-
Notifications
You must be signed in to change notification settings - Fork 11
ci: ensure JSON schemas are in sync #539
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 18 commits
082448f
4801b44
2c60146
44083a8
2c5150e
000c4bd
f4129b9
01c4066
19b5ea1
2184d0b
3730252
fafaace
e80e469
b207d1b
e572fab
261a8e0
b9615c6
b7d5f54
9ffafa1
b0449a0
05d9dae
578a154
0be3e37
00cbcdc
e6ccc08
7e2c66f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| name: Check JSON schemas consistency | ||
|
|
||
| # The json_schemas package contains TypeScript code that generates JSON schema files. | ||
| # This workflow ensures that any changes to the TypeScript code are reflected in the generated JSON schema files. | ||
| # If there is a mismatch, the workflow fails, prompting the developer to regenerate the JSON schema files. | ||
|
|
||
| on: | ||
| pull_request: | ||
| # List all .ts - .json file pairs that need to be kept in sync | ||
| paths: | ||
| - 'packages/json_schemas/src/actor.schema.ts' | ||
| - 'packages/json_schemas/schemas/actor.schema.json' | ||
|
|
||
| jobs: | ||
| check_json_schemas: | ||
| name: 'Check JSON schemas consistency' | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v5 | ||
|
|
||
| - name: Use Node.js ${{ matrix.node-version }} | ||
| uses: actions/setup-node@v5 | ||
| with: | ||
| node-version: ${{ matrix.node-version }} | ||
|
|
||
| - name: Cache node_modules | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: '**/node_modules' | ||
| key: ${{ runner.os }}-${{ matrix.node-version }}-modules-${{ hashFiles('**/package-lock.json') }} | ||
|
|
||
| - name: Install Dependencies | ||
| run: npm ci --no-audit | ||
| - run: npm run build | ||
|
|
||
| - name: Check JSON consistency | ||
| run: | | ||
| files_to_check=( | ||
| "packages/json_schemas/src/actor.schema.ts|packages/json_schemas/schemas/actor.schema.json" | ||
| # add more ts|json pairs here | ||
| ) | ||
|
|
||
| failed=0 | ||
|
|
||
| for pair in "${files_to_check[@]}"; do | ||
| ts_file="${pair%%|*}" | ||
| json_file="${pair##*|}" | ||
|
|
||
| if ! git diff --exit-code "$json_file" >/dev/null; then | ||
| echo "ERROR: $json_file is out of sync with $ts_file." | ||
| echo "Please put the schema changes to .ts file ($ts_file) and update the .json file ($json_file) by running the build script (npm run build)." | ||
| failed=1 | ||
| fi | ||
| done | ||
|
|
||
| if [ $failed -eq 1 ]; then | ||
| exit 1 | ||
| fi | ||
|
||
Uh oh!
There was an error while loading. Please reload this page.