name: CI
on:
push:
branches:
- main
paths:
- "**.rs"
- Cargo.toml
- Cargo.lock
- .github/**
pull_request:
branches:
- main
paths:
- "**.rs"
- Cargo.toml
- Cargo.lock
- .github/**
env:
CARGO_TERM_COLOR: always
jobs:
ci:
name: CI
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
components: rustfmt, clippy
override: true
- name: Run rustfmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
- name: Restore build cache
uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo
- name: Run clippy
uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --all-features -- -D warnings
- name: Run tests
uses: actions-rs/cargo@v1
with:
command: test
args: --all-features