Skip to content
23 changes: 20 additions & 3 deletions .github/workflows/schema-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ name: schema-test
# Issue: https://github.com/OAI/OpenAPI-Specification/pull/2489

#
# This workflow runs the npm test script to validate passing and failing
# testcases for the metaschema.
# This workflow
# - converts the YAML metaschemas to JSON
# - runs the npm test script to validate passing and failing testcases for the metaschemas
# - checks in changed JSON files
#

# run this on push to any branch and creation of pull-requests
on:
push: {}
pull_request: {}
workflow_dispatch: {}

jobs:
Expand All @@ -23,13 +24,29 @@ jobs:
- uses: actions/checkout@v4 # checkout repo content
with:
fetch-depth: 0

- uses: actions/setup-node@v4 # setup Node.js
with:
node-version: '20.x'

- name: Install dependencies from main
run: |
git checkout remotes/origin/main -- package.json package-lock.json
npm ci

- name: convert YAML metaschemas to JSON
run: find schemas/v3* -type f -name "*.yaml" | xargs node scripts/yaml2json/yaml2json.js

- name: Run tests
run: npm run test

- name: Check in changed JSON files
run: |
git config user.name ${GITHUB_ACTOR}
git config user.email ${PUSHER_EMAIL}
git add schemas/**/*.json
git diff-index --quiet HEAD schemas/**/*.json || git commit -m "converted JSON metaschemas"
git push
env:
CI: true
PUSHER_EMAIL: ${{ github.event.pusher.email }}
130 changes: 71 additions & 59 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
"c8": "^10.1.2",
"markdownlint-cli": "^0.42.0",
"mdv": "^1.3.4",
"vitest": "^2.1.3",
"yaml": "^2.6.0"
"vitest": "^2.1.2",
"yaml": "^2.5.1"
},
"keywords": [
"OpenAPI",
Expand Down
Loading