ci #3436
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
| name: ci | |
| on: | |
| push: | |
| branches: | |
| - automation/brawl/try/* | |
| - automation/brawl/merge/* | |
| pull_request: | |
| workflow_dispatch: | |
| schedule: | |
| - cron: "0 13 * * *" | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| env: | |
| SHA: ${{ github.event.pull_request.head.sha || github.sha }} | |
| defaults: | |
| run: | |
| shell: bash | |
| jobs: | |
| bazel-diff: | |
| name: bazel-diff | |
| runs-on: ubuntu-24.04 | |
| if: ${{ github.event_name == 'pull_request' }} | |
| env: | |
| MODIFIED_FILES: /tmp/modified-files.txt | |
| HEAD_HASHES: /tmp/head-hashes.json | |
| BASE_HASHES: /tmp/base-hashes.json | |
| IMPACTED_TARGETS: /tmp/impacted-targets.txt | |
| BASE_WORKTREE: /tmp/base | |
| steps: | |
| - uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup worktree | |
| run: git worktree add ${{ env.BASE_WORKTREE }} ${{ github.event.pull_request.base.sha }} | |
| - uses: ./.github/actions/setup-bazel | |
| with: | |
| build_buddy_token: ${{ secrets.BUILD_BUDDY_TOKEN }} | |
| - name: File diff | |
| run: git diff --name-only ${{ github.event.pull_request.base.sha }}..${{ github.sha }} > ${{ env.MODIFIED_FILES }} | |
| - name: Generate current hashes | |
| run: bazel run //tools/bazel-diff -- generate-hashes --workspacePath=$(pwd) --keep_going --includeTargetType -co="--enable_workspace" > ${{ env.HEAD_HASHES }} | |
| - name: Generate base hashes | |
| run: bazel run //tools/bazel-diff -- generate-hashes --workspacePath=${{ env.BASE_WORKTREE }} --keep_going --includeTargetType -co="--enable_workspace" > ${{ env.BASE_HASHES }} | |
| - name: Get impacted targets | |
| run: bazel run //tools/bazel-diff -- get-impacted-targets --startingHashes=${{ env.BASE_HASHES }} --finalHashes=${{ env.HEAD_HASHES }} --output=${{ env.IMPACTED_TARGETS }} | |
| - name: Upload Results | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: bazel-diff-impacted-targets | |
| path: ${{ env.IMPACTED_TARGETS }} | |
| prep: | |
| name: prep | |
| runs-on: ubuntu-24.04 | |
| outputs: | |
| prep: ${{ steps.compute.outputs.prep }} | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Run prep | |
| id: compute | |
| env: | |
| JSON_INPUT: ${{ toJson(github) }} | |
| run: | | |
| set -xeo pipefail | |
| echo $JSON_INPUT | python3 .github/scripts/ci-prep.py | tee -a $GITHUB_OUTPUT | |
| check_vendor: | |
| needs: [prep] | |
| if: ${{ !failure() && fromJson(needs.prep.outputs.prep).check_vendor != null }} | |
| uses: ./.github/workflows/ci-check-vendor.yaml | |
| secrets: | |
| build_buddy_token: ${{ secrets.BUILD_BUDDY_TOKEN }} | |
| test: | |
| needs: [prep, bazel-diff] | |
| if: ${{ !failure() && fromJson(needs.prep.outputs.prep).test != null }} | |
| uses: ./.github/workflows/ci-test.yaml | |
| with: | |
| commit_sha: "${{ fromJson(needs.prep.outputs.prep).test.commit_sha }}" | |
| pr_number: "${{ fromJson(needs.prep.outputs.prep).test.pr_number }}" | |
| matrix: "${{ toJson(fromJson(needs.prep.outputs.prep).test.matrix) }}" | |
| secrets: | |
| codecov_token: "${{ secrets.CODECOV_TOKEN }}" | |
| build_buddy_token: "${{ secrets.BUILD_BUDDY_TOKEN }}" | |
| check_fmt: | |
| needs: [prep] | |
| if: ${{ !failure() && fromJson(needs.prep.outputs.prep).check_fmt != null }} | |
| uses: ./.github/workflows/ci-check-fmt.yaml | |
| secrets: | |
| build_buddy_token: ${{ secrets.BUILD_BUDDY_TOKEN }} | |
| grind: | |
| needs: [prep, bazel-diff] | |
| if: ${{ !failure() && fromJson(needs.prep.outputs.prep).grind != null }} | |
| uses: ./.github/workflows/ci-grind.yaml | |
| with: | |
| matrix: "${{ toJson(fromJson(needs.prep.outputs.prep).grind.matrix) }}" | |
| secrets: | |
| codecov_token: "${{ secrets.CODECOV_TOKEN }}" | |
| build_buddy_token: "${{ secrets.BUILD_BUDDY_TOKEN }}" | |
| preview: | |
| needs: [prep, bazel-diff] | |
| if: ${{ !failure() && fromJson(needs.prep.outputs.prep).preview != null }} | |
| uses: ./.github/workflows/ci-preview.yaml | |
| permissions: | |
| pull-requests: write | |
| with: | |
| pr_number: "${{ fromJson(needs.prep.outputs.prep).preview.pr_number }}" | |
| commit_sha: "${{ fromJson(needs.prep.outputs.prep).preview.commit_sha }}" | |
| deploy: "${{ fromJson(needs.prep.outputs.prep).preview.deploy }}" | |
| secrets: | |
| build_buddy_token: ${{ secrets.BUILD_BUDDY_TOKEN }} | |
| vercel_token: ${{ secrets.VERCEL_TOKEN }} | |
| vercel_org_id: ${{ secrets.VERCEL_ORG_ID }} | |
| vercel_project_id_dashboard: ${{ secrets.VERCEL_PROJECT_ID_APP_SCUFFLE_CLOUD }} | |
| vercel_project_id_docs: ${{ secrets.VERCEL_PROJECT_ID_DOCS_SCUFFLE_CLOUD }} | |
| vercel_project_id_rustdoc: ${{ secrets.VERCEL_PROJECT_ID_DOCS_SCUFFLE_RS }} | |
| vercel_project_id_cloud_emails_render: ${{ secrets.VERCEL_PROJECT_ID_SCUFFLECLOUD_EMAILS_RENDER }} | |
| brawl-done: | |
| runs-on: ubuntu-24.04 | |
| needs: [check_vendor, test, check_fmt, grind, preview] | |
| if: ${{ !cancelled() && github.event_name == 'push' }} | |
| steps: | |
| - name: calculate the correct exit status | |
| run: jq --exit-status 'all(.result == "success" or .result == "skipped")' <<< '${{ toJson(needs) }}' |