updats #5
This file contains hidden or 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
name: CI | |
on: | |
push: | |
branches: [ main, develop ] | |
pull_request: | |
branches: [ main ] | |
env: | |
CARGO_TERM_COLOR: always | |
jobs: | |
test: | |
name: Test Suite | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest, windows-latest, macos-latest] | |
rust: [stable, beta] | |
exclude: | |
- os: windows-latest | |
rust: beta | |
- os: macos-latest | |
rust: beta | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install Rust | |
uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: ${{ matrix.rust }} | |
components: rustfmt, clippy | |
- name: Cache cargo registry | |
uses: actions/cache@v4 | |
with: | |
path: ~/.cargo/registry | |
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} | |
- name: Cache cargo index | |
uses: actions/cache@v4 | |
with: | |
path: ~/.cargo/git | |
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }} | |
- name: Cache cargo build | |
uses: actions/cache@v4 | |
with: | |
path: target | |
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }} | |
- name: Check formatting | |
run: cargo fmt --all -- --check | |
- name: Run clippy | |
run: cargo clippy --all-targets --all-features -- -D warnings | |
- name: Build | |
run: cargo build --verbose --all-features | |
- name: Run tests | |
run: cargo test --verbose --all-features | |
- name: Run doctests | |
run: cargo test --doc --all-features | |
coverage: | |
name: Code Coverage | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install Rust | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
components: llvm-tools-preview | |
- name: Install cargo-llvm-cov | |
uses: taiki-e/install-action@cargo-llvm-cov | |
- name: Generate code coverage | |
run: cargo llvm-cov --all-features --workspace --lcov --output-path lcov.info | |
- name: Upload coverage to Codecov | |
uses: codecov/codecov-action@v4 | |
with: | |
files: lcov.info | |
fail_ci_if_error: true | |
security: | |
name: Security Audit | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install Rust | |
uses: dtolnay/rust-toolchain@stable | |
- name: Install cargo-audit | |
run: cargo install cargo-audit | |
- name: Run security audit | |
run: cargo audit | |
wasm: | |
name: WASM Build | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install Rust | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
targets: wasm32-unknown-unknown | |
- name: Install wasm-pack | |
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh | |
- name: Build WASM package | |
run: wasm-pack build libvera --target web --features wasm | |
benchmark: | |
name: Benchmark | |
runs-on: ubuntu-latest | |
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install Rust | |
uses: dtolnay/rust-toolchain@stable | |
- name: Run benchmarks | |
run: cargo bench --all-features | |
- name: Store benchmark result | |
uses: benchmark-action/github-action-benchmark@v1 | |
with: | |
tool: 'cargo' | |
output-file-path: target/criterion/*/estimates.json | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
auto-push: true | |
release: | |
name: Release | |
runs-on: ubuntu-latest | |
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') | |
needs: [test, coverage, security, wasm] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install Rust | |
uses: dtolnay/rust-toolchain@stable | |
- name: Build release binaries | |
run: | | |
cargo build --release --bin vera-enc | |
cargo build --release --bin vera | |
- name: Create release archive | |
run: | | |
mkdir -p release | |
cp target/release/vera-enc release/ | |
cp target/release/vera release/ | |
cp README.md release/ | |
cp LICENSE-MIT release/ || echo "LICENSE-MIT not found" | |
cp LICENSE-APACHE release/ || echo "LICENSE-APACHE not found" | |
tar -czf vera-${{ github.ref_name }}-x86_64-unknown-linux-gnu.tar.gz -C release . | |
- name: Create GitHub Release | |
uses: softprops/action-gh-release@v2 | |
with: | |
files: vera-${{ github.ref_name }}-x86_64-unknown-linux-gnu.tar.gz | |
generate_release_notes: true | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |