From c4088f202ea0efd774f6ab7f358f620568ba215b Mon Sep 17 00:00:00 2001 From: Remco de Boer <29308176+redeboer@users.noreply.github.com> Date: Sat, 10 Jan 2026 15:03:20 +0100 Subject: [PATCH 01/16] BREAK: run tasks through `poe` or `pixi` only --- .cspell.json | 1 + .github/workflows/cd.yml | 2 +- .github/workflows/ci-docs.yml | 4 - .github/workflows/ci.yml | 8 +- .github/workflows/clean-caches.yml | 2 +- .github/workflows/docnb.yml | 16 +--- .github/workflows/get-pypi-name.yml | 2 +- .github/workflows/linkcheck.yml | 8 +- .github/workflows/lock.yml | 2 +- .github/workflows/pre-commit.yml | 13 ++- .github/workflows/pytest.yml | 120 ------------------------ .github/workflows/test.yml | 81 ++++++++++++++++ .pre-commit-config.yaml | 6 +- create-pytest-matrix/action.yml | 29 +++--- create-pytest-matrix/main.py | 53 ++++++----- create-python-version-matrix/action.yml | 5 - run-pre-commit/action.yml | 19 ---- run-pre-commit/main.py | 42 --------- 18 files changed, 143 insertions(+), 270 deletions(-) delete mode 100644 .github/workflows/pytest.yml create mode 100644 .github/workflows/test.yml delete mode 100644 run-pre-commit/action.yml delete mode 100644 run-pre-commit/main.py diff --git a/.cspell.json b/.cspell.json index b2bbcc7b..9724ff12 100644 --- a/.cspell.json +++ b/.cspell.json @@ -44,6 +44,7 @@ "pyproject.toml" ], "ignoreWords": [ + "PYTEST_XDIST_WORKER_COUNT", "elif", "ipynb", "mhutchie", diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 2def5ff7..a9828f1e 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -9,7 +9,7 @@ on: jobs: milestone: if: startsWith(github.ref, 'refs/tags') - uses: ComPWA/actions/.github/workflows/close-milestone.yml@v3 + uses: ComPWA/actions/.github/workflows/close-milestone.yml@v4 push-to-version-branches: name: Push to version branches if: startsWith(github.ref, 'refs/tags') && !github.event.release.prerelease diff --git a/.github/workflows/ci-docs.yml b/.github/workflows/ci-docs.yml index ab0d35fa..534fa875 100644 --- a/.github/workflows/ci-docs.yml +++ b/.github/workflows/ci-docs.yml @@ -12,9 +12,6 @@ on: default: "3.13" required: false type: string - specific-pip-packages: - required: false - type: string jobs: linkcheck: @@ -29,7 +26,6 @@ jobs: with: apt-packages: ${{ inputs.apt-packages }} python-version: ${{ inputs.python-version }} - specific-pip-packages: ${{ inputs.specific-pip-packages }} gh-pages: name: Upload to GitHub Pages diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b95a35d9..b0b75404 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,15 +17,9 @@ on: - epic/* - "[0-9]+.[0-9]+.x" workflow_dispatch: - inputs: - specific-pip-packages: - description: Run CI with specific pip packages - required: false - type: string jobs: style: - if: inputs.specific-pip-packages == '' secrets: token: ${{ secrets.PAT }} - uses: ComPWA/actions/.github/workflows/pre-commit.yml@v3.0 + uses: ComPWA/actions/.github/workflows/pre-commit.yml@v4.0 diff --git a/.github/workflows/clean-caches.yml b/.github/workflows/clean-caches.yml index 2de0c959..b241bf56 100644 --- a/.github/workflows/clean-caches.yml +++ b/.github/workflows/clean-caches.yml @@ -16,7 +16,7 @@ jobs: name: Remove caches runs-on: ubuntu-24.04 steps: - - uses: ComPWA/actions/clean-caches@v3 + - uses: ComPWA/actions/clean-caches@v4 with: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} ref: ${{ inputs.ref }} diff --git a/.github/workflows/docnb.yml b/.github/workflows/docnb.yml index 9f9fe69c..890136b4 100644 --- a/.github/workflows/docnb.yml +++ b/.github/workflows/docnb.yml @@ -8,9 +8,6 @@ on: default: "3.13" required: false type: string - specific-pip-packages: - required: false - type: string jobs: docnb: @@ -30,7 +27,6 @@ jobs: **/pyproject.toml **/uv.lock - name: Fetch Jupyter cache - if: inputs.specific-pip-packages == '' uses: actions/cache@v5 with: key: | @@ -39,24 +35,20 @@ jobs: jupyter-cache-${{ hashFiles('.constraints/py3.*.txt', 'src/**.py', 'uv.lock') }} path: | ./docs/_build/.jupyter_cache - - uses: ComPWA/actions/cache-sympy@v3 + - uses: ComPWA/actions/cache-sympy@v4 - if: inputs.apt-packages run: | sudo apt-get update -y sudo apt-get install -y ${{ inputs.apt-packages }} - if: hashFiles('**/Project.toml') - uses: ComPWA/actions/install-julia@v3 + uses: ComPWA/actions/install-julia@v4 with: ijulia: true - id: task-runner - uses: ComPWA/actions/determine-task-runner@v3 + uses: ComPWA/actions/determine-task-runner@v4 - name: Build documentation and run notebooks (poe) if: steps.task-runner.outputs.value == 'poe' - run: |- - uv run \ - --group doc \ - --with poethepoet \ - poe doc + run: uvx --from poethepoet poe doc - uses: prefix-dev/setup-pixi@v0.9.3 if: steps.task-runner.outputs.value == 'pixi' with: diff --git a/.github/workflows/get-pypi-name.yml b/.github/workflows/get-pypi-name.yml index cee9175c..7c0d1af2 100644 --- a/.github/workflows/get-pypi-name.yml +++ b/.github/workflows/get-pypi-name.yml @@ -14,5 +14,5 @@ jobs: outputs: name: ${{ steps.package-name.outputs.name }} steps: - - uses: ComPWA/actions/get-pypi-name@v3 + - uses: ComPWA/actions/get-pypi-name@v4 id: package-name diff --git a/.github/workflows/linkcheck.yml b/.github/workflows/linkcheck.yml index 747b6da5..c6432a03 100644 --- a/.github/workflows/linkcheck.yml +++ b/.github/workflows/linkcheck.yml @@ -28,16 +28,12 @@ jobs: sudo apt-get update -y sudo apt-get install -y ${{ inputs.apt-packages }} - id: task-runner - uses: ComPWA/actions/determine-task-runner@v3 + uses: ComPWA/actions/determine-task-runner@v4 - env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} if: steps.task-runner.outputs.value == 'poe' name: Run Sphinx linkcheck (poe) - run: |- - uv run \ - --group doc \ - --with poethepoet \ - poe linkcheck + run: uvx --from poethepoet poe linkcheck - uses: prefix-dev/setup-pixi@v0.9.3 if: steps.task-runner.outputs.value == 'pixi' with: diff --git a/.github/workflows/lock.yml b/.github/workflows/lock.yml index cd4a6207..500ffd3d 100644 --- a/.github/workflows/lock.yml +++ b/.github/workflows/lock.yml @@ -153,7 +153,7 @@ jobs: runs-on: ubuntu-24.04 steps: - id: versions - uses: ComPWA/actions/create-python-version-matrix@v3 + uses: ComPWA/actions/create-python-version-matrix@v4 pip-constraints: name: pip constraint files diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index 2b161571..5a631b0a 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -20,6 +20,7 @@ on: env: DISABLE_PRE_COMMIT_UV_PATCH: True FORCE_COLOR: true + PRE_COMMIT_COLOR: always jobs: determine-hooks: @@ -29,7 +30,7 @@ jobs: runs-on: ubuntu-24.04 steps: - id: hooks - uses: ComPWA/actions/get-skipped-pre-commit-hooks@v3 + uses: ComPWA/actions/get-skipped-pre-commit-hooks@v4 pre-commit: name: Run local pre-commit hooks @@ -50,6 +51,7 @@ jobs: **/.pre-commit-config.yaml **/pyproject.toml **/uv.lock + cache-suffix: pre-commit - name: Fetch pre-commit cache uses: actions/cache@v5 with: @@ -58,10 +60,11 @@ jobs: restore-keys: | pre-commit-${{ runner.os }}-py${{ inputs.python-version }} path: ~/.cache/pre-commit/ - - id: uv-run - uses: ComPWA/actions/run-pre-commit@v3 + - run: | + uv tool install --python=${{ inputs.python-version }} poethepoet + uv tool install --python=${{ inputs.python-version }} --with pre-commit-uv pre-commit - if: needs.determine-hooks.outputs.skipped-hooks == 'ALL' - run: ${{ steps.uv-run.outputs.cmd }} --with pre-commit-uv pre-commit run --all-files --color=always + run: poe style - if: needs.determine-hooks.outputs.skipped-hooks != 'ALL' name: Run pre-commit hooks that don't work on pre-commit.ci run: |- @@ -70,7 +73,7 @@ jobs: export PRETTIER_LEGACY_CLI=1 fi for hook in $skipped_hooks; do - ${{ steps.uv-run.outputs.cmd }} --with pre-commit-uv pre-commit run $hook --all-files --color=always + poe style $hook done - id: diff if: always() diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml deleted file mode 100644 index d79d5949..00000000 --- a/.github/workflows/pytest.yml +++ /dev/null @@ -1,120 +0,0 @@ -env: - FORCE_COLOR: "1" - PYTHONHASHSEED: "0" - -on: - workflow_call: - inputs: - additional-extras: - description: Space-separated additional extras that need to be installed for the tests. - required: false - type: string - coverage-python-version: - default: "3.13" - required: false - type: string - coverage-target: - required: false - type: string - macos-python-version: - required: false - type: string - multithreaded: - default: true - required: false - type: boolean - skipped-python-versions: - required: false - type: string - specific-pip-packages: - required: false - type: string - test-output-path: - required: false - type: string - secrets: - CODECOV_TOKEN: - description: Token for uploading reports to Codecov. See https://docs.codecov.com/docs/codecov-uploader. - required: false - -jobs: - create-matrix: - name: Determine job matrix - outputs: - matrix: ${{ steps.set-matrix.outputs.matrix }} - runs-on: ubuntu-24.04 - steps: - - id: set-matrix - uses: ComPWA/actions/create-pytest-matrix@v3 - with: - coverage-python-version: ${{ inputs.coverage-python-version }} - coverage-target: ${{ inputs.coverage-target }} - macos-python-version: ${{ inputs.macos-python-version }} - skipped-python-versions: ${{ inputs.skipped-python-versions }} - - pytest: - name: Run unit tests - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - UV_PYTHON: ${{ matrix.python-version }} - needs: create-matrix - runs-on: ${{ matrix.runs-on }} - strategy: - fail-fast: false - matrix: ${{ fromJSON(needs.create-matrix.outputs.matrix) }} - steps: - - uses: actions/checkout@v6 - - uses: astral-sh/setup-uv@v7 - with: - cache-dependency-glob: | - **/pyproject.toml - **/uv.lock - - uses: ComPWA/actions/cache-sympy@v3 - - id: extra - if: inputs.additional-extras - name: Determine extras to install - run: | - test_extras='' - for extra in ${{ inputs.additional-extras }}; do - test_extras="$test_extras --group $extra" - done - echo "extras=$test_extras" | tee -a $GITHUB_OUTPUT - - id: with - if: inputs.specific-pip-packages - name: Determine additional packages to install - run: | - additional_packages='' - for package in ${{ inputs.specific-pip-packages }}; do - additional_packages="$additional_packages --with $package" - done - echo "packages=$additional_packages" | tee -a $GITHUB_OUTPUT - - id: coverage - if: matrix.coverage-target - name: Determine pytest coverage flags - run: echo "flags=--cov-report=xml --cov=${{ matrix.coverage-target }}" | tee -a $GITHUB_OUTPUT - - id: multithreaded - if: inputs.multithreaded - name: Determine pytest multithreading flags - run: echo "flags=--numprocesses=auto" | tee -a $GITHUB_OUTPUT - - name: Run tests with pytest - run: >- - uv run \ - --group test \ - ${{ steps.extra.outputs.extras }} \ - --no-dev \ - ${{ steps.with.outputs.packages }} \ - pytest \ - ${{ steps.coverage.outputs.flags }} \ - ${{ steps.multithreaded.outputs.flags }} \ - -m "not slow or slow" - - if: matrix.coverage-target - uses: codecov/codecov-action@v5 - with: - files: ./coverage.xml - flags: unittests - token: ${{ secrets.CODECOV_TOKEN }} - - uses: actions/upload-artifact@v6 - if: inputs.test-output-path - with: - name: test-output-${{ matrix.runs-on }}-${{ matrix.python-version }} - path: ${{ inputs.test-output-path }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000..a3ed4add --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,81 @@ +env: + FORCE_COLOR: "1" + PYTHONHASHSEED: "0" + +on: + workflow_call: + inputs: + coverage-python-version: + default: "" + required: false + type: string + macos-python-version: + required: false + type: string + multithreaded: + default: true + required: false + type: boolean + skipped-python-versions: + required: false + type: string + test-output-path: + required: false + type: string + secrets: + CODECOV_TOKEN: + description: Token for uploading reports to Codecov. See https://docs.codecov.com/docs/codecov-uploader. + required: false + +jobs: + create-matrix: + name: Determine job matrix + outputs: + matrix: ${{ steps.set-matrix.outputs.matrix }} + runs-on: ubuntu-24.04 + steps: + - id: set-matrix + uses: ComPWA/actions/create-pytest-matrix@v4 + with: + coverage-python-version: ${{ inputs.coverage-python-version }} + macos-python-version: ${{ inputs.macos-python-version }} + skipped-python-versions: ${{ inputs.skipped-python-versions }} + + test: + name: Run unit tests + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + UV_PYTHON: ${{ matrix.python-version }} + needs: create-matrix + runs-on: ${{ matrix.runs-on }} + strategy: + fail-fast: false + matrix: ${{ fromJSON(needs.create-matrix.outputs.matrix) }} + steps: + - uses: actions/checkout@v6 + - uses: astral-sh/setup-uv@v7 + with: + cache-dependency-glob: | + **/pyproject.toml + **/uv.lock + cache-suffix: test-${{ matrix.python-version }} + - uses: ComPWA/actions/cache-sympy@v4 + - if: inputs.multithreaded + name: Activate pytest multithreading + run: echo "PYTEST_XDIST_WORKER_COUNT=auto" | tee -a $GITHUB_ENV + - run: uv tool install poethepoet + - if: matrix.codecov + run: poe cov + - if: ${{ !matrix.codecov }} + run: poe test + - if: matrix.codecov + uses: codecov/codecov-action@v5 + with: + files: ./coverage.xml + flags: unittests + token: ${{ secrets.CODECOV_TOKEN }} + - uses: actions/upload-artifact@v6 + if: inputs.test-output-path + with: + name: test-output-${{ matrix.runs-on }}-${{ matrix.python-version }} + path: ${{ inputs.test-output-path }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 453593ee..7a281a80 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -12,7 +12,7 @@ repos: - id: check-useless-excludes - repo: https://github.com/ComPWA/policy - rev: 0.8.0 + rev: 0.8.2rc1 hooks: - id: check-dev-files args: @@ -27,7 +27,7 @@ repos: - --update-lock-files=no - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.14.10 + rev: v0.14.11 hooks: - id: ruff-check args: [--fix] @@ -83,7 +83,7 @@ repos: - id: ty name: ty entry: ty check - args: [--output-format=concise] + args: [--no-progress, --output-format=concise] require_serial: true language: system types_or: [python, pyi, jupyter] diff --git a/create-pytest-matrix/action.yml b/create-pytest-matrix/action.yml index 1cb4d398..3bebc56d 100644 --- a/create-pytest-matrix/action.yml +++ b/create-pytest-matrix/action.yml @@ -1,31 +1,25 @@ name: Create run matrix of python versions -description: >- - Create a run matrix of python versions for pytest workflow. +description: Create a run matrix of python versions for pytest workflow. inputs: coverage-python-version: - default: "3.13" - description: Python version on which to run the test coverage job. - required: false - coverage-target: - description: >- - Name of the package over which to compute test coverage. Leave empty if - you do not want to compute test coverage. + default: "" + description: + Python version on which to run the test coverage job. Leave empty to + skip creating a coverage job. required: false macos-python-version: - description: >- + description: Run tests on macOS on a specific version of Python. If left empty, the no macOS job will be created. required: false skipped-python-versions: - description: >- - Do not run tests on the following supported Python versions. + description: Do not run tests on the following supported Python versions. required: false outputs: matrix: - description: >- - A JSON object that can be used for setting `jobs..strategy`. + description: A JSON object that can be used for setting `jobs..strategy`. value: ${{ steps.set-matrix.outputs.matrix }} runs: @@ -46,10 +40,9 @@ runs: delimiter="$(openssl rand -hex 8)" echo "matrix<<${delimiter}" >> $GITHUB_OUTPUT uv run -p3.13 $GITHUB_ACTION_PATH/main.py \ - '${{ inputs.coverage-python-version }}' \ - '${{ inputs.coverage-target }}' \ - '${{ inputs.macos-python-version }}' \ - '${{ inputs.skipped-python-versions }}' \ + --coverage-python-version=${{ inputs.coverage-python-version }} \ + --macos-python-version=${{ inputs.macos-python-version }} \ + --skipped-python-versions='${{ inputs.skipped-python-versions }}' \ | tee -a $GITHUB_OUTPUT echo "${delimiter}" >> $GITHUB_OUTPUT shell: bash diff --git a/create-pytest-matrix/main.py b/create-pytest-matrix/main.py index 76100199..c2315043 100644 --- a/create-pytest-matrix/main.py +++ b/create-pytest-matrix/main.py @@ -13,7 +13,7 @@ import tomllib from argparse import ArgumentParser from dataclasses import dataclass -from typing import TYPE_CHECKING +from typing import TYPE_CHECKING, Literal from packaging.specifiers import SpecifierSet from packaging.version import Version @@ -21,37 +21,38 @@ if TYPE_CHECKING: from collections.abc import Sequence +PYTHON_VERSION = Literal[ + "3.6", "3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "3.14" +] + def main(argv: Sequence[str] | None = None) -> int: parser = ArgumentParser(__doc__) - parser.add_argument("coverage-python-version") - parser.add_argument("coverage-target") - parser.add_argument("macos-python-version") - parser.add_argument("skipped-python-versions") + parser.add_argument("--coverage-python-version", choices=PYTHON_VERSION.__args__) + parser.add_argument("--macos-python-version", choices=PYTHON_VERSION.__args__) + parser.add_argument("--skipped-python-versions", type=str) args = parser.parse_args(argv) matrix = create_job_matrix( - args.__dict__["coverage-python-version"], - args.__dict__["coverage-target"], - args.__dict__["macos-python-version"], - _format_skipped_version(args.__dict__["skipped-python-versions"]), + args.coverage_python_version, + args.macos_python_version, + _format_skipped_version(args.skipped_python_versions), ) print(json.dumps(matrix, indent=2)) return 0 -def _format_skipped_version(skipped_python_versions: str) -> set[str] | None: +def _format_skipped_version(skipped_python_versions: str) -> set[PYTHON_VERSION] | None: if skipped_python_versions == "all": return None if not skipped_python_versions: return set() - return set(skipped_python_versions.split(" ")) + return set(skipped_python_versions.split(" ")) # ty:ignore[invalid-return-type] def create_job_matrix( - coverage_python_version: str, - coverage_target: str, - macos_python_version: str, - skipped_python_versions: set[str] | None, + coverage_python_version: PYTHON_VERSION | Literal[""], + macos_python_version: PYTHON_VERSION, + skipped_python_versions: set[PYTHON_VERSION] | None, ) -> dict: supported_python_versions = get_supported_python_versions() if skipped_python_versions is None: @@ -60,7 +61,7 @@ def create_job_matrix( python_versions = sorted( set(supported_python_versions) - skipped_python_versions ) - if coverage_target: + if coverage_python_version: _is_version_allowed(coverage_python_version, supported_python_versions) if coverage_python_version in python_versions: python_versions.remove(coverage_python_version) @@ -77,9 +78,9 @@ def create_job_matrix( "python-version": "3.7", "runs-on": "ubuntu-22.04", }) - if coverage_target: + if coverage_python_version: includes.append({ - "coverage-target": coverage_target, + "codecov": "codecov", "python-version": coverage_python_version, "runs-on": "ubuntu-24.04", }) @@ -100,7 +101,9 @@ def create_job_matrix( return matrix -def _is_version_allowed(version: str, supported_versions: list[str]) -> None: +def _is_version_allowed( + version: PYTHON_VERSION, supported_versions: list[PYTHON_VERSION] +) -> None: if version not in supported_versions: supported_versions_str = ", ".join(supported_versions) msg = f"Selected Python {version}, but the package only supports Python {supported_versions_str}" @@ -111,7 +114,7 @@ def _is_version_allowed(version: str, supported_versions: list[str]) -> None: VERSION_IDENTIFIER = "Programming Language :: Python :: 3." -def get_supported_python_versions() -> list[str]: +def get_supported_python_versions() -> list[PYTHON_VERSION]: version_info = _get_version_info() return _determine_python_versions(version_info) @@ -136,7 +139,7 @@ def _get_version_info() -> VersionInfo: ) -def _determine_python_versions(version_info: VersionInfo) -> list[str]: +def _determine_python_versions(version_info: VersionInfo) -> list[PYTHON_VERSION]: supported_versions = _determine_python_versions_from_classifiers(version_info) if supported_versions is not None: return supported_versions @@ -148,7 +151,7 @@ def _determine_python_versions(version_info: VersionInfo) -> list[str]: def _determine_python_versions_from_classifiers( version_info: VersionInfo, -) -> list[str] | None: +) -> list[PYTHON_VERSION] | None: if version_info.classifiers is None: return None version_identifier = "Programming Language :: Python :: 3." @@ -156,10 +159,10 @@ def _determine_python_versions_from_classifiers( if not versions: return None prefix = version_identifier[:-2] - return [s.replace(prefix, "") for s in versions] + return [s.replace(prefix, "") for s in versions] # ty:ignore[invalid-return-type] -def __get_allowed_versions(version_range: str) -> list[str]: +def __get_allowed_versions(version_range: str) -> list[PYTHON_VERSION]: """Get a list of allowed versions from a version range specifier. >>> __get_allowed_versions(">=3.9,<3.13") @@ -168,7 +171,7 @@ def __get_allowed_versions(version_range: str) -> list[str]: specifier = SpecifierSet(version_range) allowed_versions = [f"3.{v}" for v in range(6, 15)] versions_to_check = [Version(v) for v in sorted(allowed_versions)] - return [str(v) for v in versions_to_check if v in specifier] + return [str(v) for v in versions_to_check if v in specifier] # ty:ignore[invalid-return-type] if __name__ == "__main__": diff --git a/create-python-version-matrix/action.yml b/create-python-version-matrix/action.yml index b4a7b214..41685bc1 100644 --- a/create-python-version-matrix/action.yml +++ b/create-python-version-matrix/action.yml @@ -7,11 +7,6 @@ inputs: default: "3.13" description: Python version on which to run the test coverage job. required: false - coverage-target: - description: >- - Name of the package over which to compute test coverage. Leave empty if - you do not want to compute test coverage. - required: false macos-python-version: description: >- Run tests on macOS on a specific version of Python. If left empty, the no diff --git a/run-pre-commit/action.yml b/run-pre-commit/action.yml deleted file mode 100644 index 62f3bdd9..00000000 --- a/run-pre-commit/action.yml +++ /dev/null @@ -1,19 +0,0 @@ -name: Run pre-commit hooks with style environment -description: >- - Run local pre-commit hooks that may require the installation of a virtual environment. - -outputs: - cmd: - description: >- - The uv run command to use for `pre-commit` - value: ${{ steps.uv-run.outputs.cmd }} - -runs: - using: composite - steps: - - env: - UV_SYSTEM_PYTHON: 1 - id: uv-run - name: Determine skipped hooks - run: echo "cmd=$(uv run -p3.13 $GITHUB_ACTION_PATH/main.py)" | tee -a $GITHUB_OUTPUT - shell: bash diff --git a/run-pre-commit/main.py b/run-pre-commit/main.py deleted file mode 100644 index e76918e7..00000000 --- a/run-pre-commit/main.py +++ /dev/null @@ -1,42 +0,0 @@ -"""Determine which pre-commit hooks should be skipped.""" - -# /// script -# dependencies = ["rtoml"] -# /// -from pathlib import Path - -import rtoml - - -def main() -> None: - cmd = _get_uv_run_command() - print(cmd) - - -def _get_uv_run_command() -> str: - pyproject_path = Path("pyproject.toml") - if pyproject_path.is_file(): - pyproject = rtoml.load(pyproject_path) - dependency_groups = pyproject.get("dependency-groups") - candidate_groups = [ - "style", - "sty", - "lint", - ] - if dependency_groups is not None: - for group in candidate_groups: - if group in dependency_groups: - return f"uv run --group {group} --no-dev" - project_table = pyproject.get("project", {}) - extras = project_table.get("optional-dependencies") - if extras is not None: - for extra in candidate_groups: - if extra in extras: - return f"uv run --extra {extra} --no-dev" - if "dependencies" in project_table: - return "uv run --no-dev" - return "uvx" - - -if __name__ == "__main__": - raise SystemExit(main()) From e2d66617b929a969ceab95e895761982c3ba3728 Mon Sep 17 00:00:00 2001 From: Remco de Boer <29308176+redeboer@users.noreply.github.com> Date: Tue, 27 Jan 2026 12:09:59 +0100 Subject: [PATCH 02/16] MAINT: import ComPWA/update-pre-commit --- .github/workflows/lock.yml | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/.github/workflows/lock.yml b/.github/workflows/lock.yml index 500ffd3d..a2676daf 100644 --- a/.github/workflows/lock.yml +++ b/.github/workflows/lock.yml @@ -218,7 +218,22 @@ jobs: runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v6 - - uses: ComPWA/update-pre-commit@v1 + - uses: actions/setup-python@v6 + - uses: astral-sh/setup-uv@v7 + - env: + FORCE_COLOR: True + UV_SYSTEM_PYTHON: True + run: uvx --with pre-commit-uv pre-commit autoupdate -j$(nproc) + shell: bash + - name: Show changes + run: git diff --color --unified=0 + shell: bash + - uses: actions/upload-artifact@v6 + with: + if-no-files-found: error + include-hidden-files: true + name: pre-commit + path: .pre-commit-config.yaml uv-lock: name: uv.lock From f6c92d9810fb9b042e9351c948b2391318568d8d Mon Sep 17 00:00:00 2001 From: Remco de Boer <29308176+redeboer@users.noreply.github.com> Date: Tue, 27 Jan 2026 16:18:15 +0100 Subject: [PATCH 03/16] ENH: use `ubuntu-slim` where possible --- .cspell.json | 1 + .github/dependabot.yml | 22 +++++++++---------- .github/workflows/cd.yml | 2 +- .github/workflows/ci-docs.yml | 2 +- .github/workflows/clean-caches.yml | 2 +- .github/workflows/close-milestone.yml | 2 +- .github/workflows/get-pypi-name.yml | 2 +- .github/workflows/lock.yml | 12 +++++----- .github/workflows/pr-linting.yml | 2 +- .github/workflows/pre-commit.yml | 4 ++-- .../workflows/push-to-version-branches.yml | 2 +- .github/workflows/release-drafter.yml | 2 +- .github/workflows/test.yml | 2 +- .pre-commit-config.yaml | 11 +++++----- .vscode/settings.json | 1 - README.md | 2 +- pyproject.toml | 2 +- 17 files changed, 35 insertions(+), 38 deletions(-) diff --git a/.cspell.json b/.cspell.json index 9724ff12..07938e9e 100644 --- a/.cspell.json +++ b/.cspell.json @@ -36,6 +36,7 @@ "**/.cspell.json", ".editorconfig", ".envrc", + ".github/dependabot.yml", ".gitignore", ".pre-commit-config.yaml", ".prettierignore", diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 90891ae8..c658ead2 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,16 +1,14 @@ version: 2 + +multi-ecosystem-groups: + lock: + assignees: [redeboer] + commit-message: { prefix: MAINT } + schedule: { interval: quarterly } + updates: - package-ecosystem: github-actions directory: "/" - assignees: - - redeboer - commit-message: - prefix: MAINT - groups: - actions: - patterns: - - "*" - labels: - - ⬆️ Lock - schedule: - interval: monthly + labels: [⬆️ Lock] + multi-ecosystem-group: lock + patterns: ["*"] diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index a9828f1e..110ca129 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -13,7 +13,7 @@ jobs: push-to-version-branches: name: Push to version branches if: startsWith(github.ref, 'refs/tags') && !github.event.release.prerelease - runs-on: ubuntu-24.04 + runs-on: ubuntu-slim steps: - uses: actions/checkout@v6 - name: Configure Git credentials diff --git a/.github/workflows/ci-docs.yml b/.github/workflows/ci-docs.yml index 534fa875..0aac93a7 100644 --- a/.github/workflows/ci-docs.yml +++ b/.github/workflows/ci-docs.yml @@ -39,7 +39,7 @@ jobs: permissions: pages: write id-token: write - runs-on: ubuntu-24.04 + runs-on: ubuntu-slim steps: - id: deployment uses: actions/deploy-pages@v4 diff --git a/.github/workflows/clean-caches.yml b/.github/workflows/clean-caches.yml index b241bf56..1d3abcc7 100644 --- a/.github/workflows/clean-caches.yml +++ b/.github/workflows/clean-caches.yml @@ -14,7 +14,7 @@ on: jobs: cleanup: name: Remove caches - runs-on: ubuntu-24.04 + runs-on: ubuntu-slim steps: - uses: ComPWA/actions/clean-caches@v4 with: diff --git a/.github/workflows/close-milestone.yml b/.github/workflows/close-milestone.yml index 838a6b22..d8a56b36 100644 --- a/.github/workflows/close-milestone.yml +++ b/.github/workflows/close-milestone.yml @@ -3,7 +3,7 @@ on: jobs: close-milestone: - runs-on: ubuntu-24.04 + runs-on: ubuntu-slim steps: - uses: mhutchie/update-milestone-on-release@master with: diff --git a/.github/workflows/get-pypi-name.yml b/.github/workflows/get-pypi-name.yml index 7c0d1af2..6329fc1b 100644 --- a/.github/workflows/get-pypi-name.yml +++ b/.github/workflows/get-pypi-name.yml @@ -10,7 +10,7 @@ jobs: package-name: if: startsWith(github.ref, 'refs/tags') name: Determine package name - runs-on: ubuntu-24.04 + runs-on: ubuntu-slim outputs: name: ${{ steps.package-name.outputs.name }} steps: diff --git a/.github/workflows/lock.yml b/.github/workflows/lock.yml index a2676daf..152f4c35 100644 --- a/.github/workflows/lock.yml +++ b/.github/workflows/lock.yml @@ -37,7 +37,7 @@ jobs: github.event_name == 'workflow_dispatch' outputs: exists: ${{ steps.pr-exists.outputs.exists }} - runs-on: ubuntu-24.04 + runs-on: ubuntu-slim steps: - uses: actions/checkout@v6 - name: List open pull requests @@ -77,7 +77,7 @@ jobs: if: >- github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository - runs-on: ubuntu-24.04 + runs-on: ubuntu-slim outputs: lock-upgrade: ${{ steps.check.outputs.lock-upgrade }} steps: @@ -122,7 +122,7 @@ jobs: needs: - pr-has-lock-label - pr-exists - runs-on: ubuntu-24.04 + runs-on: ubuntu-slim outputs: lock-files: ${{ steps.check.outputs.lock-files }} steps: @@ -150,7 +150,7 @@ jobs: - find-lock-files outputs: matrix: ${{ steps.versions.outputs.matrix }} - runs-on: ubuntu-24.04 + runs-on: ubuntu-slim steps: - id: versions uses: ComPWA/actions/create-python-version-matrix@v4 @@ -257,7 +257,7 @@ jobs: if: >- always() && needs.pr-has-lock-label.outputs.lock-upgrade == 'true' - runs-on: ubuntu-24.04 + runs-on: ubuntu-slim needs: - julia - pip-constraints @@ -295,7 +295,7 @@ jobs: create-pr: name: Create PR - runs-on: ubuntu-24.04 + runs-on: ubuntu-slim if: >- always() && needs.pr-exists.outputs.exists == 'false' diff --git a/.github/workflows/pr-linting.yml b/.github/workflows/pr-linting.yml index c43186e9..5d706181 100644 --- a/.github/workflows/pr-linting.yml +++ b/.github/workflows/pr-linting.yml @@ -26,7 +26,7 @@ jobs: check-title: if: github.event.pull_request.state == 'open' name: Check title - runs-on: ubuntu-24.04 + runs-on: ubuntu-slim steps: - uses: actions/checkout@v6 - run: npm install @compwa/commitlint-config diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index 5a631b0a..1d26385b 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -27,7 +27,7 @@ jobs: name: Determine skipped pre-commit hooks outputs: skipped-hooks: ${{ steps.hooks.outputs.skipped-hooks }} - runs-on: ubuntu-24.04 + runs-on: ubuntu-slim steps: - id: hooks uses: ComPWA/actions/get-skipped-pre-commit-hooks@v4 @@ -107,7 +107,7 @@ jobs: name: Push changes needs: - pre-commit - runs-on: ubuntu-24.04 + runs-on: ubuntu-slim steps: - uses: actions/checkout@v6 with: diff --git a/.github/workflows/push-to-version-branches.yml b/.github/workflows/push-to-version-branches.yml index 561d0385..8fea1c8f 100644 --- a/.github/workflows/push-to-version-branches.yml +++ b/.github/workflows/push-to-version-branches.yml @@ -5,7 +5,7 @@ jobs: push: name: Push to version branches if: startsWith(github.ref, 'refs/tags') && !github.event.release.prerelease - runs-on: ubuntu-24.04 + runs-on: ubuntu-slim steps: - uses: actions/checkout@v6 - name: Configure Git credentials diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml index 32c6579c..67334ee7 100644 --- a/.github/workflows/release-drafter.yml +++ b/.github/workflows/release-drafter.yml @@ -9,7 +9,7 @@ on: jobs: update_release_draft: - runs-on: ubuntu-24.04 + runs-on: ubuntu-slim steps: - uses: release-drafter/release-drafter@v6 env: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a3ed4add..c483bc7c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -32,7 +32,7 @@ jobs: name: Determine job matrix outputs: matrix: ${{ steps.set-matrix.outputs.matrix }} - runs-on: ubuntu-24.04 + runs-on: ubuntu-slim steps: - id: set-matrix uses: ComPWA/actions/create-pytest-matrix@v4 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7a281a80..4fa2e55e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -12,22 +12,21 @@ repos: - id: check-useless-excludes - repo: https://github.com/ComPWA/policy - rev: 0.8.2rc1 + rev: 5339b98d9b3f7a2e576a22931480c6f4536b2ba7 hooks: - id: check-dev-files args: - --allow-deprecated-workflows - - --dependabot=update - --keep-pr-linting + - --keep-workflow=lock.yml - --no-pypi - --no-version-branches - --repo-name=actions - --repo-title=ComPWA actions and shared workflows - --type-checker=ty - - --update-lock-files=no - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.14.11 + rev: v0.14.14 hooks: - id: ruff-check args: [--fix] @@ -46,7 +45,7 @@ repos: - id: trailing-whitespace - repo: https://github.com/ComPWA/prettier-pre-commit - rev: v3.4.2 + rev: v3.8.1 hooks: - id: prettier @@ -63,7 +62,7 @@ repos: - --in-place - repo: https://github.com/streetsidesoftware/cspell-cli - rev: v9.4.0 + rev: v9.6.0 hooks: - id: cspell diff --git a/.vscode/settings.json b/.vscode/settings.json index 2650e2bb..cab8bfa3 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -36,7 +36,6 @@ }, "notebook.formatOnSave.enabled": true, "python.defaultInterpreterPath": ".venv/bin/python", - "python.languageServer": "None", "python.terminal.activateEnvironment": false, "redhat.telemetry.enabled": false, "rewrap.wrappingColumn": 88, diff --git a/README.md b/README.md index 0fb30ed2..2b4da99b 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier) -[![Spelling checked](https://img.shields.io/badge/cspell-checked-brightgreen.svg)](https://github.com/streetsidesoftware/cspell/tree/master/packages/cspell) +[![Spelling checked](https://img.shields.io/badge/cspell-checked-brightgreen.svg)](https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell) [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff) [![uv](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/uv/main/assets/badge/v0.json)](https://github.com/astral-sh/uv) [![ty](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ty/main/assets/badge/v0.json)](https://github.com/astral-sh/ty) diff --git a/pyproject.toml b/pyproject.toml index b3e1dac5..0d0f0c5a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -78,6 +78,7 @@ ignore = [ "PLW1514", "PT001", "PTH", + "RUF067", "SIM108", "T201", ] @@ -106,4 +107,3 @@ trailing_comma_inline_array = true division-by-zero = "warn" possibly-missing-import = "warn" possibly-unresolved-reference = "warn" -unused-ignore-comment = "warn" From f09f2d540f05e6269cb77fcaa603cce6c4682672 Mon Sep 17 00:00:00 2001 From: Remco de Boer <29308176+redeboer@users.noreply.github.com> Date: Tue, 27 Jan 2026 17:14:54 +0100 Subject: [PATCH 04/16] MAINT: upgrade lock files --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4fa2e55e..d933b757 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -12,7 +12,7 @@ repos: - id: check-useless-excludes - repo: https://github.com/ComPWA/policy - rev: 5339b98d9b3f7a2e576a22931480c6f4536b2ba7 + rev: 592883b56e43a43430756a93701e749789042d6e hooks: - id: check-dev-files args: From 285f80b34d545a421d5aaa525069b8aec7261e60 Mon Sep 17 00:00:00 2001 From: Remco de Boer <29308176+redeboer@users.noreply.github.com> Date: Tue, 27 Jan 2026 17:14:54 +0100 Subject: [PATCH 05/16] MAINT: upgrade lock files --- .pre-commit-config.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d933b757..b12b55b7 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -12,7 +12,7 @@ repos: - id: check-useless-excludes - repo: https://github.com/ComPWA/policy - rev: 592883b56e43a43430756a93701e749789042d6e + rev: 0.8.2rc12 hooks: - id: check-dev-files args: @@ -83,6 +83,7 @@ repos: name: ty entry: ty check args: [--no-progress, --output-format=concise] + pass_filenames: false require_serial: true language: system types_or: [python, pyi, jupyter] From 874ddba4ea5d3fa56a09704736a0b40319fd8134 Mon Sep 17 00:00:00 2001 From: Remco de Boer <29308176+redeboer@users.noreply.github.com> Date: Thu, 29 Jan 2026 20:31:07 +0100 Subject: [PATCH 06/16] FIX: determine style command --- .github/workflows/pre-commit.yml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index 1d26385b..e022df02 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -63,8 +63,16 @@ jobs: - run: | uv tool install --python=${{ inputs.python-version }} poethepoet uv tool install --python=${{ inputs.python-version }} --with pre-commit-uv pre-commit + - name: Determine style-check command + id: cmd + run: | + if [[ -f "pyproject.toml" && $(grep -c "\[tool.poe.tasks.style\]" pyproject.toml) -gt 0 ]]; then + echo "cmd=poe style" >> $GITHUB_OUTPUT + else + echo "cmd=pre-commit run --all-files" >> $GITHUB_OUTPUT + fi - if: needs.determine-hooks.outputs.skipped-hooks == 'ALL' - run: poe style + run: ${{ steps.cmd.outputs.cmd }} - if: needs.determine-hooks.outputs.skipped-hooks != 'ALL' name: Run pre-commit hooks that don't work on pre-commit.ci run: |- @@ -73,7 +81,7 @@ jobs: export PRETTIER_LEGACY_CLI=1 fi for hook in $skipped_hooks; do - poe style $hook + ${{ steps.cmd.outputs.cmd }} $hook done - id: diff if: always() From 9875b2c979e10b9f367ffbbf52b7318ab7441424 Mon Sep 17 00:00:00 2001 From: Remco de Boer <29308176+redeboer@users.noreply.github.com> Date: Fri, 30 Jan 2026 16:03:05 +0100 Subject: [PATCH 07/16] MAINT: upgrade lock files --- .github/workflows/docnb.yml | 2 +- .github/workflows/linkcheck.yml | 2 +- .github/workflows/lock.yml | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/docnb.yml b/.github/workflows/docnb.yml index 890136b4..4fb6e01e 100644 --- a/.github/workflows/docnb.yml +++ b/.github/workflows/docnb.yml @@ -49,7 +49,7 @@ jobs: - name: Build documentation and run notebooks (poe) if: steps.task-runner.outputs.value == 'poe' run: uvx --from poethepoet poe doc - - uses: prefix-dev/setup-pixi@v0.9.3 + - uses: prefix-dev/setup-pixi@v0.9.4 if: steps.task-runner.outputs.value == 'pixi' with: cache: true diff --git a/.github/workflows/linkcheck.yml b/.github/workflows/linkcheck.yml index c6432a03..336acc76 100644 --- a/.github/workflows/linkcheck.yml +++ b/.github/workflows/linkcheck.yml @@ -34,7 +34,7 @@ jobs: if: steps.task-runner.outputs.value == 'poe' name: Run Sphinx linkcheck (poe) run: uvx --from poethepoet poe linkcheck - - uses: prefix-dev/setup-pixi@v0.9.3 + - uses: prefix-dev/setup-pixi@v0.9.4 if: steps.task-runner.outputs.value == 'pixi' with: cache: true diff --git a/.github/workflows/lock.yml b/.github/workflows/lock.yml index 152f4c35..a42bdb1a 100644 --- a/.github/workflows/lock.yml +++ b/.github/workflows/lock.yml @@ -179,7 +179,7 @@ jobs: runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v6 - - uses: prefix-dev/setup-pixi@v0.9.3 + - uses: prefix-dev/setup-pixi@v0.9.4 with: run-install: false - name: Update lock files @@ -200,7 +200,7 @@ jobs: - if: hashFiles('pixi.lock') == '' uses: julia-actions/setup-julia@v2 - if: hashFiles('pixi.lock') - uses: prefix-dev/setup-pixi@v0.9.3 + uses: prefix-dev/setup-pixi@v0.9.4 with: activate-environment: true - name: Update Julia Manifest.toml From 8f3c765573c009ce2ba6bdfea470811753b92e81 Mon Sep 17 00:00:00 2001 From: Remco de Boer <29308176+redeboer@users.noreply.github.com> Date: Fri, 30 Jan 2026 16:16:35 +0100 Subject: [PATCH 08/16] FIX: support Pixi configs --- .github/workflows/pre-commit.yml | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index e022df02..ec9417ff 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -66,11 +66,22 @@ jobs: - name: Determine style-check command id: cmd run: | - if [[ -f "pyproject.toml" && $(grep -c "\[tool.poe.tasks.style\]" pyproject.toml) -gt 0 ]]; then - echo "cmd=poe style" >> $GITHUB_OUTPUT - else - echo "cmd=pre-commit run --all-files" >> $GITHUB_OUTPUT + cmd="pre-commit run --all-files" + if [[ -f pixi.toml && $(grep -c "\[tasks.style\]" pixi.toml) -gt 0 ]]; then + cmd="pixi run style" fi + if [[ -f pyproject.toml ]]; then + if [[ $(grep -c "\[tool.poe.tasks.style\]" pyproject.toml) -gt 0 ]]; then + cmd="poe style" + elif [[ $(grep -c "\[tool.pixi.tasks.style\]" pyproject.toml) -gt 0 ]]; then + cmd="pixi run style" + fi + fi + echo "cmd=$cmd" | tee -a $GITHUB_OUTPUT + - uses: prefix-dev/setup-pixi@v0.9.4 + if: contains(steps.cmd.outputs.cmd, 'pixi') + with: + cache: true - if: needs.determine-hooks.outputs.skipped-hooks == 'ALL' run: ${{ steps.cmd.outputs.cmd }} - if: needs.determine-hooks.outputs.skipped-hooks != 'ALL' From 2c91d4b40577e1b8186ca10660478845a9648609 Mon Sep 17 00:00:00 2001 From: Remco de Boer <29308176+redeboer@users.noreply.github.com> Date: Sun, 1 Feb 2026 11:29:23 +0100 Subject: [PATCH 09/16] MAINT: update workflow versions --- build-pypi-distribution/action.yml | 6 +++--- create-pytest-matrix/action.yml | 6 +++--- create-python-version-matrix/action.yml | 6 +++--- determine-task-runner/action.yml | 6 +++--- get-pypi-name/action.yml | 4 ++-- get-skipped-pre-commit-hooks/action.yml | 6 +++--- pip-install/action.yml | 2 +- 7 files changed, 18 insertions(+), 18 deletions(-) diff --git a/build-pypi-distribution/action.yml b/build-pypi-distribution/action.yml index 8eafcc6e..51c42c0f 100644 --- a/build-pypi-distribution/action.yml +++ b/build-pypi-distribution/action.yml @@ -9,11 +9,11 @@ description: >- runs: using: composite steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 + - uses: actions/checkout@v6 + - uses: actions/setup-python@v6 with: python-version: "3.13" - - uses: astral-sh/setup-uv@v6 + - uses: astral-sh/setup-uv@v7 with: enable-cache: false - run: uv pip install --color=always --system build diff --git a/create-pytest-matrix/action.yml b/create-pytest-matrix/action.yml index 3bebc56d..1a1c2729 100644 --- a/create-pytest-matrix/action.yml +++ b/create-pytest-matrix/action.yml @@ -25,11 +25,11 @@ outputs: runs: using: composite steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 + - uses: actions/checkout@v6 + - uses: actions/setup-python@v6 with: python-version: "3.13" - - uses: astral-sh/setup-uv@v6 + - uses: astral-sh/setup-uv@v7 with: enable-cache: false - env: diff --git a/create-python-version-matrix/action.yml b/create-python-version-matrix/action.yml index 41685bc1..1018aaef 100644 --- a/create-python-version-matrix/action.yml +++ b/create-python-version-matrix/action.yml @@ -22,13 +22,13 @@ outputs: runs: using: composite steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - if: hashFiles('pyproject.toml') - uses: actions/setup-python@v5 + uses: actions/setup-python@v6 with: python-version: "3.13" - if: hashFiles('pyproject.toml') - uses: astral-sh/setup-uv@v6 + uses: astral-sh/setup-uv@v7 with: enable-cache: false - env: diff --git a/determine-task-runner/action.yml b/determine-task-runner/action.yml index 496af04d..ae122f7c 100644 --- a/determine-task-runner/action.yml +++ b/determine-task-runner/action.yml @@ -9,11 +9,11 @@ outputs: runs: using: composite steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 + - uses: actions/checkout@v6 + - uses: actions/setup-python@v6 with: python-version: "3.13" - - uses: astral-sh/setup-uv@v6 + - uses: astral-sh/setup-uv@v7 with: enable-cache: false - env: diff --git a/get-pypi-name/action.yml b/get-pypi-name/action.yml index 9c3fe3e1..d6a41c39 100644 --- a/get-pypi-name/action.yml +++ b/get-pypi-name/action.yml @@ -10,8 +10,8 @@ outputs: runs: using: composite steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 + - uses: actions/checkout@v6 + - uses: actions/setup-python@v6 with: python-version: "3.13" - id: determine-name diff --git a/get-skipped-pre-commit-hooks/action.yml b/get-skipped-pre-commit-hooks/action.yml index 82dc8d04..94567561 100644 --- a/get-skipped-pre-commit-hooks/action.yml +++ b/get-skipped-pre-commit-hooks/action.yml @@ -14,13 +14,13 @@ outputs: runs: using: composite steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 with: sparse-checkout: .pre-commit-config.yaml - - uses: actions/setup-python@v5 + - uses: actions/setup-python@v6 with: python-version: "3.13" - - uses: astral-sh/setup-uv@v6 + - uses: astral-sh/setup-uv@v7 with: enable-cache: false - env: diff --git a/pip-install/action.yml b/pip-install/action.yml index 42d6ff4f..7b2d554b 100644 --- a/pip-install/action.yml +++ b/pip-install/action.yml @@ -25,7 +25,7 @@ runs: using: composite steps: - if: inputs.python-version - uses: actions/setup-python@v5 + uses: actions/setup-python@v6 with: python-version: ${{ inputs.python-version }} - name: Determine Python version From c8154192eab5fecb34b669aff97ac99b9373ba68 Mon Sep 17 00:00:00 2001 From: Remco de Boer <29308176+redeboer@users.noreply.github.com> Date: Sun, 1 Feb 2026 11:33:37 +0100 Subject: [PATCH 10/16] FIX: allow empty coverage target --- create-pytest-matrix/action.yml | 1 - create-pytest-matrix/main.py | 10 +++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/create-pytest-matrix/action.yml b/create-pytest-matrix/action.yml index 1a1c2729..01194fe2 100644 --- a/create-pytest-matrix/action.yml +++ b/create-pytest-matrix/action.yml @@ -3,7 +3,6 @@ description: Create a run matrix of python versions for pytest workflow. inputs: coverage-python-version: - default: "" description: Python version on which to run the test coverage job. Leave empty to skip creating a coverage job. diff --git a/create-pytest-matrix/main.py b/create-pytest-matrix/main.py index c2315043..263a217e 100644 --- a/create-pytest-matrix/main.py +++ b/create-pytest-matrix/main.py @@ -28,8 +28,12 @@ def main(argv: Sequence[str] | None = None) -> int: parser = ArgumentParser(__doc__) - parser.add_argument("--coverage-python-version", choices=PYTHON_VERSION.__args__) - parser.add_argument("--macos-python-version", choices=PYTHON_VERSION.__args__) + parser.add_argument( + "--coverage-python-version", choices=[*PYTHON_VERSION.__args__, ""] + ) + parser.add_argument( + "--macos-python-version", choices=[*PYTHON_VERSION.__args__, ""] + ) parser.add_argument("--skipped-python-versions", type=str) args = parser.parse_args(argv) matrix = create_job_matrix( @@ -51,7 +55,7 @@ def _format_skipped_version(skipped_python_versions: str) -> set[PYTHON_VERSION] def create_job_matrix( coverage_python_version: PYTHON_VERSION | Literal[""], - macos_python_version: PYTHON_VERSION, + macos_python_version: PYTHON_VERSION | Literal[""], skipped_python_versions: set[PYTHON_VERSION] | None, ) -> dict: supported_python_versions = get_supported_python_versions() From bdf7a1d10eddbf2ab7b12484d120582240204b25 Mon Sep 17 00:00:00 2001 From: Remco de Boer <29308176+redeboer@users.noreply.github.com> Date: Sun, 1 Feb 2026 11:47:59 +0100 Subject: [PATCH 11/16] FIX: support Pixi in test job --- .github/workflows/test.yml | 21 ++++++++++++++++++--- .pre-commit-config.yaml | 2 +- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c483bc7c..705796c5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -63,11 +63,26 @@ jobs: - if: inputs.multithreaded name: Activate pytest multithreading run: echo "PYTEST_XDIST_WORKER_COUNT=auto" | tee -a $GITHUB_ENV - - run: uv tool install poethepoet + - id: task-runner + uses: ComPWA/actions/determine-task-runner@v4 + - uses: prefix-dev/setup-pixi@v0.9.4 + if: steps.task-runner.outputs.value == 'pixi' + with: + cache: true - if: matrix.codecov - run: poe cov + run: |- + ${{ case( + steps.task-runner.outputs.value == 'pixi', + 'pixi run cov', + 'uvx --from poethepoet poe cov' + ) }} - if: ${{ !matrix.codecov }} - run: poe test + run: |- + ${{ case( + steps.task-runner.outputs.value == 'pixi', + 'pixi run test', + 'uvx --from poethepoet poe test' + ) }} - if: matrix.codecov uses: codecov/codecov-action@v5 with: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b12b55b7..cdd5e7c6 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -12,7 +12,7 @@ repos: - id: check-useless-excludes - repo: https://github.com/ComPWA/policy - rev: 0.8.2rc12 + rev: 0.8.2rc13 hooks: - id: check-dev-files args: From a1e84e9445a5de50298d10483fff7c011d114b81 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 1 Feb 2026 18:50:39 +0100 Subject: [PATCH 12/16] MAINT: bump the actions group with 4 updates (#158) From 33002e3a3010e84bd2a348e3a0724bbf29522c1b Mon Sep 17 00:00:00 2001 From: Remco de Boer <29308176+redeboer@users.noreply.github.com> Date: Wed, 4 Feb 2026 17:23:32 +0100 Subject: [PATCH 13/16] MAINT: upgrade lock files --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index cdd5e7c6..fee9dab2 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -12,7 +12,7 @@ repos: - id: check-useless-excludes - repo: https://github.com/ComPWA/policy - rev: 0.8.2rc13 + rev: 0.8.2rc15 hooks: - id: check-dev-files args: @@ -26,7 +26,7 @@ repos: - --type-checker=ty - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.14.14 + rev: v0.15.0 hooks: - id: ruff-check args: [--fix] From 8f59cc8c0dfeda89c5c04d26344262521264abdd Mon Sep 17 00:00:00 2001 From: Remco de Boer <29308176+redeboer@users.noreply.github.com> Date: Thu, 5 Feb 2026 15:15:28 +0100 Subject: [PATCH 14/16] FEAT: automatically update Jupyter kernels --- .cspell.json | 1 + .github/workflows/pre-commit.yml | 21 +++++++++++-- pyproject.toml | 1 + update-jupyter-kernel/action.yml | 51 ++++++++++++++++++++++++++++++++ update-jupyter-kernel/main.py | 44 +++++++++++++++++++++++++++ 5 files changed, 116 insertions(+), 2 deletions(-) create mode 100644 update-jupyter-kernel/action.yml create mode 100644 update-jupyter-kernel/main.py diff --git a/.cspell.json b/.cspell.json index 07938e9e..d0406856 100644 --- a/.cspell.json +++ b/.cspell.json @@ -49,6 +49,7 @@ "elif", "ipynb", "mhutchie", + "nbformat", "noqa", "noreply", "numprocesses", diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index ec9417ff..7525e6a7 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -114,9 +114,24 @@ jobs: uses: actions/upload-artifact@v6 with: if-no-files-found: error - name: pre-commit-changes + name: style-changes-pre-commit path: ${{ steps.diff.outputs.diff }} + jupyter-kernels: + if: >- + github.event_name == 'pull_request' && + github.event.pull_request.head.repo.full_name == github.repository + name: Update Jupyter kernels + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v6 + with: + fetch-depth: 0 + - if: hashFiles('**/*.ipynb') + uses: ComPWA/actions/update-jupyter-kernel@v4 + with: + target-branch: origin/${{ github.event.pull_request.base.ref }} + push: if: >- always() && @@ -125,6 +140,7 @@ jobs: contains(join(needs.*.result, ','), 'failure') name: Push changes needs: + - jupyter-kernels - pre-commit runs-on: ubuntu-slim steps: @@ -136,10 +152,11 @@ jobs: with: merge-multiple: true path: . - pattern: pre-commit-changes* + pattern: style-changes-* - if: always() name: Push changes run: | + rm -f .artifacts/keep-root-dir git diff --color if [[ $(git status -s) ]]; then git remote set-url origin https://x-access-token:${{ secrets.token }}@github.com/${{ github.repository }} diff --git a/pyproject.toml b/pyproject.toml index 0d0f0c5a..f08c71ab 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -21,6 +21,7 @@ dev = [ ] style = [ "PyYAML", + "nbformat", "packaging", "rtoml", "ty", diff --git a/update-jupyter-kernel/action.yml b/update-jupyter-kernel/action.yml new file mode 100644 index 00000000..d4d52467 --- /dev/null +++ b/update-jupyter-kernel/action.yml @@ -0,0 +1,51 @@ +name: Update Jupyter kernels +description: Update the Python version in Jupyter notebooks that have been modified in a PR. + +inputs: + artifact-name: + description: The name of the artifact to upload + default: style-changes-jupyter + required: false + target-branch: + description: "The target branch to compare against (default: main)" + default: ${{ github.event.pull_request.base.ref || 'main' }} + required: false + +runs: + using: composite + steps: + - uses: astral-sh/setup-uv@v7 + with: + cache-dependency-glob: | + **/.python-version + **/pyproject.toml + cache-suffix: update-jupyter-kernel + - env: + UV_NO_PROGRESS: 1 + name: Update Jupyter kernels + run: | + for notebook in $(git diff --name-only --diff-filter=AMR ${{ inputs.target-branch }} ${{ github.sha }} | grep -E '\.ipynb$'); do + uv run --directory=$(dirname "$notebook") $GITHUB_ACTION_PATH/main.py "$(basename $notebook)" + done + shell: bash + - run: git diff --color=always + shell: bash + - id: updated + run: | + if [[ $(git diff --name-only) ]]; then + delimiter="$(openssl rand -hex 8)" + echo "notebooks<<${delimiter}" >> $GITHUB_OUTPUT + echo "$(git diff --name-only)" | tee -a $GITHUB_OUTPUT + echo "${delimiter}" >> $GITHUB_OUTPUT + mkdir -p .artifacts + touch .artifacts/keep-root-dir + exit 1 + fi + shell: bash + - if: failure() + uses: actions/upload-artifact@v6 + with: + name: ${{ inputs.artifact-name }} + path: | + .artifacts/keep-root-dir + ${{ steps.updated.outputs.notebooks }} diff --git a/update-jupyter-kernel/main.py b/update-jupyter-kernel/main.py new file mode 100644 index 00000000..7180e10b --- /dev/null +++ b/update-jupyter-kernel/main.py @@ -0,0 +1,44 @@ +"""Update Python version in Jupyter kernel.""" +# /// script +# dependencies = [ +# "nbformat", +# ] +# requires-python = ">=3.13" +# /// + +import sys +from argparse import ArgumentParser +from collections.abc import Sequence +from pathlib import Path + +import nbformat + + +def main(argv: Sequence[str] | None = None) -> None: + parser = ArgumentParser(__doc__) + parser.add_argument("notebook_path", type=Path) + args = parser.parse_args(argv) + notebook = nbformat.read(args.notebook_path, as_version=nbformat.NO_CONVERT) + metadata = notebook.get("metadata") + if not metadata: + return + kernelspec = metadata.get("kernelspec") + if not kernelspec: + return + if kernelspec.get("language") != "python": + return + language_info = metadata.get("language_info") + if not language_info: + return + version = language_info.get("version") + if not version: + return + v = sys.version_info + expected_version = f"{v.major}.{v.minor}.{v.micro}" + if version != expected_version: + language_info["version"] = expected_version + nbformat.write(notebook, args.notebook_path) + + +if __name__ == "__main__": + raise SystemExit(main()) From 16b95c61bca4b68cba849ef75c6b486c73de46a0 Mon Sep 17 00:00:00 2001 From: Remco de Boer <29308176+redeboer@users.noreply.github.com> Date: Thu, 5 Feb 2026 20:54:59 +0100 Subject: [PATCH 15/16] BREAK: rename `pre-commit` workflow to `style` --- .github/workflows/ci.yml | 2 +- .github/workflows/{pre-commit.yml => style.yml} | 2 +- .pre-commit-config.yaml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) rename .github/workflows/{pre-commit.yml => style.yml} (98%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b0b75404..1e0cdb1b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,4 +22,4 @@ jobs: style: secrets: token: ${{ secrets.PAT }} - uses: ComPWA/actions/.github/workflows/pre-commit.yml@v4.0 + uses: ComPWA/actions/.github/workflows/style.yml@v4.0 diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/style.yml similarity index 98% rename from .github/workflows/pre-commit.yml rename to .github/workflows/style.yml index 7525e6a7..f80076f3 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/style.yml @@ -164,7 +164,7 @@ jobs: git config user.email "noreply@github.com" git checkout -b ${{ github.head_ref }} git add -A - git commit -m "MAINT: implement updates from pre-commit hooks" + git commit -m "MAINT: implement updates from formatters" git config pull.rebase true git pull origin ${{ github.head_ref }} git push origin HEAD:${{ github.head_ref }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index fee9dab2..1bcc41e6 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -12,7 +12,7 @@ repos: - id: check-useless-excludes - repo: https://github.com/ComPWA/policy - rev: 0.8.2rc15 + rev: 0.8.2rc16 hooks: - id: check-dev-files args: From 31a48ea22f70faee0149e96f68d408cd83d18e24 Mon Sep 17 00:00:00 2001 From: Remco de Boer <29308176+redeboer@users.noreply.github.com> Date: Thu, 5 Feb 2026 21:11:06 +0100 Subject: [PATCH 16/16] ENH: speed up `get-skipped-pre-commit-hooks` --- get-skipped-pre-commit-hooks/action.yml | 18 +++++++----------- update-jupyter-kernel/action.yml | 1 + 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/get-skipped-pre-commit-hooks/action.yml b/get-skipped-pre-commit-hooks/action.yml index 94567561..7881c5a4 100644 --- a/get-skipped-pre-commit-hooks/action.yml +++ b/get-skipped-pre-commit-hooks/action.yml @@ -14,19 +14,15 @@ outputs: runs: using: composite steps: - - uses: actions/checkout@v6 - with: - sparse-checkout: .pre-commit-config.yaml - - uses: actions/setup-python@v6 - with: - python-version: "3.13" - uses: astral-sh/setup-uv@v7 with: + cache-python: true enable-cache: false - - env: - UV_SYSTEM_PYTHON: 1 - id: set-hooks + ignore-empty-workdir: true + - uses: actions/checkout@v6 + with: + sparse-checkout: .pre-commit-config.yaml + - id: set-hooks name: Determine skipped hooks - run: | - echo "hooks=$(uv run -p3.13 $GITHUB_ACTION_PATH/main.py)" | tee -a $GITHUB_OUTPUT + run: echo "hooks=$(uv run --no-project --python=3.13 $GITHUB_ACTION_PATH/main.py)" | tee -a $GITHUB_OUTPUT shell: bash diff --git a/update-jupyter-kernel/action.yml b/update-jupyter-kernel/action.yml index d4d52467..de0c0bb4 100644 --- a/update-jupyter-kernel/action.yml +++ b/update-jupyter-kernel/action.yml @@ -19,6 +19,7 @@ runs: cache-dependency-glob: | **/.python-version **/pyproject.toml + cache-python: true cache-suffix: update-jupyter-kernel - env: UV_NO_PROGRESS: 1