name: CI on: pull_request: branches: - main push: branches: - main # Required checks must also report for merge queue entries, or the queue waits until it times out. merge_group: permissions: contents: read concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true env: CI: true # Resolve repository .npmrc placeholders without exposing credentials to build/test code. NPM_TOKEN: '' jobs: plan: permissions: contents: read actions: read packages: read runs-on: ubuntu-latest timeout-minutes: 10 outputs: full: ${{ steps.plan.outputs.full }} base: ${{ steps.scope.outputs.base }} head: ${{ steps.scope.outputs.head }} builds: ${{ steps.scope.outputs.builds }} tests: ${{ steps.scope.outputs.tests }} steps: - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v4.2.2 with: persist-credentials: false - uses: ./.github/actions/plan-validation id: plan with: workflow: ci.yml npm-token: ${{ secrets.PERSONAL_TOKEN }} # The planner may have checked out a version baseline; scope uses the # event's immutable candidate SHA, never that mutable worktree state. - name: inspect affected scope id: scope if: steps.plan.outputs.full == 'true' run: | git -c advice.detachedHead=false checkout --detach "$GITHUB_SHA" node scripts/ci/affected-scope.mjs contracts: needs: plan if: needs.plan.outputs.full == 'true' permissions: contents: read packages: read runs-on: ubuntu-latest timeout-minutes: 10 steps: - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v4.2.2 with: fetch-depth: 0 persist-credentials: false - uses: ./.github/actions/prepare-workspace with: build: 'false' npm-token: ${{ secrets.PERSONAL_TOKEN }} - name: validate source contracts and changed-file lint run: node scripts/ci/run-pr-check.mjs contracts env: PR_SCOPE_BASE: ${{ needs.plan.outputs.base }} PR_SCOPE_HEAD: ${{ needs.plan.outputs.head }} build: needs: plan if: needs.plan.outputs.full == 'true' && needs.plan.outputs.builds == 'true' permissions: contents: read packages: read runs-on: ubuntu-latest timeout-minutes: 15 steps: - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v4.2.2 with: fetch-depth: 0 persist-credentials: false - uses: ./.github/actions/prepare-workspace with: build: 'false' npm-token: ${{ secrets.PERSONAL_TOKEN }} - name: restore turbo build cache uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 with: path: .turbo/cache key: turbo-${{ runner.os }}-${{ github.sha }} restore-keys: turbo-${{ runner.os }}- - name: build affected packages and dependencies once run: node scripts/ci/run-pr-check.mjs build env: PR_SCOPE_BASE: ${{ needs.plan.outputs.base }} PR_SCOPE_HEAD: ${{ needs.plan.outputs.head }} - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 with: name: pr-build path: pr-build.tgz retention-days: 1 test: needs: [plan, build] if: ${{ !cancelled() && needs.plan.outputs.full == 'true' && needs.plan.outputs.tests == 'true' && (needs.build.result == 'success' || needs.build.result == 'skipped') }} permissions: contents: read packages: read runs-on: ubuntu-latest timeout-minutes: 15 strategy: fail-fast: true matrix: shard: [1, 2, 3, 4] steps: - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v4.2.2 with: fetch-depth: 0 persist-credentials: false - uses: ./.github/actions/setup-rendering-fonts - uses: ./.github/actions/prepare-workspace with: build: 'false' npm-token: ${{ secrets.PERSONAL_TOKEN }} - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0 if: needs.build.result == 'success' with: name: pr-build - name: test affected packages and consumers run: node scripts/ci/run-pr-check.mjs test env: PR_SCOPE_BASE: ${{ needs.plan.outputs.base }} PR_SCOPE_HEAD: ${{ needs.plan.outputs.head }} PR_SHARD: ${{ matrix.shard }} checks: needs: [plan, contracts, build, test] if: ${{ always() && !cancelled() }} runs-on: ubuntu-latest timeout-minutes: 1 steps: - name: require all selected checks and valid planning env: PLAN: ${{ needs.plan.result }} FULL: ${{ needs.plan.outputs.full }} CONTRACTS: ${{ needs.contracts.result }} BUILD: ${{ needs.build.result }} TEST: ${{ needs.test.result }} EXPECT_BUILD: ${{ needs.plan.outputs.builds }} EXPECT_TEST: ${{ needs.plan.outputs.tests }} run: | test "$PLAN" = success if [ "$FULL" = true ]; then test "$CONTRACTS" = success if [ "$EXPECT_BUILD" = true ]; then test "$BUILD" = success; fi if [ "$EXPECT_TEST" = true ]; then test "$TEST" = success; fi fi