|
| 1 | +name: API Changes |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + types: [opened, synchronize, reopened, ready_for_review] |
| 6 | + branches: |
| 7 | + - main |
| 8 | + - release/v4 |
| 9 | + - release/core-2 |
| 10 | + paths: |
| 11 | + - 'packages/clerk-js/**' |
| 12 | + - 'packages/react/**' |
| 13 | + - 'packages/shared/**' |
| 14 | + - 'snapi.config.json' |
| 15 | + - '.github/workflows/api-changes.yml' |
| 16 | + |
| 17 | +permissions: |
| 18 | + contents: read |
| 19 | + |
| 20 | +concurrency: |
| 21 | + group: ${{ github.workflow }}-${{ github.head_ref || github.ref }} |
| 22 | + cancel-in-progress: true |
| 23 | + |
| 24 | +jobs: |
| 25 | + check-api: |
| 26 | + if: ${{ github.event_name != 'pull_request' || github.event.pull_request.draft == false }} |
| 27 | + name: API Changes |
| 28 | + runs-on: 'blacksmith-8vcpu-ubuntu-2204' |
| 29 | + continue-on-error: true |
| 30 | + defaults: |
| 31 | + run: |
| 32 | + shell: bash |
| 33 | + timeout-minutes: ${{ vars.TIMEOUT_MINUTES_NORMAL && fromJSON(vars.TIMEOUT_MINUTES_NORMAL) || 10 }} |
| 34 | + |
| 35 | + env: |
| 36 | + SNAPI_PACKAGE: github:clerk/snapi#8c021a2796b313cdefa945a715df8f02e4f99867 |
| 37 | + SNAPI_FILTERS: >- |
| 38 | + --filter=@clerk/clerk-js |
| 39 | + --filter=@clerk/react |
| 40 | + --filter=@clerk/shared |
| 41 | +
|
| 42 | + steps: |
| 43 | + - name: Checkout Repo |
| 44 | + uses: actions/checkout@v4 |
| 45 | + with: |
| 46 | + fetch-depth: 100 |
| 47 | + fetch-tags: false |
| 48 | + filter: 'blob:none' |
| 49 | + show-progress: false |
| 50 | + |
| 51 | + - name: Fetch base branch |
| 52 | + run: git fetch origin "${GITHUB_BASE_REF}:refs/remotes/origin/${GITHUB_BASE_REF}" --depth=100 |
| 53 | + |
| 54 | + - name: Setup |
| 55 | + id: config |
| 56 | + uses: ./.github/actions/init-blacksmith |
| 57 | + with: |
| 58 | + cache-enabled: true |
| 59 | + turbo-signature: ${{ secrets.TURBO_REMOTE_CACHE_SIGNATURE_KEY }} |
| 60 | + turbo-team: ${{ vars.TURBO_TEAM }} |
| 61 | + turbo-token: ${{ secrets.TURBO_TOKEN }} |
| 62 | + |
| 63 | + - name: Build current declarations |
| 64 | + run: pnpm turbo build:declarations $TURBO_ARGS $SNAPI_FILTERS |
| 65 | + |
| 66 | + - name: Generate current API snapshots |
| 67 | + run: pnpm dlx --package "$SNAPI_PACKAGE" snapi snapshot --output .api-snapshots-current |
| 68 | + |
| 69 | + - name: Create baseline worktree |
| 70 | + run: | |
| 71 | + mkdir -p .worktrees |
| 72 | + git worktree add .worktrees/snapi-baseline "origin/${GITHUB_BASE_REF}" |
| 73 | + cp snapi.config.json .worktrees/snapi-baseline/snapi.config.json |
| 74 | +
|
| 75 | + - name: Install baseline dependencies |
| 76 | + run: pnpm --dir .worktrees/snapi-baseline install --frozen-lockfile |
| 77 | + |
| 78 | + - name: Build baseline declarations |
| 79 | + run: pnpm --dir .worktrees/snapi-baseline turbo build:declarations $TURBO_ARGS $SNAPI_FILTERS |
| 80 | + |
| 81 | + - name: Generate baseline API snapshots |
| 82 | + run: | |
| 83 | + pnpm --dir .worktrees/snapi-baseline dlx --package "$SNAPI_PACKAGE" snapi snapshot \ |
| 84 | + --output "$GITHUB_WORKSPACE/.api-snapshots-baseline" |
| 85 | +
|
| 86 | + - name: Detect API changes |
| 87 | + run: | |
| 88 | + pnpm dlx --package "$SNAPI_PACKAGE" snapi detect \ |
| 89 | + --baseline .api-snapshots-baseline \ |
| 90 | + --output api-changes-report.md \ |
| 91 | + --fail-on-breaking |
| 92 | +
|
| 93 | + - name: Upload API changes report |
| 94 | + uses: actions/upload-artifact@v4 |
| 95 | + if: always() |
| 96 | + with: |
| 97 | + name: api-changes-report |
| 98 | + path: api-changes-report.md |
| 99 | + if-no-files-found: ignore |
| 100 | + retention-days: 5 |
0 commit comments