feat: cache the verified dprint download when caching is enabled - #28
Merged
Conversation
With `cache: true`, the downloaded zip is cached per version and platform. On a hit, its digest is checked against the release's digest from the GitHub API, which is fetched anyway when resolving the version, and the attestation verification is skipped since the same bytes were verified when they were first cached. That takes the install from about 5 seconds to 1.5. Also updates the README to actions/checkout@v7.
…sted version Also skips the release lookup when caching is disabled since the download step gets the latest release itself, sends the token on the curl fallback, and adds a `dprint-version` output that the tests assert on.
…oads GNU sha256sum prefixes its output with a backslash when the file name contains one, which every Windows path does, so the cached download never matched the release's digest on Windows and was re-downloaded every run. Hashing via stdin avoids the escaping. Also only saves a download that was attestation verified, includes the asset's digest in the cache key so a re-uploaded asset gets its own entry, and logs when a cached download is discarded.
A second job could land on a runner with different cpu features, which compiles its own plugin variants and changes the cache, and re-running only the failed jobs lost the entry the first job saved because the unique config includes the run attempt.
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.
With
cache: true, the downloaded zip is cached per version and platform under the keydprint-executable-{os}-{arch}-{version}.gh release viewcall (0.4s) returns the latest tag and every asset's SHA-256 digest, so the exact cache key is known before the restore and "latest" stays correct.Verified locally by simulating miss, hit, tampered hit, an unattested pinned version, a version without digests, and verification disabled. Hit path is about 1.5 seconds instead of 5.
Also updates the README to
actions/checkout@v7.