diff --git a/patches/@actions__glob@0.7.0.patch b/patches/@actions__glob@0.7.0.patch new file mode 100644 index 000000000..febfce77b --- /dev/null +++ b/patches/@actions__glob@0.7.0.patch @@ -0,0 +1,16 @@ +--- a/lib/internal-pattern.js ++++ b/lib/internal-pattern.js +@@ -97,11 +97,11 @@ + partialMatch(itemPath) { + // Normalize slashes and trim unnecessary trailing slash + itemPath = pathHelper.safeTrimTrailingSeparator(itemPath); +- // matchOne does not handle root path correctly ++ // Keep the root check separate from partial path matching + if (pathHelper.dirname(itemPath) === itemPath) { + return this.rootRegExp.test(itemPath); + } +- return this.minimatch.matchOne(itemPath.split(IS_WINDOWS ? /\\+/ : /\/+/), this.minimatch.set[0], true); ++ return this.minimatch.match(itemPath, true); + } + /** + * Escapes glob patterns within a path diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a8a841098..b619c30c7 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -182,7 +182,6 @@ settings: excludeLinksFromLockfile: false overrides: - '@actions/glob@0.7.0>minimatch': 10.2.6 '@humanfs/node': 0.16.8 '@octokit/graphql': 9.0.1 '@octokit/request-error': 7.0.0 @@ -254,6 +253,7 @@ overrides: packageExtensionsChecksum: sha256-t7aflKaC02sLz7XiRIHwrlU+oApOY93sNAwB8C1uD5c= patchedDependencies: + '@actions/glob@0.7.0': c98651b472ee70df5121412c73bec2164802396f761e0c8f9e40fa957f6a5b5e '@cyclonedx/cdxgen@12.9.2': ea8b0d76a1f95182f5ca3612360ca194dd1d34acc7d11e9179f4a809c72868d6 '@rollup/plugin-commonjs@28.0.6': 4d412c02fa3df1b1f5b29b135bd3f0997f85248ceb3a578d01e7f40fba27c21b '@socketregistry/packageurl-js@1.7.0': d7dfd1df1887f1b1c7f7f623f4030a1a0533dc7b0ec6aafaf1936fe3ad36864a @@ -4662,10 +4662,6 @@ packages: resolution: {integrity: sha512-I9jwMn07Sy/IwOj3zVkVik2JTvgpaykDZEigL6Rx6N9LbMywwUSMtxET+7lVoDLLd3O3IXwJwvuuns8UB/HeAg==} engines: {node: '>=4'} - minimatch@10.2.6: - resolution: {integrity: sha512-vpLQEs+VLCr1nU0BXS07maYoFwlDAH0gngQuuttxIwutDFEMHq2blX+8vpgxDdK3J1PwjCJiep77OitTZ4Ll1A==} - engines: {node: 18 || 20 || >=22} - minimatch@11.0.9: resolution: {integrity: sha512-KCFkfyjqerNlSstjlhIGNXIKZGA/6O4V4RlhZ+Dsr621SPPw0mzlypE9D9ZOoPiVefHID+j7/XuMMlqfD/F60Q==} engines: {node: 20 || >=22} @@ -6036,7 +6032,7 @@ snapshots: dependencies: '@actions/core': 3.0.1 '@actions/exec': 3.0.0 - '@actions/glob': 0.7.0 + '@actions/glob': 0.7.0(patch_hash=c98651b472ee70df5121412c73bec2164802396f761e0c8f9e40fa957f6a5b5e) '@actions/http-client': 4.0.1 '@actions/io': 3.0.2 '@azure/core-rest-pipeline': 1.23.0(supports-color@7.2.0) @@ -6057,10 +6053,10 @@ snapshots: dependencies: '@actions/io': 3.0.2 - '@actions/glob@0.7.0': + '@actions/glob@0.7.0(patch_hash=c98651b472ee70df5121412c73bec2164802396f761e0c8f9e40fa957f6a5b5e)': dependencies: '@actions/core': 3.0.1 - minimatch: 10.2.6 + minimatch: 11.0.9 '@actions/http-client@4.0.1': dependencies: @@ -10257,10 +10253,6 @@ snapshots: min-indent@1.0.1: {} - minimatch@10.2.6: - dependencies: - brace-expansion: 5.0.13 - minimatch@11.0.9: dependencies: '@isaacs/nonrecursive-glob-match': 1.1.0 diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index c1778cd0b..7142e5e11 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -18,8 +18,6 @@ packageExtensions: dependencies: "@protobuf-ts/runtime": "^2.11.1" overrides: - # The Actions glob walker calls Minimatch.matchOne, which v11 removed. - "@actions/glob@0.7.0>minimatch": "10.2.6" "@humanfs/node": "0.16.8" "@octokit/graphql": "$@octokit/graphql" "@octokit/request-error": "$@octokit/request-error" @@ -88,6 +86,7 @@ overrides: "yaml": "2.8.1" "yargs-parser": "$yargs-parser" patchedDependencies: + "@actions/glob@0.7.0": "patches/@actions__glob@0.7.0.patch" "@socketregistry/packageurl-js@1.7.0": "patches/@socketregistry__packageurl-js@1.7.0.patch" "@socketsecurity/sdk@4.3.0": "patches/@socketsecurity__sdk@4.3.0.patch" "@cyclonedx/cdxgen@12.9.2": "patches/@cyclonedx__cdxgen@12.9.2.patch" diff --git a/test/unit/github/actions/repo/cache-downloads/index.test.mts b/test/unit/github/actions/repo/cache-downloads/index.test.mts index 55f77d331..170cee1d0 100644 --- a/test/unit/github/actions/repo/cache-downloads/index.test.mts +++ b/test/unit/github/actions/repo/cache-downloads/index.test.mts @@ -1,4 +1,4 @@ -import { mkdtemp, readFile, rm } from 'node:fs/promises' +import { mkdir, mkdtemp, readFile, rm, writeFile } from 'node:fs/promises' import { tmpdir } from 'node:os' import path from 'node:path' @@ -50,6 +50,32 @@ describe('SEA download cache action', () => { } }) + it('resolves cache directories and nested files with the installed Actions glob', async () => { + // Exercise the same resolver that saveCache uses before it uploads an archive. + const { resolvePaths } = await import( + new URL('./internal/cacheUtils.js', import.meta.resolve('@actions/cache')) + .href + ) + const workspace = await mkdtemp(path.join(tmpdir(), 'sea-cache-paths-')) + vi.stubEnv('GITHUB_WORKSPACE', workspace) + try { + const blobs = path.join(workspace, 'blobs') + const shard = path.join(blobs, 'shard') + await mkdir(shard, { recursive: true }) + await writeFile(path.join(shard, 'entry'), '') + await writeFile(path.join(shard, 'skip'), '') + expect(await resolvePaths([blobs])).toEqual(['blobs']) + expect( + await resolvePaths([ + path.join(blobs, '*', '*'), + '!' + path.join(shard, 'skip'), + ]), + ).toEqual(['blobs/shard/entry']) + } finally { + await rm(workspace, { force: true, recursive: true }) + } + }) + it('limits the cache path to content-addressed blobs', () => { const home = path.join(path.parse(process.cwd()).root, 'home', 'runner') const blobs = path.join(