Run linting, formatting, and tests in CI using Nix

This commit is contained in:
Joseph LaFreniere 2023-06-04 00:47:39 -05:00
parent 01b363d7c0
commit de8e51884e
No known key found for this signature in database
GPG Key ID: EE236AA0141EFCA3

View File

@ -1,69 +1,25 @@
# Based on https://github.com/actions-rs/meta/blob/master/recipes/quickstart.md
#
# While our "example" application has the platform-specific code,
# for simplicity we are compiling and testing everything on the Ubuntu environment only.
# For multi-OS testing see the `cross.yml` workflow.
# While our "example" application has platform-specific code,
# for simplicity we are compiling and testing everything in a nix-on-Linux environment only.
on: [push, pull_request]
name: ci
jobs:
check:
name: Check
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2
- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: Run cargo check
uses: actions-rs/cargo@v1
with:
command: check
test:
name: Test Suite
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2
- name: Install nix
uses: cachix/install-nix-action@v18
- name: Run tests
run: nix develop --command cargo test
lints:
nix-flake-check:
name: Lints
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
components: rustfmt, clippy
- name: Install nix
uses: cachix/install-nix-action@v21
- name: Run cargo fmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
- name: Ensure the build succeeds
run: nix build
- name: Run cargo clippy
uses: actions-rs/cargo@v1
with:
command: clippy
args: -- -D warnings
- name: Run `nix flake check` to run formatters, linters, and tests
run: nix flake check --print-build-logs