name: "CI/CD"
on:
- push
- pull_request
jobs:
audit:
name: audit
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v2
- name: audit
uses: actions-rs/audit-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
check:
name: check
needs: [audit]
runs-on: ubuntu-latest
continue-on-error: ${{ matrix.rust == 'nightly' }}
strategy:
fail-fast: false
matrix:
rust: [stable, nightly]
steps:
- name: checkout
uses: actions/checkout@v2
- name: install rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
override: true
- name: cargo check
uses: actions-rs/cargo@v1
with:
command: check
args: --all-features --verbose
test:
name: test
needs: [audit]
runs-on: ubuntu-latest
continue-on-error: ${{ matrix.rust == 'nightly' }}
strategy:
fail-fast: false
matrix:
rust: [stable, nightly]
args:
- --lib
- --doc
- --test integration
- --test hypothesis
- --test versions
- --benches
steps:
- name: checkout
uses: actions/checkout@v2
- name: install rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
override: true
- name: cargo test
uses: actions-rs/cargo@v1
with:
command: test
args: --all-features ${{ matrix.args }}
lint:
name: lint
needs: [audit]
runs-on: ubuntu-latest
continue-on-error: ${{ matrix.rust == 'nightly' }}
strategy:
fail-fast: false
matrix:
rust: [stable, nightly]
steps:
- name: checkout
uses: actions/checkout@v2
- name: install rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
override: true
components: rustfmt, clippy
- name: rustfmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
- name: clippy
uses: actions-rs/clippy-check@v1
with:
name: ${{ matrix.rust }}
token: ${{ secrets.GITHUB_TOKEN }}
coverage:
name: coverage
needs: [check, test, lint]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- suite: unit-tests
args: --lib
- suite: integration-tests
args: --test integration
- suite: property-fuzzing-tests
args: --test hypothesis
steps:
- name: checkout
uses: actions/checkout@v2
- name: install rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
override: true
components: llvm-tools-preview
- name: test
uses: actions-rs/cargo@v1
with:
command: test
args: ${{ matrix.args }}
env:
RUSTFLAGS: "-Zinstrument-coverage"
- name: install grcov
uses: actions-rs/install@v0.1
with:
crate: grcov
use-tool-cache: true
- name: gather
run: "grcov . --binary-path target/debug/ \
--source-dir . \
--branch \
--ignore-not-existing \
--output-type lcov \
--output-path coverage.lcov \
--prefix-dir /home/user/build/ \
--ignore '/*' \
--excl-line 'panic!'"
- name: upload
uses: codecov/codecov-action@v2
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: ${{ matrix.suite }}
files: coverage.lcov
publish:
name: publish
if: ${{ github.event_name == 'push' &&
startsWith(github.ref, 'refs/tag') }}
needs:
- coverage
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v2
- name: install
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: publish
uses: actions-rs/cargo@v1
with:
command: publish
args: --token ${{ secrets.CRATES_TOKEN }}