Skip to content

馃悰 fix(schema): declare prefix in the labeled factor group's not clause #40

馃悰 fix(schema): declare prefix in the labeled factor group's not clause

馃悰 fix(schema): declare prefix in the labeled factor group's not clause #40

name: Update SchemaStore
on:
push:
tags: ["*"]
pull_request:
paths:
- "src/tox/tox.schema.json"
- ".github/workflows/update-schemastore.yaml"
permissions:
contents: read
jobs:
validate:
name: schema passes SchemaStore's checks
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Clone SchemaStore
run: git clone --depth 1 https://github.com/SchemaStore/schemastore /tmp/schemastore
- name: Install SchemaStore's dependencies
run: npm ci
working-directory: /tmp/schemastore
- name: Stage tox's schema
run: |
python3 -c "
import json
with open('${{ github.workspace }}/src/tox/tox.schema.json') as f:
schema = json.load(f)
schema['\$id'] = 'https://json.schemastore.org/tox.json'
with open('/tmp/schemastore/src/schemas/json/tox.json', 'w') as f:
json.dump(schema, f, indent=2)
f.write('\n')
"
- name: Run SchemaStore's checks against it
run: node ./cli.js check --schema-name=tox.json
working-directory: /tmp/schemastore
update-schemastore:
needs: validate
if: github.event_name == 'push'
runs-on: ubuntu-24.04
environment: schemastore
env:
GH_TOKEN: ${{ secrets.SCHEMASTORE_TOKEN }}
BRANCH: update-tox-schema
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Fork and clone SchemaStore
run: gh repo fork SchemaStore/schemastore --clone -- /tmp/schemastore
- name: Sync fork's master with upstream
run: gh repo sync "$(gh api user --jq .login)/schemastore" -b master
- name: Create or reset branch from synced fork
run: |
git fetch origin master
git switch -C "$BRANCH" origin/master
working-directory: /tmp/schemastore
- name: Update schema and check for changes
id: diff
run: |
python3 -c "
import json, sys
with open('${{ github.workspace }}/src/tox/tox.schema.json') as f:
new = json.load(f)
new['\$id'] = 'https://json.schemastore.org/tox.json'
with open('/tmp/schemastore/src/schemas/json/tox.json') as f:
old = json.load(f)
if new == old:
sys.exit(1)
with open('/tmp/schemastore/src/schemas/json/tox.json', 'w') as f:
json.dump(new, f, indent=2)
f.write('\n')
" && echo "changed=true" >> "$GITHUB_OUTPUT" || echo "changed=false" >> "$GITHUB_OUTPUT"
- name: Commit and push
if: steps.diff.outputs.changed == 'true'
run: |
gh auth setup-git
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add src/schemas/json/tox.json
git commit -m "Update tox JSON Schema to ${GITHUB_REF_NAME}"
git push --force origin "$BRANCH"
working-directory: /tmp/schemastore
- name: Create or update pull request
if: steps.diff.outputs.changed == 'true'
run: |
FORK_OWNER=$(gh api user --jq .login)
HEAD="$FORK_OWNER:$BRANCH"
if ! gh pr view "$HEAD" --repo SchemaStore/schemastore > /dev/null 2>&1; then
gh pr create \
--repo SchemaStore/schemastore \
--head "$HEAD" \
--title "Update tox JSON Schema to ${GITHUB_REF_NAME}" \
--body "Updates tox's JSON Schema to [${{ github.sha }}](https://github.com/tox-dev/tox/commit/${{ github.sha }}) (release ${GITHUB_REF_NAME})."
else
gh pr edit "$HEAD" --repo SchemaStore/schemastore \
--title "Update tox JSON Schema to ${GITHUB_REF_NAME}" \
--body "Updates tox's JSON Schema to [${{ github.sha }}](https://github.com/tox-dev/tox/commit/${{ github.sha }}) (release ${GITHUB_REF_NAME})."
fi