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