-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from sapporo-wes/enhancement/ci_test
Add CI
- Loading branch information
Showing
2 changed files
with
88 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
name: cache_cargo | ||
description: "Cache .cargo registry" | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Cache .cargo registry | ||
uses: actions/cache@v3 | ||
with: | ||
path: | | ||
~/.cargo/registry/index/ | ||
~/.cargo/registry/cache/ | ||
~/.cargo/git/db/ | ||
target/ | ||
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | ||
restore-keys: ${{ runner.os }}-cargo- |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
name: Rust CI | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
- enhancement** | ||
- bug** | ||
paths: | ||
- 'src/**' | ||
- 'tests/**' | ||
- 'Cargo.**' | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
|
||
jobs: | ||
build_cache: | ||
name: Cache Rust ${{ matrix.os }} | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
fail-fast: true | ||
matrix: | ||
# os: [ubuntu-latest, macos-latest] | ||
os: [ubuntu-latest] | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
- name: Cache cargo directory | ||
uses: ./.github/actions/cache_cargo | ||
- name: Set toolchain | ||
uses: dtolnay/rust-toolchain@master | ||
with: | ||
toolchain: stable | ||
components: rustfmt, clippy | ||
- name: Build | ||
run: cargo build | ||
|
||
fmt_clippy: | ||
name: format and clippy | ||
runs-on: ubuntu-latest | ||
needs: build_cache | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
- name: Cache cargo directory | ||
uses: ./.github/actions/cache_cargo | ||
- name: Check | ||
run: cargo check | ||
- name: Format code | ||
run: cargo fmt --all -- --check | ||
- name: Clippy | ||
run: cargo clippy --all-targets --all-features -- -D warnings --no-deps | ||
|
||
test: | ||
name: cargo test | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
fail-fast: true | ||
matrix: | ||
# os: [ubuntu-latest, macos-latest] | ||
os: [ubuntu-latest] | ||
needs: build_cache | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
- name: Cache cargo directory | ||
uses: ./.github/actions/cache_cargo | ||
- name: Run tests | ||
run: cargo test -- --nocapture | ||
|