|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + pull_request: |
| 8 | + |
| 9 | +env: |
| 10 | + RUSTFLAGS: -Dwarnings |
| 11 | + |
| 12 | +jobs: |
| 13 | + lint: |
| 14 | + name: Lint |
| 15 | + runs-on: ubuntu-latest |
| 16 | + steps: |
| 17 | + - uses: actions/checkout@v4 |
| 18 | + |
| 19 | + - run: rustup toolchain install stable --profile minimal --component rustfmt --component clippy --no-self-update |
| 20 | + - uses: Swatinem/rust-cache@v2 |
| 21 | + |
| 22 | + - uses: actions/setup-python@v5 |
| 23 | + |
| 24 | + - run: cargo fmt --all -- --check |
| 25 | + - run: cargo clippy --all-features --workspace --tests --examples -- -D clippy::all |
| 26 | + |
| 27 | + doctest: |
| 28 | + name: Documentation (and Tests) |
| 29 | + runs-on: ubuntu-latest |
| 30 | + env: |
| 31 | + RUSTDOCFLAGS: -Dwarnings |
| 32 | + steps: |
| 33 | + - uses: actions/checkout@v4 |
| 34 | + |
| 35 | + - run: rustup toolchain install stable --profile minimal --no-self-update |
| 36 | + - uses: Swatinem/rust-cache@v2 |
| 37 | + |
| 38 | + - uses: actions/setup-python@v5 |
| 39 | + |
| 40 | + - run: cargo test --workspace --all-features --doc |
| 41 | + - run: cargo doc --workspace --all-features --document-private-items --no-deps |
| 42 | + |
| 43 | + test: |
| 44 | + name: Test |
| 45 | + runs-on: ubuntu-latest |
| 46 | + steps: |
| 47 | + - uses: actions/checkout@v4 |
| 48 | + |
| 49 | + - run: rustup toolchain install stable --profile minimal --component llvm-tools-preview --no-self-update |
| 50 | + - uses: Swatinem/rust-cache@v2 |
| 51 | + - uses: taiki-e/install-action@cargo-llvm-cov |
| 52 | + - uses: taiki-e/install-action@nextest |
| 53 | + |
| 54 | + - uses: actions/setup-python@v5 |
| 55 | + - uses: astral-sh/setup-uv@v3 |
| 56 | + - run: uv sync --all-extras --dev |
| 57 | + |
| 58 | + - run: cargo llvm-cov nextest --lcov --output-path core.lcov --workspace --all-features --all-targets |
| 59 | + - run: mv target/nextest/default/core-test-results.xml . |
| 60 | + |
| 61 | + - name: Run Python tests |
| 62 | + run: | |
| 63 | + source .venv/bin/activate |
| 64 | +
|
| 65 | + # Clear prior profile data |
| 66 | + cargo llvm-cov clean --workspace |
| 67 | +
|
| 68 | + # Set env vars so maturin will build our Rust code with coverage instrumentation |
| 69 | + source <(cargo llvm-cov show-env --export-prefix) |
| 70 | + maturin develop --uv |
| 71 | +
|
| 72 | + # Run Python tests. Any Rust code exercised by these tests will emit coverage data |
| 73 | + pytest --cov --junitxml=python-test-results.xml |
| 74 | +
|
| 75 | + # Turn the Rust coverage data into an lcov file |
| 76 | + cargo llvm-cov --no-run --lcov --output-path bindings.lcov |
| 77 | +
|
| 78 | + - name: Upload coverage data to Codecov |
| 79 | + if: ${{ !cancelled() }} |
| 80 | + uses: codecov/codecov-action@v4 |
| 81 | + with: |
| 82 | + files: ./core.lcov,./bindings.lcov,./.coverage |
| 83 | + token: ${{ secrets.CODECOV_ORG_TOKEN }} |
| 84 | + url: ${{ secrets.CODECOV_URL }} |
| 85 | + disable_search: true |
| 86 | + verbose: true |
| 87 | + - name: Upload test results to Codecov |
| 88 | + if: ${{ !cancelled() }} |
| 89 | + uses: codecov/test-results-action@v1 |
| 90 | + with: |
| 91 | + files: ./core-test-results.xml,./python-test-results.xml |
| 92 | + token: ${{ secrets.CODECOV_ORG_TOKEN }} |
| 93 | + url: ${{ secrets.CODECOV_URL }} |
| 94 | + disable_search: true |
| 95 | + verbose: true |
| 96 | + |
| 97 | + - name: Upload coverage data to Codecov (Staging) |
| 98 | + if: ${{ !cancelled() }} |
| 99 | + uses: codecov/codecov-action@v4 |
| 100 | + with: |
| 101 | + files: ./core.lcov,./bindings.lcov,./.coverage |
| 102 | + token: ${{ secrets.CODECOV_ORG_TOKEN_STAGING }} |
| 103 | + url: ${{ secrets.CODECOV_STAGING_API_URL }} |
| 104 | + disable_search: true |
| 105 | + verbose: true |
| 106 | + - name: Upload test results to Codecov (Staging) |
| 107 | + if: ${{ !cancelled() }} |
| 108 | + uses: codecov/test-results-action@v1 |
| 109 | + with: |
| 110 | + files: ./core-test-results.xml,./python-test-results.xml |
| 111 | + token: ${{ secrets.CODECOV_ORG_TOKEN_STAGING }} |
| 112 | + url: ${{ secrets.CODECOV_STAGING_API_URL }} |
| 113 | + disable_search: true |
| 114 | + verbose: true |
0 commit comments