Skip to content
Merged
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
5 changes: 5 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,10 @@ updates:
open-pull-requests-limit: 5
reviewers:
- "cubehouse"
# Actions are pinned to commit SHAs; one grouped PR moves all the pins.
groups:
actions:
patterns:
- "*"
commit-message:
prefix: "ci"
13 changes: 9 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ on:
push:
branches: [main, v2]
pull_request:
# Least privilege for the workflow token. A job that needs more asks for it
# in its own permissions block.
permissions:
contents: read

jobs:
test:
# Pinned: ubuntu-latest moved to 26.04, which has no Python 3.9 build, and
Expand All @@ -12,8 +17,8 @@ jobs:
matrix:
python: ['3.9', '3.10', '3.11', '3.12', '3.13']
steps:
- uses: actions/checkout@v7
- uses: actions/setup-python@v7
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7
with:
python-version: '${{ matrix.python }}'
- run: pip install -e '.[dev]'
Expand All @@ -28,8 +33,8 @@ jobs:
docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: actions/setup-python@v7
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7
with:
python-version: '3.12'
- run: pip install -e '.[docs]'
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: actions/setup-python@v7
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7
with: { python-version: '3.12' }
- run: pip install -e '.[docs]'
- run: mkdocs build --strict
- uses: actions/upload-pages-artifact@v3
- uses: actions/upload-pages-artifact@56afc609e74202658d3ffba0e8f6dda462b719fa # v3
with: { path: site }

deploy:
Expand All @@ -33,4 +33,4 @@ jobs:
url: ${{ steps.deployment.outputs.page_url }}
steps:
- id: deployment
uses: actions/deploy-pages@v5
uses: actions/deploy-pages@368f82528645a54fb793d4d04e342629a3f51346 # v5
9 changes: 7 additions & 2 deletions .github/workflows/mutation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,17 @@ on:
paths:
- 'tests/mutation/**'

# Least privilege for the workflow token. A job that needs more asks for it
# in its own permissions block.
permissions:
contents: read

jobs:
mutate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: actions/setup-python@v7
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7
with:
python-version: '3.12'
- run: pip install -e '.[dev]'
Expand Down
41 changes: 37 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,55 @@ name: Release
on:
push:
tags: ['v*']
# Least privilege for the workflow token. A job that needs more asks for it
# in its own permissions block.
permissions:
contents: read

jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
steps:
- uses: actions/checkout@v7
- uses: actions/setup-python@v7
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
# Full history: the on-main check below needs the ancestry.
fetch-depth: 0
# A tag can be pushed on any commit, reviewed or not. Only a commit that
# is already on main may be published, so the check runs before anything
# is installed. HEAD is the tagged commit; the checkout above fetched the
# full history, and main is fetched again by name so the comparison does
# not depend on which refs that checkout happened to bring.
- name: Tagged commit must be on main
run: |
git fetch --no-tags origin '+refs/heads/main:refs/remotes/origin/main'
COMMIT=$(git rev-parse HEAD)
if ! git merge-base --is-ancestor "$COMMIT" origin/main; then
echo "::error::$GITHUB_REF_NAME points at $COMMIT, which is not on main. Merge it first, then tag the merged commit."
exit 1
fi
echo "$GITHUB_REF_NAME ($COMMIT) is on main"
- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7
with:
python-version: '3.12'
# The tag is the only thing typed by hand, so it is the thing most likely
# to be wrong. Publishing 1.2.0 from a tag reading v1.3.0 would be silent.
- name: Tag must match pyproject.toml
run: |
TAG="${GITHUB_REF_NAME#v}"
PKG=$(python -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['version'])")
echo "tag=$TAG pyproject.toml=$PKG"
if [ "$TAG" != "$PKG" ]; then
echo "::error::tag $TAG does not match pyproject.toml $PKG"
exit 1
fi
- run: pip install -e '.[dev]'
- run: pytest tests/unit
- run: pip install build
- run: python -m build
- uses: pypa/gh-action-pypi-publish@release/v1
- uses: softprops/action-gh-release@v3
- uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # release/v1
- uses: softprops/action-gh-release@88b783939ccdbabad21b9a37510aed7fad5f2e60 # v3
with:
generate_release_notes: true
83 changes: 68 additions & 15 deletions .github/workflows/spec-drift.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,28 @@ on:
schedule:
- cron: '23 6 * * *'
workflow_dispatch:
# Least privilege for the workflow token. A job that needs more asks for it
# in its own permissions block.
permissions:
contents: read

jobs:
# TWO JOBS, deliberately. This one installs dependencies and runs the
# generator and the tests, so it gets a read-only token and no secrets. The
# drift bot's credentials exist only in the second job, which runs none of
# that code: it receives the generated file as an artifact.
regenerate:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
issues: write
contents: read
outputs:
regen: ${{ steps.regen.outcome }}
smoke: ${{ steps.smoke.outcome }}
steps:
- uses: actions/checkout@v7
- uses: actions/setup-python@v7
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
persist-credentials: false
- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7
with:
python-version: '3.12'
- run: pip install -e '.[dev]'
Expand All @@ -31,6 +43,47 @@ jobs:
if: steps.regen.outcome == 'success'
continue-on-error: true
run: pytest tests/live -v

# Uploaded whether or not it changed: the second job puts it over a
# clean checkout, and an unchanged file opens no PR.
- name: Hand the generated models to the PR job
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7
with:
name: spec-drift-generated
path: themeparks/_generated/models.py
if-no-files-found: error
retention-days: 1

open-pr:
needs: regenerate
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
issues: write
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7

# Downloaded OUTSIDE the checkout, then exactly one named file is copied
# in. Unpacking an artifact straight into the workspace would let
# whatever produced it write anywhere in it, .git included.
- name: Fetch the generated models
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8
with:
name: spec-drift-generated
path: ${{ runner.temp }}/spec-drift-generated

- name: Put the generated models in place
env:
GENERATED: ${{ runner.temp }}/spec-drift-generated
run: |
if [ ! -f "$GENERATED/models.py" ] || [ -L "$GENERATED/models.py" ]; then
echo "::error::the artifact has no regular file named models.py"
exit 1
fi
install -m 0644 "$GENERATED/models.py" themeparks/_generated/models.py
git status --short

# The PR must not be opened with GITHUB_TOKEN. GitHub does not start
# workflow runs from GITHUB_TOKEN-raised events, so a PR opened that way
# never gets its required checks and can never be merged, however good
Expand All @@ -43,13 +96,13 @@ jobs:
# that is not GITHUB_TOKEN, and this app is that identity.
- name: Mint an installation token for the drift bot
id: app-token
uses: actions/create-github-app-token@v3
uses: actions/create-github-app-token@f418cff399f7aef4c2f0ad47e25ca7a6abbdd6fc # v3
with:
app-id: ${{ secrets.DRIFT_APP_ID }}
private-key: ${{ secrets.DRIFT_APP_PRIVATE_KEY }}

- name: Open PR if models changed
uses: peter-evans/create-pull-request@v8
uses: peter-evans/create-pull-request@3ffccacd46053766916f087ce41d627c0b8cf2d1 # v8
with:
token: ${{ steps.app-token.outputs.token }}
branch: bot/spec-drift
Expand All @@ -58,34 +111,34 @@ jobs:
body: |
Automated regeneration from https://api.themeparks.wiki/docs/v1.yaml

- regenerate: ${{ steps.regen.outcome }}
- live smoke tests: ${{ steps.smoke.outcome || 'skipped (regenerate failed)' }}
- regenerate: ${{ needs.regenerate.outputs.regen }}
- live smoke tests: ${{ needs.regenerate.outputs.smoke || 'skipped (regenerate failed)' }}

A regenerate failure means the upstream contract changed in a way
this client cannot absorb automatically. Do not merge until green.
add-paths: |
themeparks/_generated/models.py
- name: Open issue if regeneration failed
if: steps.regen.outcome == 'failure'
uses: JasonEtco/create-an-issue@v2
if: needs.regenerate.outputs.regen == 'failure'
uses: JasonEtco/create-an-issue@1b14a70e4d8dc185e5cc76d3bec9eab20257b2c5 # v2
env:
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
with:
filename: .github/DRIFT_REGEN_FAILURE.md
update_existing: true

- name: Open issue if smoke tests failed
if: steps.smoke.outcome == 'failure'
uses: JasonEtco/create-an-issue@v2
if: needs.regenerate.outputs.smoke == 'failure'
uses: JasonEtco/create-an-issue@1b14a70e4d8dc185e5cc76d3bec9eab20257b2c5 # v2
env:
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
with:
filename: .github/SMOKE_FAILURE.md

# The job must go red when regeneration did, or a silent failure is just
# The run must go red when regeneration did, or a silent failure is just
# a green tick with a stale client behind it.
- name: Fail the run if regeneration failed
if: steps.regen.outcome == 'failure'
if: needs.regenerate.outputs.regen == 'failure'
run: |
echo "::error::Model regeneration failed — upstream contract changed."
exit 1
Loading