CI: fix schema publishing.

Previously, two concurrent jobs were used, which caused a race condition.
Serialize them.
This commit is contained in:
Catherine 2024-05-10 13:32:11 +00:00
parent 496432edaa
commit 631ef564aa
2 changed files with 25 additions and 25 deletions

View file

@ -162,30 +162,6 @@ jobs:
steps: steps:
- run: ${{ contains(needs.*.result, 'failure') && 'false' || 'true' }} - run: ${{ contains(needs.*.result, 'failure') && 'false' || 'true' }}
publish-schemas:
needs: document
if: ${{ github.repository == 'amaranth-lang/amaranth' }}
runs-on: ubuntu-latest
steps:
- name: Check out source code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download schema archive
uses: actions/download-artifact@v4
with:
name: schema
path: schema/
- name: Publish development schemas
if: ${{ github.event_name == 'push' && github.event.ref == 'refs/heads/main' }}
uses: JamesIves/github-pages-deploy-action@releases/v4
with:
repository-name: amaranth-lang/amaranth-lang.github.io
ssh-key: ${{ secrets.PAGES_DEPLOY_KEY }}
branch: main
folder: schema/
target-folder: schema/amaranth/
publish-docs: publish-docs:
needs: document needs: document
if: ${{ github.repository == 'amaranth-lang/amaranth' }} if: ${{ github.repository == 'amaranth-lang/amaranth' }}
@ -242,6 +218,30 @@ jobs:
folder: pages/ folder: pages/
clean: false clean: false
publish-schemas:
needs: [required, publish-docs] # avoid race condition with publish-docs
if: ${{ github.repository == 'amaranth-lang/amaranth' }}
runs-on: ubuntu-latest
steps:
- name: Check out source code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download schema archive
uses: actions/download-artifact@v4
with:
name: schema
path: schema/
- name: Publish schemas
if: ${{ github.event_name == 'push' && github.event.ref == 'refs/heads/main' }}
uses: JamesIves/github-pages-deploy-action@releases/v4
with:
repository-name: amaranth-lang/amaranth-lang.github.io
ssh-key: ${{ secrets.PAGES_DEPLOY_KEY }}
branch: main
folder: schema/
target-folder: schema/amaranth/
publish-package: publish-package:
needs: required needs: required
runs-on: ubuntu-latest runs-on: ubuntu-latest

View file

@ -135,7 +135,7 @@ def _extract_schemas(package, *, base_uri, path="schema/"):
entry_points = distribution(package).entry_points entry_points = distribution(package).entry_points
for entry_point in entry_points.select(group="amaranth.lib.meta"): for entry_point in entry_points.select(group="amaranth.lib.meta"):
schema = entry_point.load().schema schema = entry_point.load().schema
relative_path = entry_point.name # v0.5/component.json relative_path = entry_point.name # "0.5/component.json"
schema_filename = pathlib.Path(path) / relative_path schema_filename = pathlib.Path(path) / relative_path
assert schema["$id"] == f"{base_uri}/{relative_path}", \ assert schema["$id"] == f"{base_uri}/{relative_path}", \
f"Schema $id {schema['$id']} must be {base_uri}/{relative_path}" f"Schema $id {schema['$id']} must be {base_uri}/{relative_path}"