Repository navigation
Fix: Scope cache to path_prefix and use actions/attest - #277
Merged
ModeSevenIndustrialSolutions merged 2 commits intoOct 1, 2026
Conversation
ModeSevenIndustrialSolutions
force-pushed
the
fix/cache-path-prefix-and-attest
branch
from
October 1, 2026 10:40
853aad1 to
2515ce4
Compare
ModeSevenIndustrialSolutions
force-pushed
the
fix/cache-path-prefix-and-attest
branch
from
October 1, 2026 10:46
2515ce4 to
918f801
Compare
ModeSevenIndustrialSolutions
force-pushed
the
fix/cache-path-prefix-and-attest
branch
from
October 1, 2026 10:59
918f801 to
aa74f21
Compare
ModeSevenIndustrialSolutions
marked this pull request as ready for review
October 1, 2026 11:04
ModeSevenIndustrialSolutions
marked this pull request as draft
October 1, 2026 11:05
ModeSevenIndustrialSolutions
marked this pull request as ready for review
October 1, 2026 14:35
ModeSevenIndustrialSolutions
force-pushed
the
fix/cache-path-prefix-and-attest
branch
2 times, most recently
from
October 1, 2026 14:39
aa74f21 to
b47db11
Compare
The cache step ignored path_prefix. Its key hashed dependency files across the whole workspace, so unrelated projects, fixtures and even files inside the cached .tox directory changed it, while tox.ini, which governs the .tox contents, was missing. Its .tox and .venv paths were relative to the workspace root, but tox --root <path_prefix> creates .tox under path_prefix, so for any project in a subdirectory the tox environments were never saved or restored. Add scripts/cache-paths.sh, which derives both cache inputs from path_prefix: - tox_path, the project's .tox as an actions/cache path. actions/cache reads path as @actions/glob patterns, so it is canonical and relative to the workspace (no "." or ".." segment trips the matcher, and each directory gets one cache version), anchored with "./" so a leading "!" or "#" stays literal, and escaped as globEscape() does so a directory named glob[1] cannot match glob1. - deps_hash, a SHA-256 over the project's pyproject.toml, setup.py, setup.cfg, requirements*.txt and tox.ini. hashFiles() does not fit: it also reads its arguments as glob patterns, and it skips every file outside GITHUB_WORKSPACE, which would freeze the key for a project there. The script resolves directories with cd -P and reads PWD, so a symlink cannot defeat the workspace comparison and no command substitution strips a trailing newline from the name. It rejects a path containing a line break, which would split the pattern list and the step output, and writes its outputs with printf, because echo would expand the escaping's backslashes under an inherited xpg_echo. Drop .venv, ~/.cache/pypoetry and ~/.cache/pipenv, which nothing in the action creates, and poetry.lock and Pipfile* from the key. Add runner.arch to the key and restore keys, so x64 and arm64 runners on the same OS stop sharing architecture-specific tox environments. tests/test_cache_paths.sh covers equivalent spellings, glob and leading "!" or "#" names beside decoys, symlinked paths, a project outside the workspace, line breaks, and an inherited CDPATH or xpg_echo. A new job in the testing workflow runs it. The new paths give the cache a new version, so existing entries will not restore; the first run on each branch repopulates them. Reported in lfreleng-actions#273. Co-authored-by: Claude <noreply@anthropic.com> Signed-off-by: Matthew Watkins <mwatkins@linuxfoundation.org>
As of v4, actions/attest-build-provenance is a thin composite wrapper around actions/attest, and GitHub advises new implementations to use actions/attest directly. The wrapper forwards every input unchanged; with no predicate inputs, actions/attest emits SLSA build provenance, so the attestations this action produces do not change. The wrapper also sets NODE_OPTIONS to raise node's HTTP header limit, which matters only when pushing attestations to an OCI registry. This action never sets push-to-registry, so nothing needs carrying across. The subject-path input and the caller's id-token: write and attestations: write permissions stay as they are. Pin 1e69f48 is v4.2.2 of actions/attest, verified as a commit object rather than an annotated tag, matching lfreleng-actions/node-workflows. Reported in lfreleng-actions#249. Co-authored-by: Claude <noreply@anthropic.com> Signed-off-by: Matthew Watkins <mwatkins@linuxfoundation.org>
ModeSevenIndustrialSolutions
force-pushed
the
fix/cache-path-prefix-and-attest
branch
from
October 1, 2026 14:47
b47db11 to
7f819cb
Compare
zxiiro
approved these changes
Oct 1, 2026
zxiiro
left a comment
Contributor
There was a problem hiding this comment.
🤖 Auto-approved by agent: reviewed workflow/code change for security and CI/CD impact, found low risk. Scopes pip/.tox cache to path_prefix via a hardened cache-paths.sh (glob-escapes, rejects newlines) and swaps attest-build-provenance for actions/attest at a pinned SHA; no widened permissions.
ModeSevenIndustrialSolutions
merged commit Oct 1, 2026
3cdb6f8
into
lfreleng-actions:main
12 checks passed
ModeSevenIndustrialSolutions
deleted the
fix/cache-path-prefix-and-attest
branch
October 2, 2026 10:15
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.


Closes #273
Closes #249
Commits
7c1bb317f819cbThe two commits are independent: each closes one issue, and they change
different steps of
action.yaml.#273: Cache key and paths ignore
path_prefixProblem
The
Cache Python dependenciesstep was the only step in the action thatignored
path_prefix:**/patterns hashed dependency files across the wholeworkspace, so unrelated projects, fixtures, and even files inside the
cached
.toxdirectory changed it.tox.ini, which governs the.toxcontents, was missing.
.toxand.venvwere relative to the workspace root, buttox --root "$path_prefix"creates.toxunderpath_prefix. For anyproject in a subdirectory, the tox environments were never saved or
restored.
I confirmed the key problem with the runner's own
hashFiles()matching(
@actions/glob0.7.0, the versionactions/runnerbundles), against afixture workspace with project
sub/beside an unrelatedother/:other/pyproject.toml,other/setup.py,pyproject.toml,sub/.tox/build/pyproject.toml,sub/docs/requirements.txt,sub/pyproject.toml,sub/requirements*.txt,sub/setup.cfgsub/pyproject.toml,sub/requirements-dev.txt,sub/requirements.txt,sub/setup.cfg,sub/tox.iniFix
A new script,
scripts/cache-paths.sh, runs as theDerive cache locations from path_prefixstep and emits both cacheinputs:
tox_path, the project's.toxas anactions/cachepath.actions/cachereadspathas@actions/globpatterns(
resolvePaths()), so the path has to match that directory and nothingelse. It is:
sub,sub/,./sub,x/../sub, an absolute path and a path through a symlink all become./sub/.tox. No.or..segment reaches@actions/glob, whichrejects those outright. Each directory also gets one cache version,
because
actions/cacheversions entries by the literal path strings(
getCacheVersion())../, so a leading!or#is not read as anegation or a comment.
@actions/glob's ownPattern.globEscape()does it(
\,[,?,*), soglob[1]cannot matchglob1.deps_hash, a SHA-256 over the project'spyproject.toml,setup.py,setup.cfg,requirements*.txtandtox.ini, computed inthe script.
hashFiles()doesn't fit here: it reads its arguments asglob patterns too, and it skips every file outside
GITHUB_WORKSPACE.For a project there, the key would never change.
The script resolves directories with
cd -Pand reads$PWD, not$(pwd). That way a symlink on either side cannot defeat the workspacecomparison, and command substitution cannot strip a trailing newline,
which would turn a directory named
project\ninto the unrelatedproject. A path containing CR or LF fails the step, because eitherwould split the pattern list and the step's output file. Outputs are
written with
printf, notecho: under an inheritedxpg_echoshelloption (
BASHOPTS=xpg_echo),echowould expand the backslashes theescaping adds.
Also:
~/.cache/pipand the project's.tox..venv,~/.cache/pypoetryand~/.cache/pipenvare gone: nothing in theaction creates them.
runner.archis now in the key and the restore keys, so x64 and arm64runners on the same OS no longer share architecture-specific tox
environments. (
python-audit-actionalready does this.)Tests
tests/test_cache_paths.sh(plain bash, in the style ofnexus-publish-action/tests/test_publish.sh) has 13 tests. A newTest cache path derivationjob runs it; it needs no repositoryvariables, so it also runs on fork PRs. It covers:
glob[1],a*b,a?band a backslash beside their decoys, for bothpath and hash
!and#nested files and
.toxcontents don'tfiles
project\n,pro\nject,project\r): rejected, withnothing written to the step output
CDPATHxpg_echoImpact
The changed paths give the cache a new version, so existing entries will
not restore. The first run on each branch repopulates them. The key
format also changes, from
python-<os>-<py>-…topython-<os>-<arch>-<py>-…. That matters only to anyone filtering on itwith the
Clear Action Cache 🧹workflow'skey_patterninput.#249: Migrate from
attest-build-provenancetoattestA like-for-like swap of the
uses:line:action.ymlat the old pin. It forwards everyinput to
actions/attestunchanged. With nopredicate-typeorpredicate,actions/attestemits SLSA build provenance by default, sothe output does not change.
NODE_OPTIONS: --max-http-header-size=32768, asthis issue's follow-up comment notes. That only matters for
push-to-registry, which this action never sets, so nothing needscarrying across.
subject-pathand the caller'sid-token: writeandattestations: writepermissions are unchanged.1e69f48is a commit SHA, not a tag object(
GET /repos/actions/attest/git/ref/tags/v4.2.2→type: commit). Itis the same pin
lfreleng-actions/node-workflows#57adopted.SBOM attestation (
sbom-path), which the issue mentions as optional, isleft for its own issue to keep this change atomic.
Validation
bash tests/test_cache_paths.sh: all 13 tests pass, under bash 5.3and under bash 3.2 (the macOS system shell).
scripts/cache-paths.sh12 ways in ascratch copy, one at a time: dropping the escaping (all of it, or
[or
*alone), the./anchor, the line-break check,-P, the CDPATHguard, or the workspace-root case; capturing the path with
$(pwd);leaving
tox.iniorrequirements*.txtout of the hash; and hashingfrom the workspace. The suite caught all 12. Separately, the
xpg_echotest fails against the earlierechoversion of thescript, on exactly the
back\slashassertion.tox_pathstring the tests assert through@actions/glob0.7.0, in a workspace with decoys (
glob1,axb,bang,backslash). Each matched exactly its own.tox.@actions/cachegetCacheVersion()andresolvePaths(), and therunner's
hashFiles.ts, to confirm literal-path versioning, globhandling of
path, and thathashFiles()skips files outside theworkspace.
prek run --fileson each commit's files: passed, includingshellcheckandreuseon the new scripts.zizmor --persona auditor action.yaml .github/workflows/testing.yaml:no findings.
aislop-gate.sh upstream/main: clean (5 files gated).Not covered by CI on this PR: attestation needs
id-token: writeand areal artefact build, which the fork-PR test job does not have.