diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fe853c3195f5..5e933ae046ec 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -59,115 +59,24 @@ env: # Test jobs restore workspace dependencies and build their SDK outputs locally. # The central build still produces the shared release artifacts. jobs: - job_get_metadata: - uses: ./.github/workflows/ci-metadata.yml - name: Get CI Metadata + job_plan_ci: + uses: ./.github/workflows/ci-planning.yml + name: Plan CI jobs with: head_commit: ${{ github.event.inputs.commit || github.sha }} permissions: pull-requests: read - job_get_test_matrix: - name: Plan test jobs - needs: job_get_metadata - runs-on: ubuntu-24.04-arm - timeout-minutes: 10 - if: | - needs.job_get_metadata.outputs.changed_any_code == 'true' || - needs.job_get_metadata.outputs.is_base_branch == 'true' || - needs.job_get_metadata.outputs.is_release == 'true' || - (needs.job_get_metadata.outputs.is_gitflow_sync == 'false' && needs.job_get_metadata.outputs.has_gitflow_label == 'false' && needs.job_get_metadata.outputs.changed_any_code == 'true') - steps: - - name: Check out base commit (${{ github.event.pull_request.base.sha }}) - uses: actions/checkout@v7 - if: github.event_name == 'pull_request' - with: - ref: ${{ github.event.pull_request.base.sha }} - - - name: 'Check out current commit (${{ needs.job_get_metadata.outputs.commit_label }})' - uses: actions/checkout@v7 - with: - ref: ${{ env.HEAD_COMMIT }} - - - name: Set up Node - uses: ./.github/actions/setup-node - - - name: Set up affected-project planner - if: github.event_name == 'pull_request' && needs.job_get_metadata.outputs.changed_ci != 'true' - uses: ./.github/actions/setup-nx-planner - - - name: Check for Affected Nx Projects - uses: ./.github/actions/nx-affected-list - id: checkForAffected - if: github.event_name == 'pull_request' && needs.job_get_metadata.outputs.changed_ci != 'true' - with: - base: ${{ github.event.pull_request.base.sha }} - head: ${{ env.HEAD_COMMIT }} - - - name: Determine which test applications should be run - id: matrix - run: - node ./lib/getTestMatrix.mjs --shards=2 --separate-aws-layer --base=${{ (github.event_name == 'pull_request' - && needs.job_get_metadata.outputs.changed_ci != 'true' && github.event.pull_request.base.sha) || '' }} >> - $GITHUB_OUTPUT - working-directory: dev-packages/e2e-tests - - - name: Determine which optional E2E test applications should be run - id: matrix-optional - run: - node ./lib/getTestMatrix.mjs --variant=optional --base=${{ (github.event_name == 'pull_request' && - needs.job_get_metadata.outputs.changed_ci != 'true' && github.event.pull_request.base.sha) || '' }} >> - $GITHUB_OUTPUT - working-directory: dev-packages/e2e-tests - - outputs: - changed_node_integration: - ${{ needs.job_get_metadata.outputs.changed_ci == 'true' || contains(steps.checkForAffected.outputs.affected, - '@sentry-internal/node-integration-tests') }} - changed_node: - ${{ needs.job_get_metadata.outputs.changed_ci == 'true' || contains(steps.checkForAffected.outputs.affected, - '@sentry/node') }} - changed_deno: - ${{ needs.job_get_metadata.outputs.changed_ci == 'true' || contains(steps.checkForAffected.outputs.affected, - '@sentry/deno') }} - changed_bun: - ${{ needs.job_get_metadata.outputs.changed_ci == 'true' || contains(steps.checkForAffected.outputs.affected, - '@sentry/bun') }} - changed_bun_integration: - ${{ needs.job_get_metadata.outputs.changed_ci == 'true' || contains(steps.checkForAffected.outputs.affected, - '@sentry-internal/bun-integration-tests') }} - changed_deno_integration: - ${{ needs.job_get_metadata.outputs.changed_ci == 'true' || contains(steps.checkForAffected.outputs.affected, - '@sentry-internal/deno-integration-tests') }} - changed_browser_integration: - ${{ needs.job_get_metadata.outputs.changed_ci == 'true' || contains(steps.checkForAffected.outputs.affected, - '@sentry-internal/browser-integration-tests') }} - changed_cloudflare_integration: - ${{ needs.job_get_metadata.outputs.changed_ci == 'true' || contains(steps.checkForAffected.outputs.affected, - '@sentry-internal/cloudflare-integration-tests') }} - changed_bundler_plugin_integration: - ${{ needs.job_get_metadata.outputs.changed_ci == 'true' || contains(steps.checkForAffected.outputs.affected, - '@sentry-internal/bundler-plugin-integration-tests') }} - changed_aws_serverless: - ${{ needs.job_get_metadata.outputs.changed_ci == 'true' || contains(steps.checkForAffected.outputs.affected, - '@sentry/aws-serverless') }} - e2e-matrix-1: ${{ steps.matrix.outputs.matrix-1 }} - e2e-matrix-2: ${{ steps.matrix.outputs.matrix-2 }} - e2e-matrix-aws-layer: ${{ steps.matrix.outputs.matrix-aws-layer }} - e2e-matrix-with-secrets: ${{ steps.matrix.outputs.matrix-with-secrets }} - e2e-matrix-optional: ${{ steps.matrix-optional.outputs.matrix }} - e2e-matrix-optional-without-secrets: ${{ steps.matrix-optional.outputs.matrix-without-secrets }} - job_build: name: Build - needs: job_get_metadata + needs: job_plan_ci runs-on: ubuntu-24.04-arm timeout-minutes: 15 if: | - needs.job_get_metadata.outputs.changed_any_code == 'true' || - needs.job_get_metadata.outputs.is_base_branch == 'true' || - needs.job_get_metadata.outputs.is_release == 'true' || - (needs.job_get_metadata.outputs.is_gitflow_sync == 'false' && needs.job_get_metadata.outputs.has_gitflow_label == 'false' && needs.job_get_metadata.outputs.changed_any_code == 'true') + needs.job_plan_ci.outputs.changed_any_code == 'true' || + needs.job_plan_ci.outputs.is_base_branch == 'true' || + needs.job_plan_ci.outputs.is_release == 'true' || + (needs.job_plan_ci.outputs.is_gitflow_sync == 'false' && needs.job_plan_ci.outputs.has_gitflow_label == 'false' && needs.job_plan_ci.outputs.changed_any_code == 'true') steps: - name: Check out base commit (${{ github.event.pull_request.base.sha }}) uses: actions/checkout@v7 @@ -175,7 +84,7 @@ jobs: with: ref: ${{ github.event.pull_request.base.sha }} - - name: 'Check out current commit (${{ needs.job_get_metadata.outputs.commit_label }})' + - name: 'Check out current commit (${{ needs.job_plan_ci.outputs.commit_label }})' uses: actions/checkout@v7 with: ref: ${{ env.HEAD_COMMIT }} @@ -259,12 +168,12 @@ jobs: job_build_layer: name: Build Lambda layer - needs: [job_get_metadata, job_build] - if: needs.job_get_metadata.outputs.is_release == 'true' + needs: [job_plan_ci, job_build] + if: needs.job_plan_ci.outputs.is_release == 'true' timeout-minutes: 10 runs-on: ubuntu-24.04 steps: - - name: Check out current commit (${{ needs.job_get_metadata.outputs.commit_label }}) + - name: Check out current commit (${{ needs.job_plan_ci.outputs.commit_label }}) uses: actions/checkout@v7 with: ref: ${{ env.HEAD_COMMIT }} @@ -297,7 +206,7 @@ jobs: job_check_branches: name: Check PR branches - needs: job_get_metadata + needs: job_plan_ci runs-on: ubuntu-24.04 if: github.event_name == 'pull_request' permissions: @@ -312,14 +221,14 @@ jobs: job_size_check: name: Size Check - needs: [job_get_metadata, job_get_test_matrix] + needs: job_plan_ci timeout-minutes: 15 runs-on: ubuntu-24.04-arm - if: - github.event_name == 'pull_request' || needs.job_get_metadata.outputs.is_base_branch == 'true' || - needs.job_get_metadata.outputs.is_release == 'true' + if: >- + needs.job_plan_ci.outputs.should_run_tests == 'true' && (github.event_name == 'pull_request' || + needs.job_plan_ci.outputs.is_base_branch == 'true' || needs.job_plan_ci.outputs.is_release == 'true') steps: - - name: Check out current commit (${{ needs.job_get_metadata.outputs.commit_label }}) + - name: Check out current commit (${{ needs.job_plan_ci.outputs.commit_label }}) uses: actions/checkout@v7 with: ref: ${{ env.HEAD_COMMIT }} @@ -339,11 +248,12 @@ jobs: name: Lint # Even though the linter only checks source code, not built code, it needs the built code in order check that all # inter-package dependencies resolve cleanly. - needs: [job_get_metadata, job_get_test_matrix] + needs: job_plan_ci + if: needs.job_plan_ci.outputs.should_run_tests == 'true' timeout-minutes: 10 runs-on: ubuntu-24.04-arm steps: - - name: Check out current commit (${{ needs.job_get_metadata.outputs.commit_label }}) + - name: Check out current commit (${{ needs.job_plan_ci.outputs.commit_label }}) uses: actions/checkout@v7 with: ref: ${{ env.HEAD_COMMIT }} @@ -376,16 +286,16 @@ jobs: job_check_lockfile: name: Check lockfile - needs: [job_get_metadata] + needs: job_plan_ci # `pnpm dedupe` fetches metadata for every package from npm, so this job can take 8+ min on PRs. timeout-minutes: 20 runs-on: ubuntu-24.04 if: | - needs.job_get_metadata.outputs.changed_deps == 'true' || - needs.job_get_metadata.outputs.is_base_branch == 'true' || - needs.job_get_metadata.outputs.is_release == 'true' + needs.job_plan_ci.outputs.changed_deps == 'true' || + needs.job_plan_ci.outputs.is_base_branch == 'true' || + needs.job_plan_ci.outputs.is_release == 'true' steps: - - name: Check out current commit (${{ needs.job_get_metadata.outputs.commit_label }}) + - name: Check out current commit (${{ needs.job_plan_ci.outputs.commit_label }}) uses: actions/checkout@v7 with: ref: ${{ env.HEAD_COMMIT }} @@ -413,11 +323,11 @@ jobs: job_check_format: name: Check file formatting - needs: [job_get_metadata] + needs: job_plan_ci timeout-minutes: 10 runs-on: ubuntu-24.04 steps: - - name: Check out current commit (${{ needs.job_get_metadata.outputs.commit_label }}) + - name: Check out current commit (${{ needs.job_plan_ci.outputs.commit_label }}) uses: actions/checkout@v7 with: ref: ${{ env.HEAD_COMMIT }} @@ -433,12 +343,12 @@ jobs: job_artifacts: name: Upload Artifacts - needs: [job_get_metadata, job_build, job_build_layer] + needs: [job_plan_ci, job_build, job_build_layer] runs-on: ubuntu-24.04 # Build artifacts are only needed for releasing workflow. - if: needs.job_get_metadata.outputs.is_release == 'true' + if: needs.job_plan_ci.outputs.is_release == 'true' steps: - - name: Check out current commit (${{ needs.job_get_metadata.outputs.commit_label }}) + - name: Check out current commit (${{ needs.job_plan_ci.outputs.commit_label }}) uses: actions/checkout@v7 with: ref: ${{ env.HEAD_COMMIT }} @@ -484,7 +394,8 @@ jobs: job_browser_unit_tests: name: Browser Unit Tests - needs: [job_get_metadata, job_get_test_matrix] + needs: job_plan_ci + if: needs.job_plan_ci.outputs.should_run_tests == 'true' timeout-minutes: 10 runs-on: ubuntu-24.04 steps: @@ -494,7 +405,7 @@ jobs: with: ref: ${{ github.event.pull_request.base.sha }} - - name: Check out current commit (${{ needs.job_get_metadata.outputs.commit_label }}) + - name: Check out current commit (${{ needs.job_plan_ci.outputs.commit_label }}) uses: actions/checkout@v7 with: ref: ${{ env.HEAD_COMMIT }} @@ -518,8 +429,10 @@ jobs: job_bun_unit_tests: name: Bun (${{ matrix.bun }}) Unit Tests - needs: [job_get_metadata, job_get_test_matrix] - if: needs.job_get_test_matrix.outputs.changed_bun == 'true' || github.event_name != 'pull_request' + needs: job_plan_ci + if: >- + needs.job_plan_ci.outputs.should_run_tests == 'true' && (needs.job_plan_ci.outputs.changed_bun == 'true' || + github.event_name != 'pull_request') timeout-minutes: 10 runs-on: ubuntu-24.04-arm strategy: @@ -528,7 +441,7 @@ jobs: # 1.3.14 is the oldest supported Bun version bun: ['1.3.14', '1.4'] steps: - - name: Check out current commit (${{ needs.job_get_metadata.outputs.commit_label }}) + - name: Check out current commit (${{ needs.job_plan_ci.outputs.commit_label }}) uses: actions/checkout@v7 with: ref: ${{ env.HEAD_COMMIT }} @@ -546,12 +459,14 @@ jobs: job_deno_unit_tests: name: Deno Unit Tests - needs: [job_get_metadata, job_get_test_matrix] - if: needs.job_get_test_matrix.outputs.changed_deno == 'true' || github.event_name != 'pull_request' + needs: job_plan_ci + if: >- + needs.job_plan_ci.outputs.should_run_tests == 'true' && (needs.job_plan_ci.outputs.changed_deno == 'true' || + github.event_name != 'pull_request') timeout-minutes: 10 runs-on: ubuntu-24.04-arm steps: - - name: Check out current commit (${{ needs.job_get_metadata.outputs.commit_label }}) + - name: Check out current commit (${{ needs.job_plan_ci.outputs.commit_label }}) uses: actions/checkout@v7 with: ref: ${{ env.HEAD_COMMIT }} @@ -569,7 +484,8 @@ jobs: job_node_unit_tests: name: Node (${{ matrix.node }}) Unit Tests (${{ matrix.shard }}/2) - needs: [job_get_metadata, job_get_test_matrix] + needs: job_plan_ci + if: needs.job_plan_ci.outputs.should_run_tests == 'true' timeout-minutes: 10 runs-on: ubuntu-24.04-arm # Node 27 is an alpha: its ABI and APIs can change, so its failures must not fail the required checks. @@ -585,7 +501,7 @@ jobs: if: github.event_name == 'pull_request' with: ref: ${{ github.event.pull_request.base.sha }} - - name: Check out current commit (${{ needs.job_get_metadata.outputs.commit_label }}) + - name: Check out current commit (${{ needs.job_plan_ci.outputs.commit_label }}) uses: actions/checkout@v7 with: ref: ${{ env.HEAD_COMMIT }} @@ -628,8 +544,10 @@ jobs: name: Playwright ${{ matrix.bundle }}${{ matrix.project && matrix.project != 'chromium' && format(' {0}', matrix.project) || ''}}${{ matrix.shard && format(' ({0}/{1})', matrix.shard, matrix.shards) || ''}} Tests - needs: [job_get_metadata, job_get_test_matrix] - if: needs.job_get_test_matrix.outputs.changed_browser_integration == 'true' || github.event_name != 'pull_request' + needs: job_plan_ci + if: >- + needs.job_plan_ci.outputs.should_run_tests == 'true' && (needs.job_plan_ci.outputs.changed_browser_integration == + 'true' || github.event_name != 'pull_request') runs-on: ubuntu-24.04-large-js timeout-minutes: 25 strategy: @@ -715,7 +633,7 @@ jobs: shards: 3 steps: - - name: Check out current commit (${{ needs.job_get_metadata.outputs.commit_label }}) + - name: Check out current commit (${{ needs.job_plan_ci.outputs.commit_label }}) uses: actions/checkout@v7 with: ref: ${{ env.HEAD_COMMIT }} @@ -752,8 +670,10 @@ jobs: job_browser_loader_tests: name: PW ${{ matrix.bundle }} Tests - needs: [job_get_metadata, job_get_test_matrix] - if: needs.job_get_test_matrix.outputs.changed_browser_integration == 'true' || github.event_name != 'pull_request' + needs: job_plan_ci + if: >- + needs.job_plan_ci.outputs.should_run_tests == 'true' && (needs.job_plan_ci.outputs.changed_browser_integration == + 'true' || github.event_name != 'pull_request') runs-on: ubuntu-24.04 timeout-minutes: 15 strategy: @@ -769,7 +689,7 @@ jobs: - loader_tracing_replay steps: - - name: Check out current commit (${{ needs.job_get_metadata.outputs.commit_label }}) + - name: Check out current commit (${{ needs.job_plan_ci.outputs.commit_label }}) uses: actions/checkout@v7 with: ref: ${{ env.HEAD_COMMIT }} @@ -804,12 +724,14 @@ jobs: # Runs the CDN bundles in the oldest Chromium we support. Chromium snapshots only exist for x64. job_browser_min_version_tests: name: Minimum Chromium Version Tests - needs: [job_get_metadata, job_get_test_matrix] - if: needs.job_get_test_matrix.outputs.changed_browser_integration == 'true' || github.event_name != 'pull_request' + needs: job_plan_ci + if: >- + needs.job_plan_ci.outputs.should_run_tests == 'true' && (needs.job_plan_ci.outputs.changed_browser_integration == + 'true' || github.event_name != 'pull_request') runs-on: ubuntu-24.04 timeout-minutes: 5 steps: - - name: Check out current commit (${{ needs.job_get_metadata.outputs.commit_label }}) + - name: Check out current commit (${{ needs.job_plan_ci.outputs.commit_label }}) uses: actions/checkout@v7 with: ref: ${{ env.HEAD_COMMIT }} @@ -829,8 +751,10 @@ jobs: job_node_integration_tests: name: Node (${{ matrix.node }}) Integration Tests (${{ matrix.shard }}/${{ matrix.shards }}) - needs: [job_get_metadata, job_get_test_matrix] - if: needs.job_get_test_matrix.outputs.changed_node_integration == 'true' || github.event_name != 'pull_request' + needs: job_plan_ci + if: >- + needs.job_plan_ci.outputs.should_run_tests == 'true' && (needs.job_plan_ci.outputs.changed_node_integration == + 'true' || github.event_name != 'pull_request') runs-on: ubuntu-24.04-arm timeout-minutes: 20 # Node 27 is an alpha: its ABI and APIs can change, so its failures must not fail the required checks. @@ -842,7 +766,7 @@ jobs: shard: [1, 2, 3, 4, 5, 6] shards: [6] steps: - - name: Check out current commit (${{ needs.job_get_metadata.outputs.commit_label }}) + - name: Check out current commit (${{ needs.job_plan_ci.outputs.commit_label }}) uses: actions/checkout@v7 with: ref: ${{ env.HEAD_COMMIT }} @@ -880,15 +804,15 @@ jobs: job_sql_server_integration_tests: name: SQL Server Integration Tests (Node 24) - needs: [job_get_metadata, job_get_test_matrix] + needs: job_plan_ci if: >- - needs.job_get_test_matrix.outputs.changed_node_integration == 'true' || - needs.job_get_test_matrix.outputs.changed_bun_integration == 'true' || - needs.job_get_test_matrix.outputs.changed_deno_integration == 'true' || github.event_name != 'pull_request' + needs.job_plan_ci.outputs.should_run_tests == 'true' && (needs.job_plan_ci.outputs.changed_node_integration == + 'true' || needs.job_plan_ci.outputs.changed_bun_integration == 'true' || + needs.job_plan_ci.outputs.changed_deno_integration == 'true' || github.event_name != 'pull_request') runs-on: ubuntu-24.04 timeout-minutes: 20 steps: - - name: Check out current commit (${{ needs.job_get_metadata.outputs.commit_label }}) + - name: Check out current commit (${{ needs.job_plan_ci.outputs.commit_label }}) uses: actions/checkout@v7 with: ref: ${{ env.HEAD_COMMIT }} @@ -907,9 +831,10 @@ jobs: # Runs on the wrangler pinned in the package, so the required run stays on a fixed, older runtime. job_cloudflare_integration_tests: name: Cloudflare Integration Tests (${{ matrix.shard }}/${{ matrix.shards }}) - needs: [job_get_metadata, job_get_test_matrix] - if: - needs.job_get_test_matrix.outputs.changed_cloudflare_integration == 'true' || github.event_name != 'pull_request' + needs: job_plan_ci + if: >- + needs.job_plan_ci.outputs.should_run_tests == 'true' && (needs.job_plan_ci.outputs.changed_cloudflare_integration + == 'true' || github.event_name != 'pull_request') runs-on: ubuntu-24.04-arm timeout-minutes: 15 strategy: @@ -918,7 +843,7 @@ jobs: shard: [1, 2, 3, 4, 5, 6] shards: [6] steps: &cloudflare_integration_tests_steps - - name: Check out current commit (${{ needs.job_get_metadata.outputs.commit_label }}) + - name: Check out current commit (${{ needs.job_plan_ci.outputs.commit_label }}) uses: actions/checkout@v7 with: ref: ${{ env.HEAD_COMMIT }} @@ -945,11 +870,10 @@ jobs: # block a PR, and like the optional E2E tests it does not run on release branches. job_optional_cloudflare_integration_tests: name: Cloudflare Integration Tests (${{ matrix.shard }}/2, latest wrangler) (optional) - needs: [job_get_metadata, job_get_test_matrix] - if: - needs.job_get_metadata.outputs.is_release != 'true' && - (needs.job_get_test_matrix.outputs.changed_cloudflare_integration == 'true' || github.event_name != - 'pull_request') + needs: job_plan_ci + if: >- + needs.job_plan_ci.outputs.should_run_tests == 'true' && (needs.job_plan_ci.outputs.is_release != 'true' && + (needs.job_plan_ci.outputs.changed_cloudflare_integration == 'true' || github.event_name != 'pull_request')) runs-on: ubuntu-24.04-arm timeout-minutes: 15 strategy: @@ -962,10 +886,10 @@ jobs: job_bundler_plugin_integration_tests: name: Bundler Plugin Integration Tests (Node ${{ matrix.node }}) - needs: [job_get_metadata, job_get_test_matrix] - if: - needs.job_get_test_matrix.outputs.changed_bundler_plugin_integration == 'true' || github.event_name != - 'pull_request' + needs: job_plan_ci + if: >- + needs.job_plan_ci.outputs.should_run_tests == 'true' && + (needs.job_plan_ci.outputs.changed_bundler_plugin_integration == 'true' || github.event_name != 'pull_request') runs-on: ubuntu-24.04-arm timeout-minutes: 15 # Node 27 is an alpha: its ABI and APIs can change, so its failures must not fail the required checks. @@ -975,7 +899,7 @@ jobs: matrix: node: [20.19, 22, 24, 26, '^27.0.0-0'] steps: - - name: Check out current commit (${{ needs.job_get_metadata.outputs.commit_label }}) + - name: Check out current commit (${{ needs.job_plan_ci.outputs.commit_label }}) uses: actions/checkout@v7 with: ref: ${{ env.HEAD_COMMIT }} @@ -994,8 +918,10 @@ jobs: job_bun_integration_tests: name: Bun (${{ matrix.bun }}) Integration Tests (${{ matrix.shard }}/6) - needs: [job_get_metadata, job_get_test_matrix] - if: needs.job_get_test_matrix.outputs.changed_bun_integration == 'true' || github.event_name != 'pull_request' + needs: job_plan_ci + if: >- + needs.job_plan_ci.outputs.should_run_tests == 'true' && (needs.job_plan_ci.outputs.changed_bun_integration == + 'true' || github.event_name != 'pull_request') runs-on: ubuntu-24.04-arm timeout-minutes: 15 strategy: @@ -1005,7 +931,7 @@ jobs: bun: ['1.3.14', '1.4'] shard: [1, 2, 3, 4, 5, 6] steps: - - name: Check out current commit (${{ needs.job_get_metadata.outputs.commit_label }}) + - name: Check out current commit (${{ needs.job_plan_ci.outputs.commit_label }}) uses: actions/checkout@v7 with: ref: ${{ env.HEAD_COMMIT }} @@ -1024,8 +950,10 @@ jobs: job_deno_integration_tests: name: Deno Integration Tests (${{ matrix.shard }}/6) - needs: [job_get_metadata, job_get_test_matrix] - if: needs.job_get_test_matrix.outputs.changed_deno_integration == 'true' || github.event_name != 'pull_request' + needs: job_plan_ci + if: >- + needs.job_plan_ci.outputs.should_run_tests == 'true' && (needs.job_plan_ci.outputs.changed_deno_integration == + 'true' || github.event_name != 'pull_request') runs-on: ubuntu-24.04-arm timeout-minutes: 15 strategy: @@ -1033,7 +961,7 @@ jobs: matrix: shard: [1, 2, 3, 4, 5, 6] steps: - - name: Check out current commit (${{ needs.job_get_metadata.outputs.commit_label }}) + - name: Check out current commit (${{ needs.job_plan_ci.outputs.commit_label }}) uses: actions/checkout@v7 with: ref: ${{ env.HEAD_COMMIT }} @@ -1061,10 +989,10 @@ jobs: # and `steps`. job_e2e_tests_1: name: E2E ${{ matrix.label || matrix.test-application }} Test - if: - always() && needs.job_get_test_matrix.result == 'success' && needs.job_get_test_matrix.outputs.e2e-matrix-1 != - '{"include":[]}' - needs: [job_get_metadata, job_get_test_matrix] + if: >- + needs.job_plan_ci.outputs.should_run_tests == 'true' && (always() && needs.job_plan_ci.result == 'success' && + needs.job_plan_ci.outputs.e2e-matrix-1 != '{"include":[]}') + needs: job_plan_ci runs-on: ubuntu-24.04 timeout-minutes: 15 # We just use a dummy DSN here, only send to the tunnel anyhow @@ -1083,9 +1011,9 @@ jobs: pnpm_config_verify_deps_before_run: 'false' strategy: fail-fast: false - matrix: ${{ fromJson(needs.job_get_test_matrix.outputs.e2e-matrix-1) }} + matrix: ${{ fromJson(needs.job_plan_ci.outputs.e2e-matrix-1) }} steps: &e2e-steps - - name: Check out current commit (${{ needs.job_get_metadata.outputs.commit_label }}) + - name: Check out current commit (${{ needs.job_plan_ci.outputs.commit_label }}) uses: actions/checkout@v7 with: ref: ${{ env.HEAD_COMMIT }} @@ -1150,42 +1078,42 @@ jobs: job_e2e_tests_2: name: E2E ${{ matrix.label || matrix.test-application }} Test - if: - always() && needs.job_get_test_matrix.result == 'success' && needs.job_get_test_matrix.outputs.e2e-matrix-2 != - '{"include":[]}' - needs: [job_get_metadata, job_get_test_matrix] + if: >- + needs.job_plan_ci.outputs.should_run_tests == 'true' && (always() && needs.job_plan_ci.result == 'success' && + needs.job_plan_ci.outputs.e2e-matrix-2 != '{"include":[]}') + needs: job_plan_ci runs-on: ubuntu-24.04 timeout-minutes: 15 env: *e2e-env strategy: fail-fast: false - matrix: ${{ fromJson(needs.job_get_test_matrix.outputs.e2e-matrix-2) }} + matrix: ${{ fromJson(needs.job_plan_ci.outputs.e2e-matrix-2) }} steps: *e2e-steps job_e2e_aws_layer_tests: name: E2E ${{ matrix.label || matrix.test-application }} Test - needs: [job_get_metadata, job_get_test_matrix] + needs: job_plan_ci if: >- - always() && needs.job_get_test_matrix.result == 'success' && - needs.job_get_test_matrix.outputs.e2e-matrix-aws-layer != '{"include":[]}' + needs.job_plan_ci.outputs.should_run_tests == 'true' && (always() && needs.job_plan_ci.result == 'success' && + needs.job_plan_ci.outputs.e2e-matrix-aws-layer != '{"include":[]}') runs-on: ubuntu-24.04 timeout-minutes: 15 env: *e2e-env strategy: fail-fast: false - matrix: ${{ fromJson(needs.job_get_test_matrix.outputs.e2e-matrix-aws-layer) }} + matrix: ${{ fromJson(needs.job_plan_ci.outputs.e2e-matrix-aws-layer) }} steps: *e2e-steps # PRs from forks and Dependabot get no secrets, so they skip these jobs. Release branches skip them too, so that an # outage of an external API cannot block a release. job_e2e_tests_with_secrets: name: E2E ${{ matrix.label || matrix.test-application }} Test - if: - always() && needs.job_get_metadata.outputs.is_release != 'true' && needs.job_get_test_matrix.result == 'success' - && needs.job_get_test_matrix.outputs.e2e-matrix-with-secrets != '{"include":[]}' && (github.event_name != - 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) && github.actor != - 'dependabot[bot]' - needs: [job_get_metadata, job_get_test_matrix] + if: >- + needs.job_plan_ci.outputs.should_run_tests == 'true' && (always() && needs.job_plan_ci.outputs.is_release != + 'true' && needs.job_plan_ci.result == 'success' && needs.job_plan_ci.outputs.e2e-matrix-with-secrets != + '{"include":[]}' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == + github.repository) && github.actor != 'dependabot[bot]') + needs: job_plan_ci runs-on: ubuntu-24.04 timeout-minutes: 15 permissions: @@ -1209,7 +1137,7 @@ jobs: pnpm_config_verify_deps_before_run: 'false' strategy: fail-fast: false - matrix: ${{ fromJson(needs.job_get_test_matrix.outputs.e2e-matrix-with-secrets) }} + matrix: ${{ fromJson(needs.job_plan_ci.outputs.e2e-matrix-with-secrets) }} steps: *e2e-steps # - We skip optional tests on release branches @@ -1218,12 +1146,12 @@ jobs: job_optional_e2e_tests: name: E2E Tests (optional) # A PR from a fork cannot dispatch optional-e2e.yml, see job_optional_e2e_tests_without_secrets. - if: - always() && needs.job_get_metadata.outputs.is_release != 'true' && needs.job_get_test_matrix.result == 'success' - && needs.job_get_test_matrix.outputs.e2e-matrix-optional != '{"include":[]}' && (github.event_name != - 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) && github.actor != - 'dependabot[bot]' - needs: [job_get_metadata, job_get_test_matrix] + if: >- + needs.job_plan_ci.outputs.should_run_tests == 'true' && (always() && needs.job_plan_ci.outputs.is_release != + 'true' && needs.job_plan_ci.result == 'success' && needs.job_plan_ci.outputs.e2e-matrix-optional != + '{"include":[]}' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == + github.repository) && github.actor != 'dependabot[bot]') + needs: job_plan_ci # This job only waits for optional-e2e.yml, which can take most of an hour. runs-on: ubuntu-24.04 timeout-minutes: 60 @@ -1231,7 +1159,7 @@ jobs: contents: read actions: write steps: - - name: Check out current commit (${{ needs.job_get_metadata.outputs.commit_label }}) + - name: Check out current commit (${{ needs.job_plan_ci.outputs.commit_label }}) uses: actions/checkout@v7 with: ref: ${{ env.HEAD_COMMIT }} @@ -1247,15 +1175,16 @@ jobs: with: github_token: ${{ secrets.GITHUB_TOKEN }} commit: ${{ env.HEAD_COMMIT }} - matrix: ${{ needs.job_get_test_matrix.outputs.e2e-matrix-optional }} + matrix: ${{ needs.job_plan_ci.outputs.e2e-matrix-optional }} job_optional_e2e_tests_without_secrets: name: E2E ${{ matrix.label || matrix.test-application }} Test (optional) - if: - always() && needs.job_get_metadata.outputs.is_release != 'true' && needs.job_get_test_matrix.result == 'success' - && needs.job_get_test_matrix.outputs.e2e-matrix-optional-without-secrets != '{"include":[]}' && github.event_name - == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository - needs: [job_get_metadata, job_get_test_matrix] + if: >- + needs.job_plan_ci.outputs.should_run_tests == 'true' && (always() && needs.job_plan_ci.outputs.is_release != + 'true' && needs.job_plan_ci.result == 'success' && needs.job_plan_ci.outputs.e2e-matrix-optional-without-secrets + != '{"include":[]}' && github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != + github.repository) + needs: job_plan_ci runs-on: ubuntu-24.04 timeout-minutes: 15 permissions: @@ -1263,7 +1192,7 @@ jobs: env: *e2e-env strategy: fail-fast: false - matrix: ${{ fromJson(needs.job_get_test_matrix.outputs.e2e-matrix-optional-without-secrets) }} + matrix: ${{ fromJson(needs.job_plan_ci.outputs.e2e-matrix-optional-without-secrets) }} steps: *e2e-steps job_required_jobs_passed: @@ -1271,7 +1200,7 @@ jobs: needs: [ job_build, - job_get_test_matrix, + job_plan_ci, job_build_layer, job_browser_unit_tests, job_bun_unit_tests, diff --git a/.github/workflows/ci-metadata.yml b/.github/workflows/ci-metadata.yml deleted file mode 100644 index 6b4ed392bd1f..000000000000 --- a/.github/workflows/ci-metadata.yml +++ /dev/null @@ -1,98 +0,0 @@ -name: 'Get Metadata' -on: - workflow_call: - inputs: - head_commit: - description: 'The commit SHA to check out and test' - type: string - required: true - outputs: - commit_label: - description: 'Short SHA + commit message for display' - value: ${{ jobs.get_metadata.outputs.commit_label }} - is_base_branch: - description: 'Whether the ref is develop, v10, v9, or v8' - value: ${{ jobs.get_metadata.outputs.is_base_branch }} - is_release: - description: 'Whether the ref is a release branch' - value: ${{ jobs.get_metadata.outputs.is_release }} - changed_ci: - description: 'Whether .github/** files changed' - value: ${{ jobs.get_metadata.outputs.changed_ci }} - changed_any_code: - description: 'Whether any non-markdown files changed' - value: ${{ jobs.get_metadata.outputs.changed_any_code }} - changed_deps: - description: 'Whether any package.json, pnpm-lock.yaml or pnpm-workspace.yaml changed' - value: ${{ jobs.get_metadata.outputs.changed_deps }} - is_gitflow_sync: - description: 'Whether this is a gitflow sync (master merge)' - value: ${{ jobs.get_metadata.outputs.is_gitflow_sync }} - has_gitflow_label: - description: 'Whether the PR has the Gitflow label' - value: ${{ jobs.get_metadata.outputs.has_gitflow_label }} - force_skip_cache: - description: 'Whether to skip caching (schedule or ci-skip-cache label)' - value: ${{ jobs.get_metadata.outputs.force_skip_cache }} - -jobs: - get_metadata: - name: Get Metadata - runs-on: ubuntu-24.04 - permissions: - pull-requests: read - steps: - - name: Check out current commit - uses: actions/checkout@v7 - with: - ref: ${{ inputs.head_commit }} - # We need to check out not only the fake merge commit between the PR and the base branch which GH creates, but - # also its parents, so that we can pull the commit message from the head commit of the PR - fetch-depth: 2 - - - name: Get metadata - id: get_metadata - # We need to try a number of different options for finding the head commit, because each kind of trigger event - # stores it in a different location - env: - COMMIT_SHA_EXPR: - ${{ github.event.pull_request.head.sha || github.event.head_commit.id || inputs.head_commit }} - run: | - COMMIT_SHA=$(git rev-parse --short "$COMMIT_SHA_EXPR") - echo "COMMIT_SHA=$COMMIT_SHA" >> $GITHUB_ENV - echo "COMMIT_MESSAGE=$(git log -n 1 --pretty=format:%s $COMMIT_SHA)" >> $GITHUB_ENV - - # Most changed packages are determined in job_get_test_matrix via Nx - - name: Determine changed packages - uses: dorny/paths-filter@v4.0.3 - id: changed - with: - filters: | - workflow: - - '.github/**' - any_code: - - '!**/*.md' - deps: - - '**/package.json' - - 'pnpm-lock.yaml' - - 'pnpm-workspace.yaml' - - outputs: - commit_label: '${{ env.COMMIT_SHA }}: ${{ env.COMMIT_MESSAGE }}' - # Note: These next three have to be checked as strings ('true'/'false')! - is_base_branch: - ${{ github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/v10' || github.ref == 'refs/heads/v9' || - github.ref == 'refs/heads/v8'}} - is_release: ${{ startsWith(github.ref, 'refs/heads/release/') }} - changed_ci: ${{ steps.changed.outputs.workflow == 'true' }} - changed_any_code: ${{ steps.changed.outputs.any_code == 'true' }} - changed_deps: ${{ steps.changed.outputs.deps == 'true' }} - - # When merging into master, or from master - is_gitflow_sync: ${{ github.head_ref == 'master' || github.ref == 'refs/heads/master' }} - has_gitflow_label: - ${{ github.event_name == 'pull_request' && contains(toJSON(github.event.pull_request.labels.*.name), 'Gitflow') - }} - force_skip_cache: - ${{ github.event_name == 'schedule' || (github.event_name == 'pull_request' && - contains(toJSON(github.event.pull_request.labels.*.name), 'ci-skip-cache')) }} diff --git a/.github/workflows/ci-planning.yml b/.github/workflows/ci-planning.yml new file mode 100644 index 000000000000..a1b4325341f6 --- /dev/null +++ b/.github/workflows/ci-planning.yml @@ -0,0 +1,237 @@ +name: 'Plan CI jobs' +on: + workflow_call: + inputs: + head_commit: + description: 'The commit SHA to check out and test' + type: string + required: true + outputs: + commit_label: + description: 'Short SHA + commit message for display' + value: ${{ jobs.plan_ci.outputs.commit_label }} + is_base_branch: + description: 'Whether the ref is develop, v10, v9, or v8' + value: ${{ jobs.plan_ci.outputs.is_base_branch }} + is_release: + description: 'Whether the ref is a release branch' + value: ${{ jobs.plan_ci.outputs.is_release }} + changed_ci: + description: 'Whether .github/** files changed' + value: ${{ jobs.plan_ci.outputs.changed_ci }} + changed_any_code: + description: 'Whether any non-markdown files changed' + value: ${{ jobs.plan_ci.outputs.changed_any_code }} + changed_deps: + description: 'Whether any package.json, pnpm-lock.yaml or pnpm-workspace.yaml changed' + value: ${{ jobs.plan_ci.outputs.changed_deps }} + is_gitflow_sync: + description: 'Whether this is a gitflow sync (master merge)' + value: ${{ jobs.plan_ci.outputs.is_gitflow_sync }} + has_gitflow_label: + description: 'Whether the PR has the Gitflow label' + value: ${{ jobs.plan_ci.outputs.has_gitflow_label }} + force_skip_cache: + description: 'Whether to skip caching (schedule or ci-skip-cache label)' + value: ${{ jobs.plan_ci.outputs.force_skip_cache }} + should_run_tests: + description: 'Skip tests for Markdown-only PRs; always run on base and release branches.' + value: ${{ jobs.plan_ci.outputs.should_run_tests }} + changed_node_integration: + description: 'Test planning output: changed_node_integration' + value: ${{ jobs.plan_ci.outputs.changed_node_integration }} + changed_node: + description: 'Test planning output: changed_node' + value: ${{ jobs.plan_ci.outputs.changed_node }} + changed_deno: + description: 'Test planning output: changed_deno' + value: ${{ jobs.plan_ci.outputs.changed_deno }} + changed_bun: + description: 'Test planning output: changed_bun' + value: ${{ jobs.plan_ci.outputs.changed_bun }} + changed_bun_integration: + description: 'Test planning output: changed_bun_integration' + value: ${{ jobs.plan_ci.outputs.changed_bun_integration }} + changed_deno_integration: + description: 'Test planning output: changed_deno_integration' + value: ${{ jobs.plan_ci.outputs.changed_deno_integration }} + changed_browser_integration: + description: 'Test planning output: changed_browser_integration' + value: ${{ jobs.plan_ci.outputs.changed_browser_integration }} + changed_cloudflare_integration: + description: 'Test planning output: changed_cloudflare_integration' + value: ${{ jobs.plan_ci.outputs.changed_cloudflare_integration }} + changed_bundler_plugin_integration: + description: 'Test planning output: changed_bundler_plugin_integration' + value: ${{ jobs.plan_ci.outputs.changed_bundler_plugin_integration }} + changed_aws_serverless: + description: 'Test planning output: changed_aws_serverless' + value: ${{ jobs.plan_ci.outputs.changed_aws_serverless }} + e2e-matrix-1: + description: 'Test planning output: e2e-matrix-1' + value: ${{ jobs.plan_ci.outputs.e2e-matrix-1 }} + e2e-matrix-2: + description: 'Test planning output: e2e-matrix-2' + value: ${{ jobs.plan_ci.outputs.e2e-matrix-2 }} + e2e-matrix-aws-layer: + description: 'Test planning output: e2e-matrix-aws-layer' + value: ${{ jobs.plan_ci.outputs.e2e-matrix-aws-layer }} + e2e-matrix-with-secrets: + description: 'Test planning output: e2e-matrix-with-secrets' + value: ${{ jobs.plan_ci.outputs.e2e-matrix-with-secrets }} + e2e-matrix-optional-without-secrets: + description: 'Test planning output: e2e-matrix-optional-without-secrets' + value: ${{ jobs.plan_ci.outputs.e2e-matrix-optional-without-secrets }} + e2e-matrix-optional: + description: 'Test planning output: e2e-matrix-optional' + value: ${{ jobs.plan_ci.outputs.e2e-matrix-optional }} + +jobs: + plan_ci: + name: Plan CI jobs + runs-on: ubuntu-24.04-arm + env: + CACHED_DEPENDENCY_PATHS: | + ${{ github.workspace }}/node_modules + ${{ github.workspace }}/packages/*/node_modules + ${{ github.workspace }}/dev-packages/*/node_modules + ~/.cache/mongodb-binaries/ + permissions: + pull-requests: read + steps: + - name: Check out current commit + uses: actions/checkout@v7 + with: + ref: ${{ inputs.head_commit }} + # We need to check out not only the fake merge commit between the PR and the base branch which GH creates, but + # also its parents, so that we can pull the commit message from the head commit of the PR + fetch-depth: 2 + + - name: Get metadata + id: get_metadata + # We need to try a number of different options for finding the head commit, because each kind of trigger event + # stores it in a different location + env: + COMMIT_SHA_EXPR: + ${{ github.event.pull_request.head.sha || github.event.head_commit.id || inputs.head_commit }} + run: | + COMMIT_SHA=$(git rev-parse --short "$COMMIT_SHA_EXPR") + echo "COMMIT_SHA=$COMMIT_SHA" >> $GITHUB_ENV + echo "COMMIT_MESSAGE=$(git log -n 1 --pretty=format:%s $COMMIT_SHA)" >> $GITHUB_ENV + + - name: Determine changed packages + uses: dorny/paths-filter@v4.0.3 + id: changed + with: + filters: | + workflow: + - '.github/**' + any_code: + - '!**/*.md' + deps: + - '**/package.json' + - 'pnpm-lock.yaml' + - 'pnpm-workspace.yaml' + + - name: Determine whether tests should run + id: plan + env: + ENABLED: >- + ${{ steps.changed.outputs.any_code == 'true' || github.ref == 'refs/heads/develop' || github.ref == + 'refs/heads/v10' || github.ref == 'refs/heads/v9' || github.ref == 'refs/heads/v8' || startsWith(github.ref, + 'refs/heads/release/') }} + run: echo "enabled=$ENABLED" >> "$GITHUB_OUTPUT" + + - name: Set up Node + if: steps.plan.outputs.enabled == 'true' + uses: ./.github/actions/setup-node + + - name: Set up affected-project planner + if: + steps.plan.outputs.enabled == 'true' && github.event_name == 'pull_request' && steps.changed.outputs.workflow + != 'true' + uses: ./.github/actions/setup-nx-planner + + - name: Check for Affected Nx Projects + uses: ./.github/actions/nx-affected-list + id: checkForAffected + if: + steps.plan.outputs.enabled == 'true' && github.event_name == 'pull_request' && steps.changed.outputs.workflow + != 'true' + with: + base: ${{ github.event.pull_request.base.sha }} + head: ${{ inputs.head_commit }} + + - name: Determine which test applications should be run + id: matrix + if: steps.plan.outputs.enabled == 'true' + run: + node ./lib/getTestMatrix.mjs --shards=2 --separate-aws-layer --base=${{ (github.event_name == 'pull_request' + && steps.changed.outputs.workflow != 'true' && github.event.pull_request.base.sha) || '' }} >> $GITHUB_OUTPUT + working-directory: dev-packages/e2e-tests + + - name: Determine which optional E2E test applications should be run + id: matrix-optional + if: steps.plan.outputs.enabled == 'true' + run: + node ./lib/getTestMatrix.mjs --variant=optional --base=${{ (github.event_name == 'pull_request' && + steps.changed.outputs.workflow != 'true' && github.event.pull_request.base.sha) || '' }} >> $GITHUB_OUTPUT + working-directory: dev-packages/e2e-tests + + outputs: + commit_label: '${{ env.COMMIT_SHA }}: ${{ env.COMMIT_MESSAGE }}' + # Note: These next three have to be checked as strings ('true'/'false')! + is_base_branch: + ${{ github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/v10' || github.ref == 'refs/heads/v9' || + github.ref == 'refs/heads/v8'}} + is_release: ${{ startsWith(github.ref, 'refs/heads/release/') }} + changed_ci: ${{ steps.changed.outputs.workflow == 'true' }} + changed_any_code: ${{ steps.changed.outputs.any_code == 'true' }} + changed_deps: ${{ steps.changed.outputs.deps == 'true' }} + + # When merging into master, or from master + is_gitflow_sync: ${{ github.head_ref == 'master' || github.ref == 'refs/heads/master' }} + has_gitflow_label: + ${{ github.event_name == 'pull_request' && contains(toJSON(github.event.pull_request.labels.*.name), 'Gitflow') + }} + force_skip_cache: + ${{ github.event_name == 'schedule' || (github.event_name == 'pull_request' && + contains(toJSON(github.event.pull_request.labels.*.name), 'ci-skip-cache')) }} + should_run_tests: ${{ steps.plan.outputs.enabled == 'true' }} + changed_node_integration: + ${{ steps.changed.outputs.workflow == 'true' || contains(steps.checkForAffected.outputs.affected, + '@sentry-internal/node-integration-tests') }} + changed_node: + ${{ steps.changed.outputs.workflow == 'true' || contains(steps.checkForAffected.outputs.affected, + '@sentry/node') }} + changed_deno: + ${{ steps.changed.outputs.workflow == 'true' || contains(steps.checkForAffected.outputs.affected, + '@sentry/deno') }} + changed_bun: + ${{ steps.changed.outputs.workflow == 'true' || contains(steps.checkForAffected.outputs.affected, '@sentry/bun') + }} + changed_bun_integration: + ${{ steps.changed.outputs.workflow == 'true' || contains(steps.checkForAffected.outputs.affected, + '@sentry-internal/bun-integration-tests') }} + changed_deno_integration: + ${{ steps.changed.outputs.workflow == 'true' || contains(steps.checkForAffected.outputs.affected, + '@sentry-internal/deno-integration-tests') }} + changed_browser_integration: + ${{ steps.changed.outputs.workflow == 'true' || contains(steps.checkForAffected.outputs.affected, + '@sentry-internal/browser-integration-tests') }} + changed_cloudflare_integration: + ${{ steps.changed.outputs.workflow == 'true' || contains(steps.checkForAffected.outputs.affected, + '@sentry-internal/cloudflare-integration-tests') }} + changed_bundler_plugin_integration: + ${{ steps.changed.outputs.workflow == 'true' || contains(steps.checkForAffected.outputs.affected, + '@sentry-internal/bundler-plugin-integration-tests') }} + changed_aws_serverless: + ${{ steps.changed.outputs.workflow == 'true' || contains(steps.checkForAffected.outputs.affected, + '@sentry/aws-serverless') }} + e2e-matrix-1: ${{ steps.matrix.outputs.matrix-1 || '{"include":[]}' }} + e2e-matrix-2: ${{ steps.matrix.outputs.matrix-2 || '{"include":[]}' }} + e2e-matrix-aws-layer: ${{ steps.matrix.outputs.matrix-aws-layer || '{"include":[]}' }} + e2e-matrix-optional: ${{ steps.matrix-optional.outputs.matrix || '{"include":[]}' }} + e2e-matrix-with-secrets: ${{ steps.matrix.outputs.matrix-with-secrets || '{"include":[]}' }} + e2e-matrix-optional-without-secrets: + ${{ steps.matrix-optional.outputs.matrix-without-secrets || '{"include":[]}' }}