Build + Test Code Coverage #144
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: manually remove gcloud | |
shell: bash | |
run: | | |
gcloud_sdk_root=$(gcloud info --format='value(installation.sdk_root)') | |
gcloud_global_config=$(gcloud info --format='value(config.paths.global_config_dir)') | |
echo "will remove directory : $gcloud_sdk_root" | |
echo "will remove directory : $gcloud_global_config" | |
sudo rm -fr $gcloud_sdk_root | |
sudo rm -fr $gcloud_global_config | |
- name: same as 'large-packages' but without 'google-cloud-sdk' | |
shell: bash | |
run: | | |
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-chrome-stable firefox powershell mono-devel libgl1-mesa-dri | |
sudo apt-get autoremove -y | |
sudo apt-get clean | |
- name: Free Disk Space | |
uses: jlumbroso/free-disk-space@main | |
with: | |
tool-cache: true | |
large-packages: false | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@stable | |
with: | |
components: llvm-tools-preview | |
- uses: taiki-e/install-action@cargo-llvm-cov | |
- uses: taiki-e/install-action@nextest | |
- uses: Swatinem/rust-cache@v2 | |
- 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 | |
env: | |
MIN_TPS: 3 | |
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 | |
echo $${{matrix.args}} | xargs cargo llvm-cov nextest --features=nimiq-zkp-component/test-prover | |
# Fixme: --doctest is not supported in stable. See: | |
# https://github.com/taiki-e/cargo-llvm-cov/tree/7448e48b438797efb446a98ebd8ff22d3fae5ebe#known-limitations | |
# run: cargo llvm-cov --features=nimiq-zkp-component/test-prover --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@v4 | |
env: | |
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | |
with: | |
files: coverage.lcov | |
fail_ci_if_error: true | |
flags: unittests | |
name: Nimiq code coverage | |
verbose: true | |