Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
144 lines
4.8 KiB
YAML
144 lines
4.8 KiB
YAML
# Run cargo-llvm-cov and upload to codecov.io
|
|
|
|
name: Pacquet Code Coverage
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
pull_request:
|
|
types: [opened, synchronize]
|
|
paths:
|
|
- 'pnpm/**/*.rs'
|
|
- 'pnpr/**/*.rs'
|
|
push:
|
|
branches:
|
|
- main
|
|
paths:
|
|
- 'pnpm/**/*.rs'
|
|
- 'pnpr/**/*.rs'
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: ${{ github.ref_name != 'main' }}
|
|
|
|
jobs:
|
|
coverage:
|
|
name: Code Coverage
|
|
runs-on: blacksmith-4vcpu-ubuntu-2404
|
|
# Build the instrumented artifacts with line-tables-only debug info, as
|
|
# `Rust CI / Test` does. Coverage regions live in the binary's own
|
|
# `__llvm_covmap`/`__llvm_covfun` sections, so llvm-cov needs no DWARF at
|
|
# all, while the full `--all-targets` debug build of the whole workspace
|
|
# (~70 crates plus heavy C deps like aws-lc-sys, ring, libsql-ffi and
|
|
# tree-sitter) is what pushes target/ over the runner's free disk. Line
|
|
# tables keep panic backtraces file:line-accurate. Set here in CI rather
|
|
# than in Cargo.toml so a local `just codecov` keeps full debug info.
|
|
env:
|
|
CARGO_PROFILE_DEV_DEBUG: line-tables-only
|
|
CARGO_PROFILE_TEST_DEBUG: line-tables-only
|
|
# A coverage run compiles the workspace from cold and then runs every
|
|
# test; the healthy runtime is ~8 minutes. Without this a wedged job
|
|
# would sit on the default 360-minute limit.
|
|
timeout-minutes: 60
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
with:
|
|
submodules: true # Pull submodules for `cargo coverage`
|
|
persist-credentials: false
|
|
|
|
# The instrumented build holds a full set of debug artifacts in
|
|
# target/llvm-cov-target, on top of a profraw file per test process and
|
|
# the merged profdata. That no longer fits in the runner's free disk:
|
|
# the job dies with "No space left on device" — often while the runner
|
|
# itself is writing its diagnostic log, so the failure lands with no
|
|
# step output at all. Drop the preinstalled toolchains this job never
|
|
# uses (~25 GB) before compiling anything.
|
|
- name: Free up runner disk space
|
|
run: |
|
|
sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc /opt/hostedtoolcache/CodeQL
|
|
df -h /
|
|
|
|
- name: Install Rust Toolchain
|
|
uses: ./.github/actions/rustup
|
|
|
|
- name: Install cargo-llvm-cov
|
|
uses: taiki-e/install-action@6a1bd70eaac3c8bdf093356838d7ee09fda951cf # v2.85.5
|
|
with:
|
|
tool: cargo-llvm-cov
|
|
|
|
- name: Install cargo-nextest
|
|
uses: taiki-e/install-action@6a1bd70eaac3c8bdf093356838d7ee09fda951cf # v2.85.5
|
|
with:
|
|
tool: cargo-nextest
|
|
|
|
- name: Install llvm-tools-preview for llvm-cov
|
|
run: rustup component add llvm-tools-preview
|
|
|
|
- name: Install pnpm (for compatibility check)
|
|
uses: pnpm/setup@6523ce966bcf7a1061ce6401e5c6e0b60466bd31
|
|
with:
|
|
install: false
|
|
|
|
- name: Cache pnpm
|
|
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
|
|
with:
|
|
key: codecov-pnpm-v11-${{ runner.os }}
|
|
path: |
|
|
${{ env.PNPM_HOME }}/store/v11
|
|
${{ env.HOME }}/.local/share/pnpm/store/v11
|
|
timeout-minutes: 1
|
|
continue-on-error: true
|
|
|
|
- name: Install just
|
|
uses: taiki-e/install-action@6a1bd70eaac3c8bdf093356838d7ee09fda951cf # v2.85.5
|
|
with:
|
|
tool: just
|
|
|
|
- name: Install dependencies
|
|
run: just install
|
|
|
|
- name: Run
|
|
run: |
|
|
# removing env vars is a temporary workaround for unit tests in pacquet relying on external environment
|
|
# this should be removed in the future
|
|
unset PNPM_HOME
|
|
unset XDG_DATA_HOME
|
|
|
|
cargo codecov --lcov --output-path lcov.info
|
|
|
|
- name: Report disk usage
|
|
if: always()
|
|
run: df -h /
|
|
|
|
- name: Upload Artifact
|
|
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
|
with:
|
|
name: codecov
|
|
path: lcov.info
|
|
|
|
# codecov often fails, use another workflow for retry
|
|
upload-codecov:
|
|
name: Upload coverage file
|
|
runs-on: blacksmith-4vcpu-ubuntu-2404
|
|
needs: coverage
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
with:
|
|
persist-credentials: false
|
|
|
|
- name: Download coverage file
|
|
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
|
|
with:
|
|
name: codecov
|
|
|
|
- name: Upload to codecov.io
|
|
uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7.0.0
|
|
with:
|
|
token: ${{ secrets.CODECOV_TOKEN }}
|
|
fail_ci_if_error: true
|
|
files: lcov.info
|