Skip to content

Optimize CI: Add shfmt binary caching #62

@maxrantil

Description

@maxrantil

Context

The shfmt job downloads the shfmt binary on every CI run, taking 10-15 seconds.

Problem

Redundant downloads: Binary is downloaded fresh every time:

- name: Install shfmt
  run: |
    wget -O shfmt https://github.com/mvdan/sh/releases/download/v3.7.0/shfmt_v3.7.0_linux_amd64
    chmod +x shfmt
    sudo mv shfmt /usr/local/bin/

Impact: Wasted CI time and bandwidth (minor but avoidable)

Recommended Solution

Add GitHub Actions caching:

- name: Cache shfmt binary
  uses: actions/cache@v4
  id: cache-shfmt
  with:
    path: ~/.local/bin/shfmt
    key: shfmt-v3.7.0-${{ runner.os }}

- name: Install shfmt
  if: steps.cache-shfmt.outputs.cache-hit \!= 'true'
  run: |
    mkdir -p ~/.local/bin
    wget -O ~/.local/bin/shfmt https://github.com/mvdan/sh/releases/download/v3.7.0/shfmt_v3.7.0_linux_amd64
    chmod +x ~/.local/bin/shfmt

- name: Add shfmt to PATH
  run: echo "$HOME/.local/bin" >> $GITHUB_PATH

Benefits

  • Time savings: 10-15 seconds per CI run (on cache hit)
  • Bandwidth reduction: Download only when version changes
  • Cost efficiency: Marginal but good practice

Storage Impact

~10MB cached binary (negligible)

Estimated Effort

10-15 minutes (simple YAML change)

Priority

Low - Nice optimization, not critical

References

  • Agent: devops-deployment-agent (recommended this optimization)
  • File: .github/workflows/shell-quality.yml

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions