diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c55483590816..35e2c3e95ccf 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -38,12 +38,35 @@ env: BUILD_CACHE_KEY: ${{ github.event.inputs.commit || github.sha }} jobs: + job_get_metadata: + name: Get Metadata + runs-on: ubuntu-latest + steps: + - name: Check out current commit + uses: actions/checkout@v2 + with: + ref: ${{ env.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 + run: | + COMMIT_SHA=$(git rev-parse --short ${{ github.event.pull_request.head.sha || github.event.head_commit.id || env.HEAD_COMMIT }}) + echo "COMMIT_SHA=$COMMIT_SHA" >> $GITHUB_ENV + echo "COMMIT_MESSAGE=$(git log -n 1 --pretty=format:%s $COMMIT_SHA)" >> $GITHUB_ENV + outputs: + commit_label: "${{ env.COMMIT_SHA }}: ${{ env.COMMIT_MESSAGE }}" + job_install_deps: name: Install Dependencies + needs: job_get_metadata runs-on: ubuntu-latest timeout-minutes: 15 steps: - - name: Check out current commit (${{ env.HEAD_COMMIT }}) + - name: "Check out current commit (${{ needs.job_get_metadata.outputs.commit_label }})" uses: actions/checkout@v2 with: ref: ${{ env.HEAD_COMMIT }} @@ -70,11 +93,11 @@ jobs: job_build: name: Build - needs: job_install_deps + needs: [ job_get_metadata, job_install_deps ] runs-on: ubuntu-latest timeout-minutes: 20 steps: - - name: Check out current commit (${{ env.HEAD_COMMIT }}) + - name: Check out current commit (${{ needs.job_get_metadata.outputs.commit_label }}) uses: actions/checkout@v2 with: ref: ${{ env.HEAD_COMMIT }} @@ -150,13 +173,13 @@ jobs: job_size_check: name: Size Check - needs: job_build + needs: [job_get_metadata, job_build] timeout-minutes: 15 runs-on: ubuntu-latest # Size Check will error out outside of the context of a PR if: ${{ github.event_name == 'pull_request' }} steps: - - name: Check out current commit (${{ env.HEAD_COMMIT }}) + - name: Check out current commit (${{ needs.job_get_metadata.outputs.commit_label }}) uses: actions/checkout@v2 with: ref: ${{ env.HEAD_COMMIT }} @@ -184,11 +207,11 @@ jobs: job_lint: name: Lint - needs: job_build + needs: [job_get_metadata, job_build] timeout-minutes: 10 runs-on: ubuntu-latest steps: - - name: Check out current commit (${{ env.HEAD_COMMIT }}) + - name: Check out current commit (${{ needs.job_get_metadata.outputs.commit_label }}) uses: actions/checkout@v2 with: ref: ${{ env.HEAD_COMMIT }} @@ -211,11 +234,11 @@ jobs: job_circular_dep_check: name: Circular Dependency Check - needs: job_build + needs: [job_get_metadata, job_build] timeout-minutes: 10 runs-on: ubuntu-latest steps: - - name: Check out current commit (${{ env.HEAD_COMMIT }}) + - name: Check out current commit (${{ needs.job_get_metadata.outputs.commit_label }}) uses: actions/checkout@v2 with: ref: ${{ env.HEAD_COMMIT }} @@ -238,12 +261,12 @@ jobs: job_artifacts: name: Upload Artifacts - needs: job_build + needs: [job_get_metadata, job_build] runs-on: ubuntu-latest # Build artifacts are only needed for releasing workflow. if: startsWith(github.ref, 'refs/heads/release/') steps: - - name: Check out current commit (${{ github.sha }}) + - name: Check out current commit (${{ needs.job_get_metadata.outputs.commit_label }}) uses: actions/checkout@v2 with: ref: ${{ env.HEAD_COMMIT }} @@ -275,7 +298,7 @@ jobs: job_unit_test: name: Test (Node ${{ matrix.node }}) - needs: job_build + needs: [job_get_metadata, job_build] continue-on-error: true timeout-minutes: 30 runs-on: ubuntu-latest @@ -283,7 +306,7 @@ jobs: matrix: node: [8, 10, 12, 14, 16, 18] steps: - - name: Check out current commit (${{ env.HEAD_COMMIT }}) + - name: Check out current commit (${{ needs.job_get_metadata.outputs.commit_label }}) uses: actions/checkout@v2 with: ref: ${{ env.HEAD_COMMIT }} @@ -312,7 +335,7 @@ jobs: job_nextjs_integration_test: name: Test @sentry/nextjs on (Node ${{ matrix.node }}) - needs: job_build + needs: [job_get_metadata, job_build] continue-on-error: true timeout-minutes: 30 runs-on: ubuntu-latest @@ -320,7 +343,7 @@ jobs: matrix: node: [10, 12, 14, 16, 18] steps: - - name: Check out current commit (${{ env.HEAD_COMMIT }}) + - name: Check out current commit (${{ needs.job_get_metadata.outputs.commit_label }}) uses: actions/checkout@v2 with: ref: ${{ env.HEAD_COMMIT }} @@ -349,12 +372,12 @@ jobs: # separate job allows them to run in parallel with the other tests. job_ember_tests: name: Test @sentry/ember - needs: job_build + needs: [job_get_metadata, job_build] continue-on-error: true timeout-minutes: 30 runs-on: ubuntu-latest steps: - - name: Check out current commit (${{ env.HEAD_COMMIT }}) + - name: Check out current commit (${{ needs.job_get_metadata.outputs.commit_label }}) uses: actions/checkout@v2 with: ref: ${{ env.HEAD_COMMIT }} @@ -388,7 +411,7 @@ jobs: job_browser_playwright_tests: name: Playwright - ${{ (matrix.tracing_only && 'Browser + Tracing') || 'Browser' }} (${{ matrix.bundle }}) - needs: job_build + needs: [job_get_metadata, job_build] runs-on: ubuntu-latest strategy: matrix: @@ -410,7 +433,7 @@ jobs: - bundle: cjs tracing_only: false steps: - - name: Check out current commit (${{ env.HEAD_COMMIT }}) + - name: Check out current commit (${{ needs.job_get_metadata.outputs.commit_label }}) uses: actions/checkout@v2 with: ref: ${{ env.HEAD_COMMIT }} @@ -439,7 +462,7 @@ jobs: job_browser_integration_tests: name: Old Browser Integration Tests (${{ matrix.browser }}) - needs: job_build + needs: [job_get_metadata, job_build] runs-on: ubuntu-latest timeout-minutes: 10 continue-on-error: true @@ -450,7 +473,7 @@ jobs: - FirefoxHeadless - WebkitHeadless steps: - - name: Check out current commit (${{ env.HEAD_COMMIT }}) + - name: Check out current commit (${{ needs.job_get_metadata.outputs.commit_label }}) uses: actions/checkout@v2 with: ref: ${{ env.HEAD_COMMIT }} @@ -478,12 +501,12 @@ jobs: job_browser_build_tests: name: Browser Build Tests - needs: job_build + needs: [job_get_metadata, job_build] runs-on: ubuntu-latest timeout-minutes: 5 continue-on-error: true steps: - - name: Check out current commit (${ env.HEAD_COMMIT }}) + - name: Check out current commit (${{ needs.job_get_metadata.outputs.commit_label }}) uses: actions/checkout@v2 with: ref: ${{ env.HEAD_COMMIT }} @@ -512,7 +535,7 @@ jobs: job_node_integration_tests: name: Node SDK Integration Tests (${{ matrix.node }}) - needs: job_build + needs: [job_get_metadata, job_build] runs-on: ubuntu-latest timeout-minutes: 10 continue-on-error: true @@ -520,7 +543,7 @@ jobs: matrix: node: [10, 12, 14, 16, 18] steps: - - name: Check out current commit (${{ github.sha }}) + - name: Check out current commit (${{ needs.job_get_metadata.outputs.commit_label }}) uses: actions/checkout@v2 with: ref: ${{ env.HEAD_COMMIT }}