name: E2E Tests on: pull_request: push: branches: - main concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: changes: runs-on: ubuntu-latest permissions: contents: read pull-requests: read outputs: should_run: ${{ github.event_name == 'push' || steps.filter.outputs.cli == 'true' }} steps: - uses: actions/checkout@v7 - uses: dorny/paths-filter@7b450fff21473bca461d4b92ce414b9d0420d706 # v4 id: filter with: filters: | cli: - 'packages/@sanity/cli/**' - 'packages/@sanity/cli-build/**' - 'packages/@sanity/cli-core/**' - 'packages/@sanity/cli-e2e/**' - 'packages/@sanity/cli-setup/**' - 'packages/@sanity/cli-test/**' - 'packages/create-sanity/**' - 'fixtures/**' - 'pnpm-lock.yaml' e2e: needs: changes if: needs.changes.outputs.should_run == 'true' runs-on: ${{ matrix.os }} timeout-minutes: 20 env: TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} TURBO_TEAM: ${{ vars.TURBO_TEAM }} # Skip npm's advisory lookup and funding notice in every install this job # runs, including the packed-CLI install in the e2e global setup. npm_config_audit: 'false' npm_config_fund: 'false' strategy: matrix: os: [ubuntu-latest] node-version: [22, 24, 26] shardIndex: [1, 2] shardTotal: [2] fail-fast: false steps: - uses: actions/checkout@v7 - name: Setup Environment uses: ./.github/actions/setup with: node-version: ${{ matrix.node-version }} - name: Restore Vitest cache uses: actions/cache@v6 with: path: packages/@sanity/cli-e2e/node_modules/.vite/vitest key: vitest-e2e-cache-${{ matrix.os }}-node${{ matrix.node-version }}-shard${{ matrix.shardIndex }}-${{ github.run_id }} restore-keys: | vitest-e2e-cache-${{ matrix.os }}-node${{ matrix.node-version }}-shard${{ matrix.shardIndex }}- - name: Build CLI run: pnpm build:cli - name: Run E2E tests env: SANITY_E2E_TOKEN: ${{ secrets.SANITY_E2E_TOKEN }} SANITY_E2E_PROJECT_ID: ${{ secrets.SANITY_E2E_PROJECT_ID }} SANITY_E2E_DATASET: ${{ secrets.SANITY_E2E_DATASET }} SANITY_E2E_ORGANIZATION_ID: ${{ secrets.SANITY_E2E_ORGANIZATION_ID }} run: | set -o pipefail pnpm --filter @sanity/cli-e2e test --shard ${{ matrix.shardIndex }}/${{ matrix.shardTotal }} 2>&1 | tee "$RUNNER_TEMP/e2e-log.txt" - name: Upload test log to GitHub Actions Artifacts if: ${{ !cancelled() }} uses: actions/upload-artifact@v7 with: name: e2e-log-node${{ matrix.node-version }}-shard${{ matrix.shardIndex }} path: ${{ runner.temp }}/e2e-log.txt retention-days: 1 overwrite: true e2e-status: if: always() needs: [changes, e2e] runs-on: ubuntu-latest steps: - name: Check status run: | # Fail if any needed job failed or was cancelled results=("${{ needs.changes.result }}" "${{ needs.e2e.result }}") for result in "${results[@]}"; do if [ "$result" == "failure" ] || [ "$result" == "cancelled" ]; then echo "Job failed or was cancelled: $result" exit 1 fi done echo "All jobs passed or were skipped"