85 lines
2.9 KiB
YAML
85 lines
2.9 KiB
YAML
# Code coverage generation via cargo-llvm-cov, which is then uploaded to Codecov.
|
|
# Codecov will report back via a comment if run on a PR.
|
|
#
|
|
# Note that Codecov will report back the average all uploaded coverage files.
|
|
|
|
name: codecov
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
pull_request:
|
|
push:
|
|
branches:
|
|
- main
|
|
|
|
env:
|
|
CARGO_INCREMENTAL: 0
|
|
CARGO_HUSKY_DONT_INSTALL_HOOKS: true
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: ${{ github.event_name == 'pull_request' || github.repository != 'ClementTsang/bottom' }}
|
|
|
|
jobs:
|
|
pre-job:
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
should_skip: ${{ steps.skip_check.outputs.should_skip }}
|
|
steps:
|
|
- id: skip_check
|
|
uses: fkirc/skip-duplicate-actions@f75f66ce1886f00957d99748a42c724f4330bdcf # v5.3.1
|
|
with:
|
|
skip_after_successful_duplicate: "false"
|
|
paths: '["tests/**", "src/**", ".github/workflows/coverage.yml", ".cargo/**", "Cargo.toml", "Cargo.lock", "build.rs"]'
|
|
do_not_skip: '["workflow_dispatch", "push"]'
|
|
|
|
coverage:
|
|
needs: pre-job
|
|
if: ${{ needs.pre-job.outputs.should_skip != 'true' }}
|
|
runs-on: ${{ matrix.info.os }}
|
|
timeout-minutes: 12
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
info:
|
|
- { os: "ubuntu-latest", target: "x86_64-unknown-linux-gnu" }
|
|
- { os: "macos-12", target: "x86_64-apple-darwin" }
|
|
- { os: "windows-2019", target: "x86_64-pc-windows-msvc" }
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
|
|
|
|
- name: Set up Rust toolchain
|
|
uses: dtolnay/rust-toolchain@21dc36fb71dd22e3317045c0c31a3f4249868b17
|
|
with:
|
|
toolchain: stable
|
|
|
|
- name: Enable Rust cache
|
|
uses: Swatinem/rust-cache@9bdad043e88c75890e36ad3bbc8d27f0090dd609 # 2.7.3
|
|
if: ${{ github.event_name != 'pull_request' || ! github.event.pull_request.head.repo.fork }} # If it is a PR, only if not a fork
|
|
with:
|
|
key: ${{ matrix.info.target }}
|
|
cache-all-crates: true
|
|
|
|
- name: Install cargo-llvm-cov
|
|
run: |
|
|
rustup component add llvm-tools-preview
|
|
cargo install cargo-llvm-cov --version 0.6.11 --locked
|
|
|
|
- name: Generate code coverage
|
|
run: |
|
|
cargo llvm-cov --all-features --workspace --lcov --output-path lcov.info --locked --target=${{ matrix.info.target }}
|
|
|
|
# The token is generally not needed, but sometimes the default shared token hits limits.
|
|
- name: Upload to codecov.io
|
|
uses: Wandalen/wretry.action@6feedb7dedadeb826de0f45ff482b53b379a7844 # v3.5.0
|
|
with:
|
|
action: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673 # v4.5.0
|
|
with: |
|
|
files: lcov.info
|
|
fail_ci_if_error: true
|
|
token: ${{ secrets.CODECOV_TOKEN }}
|
|
flags: ${{ matrix.info.os }}
|
|
attempt_limit: 5
|
|
attempt_delay: 1500
|