Skip to content

Commit a90a5e4

Browse files
committed
improve workflow
1 parent 40bda26 commit a90a5e4

4 files changed

Lines changed: 161 additions & 71 deletions

File tree

.github/sdk-matrix.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[
2+
{
3+
"language": "node",
4+
"sdk_repo": "workos/workos-node",
5+
"sdk_checkout_path": "backend/workos-node"
6+
}
7+
]

.github/workflows/generate-sdks.yml

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,27 @@ concurrency:
1212
cancel-in-progress: true
1313

1414
jobs:
15+
load-matrix:
16+
runs-on: ubuntu-latest
17+
outputs:
18+
matrix: ${{ steps.set-matrix.outputs.matrix }}
19+
steps:
20+
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
21+
with:
22+
sparse-checkout: .github/sdk-matrix.json
23+
sparse-checkout-cone-mode: false
24+
25+
- name: Load SDK matrix
26+
id: set-matrix
27+
run: echo "matrix=$(jq -c . .github/sdk-matrix.json)" >> "$GITHUB_OUTPUT"
28+
1529
generate:
30+
needs: load-matrix
1631
runs-on: ubuntu-latest
1732
strategy:
1833
fail-fast: false
1934
matrix:
20-
include:
21-
- language: node
22-
sdk_repo: workos/workos-node
23-
sdk_checkout_path: backend/workos-node
35+
include: ${{ fromJson(needs.load-matrix.outputs.matrix) }}
2436

2537
steps:
2638
- name: Generate GitHub App token
@@ -190,30 +202,6 @@ jobs:
190202
--title "${PREFIX}(generated): ${SUMMARY}" \
191203
--body "$BODY"
192204
193-
- name: Create issue on failure
194-
if: failure()
195-
env:
196-
GH_TOKEN: ${{ steps.app-token.outputs.token }}
197-
run: |
198-
BODY="## Failure
199-
- Language: ${{ matrix.language }}
200-
- Triggered by: ${{ github.sha }}
201-
202-
## Details
203-
- Exit 1: compat violations or smoke test findings
204-
- Exit 2: generated SDK failed to compile
205-
206-
## Next Steps
207-
- Check workflow run artifacts for smoke-diff-findings.json or smoke-compile-errors.json
208-
- The emitter may need a targeted fix for a new spec pattern
209-
210-
Run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
211-
212-
gh issue create \
213-
--repo workos/openapi-spec \
214-
--title "SDK generation failed for ${{ matrix.language }}" \
215-
--body "$BODY"
216-
217205
- name: Upload diagnostics
218206
if: always()
219207
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2

.github/workflows/restrict-issues.yml

Lines changed: 0 additions & 43 deletions
This file was deleted.
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
name: Validate SDKs
2+
3+
on:
4+
pull_request:
5+
branches: [main]
6+
7+
concurrency:
8+
group: sdk-validation-${{ github.event.pull_request.number }}
9+
cancel-in-progress: true
10+
11+
jobs:
12+
detect-changes:
13+
runs-on: ubuntu-latest
14+
outputs:
15+
spec-changed: ${{ steps.filter.outputs.spec }}
16+
matrix: ${{ steps.set-matrix.outputs.matrix }}
17+
steps:
18+
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
19+
20+
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
21+
id: filter
22+
with:
23+
filters: |
24+
spec:
25+
- 'spec/**'
26+
27+
- name: Load SDK matrix
28+
id: set-matrix
29+
run: echo "matrix=$(jq -c . .github/sdk-matrix.json)" >> "$GITHUB_OUTPUT"
30+
31+
sdk_build:
32+
needs: detect-changes
33+
if: needs.detect-changes.outputs.spec-changed == 'true'
34+
runs-on: ubuntu-latest
35+
strategy:
36+
fail-fast: false
37+
matrix:
38+
include: ${{ fromJson(needs.detect-changes.outputs.matrix) }}
39+
40+
steps:
41+
- name: Generate GitHub App token
42+
id: app-token
43+
uses: actions/create-github-app-token@fee1f7d63c2ff003460e3d139729b119787bc349 # v2.2.2
44+
with:
45+
app-id: ${{ secrets.SDK_BOT_APP_ID }}
46+
private-key: ${{ secrets.SDK_BOT_PRIVATE_KEY }}
47+
48+
- name: Checkout openapi-spec
49+
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
50+
with:
51+
path: openapi-spec
52+
53+
- name: Checkout oagen-emitters
54+
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
55+
with:
56+
repository: workos/oagen-emitters
57+
token: ${{ steps.app-token.outputs.token }}
58+
path: oagen-emitters
59+
60+
- name: Checkout live SDK
61+
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
62+
with:
63+
repository: ${{ matrix.sdk_repo }}
64+
token: ${{ steps.app-token.outputs.token }}
65+
path: ${{ matrix.sdk_checkout_path }}
66+
67+
- name: Setup Node
68+
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
69+
with:
70+
node-version: '24'
71+
cache: 'npm'
72+
cache-dependency-path: oagen-emitters/package-lock.json
73+
74+
- name: Install dependencies
75+
working-directory: oagen-emitters
76+
run: npm ci
77+
78+
- name: Extract baseline
79+
working-directory: oagen-emitters
80+
run: npm run sdk:extract:${{ matrix.language }}
81+
82+
- name: Generate
83+
working-directory: oagen-emitters
84+
run: npm run sdk:generate:${{ matrix.language }}
85+
86+
- name: Verify
87+
working-directory: oagen-emitters
88+
run: npm run sdk:verify:${{ matrix.language }}
89+
90+
- name: Comment on failure
91+
if: failure()
92+
uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7.1.0
93+
with:
94+
github-token: ${{ steps.app-token.outputs.token }}
95+
script: |
96+
const body = [
97+
`## SDK build failed for \`${{ matrix.language }}\``,
98+
'',
99+
'The spec changes in this PR caused the **${{ matrix.language }}** SDK build to fail.',
100+
'',
101+
`**[View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})**`,
102+
'',
103+
'This check must pass before the PR can be merged.'
104+
].join('\n');
105+
106+
await github.rest.issues.createComment({
107+
owner: context.repo.owner,
108+
repo: context.repo.repo,
109+
issue_number: context.issue.number,
110+
body
111+
});
112+
113+
- name: Upload diagnostics
114+
if: always()
115+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
116+
with:
117+
name: oagen-diagnostics-${{ matrix.language }}
118+
path: |
119+
oagen-emitters/sdk/
120+
oagen-emitters/sdk-*-surface.json
121+
oagen-emitters/smoke-*.json
122+
retention-days: 14
123+
124+
sdk-validation:
125+
runs-on: ubuntu-latest
126+
needs: [detect-changes, sdk_build]
127+
if: always()
128+
steps:
129+
- name: Check result
130+
run: |
131+
if [[ "${{ needs.detect-changes.outputs.spec-changed }}" != "true" ]]; then
132+
echo "No spec changes, skipping SDK validation"
133+
exit 0
134+
fi
135+
if [[ "${{ needs.sdk_build.result }}" != "success" ]]; then
136+
echo "SDK build failed"
137+
exit 1
138+
fi

0 commit comments

Comments
 (0)