Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions .github/workflows/apply-test-ids.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Test IDs

on:
pull_request_target:
types: [opened, synchronize]
paths:
- 'tests/**/*.json'

permissions:
contents: write

jobs:
generate:
runs-on: ubuntu-latest

steps:
- name: Detect changed files
uses: dorny/paths-filter@v3
id: changes
with:
filters: |
other:
- '!tests/**/*.json'

- name: Block mixed changes
if: steps.changes.outputs.other == 'true'
run: |
echo "Tests and other files were changed together."
echo "Please submit test JSON changes separately."
exit 1

- name: Checkout PR branch
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: latest

- name: Install dependencies
run: npm ci

- name: Generate test IDs
run: |
node scripts/generate-ids-for.js draft2020-12
node scripts/generate-ids-for.js draft2019-09
node scripts/generate-ids-for.js draft7
node scripts/generate-ids-for.js draft6
node scripts/generate-ids-for.js draft4
node scripts/generate-ids-for.js v1

- name: Commit and push
run: |
git config user.name "test-id-bot"
git config user.email "test-id-bot@users.noreply.github.com"
git add tests/
git diff --cached --quiet || git commit -m "chore: auto-add missing test IDs"
git push https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.event.pull_request.head.repo.full_name }}.git HEAD:refs/heads/${{ github.event.pull_request.head.ref }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,4 @@ cython_debug/
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
node_modules/
182 changes: 182 additions & 0 deletions package-lock.json

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

12 changes: 11 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
{
"name": "json-schema-test-suite",
"version": "0.1.0",
"type": "module",
"description": "A language agnostic test suite for the JSON Schema specifications",
"repository": "github:json-schema-org/JSON-Schema-Test-Suite",
"keywords": [
"json-schema",
"tests"
],
"author": "http://json-schema.org",
"license": "MIT"
"license": "MIT",
"devDependencies": {
"@hyperjump/browser": "^1.3.1",
"@hyperjump/json-pointer": "^1.1.1",
"@hyperjump/json-schema": "^1.17.4",
"@hyperjump/pact": "^1.4.0",
"@hyperjump/uri": "^1.3.2",
"json-stringify-deterministic": "^1.0.12",
"jsonc-parser": "^3.3.1"
}
}
7 changes: 7 additions & 0 deletions remotes/draft2019-09/ignore-dependentRequired.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"$id": "http://localhost:1234/draft2019-09/integer.json",
"$schema": "http://json-schema.org/draft-07/schema#",
"dependentRequired": {
"foo": ["bar"]
}
}
7 changes: 7 additions & 0 deletions remotes/draft2019-09/prefixItems.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"$id": "http://localhost:1234/draft2020-12/prefixItems.json",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"prefixItems": [
{"type": "string"}
]
}
7 changes: 7 additions & 0 deletions remotes/draft2020-12/ignore-prefixItems.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"$id": "http://localhost:1234/draft2020-12/ignore-prefixItems.json",
"$schema": "https://json-schema.org/draft/2019-09/schema",
"prefixItems": [
{"type": "string"}
]
}
7 changes: 7 additions & 0 deletions remotes/draft7/dependentRequired.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"$id": "http://localhost:1234/draft7/dependentRequired.json",
"$schema": "https://json-schema.org/draft/2019-09/schema",
"dependentRequired": {
"foo": ["bar"]
}
}
9 changes: 9 additions & 0 deletions scripts/generate-ids-for.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { generateIdsFor } from "./utils/test-ids.js";

const version = process.argv[2];
if (!version) {
console.error("Usage: node scripts/generate-ids-for.js <draftXXXX>");
process.exit(1);
}

await generateIdsFor(version);
Loading
Loading