Skip to content

Commit

Permalink
Optimize GitHub Actions workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
zoni committed Sep 23, 2023
1 parent f72ef65 commit 2151517
Showing 1 changed file with 73 additions and 36 deletions.
109 changes: 73 additions & 36 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,72 +3,109 @@ on: [push, pull_request]
name: CI tests

jobs:
linting:
name: Run lints
build:
name: Build project
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
- uses: dtolnay/rust-toolchain@stable
id: setup_rust
with:
profile: minimal
toolchain: stable
override: true

- run: rustup component add rustfmt
- uses: actions-rs/cargo@v1
components: "rustfmt, clippy"
- uses: actions/cache@v3
with:
command: fmt
args: --all -- --check
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: "rustc-base-${{ steps.setup_rust.outputs.cachekey }}"
- run: cargo build

- uses: actions-rs/cargo@v1
lint:
name: Run lints
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
id: setup_rust
with:
command: check

- run: rustup component add clippy
- uses: actions-rs/cargo@v1
components: "rustfmt, clippy"
- uses: actions/cache@v3
with:
command: clippy
args: -- -D warnings
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: "rustc-lint-${{ steps.setup_rust.outputs.cachekey }}"
restore-keys: |
rustc-lint-${{ steps.setup_rust.outputs.cachekey }}
rustc-base-${{ steps.setup_rust.outputs.cachekey }}
- run: cargo fmt --all -- --check
- run: cargo check
- run: cargo clippy -- -D warnings

test-linux:
name: Test on Linux
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
- uses: dtolnay/rust-toolchain@stable
id: setup_rust
- uses: actions/cache@v3
with:
profile: minimal
toolchain: stable
override: true
- uses: actions-rs/cargo@v1
with:
command: test
path: |
~/.cargo/
target/
key: "rustc-test-${{ steps.setup_rust.outputs.cachekey }}"
restore-keys: |
rustc-test-${{ steps.setup_rust.outputs.cachekey }}
rustc-base-${{ steps.setup_rust.outputs.cachekey }}
- run: cargo test

test-windows:
name: Test on Windows
runs-on: windows-latest
needs: build
steps:
- run: git config --system core.autocrlf false && git config --system core.eol lf
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- uses: actions-rs/cargo@v1
- uses: dtolnay/rust-toolchain@stable
id: setup_rust
- uses: actions/cache@v3
with:
command: test
path: |
~/.cargo/
target/
key: "rustc-windows-${{ steps.setup_rust.outputs.cachekey }}"
restore-keys: |
rustc-windows-${{ steps.setup_rust.outputs.cachekey }}
rustc-base-${{ steps.setup_rust.outputs.cachekey }}
- run: cargo test

coverage:
name: Code coverage
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
- uses: dtolnay/rust-toolchain@stable
id: setup_rust
- uses: actions/cache@v3
with:
profile: minimal
toolchain: stable
override: true
path: |
~/.cargo/
target/
key: "rustc-coverage-${{ steps.setup_rust.outputs.cachekey }}"
restore-keys: |
rustc-coverage-${{ steps.setup_rust.outputs.cachekey }}
rustc-base-${{ steps.setup_rust.outputs.cachekey }}
- uses: actions-rs/[email protected]
with:
# Constrained by https://github.com/actions-rs/tarpaulin/pull/23
Expand Down

0 comments on commit 2151517

Please sign in to comment.