Skip to content

Skip setup-node when requested version already installed#40442

Closed
Copilot wants to merge 4 commits intomainfrom
copilot/add-version-check-before-setup-node
Closed

Skip setup-node when requested version already installed#40442
Copilot wants to merge 4 commits intomainfrom
copilot/add-version-check-before-setup-node

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 13, 2026

On ubuntu-slim runners, setup-node with version patterns like 24.x downloads the latest patch version instead of using the cached version, causing unnecessary network overhead (actions/setup-node#1492).

Changes

Modified .github/actions/setup-node-install-deps/action.yaml:

  • Added version check step: Runs node -v and compares with requested version before calling setup-node
  • Conditional setup-node execution: Skips setup-node when current version matches requested pattern
  • Version pattern handling:
    • Major only ("24"): matches any 24.x.x
    • Major.x ("24.x"): matches any 24.x.x
    • Exact ("24.13.0"): requires exact match
    • Empty string: uses current version without setup
- id: check-node-version
  run: |
    CURRENT_VERSION=$(node -v 2>/dev/null || echo "")
    CURRENT_VERSION=${CURRENT_VERSION#v}
    
    # Compare versions and set skip-setup=true if match
    # ... version comparison logic ...

- if: steps.check-node-version.outputs.skip-setup != 'true'
  uses: actions/setup-node@v4
  with:
    node-version: ${{ inputs.node-version }}

Existing npm install and dependency management behavior unchanged.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Workaround for actions/setup-node#1492 where specifying node-version on ubuntu-slim
triggers unnecessary downloads instead of using cached versions. This change:

- Adds a check-node-version step that compares current Node version with requested version
- Skips setup-node call if versions match (handles "24", "24.x", and "24.13.0" patterns)
- Reduces build time by avoiding slow downloads on ubuntu-slim runners

Co-authored-by: mikeharder <9459391+mikeharder@users.noreply.github.com>
@github-actions
Copy link
Copy Markdown

github-actions bot commented Feb 13, 2026

Next Steps to Merge

⌛ Please wait. Next steps to merge this PR are being evaluated by automation. ⌛

Comment generated by summarize-checks workflow run.

Copilot AI and others added 2 commits February 13, 2026 08:51
Changes based on code review:
- Use empty string instead of "none" sentinel value for missing Node
- Add explicit comment explaining two separate regex checks
- Simplify logic by using empty string checks consistently

Co-authored-by: mikeharder <9459391+mikeharder@users.noreply.github.com>
- Restructure version extraction to ensure fallback works correctly
- Use CURRENT_VERSION=${CURRENT_VERSION#v} instead of sed in pipe
- Apply Prettier formatting (remove trailing spaces)

Co-authored-by: mikeharder <9459391+mikeharder@users.noreply.github.com>
Copilot AI changed the title [WIP] Add version check before calling setup-node Skip setup-node when requested version already installed Feb 13, 2026
Copilot AI requested a review from mikeharder February 13, 2026 08:55
@mikeharder mikeharder moved this from 🤔 Triage to 🔬 Dev in PR in Azure SDK EngSys 🚀🌒🧑‍🚀 Feb 13, 2026
@mikeharder mikeharder closed this Feb 13, 2026
@github-project-automation github-project-automation bot moved this from 🔬 Dev in PR to 🎊 Closed in Azure SDK EngSys 🚀🌒🧑‍🚀 Feb 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

2 participants