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
18 changes: 9 additions & 9 deletions .agents/skills/ptf-generate/references/generation-checklist.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ Run the relevant project gates after
`cargo run --manifest-path codegen/Cargo.toml -- generate`:

```sh
just codegen::format
just codegen::lint
just codegen::test
just rust::format
just rust::lint
just rust::test
just python::test
just python::lint
just python::format
mise run codegen:format
mise run codegen:lint
mise run codegen:test
mise run rust:format
mise run rust:lint
mise run rust:test
mise run python:format
mise run python:lint
mise run python:test
```

Run `cargo run --manifest-path codegen/Cargo.toml -- generate` a second time and
Expand Down
28 changes: 14 additions & 14 deletions .github/scripts/check-version.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
import re
import runpy
import sys
import tomllib
from pathlib import Path

import tomllib

expected = sys.argv[1].removeprefix("v")
expected = sys.argv[1].removeprefix('v')

with Path("targets/ptfkit-rs/Cargo.toml").open("rb") as file:
rust = tomllib.load(file)["package"]["version"]
with Path('targets/ptfkit-rs/Cargo.toml').open('rb') as file:
rust = tomllib.load(file)['package']['version']

python = runpy.run_path("targets/ptfkit-py/src/ptfkit/_version.py")["__version__"]
python = runpy.run_path('targets/ptfkit-py/src/ptfkit/_version.py')['__version__']

native_source = Path("targets/ptfkit-native/cmake/ptfkitVersion.cmake").read_text()
native_source = Path('targets/ptfkit-native/cmake/ptfkitVersion.cmake').read_text()
match = re.fullmatch(
r"# @generated by ptfkit-codegen; do not edit\.\n"
r'# @generated by ptfkit-codegen; do not edit\.\n'
r'set\(PTFKIT_VERSION "([^"]+)"\)\n?',
native_source,
)
if match is None:
raise SystemExit("failed to read native version")
message = 'failed to read native version'
raise SystemExit(message)
native = match.group(1)

versions = {"rust": rust, "python": python, "native": native}
mismatches = {
name: version for name, version in versions.items() if version != expected
}
versions = {'rust': rust, 'python': python, 'native': native}
mismatches = {name: version for name, version in versions.items() if version != expected}
if mismatches:
details = ", ".join(f"{name}={version}" for name, version in mismatches.items())
raise SystemExit(f"version mismatch for tag {expected}: {details}")
details = ', '.join(f'{name}={version}' for name, version in mismatches.items())
message = f'version mismatch for tag {expected}: {details}'
raise SystemExit(message)
4 changes: 4 additions & 0 deletions .github/scripts/ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
extend = "../../ruff.toml"

[lint]
ignore = ["INP001"]
75 changes: 40 additions & 35 deletions .github/workflows/pr.yaml → .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: PR Checks
name: CI

on:
push:
Expand All @@ -18,7 +18,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v7

- name: Install uv
- name: Set up uv
uses: astral-sh/setup-uv@v10.0.1
with:
enable-cache: true
Expand All @@ -34,16 +34,13 @@ jobs:
- name: Checkout
uses: actions/checkout@v7

- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
- name: Set up uv cache
uses: astral-sh/setup-uv@v10.0.1
with:
components: clippy, rustfmt
enable-cache: true

- name: Install clang-format
uses: awalsh128/cache-apt-pkgs-action@v1
with:
packages: clang-format
version: 1.0
- name: Set up development toolchains
uses: jdx/mise-action@v4

- name: Cache Rust dependencies and codegen artifacts
uses: Swatinem/rust-cache@v2
Expand All @@ -54,16 +51,6 @@ jobs:
- name: Set up Rust problem matchers
uses: r7kamura/rust-problem-matchers@v1

- name: Set up Python
uses: actions/setup-python@v7
with:
python-version-file: targets/ptfkit-py/pyproject.toml

- name: Install uv
uses: astral-sh/setup-uv@v10.0.1
with:
enable-cache: true

- name: Check ptfkit-py uv.lock
run: uv lock --project targets/ptfkit-py --check

Expand All @@ -88,21 +75,26 @@ jobs:
continue-on-error: true
run: cargo test --manifest-path codegen/Cargo.toml

- name: Check ptfkit-py lint
- name: Check Python target and GitHub script lint
id: ptfkit-py-lint
continue-on-error: true
run: uv run --directory targets/ptfkit-py --no-sync ruff check --output-format=github
run: ruff check targets/ptfkit-py .github/scripts --output-format=github

- name: Check ptfkit-py formatting
- name: Check Python target and GitHub script formatting
id: ptfkit-py-format
continue-on-error: true
run: uv run --directory targets/ptfkit-py --no-sync ruff format --check --output-format=github
run: ruff format targets/ptfkit-py .github/scripts --check --output-format=github

- name: Check ptfkit-py types
id: ptfkit-py-typescheck
continue-on-error: true
run: uv run --directory targets/ptfkit-py --no-sync ty check --output-format=github

- name: Check GitHub script types
id: github-script-typescheck
continue-on-error: true
run: ty check .github/scripts --output-format=github

- name: Check ptfkit-rs formatting
id: ptfkit-rs-format
continue-on-error: true
Expand Down Expand Up @@ -133,6 +125,7 @@ jobs:
steps.ptfkit-py-lint.outcome == 'failure' ||
steps.ptfkit-py-format.outcome == 'failure' ||
steps.ptfkit-py-typescheck.outcome == 'failure' ||
steps.github-script-typescheck.outcome == 'failure' ||
steps.ptfkit-rs-format.outcome == 'failure' ||
steps.c-family-format.outcome == 'failure' ||
steps.ptfkit-rs-lint.outcome == 'failure' ||
Expand All @@ -150,16 +143,16 @@ jobs:
- name: Checkout
uses: actions/checkout@v7

- name: Set up uv
uses: astral-sh/setup-uv@v10.0.1
with:
enable-cache: true

- uses: actions/setup-python@v7
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true

- name: Install uv
uses: astral-sh/setup-uv@v10.0.1
with:
enable-cache: true

- name: Run pytest
run: uv run --directory targets/ptfkit-py pytest --no-cov

Expand All @@ -174,10 +167,13 @@ jobs:
- name: Checkout
uses: actions/checkout@v7

- name: Set up development toolchains
uses: jdx/mise-action@v4

- name: Configure ptfkit-native
run: >
cmake -S targets/ptfkit-native -B targets/ptfkit-native/build
-DBUILD_TESTING=ON -DPTFKIT_BUILD_CPP_MODULES=ON
-GNinja -DBUILD_TESTING=ON -DPTFKIT_BUILD_CPP_MODULES=ON

- name: Build ptfkit-native
run: cmake --build targets/ptfkit-native/build
Expand All @@ -192,25 +188,34 @@ jobs:
- name: Checkout
uses: actions/checkout@v7

- name: Install uv
- name: Set up development toolchains
uses: jdx/mise-action@v4

- name: Set up uv cache
uses: astral-sh/setup-uv@v10.0.1
with:
enable-cache: true
cache-dependency-glob: |
docs/pyproject.toml
docs/uv.lock

- name: Check documentation lock
run: uv lock --project docs --check

- name: Sync documentation environment
run: uv sync --project docs --frozen

- name: Check documentation lint
run: ruff check docs --output-format=github

- name: Check documentation formatting
run: ruff format docs --check --output-format=github

- name: Check documentation types
run: uv run --directory docs --no-sync ty check --output-format=github

- name: Build documentation
run: uv --directory=docs run mkdocs build --strict --config-file mkdocs.yml

summary:
name: PR Checks Summary
name: CI Summary
runs-on: ubuntu-latest
if: always()
needs: [code-quality, docs, native, pytest]
Expand Down
58 changes: 42 additions & 16 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ repos:
language: system
entry: cargo
args: [run, --manifest-path, codegen/Cargo.toml, generate]
files: '^(codegen/|specs/|targets/ptfkit-(rs|py)/src/)'
files: '^(codegen/|specs/|targets/)'
pass_filenames: false
- id: rustfmt-codegen
name: rustfmt codegen
Expand All @@ -37,36 +37,62 @@ repos:
language: system
entry: clang-format
args: [--style=file, -i]
files: '\\.(c|h|cc|cpp|cppm|cxx|hpp)$'
- id: uv-lock
name: uv lock
files: '\.(c|h|cc|cpp|cppm|cxx|hpp)$'
- id: uv-lock-ptfkit-py
name: uv lock ptfkit-py
language: system
entry: uv
args: [--project, targets/ptfkit-py, lock, --check]
files: .*(uv\.lock|pyproject\.toml|uv\.toml)$
files: '^targets/ptfkit-py/(uv\.lock|pyproject\.toml|uv\.toml)$'
pass_filenames: false
- id: uv-sync
name: uv sync
- id: uv-sync-ptfkit-py
name: uv sync ptfkit-py
language: system
entry: uv
args: [--project, targets/ptfkit-py, sync, --frozen, --all-groups, --all-extras, --all-packages]
args: [--project, targets/ptfkit-py, sync, --frozen]
always_run: true
pass_filenames: false
- id: uv-lock-docs
name: uv lock docs
language: system
entry: uv
args: [--project, docs, lock, --check]
files: '^docs/(uv\.lock|pyproject\.toml|uv\.toml)$'
pass_filenames: false
- id: uv-sync-docs
name: uv sync docs
language: system
entry: uv
args: [--project, docs, sync, --frozen]
always_run: true
pass_filenames: false
- id: ruff-check
name: ruff check
language: system
entry: uv
args: [--project, targets/ptfkit-py, run, --no-sync, ruff, check, --fix]
entry: ruff
args: [check, --fix]
types: [file, python]
- id: ruff-format
name: ruff format
language: system
entry: uv
args: [--project, targets/ptfkit-py, run, --no-sync, ruff, format]
entry: ruff
args: [format]
types: [file, python]
- id: ty-check
name: ty check
- id: ty-check-python
name: ty check ptfkit-py
language: system
entry: uv
args: [--project, targets/ptfkit-py, run, --no-sync, ty, check]
entry: ty
args: [check, --project, targets/ptfkit-py]
files: '^targets/ptfkit-py/.*\.py$'
- id: ty-check-docs
name: ty check documentation
language: system
entry: uv
args: [--project, docs, run, --no-sync, ty, check]
files: '^docs/.*\.py$'
- id: ty-check-github
name: ty check GitHub scripts
language: system
entry: ty
args: [check]
files: '^\.github/scripts/.*\.py$'
43 changes: 0 additions & 43 deletions Justfile

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ptfkit

[![CI](https://img.shields.io/github/actions/workflow/status/AgroDT/ptfkit/pr.yaml?branch=main)](https://github.com/AgroDT/ptfkit/actions/workflows/pr.yaml)
[![CI](https://img.shields.io/github/actions/workflow/status/AgroDT/ptfkit/ci.yaml?branch=main)](https://github.com/AgroDT/ptfkit/actions/workflows/ci.yaml)
[![Documentation](https://img.shields.io/github/actions/workflow/status/AgroDT/ptfkit/deploy-docs.yaml?label=docs)](https://agrodt.github.io/ptfkit/)
[![PyPI version](https://img.shields.io/pypi/v/ptfkit)](https://pypi.org/project/ptfkit/)
[![crates.io version](https://img.shields.io/crates/v/ptfkit)](https://crates.io/crates/ptfkit)
Expand Down
Loading
Loading