Skip to content

Commit d071369

Browse files
authored
Merge pull request #28 from Point72/tkp/speed
Speed up CI and update from template
2 parents 10c8b62 + 1b4f1af commit d071369

8 files changed

Lines changed: 104 additions & 32 deletions

File tree

.copier-answers.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# Changes here will be overwritten by Copier
2-
_commit: 84508d6
2+
_commit: be75208
33
_src_path: https://github.com/python-project-templates/base.git
44
add_docs: false
55
add_extension: rust
6+
add_pyodide: false
67
add_wiki: true
78
email: OpenSource@Point72.com
89
github: Point72

.github/dependabot.yaml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ updates:
44
directory: "/"
55
schedule:
66
interval: "monthly"
7+
groups:
8+
github-actions:
9+
patterns:
10+
- "*"
711
labels:
812
- "part: github_actions"
913
cooldown:
@@ -15,6 +19,10 @@ updates:
1519
interval: "monthly"
1620
cooldown:
1721
default-days: 7
22+
groups:
23+
python:
24+
patterns:
25+
- "*"
1826
labels:
1927
- "lang: python"
2028
- "part: dependencies"
@@ -25,7 +33,10 @@ updates:
2533
interval: "monthly"
2634
cooldown:
2735
default-days: 7
36+
groups:
37+
rust:
38+
patterns:
39+
- "*"
2840
labels:
2941
- "lang: rust"
3042
- "part: dependencies"
31-

.github/workflows/build.yaml

Lines changed: 70 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ permissions:
2323

2424
jobs:
2525
build:
26+
name: build (${{ matrix.name }})
2627
runs-on: ${{ matrix.os }}
2728
permissions:
2829
contents: read
@@ -31,7 +32,28 @@ jobs:
3132

3233
strategy:
3334
matrix:
34-
os: [ubuntu-latest, macos-latest, windows-latest]
35+
include:
36+
- name: ubuntu-latest
37+
dist_path: dist
38+
os: ubuntu-latest
39+
python: "3.11"
40+
target: native
41+
- name: ubuntu-24.04-arm
42+
dist_path: dist
43+
os: ubuntu-24.04-arm
44+
python: "3.11"
45+
target: native
46+
- name: macos-latest
47+
dist_path: dist
48+
os: macos-latest
49+
python: "3.11"
50+
target: native
51+
- name: windows-latest
52+
dist_path: dist
53+
os: windows-latest
54+
python: "3.11"
55+
target: native
56+
3557

3658
steps:
3759
- name: Checkout
@@ -42,7 +64,7 @@ jobs:
4264
- name: Setup Python
4365
uses: actions-ext/python/setup@ec67f82b3bd863948308a41ecb9e70547cbb19c7
4466
with:
45-
version: "3.11"
67+
version: ${{ matrix.python }}
4668

4769
- name: Setup Rust
4870
uses: actions-ext/rust/setup@0f0b7c9ab3cdb6e9a1f79e2147974d6762ddafea
@@ -57,54 +79,62 @@ jobs:
5779

5880
- name: Install dependencies
5981
run: make develop
82+
if: matrix.target == 'native'
6083

6184
- name: Lint
6285
run: make lint
86+
if: matrix.target == 'native'
6387

6488
- name: Checks
6589
run: make checks
66-
if: matrix.os == 'ubuntu-latest'
90+
if: matrix.name == 'ubuntu-latest'
6791

6892
# On Linux `make dist-rs` rebuilds this same release profile, and
6993
# cibuildwheel then rebuilds the tree again from scratch in the manylinux
7094
# container, so building here is a third compile and a third copy on disk.
7195
- name: Build
7296
run: make build
73-
if: matrix.os != 'ubuntu-latest'
97+
if: matrix.target == 'native' && runner.os != 'Linux'
7498

99+
# Coverage instrumentation forces a rebuild that shares nothing with the
100+
# cached ordinary build, so only the platform that uploads it pays for it.
75101
- name: Test
76102
run: make coverage
103+
if: matrix.name == 'ubuntu-latest'
104+
105+
- name: Test
106+
run: make test
107+
if: matrix.target == 'native' && matrix.name != 'ubuntu-latest'
108+
109+
- name: Build and test Pyodide wheel
110+
run: make test-pyodide
111+
if: matrix.target == 'pyodide'
77112

78113
- name: Upload test results (Python)
79114
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
80115
with:
81-
name: test-results-${{ matrix.os }}
116+
name: test-results-${{ matrix.name }}
82117
path: '**/junit.xml'
83-
if: always()
118+
if: always() && matrix.target == 'native'
84119

85120
- name: Publish test results
86121
uses: EnricoMi/publish-unit-test-result-action@d0a4676d0e0b938bc201470d88276b7c74c712b3 # v2.24.0
87122
with:
88123
files: '**/junit.xml'
89-
if: matrix.os == 'ubuntu-latest'
124+
if: matrix.name == 'ubuntu-latest'
90125

91126
- name: Upload coverage
92127
uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7.0.0
93128
with:
94129
token: ${{ secrets.CODECOV_TOKEN }}
95-
96-
- name: Set up QEMU
97-
uses: docker/setup-qemu-action@96fe6ef7f33517b61c61be40b68a1882f3264fb8 # v4.2.0
98-
with:
99-
platforms: all
100-
if: runner.os == 'Linux' && runner.arch == 'X64'
130+
if: matrix.name == 'ubuntu-latest'
101131

102132
- name: Free disk space
103133
run: |
104134
sudo rm -rf /usr/local/lib/android /usr/share/dotnet /opt/ghc /usr/local/.ghcup /usr/share/swift
105135
df -h /
106136
shell: bash
107-
if: matrix.os == 'ubuntu-latest'
137+
if: matrix.target == 'native' && runner.os == 'Linux'
108138

109139
# The wheel is compiled inside the manylinux container, which cannot see
110140
# the Swatinem/rust-cache the host steps use. pyproject points the
@@ -119,25 +149,40 @@ jobs:
119149
path: |
120150
/tmp/cibw-cargo-home
121151
/tmp/cibw-cargo-target
122-
key: cibw-cargo-${{ runner.os }}-${{ hashFiles('Cargo.lock', 'rust/Cargo.lock') }}
152+
key: cibw-cargo-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('Cargo.lock', 'rust/Cargo.lock') }}
123153
restore-keys: |
124-
cibw-cargo-${{ runner.os }}-
125-
if: matrix.os == 'ubuntu-latest'
154+
cibw-cargo-${{ runner.os }}-${{ runner.arch }}-
155+
if: matrix.target == 'native' && runner.os == 'Linux'
126156

127-
- name: Build distributions (Linux)
157+
- name: Build distributions (Linux x86_64)
128158
run: |
129159
rm -rf dist
130160
make dist-rs
131161
make dist-py-sdist
132-
rm -rf rust/target
133162
make dist-py-wheel
134163
make dist-check
135164
# The container writes these as root; hand them back so the cache save
136165
# can read them.
137166
sudo chown -R "$(id -u):$(id -g)" /tmp/cibw-cargo-home /tmp/cibw-cargo-target
138167
du -sh /tmp/cibw-cargo-home /tmp/cibw-cargo-target
139168
shell: bash
140-
if: matrix.os == 'ubuntu-latest'
169+
env:
170+
CIBW_ARCHS_LINUX: native
171+
if: matrix.name == 'ubuntu-latest'
172+
173+
- name: Build distributions (Linux ARM64)
174+
run: |
175+
rm -rf dist
176+
make dist-py-wheel
177+
make dist-check
178+
# The container writes these as root; hand them back so the cache save
179+
# can read them.
180+
sudo chown -R "$(id -u):$(id -g)" /tmp/cibw-cargo-home /tmp/cibw-cargo-target
181+
du -sh /tmp/cibw-cargo-home /tmp/cibw-cargo-target
182+
shell: bash
183+
env:
184+
CIBW_ARCHS_LINUX: native
185+
if: matrix.name == 'ubuntu-24.04-arm'
141186

142187
- name: Build distributions (macOS/Windows)
143188
run: |
@@ -147,22 +192,22 @@ jobs:
147192
shell: bash
148193
env:
149194
CIBW_ENVIRONMENT_MACOS: MACOSX_DEPLOYMENT_TARGET=11.0
150-
if: matrix.os != 'ubuntu-latest'
195+
if: matrix.target == 'native' && runner.os != 'Linux'
151196

152197
- name: Test wheel
153198
uses: actions-ext/python/test-wheel@ec67f82b3bd863948308a41ecb9e70547cbb19c7
154199
with:
155200
module: nepenthe
156-
if: matrix.os == 'ubuntu-latest'
201+
if: matrix.target == 'native' && runner.os == 'Linux'
157202

158203
- name: Test source distribution
159204
uses: actions-ext/python/test-sdist@ec67f82b3bd863948308a41ecb9e70547cbb19c7
160205
with:
161206
module: nepenthe
162-
if: matrix.os == 'ubuntu-latest'
207+
if: matrix.name == 'ubuntu-latest'
163208

164209
- name: Upload distributions
165210
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
166211
with:
167-
name: dist-${{ matrix.os }}
168-
path: dist
212+
name: dist-${{ matrix.name }}
213+
path: ${{ matrix.dist_path }}

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ __pycache__/
1313
*.exp
1414
*.lib
1515

16+
# vcpkg
17+
vcpkg/
18+
vcpkg_installed/
19+
1620
# Rust
1721
target
1822
target-capi
@@ -142,6 +146,7 @@ nepenthe/labextension
142146

143147
# Emscripten SDK (locally installed)
144148
emsdk
149+
.pyodide_build/
145150

146151
# Mac
147152
.DS_Store

Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,6 @@ tokio = { version = "1.52.3", features = ["rt-multi-thread"] }
1717

1818
[profile.release]
1919
panic = 'abort'
20-
lto = true
20+
# Thin LTO keeps most of the optimization but links in parallel; fat LTO over
21+
# the rattler dependency tree dominated every wheel build.
22+
lto = "thin"

Makefile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ develop: develop-rs develop-py ## setup project for development
1212

1313
.PHONY: requirements-py requirements-rs requirements
1414
requirements-py: ## install prerequisite python build requirements
15-
python -m pip install --upgrade pip toml
16-
python -m pip install `python -c 'import toml; c = toml.load("pyproject.toml"); print("\n".join(c["build-system"]["requires"]))'`
17-
python -m pip install `python -c 'import toml; c = toml.load("pyproject.toml"); print(" ".join(c["project"]["optional-dependencies"]["develop"]))'`
15+
uv pip install -r pyproject.toml --extra develop
1816

1917
requirements-rs: ## install prerequisite rust build requirements
2018
make -C rust requirements
@@ -112,6 +110,7 @@ coverage-rs: ## run rust tests and collect test coverage
112110

113111
.PHONY: test coverage tests
114112
test: test-py test-rs ## run all tests
113+
115114
coverage: coverage-py coverage-rs ## run all tests and collect test coverage
116115

117116
# alias

pyproject.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ current_version = "0.1.1"
6565
commit = true
6666
tag = true
6767
commit_args = "-s"
68+
pre_commit_hooks = [
69+
"cargo update --workspace",
70+
"git add Cargo.lock",
71+
]
6872

6973
[[tool.bumpversion.files]]
7074
filename = "pyproject.toml"
@@ -94,6 +98,10 @@ rustup target add aarch64-unknown-linux-gnu
9498
rustup target add x86_64-unknown-linux-gnu
9599
rustup show
96100
"""
101+
# A host `make develop` leaves a built extension in the source tree, which the
102+
# container would otherwise package instead of its own. The template also runs
103+
# `cargo clean` here, which would wipe the cached target dir below.
104+
before-build = "rm -f {package}/nepenthe/*.so"
97105
# cibuildwheel mounts the host filesystem at /host, so pointing cargo there keeps
98106
# the wheel build's state outside the container, where the workflow can cache it.
99107
# The in-container build is the one compile in CI that Swatinem/rust-cache cannot
@@ -123,6 +131,7 @@ archs = "arm64"
123131
environment = {PATH="$UserProfile\\.cargo\bin;$PATH", CARGO_TERM_COLOR="always"}
124132
skip = "*win32 *arm_64"
125133

134+
126135
[tool.coverage.run]
127136
branch = true
128137
omit = [

rust/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ checks: check
4242

4343
.PHONY: test tests test-ci tests-ci
4444
test: ## run the tests
45-
cargo llvm-cov nextest --cobertura --output-path junit.xml
45+
cargo nextest run
4646

4747
# alias
4848
tests: test

0 commit comments

Comments
 (0)