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
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 4
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[*.{json,md,toml,yaml,yml}]
indent_size = 2
11 changes: 11 additions & 0 deletions .github/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
changelog:
categories:
- title: Changes
labels:
- "*"
exclude:
labels:
- renovate
- title: Dependencies
labels:
- renovate
138 changes: 138 additions & 0 deletions .github/workflows/biome-migrate.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
name: Biome Migrate

# Renovate bumps the version of Biome in .trunk/trunk.yaml but cannot run
# `biome migrate`, so the $schema and the renamed options and rules of
# biome.jsonc stay behind. On its branches the update job below commits the
# migrated biome.jsonc; anywhere else, a biome.jsonc that the Biome of
# .trunk/trunk.yaml would migrate fails the check.
on:
pull_request:
branches:
- main
paths:
- .github/workflows/biome-migrate.yaml
- .trunk/trunk.yaml
- biome.jsonc
workflow_dispatch: {}

permissions:
contents: read

jobs:
check:
name: Check biome.jsonc

runs-on: ubuntu-26.04-arm
timeout-minutes: 10

outputs:
stale: ${{ steps.up_to_date.outputs.stale }}

env:
# Only branches of this repository qualify, never a fork's.
RENOVATE_PR: ${{ github.event_name == 'pull_request' && startsWith(github.head_ref, 'renovate/')
&& github.event.pull_request.head.repo.full_name == github.repository }}

steps:
# A Renovate branch is checked out at its head rather than merged with
# main, so that the migrated biome.jsonc matches the branch it is
# committed to.
- name: Checkout
uses: actions/checkout@v7
with:
ref: ${{ env.RENOVATE_PR == 'true' && github.event.pull_request.head.sha || '' }}

# The version is the one that Trunk runs, pinned with a trailing ! in
# .trunk/trunk.yaml. npx comes with the Node of the runner image.
- name: Migrate biome.jsonc
run: |-
BIOME_VERSION=$(perl -ne 'print $1 if /^\s*-\s*biome@([^!\s]+)/' .trunk/trunk.yaml)
if [[ -z $BIOME_VERSION ]]; then
echo "::error::No version of Biome in .trunk/trunk.yaml" >&2
exit 1
fi
echo "BIOME_VERSION=$BIOME_VERSION" >> "$GITHUB_ENV"
npx --yes "@biomejs/biome@${BIOME_VERSION}" migrate --write

- name: Check biome.jsonc is up to date
id: up_to_date
run: |-
if git diff --exit-code --stat -- biome.jsonc; then
echo "biome.jsonc is up to date."
exit 0
fi

if [ "$RENOVATE_PR" = 'true' ]; then
git diff --binary -- biome.jsonc > biome.patch
echo "stale=true" | tee -a "$GITHUB_OUTPUT"
echo "::notice::biome.jsonc is not migrated on a Renovate branch; the update job commits it."
exit 0
fi

echo "::error::biome.jsonc is not migrated to the Biome of .trunk/trunk.yaml. Run \`npx --yes @biomejs/biome@$BIOME_VERSION migrate --write\` and commit the result." >&2
exit 1

- name: Upload the patch
if: steps.up_to_date.outputs.stale == 'true'
uses: actions/upload-artifact@v7
with:
name: biome-patch
path: biome.patch
retention-days: 1

# Commits the biome.jsonc that the check job migrated onto the Renovate
# branch, with the token of the workflow. A push with it starts no workflow,
# so the job starts the checks of the commit itself, as workflow_dispatch is
# the event that the token can start; this check among them, which fails if
# biome.jsonc still needs migrating, as it does not commit on such a run. The
# job runs no code of npm: it only applies the patch.
update:
name: Commit the migrated biome.jsonc

needs: check
if: needs.check.outputs.stale == 'true'

runs-on: ubuntu-26.04-arm
timeout-minutes: 10

permissions:
actions: write
contents: write

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

- name: Download the patch
uses: actions/download-artifact@v8
with:
name: biome-patch

# The author is in gitIgnoredAuthors of .renovaterc.json, so that
# Renovate keeps rebasing and updating the branch. The push goes to the
# commit that the check job migrated biome.jsonc for: if the branch moved
# meanwhile, the push is rejected, and the run of the newer commit takes
# over.
- name: Commit and push to the pull request branch
env:
BRANCH: ${{ github.head_ref }}
MESSAGE: Migrate biome.jsonc to the new version of Biome
run: |-
git apply --index biome.patch
rm biome.patch
git -c user.name='github-actions[bot]' \
-c user.email='41898282+github-actions[bot]@users.noreply.github.com' \
commit -m "$MESSAGE"
git push origin "HEAD:refs/heads/$BRANCH"

- name: Run the checks of the commit
env:
BRANCH: ${{ github.head_ref }}
GH_TOKEN: ${{ github.token }}
run: |-
gh workflow run biome-migrate.yaml --ref "$BRANCH"
gh workflow run build.yaml --ref "$BRANCH"
gh workflow run tests.yaml --ref "$BRANCH"
gh workflow run trunk-check.yaml --ref "$BRANCH"
73 changes: 73 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Build

# Checks that uv.lock matches pyproject.toml, builds the sdist and the wheel,
# checks that the wheel has the module of the reactor and nothing of the
# namespace of Pyjoyment, and installs it with Pyjoyment and imports it and
# runs examples/loopback_winloop.py, a request to a server of its own on the
# loop of Winloop, outside the checkout.
on:
push:
branches:
- main
pull_request:
branches:
- "*"
workflow_dispatch: {}

permissions:
contents: read

jobs:
build:
name: build

# Windows, where the wheel installs Winloop, which the example runs on
runs-on: windows-2025
defaults:
run:
shell: bash
timeout-minutes: 10

steps:
- name: Checkout
uses: actions/checkout@v7

- name: Set up mise
uses: jdx/mise-action@v5
with:
version: 2026.10.25 # datasource=github-releases depName=jdx/mise

# uv.lock has to match pyproject.toml.
- name: Check uv.lock
run: uv lock --check

- name: Build sdist and wheel
run: uv build

# The packages Pyjo and Pyjo.Reactor are those of Pyjoyment: a wheel
# with their __init__.py would overwrite the files of Pyjoyment.
- name: Check wheel contents
run: |-
python -m zipfile -l dist/*.whl | tee wheel.txt
grep -q 'Pyjo/Reactor/Winloop.py' wheel.txt
if grep -E 'Pyjo/(Reactor/)?__init__\.py' wheel.txt; then exit 1; fi

# The wheel in an environment of its own, outside the checkout, so that
# nothing comes from it, with the Pyjoyment of PyPI that it depends on.
# The first line of the example is the class of the reactor and whether
# its loop is one of Winloop, so that Pyjo.Reactor.Asyncio or a loop of asyncio
# in their place fails the step. Python of Windows ends its lines with
# CRLF, which diff leaves out.
- name: Install and run the wheel
shell: bash
run: |-
uv venv --python "$(python -c 'import sys; print(sys.executable)')" "$RUNNER_TEMP/venv"
uv pip install --python "$RUNNER_TEMP/venv/Scripts/python" dist/*.whl
cp examples/loopback_winloop.py "$RUNNER_TEMP/"
cd "$RUNNER_TEMP"
venv/Scripts/python -c 'import Pyjo.Reactor.Winloop; print(Pyjo.Reactor.Winloop.__version__)'
venv/Scripts/python loopback_winloop.py | tee loopback.txt
diff --strip-trailing-cr - loopback.txt <<'EOF'
Pyjo_Reactor_Winloop winloop
200 Your Pyjo is working!
EOF
41 changes: 41 additions & 0 deletions .github/workflows/cleanup-cache.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Cleanup cache

# Deletes the caches of a pull request once it is closed, which GitHub keeps
# until they expire and then evicts the ones of main first: the ones of its
# merge ref, and the ones of its branch, which the checks started with
# workflow_dispatch on the branches of the automated workflows leave. A pull
# request of a fork has a read-only token, which cannot delete them.
on:
pull_request:
types:
- closed

permissions:
actions: write

jobs:
cleanup-cache:
name: cleanup cache

runs-on: ubuntu-26.04-arm
timeout-minutes: 10

env:
GH_REPO: ${{ github.repository }}
GH_TOKEN: ${{ github.token }}

steps:
- name: Cleanup cache
run: |-
refs=("refs/pull/${NUMBER}/merge")
if [[ ${BRANCH} != "${DEFAULT_BRANCH}" ]]; then
refs+=("refs/heads/${BRANCH}")
fi
for ref in "${refs[@]}"; do
gh cache list --ref "${ref}" --limit 100 --json id --jq '.[].id' | xargs -n1 -r -t gh cache delete
done
continue-on-error: true
env:
BRANCH: ${{ github.event.pull_request.head.ref }}
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
NUMBER: ${{ github.event.pull_request.number }}
60 changes: 60 additions & 0 deletions .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Docs

# Builds the documentation with Sphinx of the group docs and the environment of
# uv.lock, as Read the Docs does, from the pages of docs, the docstrings of the
# module and the examples that the pages include: a warning of Sphinx, as a
# reference that is not found or a docstring that is not valid
# reStructuredText, fails the build.
on:
push:
branches:
- main
paths:
- .github/workflows/docs.yaml
- .readthedocs.yaml
- docs/**
- examples/**
- Pyjo/**
- mise.lock
- mise.toml
- pyproject.toml
- uv.lock
pull_request:
branches:
- "*"
paths:
- .github/workflows/docs.yaml
- .readthedocs.yaml
- docs/**
- examples/**
- Pyjo/**
- mise.lock
- mise.toml
- pyproject.toml
- uv.lock
workflow_dispatch: {}

permissions:
contents: read

jobs:
build:
name: build

runs-on: ubuntu-26.04-arm
timeout-minutes: 10

steps:
- name: Checkout
uses: actions/checkout@v7

- name: Set up mise
uses: jdx/mise-action@v5
with:
version: 2026.10.25 # datasource=github-releases depName=jdx/mise

# --keep-going reports all the warnings, which -W turns into errors.
- name: Build documentation
run: |-
uv run --locked --group docs \
sphinx-build -W --keep-going -b html docs docs/_build/html
Loading
Loading