Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: Optimised CI workflows #112

Merged
merged 15 commits into from
Jan 25, 2022
49 changes: 49 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Lint

on: [push, pull_request]

jobs:
clippy:
name: Clippy
runs-on: ubuntu-latest

steps:
- name: Checkout sources
uses: actions/checkout@v2

- name: Install stable toolchain
id: toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
components: clippy
profile: minimal
override: true

- name: Cache
uses: Swatinem/rust-cache@v1

- name: Run clippy
uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: -- -D clippy::all

rustfmt:
name: Format
runs-on: ubuntu-latest

steps:
- name: Checkout sources
uses: actions/checkout@v2

- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
components: rustfmt
profile: minimal
override: true

- name: Run cargo fmt
run: cargo fmt --all -- --check
30 changes: 15 additions & 15 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
name: Main Workflow
on:
push:
branches: [main]
pull_request:
branches: [main]

on: [push, pull_request]

jobs:
build:
name: Build
strategy:
matrix:
rust-version: ["1.54", "1.55", "1.56", "1.57"]
rust-version: ["1.55", "1.56", "1.57"]
runs-on: ubuntu-latest
container: rust:${{ matrix.rust-version }}
steps:
- name: Repository Checkout
uses: actions/checkout@v2

- name: Format Rust Code
run: |
rustup component add rustfmt
cargo fmt --all -- --check
- name: Cache
uses: Swatinem/rust-cache@v1

- name: Lint Rust Code
run: |
rustup component add clippy
cargo clippy -- -D clippy::all
- name: Build Binary
run: cargo build --locked

- name: Build Release Binary
run: cargo build --release
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')
run: cargo build --release --locked

- name: Run Unit Tests
run: cargo test

- name: Run Release Unit Tests
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')
run: cargo test --release --locked