Skip to content

Build + Test Code Coverage #52

Build + Test Code Coverage

Build + Test Code Coverage #52

Workflow file for this run

name: Build + Test Code Coverage
on:
schedule:
- cron: '0 12 * * 0' # run on Sundays at 12
workflow_dispatch:
jobs:
Run:
strategy:
fail-fast: false
matrix:
test:
- CodeCov1
- CodeCov2
include:
- test: CodeCov1
args: first_half
- test: CodeCov2
args: second_half
runs-on: ubuntu-22.04
steps:
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@main
with:
# this might remove tools that are actually needed,
# if set to "true" but frees about 6 GB
tool-cache: true
# all of these default to true, but feel free to set to
# "false" if necessary for your workflow
android: true
dotnet: true
haskell: true
large-packages: false
swap-storage: true
- name: Remove large packages
run: |
sudo apt-get remove -y '^dotnet-.*'
sudo apt-get remove -y 'php.*'
sudo apt-get remove -y '^mongodb-.*'
sudo apt-get remove -y '^mysql-.*'
sudo apt-get remove -y azure-cli google-cloud-sdk google-chrome-stable firefox powershell mono-devel libgl1-mesa-dri
sudo apt-get autoremove -y
sudo apt-get clean
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
components: llvm-tools-preview
- uses: taiki-e/install-action@cargo-llvm-cov
- uses: taiki-e/install-action@nextest
- uses: Swatinem/rust-cache@v2
- name: Install Protoc
run: sudo apt-get install protobuf-compiler
- name: Remove possible stale artifacts
run: cargo llvm-cov clean --workspace
- name: Disk Space
run: df -h /
- name: Run test with coverage instrumentation
shell: bash
run: |
set +o pipefail
# fetch all package names
pkg_names=($(cargo build -p 2>&1 | grep ' ' | cut -c 5-))
# find the middle package index
num_pkgs=${#pkg_names[@]}
half_pkgs=$(expr $num_pkgs / 2)
# sets the packages to run for both code cov runs
first_half=${pkg_names[@]:0:$half_pkgs}
second_half=${pkg_names[@]:$half_pkgs:$num_pkgs}
first_half=$(echo $first_half | xargs printf -- '-p %s\n')
second_half=$(echo $second_half | xargs printf -- '-p %s\n')
echo $first_half
echo $second_half
set -o pipefail
NEXTEST_TEST_THREADS=1 echo $${{matrix.args}} | xargs cargo llvm-cov nextest --all-features
# Fixme: --doctest is not supported in stable. See:
# https://github.com/taiki-e/cargo-llvm-cov/tree/7448e48b438797efb446a98ebd8ff22d3fae5ebe#known-limitations
# run: cargo llvm-cov --all-features --doctests
- name: Disk Space
run: df -h /
- name: Generate coverage report
run: cargo llvm-cov report --lcov --output-path coverage.lcov
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
files: coverage.lcov
fail_ci_if_error: false
flags: unittests
name: Nimiq code coverage
verbose: true