Skip to content

Commit

Permalink
ci: improve github workflows (#190)
Browse files Browse the repository at this point in the history
* ci: improve github workflows

- split test workflow into lint and test parts
- add cache and sccache
- use stable toolchain for rustfmt and clippy

* remove useless env
  • Loading branch information
koushiro authored Jun 21, 2024
1 parent 19db131 commit d466f18
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 18 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
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
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
42 changes: 28 additions & 14 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,46 @@ 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
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 d466f18

Please sign in to comment.