11name : API Changes
22
33on :
4+ push :
5+ branches :
6+ - main
7+ - release/v4
8+ - release/core-2
9+ paths :
10+ - ' packages/clerk-js/**'
11+ - ' packages/react/**'
12+ - ' packages/shared/**'
13+ - ' packages/ui/**'
14+ - ' snapi.config.json'
15+ - ' .github/workflows/api-changes.yml'
416 pull_request :
517 types : [opened, synchronize, reopened, ready_for_review]
618 branches :
1123 - ' packages/clerk-js/**'
1224 - ' packages/react/**'
1325 - ' packages/shared/**'
26+ - ' packages/ui/**'
1427 - ' snapi.config.json'
1528 - ' .github/workflows/api-changes.yml'
1629
@@ -19,11 +32,58 @@ permissions:
1932
2033concurrency :
2134 group : ${{ github.workflow }}-${{ github.head_ref || github.ref }}
22- cancel-in-progress : true
35+ cancel-in-progress : ${{ github.event_name == 'pull_request' }}
36+
37+ env :
38+ SNAPI_PACKAGE : github:clerk/snapi#8c021a2796b313cdefa945a715df8f02e4f99867
39+ SNAPI_FILTERS : >-
40+ --filter=@clerk/clerk-js
41+ --filter=@clerk/react
42+ --filter=@clerk/shared
43+ --filter=@clerk/ui
2344
2445jobs :
46+ publish-baseline :
47+ if : github.event_name == 'push'
48+ name : Publish API Baseline
49+ runs-on : ' blacksmith-8vcpu-ubuntu-2204'
50+ continue-on-error : true
51+ defaults :
52+ run :
53+ shell : bash
54+ timeout-minutes : ${{ vars.TIMEOUT_MINUTES_NORMAL && fromJSON(vars.TIMEOUT_MINUTES_NORMAL) || 10 }}
55+
56+ steps :
57+ - name : Checkout Repo
58+ uses : actions/checkout@v4
59+ with :
60+ filter : ' blob:none'
61+ show-progress : false
62+
63+ - name : Setup
64+ uses : ./.github/actions/init-blacksmith
65+ with :
66+ cache-enabled : true
67+ turbo-signature : ${{ secrets.TURBO_REMOTE_CACHE_SIGNATURE_KEY }}
68+ turbo-team : ${{ vars.TURBO_TEAM }}
69+ turbo-token : ${{ secrets.TURBO_TOKEN }}
70+
71+ - name : Build declarations
72+ run : pnpm turbo build:declarations $TURBO_ARGS $SNAPI_FILTERS
73+
74+ - name : Generate API snapshot
75+ run : |
76+ pnpm dlx --package "$SNAPI_PACKAGE" snapi snapshot \
77+ --output "$GITHUB_WORKSPACE/.api-snapshots-baseline"
78+
79+ - name : Save baseline to cache
80+ uses : actions/cache/save@v4
81+ with :
82+ path : .api-snapshots-baseline
83+ key : snapi-baseline-${{ github.sha }}
84+
2585 check-api :
26- if : ${{ github.event_name != 'pull_request' || github.event.pull_request.draft == false }}
86+ if : ${{ github.event_name == 'pull_request' && github.event.pull_request.draft == false }}
2787 name : API Changes
2888 runs-on : ' blacksmith-8vcpu-ubuntu-2204'
2989 continue-on-error : true
3292 shell : bash
3393 timeout-minutes : ${{ vars.TIMEOUT_MINUTES_NORMAL && fromJSON(vars.TIMEOUT_MINUTES_NORMAL) || 10 }}
3494
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-
4295 steps :
4396 - name : Checkout Repo
4497 uses : actions/checkout@v4
@@ -48,34 +101,47 @@ jobs:
48101 filter : ' blob:none'
49102 show-progress : false
50103
51- - name : Fetch base branch
52- run : git fetch origin "${GITHUB_BASE_REF}:refs/remotes/origin/${GITHUB_BASE_REF}" --depth=100
53-
54104 - name : Setup
55- id : config
56105 uses : ./.github/actions/init-blacksmith
57106 with :
58107 cache-enabled : true
59108 turbo-signature : ${{ secrets.TURBO_REMOTE_CACHE_SIGNATURE_KEY }}
60109 turbo-team : ${{ vars.TURBO_TEAM }}
61110 turbo-token : ${{ secrets.TURBO_TOKEN }}
62111
112+ - name : Restore baseline from cache
113+ id : baseline-cache
114+ uses : actions/cache/restore@v4
115+ with :
116+ path : .api-snapshots-baseline
117+ key : snapi-baseline-${{ github.event.pull_request.base.sha }}
118+ restore-keys : |
119+ snapi-baseline-
120+
63121 - name : Build current declarations
64122 run : pnpm turbo build:declarations $TURBO_ARGS $SNAPI_FILTERS
65123
124+ - name : Fetch base branch
125+ if : steps.baseline-cache.outputs.cache-matched-key == ''
126+ run : git fetch origin "${GITHUB_BASE_REF}:refs/remotes/origin/${GITHUB_BASE_REF}" --depth=100
127+
66128 - name : Create baseline worktree
129+ if : steps.baseline-cache.outputs.cache-matched-key == ''
67130 run : |
68131 mkdir -p .worktrees
69132 git worktree add .worktrees/snapi-baseline "origin/${GITHUB_BASE_REF}"
70133 cp snapi.config.json .worktrees/snapi-baseline/snapi.config.json
71134
72135 - name : Install baseline dependencies
136+ if : steps.baseline-cache.outputs.cache-matched-key == ''
73137 run : pnpm --dir .worktrees/snapi-baseline install --frozen-lockfile
74138
75139 - name : Build baseline declarations
140+ if : steps.baseline-cache.outputs.cache-matched-key == ''
76141 run : pnpm --dir .worktrees/snapi-baseline turbo build:declarations $TURBO_ARGS $SNAPI_FILTERS
77142
78143 - name : Generate baseline API snapshots
144+ if : steps.baseline-cache.outputs.cache-matched-key == ''
79145 run : |
80146 pnpm --dir .worktrees/snapi-baseline dlx --package "$SNAPI_PACKAGE" snapi snapshot \
81147 --output "$GITHUB_WORKSPACE/.api-snapshots-baseline"
0 commit comments