Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 20, 2025

The setup-node action fails with "Some specified paths were not resolved" when get-package-manager is invoked from external composite actions (e.g., hoverkraft-tech/ci-github-common). The glob package requires cache paths within GITHUB_WORKSPACE, but external actions run from /__w/_actions/....

Changes

actions/get-package-manager/action.yml

  • Detect when working directory is outside GITHUB_WORKSPACE (relative path starts with ../)
  • Create a symlink (.github-actions-cache) inside GITHUB_WORKSPACE pointing to the external directory
  • Use symlink path for cache dependencies, maintaining caching functionality
  • Graceful fallback to disable caching if symlink creation fails

actions/setup-node/action.yml

  • Conditionally enable caching only when cache-dependency-path is non-empty
  • Gracefully disables caching for external composite actions (fallback scenario)

Behavior

# Inside GITHUB_WORKSPACE (unchanged)
cache-dependency-path: "tests/npm/**/package-lock.json"
cache: "npm"

# Outside GITHUB_WORKSPACE (new - with symlink)
cache-dependency-path: ".github-actions-cache/**/package-lock.json"
cache: "npm"

# Outside GITHUB_WORKSPACE (fallback - symlink creation fails)
cache-dependency-path: ""
cache: ""

Existing workflows unaffected. External composite actions now maintain full caching functionality through symlinks, with automatic fallback if needed.

Original prompt

On action.yml, Cache dependency path must be inside GITHUB_WORKSPACE

because of setup-node action iss using glob package and its having this constraint: https://github.com/actions/toolkit/blob/main/packages/glob/src/internal-hash-files.ts#L23

Sadlyu when using an external composite action that using get-package-manager, the cache depency path is something like this:

cache-dependency-path: /__w/_actions/hoverkraft-tech/ci-github-common/d95c78dc4b10250a07e227d3ddf33b0ea093e28d/actions/parse-ci-reports/**/package-lock.json

So when using this path with setup-nde action, we have this error:

Error: Some specified paths were not resolved, unable to cache dependencies.

We must find a way to manage this case


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Fix cache dependency path for setup-node action Fix cache-dependency-path for actions outside GITHUB_WORKSPACE Nov 20, 2025
Copilot AI requested a review from neilime November 20, 2025 15:55
Copy link
Member

@neilime neilime left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot, will it possible to maintain cache feature using symlink for path outside workspace?

Copy link
Contributor Author

Copilot AI commented Nov 20, 2025

@copilot, will it possible to maintain cache feature using symlink for path outside workspace?

Yes! Great suggestion. I've implemented a symlink approach in commit b65dbeb. When the working directory is outside GITHUB_WORKSPACE, the action now creates a symlink named .github-actions-cache inside the workspace pointing to the external directory. This allows setup-node to cache dependencies while respecting the glob package constraints. If symlink creation fails, it gracefully falls back to disabling caching.

Copilot AI changed the title Fix cache-dependency-path for actions outside GITHUB_WORKSPACE Maintain cache for actions outside GITHUB_WORKSPACE using symlinks Nov 20, 2025
Copilot AI requested a review from neilime November 20, 2025 16:10
@github-actions
Copy link
Contributor

github-actions bot commented Nov 20, 2025

Code Coverage Report

Summary

Summary
Generated on: 11/20/2025 - 16:24:14
Parser: LCov
Assemblies: 1
Classes: 1
Files: 1
Line coverage: 100% (2 of 2)
Covered lines: 2
Uncovered lines: 0
Coverable lines: 2
Total lines: 5
Method coverage: Feature is only available for sponsors
Tag: 526_19543299942

Coverage

Default - 100%
Name Line
Default 100%
src/index.js 100%

@neilime neilime marked this pull request as ready for review November 20, 2025 16:27
@neilime neilime changed the title Maintain cache for actions outside GITHUB_WORKSPACE using symlinks fix(setup-node): maintain cache for projects outside GITHUB_WORKSPACE using symlinks Nov 20, 2025
@neilime neilime merged commit 29d543f into main Nov 20, 2025
72 of 77 checks passed
@neilime neilime deleted the copilot/fix-cache-dependency-path branch November 20, 2025 16:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants