-
Notifications
You must be signed in to change notification settings - Fork 0
101 lines (93 loc) · 2.77 KB
/
CI.yml
File metadata and controls
101 lines (93 loc) · 2.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
env:
CARGO_TERM_COLOR: always
RUSTFLAGS: "-D warnings"
jobs:
python-lint:
name: Python lint + typecheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: "3.12"
cache: pip
- name: Install lint tooling
run: python -m pip install ruff mypy
- name: Ruff check
run: ruff check .
- name: Ruff format check
run: ruff format --check .
- name: Mypy
run: mypy python
rust-lint:
name: Rust fmt + clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- uses: Swatinem/rust-cache@v2
- name: cargo fmt
run: cargo fmt --check
- name: cargo clippy
run: cargo clippy --all-targets -- -D warnings
test:
name: Test ${{ matrix.os }} / Python ${{ matrix.python }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python: ["3.9", "3.11", "3.13"]
steps:
- uses: actions/checkout@v6
with:
submodules: recursive
- uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python }}
cache: pip
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Create venv
run: python -m venv .venv
- name: Export venv to PATH and VIRTUAL_ENV
shell: python
run: |
import os, sys
venv = os.path.abspath(".venv")
bin_dir = os.path.join(venv, "Scripts" if sys.platform == "win32" else "bin")
with open(os.environ["GITHUB_PATH"], "a") as f:
f.write(bin_dir + "\n")
with open(os.environ["GITHUB_ENV"], "a") as f:
f.write(f"VIRTUAL_ENV={venv}\n")
- name: Install test tooling
run: python -m pip install --upgrade pip maturin pytest pytest-cov
- name: Build extension (release)
run: maturin develop --release
- name: Pytest
run: pytest -v
# Guarantees the three OS × Python matrix all pass before merging; useful
# as a required check in branch protection without listing every cell.
test-summary:
name: Test summary
runs-on: ubuntu-latest
needs: [test]
if: always()
steps:
- name: Fail if any matrix job failed
if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')
run: exit 1