-
Notifications
You must be signed in to change notification settings - Fork 0
129 lines (117 loc) · 3.91 KB
/
Copy pathCI.yml
File metadata and controls
129 lines (117 loc) · 3.91 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
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:
# README/CHANGELOG/CONTRIBUTING/SECURITY are generated by
# @ktav-lang/polydoc from the root-docs/ unit trees. This job fails when a
# committed artifact drifts from its source — which is what a hand-edit of
# the artifact looks like. The artifacts live partly at the repo root and
# partly under docs/<lang>/ (see the OUT_PATHS table in
# scripts/build-docs.mjs), but all of them are generated: fix the unit
# source and re-run the generator; never patch the artifact.
docs:
name: Docs (generated markdown)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v4
with:
node-version: '24'
cache: 'npm'
- name: Install Node dependencies
run: npm ci
- name: Generated docs are byte-identical to their source units
run: node scripts/build-docs.mjs --check
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
# ruff is pinned exactly (kept in sync with the "dev" extra in
# pyproject.toml) so this gate only moves when someone deliberately
# moves it — an unpinned install once went red on a Markdown-
# formatting change nobody in this repo made.
run: python -m pip install ruff==0.16.8 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