name: Rust
on:
push:
branches: [ main ]
tags:
- '*'
pull_request:
branches: [ main ]
env:
CARGO_TERM_COLOR: always
jobs:
fmt:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install latest stable
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
components: rustfmt
- name: Check code format
run: cargo fmt --all -- --check
clippy:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install latest stable
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
components: rustfmt
- name: Check code format
run: cargo fmt --all -- --check
stable-build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install latest stable
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
components: rustfmt, clippy
- name: Build debug
run: cargo build --verbose
- name: Build release
run: cargo build --release --verbose
- uses: actions/cache@v2
id: stable-cargo-build
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-stable-cargo-${{ hashFiles('**/Cargo.lock') }}
stable-tests:
runs-on: ubuntu-latest
needs: ["stable-build"]
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install latest stable
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
components: rustfmt, clippy
- name: Build debug
run: cargo test --verbose
- name: Build release
run: cargo test --release --verbose
- uses: actions/cache@v2
id: stable-cargo-build
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-stable-cargo-${{ hashFiles('**/Cargo.lock') }}