Skip to content

Add CI

Add CI #2

Workflow file for this run

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