Merge pull request #213 from opensanctions/dependabot/cargo/rust/serd… #1106
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: build | |
| on: | |
| push: | |
| pull_request: | |
| permissions: | |
| id-token: write | |
| contents: read | |
| attestations: write | |
| artifact-metadata: write | |
| env: | |
| CARGO_TERM_COLOR: always | |
| jobs: | |
| lint-test: | |
| name: lint + test | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Install libicu (needed for pyicu at import time) | |
| run: sudo apt-get install -y -qq libicu-dev | |
| - uses: actions/setup-python@v6 | |
| with: | |
| python-version: "3.14" | |
| cache: pip | |
| - uses: dtolnay/rust-toolchain@stable | |
| with: | |
| components: rustfmt, clippy | |
| - uses: Swatinem/rust-cache@v2 | |
| with: | |
| workspaces: rust | |
| - name: cargo fmt --check | |
| working-directory: rust | |
| run: cargo fmt --check | |
| - name: cargo clippy | |
| working-directory: rust | |
| run: cargo clippy --all-targets -- -D warnings | |
| - name: cargo test (pure-Rust, no python feature) | |
| working-directory: rust | |
| run: cargo test | |
| - name: Install package (builds Rust extension via maturin) | |
| run: pip install -e ".[dev]" | |
| - name: Check generated data is up to date | |
| run: | | |
| make build | |
| git diff --exit-code -- rust/data rust/src/generated | |
| - name: pytest | |
| run: make test | |
| - name: mypy --strict | |
| run: make typecheck | |
| linux: | |
| name: wheels / manylinux ${{ matrix.target }} | |
| runs-on: ubuntu-latest | |
| needs: lint-test | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| target: [x86_64, aarch64] | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: PyO3/maturin-action@v1 | |
| env: | |
| CARGO: /usr/local/bin/cargo-auditable-wrapper | |
| with: | |
| target: ${{ matrix.target }} | |
| manylinux: auto | |
| sccache: "true" | |
| before-script-linux: | | |
| RUSTC_WRAPPER= cargo install cargo-auditable --locked | |
| REAL_CARGO=$(command -v cargo) | |
| cat > /usr/local/bin/cargo-auditable-wrapper <<EOF | |
| #!/bin/sh | |
| exec "$REAL_CARGO" auditable "\$@" | |
| EOF | |
| chmod +x /usr/local/bin/cargo-auditable-wrapper | |
| args: --release --out dist -i 3.10 3.11 3.12 3.13 3.14 --manifest-path rust/Cargo.toml | |
| - uses: actions/upload-artifact@v7 | |
| with: | |
| name: wheels-manylinux-${{ matrix.target }} | |
| path: dist | |
| - uses: actions/attest-build-provenance@v4 | |
| with: | |
| subject-path: 'dist/*.whl' | |
| musllinux: | |
| name: wheels / musllinux ${{ matrix.target }} | |
| runs-on: ubuntu-latest | |
| needs: lint-test | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| target: [x86_64, aarch64] | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: PyO3/maturin-action@v1 | |
| env: | |
| CARGO: /usr/local/bin/cargo-auditable-wrapper | |
| with: | |
| target: ${{ matrix.target }} | |
| manylinux: musllinux_1_2 | |
| sccache: "true" | |
| before-script-linux: | | |
| RUSTC_WRAPPER= cargo install cargo-auditable --locked | |
| REAL_CARGO=$(command -v cargo) | |
| cat > /usr/local/bin/cargo-auditable-wrapper <<EOF | |
| #!/bin/sh | |
| exec "$REAL_CARGO" auditable "\$@" | |
| EOF | |
| chmod +x /usr/local/bin/cargo-auditable-wrapper | |
| args: --release --out dist -i 3.10 3.11 3.12 3.13 3.14 --manifest-path rust/Cargo.toml | |
| - uses: actions/upload-artifact@v7 | |
| with: | |
| name: wheels-musllinux-${{ matrix.target }} | |
| path: dist | |
| - uses: actions/attest-build-provenance@v4 | |
| with: | |
| subject-path: 'dist/*.whl' | |
| macos: | |
| name: wheels / macos ${{ matrix.target }} | |
| runs-on: macos-latest | |
| needs: lint-test | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| target: [x86_64, aarch64] | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: actions/setup-python@v6 | |
| with: | |
| python-version: "3.13" | |
| - uses: taiki-e/install-action@v2 | |
| with: | |
| tool: cargo-auditable | |
| - name: Create cargo-auditable wrapper for maturin | |
| run: | | |
| REAL_CARGO=$(command -v cargo) | |
| cat > "${RUNNER_TEMP}/cargo-auditable-wrapper" <<EOF | |
| #!/bin/sh | |
| exec "$REAL_CARGO" auditable "\$@" | |
| EOF | |
| chmod +x "${RUNNER_TEMP}/cargo-auditable-wrapper" | |
| - uses: PyO3/maturin-action@v1 | |
| env: | |
| CARGO: ${{ runner.temp }}/cargo-auditable-wrapper | |
| with: | |
| target: ${{ matrix.target }} | |
| sccache: "true" | |
| args: --release --out dist -i 3.10 3.11 3.12 3.13 3.14 --manifest-path rust/Cargo.toml | |
| - uses: actions/upload-artifact@v7 | |
| with: | |
| name: wheels-macos-${{ matrix.target }} | |
| path: dist | |
| - uses: actions/attest-build-provenance@v4 | |
| with: | |
| subject-path: 'dist/*.whl' | |
| windows: | |
| name: wheels / windows ${{ matrix.target }} | |
| runs-on: windows-latest | |
| needs: lint-test | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| target: [x64] | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: actions/setup-python@v6 | |
| with: | |
| python-version: "3.13" | |
| architecture: ${{ matrix.target }} | |
| - uses: PyO3/maturin-action@v1 | |
| with: | |
| target: ${{ matrix.target }} | |
| sccache: "true" | |
| args: --release --out dist -i 3.10 3.11 3.12 3.13 3.14 --manifest-path rust/Cargo.toml | |
| - uses: actions/upload-artifact@v7 | |
| with: | |
| name: wheels-windows-${{ matrix.target }} | |
| path: dist | |
| - uses: actions/attest-build-provenance@v4 | |
| with: | |
| subject-path: 'dist/*.whl' | |
| sdist: | |
| name: sdist | |
| runs-on: ubuntu-latest | |
| needs: lint-test | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: PyO3/maturin-action@v1 | |
| with: | |
| command: sdist | |
| args: --out dist --manifest-path rust/Cargo.toml | |
| - uses: actions/upload-artifact@v7 | |
| with: | |
| name: wheels-sdist | |
| path: dist | |
| - uses: actions/attest-build-provenance@v4 | |
| with: | |
| subject-path: 'dist/*.tar.gz' | |
| release: | |
| name: Publish to PyPI | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') | |
| needs: [linux, musllinux, macos, windows, sdist] | |
| steps: | |
| - uses: actions/download-artifact@v8 | |
| with: | |
| pattern: wheels-* | |
| path: dist | |
| merge-multiple: true | |
| - uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| skip-existing: true |