Skip to content

feat: CI tool installs cache their release downloads, retry them, and verify against pinned sha256 - #117

Draft
TzuH-Hsu wants to merge 1 commit into
mainfrom
feat/116-ci-tool-download-cache
Draft

TzuH-Hsu wants to merge 1 commit into
mainfrom
feat/116-ci-tool-download-cache

Conversation

@TzuH-Hsu

Copy link
Copy Markdown
Owner

Summary

make ci-tools no longer fails the whole ci job when GitHub's release downloads return 5xx. The release assets it downloads (actionlint, gitleaks, lychee) are kept in an actions/cache entry, every download retries, and every asset, cached or downloaded, is checked against a sha256 pinned in this repository.

  • sha256 pins: ACTIONLINT_SHA256, GITLEAKS_SHA256 and LYCHEE_SHA256 sit next to the version pins in scripts/install-ci-tools.sh, same one-per-line shape. The values are the asset lines of each release's checksum file at the pinned versions. check-tool-versions.sh reads only the _VERSION lines, so it is unaffected; its drift message now says to bump the sha256 pin in the same PR.
  • Verification: verify_pinned replaces verify_checksum. The installer no longer downloads the release's checksum file, and the cache never holds one, so whoever can write a cache entry cannot make a different asset pass. A cached asset that does not match is deleted and downloaded again; a download that does not match fails the step and prints the checksum file's URL to take a new pin from.
  • Retries: each download is curl -fsSL --retry 5 --retry-all-errors --retry-delay 10 --connect-timeout 30 --max-time 300. That rides out a blip of about a minute; the cache covers longer outages.
  • Cache: with CI_TOOLS_CACHE_DIR set, the installer keeps <owner>/<repo>/<tag>/<asset>, one version per tool, verified assets only. ci.yml restores ${{ runner.temp }}/ci-tools-cache with actions/cache/restore before Install CI tools and saves it with actions/cache/save right after when the key was not restored, so a run that fails later still leaves its downloads. Both are pinned to the v6.1.0 commit. The key is ci-tools-<os>-<arch>- plus a hash of every scripts/install-*.sh and scripts/tool-* file, so an adopter's own installer and pin files (scripts/tool-pins.extra) are covered without editing the workflow; only that exact key is restored (no restore-keys).
  • maintenance.yml: restores the same entry before Install lychee and saves nothing, since it installs lychee alone.
  • Unset CI_TOOLS_CACHE_DIR (local runs): no cache, everything else the same.

Not cached: markdownlint-cli2 and yamllint, which come from npm and PyPI rather than GitHub's release downloads; npm and pip retry on their own.

Docs: a "Download cache for the CI tools" section in docs/setup/runners.md (including how an adopter's own installer can share the cache), skills/github-actions-hygiene rule 8 and its snippet (verify against a pin, not a fetched checksum file), and the docs/template/architecture.md ledger row.

Related issue

Closes #116

Reviewer guide

  • Start with fetch_release_asset, download and verify_pinned in scripts/install-ci-tools.sh, then the three steps around Install CI tools in .github/workflows/ci.yml: the key, and the if on the save step.
  • scripts/install-ci-tools.test.js runs the installer against a fake curl and uname; the tampered-cache cases are the two a tampered cached asset … tests. The last two tests keep the restore keys of ci.yml and maintenance.yml equal.
  • Mechanical: maintenance.yml, check-tool-versions.sh (one message line), the three docs.

For adopters: this changes scripts/install-ci-tools.sh, ci.yml and maintenance.yml. A repository that bumped a kit tool past the template's pin needs that tool's sha256 pin at its own version when taking this. An adopter installer for extra tools keeps working unchanged and is not cached until it uses CI_TOOLS_CACHE_DIR the same way.

Validation

Pick validation depth by blast radius. A level that applies but could not run becomes a RISK: line below. See AGENTS.md for the validation ladder.

  • L0 static — make lint (markdownlint-cli2 0.23.3, yamllint, lychee --offline, actionlint, gitleaks); shellcheck on install-ci-tools.sh and check-tool-versions.sh
  • L1 unit — make check, with 12 new tests in scripts/install-ci-tools.test.js; before the installer change all 12 failed
  • L2 integration — this PR's ci run installs the tools for real on a cache miss: each asset is downloaded once, matches its pin, and the entry is saved
  • L3 e2e / preview — a later run with the same key restores the entry and prints from the cache (...), not downloaded for each asset

Risk / rollback

RISK: L2/L3 not run locally — the tarball tools are linux x86_64 only; this PR's CI runs are the integration evidence
RISK: a kit tool version bump without its sha256 pin fails CI until the pin is added from the release's checksum file
RISK: a pin change misses the cache once (exact key only), so a release-download outage at that moment still fails that run
RISK: the entry counts against the repository's Actions cache quota, which GitHub evicts on its own; it is a few tens of MB
Rollback: revert this PR; the installer goes back to downloading the asset and its checksum file every run

Checklist

Before merging:

  • Conventional Commit PR title (<type>: <description>)
  • Linked issue using "Closes #N"
  • No secrets, no *.local.md files committed
  • Documentation updated where affected

… pinned sha256

GitHub release downloads intermittently return 5xx, and every CI run
downloads actionlint, gitleaks and lychee from there with a single curl.

- install-ci-tools.sh: <TOOL>_SHA256 pins next to the version pins; every
  asset is checked against its pin, never against a checksum file fetched
  alongside it. Downloads retry (curl --retry 5 --retry-all-errors).
  CI_TOOLS_CACHE_DIR keeps verified assets between runs; a cached asset
  that does not match its pin is deleted and downloaded again.
- ci.yml restores and saves that directory with actions/cache (exact key:
  runner OS and arch plus a hash of scripts/install-*.sh and
  scripts/tool-*); maintenance.yml restores only.
- scripts/install-ci-tools.test.js runs the installer against a fake curl.
- Docs: runners.md, github-actions-hygiene rule 8, architecture.md.
@TzuH-Hsu TzuH-Hsu added the area:ci CI workflows and automation label Nov 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:ci CI workflows and automation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Task: CI tool installs fail whenever GitHub's release downloads return 5xx — cache the assets, retry, verify against pinned sha256

1 participant