ci: make the CI simpler for both, release and tests

This commit is contained in:
Anand Balakrishnan 2023-10-06 12:53:28 -07:00
parent 22adbdf1a1
commit a4ed00b02d
No known key found for this signature in database
2 changed files with 33 additions and 95 deletions

View file

@ -8,16 +8,20 @@ on:
pull_request: pull_request:
workflow_dispatch: workflow_dispatch:
defaults:
run:
shell: bash -leo pipefail {0}
permissions: permissions:
contents: 'read' contents: 'read'
jobs: jobs:
linux: testing:
runs-on: ubuntu-latest
strategy: strategy:
matrix: matrix:
target: [x86_64, aarch64] os: ["ubuntu-latest", "windows-latest", "macos-latest"]
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
runs-on: ${{ matrix.os }}
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- uses: mamba-org/setup-micromamba@v1 - uses: mamba-org/setup-micromamba@v1
@ -31,80 +35,21 @@ jobs:
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: Generate lockfile
run: cargo generate-lockfile
- uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-${{ matrix.target }}-py${{ matrix.python-version }}-cargo-${{ hashFiles('Cargo.lock') }}
- name: Build - name: Build
shell: bash -el {0}
run: cargo build --release run: cargo build --release
- name: Rust Tests - name: Rust Tests
shell: bash -el {0}
run: cargo test --release run: cargo test --release
- name: Build wheels - name: Build wheels
shell: bash -el {0}
run: maturin develop --release --manifest-path pyargus/Cargo.toml run: maturin develop --release --manifest-path pyargus/Cargo.toml
- name: Python Tests - name: Python Tests
if: matrix.target == 'x86_64'
shell: bash -el {0}
run: pytest pyargus run: pytest pyargus
windows: linting:
runs-on: windows-latest
strategy: strategy:
matrix: matrix:
target: [x64] os: ["ubuntu-latest", "windows-latest", "macos-latest"]
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] python-version: ['3.10']
steps: runs-on: ${{ matrix.os }}
- uses: actions/checkout@v3
- uses: mamba-org/setup-micromamba@v1
with:
environment-name: ci
environment-file: environment.yaml
create-args: >-
python==${{ matrix.python-version }}
init-shell: powershell
cache-environment: true
post-cleanup: 'all'
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Generate lockfile
run: cargo generate-lockfile
- uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-${{ matrix.target }}-py${{ matrix.python-version }}-cargo-${{ hashFiles('Cargo.lock') }}
- name: Build
shell: pwsh
run: cargo build --release
- name: Rust Tests
shell: pwsh
run: cargo test --release
- name: Build wheels
shell: pwsh
run: maturin develop --release --manifest-path pyargus/Cargo.toml
- name: Python Tests
shell: pwsh
run: pytest pyargus
macos:
runs-on: macos-latest
strategy:
matrix:
target: [x86_64, aarch64]
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- uses: mamba-org/setup-micromamba@v1 - uses: mamba-org/setup-micromamba@v1
@ -119,27 +64,22 @@ jobs:
- name: Install Rust toolchain - name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable uses: dtolnay/rust-toolchain@stable
with: with:
targets: ${{ matrix.target }}-apple-darwin toolchain: nightly
- name: Generate lockfile components: "clippy"
run: cargo generate-lockfile - name: Rust lints
- uses: actions/cache@v3 run: |
with: cargo +nightly fmt --all --check
path: | cargo +nightly check --workspace
~/.cargo/bin/ cargo +nightly clippy --workspace
~/.cargo/registry/index/ - name: Build Python package
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-${{ matrix.target }}-py${{ matrix.python-version }}-cargo-${{ hashFiles('Cargo.lock') }}
- name: Build
shell: bash -el {0}
run: cargo build --release
- name: Rust Tests
shell: bash -el {0}
run: cargo test --release
- name: Build wheels
shell: bash -el {0}
run: maturin develop --release --manifest-path pyargus/Cargo.toml run: maturin develop --release --manifest-path pyargus/Cargo.toml
- name: Python checks
working-directory: pyargus
run: |
black .
isort .
flake8
ruff check .
mypy .
- name: Python Tests - name: Python Tests
shell: bash -el {0}
run: pytest pyargus run: pytest pyargus

View file

@ -115,14 +115,12 @@ jobs:
id-token: write # IMPORTANT: mandatory for trusted publishing id-token: write # IMPORTANT: mandatory for trusted publishing
needs: [linux, windows, macos, sdist] needs: [linux, windows, macos, sdist]
steps: steps:
- uses: actions/download-artifact@v3 - name: Download all dists
uses: actions/download-artifact@v3
with: with:
name: wheels name: wheels
path: dist path: dist/
- name: Publish to PyPI - name: Publish distribution 📦 to TestPyPI
uses: PyO3/maturin-action@v1 uses: pypa/gh-action-pypi-publish@release/v1
env:
MATURIN_REPOSITORY_URL: "https://test.pypi.org"
with: with:
command: upload repository-url: https://test.pypi.org/legacy/
args: --non-interactive dist/*