Skip to content

Commit

Permalink
Merge pull request #14 from sapporo-wes/enhancement/ci_test
Browse files Browse the repository at this point in the history
Add CI
  • Loading branch information
fmaccha authored Oct 5, 2024
2 parents 654b68f + bd7fbbd commit 8027f9e
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .github/actions/cache_cargo/action.yaml
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-
72 changes: 72 additions & 0 deletions .github/workflows/rust_ci.yaml
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

0 comments on commit 8027f9e

Please sign in to comment.