-
Notifications
You must be signed in to change notification settings - Fork 2
251 lines (225 loc) · 8.2 KB
/
ci.yaml
File metadata and controls
251 lines (225 loc) · 8.2 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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
name: Continuous Integration
on:
pull_request:
paths:
- "crates/**"
- "bindings/python/**"
- "Cargo.toml"
- "Cargo.lock"
- "justfile"
- ".github/workflows/ci.yaml"
- ".github/actions/**"
push:
branches:
- main
paths:
- "crates/**"
- "bindings/python/**"
- "Cargo.toml"
- "Cargo.lock"
- "justfile"
- ".github/workflows/ci.yaml"
- ".github/actions/**"
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}
cancel-in-progress: true
permissions:
contents: read
env:
UV_VERSION: "0.9.4"
JUST_VERSION: "1.43.0"
PYTHON_LATEST: "3.12"
RUST_TOOLCHAIN_VERSION: "1.85"
jobs:
version-consistency:
name: Version consistency
runs-on: ubuntu-latest
timeout-minutes: 2
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
persist-credentials: false
- name: Validate Cargo.toml and pyproject.toml versions match
run: |
set -euo pipefail
cargo_version="$(awk -F '"' '
/^\[workspace\.package\]$/ { in_ws = 1; next }
/^\[/ && in_ws { in_ws = 0 }
in_ws && /^version = / { print $2; exit }
' Cargo.toml)"
pyproject_version="$(awk -F '"' '
/^\[project\]$/ { in_proj = 1; next }
/^\[/ && in_proj { in_proj = 0 }
in_proj && /^version = / { print $2; exit }
' bindings/python/pyproject.toml)"
[[ -n "$cargo_version" ]] || { echo "::error::Could not read workspace version from Cargo.toml"; exit 1; }
[[ -n "$pyproject_version" ]] || { echo "::error::Could not read version from pyproject.toml"; exit 1; }
[[ "$cargo_version" == "$pyproject_version" ]] || { echo "::error::Version mismatch: Cargo.toml=$cargo_version pyproject.toml=$pyproject_version"; exit 1; }
echo "Versions match: $cargo_version"
rust-fmt:
name: Rust formatting
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
persist-credentials: false
- name: Set up Rust toolchain
run: |
rustup toolchain install "$RUST_TOOLCHAIN_VERSION" --profile minimal
rustup component add rustfmt --toolchain "$RUST_TOOLCHAIN_VERSION"
rustup default "$RUST_TOOLCHAIN_VERSION"
- name: Check Rust formatting
run: cargo +"$RUST_TOOLCHAIN_VERSION" fmt --all -- --check
rust-clippy:
name: Rust clippy (${{ matrix.target.name }})
needs: [rust-fmt, version-consistency]
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
target:
- name: core
command: just clippy-core
apt-deps: ""
fflags: ""
- name: arco-ipopt
command: just clippy-solver arco-ipopt
# Build IPOPT from source via ipopt-sys; the Ubuntu 24.04 system
# package (3.11.9) has a memory corruption bug with MUMPS >= 5.1.0.
apt-deps: liblapack-dev libopenblas-dev gfortran
# MUMPS 4.10.0 (bundled by ipopt-sys) has type mismatches that
# GCC 14 rejects by default (-fallow-argument-mismatch).
fflags: "-fallow-argument-mismatch"
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
persist-credentials: false
- name: Install system dependencies
if: matrix.target.apt-deps != ''
env:
MATRIX_APT_DEPS: ${{ matrix.target.apt-deps }}
run: |
set -euo pipefail
sudo apt-get update -qq
read -r -a apt_deps <<< "$MATRIX_APT_DEPS"
sudo apt-get install -y --no-install-recommends "${apt_deps[@]}"
- name: Set up build environment
uses: ./.github/actions/setup-build-env
with:
python-version: ${{ env.PYTHON_LATEST }}
uv-version: ${{ env.UV_VERSION }}
just-version: ${{ env.JUST_VERSION }}
rust-toolchain-version: ${{ env.RUST_TOOLCHAIN_VERSION }}
install-uv: "false"
sync-python-licenses: "false"
rust-cache-shared-key: rust-clippy
- name: Run clippy (${{ matrix.target.name }})
env:
MATRIX_TARGET_NAME: ${{ matrix.target.name }}
FFLAGS: ${{ matrix.target.fflags }}
FCFLAGS: ${{ matrix.target.fflags }}
run: |
set -euo pipefail
case "$MATRIX_TARGET_NAME" in
core) just clippy-core ;;
arco-ipopt) just clippy-solver arco-ipopt ;;
*)
echo "::error::Unknown clippy target: $MATRIX_TARGET_NAME"
exit 1
;;
esac
rust-test:
name: Rust tests (${{ matrix.target.name }})
needs: [rust-fmt, version-consistency]
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
target:
- name: core
command: just test-core
apt-deps: ""
fflags: ""
- name: arco-ipopt
command: just test-solver arco-ipopt
# Build IPOPT from source via ipopt-sys; the Ubuntu 24.04 system
# package (3.11.9) has a memory corruption bug with MUMPS >= 5.1.0.
apt-deps: liblapack-dev libopenblas-dev gfortran
# MUMPS 4.10.0 (bundled by ipopt-sys) has type mismatches that
# GCC 14 rejects by default (-fallow-argument-mismatch).
fflags: "-fallow-argument-mismatch"
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
persist-credentials: false
- name: Install system dependencies
if: matrix.target.apt-deps != ''
env:
MATRIX_APT_DEPS: ${{ matrix.target.apt-deps }}
run: |
set -euo pipefail
sudo apt-get update -qq
read -r -a apt_deps <<< "$MATRIX_APT_DEPS"
sudo apt-get install -y --no-install-recommends "${apt_deps[@]}"
- name: Set up build environment
uses: ./.github/actions/setup-build-env
with:
python-version: ${{ env.PYTHON_LATEST }}
uv-version: ${{ env.UV_VERSION }}
just-version: ${{ env.JUST_VERSION }}
rust-toolchain-version: ${{ env.RUST_TOOLCHAIN_VERSION }}
install-uv: "true"
sync-python-licenses: "false"
rust-cache-shared-key: rust-clippy
save-rust-cache: "false"
- name: Run tests (${{ matrix.target.name }})
env:
MATRIX_TARGET_NAME: ${{ matrix.target.name }}
FFLAGS: ${{ matrix.target.fflags }}
FCFLAGS: ${{ matrix.target.fflags }}
run: |
set -euo pipefail
case "$MATRIX_TARGET_NAME" in
core) just test-core ;;
arco-ipopt) just test-solver arco-ipopt ;;
*)
echo "::error::Unknown test target: $MATRIX_TARGET_NAME"
exit 1
;;
esac
python-validation:
name: Python validation (py${{ matrix.python-version }})
needs: [version-consistency]
runs-on: ubuntu-latest
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
persist-credentials: false
- name: Set up build environment
uses: ./.github/actions/setup-build-env
with:
python-version: ${{ matrix.python-version }}
uv-version: ${{ env.UV_VERSION }}
just-version: ${{ env.JUST_VERSION }}
rust-toolchain-version: ${{ env.RUST_TOOLCHAIN_VERSION }}
rust-cache-shared-key: rust-clippy
save-uv-cache: "false"
save-rust-cache: "false"
- name: Run Python quality checks
run: just py-check
- name: Verify pre-commit config
run: uvx --from pre-commit pre-commit validate-config
- name: Build wheel and validate import
run: just py-validate-wheel "dist/*.whl"
- name: Run docs doctests
if: matrix.python-version == '3.12'
run: just py-doctest-ci