Skip to content

Commit

Permalink
ci: improve github workflows
Browse files Browse the repository at this point in the history
- split test workflow into lint and test parts
- add cache and sccache
- use stable toolchain for rustfmt and clippy
  • Loading branch information
koushiro committed Jun 20, 2024
1 parent 19db131 commit 4947bf8
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 18 deletions.
56 changes: 56 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Lint

on:
push:
branches: ["master"]
paths-ignore:
- "**/README.md"
pull_request:
paths-ignore:
- "**/README.md"

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
CARGO_TERM_COLOR: always
CARGO_INCREMENTAL: 0
CARGO_NET_GIT_FETCH_WITH_CLI: true
RUSTC_WRAPPER: sccache
SCCACHE_GHA_ENABLED: true

jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4

- name: Cache cargo registry & git sources
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/
~/.cargo/git/db/
key: ${{ runner.os }}-cargo-lint-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-lint-${{ hashFiles('**/Cargo.lock') }}
${{ runner.os }}-cargo-lint-
${{ runner.os }}-cargo-
- name: Run sccache
uses: mozilla-actions/[email protected]

- name: Install toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: 1.78.0
components: rustfmt, clippy

- name: Check format
run: cargo fmt --all -- --check

- name: Check clippy
run: cargo clippy --all-targets --all-features -- -D warnings
44 changes: 30 additions & 14 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,48 @@ on:
paths-ignore:
- "**/README.md"
pull_request:
branches: ["master"]

env:
CARGO_TERM_COLOR: always
paths-ignore:
- "**/README.md"

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
CARGO_TERM_COLOR: always
CARGO_INCREMENTAL: 0
CARGO_NET_GIT_FETCH_WITH_CLI: true
RUSTC_WRAPPER: sccache
SCCACHE_GHA_ENABLED: true

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4

- name: Cache cargo registry & git sources
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/
~/.cargo/git/db/
key: ${{ runner.os }}-cargo-test-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-test-${{ hashFiles('**/Cargo.lock') }}
${{ runner.os }}-cargo-test-
${{ runner.os }}-cargo-
- name: Run sccache
uses: mozilla-actions/[email protected]

- name: Install toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: nightly-2024-02-09
toolchain: 1.78.0
components: rustfmt, clippy
- uses: actions/checkout@v3
with:
submodules: recursive
- name: Check format
run: cargo +nightly-2024-02-09 fmt --all -- --check
- name: Check clippy
run: cargo +nightly-2024-02-09 clippy --all-targets --all-features -- -D warnings
- name: Build
run: cargo build --verbose

- name: Run tests
run: cargo test --verbose
4 changes: 0 additions & 4 deletions .rustfmt.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,2 @@
reorder_imports = true
max_width = 120

ignore = [
"vendor/*",
]

0 comments on commit 4947bf8

Please sign in to comment.