Skip to content

Commit 3fcd194

Browse files
authored
Merge pull request #249 from adamreichold/delay-test-job
Only run test job after basic checks are green to reduce wasted CI work.
2 parents 7c63a12 + 660ba20 commit 3fcd194

File tree

9 files changed

+103
-546
lines changed

9 files changed

+103
-546
lines changed

.github/workflows/ci.yml

Lines changed: 77 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ jobs:
1717
toolchain: stable
1818
profile: minimal
1919
components: rustfmt, clippy
20+
default: true
21+
- uses: Swatinem/rust-cache@v1
22+
continue-on-error: true
2023
- env:
2124
CLIPPYFLAGS: --deny warnings --allow clippy::needless-lifetimes
2225
run: |
@@ -27,50 +30,67 @@ jobs:
2730
test:
2831
name: python${{ matrix.python-version }}-${{ matrix.platform.python-architecture }} ${{ matrix.platform.os }}
2932
runs-on: ${{ matrix.platform.os }}
33+
needs: [lint, check-msrv, linalg-example]
3034
strategy:
31-
max-parallel: 16
35+
fail-fast: false
3236
matrix:
33-
python-version: [3.6, 3.7, 3.8, 3.9]
37+
python-version: [3.7, 3.8, 3.9]
3438
platform: [
3539
{ os: "ubuntu-latest", python-architecture: "x64", rust-target: "x86_64-unknown-linux-gnu" },
3640
{ os: "macOS-latest", python-architecture: "x64", rust-target: "x86_64-apple-darwin" },
3741
{ os: "windows-latest", python-architecture: "x64", rust-target: "x86_64-pc-windows-msvc" },
3842
{ os: "windows-latest", python-architecture: "x86", rust-target: "i686-pc-windows-msvc" },
3943
]
44+
include:
45+
# NumPy does not provide pre-built wheels for PyPy on macOS and Windows
46+
- python-version: pypy-3.7
47+
platform: { os: "ubuntu-latest", python-architecture: "x64", rust-target: "x86_64-unknown-linux-gnu" }
48+
- python-version: pypy-3.8
49+
platform: { os: "ubuntu-latest", python-architecture: "x64", rust-target: "x86_64-unknown-linux-gnu" }
4050
steps:
4151
- uses: actions/checkout@v2
4252
- name: Set up Python ${{ matrix.python-version }}
4353
uses: actions/setup-python@v2
4454
with:
4555
python-version: ${{ matrix.python-version }}
56+
architecture: ${{ matrix.platform.python-architecture }}
4657
- name: Install Rust
4758
uses: actions-rs/toolchain@v1
4859
with:
4960
toolchain: stable
61+
profile: minimal
62+
target: ${{ matrix.platform.rust-target }}
5063
default: true
51-
- run: rustup set default-host ${{ matrix.platform.rust-target }}
64+
- name: Install toml
65+
run: pip install toml
66+
- name: Edit Cargo.toml and enable new resolver
67+
run: |
68+
import toml
69+
cargo_toml = toml.load("Cargo.toml")
70+
cargo_toml["workspace"]["resolver"] = "2"
71+
with open("Cargo.toml", "w") as f:
72+
toml.dump(cargo_toml, f)
73+
shell: python
5274
- name: Build without default features
53-
run: cargo build --no-default-features --verbose
75+
run: cargo build --no-default-features
5476
- name: Build with default features
55-
run: cargo build --verbose
56-
- name: Install test dependencies
77+
run: cargo build
78+
- name: Test
5779
run: |
58-
python -m pip install --upgrade pip
59-
pip install maturin numpy poetry
60-
- name: Run cargo test
61-
run: cargo test --verbose
62-
- name: Test Examples
80+
pip install numpy
81+
cargo test
82+
# Not on PyPy, because no embedding API
83+
if: ${{ !startsWith(matrix.python-version, 'pypy') }}
84+
- name: Test example
6385
run: |
64-
for example_dir in 'examples/simple-extension'; do
65-
pushd $example_dir && \
66-
poetry install && \
67-
poetry run maturin develop && \
68-
poetry run pytest && \
69-
popd
70-
done
71-
shell: bash
86+
pip install tox
87+
tox
88+
working-directory: examples/simple-extension
7289
env:
90+
CARGO_TERM_VERBOSE: true
91+
CARGO_BUILD_TARGET: ${{ matrix.platform.rust-target }}
7392
RUST_BACKTRACE: 1
93+
TOX_TESTENV_PASSENV: CARGO_BUILD_TARGET
7494

7595
check-msrv:
7696
runs-on: ubuntu-latest
@@ -80,37 +100,48 @@ jobs:
80100
uses: actions/setup-python@v2
81101
with:
82102
python-version: 3.8
83-
- name: Install MSRV Rust
103+
- name: Install Rust
84104
uses: actions-rs/toolchain@v1
85105
with:
86-
profile: minimal
87106
toolchain: 1.48.0
107+
profile: minimal
88108
default: true
89-
- name: Install maturin, poetry, and toml
90-
run: pip install maturin poetry toml
91-
- name: Create an isolated example directory
92-
run: cp -r examples/simple-extension/ ../simple-extension-msrv
93-
- name: Edit Cargo.toml and change the path of rust-numpy
109+
- uses: Swatinem/rust-cache@v1
110+
with:
111+
working-directory: examples/simple-extension
112+
continue-on-error: true
113+
- name: Install toml
114+
run: pip install toml
115+
- name: Edit Cargo.toml and detach from workspace
94116
run: |
95117
import toml
96118
cargo_toml = toml.load("Cargo.toml")
97-
cargo_toml["dependencies"]["numpy"]["path"] = "../rust-numpy"
98119
cargo_toml["dependencies"]["ndarray"] = "0.13.1"
99120
cargo_toml["dependencies"]["num-complex"] = "0.2.4"
121+
cargo_toml["workspace"] = {}
100122
with open("Cargo.toml", "w") as f:
101123
toml.dump(cargo_toml, f)
102-
working-directory: ../simple-extension-msrv
124+
working-directory: examples/simple-extension
103125
shell: python
104-
- name: Use ndarray 0.13.1
126+
- name: Generate lockfile
127+
run: cargo generate-lockfile
128+
working-directory: examples/simple-extension
129+
- name: Unify dependencies on ndarray to 0.13.1
105130
run: |
106-
cargo generate-lockfile
107-
cargo update -p $(cargo pkgid -p ndarray 2>&1 >/dev/null | grep 0.15 | sed -e 's/^[ \t]*//') --precise 0.13.1
108-
working-directory: ../simple-extension-msrv
109-
- name: Test Example
131+
import toml
132+
import subprocess
133+
cargo_lock = toml.load("Cargo.lock")
134+
for pkg in cargo_lock["package"]:
135+
if pkg["name"] == "ndarray" and pkg["version"] != "0.13.1":
136+
pkg_id = pkg["name"] + ":" + pkg["version"]
137+
subprocess.run(["cargo", "update", "--package", pkg_id, "--precise", "0.13.1"], check=True)
138+
working-directory: examples/simple-extension
139+
shell: python
140+
- name: Test example
110141
run: |
111-
poetry install && poetry run maturin develop && poetry run pytest
112-
working-directory: ../simple-extension-msrv
113-
shell: bash
142+
pip install tox
143+
tox
144+
working-directory: examples/simple-extension
114145

115146
linalg-example:
116147
runs-on: ubuntu-latest
@@ -120,18 +151,18 @@ jobs:
120151
uses: actions/setup-python@v2
121152
with:
122153
python-version: 3.8
123-
- name: Install gfortran
124-
run: |
125-
sudo apt install -y gfortran
154+
- name: Install OpenBLAS
155+
run: sudo apt install --yes libopenblas-dev
126156
- name: Install Rust
127157
uses: actions-rs/toolchain@v1
128158
with:
129159
toolchain: stable
130-
- name: Install maturin and poetry
131-
run: pip install maturin poetry
132-
- name: Test Examples
160+
profile: minimal
161+
default: true
162+
- uses: Swatinem/rust-cache@v1
163+
continue-on-error: true
164+
- name: Test example
133165
run: |
134-
cd examples/linalg && \
135-
poetry install && \
136-
poetry run maturin develop && \
137-
poetry run pytest
166+
pip install tox
167+
tox
168+
working-directory: examples/linalg

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ build/
1414
*.so
1515
*.egg-info/
1616
**/dist/
17-
__pycache__
17+
__pycache__

examples/linalg/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ crate-type = ["cdylib"]
1111
[dependencies]
1212
pyo3 = { version = "0.15", features = ["extension-module"] }
1313
numpy = { path = "../.." }
14-
ndarray-linalg = { version = "0.14.1", features = ["openblas-static"] }
14+
ndarray-linalg = { version = "0.14.1", features = ["openblas-system"] }

0 commit comments

Comments
 (0)