name: push-main
on:
push:
branches:
- main
jobs:
test:
runs-on: buildjet-4vcpu-ubuntu-2004
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 1
- name: Install rust toolchain
uses: actions-rs/toolchain@v1
- uses: Swatinem/rust-cache@v1
- name: Install grcov
run: |
wget https://github.com/mozilla/grcov/releases/download/v0.8.2/grcov-linux-x86_64.tar.bz2
tar -xf grcov-linux-x86_64.tar.bz2
mv grcov $HOME/.cargo/bin
- name: Install llvm-tools
run: rustup component add llvm-tools-preview
- name: Run test with code coverage, only lib
run: cargo test --lib
env:
RUSTFLAGS: '-C instrument-coverage'
LLVM_PROFILE_FILE: test-%p-%m.profraw
APP_ENVIRONMENT: test
- name: Export lcov.info with grcov
run: grcov . --binary-path ./target/debug/ -s . -t lcov --branch --ignore-not-existing --ignore "/*" -o lcov.info
- name: Upload to codecov.io
uses: codecov/codecov-action@v2
with:
token: ${{secrets.CODECOV_TOKEN}}
fail_ci_if_error: false
audit:
runs-on: buildjet-4vcpu-ubuntu-2004
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 1
- uses: Swatinem/rust-cache@v1
- name: Audit security vulnerabilities
run: |
cargo install cargo-audit
cargo audit --ignore RUSTSEC-2020-0071 --ignore RUSTSEC-2020-0159 --ignore RUSTSEC-2022-0014
lint:
runs-on: buildjet-4vcpu-ubuntu-2004
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 1
- name: Install rust toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
components: clippy
- uses: Swatinem/rust-cache@v1
- name: Run cargo clippy
run: cargo clippy -- -D warnings
publish:
needs: [test, audit, lint]
name: Publish
runs-on: buildjet-4vcpu-ubuntu-2004
steps:
- name: Checkout sources
uses: actions/checkout@v2
- name: Install rust toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
- run: cargo publish --token ${CRATE_TOKEN}
env:
CRATE_TOKEN: ${{ secrets.CRATE_TOKEN }}