Format, and rewrite CI with nix #64
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Check and build the library using Nix | |
on: | |
push: | |
branches: | |
- main | |
tags: | |
- "v*.*.*" | |
pull_request: | |
branches: | |
- main | |
jobs: | |
check: | |
name: Check/Lint | |
runs-on: ubuntu-latest | |
steps: | |
- name: git checkout | |
uses: actions/checkout@v3 | |
- name: Install Nix | |
uses: DeterminateSystems/nix-installer-action@main | |
- uses: DeterminateSystems/magic-nix-cache-action@main | |
- name: Check Nixpkgs inputs | |
uses: DeterminateSystems/flake-checker-action@main | |
with: | |
fail-mode: true | |
# Nix-specific logic begins here | |
- name: Check Rust formatting | |
run: | | |
nix develop --command cargo fmt --all --check | |
- name: Check Clippy lints | |
run: | | |
nix develop --command cargo clippy --all-targets | |
- name: Check spelling | |
run: | | |
nix develop --command \ | |
codespell \ | |
--skip target,.git \ | |
--ignore-words-list crate | |
test_and_build: | |
name: Test and build library | |
needs: check | |
runs-on: ubuntu-latest | |
steps: | |
- name: git checkout | |
uses: actions/checkout@v3 | |
- name: Install Nix | |
uses: DeterminateSystems/nix-installer-action@main | |
- uses: DeterminateSystems/magic-nix-cache-action@main | |
- name: Set up Rust cache | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.cargo/bin/ | |
~/.cargo/registry/index/ | |
~/.cargo/registry/cache/ | |
~/.cargo/git/db/ | |
target/ | |
key: psrdada-rs-${{ hashFiles('**/Cargo.lock') }} | |
- name: Test library | |
run: | | |
nix develop --command cargo test | |
- name: Build library | |
run: | | |
nix develop --command cargo build | |
- name: Generate code coverage | |
run: nix develop --command cargo llvm-cov --workspace --lcov --output-path lcov.info | |
- name: Upload coverage to Codecov | |
uses: codecov/codecov-action@v3 | |
with: | |
files: lcov.info | |
fail_ci_if_error: true |