Repository navigation
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
Draft
feat: CI tool installs cache their release downloads, retry them, and verify against pinned sha256#117TzuH-Hsu wants to merge 1 commit into
TzuH-Hsu wants to merge 1 commit into
Conversation
… 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
make ci-toolsno longer fails the wholecijob when GitHub's release downloads return 5xx. The release assets it downloads (actionlint, gitleaks, lychee) are kept in anactions/cacheentry, every download retries, and every asset, cached or downloaded, is checked against a sha256 pinned in this repository.ACTIONLINT_SHA256,GITLEAKS_SHA256andLYCHEE_SHA256sit next to the version pins inscripts/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.shreads only the_VERSIONlines, so it is unaffected; its drift message now says to bump the sha256 pin in the same PR.verify_pinnedreplacesverify_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.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.CI_TOOLS_CACHE_DIRset, the installer keeps<owner>/<repo>/<tag>/<asset>, one version per tool, verified assets only.ci.ymlrestores${{ runner.temp }}/ci-tools-cachewithactions/cache/restorebeforeInstall CI toolsand saves it withactions/cache/saveright 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 isci-tools-<os>-<arch>-plus a hash of everyscripts/install-*.shandscripts/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 (norestore-keys).maintenance.yml: restores the same entry beforeInstall lycheeand saves nothing, since it installs lychee alone.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-hygienerule 8 and its snippet (verify against a pin, not a fetched checksum file), and thedocs/template/architecture.mdledger row.Related issue
Closes #116
Reviewer guide
fetch_release_asset,downloadandverify_pinnedinscripts/install-ci-tools.sh, then the three steps aroundInstall CI toolsin.github/workflows/ci.yml: the key, and theifon the save step.scripts/install-ci-tools.test.jsruns the installer against a fakecurlanduname; the tampered-cache cases are the twoa tampered cached asset …tests. The last two tests keep the restore keys ofci.ymlandmaintenance.ymlequal.maintenance.yml,check-tool-versions.sh(one message line), the three docs.For adopters: this changes
scripts/install-ci-tools.sh,ci.ymlandmaintenance.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 usesCI_TOOLS_CACHE_DIRthe 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.make lint(markdownlint-cli2 0.23.3, yamllint, lychee--offline, actionlint, gitleaks);shellcheckoninstall-ci-tools.shandcheck-tool-versions.shmake check, with 12 new tests inscripts/install-ci-tools.test.js; before the installer change all 12 failedcirun installs the tools for real on a cache miss: each asset is downloaded once, matches its pin, and the entry is savedfrom the cache (...), not downloadedfor each assetRisk / rollback
Checklist
Before merging:
<type>: <description>)*.local.mdfiles committed