Repository navigation
feat: download trunk-analytics-cli from trunk.io (GitHub as fallback), cache by default - #151
Merged
Merged
Conversation
…leases Resolve `latest` from trunk.io/releases/analytics-cli/prod/channel.json once, and use that concrete version for both the cache key and the download. Check each download against the version's manifest.json sha256. A 403/404 from the releases host means the version is not published, so it fails fast without retries. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
When trunk.io cannot serve the CLI (an unreachable channel.json, a network error, a 5xx, a 403/404, or a failed sha256 check), download it from GitHub releases instead and warn with the trunk.io error. For `latest` that goes through GitHub's /releases/latest redirect and /latest/download/. The use-cache input now defaults to true. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
dfrankland
marked this pull request as ready for review
October 2, 2026 20:58
dfrankland
requested review from
EliSchleifer,
TylerJang27,
acatxnamedvirtue,
mmatheson and
pat-trunk-io
October 2, 2026 20:59
… be resolved Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
acatxnamedvirtue
approved these changes
Oct 2, 2026
TylerJang27
approved these changes
Oct 3, 2026
| handler: repoReleasesVersionDownloadHandler, | ||
| mock: repoReleasesVersionDownloadMock, | ||
| } = MSW_MOCKS.repoReleasesVersionDownload(cliVersion) | ||
| it("uses the cache when use-cache is not set", async () => { |
Collaborator
There was a problem hiding this comment.
new behavior. Sanity check that this is intentional?
Member
Author
There was a problem hiding this comment.
I wanted to make caching the default behavior. This should be checking that we default to using the cache if use-cache is not set.
| expect(githubDownloadMock).not.toHaveBeenCalled(); | ||
| }); | ||
|
|
||
| it("falls back to GitHub's pinned download when trunk.io does not have the version", async () => { |
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.
What
The action now downloads
trunk-analytics-clifrom our own release host,https://trunk.io/releases/analytics-cli/prod. GitHub releases are kept only as a fallback. Caching the CLI is now on by default.trunk.io first
latestis resolved once, up front, fromchannel.json({"latest":"x.y.z"}). The cache key and the download use that version.${base}/${version}/${artifact}. Artifact names are unchanged.${base}/${version}/manifest.json. The tarball's sha256 has to matchartifacts[<filename>].sha256. This check applies only to the trunk.io source.s3:ListBucket. That answer is deterministic, so we go straight to the fallback. Network errors and 5xx responses are retried first.GitHub releases as the fallback
GitHub is used whenever trunk.io cannot serve the CLI:
channel.jsonis unreachable, a network error or 5xx outlasts the retries, the version is not published there (403/404), or the sha256 does not match. Each time, acore.warningnames the trunk.io failure.latest: GitHub's/releases/latestredirect resolves the version, which sets the cache key, and the binary comes from/latest/download/<artifact>. If GitHub can't resolve it either, the version falls back toDEFAULT_CLI_VERSION, now 0.16.0 (was 0.15.4).latestthat trunk.io resolved: the binary comes from/download/<ver>/<artifact>.Caching on by default
use-cachenow defaults totrueinaction.yaml, and an absent input means caching is on insrc/inputs.ts.false(or any value other thantrue) turns it off.The fetching and resolution code moved from
cache.tsandlib.tsintosrc/release.ts.dist/is rebuilt.Merge order: do not merge until the backfill has run
Land trunk-io/analytics-cli#1216 first, and run its backfill of existing GitHub releases. With the GitHub fallback, an early merge no longer breaks pinned versions or the
0.16.0default. They download from GitHub instead, but every run logs a fallback warning and stays on GitHub's rate limits until the host is populated.Testing
jest: 61 tests pass.__tests__/download.test.tscovers:channel.jsonthat resolves through GitHub's redirect and downloads/latest/download/;cache.test.tsadds "uses the cache when use-cache is not set".tsc --noEmit,eslint src __tests__ __fixtures__,trunk checkandtrunk fmt: clean.🤖 Generated with Claude Code