Repository navigation
Rust ENDF-6 parser crate with Python bindings and a parity harness #14
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Rust | |
| on: | |
| workflow_dispatch: | |
| pull_request: | |
| branches: | |
| - main | |
| - local-develop | |
| push: | |
| branches: | |
| - main | |
| - local-develop | |
| jobs: | |
| crate: | |
| name: Crate | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: dtolnay/rust-toolchain@stable | |
| with: | |
| components: rustfmt, clippy | |
| - uses: Swatinem/rust-cache@v2 | |
| - name: Format | |
| run: cargo fmt --all --check | |
| - name: Clippy | |
| run: cargo clippy --all-targets -- -D warnings | |
| # Debug and release both, because the parity tests compare floating | |
| # point and the two profiles have caught different things. | |
| - name: Test | |
| run: | | |
| cargo test | |
| cargo test --release | |
| # The crate declares rust-version = "1.74" and consumers will believe it. | |
| # Nothing else here checks it: the other jobs run stable, which happily | |
| # accepts APIs stabilised years later. The library only — dev-dependencies | |
| # are free to need a newer compiler, since they reach nobody downstream. | |
| msrv: | |
| name: MSRV | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: dtolnay/rust-toolchain@1.74 | |
| - uses: Swatinem/rust-cache@v2 | |
| - name: Build on the declared minimum | |
| run: cargo build -p endf | |
| goldens: | |
| name: Goldens reproduce | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: actions/setup-python@v6 | |
| with: | |
| python-version: "3.12" | |
| - name: Install | |
| run: python -m pip install .[test] | |
| # The golden files are what holds the Rust reader to the Python one, so | |
| # a change that quietly rewrites them would defeat the whole harness. | |
| # | |
| # `--check` compares the dump text rather than the compressed bytes and | |
| # prints the offending lines. Comparing bytes would fail on any machine | |
| # whose liblzma is not the one that wrote the file, which says nothing | |
| # about the reader. | |
| - name: Check for drift | |
| run: | | |
| python tools/dump_golden.py --check | |
| python tools/dump_chain_golden.py --check | |
| bindings: | |
| name: Python bindings | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| python-version: ["3.10", "3.13"] | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: actions/setup-python@v6 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - uses: dtolnay/rust-toolchain@stable | |
| - uses: Swatinem/rust-cache@v2 | |
| - name: Install | |
| run: | | |
| python -m pip install -U pip | |
| python -m pip install .[test] maturin | |
| # An abi3 wheel, so one build serves every supported Python. | |
| - name: Build the extension module | |
| run: maturin build --release -m crates/endf-py/Cargo.toml -o dist | |
| - name: Install the extension module | |
| run: python -m pip install --no-index --find-links dist endf-py | |
| # The bindings' tests compare the extension against the pure-Python | |
| # reader on the same fixtures, so they only mean anything once it is | |
| # installed. Fail rather than skip if the import did not take. | |
| - name: Test | |
| run: | | |
| python -c "import _endf" | |
| python -m pytest -ra tests/test_rust_bindings.py tests/test_rust_stub.py | |
| # The stub is only worth shipping if a type checker can use it. This | |
| # fails on a stub that is present but wrong, which the name comparison | |
| # in test_rust_stub.py cannot see. | |
| - name: Type-check against the stub | |
| run: | | |
| python -m pip install mypy | |
| python -m mypy --strict crates/endf-py/typecheck.py |