name: CI
on:
pull_request:
push:
branches:
- main
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }}
- uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('dev-requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- uses: actions/setup-python@v2
with:
python-version: "3.9"
- name: Run unit and system tests
run: cargo test --verbose
- name: Install Python dependencies
run: python -m pip install -r dev-requirements.txt
- name: Run `main.rs` tests
run: python -m pytest tests/test_main.py
coverage:
runs-on: ubuntu-latest
needs: test
env:
CARGO_TARGET_DIR: target
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }}
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Install tarpaulin
run: cargo install cargo-tarpaulin
- name: Run coverage
run: cargo tarpaulin -v --out Xml --exclude-files tests/*
- uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }}
- uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('dev-requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- uses: actions/setup-python@v2
with:
python-version: "3.8"
- name: Install Black
run: python -m pip install black
- name: Install Rust components
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
components: rustfmt, clippy
- name: Run clippy
run: cargo clippy --all-targets --all-features -- -D warnings
- name: Run rustfmt
if: ${{ always() }}
run: cargo fmt --all -- --check
- name: Run Black
if: ${{ always() }}
run: python -m black --check .