chore(ci): add GitHub CI #3
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
on: [push, pull_request] | |
name: Build | |
env: | |
CARGO_TERM_COLOR: always | |
jobs: | |
fmt: | |
name: Check Code Format | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@master | |
- name: Install Rust nightly | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
toolchain: nightly | |
components: rustfmt | |
- name: Run Rustfmt | |
run: cargo fmt -- --check | |
build: | |
name: Build and Test Project | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@master | |
- name: Install Rust nightly | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
toolchain: nightly | |
components: clippy | |
- name: Cache Rust dependcies | |
uses: actions/cache@v2 | |
with: | |
path: | | |
~/.cargo/registry | |
~/.cargo/git | |
target | |
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.toml') }}-${{ hashFiles('**/Cargo.lock') }} | |
restore-keys: | | |
${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.toml') }}- | |
${{ runner.os }}-cargo- | |
- name: Build | |
run: cargo build | |
- name: Build Release | |
run: cargo build --release | |
- name: Run Clippy | |
run: cargo clippy | |
- name: Run Unit Tests | |
run: cargo test |