Skip to content

update-test-suite

update-test-suite #92

name: update-test-suite
on:
workflow_dispatch:
schedule:
- cron: '0 15 * * 2' # every tuesday 15:00
jobs:
update-test-suite:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout test suite
uses: actions/checkout@v4
with:
repository: json-schema-org/JSON-Schema-Test-Suite
path: test-suite
sparse-checkout: |
remotes
tests/draft7
tests/draft2019-09
tests/draft2020-12
- name: Remove unused draft versions
run: |
rm -rf test-suite/remotes/draft6
rm -rf test-suite/remotes/draft-next
- name: Checkout json-schema
uses: actions/checkout@v4
with:
ref: master
path: json-schema
- name: Copy new test suite
run: |
rsync -r --delete test-suite/remotes json-schema/src/test/resources/suite
rsync -r --delete test-suite/tests json-schema/src/test/resources/suite
- name: Generate branch name
run: echo "BRANCH_NAME=chore/update-test-suite-$(date +"%Y%m%d-%H%M%S")" >> $GITHUB_ENV
- name: Commit JSON test suite
uses: EndBug/add-and-commit@v9.1.4
id: json-commit
with:
cwd: json-schema
add: . --no-ignore-removal
new_branch: ${{ env.BRANCH_NAME }}
message: 'chore(test-suite): update official test suite from json-schema-org/JSON-Schema-Test-Suite'
- name: Generate YAML files
run: |
find test-suite/remotes -type f -exec sh -c 'yq -Poy {} > $(echo {} | sed 's/\.[^.]*$//').yml' \;
find test-suite/tests -type f -exec sh -c 'yq -Poy {} > $(echo {} | sed 's/\.[^.]*$//').yml' \;
- name: Delete JSON files
run: |
find test-suite/remotes -name '*.json' -exec rm {} \;
find test-suite/tests -name '*.json' -exec rm {} \;
- name: Copy new YAML test suite
run: |
rsync -r --delete test-suite/remotes json-schema/src/test/resources/suite-yaml
rsync -r --delete test-suite/tests json-schema/src/test/resources/suite-yaml
- name: Fix YAML suite
run: |
cat test-suite/tests/draft2020-12/if-then-else.yml | yq '((.[] | select(.description == "if appears at the end when serialized (keyword processing sequence)")).tests[] | select(.description == "no redirects to then and fails")).data style = "single"' > json-schema/src/test/resources/suite-yaml/tests/draft2020-12/if-then-else.yml
cat test-suite/tests/draft2019-09/if-then-else.yml | yq '((.[] | select(.description == "if appears at the end when serialized (keyword processing sequence)")).tests[] | select(.description == "no redirects to then and fails")).data style = "single"' > json-schema/src/test/resources/suite-yaml/tests/draft2019-09/if-then-else.yml
cat test-suite/tests/draft7/if-then-else.yml | yq '((.[] | select(.description == "if appears at the end when serialized (keyword processing sequence)")).tests[] | select(.description == "no redirects to then and fails")).data style = "single"' > json-schema/src/test/resources/suite-yaml/tests/draft7/if-then-else.yml
cat test-suite/tests/draft2020-12/unevaluatedItems.yml | yq '((.[] | select(.description == "unevaluatedItems with nested items")).tests[] | select(.description == "with invalid additional item")).data[0] style = "single"' > json-schema/src/test/resources/suite-yaml/tests/draft2020-12/unevaluatedItems.yml
cat test-suite/tests/draft2019-09/unevaluatedItems.yml | yq '((.[] | select(.description == "unevaluatedItems with nested items")).tests[] | select(.description == "with invalid additional item")).data[0] style = "single"' > json-schema/src/test/resources/suite-yaml/tests/draft2019-09/unevaluatedItems.yml
cat test-suite/tests/draft2020-12/optional/format/ipv6.yml | yq '((.[] | select(.description == "validation of IPv6 addresses")).tests[] | select(.description == "an IPv6 address with too many components" or .description == "insufficient octets without double colons")).data style = "single"' > json-schema/src/test/resources/suite-yaml/tests/draft2020-12/optional/format/ipv6.yml
cat test-suite/tests/draft2019-09/optional/format/ipv6.yml | yq '((.[] | select(.description == "validation of IPv6 addresses")).tests[] | select(.description == "an IPv6 address with too many components" or .description == "insufficient octets without double colons")).data style = "single"' > json-schema/src/test/resources/suite-yaml/tests/draft2019-09/optional/format/ipv6.yml
cat test-suite/tests/draft7/optional/format/ipv6.yml | yq '((.[] | select(.description == "validation of IPv6 addresses")).tests[] | select(.description == "an IPv6 address with too many components" or .description == "insufficient octets without double colons")).data style = "single"' > json-schema/src/test/resources/suite-yaml/tests/draft7/optional/format/ipv6.yml
cat test-suite/tests/draft2020-12/optional/format/time.yml | yq '((.[] | select(.description == "validation of time strings")).tests[] | select(.description == "no time offset with second fraction")).data style = "single"' > json-schema/src/test/resources/suite-yaml/tests/draft2020-12/optional/format/time.yml
cat test-suite/tests/draft2019-09/optional/format/time.yml | yq '((.[] | select(.description == "validation of time strings")).tests[] | select(.description == "no time offset with second fraction")).data style = "single"' > json-schema/src/test/resources/suite-yaml/tests/draft2019-09/optional/format/time.yml
cat test-suite/tests/draft7/optional/format/time.yml | yq '((.[] | select(.description == "validation of time strings")).tests[] | select(.description == "no time offset with second fraction")).data style = "single"' > json-schema/src/test/resources/suite-yaml/tests/draft7/optional/format/time.yml
- name: Commit YAML test suite
uses: EndBug/add-and-commit@v9.1.4
id: yaml-commit
with:
cwd: json-schema
add: . --no-ignore-removal
new_branch: ${{ env.BRANCH_NAME }}
message: 'chore(test-suite): regenerate YAML test suite'
- name: Create PR
if: ${{ steps.json-commit.outputs.pushed == 'true' || steps.yaml-commit.outputs.pushed == 'true' }}
run: >
gh pr create -B master -H ${{ env.BRANCH_NAME }}
--repo harrel56/json-schema
--title 'chore(test-suite): incremental test suite update from upstream'
--body 'Automatically generated by scheduled workflow. New changes from https://github.com/json-schema-org/JSON-Schema-Test-Suite detected.'
--label dependencies
env:
GITHUB_TOKEN: ${{ secrets.PR_TOKEN }}