Skip to content

Commit ab9eacf

Browse files
authored
Merge branch 'mainline' into feature/enable-claude-pr-review
2 parents 23312bb + 07a325b commit ab9eacf

196 files changed

Lines changed: 49048 additions & 262 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/scripts/get_latest_changelog.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
3030
```
3131
"""
32+
3233
import re
3334

3435
h2 = r"^##\s.*$"

‎.github/workflows/codeql.yml‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,34 @@ jobs:
1414
uses: OpenJobDescription/.github/.github/workflows/reusable_codeql.yml@mainline
1515
permissions:
1616
security-events: write
17+
18+
# The org-level reusable workflow above analyses the Python sources in
19+
# `src/` and `test/`. The Rust bindings under `rust-bindings/` are a
20+
# separate language target that the reusable workflow doesn't cover, so
21+
# we run a dedicated Rust analysis here. Pattern matches openjd-rs's
22+
# codeql.yml.
23+
Analyze-rust:
24+
name: Analyze (rust)
25+
runs-on: ubuntu-latest
26+
permissions:
27+
# Required for github/codeql-action/init + codeql-action/analyze.
28+
contents: read
29+
security-events: write
30+
steps:
31+
- name: Checkout repository
32+
uses: actions/checkout@v6
33+
34+
- name: Initialize CodeQL
35+
uses: github/codeql-action/init@v4
36+
with:
37+
languages: rust
38+
# Rust's CodeQL extractor does not support `autobuild` (it
39+
# errors out with "Rust does not support the autobuild build
40+
# mode"). The extractor reads source files directly via the
41+
# rust-analyzer-style frontend; no cargo invocation is needed
42+
# for the database build.
43+
build-mode: none
44+
queries: +security-and-quality
45+
46+
- name: Perform CodeQL Analysis
47+
uses: github/codeql-action/analyze@v4

‎.github/workflows/release_publish.yml‎

Lines changed: 17 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -35,57 +35,36 @@ jobs:
3535
tag: ${{ needs.TagRelease.outputs.tag }}
3636

3737
PreRelease:
38-
needs: [TagRelease, UnitTests]
39-
uses: OpenJobDescription/.github/.github/workflows/reusable_prerelease.yml@mainline
40-
permissions:
41-
id-token: write
42-
contents: write
43-
secrets: inherit
44-
with:
45-
tag: ${{ needs.TagRelease.outputs.tag }}
38+
needs: [TagRelease, UnitTests]
39+
uses: OpenJobDescription/.github/.github/workflows/reusable_maturin_prerelease.yml@mainline
40+
secrets: inherit
41+
with:
42+
tag: ${{ needs.TagRelease.outputs.tag }}
4643

4744
Release:
48-
needs: [TagRelease, PreRelease]
49-
uses: OpenJobDescription/.github/.github/workflows/reusable_release.yml@mainline
50-
secrets: inherit
51-
permissions:
52-
id-token: write
53-
contents: write
54-
with:
55-
tag: ${{ needs.TagRelease.outputs.tag }}
56-
57-
Publish:
58-
needs: [TagRelease, Release]
59-
uses: OpenJobDescription/.github/.github/workflows/reusable_publish_python.yml@mainline
45+
needs: [TagRelease, PreRelease]
46+
uses: OpenJobDescription/.github/.github/workflows/reusable_release.yml@mainline
47+
secrets: inherit
6048
permissions:
6149
id-token: write
62-
secrets: inherit
50+
contents: write
6351
with:
64-
tag: ${{ needs.TagRelease.outputs.tag }}
52+
tag: ${{ needs.TagRelease.outputs.tag }}
6553

6654
# PyPI does not support reusable workflows yet
67-
# # See https://github.com/pypi/warehouse/issues/11096
55+
# See https://github.com/pypi/warehouse/issues/11096
6856
PublishToPyPI:
69-
needs: [TagRelease, Publish]
57+
needs: [TagRelease, Release, PreRelease]
7058
runs-on: ubuntu-latest
7159
environment: release
7260
permissions:
7361
id-token: write
7462
steps:
75-
- name: Checkout
76-
uses: actions/checkout@v6
63+
- uses: actions/download-artifact@v4
7764
with:
78-
ref: ${{ needs.TagRelease.outputs.tag }}
79-
fetch-depth: 0
80-
- name: Set up Python
81-
uses: actions/setup-python@v6
82-
with:
83-
python-version: '3.9'
84-
- name: Install dependencies
85-
run: |
86-
pip install --upgrade hatch "virtualenv<21"
87-
- name: Build
88-
run: hatch -v build
89-
# # See https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/configuring-openid-connect-in-pypi
65+
name: build-artifact
66+
path: dist
9067
- name: Publish to PyPI
9168
uses: pypa/gh-action-pypi-publish@release/v1
69+
with:
70+
packages-dir: dist

‎.github/workflows/rust_quality.yml‎

Lines changed: 207 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,207 @@
1+
name: Rust Quality
2+
3+
# Build, lint, and test the Rust bindings crate at rust-bindings/.
4+
#
5+
# The existing Python-side code_quality workflow covers Python tests and
6+
# transitively builds the Rust extension via `maturin develop`, but does
7+
# not run `cargo test` (which covers doctests and any pure-Rust unit
8+
# tests added to the bindings crate).
9+
#
10+
# The bindings' `openjd-*` dependencies come from crates.io at the
11+
# versions pinned in `rust-bindings/Cargo.toml`. There is no sibling
12+
# repository requirement — local-development overrides are documented
13+
# in a commented-out `[patch.crates-io]` block at the bottom of that
14+
# file.
15+
16+
on:
17+
pull_request:
18+
branches: [ mainline, release, 'patch_*' ]
19+
workflow_call:
20+
inputs:
21+
branch:
22+
required: false
23+
type: string
24+
tag:
25+
required: false
26+
type: string
27+
28+
# Cancel in-progress runs on PR pushes to save CI minutes and avoid
29+
# cache-save races (two concurrent runs trying to save to the same key).
30+
# Matches the pattern used in openjd-rs.
31+
concurrency:
32+
group: rust-quality-${{ github.workflow }}-${{ github.ref }}
33+
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
34+
35+
env:
36+
CARGO_INCREMENTAL: 0
37+
CARGO_NET_RETRY: 10
38+
RUSTUP_MAX_RETRIES: 10
39+
RUST_BACKTRACE: 1
40+
41+
jobs:
42+
rust_quality:
43+
name: Rust (${{ matrix.os }})
44+
strategy:
45+
fail-fast: false
46+
matrix:
47+
os: [ubuntu-latest, windows-latest, macos-latest]
48+
runs-on: ${{ matrix.os }}
49+
permissions:
50+
contents: read
51+
52+
steps:
53+
- name: Checkout openjd-model-for-python
54+
uses: actions/checkout@v4
55+
with:
56+
ref: ${{ inputs.branch || inputs.tag || github.ref }}
57+
58+
- name: Install Rust toolchain
59+
uses: dtolnay/rust-toolchain@stable
60+
with:
61+
components: clippy, rustfmt
62+
63+
# Include the rustc version in the cache key so that a toolchain
64+
# upgrade automatically invalidates the target/ cache (stale rustc
65+
# artifacts are one of the main reasons cache restore-key hits
66+
# produce slow rebuilds).
67+
- name: Compute rustc hash
68+
id: rustc
69+
shell: bash
70+
run: echo "hash=$(rustc --version --verbose | sha256sum | cut -c1-16)" >> "$GITHUB_OUTPUT"
71+
72+
- name: Cache Cargo registry and build artifacts
73+
id: cache
74+
uses: actions/cache@v4
75+
with:
76+
path: |
77+
~/.cargo/registry/index
78+
~/.cargo/registry/cache
79+
~/.cargo/git/db
80+
target
81+
key: cargo-${{ matrix.os }}-${{ steps.rustc.outputs.hash }}-${{ hashFiles('Cargo.lock', 'rust-bindings/Cargo.toml') }}
82+
restore-keys: |
83+
cargo-${{ matrix.os }}-${{ steps.rustc.outputs.hash }}-
84+
cargo-${{ matrix.os }}-
85+
86+
# On a restore-key (non-exact) hit, target/ contains artifacts built
87+
# against a different Cargo.lock. Cargo will spend a long time
88+
# scanning fingerprints and discovering staleness, especially on
89+
# Windows. Starting from an empty target/ with a warm registry cache
90+
# is faster.
91+
- name: Discard stale target/ on restore-key-only hit
92+
if: steps.cache.outputs.cache-hit != 'true'
93+
shell: bash
94+
run: rm -rf target
95+
96+
- name: cargo fmt --check
97+
run: cargo fmt --manifest-path rust-bindings/Cargo.toml --check
98+
99+
- name: cargo build
100+
run: cargo build --manifest-path rust-bindings/Cargo.toml --all-targets
101+
102+
- name: cargo clippy
103+
run: cargo clippy --manifest-path rust-bindings/Cargo.toml --all-targets -- -D warnings
104+
105+
- name: cargo test
106+
run: cargo test --manifest-path rust-bindings/Cargo.toml
107+
108+
- name: cargo test --doc
109+
# Runs separately from `cargo test` above so a docstring regression
110+
# (e.g. a Python example rustdoc tries to compile as Rust) is
111+
# clearly visible in the CI log.
112+
run: cargo test --manifest-path rust-bindings/Cargo.toml --doc
113+
114+
cargo_doc:
115+
name: cargo doc -D warnings
116+
runs-on: ubuntu-latest
117+
permissions:
118+
contents: read
119+
steps:
120+
- name: Checkout openjd-model-for-python
121+
uses: actions/checkout@v4
122+
with:
123+
ref: ${{ inputs.branch || inputs.tag || github.ref }}
124+
125+
- name: Install Rust toolchain
126+
uses: dtolnay/rust-toolchain@stable
127+
128+
- name: Compute rustc hash
129+
id: rustc
130+
shell: bash
131+
run: echo "hash=$(rustc --version --verbose | sha256sum | cut -c1-16)" >> "$GITHUB_OUTPUT"
132+
133+
# Restore-only: rust_quality(ubuntu) owns the cache write. Saving
134+
# from here too would race with that job.
135+
- name: Restore Cargo cache (read-only)
136+
uses: actions/cache/restore@v4
137+
with:
138+
path: |
139+
~/.cargo/registry/index
140+
~/.cargo/registry/cache
141+
~/.cargo/git/db
142+
target
143+
key: cargo-ubuntu-latest-${{ steps.rustc.outputs.hash }}-${{ hashFiles('Cargo.lock', 'rust-bindings/Cargo.toml') }}
144+
restore-keys: |
145+
cargo-ubuntu-latest-${{ steps.rustc.outputs.hash }}-
146+
cargo-ubuntu-latest-
147+
148+
# Catches docstring breakages (broken intra-doc links, stale code
149+
# blocks, etc.) in pyclass `///` docs.
150+
- name: cargo doc
151+
run: cargo doc --manifest-path rust-bindings/Cargo.toml --no-deps
152+
env:
153+
RUSTDOCFLAGS: -D warnings
154+
155+
cargo_deny:
156+
name: cargo-deny (licenses, advisories, bans, sources)
157+
runs-on: ubuntu-latest
158+
permissions:
159+
contents: read
160+
steps:
161+
- name: Checkout openjd-model-for-python
162+
uses: actions/checkout@v4
163+
with:
164+
ref: ${{ inputs.branch || inputs.tag || github.ref }}
165+
166+
- name: Install Rust toolchain
167+
uses: dtolnay/rust-toolchain@stable
168+
169+
- name: Install cargo-deny
170+
run: cargo install cargo-deny --locked
171+
172+
# Licenses, bans, and sources apply to every crate we compile,
173+
# including dev-dependencies, so scan the full graph. Advisories
174+
# are scoped to the normal dep graph (what actually ships in the
175+
# extension module).
176+
- name: cargo deny check licenses, bans, sources
177+
run: cargo deny --manifest-path rust-bindings/Cargo.toml check --config deny.toml licenses bans sources
178+
179+
- name: cargo deny check advisories
180+
run: cargo deny --manifest-path rust-bindings/Cargo.toml check --config deny.toml advisories --exclude-dev
181+
182+
third_party_licenses:
183+
name: THIRD-PARTY-LICENSES check
184+
runs-on: ubuntu-latest
185+
permissions:
186+
contents: read
187+
steps:
188+
- name: Checkout openjd-model-for-python
189+
uses: actions/checkout@v4
190+
with:
191+
ref: ${{ inputs.branch || inputs.tag || github.ref }}
192+
193+
- name: Install Rust toolchain
194+
uses: dtolnay/rust-toolchain@stable
195+
196+
# cargo-about renders `about.hbs` using the workspace's Cargo.lock
197+
# and `about.toml`. The committed `THIRD-PARTY-LICENSES` is shipped
198+
# with every release, so it must stay in sync with the dependency
199+
# graph. The `cli` feature is required to actually build the
200+
# cargo-about binary; without it `cargo install` compiles the crate
201+
# but emits "none of the package's binaries are available" and
202+
# installs nothing.
203+
- name: Install cargo-about
204+
run: cargo install cargo-about --locked --features cli
205+
206+
- name: Check THIRD-PARTY-LICENSES is up to date
207+
run: bash scripts/check_third_party_licenses.sh

‎.gitignore‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
*~
22
*#
33
*.swp
4+
*.pdb
45

56
*.DS_Store
67

@@ -22,3 +23,19 @@ __pycache__/
2223
/build
2324
/dist
2425
_version.py
26+
27+
# scripts/maturin_build.py backup file
28+
/pyproject.toml.vcs-bak
29+
30+
# Rust build artifacts
31+
/target/
32+
/rust-bindings/target/
33+
# Cargo.lock is committed so the `_openjd_rs.abi3.so` Python extension
34+
# gives reproducible wheel builds and keeps the `THIRD-PARTY-LICENSES.txt`
35+
# check stable across CI runs.
36+
37+
# Compiled extension modules
38+
*.so
39+
*.pyd
40+
*.dylib
41+
.hypothesis/

0 commit comments

Comments
 (0)