Repository navigation
perf(ci): Restore grouped dependencies in CI test jobs #26901
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
Closed
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,30 +1,45 @@ | ||
| name: 'Install pnpm dependencies' | ||
| description: 'Installs pnpm dependencies and caches them.' | ||
|
|
||
| name: Install pnpm dependencies | ||
| description: Installs pnpm dependencies and caches them. | ||
| outputs: | ||
| cache_key: | ||
| description: 'The dependency cache key' | ||
| description: The dependency cache key | ||
| value: ${{ steps.compute_lockfile_hash.outputs.hash }} | ||
|
|
||
| runs: | ||
| using: 'composite' | ||
| using: composite | ||
| steps: | ||
| - name: Install pnpm | ||
| uses: ./.github/actions/install-pnpm | ||
|
|
||
| - name: Compute dependency cache key | ||
| id: compute_lockfile_hash | ||
| run: node ./scripts/dependency-hash-key.js >> "$GITHUB_OUTPUT" | ||
| shell: bash | ||
|
|
||
| - name: Compute selected dependency cache key | ||
| id: group | ||
| if: inputs.group != '' | ||
| env: | ||
| DEPENDENCY_GROUP: ${{ inputs.group }} | ||
| DEPENDENCY_HASH: ${{ steps.compute_lockfile_hash.outputs.hash }} | ||
| run: node "$GITHUB_ACTION_PATH/groups.mjs" key "$DEPENDENCY_GROUP" "$DEPENDENCY_HASH" >> "$GITHUB_OUTPUT" | ||
| shell: bash | ||
| - name: Restore selected workspace dependencies | ||
| id: selected | ||
| if: inputs.group != '' | ||
| uses: actions/cache/restore@v6.1.0 | ||
| with: | ||
| path: ${{ env.CACHED_DEPENDENCY_PATHS }} | ||
| key: ${{ steps.group.outputs.key }} | ||
| - name: Check dependency cache | ||
| uses: actions/cache@v6.1.0 | ||
| id: cache_dependencies | ||
| with: | ||
| path: ${{ env.CACHED_DEPENDENCY_PATHS }} | ||
| key: ${{ steps.compute_lockfile_hash.outputs.hash }}-${{ runner.arch }} | ||
|
|
||
| if: inputs.group == '' || steps.selected.outputs.cache-hit != 'true' | ||
| - name: Install dependencies | ||
| if: steps.cache_dependencies.outputs.cache-hit != 'true' | ||
| if: steps.selected.outputs.cache-hit != 'true' && steps.cache_dependencies.outputs.cache-hit != 'true' | ||
| run: pnpm install --frozen-lockfile | ||
| shell: bash | ||
| inputs: | ||
| group: | ||
| description: Optional dependency group; fall back to the full workspace cache on a miss. | ||
| default: '' |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| import { createHash } from 'node:crypto'; | ||
| import fs from 'node:fs'; | ||
|
|
||
| const workspaces = JSON.parse(fs.readFileSync('package.json', 'utf8')).workspaces; | ||
| const sdk = workspaces.filter(directory => directory.startsWith('packages/')); | ||
| const serverTests = [ | ||
| 'dev-packages/node-integration-tests', | ||
| 'dev-packages/bun-integration-tests', | ||
| 'dev-packages/deno-integration-tests', | ||
| 'dev-packages/bundler-plugin-integration-tests', | ||
| ]; | ||
| const browserTests = ['dev-packages/browser-integration-tests', 'dev-packages/browser-min-version-tests']; | ||
| const groups = { | ||
| sdk: [...sdk, 'dev-packages/test-utils', 'dev-packages/bundler-tests'], | ||
| server: [...sdk, 'dev-packages/test-utils', ...serverTests], | ||
| browser: [...browserTests, 'packages/browser'], | ||
| cloudflare: ['dev-packages/cloudflare-integration-tests'], | ||
| }; | ||
|
|
||
| const [command, value, dependencyHash] = process.argv.slice(2); | ||
| if (command === 'select') { | ||
| const paths = value.split(','); | ||
| let group = ''; | ||
| if (paths.every(directory => browserTests.includes(directory) || directory === 'packages/browser')) { | ||
| group = 'browser'; | ||
| } else if (paths.every(directory => serverTests.includes(directory))) { | ||
| group = 'server'; | ||
| } else if (paths.every(directory => groups.cloudflare.includes(directory))) { | ||
| group = 'cloudflare'; | ||
| } else if ( | ||
| paths.every( | ||
| directory => | ||
| directory.startsWith('packages/') || directory.startsWith('dev-packages/e2e-tests/test-applications/'), | ||
| ) | ||
| ) { | ||
| group = 'sdk'; | ||
| } | ||
| process.stdout.write(`group=${group}\n`); | ||
| } else { | ||
| const paths = groups[value]; | ||
| if (!paths) throw new Error(`Unknown dependency group: ${value}`); | ||
| if (command === 'roots') { | ||
| process.stdout.write(`paths=${paths.join(',')}\n`); | ||
| } else if (command === 'key') { | ||
| if (!dependencyHash) throw new Error('Missing dependency hash'); | ||
| // Changing a group's membership must invalidate its installation too. | ||
| const membership = createHash('sha256').update(JSON.stringify(paths)).digest('hex').slice(0, 12); | ||
| process.stdout.write( | ||
| `key=dependencies-selected-v1-${value}-${membership}-${dependencyHash}-${process.env.RUNNER_OS}-${process.env.RUNNER_ARCH}\n`, | ||
| ); | ||
| } else { | ||
| throw new Error(`Unknown command: ${command}`); | ||
| } | ||
| } |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| name: Seed workspace dependency caches | ||
| on: | ||
| push: | ||
| branches: [develop] | ||
| workflow_dispatch: | ||
| permissions: | ||
| contents: read | ||
| env: | ||
| CACHED_DEPENDENCY_PATHS: | | ||
| ${{ github.workspace }}/node_modules | ||
| ${{ github.workspace }}/packages/*/node_modules | ||
| ${{ github.workspace }}/dev-packages/*/node_modules | ||
| ~/.cache/mongodb-binaries/ | ||
| SKIP_PLAYWRIGHT_BROWSER_INSTALL: '1' | ||
| pnpm_config_verify_deps_before_run: 'false' | ||
| jobs: | ||
| seed: | ||
| name: Seed ${{ matrix.group }} dependencies (${{ matrix.runner }}) | ||
| runs-on: ${{ matrix.runner }} | ||
| timeout-minutes: 15 | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| include: | ||
| - { group: sdk, runner: ubuntu-24.04 } | ||
| - { group: sdk, runner: ubuntu-24.04-arm } | ||
| - { group: server, runner: ubuntu-24.04 } | ||
| - { group: server, runner: ubuntu-24.04-arm } | ||
| - { group: browser, runner: ubuntu-24.04 } | ||
| - { group: cloudflare, runner: ubuntu-24.04-arm } | ||
| steps: | ||
| - uses: actions/checkout@v7 | ||
| - uses: ./.github/actions/setup-node | ||
| - uses: ./.github/actions/install-pnpm | ||
| - name: Compute cache key | ||
| id: key | ||
| env: | ||
| GROUP: ${{ matrix.group }} | ||
| run: | | ||
| hash=$(node scripts/dependency-hash-key.js) | ||
| node .github/actions/install-dependencies/groups.mjs key "$GROUP" "${hash#hash=}" >> "$GITHUB_OUTPUT" | ||
| - name: Restore selected dependencies | ||
| id: cache | ||
| uses: actions/cache/restore@v6.1.0 | ||
| with: | ||
| path: ${{ env.CACHED_DEPENDENCY_PATHS }} | ||
| key: ${{ steps.key.outputs.key }} | ||
| - name: Select workspace roots | ||
| if: steps.cache.outputs.cache-hit != 'true' | ||
| id: roots | ||
| env: | ||
| GROUP: ${{ matrix.group }} | ||
| run: node .github/actions/install-dependencies/groups.mjs roots "$GROUP" >> "$GITHUB_OUTPUT" | ||
| - name: Expand workspace dependencies | ||
| if: steps.cache.outputs.cache-hit != 'true' | ||
| id: projects | ||
| env: | ||
| INPUT_PACKAGE_PATH: ${{ steps.roots.outputs.paths }} | ||
| run: node .github/actions/build-local-sdk/select-projects.mjs >> "$GITHUB_OUTPUT" | ||
| - name: Install selected dependencies | ||
| if: steps.cache.outputs.cache-hit != 'true' | ||
| env: | ||
| PROJECTS: ${{ steps.projects.outputs.projects }} | ||
| run: | | ||
| filters=(--filter sentry-javascript) | ||
| IFS=',' read -ra projects <<< "$PROJECTS" | ||
| for project in "${projects[@]}"; do | ||
| filters+=(--filter "$project") | ||
| done | ||
| pnpm "${filters[@]}" install --frozen-lockfile | ||
| git diff --exit-code -- pnpm-lock.yaml pnpm-workspace.yaml package.json | ||
| - name: Measure installation | ||
| run: | | ||
| du -sh node_modules | ||
| find node_modules/.pnpm -mindepth 1 -maxdepth 1 -type d | wc -l | ||
| - name: Save selected dependencies | ||
| if: steps.cache.outputs.cache-hit != 'true' | ||
| uses: actions/cache/save@v6.1.0 | ||
| with: | ||
| path: ${{ env.CACHED_DEPENDENCY_PATHS }} | ||
| key: ${{ steps.key.outputs.key }} |
Oops, something went wrong.
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.
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.
Selected caches trigger a full reinstall
High Severity
Jobs that restore a selected dependency cache never set
pnpm_config_verify_deps_before_run. A filtered install does not satisfy the full lockfile, so the nextpnpm execorpnpm runinstalls the whole workspace. Seed and E2E already disable that check; unit-test andbuild-local-sdkconsumers do not, so the smaller cache is discarded and 10-minute jobs can time out.Additional Locations (2)
.github/workflows/build.yml#L595-L599.github/actions/build-local-sdk/action.yml#L25-L30Reviewed by Cursor Bugbot for commit 6b21452. Configure here.