Files
pnpm/.github/workflows/pacquet-codecov.yml
Zoltan Kochanandgithub-actions[bot] 901f2438e0 chore: update dependencies, Node.js, pnpm, and GitHub Actions (#17217)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2026-10-23 10:35:07 +02:00

188 lines
6.7 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-8vcpu-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
# Main only restores compiler cache entries that main wrote.
SCCACHE_SCOPE: ${{ github.event.pull_request.number && format('pr{0}', github.event.pull_request.number) || github.ref_name }}
# 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@a4d3f3f761dcd95cce1b72cb61cb6d1963438177 # v2.87.30
with:
tool: cargo-llvm-cov
- name: Install Python for ecosystem tests
uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 #v7.1.0 v6
with:
python-version: '3.13'
- name: Install cargo-nextest
uses: taiki-e/install-action@a4d3f3f761dcd95cce1b72cb61cb6d1963438177 # v2.87.30
with:
tool: cargo-nextest,sccache@0.17.0
# Same compiler cache as the Rust test jobs (see pacquet-ci.yml), in its own
# entries because instrumented builds hash differently.
- name: Use sccache
run: |
{
echo "SCCACHE_DAY=$(date -u +%Y-%m-%d)"
echo "SCCACHE_DIR=$RUNNER_TEMP/sccache"
echo "SCCACHE_CACHE_SIZE=2G"
echo "SCCACHE_IDLE_TIMEOUT=0"
echo "RUSTC_WRAPPER=sccache"
echo "CARGO_INCREMENTAL=0"
} >> "$GITHUB_ENV"
- name: Restore sccache
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ${{ runner.temp }}/sccache
key: sccache-cov-v1-${{ runner.os }}-${{ env.SCCACHE_SCOPE }}-${{ env.SCCACHE_DAY }}
restore-keys: |
sccache-cov-v1-${{ runner.os }}-${{ env.SCCACHE_SCOPE }}-
sccache-cov-v1-${{ runner.os }}-main-
timeout-minutes: 2
continue-on-error: true
- name: Install llvm-tools-preview for llvm-cov
run: rustup component add llvm-tools-preview
- name: Install pnpm (for compatibility check)
uses: pnpm/setup@a0881977cd8ea73b1ed212236c99ca10dcc80cf4 # v3.1.1
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@a4d3f3f761dcd95cce1b72cb61cb6d1963438177 # v2.87.30
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
env PNPM_CONFIG_CI=false PNPM_CONFIG_UPDATE_NOTIFIER=false cargo codecov --lcov --output-path lcov.info
- name: Stop sccache
if: ${{ !cancelled() }}
run: sccache --stop-server || true
- name: Save sccache
if: ${{ !cancelled() }}
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ${{ runner.temp }}/sccache
key: sccache-cov-v1-${{ runner.os }}-${{ env.SCCACHE_SCOPE }}-${{ env.SCCACHE_DAY }}
timeout-minutes: 3
continue-on-error: true
- name: Report disk usage
if: always()
run: df -h /
- name: Upload Artifact
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
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@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: codecov
- name: Upload to codecov.io
uses: codecov/codecov-action@303a32d7a59b442fa8d48b6a1cc6825c09c847a5 # v7.1.1
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
files: lcov.info