ci: use nox for everything
This commit is contained in:
parent
add6415c9d
commit
e28e77f13f
2 changed files with 74 additions and 48 deletions
72
.github/workflows/ci.yaml
vendored
72
.github/workflows/ci.yaml
vendored
|
|
@ -23,7 +23,6 @@ jobs:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: ["ubuntu-latest", "windows-latest", "macos-latest"]
|
os: ["ubuntu-latest", "windows-latest", "macos-latest"]
|
||||||
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
|
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
|
@ -31,28 +30,35 @@ jobs:
|
||||||
with:
|
with:
|
||||||
environment-name: ci
|
environment-name: ci
|
||||||
environment-file: environment.yaml
|
environment-file: environment.yaml
|
||||||
create-args: >-
|
|
||||||
python==${{ matrix.python-version }}
|
|
||||||
init-shell: bash
|
init-shell: bash
|
||||||
cache-environment: true
|
cache-environment: true
|
||||||
post-cleanup: 'all'
|
post-cleanup: 'all'
|
||||||
- name: Install Rust toolchain
|
- name: Install Rust toolchain
|
||||||
uses: dtolnay/rust-toolchain@stable
|
uses: dtolnay/rust-toolchain@stable
|
||||||
- name: Build
|
- name: Generate lockfile
|
||||||
run: cargo build --release
|
run: cargo generate-lockfile
|
||||||
- name: Rust Tests
|
- name: Set up project cache
|
||||||
run: RUST_BACKTRACE=1 cargo test --release
|
uses: actions/cache@v3
|
||||||
- name: Build wheels
|
continue-on-error: false
|
||||||
run: maturin develop --release --manifest-path pyargus/Cargo.toml -E test
|
with:
|
||||||
- name: Python Tests
|
path: |
|
||||||
run: RUST_BACKTRACE=1 pytest pyargus --hypothesis-explain
|
~/.cargo/bin/
|
||||||
|
~/.cargo/registry/index/
|
||||||
|
~/.cargo/registry/cache/
|
||||||
|
~/.cargo/git/db/
|
||||||
|
target/
|
||||||
|
.nox/
|
||||||
|
.hypothesis/
|
||||||
|
key: ${{ runner.os }}-argus-${{ hashFiles('**/Cargo.toml', "noxfile.py") }}
|
||||||
|
restore-keys: ${{ runner.os }}-argus-
|
||||||
|
- name: Run tests
|
||||||
|
run: nox -s tests
|
||||||
|
|
||||||
linting:
|
linting:
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: ["ubuntu-latest", "windows-latest", "macos-latest"]
|
os: ["ubuntu-latest", "windows-latest", "macos-latest"]
|
||||||
python-version: ['3.10']
|
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
|
@ -60,8 +66,6 @@ jobs:
|
||||||
with:
|
with:
|
||||||
environment-name: ci
|
environment-name: ci
|
||||||
environment-file: environment.yaml
|
environment-file: environment.yaml
|
||||||
create-args: >-
|
|
||||||
python==${{ matrix.python-version }}
|
|
||||||
init-shell: bash
|
init-shell: bash
|
||||||
cache-environment: true
|
cache-environment: true
|
||||||
post-cleanup: 'all'
|
post-cleanup: 'all'
|
||||||
|
|
@ -70,21 +74,24 @@ jobs:
|
||||||
with:
|
with:
|
||||||
toolchain: nightly
|
toolchain: nightly
|
||||||
components: "clippy, rustfmt"
|
components: "clippy, rustfmt"
|
||||||
- name: Rust lints
|
- name: Generate lockfile
|
||||||
run: |
|
run: cargo generate-lockfile
|
||||||
cargo +nightly fmt --all --check
|
- name: Set up project cache
|
||||||
cargo +nightly check --workspace
|
uses: actions/cache@v3
|
||||||
cargo +nightly clippy --workspace
|
continue-on-error: false
|
||||||
- name: Build Python package
|
with:
|
||||||
run: maturin develop --release --manifest-path pyargus/Cargo.toml -E dev
|
path: |
|
||||||
- name: Python checks
|
~/.cargo/bin/
|
||||||
working-directory: pyargus
|
~/.cargo/registry/index/
|
||||||
run: |
|
~/.cargo/registry/cache/
|
||||||
black .
|
~/.cargo/git/db/
|
||||||
isort .
|
target/
|
||||||
flake8
|
.nox/
|
||||||
ruff check .
|
.hypothesis/
|
||||||
mypy .
|
key: ${{ runner.os }}-argus-${{ hashFiles('**/Cargo.toml', "noxfile.py") }}
|
||||||
|
restore-keys: ${{ runner.os }}-argus-
|
||||||
|
- name: Run lints
|
||||||
|
run: nox -s lint
|
||||||
|
|
||||||
docs:
|
docs:
|
||||||
name: Documentation
|
name: Documentation
|
||||||
|
|
@ -103,9 +110,7 @@ jobs:
|
||||||
- name: Build Python package
|
- name: Build Python package
|
||||||
run: maturin develop --release --manifest-path pyargus/Cargo.toml
|
run: maturin develop --release --manifest-path pyargus/Cargo.toml
|
||||||
- name: Build HTML docs
|
- name: Build HTML docs
|
||||||
run: |
|
run: nox -s docs
|
||||||
sphinx-multiversion docs _site -b html
|
|
||||||
cp ./docs/_templates/index-redirect.html _site/index.html
|
|
||||||
- name: Deploy
|
- name: Deploy
|
||||||
uses: peaceiris/actions-gh-pages@v3
|
uses: peaceiris/actions-gh-pages@v3
|
||||||
if: github.ref == 'refs/heads/dev' || startsWith(github.ref, 'refs/tags/')
|
if: github.ref == 'refs/heads/dev' || startsWith(github.ref, 'refs/tags/')
|
||||||
|
|
@ -118,7 +123,6 @@ jobs:
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
os: ["ubuntu-latest"]
|
os: ["ubuntu-latest"]
|
||||||
python-version: ["3.10"]
|
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
|
@ -126,8 +130,6 @@ jobs:
|
||||||
with:
|
with:
|
||||||
environment-name: ci
|
environment-name: ci
|
||||||
environment-file: environment.yaml
|
environment-file: environment.yaml
|
||||||
create-args: >-
|
|
||||||
python==${{ matrix.python-version }}
|
|
||||||
init-shell: bash
|
init-shell: bash
|
||||||
cache-environment: true
|
cache-environment: true
|
||||||
post-cleanup: 'all'
|
post-cleanup: 'all'
|
||||||
|
|
|
||||||
50
noxfile.py
50
noxfile.py
|
|
@ -1,5 +1,6 @@
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
|
import sys
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
import nox
|
import nox
|
||||||
|
|
@ -30,6 +31,13 @@ ENV = dict(
|
||||||
CARGO_TARGET_DIR=str(TARGET_DIR),
|
CARGO_TARGET_DIR=str(TARGET_DIR),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
DEFAULT_PYTHON = f"{sys.version_info.major}.{sys.version_info.minor}"
|
||||||
|
if os.environ.get("CI"):
|
||||||
|
PYTHONS = [f"3.{i}" for i in range(8, 12 + 1)]
|
||||||
|
ENV["RUST_BACKTRACE"] = "1"
|
||||||
|
else:
|
||||||
|
PYTHONS = [DEFAULT_PYTHON]
|
||||||
|
|
||||||
|
|
||||||
@nox.session(python=False)
|
@nox.session(python=False)
|
||||||
def clean(session: nox.Session):
|
def clean(session: nox.Session):
|
||||||
|
|
@ -53,7 +61,7 @@ def dev(session: nox.Session):
|
||||||
session.run("pre-commit", "install")
|
session.run("pre-commit", "install")
|
||||||
|
|
||||||
|
|
||||||
@nox.session
|
@nox.session(python=DEFAULT_PYTHON)
|
||||||
def docs(session: nox.Session):
|
def docs(session: nox.Session):
|
||||||
session.conda_install(
|
session.conda_install(
|
||||||
"sphinx",
|
"sphinx",
|
||||||
|
|
@ -78,11 +86,12 @@ def rustfmt(session: nox.Session):
|
||||||
|
|
||||||
@nox.session(tags=["lint", "fix", "rust"], python=False)
|
@nox.session(tags=["lint", "fix", "rust"], python=False)
|
||||||
def cargo_check(session: nox.Session):
|
def cargo_check(session: nox.Session):
|
||||||
session.run("cargo", "check", "--workspace", external=True)
|
session.run("cargo", "+nightly", "fmt", "--all", "--check", external=True)
|
||||||
session.run("cargo", "clippy", "--workspace", external=True)
|
session.run("cargo", "+nightly", "check", "--workspace", external=True)
|
||||||
|
session.run("cargo", "+nightly", "clippy", "--workspace", external=True)
|
||||||
|
|
||||||
|
|
||||||
@nox.session(tags=["style", "fix", "python"])
|
@nox.session(tags=["style", "fix", "python"], python=DEFAULT_PYTHON)
|
||||||
def black(session: nox.Session):
|
def black(session: nox.Session):
|
||||||
session.conda_install("black")
|
session.conda_install("black")
|
||||||
session.run("black", str(__file__))
|
session.run("black", str(__file__))
|
||||||
|
|
@ -90,14 +99,14 @@ def black(session: nox.Session):
|
||||||
session.run("black", ".")
|
session.run("black", ".")
|
||||||
|
|
||||||
|
|
||||||
@nox.session(tags=["style", "fix", "python"])
|
@nox.session(tags=["style", "fix", "python"], python=DEFAULT_PYTHON)
|
||||||
def isort(session: nox.Session):
|
def isort(session: nox.Session):
|
||||||
session.conda_install("isort")
|
session.conda_install("isort")
|
||||||
with session.chdir(CURRENT_DIR / "pyargus"):
|
with session.chdir(CURRENT_DIR / "pyargus"):
|
||||||
session.run("isort", ".")
|
session.run("isort", ".")
|
||||||
|
|
||||||
|
|
||||||
@nox.session(tags=["lint", "python"])
|
@nox.session(tags=["lint", "python"], python=DEFAULT_PYTHON)
|
||||||
def flake8(session: nox.Session):
|
def flake8(session: nox.Session):
|
||||||
session.conda_install(
|
session.conda_install(
|
||||||
"flake8",
|
"flake8",
|
||||||
|
|
@ -109,14 +118,14 @@ def flake8(session: nox.Session):
|
||||||
session.run("flake8")
|
session.run("flake8")
|
||||||
|
|
||||||
|
|
||||||
@nox.session(tags=["lint", "fix", "python"])
|
@nox.session(tags=["lint", "fix", "python"], python=DEFAULT_PYTHON)
|
||||||
def ruff(session: nox.Session):
|
def ruff(session: nox.Session):
|
||||||
session.conda_install("ruff")
|
session.conda_install("ruff")
|
||||||
with session.chdir(CURRENT_DIR / "pyargus"):
|
with session.chdir(CURRENT_DIR / "pyargus"):
|
||||||
session.run("ruff", "--fix", "--exit-non-zero-on-fix", ".")
|
session.run("ruff", "--fix", "--exit-non-zero-on-fix", ".")
|
||||||
|
|
||||||
|
|
||||||
@nox.session(tags=["lint", "python"])
|
@nox.session(tags=["lint", "python"], python=PYTHONS)
|
||||||
def mypy(session: nox.Session):
|
def mypy(session: nox.Session):
|
||||||
session.conda_install("mypy", "typing-extensions", "pytest", "hypothesis", "lark")
|
session.conda_install("mypy", "typing-extensions", "pytest", "hypothesis", "lark")
|
||||||
session.env.update(ENV)
|
session.env.update(ENV)
|
||||||
|
|
@ -132,25 +141,40 @@ def mypy(session: nox.Session):
|
||||||
# )
|
# )
|
||||||
|
|
||||||
|
|
||||||
@nox.session
|
@nox.session(python=PYTHONS)
|
||||||
def tests(session: nox.Session):
|
def tests(session: nox.Session):
|
||||||
session.conda_install("pytest", "hypothesis", "lark")
|
session.conda_install("pytest", "hypothesis", "lark")
|
||||||
session.env.update(ENV)
|
session.env.update(ENV)
|
||||||
session.install("./pyargus[test]")
|
|
||||||
try:
|
try:
|
||||||
session.run(
|
session.run(
|
||||||
"cargo", "test", "--workspace", "--exclude", "pyargus", external=True
|
"cargo",
|
||||||
|
"test",
|
||||||
|
"--release",
|
||||||
|
"--workspace",
|
||||||
|
"--exclude",
|
||||||
|
"pyargus",
|
||||||
|
external=True,
|
||||||
)
|
)
|
||||||
except Exception:
|
except Exception:
|
||||||
...
|
...
|
||||||
try:
|
try:
|
||||||
|
session.run(
|
||||||
|
"maturin",
|
||||||
|
"develop",
|
||||||
|
"--release",
|
||||||
|
"-m",
|
||||||
|
"./pyargus/Cargo.toml",
|
||||||
|
"-E",
|
||||||
|
"test",
|
||||||
|
silent=True,
|
||||||
|
)
|
||||||
with session.chdir(CURRENT_DIR / "pyargus"):
|
with session.chdir(CURRENT_DIR / "pyargus"):
|
||||||
session.run("pytest", ".")
|
session.run("pytest", ".", "--hypothesis-explain")
|
||||||
except Exception:
|
except Exception:
|
||||||
...
|
...
|
||||||
|
|
||||||
|
|
||||||
@nox.session
|
@nox.session(python=DEFAULT_PYTHON)
|
||||||
def coverage(session: nox.Session):
|
def coverage(session: nox.Session):
|
||||||
session.conda_install("pytest", "coverage", "hypothesis", "lark", "maturin", "lcov")
|
session.conda_install("pytest", "coverage", "hypothesis", "lark", "maturin", "lcov")
|
||||||
session.run("cargo", "install", "grcov", external=True, silent=True)
|
session.run("cargo", "install", "grcov", external=True, silent=True)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue