ci: replace makefile with nox
This commit is contained in:
parent
03e650c02f
commit
c2e49a2b4c
14
.github/pull_request_template.md
vendored
14
.github/pull_request_template.md
vendored
|
@ -5,11 +5,9 @@ Please consider adding the following to your pull request:
|
|||
- docs to all new functions and / or detail in the guide
|
||||
- tests for all new or changed functions
|
||||
|
||||
Be aware the CI pipeline will check your pull request for the following:
|
||||
- Rust tests (Just `cargo test` or `make test` if you need to test examples)
|
||||
- Rust lints (`make clippy`)
|
||||
- Rust formatting (`cargo fmt`)
|
||||
- Python formatting (`black . --check`. You can install black with `pip install black`)
|
||||
- Compatibility with all supported Python versions for all examples. This uses `tox`; you can do run it using `cargo xtask test-py`.
|
||||
|
||||
You can run a similar set of checks as the CI pipeline using `make test`.
|
||||
Be aware the CI pipeline will check your pull request for the following. This is done using `nox` (you can install with `pip install nox`):
|
||||
- Rust tests (`cargo test` or `nox -s test-rust`)
|
||||
- Examples (`nox -s test-py`)
|
||||
- Rust lints (`nox -s clippy`)
|
||||
- Rust formatting (`nox -s fmt-rust`)
|
||||
- Python formatting (`nox -s fmt-py`)
|
||||
|
|
10
.github/workflows/ci.yml
vendored
10
.github/workflows/ci.yml
vendored
|
@ -15,27 +15,29 @@ jobs:
|
|||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-python@v2
|
||||
- run: pip install black==21.12b0
|
||||
- run: pip install nox
|
||||
- uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
profile: minimal
|
||||
components: rustfmt
|
||||
- name: Check python formatting (black)
|
||||
run: make fmt_py
|
||||
run: nox -s fmt-py
|
||||
- name: Check rust formatting (rustfmt)
|
||||
run: make fmt_rust
|
||||
run: nox -s fmt-rust
|
||||
|
||||
clippy:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-python@v2
|
||||
- run: pip install nox
|
||||
- uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
profile: minimal
|
||||
components: clippy
|
||||
- run: make clippy
|
||||
- run: nox -s clippy
|
||||
|
||||
check-target:
|
||||
needs: [fmt]
|
||||
|
|
41
Makefile
41
Makefile
|
@ -1,41 +0,0 @@
|
|||
.PHONY: test test_py publish clippy lint fmt fmt_py fmt_rust
|
||||
|
||||
ALL_ADDITIVE_FEATURES = macros multiple-pymethods num-bigint num-complex hashbrown serde indexmap eyre anyhow
|
||||
COVERAGE_PACKAGES = --package pyo3 --package pyo3-build-config --package pyo3-macros-backend --package pyo3-macros
|
||||
|
||||
test: lint test_py
|
||||
cargo test
|
||||
cargo test --features="abi3"
|
||||
cargo test --features="$(ALL_ADDITIVE_FEATURES)"
|
||||
cargo test --features="abi3 $(ALL_ADDITIVE_FEATURES)"
|
||||
|
||||
test_py:
|
||||
@for example in examples/*/noxfile.py; do echo "-- Running nox for $$example --"; nox -f $$example/noxfile.py || exit 1; echo ""; done
|
||||
echo "-- Running nox for pytests/noxfile.py --";
|
||||
nox -f pytests/noxfile.py || exit 1;
|
||||
|
||||
fmt_py:
|
||||
black . --check
|
||||
|
||||
fmt_rust:
|
||||
cargo fmt --all -- --check
|
||||
|
||||
fmt: fmt_rust fmt_py
|
||||
@true
|
||||
|
||||
clippy:
|
||||
cargo clippy --features="$(ALL_ADDITIVE_FEATURES)" --all-targets --workspace -- -Dwarnings
|
||||
cargo clippy --features="abi3 $(ALL_ADDITIVE_FEATURES)" --all-targets --workspace -- -Dwarnings
|
||||
for example in examples/*/; do cargo clippy --manifest-path $$example/Cargo.toml -- -Dwarnings || exit 1; done
|
||||
|
||||
lint: fmt clippy
|
||||
@true
|
||||
|
||||
publish: test
|
||||
cargo publish --manifest-path pyo3-build-config/Cargo.toml
|
||||
sleep 10
|
||||
cargo publish --manifest-path pyo3-macros-backend/Cargo.toml
|
||||
sleep 10 # wait for crates.io to update
|
||||
cargo publish --manifest-path pyo3-macros/Cargo.toml
|
||||
sleep 10 # wait for crates.io to update
|
||||
cargo publish
|
88
noxfile.py
Normal file
88
noxfile.py
Normal file
|
@ -0,0 +1,88 @@
|
|||
import time
|
||||
from glob import glob
|
||||
|
||||
import nox
|
||||
|
||||
nox.options.sessions = ["test", "clippy", "fmt"]
|
||||
|
||||
|
||||
@nox.session(venv_backend="none")
|
||||
def test(session: nox.Session):
|
||||
test_rust(session)
|
||||
test_py(session)
|
||||
|
||||
|
||||
@nox.session(name="test-rust", venv_backend="none")
|
||||
def test_rust(session: nox.Session):
|
||||
session.run("cargo", "test", external=True)
|
||||
session.run("cargo", "test", "--features=abi3", external=True)
|
||||
session.run("cargo", "test", "--features=full", external=True)
|
||||
session.run("cargo", "test", "--features=abi3 full", external=True)
|
||||
|
||||
|
||||
@nox.session(name="test-py", venv_backend="none")
|
||||
def test_py(session):
|
||||
session.run("nox", "-f", "pytests/noxfile.py", external=True)
|
||||
for example in glob("examples/*/noxfile.py"):
|
||||
session.run("nox", "-f", example, external=True)
|
||||
|
||||
|
||||
@nox.session
|
||||
def fmt(session: nox.Session):
|
||||
fmt_rust(session)
|
||||
fmt_py(session)
|
||||
|
||||
|
||||
@nox.session(name="fmt-rust", venv_backend="none")
|
||||
def fmt_rust(session: nox.Session):
|
||||
session.run("cargo", "fmt", "--all", "--check", external=True)
|
||||
|
||||
|
||||
@nox.session(name="fmt-py")
|
||||
def fmt_py(session: nox.Session):
|
||||
session.install("black==21.12b0")
|
||||
session.run("black", ".", "--check")
|
||||
|
||||
|
||||
@nox.session(venv_backend="none")
|
||||
def clippy(session: nox.Session) -> None:
|
||||
for feature_set in ["full", "abi3 full"]:
|
||||
session.run(
|
||||
"cargo",
|
||||
"clippy",
|
||||
f"--features={feature_set}",
|
||||
"--all-targets",
|
||||
"--workspace",
|
||||
"--",
|
||||
"--deny=warnings",
|
||||
external=True,
|
||||
)
|
||||
|
||||
|
||||
@nox.session(venv_backend="none")
|
||||
def publish(session: nox.Session) -> None:
|
||||
session.run(
|
||||
"cargo",
|
||||
"publish",
|
||||
"--manifest-path",
|
||||
"pyo3-build-config/Cargo.toml",
|
||||
external=True,
|
||||
)
|
||||
time.sleep(10)
|
||||
session.run(
|
||||
"cargo",
|
||||
"publish",
|
||||
"--manifest-path",
|
||||
"pyo3-macros-backend/Cargo.toml",
|
||||
external=True,
|
||||
)
|
||||
time.sleep(10)
|
||||
session.run(
|
||||
"cargo", "publish", "--manifest-path", "pyo3-macros/Cargo.toml", external=True
|
||||
)
|
||||
time.sleep(10)
|
||||
session.run(
|
||||
"cargo", "publish", "--manifest-path", "pyo3-ffi/Cargo.toml", external=True
|
||||
)
|
||||
time.sleep(10)
|
||||
session.run("cargo", "publish", external=True)
|
Loading…
Reference in a new issue