114 lines
2.4 KiB
YAML
114 lines
2.4 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches: [ main, develop ]
|
|
pull_request:
|
|
branches: [ main, develop ]
|
|
|
|
env:
|
|
CARGO_TERM_COLOR: always
|
|
|
|
jobs:
|
|
test:
|
|
name: Test
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
matrix:
|
|
rust: [stable, beta, nightly]
|
|
include:
|
|
- rust: stable
|
|
cache-key: stable
|
|
- rust: beta
|
|
cache-key: beta
|
|
- rust: nightly
|
|
cache-key: nightly
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Install Rust
|
|
uses: dtolnay/rust-toolchain@master
|
|
with:
|
|
toolchain: ${{ matrix.rust }}
|
|
|
|
- name: Cache cargo registry
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: ~/.cargo/registry
|
|
key: ${{ runner.os }}-cargo-registry-${{ matrix.cache-key }}
|
|
|
|
- name: Cache cargo index
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: ~/.cargo/git
|
|
key: ${{ runner.os }}-cargo-index-${{ matrix.cache-key }}
|
|
|
|
- name: Cache cargo build
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: target
|
|
key: ${{ runner.os }}-cargo-build-target-${{ matrix.cache-key }}-${{ hashFiles('**/Cargo.lock') }}
|
|
|
|
- name: Install cargo-cache
|
|
run: cargo install cargo-cache
|
|
|
|
- name: Cache cargo
|
|
run: cargo cache -a
|
|
|
|
- name: Build
|
|
run: cargo build --verbose
|
|
|
|
- name: Run tests
|
|
run: cargo test --verbose
|
|
|
|
- name: Run clippy
|
|
uses: actions-rs/clippy-check@v1
|
|
with:
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
args: --all-targets --all-features -- -D warnings
|
|
|
|
- name: Check formatting
|
|
run: cargo fmt --all -- --check
|
|
|
|
security:
|
|
name: Security Audit
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Install Rust
|
|
uses: dtolnay/rust-toolchain@master
|
|
with:
|
|
toolchain: stable
|
|
|
|
- name: Install cargo-audit
|
|
run: cargo install cargo-audit
|
|
|
|
- name: Run security audit
|
|
run: cargo audit
|
|
|
|
build:
|
|
name: Build Release
|
|
runs-on: ${{ matrix.os }}
|
|
needs: [test, security]
|
|
strategy:
|
|
matrix:
|
|
os: [ubuntu-latest, windows-latest, macos-latest]
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Install Rust
|
|
uses: dtolnay/rust-toolchain@master
|
|
with:
|
|
toolchain: stable
|
|
|
|
- name: Build release
|
|
run: cargo build --release --verbose
|
|
|
|
- name: Upload artifacts
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: kfmtbox-${{ matrix.os }}
|
|
path: target/release/kfmtbox* |