-
Notifications
You must be signed in to change notification settings - Fork 459
chore: optimize CI #8199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: optimize CI #8199
Changes from all commits
826e098
62c1e2b
c02bd42
131e7b1
f883afd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| --- | ||
| # Node.js versions tested on Linux in every PR's test matrix. | ||
| # The minimum version should stay aligned with package.json `engines.node`. | ||
| # Used by: unit-tests.yml, integration-tests.yml, e2e-tests.yml | ||
| node_versions: ['20.12.2', '22', '24'] | ||
|
|
||
| # Additional operating systems added to the full test matrix on release-please | ||
| # PRs and scheduled (cron) E2E runs. Only the primary Node version (see below) | ||
| # is tested on these platforms to keep the job count manageable. | ||
| # Do NOT include ubuntu here — Linux is always covered by `node_versions` above. | ||
| # Used by: unit-tests.yml, integration-tests.yml, e2e-tests.yml | ||
| extra_oses_on_release: ['macOS-latest', 'windows-2025'] | ||
|
|
||
| # The "primary" Node.js version. Two uses: | ||
| # 1. Paired with each of `extra_oses_on_release` in the full matrix. | ||
| # 2. The pinned version for all single-version workflows. | ||
| # Must be present in `node_versions` above. | ||
| # Used by: unit-tests.yml, integration-tests.yml, e2e-tests.yml, | ||
| # release-please.yml, pre-release.yml, pre-release-sha.yml, | ||
| # benchmark.yml, lint.yml, typecheck.yml, format.yml, verify-docs.yml | ||
| primary_node_version: '24' |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,9 +20,13 @@ jobs: | |
| with: | ||
| ref: ${{ inputs.ref }} | ||
|
|
||
| - name: Read primary Node version | ||
| id: node | ||
| run: echo "version=$(yq eval '.primary_node_version' .github/test-matrix.yml)" >> "$GITHUB_OUTPUT" | ||
|
Comment on lines
+23
to
+25
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
# Verify whether commits before matrix-file introduction exist (and would fail current logic)
intro_commit=$(git log --diff-filter=A --format=%H -- .github/test-matrix.yml | head -n1 || true)
if [[ -z "${intro_commit}" ]]; then
echo "No introduction commit for .github/test-matrix.yml found in available history."
exit 0
fi
parent_commit=$(git rev-parse "${intro_commit}^")
echo "Matrix file introduced at: ${intro_commit}"
echo "Parent commit to test: ${parent_commit}"
if git cat-file -e "${parent_commit}:.github/test-matrix.yml" 2>/dev/null; then
echo "Unexpected: matrix file exists in parent commit."
else
echo "Confirmed: parent commit lacks .github/test-matrix.yml."
echo "Current pre-release-sha logic would fail for that SHA."
fiRepository: netlify/cli Length of output: 278 🏁 Script executed: #!/bin/bash
# Find when .github/test-matrix.yml was introduced using git log
git log --follow --format="%H %ai %s" -- .github/test-matrix.yml | tail -5
echo "---"
# Check if file exists in current HEAD
if [[ -f .github/test-matrix.yml ]]; then
echo "File exists in current HEAD"
head -5 .github/test-matrix.yml
else
echo "File does not exist in current HEAD"
fiRepository: netlify/cli Length of output: 419 🏁 Script executed: #!/bin/bash
# Check what would happen if yq tries to read a non-existent file
if ! command -v yq &> /dev/null; then
echo "yq not available in sandbox"
else
# Test yq behavior with non-existent file
yq eval '.primary_node_version' /nonexistent/path.yml 2>&1 || true
fiRepository: netlify/cli Length of output: 82 🏁 Script executed: #!/bin/bash
# Read the workflow file to see full context around lines 18-29
cat -n .github/workflows/pre-release-sha.yml | sed -n '15,35p'Repository: netlify/cli Length of output: 919 Handle SHAs that predate Line 23 reads config from the checked-out ref (line 18), but the file was only recently added (2026-04-23). Any older SHA will fail the Add a conditional fallback to handle missing file: Proposed fix- - name: Read primary Node version
- id: node
- run: echo "version=$(yq eval '.primary_node_version' .github/test-matrix.yml)" >> "$GITHUB_OUTPUT"
+ - name: Read primary Node version
+ id: node
+ run: |
+ if [[ -f .github/test-matrix.yml ]]; then
+ version="$(yq eval '.primary_node_version' .github/test-matrix.yml)"
+ else
+ # fallback for historical SHAs that predate the matrix file
+ version="24"
+ fi
+ echo "version=$version" >> "$GITHUB_OUTPUT"Also applies to: 29-29 🤖 Prompt for AI Agents |
||
|
|
||
| - uses: actions/setup-node@v6 | ||
| with: | ||
| node-version: '24' | ||
| node-version: ${{ steps.node.outputs.version }} | ||
| cache: npm | ||
| registry-url: 'https://registry.npmjs.org' | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use a same-repo check before expanding the integration matrix.
This branch-prefix check is spoofable on forked PRs for the same reason as in the unit workflow:
github.head_refonly carries the PR source branch name, and forkedpull_requestevents run in the base repository. Here the impact is larger because each extra OS also fans out across 4 shards. (docs.github.com)🔧 Suggested guard
- name: Compute matrix id: matrix env: HEAD_REF: ${{ github.head_ref }} + HEAD_REPO: ${{ github.event.pull_request.head.repo.full_name }} + BASE_REPO: ${{ github.repository }} run: | node_versions=$(yq eval '.node_versions | join(" ")' .github/test-matrix.yml) extra_oses=$(yq eval '.extra_oses_on_release | join(" ")' .github/test-matrix.yml) primary=$(yq eval '.primary_node_version' .github/test-matrix.yml) OS_NODE=() for node in $node_versions; do OS_NODE+=("ubuntu-latest:$node") done - if [[ "$HEAD_REF" == release-please--* ]]; then + if [[ "$HEAD_REPO" == "$BASE_REPO" && "$HEAD_REF" == release-please--* ]]; then for os in $extra_oses; do OS_NODE+=("$os:$primary") done fi📝 Committable suggestion
🤖 Prompt for AI Agents