2023-12-12 15:51:28 -08:00
|
|
|
# This workflow calculates the test coverage for the Rust codebase.
|
|
|
|
# 1. The code is checked out.
|
|
|
|
# 2. Rust with the stable toolchain, minimal profile, and llvm-tools-preview component is set up.
|
|
|
|
# 3. Necessary tools like 'cargo-llvm-cov' are installed.
|
|
|
|
# 4. Proptest is minimized for efficient coverage test runs.
|
|
|
|
# 5. Tests are run without producing a report to gather coverage information.
|
|
|
|
# 6. A coverage report (lcov format) is generated based on the gathered information.
|
|
|
|
# 7. Finally, this report is uploaded to Codecov for visualization and analysis.
|
2021-07-07 07:36:54 -07:00
|
|
|
name: Coverage
|
2021-02-16 11:05:27 -08:00
|
|
|
|
2022-08-29 17:11:05 -07:00
|
|
|
# Ensures that only one workflow task will run at a time. Previous builds, if
|
|
|
|
# already in process, will get cancelled. Only the latest commit will be allowed
|
|
|
|
# to run, cancelling any workflows in between
|
|
|
|
concurrency:
|
|
|
|
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
|
|
|
|
cancel-in-progress: true
|
|
|
|
|
2021-02-16 11:05:27 -08:00
|
|
|
on:
|
2021-06-14 18:36:33 -07:00
|
|
|
workflow_dispatch:
|
2023-10-24 16:27:24 -07:00
|
|
|
|
|
|
|
# we build Rust caches on main,
|
|
|
|
# so they can be shared by all branches:
|
|
|
|
# https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#restrictions-for-accessing-a-cache
|
2022-02-22 01:48:00 -08:00
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- main
|
|
|
|
paths:
|
2022-03-02 06:23:05 -08:00
|
|
|
# code and tests
|
2022-02-22 01:48:00 -08:00
|
|
|
- '**/*.rs'
|
2022-03-04 11:55:49 -08:00
|
|
|
# hard-coded checkpoints and proptest regressions
|
2022-02-22 01:48:00 -08:00
|
|
|
- '**/*.txt'
|
2022-03-02 06:23:05 -08:00
|
|
|
# test data snapshots
|
|
|
|
- '**/*.snap'
|
|
|
|
# dependencies
|
2022-02-22 01:48:00 -08:00
|
|
|
- '**/Cargo.toml'
|
|
|
|
- '**/Cargo.lock'
|
2022-08-26 11:06:32 -07:00
|
|
|
# configuration files
|
|
|
|
- '.cargo/config.toml'
|
|
|
|
- '**/clippy.toml'
|
2022-03-02 06:23:05 -08:00
|
|
|
# workflow definitions
|
2022-02-22 01:48:00 -08:00
|
|
|
- 'codecov.yml'
|
2023-10-17 23:16:02 -07:00
|
|
|
- '.github/workflows/ci-coverage.yml'
|
2023-10-24 16:27:24 -07:00
|
|
|
|
2021-02-16 11:05:27 -08:00
|
|
|
pull_request:
|
2022-02-11 06:05:19 -08:00
|
|
|
paths:
|
2022-01-25 03:58:11 -08:00
|
|
|
- '**/*.rs'
|
|
|
|
- '**/*.txt'
|
2022-03-02 06:23:05 -08:00
|
|
|
- '**/*.snap'
|
2022-01-25 03:58:11 -08:00
|
|
|
- '**/Cargo.toml'
|
|
|
|
- '**/Cargo.lock'
|
2023-01-24 08:27:56 -08:00
|
|
|
- '.cargo/config.toml'
|
|
|
|
- '**/clippy.toml'
|
2022-01-25 03:58:11 -08:00
|
|
|
- 'codecov.yml'
|
2023-10-17 23:16:02 -07:00
|
|
|
- '.github/workflows/ci-coverage.yml'
|
2021-02-16 11:05:27 -08:00
|
|
|
|
refactor (actions): make better use of variables, secrets and versions (#3393)
* style: use global variables and don't double print
Remove repeated instances of global environment variables. Do not print ENV variables on the terminal as GitHub Actions already shows it.
* fix (actions): Use fixed major versions for actions
As actions get recurrent fixes, using a specific version causes more maintance on the pipelines.
On the other hand, using @master versions could make some action unreliable, as breaking changes might be included without further notice, and even change behavior on a daily basis.
* refactor: make better use of ENV variables
A whole step with refex was being used to extract different variables from GitHub's environment. This gets depecrated in favor of using `rlespinasse/github-slug-action@v4` which has slug URL variables.
A SLUG on a variable will:
- put the variable content in lower case
- replace any character by - except 0-9, a-z, ., and _
- remove leading and trailing - character
- limit the string size to 63 characters
This changes also takes care of using the Head or Base branch for deployments. This will allow us tomerge of workflows, as most steps on this deployment actions are very similar, with little variations between workflows.
* fix (actions): use secrets for sensitive information
* revert: use specific versions for dependabot
Reverting commit 8c934099028e0651e464678c096d8d3815efe95c
2022-01-26 17:46:18 -08:00
|
|
|
env:
|
2023-04-12 23:56:21 -07:00
|
|
|
CARGO_INCREMENTAL: ${{ vars.CARGO_INCREMENTAL }}
|
|
|
|
RUST_LOG: ${{ vars.RUST_LOG }}
|
|
|
|
RUST_BACKTRACE: ${{ vars.RUST_BACKTRACE }}
|
|
|
|
RUST_LIB_BACKTRACE: ${{ vars.RUST_LIB_BACKTRACE }}
|
|
|
|
COLORBT_SHOW_HIDDEN: ${{ vars.COLORBT_SHOW_HIDDEN }}
|
refactor (actions): make better use of variables, secrets and versions (#3393)
* style: use global variables and don't double print
Remove repeated instances of global environment variables. Do not print ENV variables on the terminal as GitHub Actions already shows it.
* fix (actions): Use fixed major versions for actions
As actions get recurrent fixes, using a specific version causes more maintance on the pipelines.
On the other hand, using @master versions could make some action unreliable, as breaking changes might be included without further notice, and even change behavior on a daily basis.
* refactor: make better use of ENV variables
A whole step with refex was being used to extract different variables from GitHub's environment. This gets depecrated in favor of using `rlespinasse/github-slug-action@v4` which has slug URL variables.
A SLUG on a variable will:
- put the variable content in lower case
- replace any character by - except 0-9, a-z, ., and _
- remove leading and trailing - character
- limit the string size to 63 characters
This changes also takes care of using the Head or Base branch for deployments. This will allow us tomerge of workflows, as most steps on this deployment actions are very similar, with little variations between workflows.
* fix (actions): use secrets for sensitive information
* revert: use specific versions for dependabot
Reverting commit 8c934099028e0651e464678c096d8d3815efe95c
2022-01-26 17:46:18 -08:00
|
|
|
|
2021-02-16 11:05:27 -08:00
|
|
|
jobs:
|
|
|
|
coverage:
|
2022-05-25 17:28:02 -07:00
|
|
|
name: Coverage on stable
|
2021-11-25 08:26:32 -08:00
|
|
|
# The large timeout is to accommodate:
|
2023-10-24 16:27:24 -07:00
|
|
|
# - stable builds (typically 50-90 minutes), and
|
|
|
|
timeout-minutes: 120
|
2023-09-25 16:33:49 -07:00
|
|
|
runs-on: ubuntu-latest-xl
|
2021-11-19 15:02:56 -08:00
|
|
|
|
2021-02-16 11:05:27 -08:00
|
|
|
steps:
|
2024-07-10 11:49:09 -07:00
|
|
|
- uses: actions/checkout@v4.1.7
|
2021-05-16 16:32:38 -07:00
|
|
|
with:
|
|
|
|
persist-credentials: false
|
2021-02-16 11:05:27 -08:00
|
|
|
|
2023-05-10 07:25:41 -07:00
|
|
|
# Setup Rust with stable toolchain and minimal profile
|
|
|
|
- name: Setup Rust
|
|
|
|
run: |
|
|
|
|
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain=stable --profile=minimal --component=llvm-tools-preview
|
2021-02-16 11:05:27 -08:00
|
|
|
|
2021-06-14 18:35:26 -07:00
|
|
|
- name: Install cargo-llvm-cov cargo command
|
2021-08-27 08:03:40 -07:00
|
|
|
run: cargo install cargo-llvm-cov
|
2021-06-14 18:35:26 -07:00
|
|
|
|
2021-11-22 09:26:07 -08:00
|
|
|
- name: Skip network tests on Ubuntu
|
|
|
|
# Ubuntu runners don't have reliable network or DNS during test steps.
|
2021-11-19 15:02:56 -08:00
|
|
|
shell: bash
|
|
|
|
run: echo "ZEBRA_SKIP_NETWORK_TESTS=1" >> $GITHUB_ENV
|
|
|
|
|
2021-11-22 09:26:07 -08:00
|
|
|
- name: Minimise proptest cases in Coverage tests
|
|
|
|
# We set cases to 1, because some tests already run 1 case by default.
|
|
|
|
# We set maximum shrink iterations to 0, because we don't expect failures in these tests.
|
|
|
|
#
|
|
|
|
# Coverage tests are much slower than other tests, particularly in hot loops.
|
|
|
|
shell: bash
|
|
|
|
run: |
|
2022-04-11 22:06:37 -07:00
|
|
|
echo "PROPTEST_CASES=1" >> $GITHUB_ENV
|
|
|
|
echo "PROPTEST_MAX_SHRINK_ITERS=0" >> $GITHUB_ENV
|
2021-11-22 09:26:07 -08:00
|
|
|
|
2021-11-19 15:02:56 -08:00
|
|
|
- name: Run Zebra tests
|
|
|
|
run: cargo llvm-cov --lcov --no-report
|
|
|
|
|
|
|
|
- name: Generate coverage report
|
|
|
|
run: cargo llvm-cov --lcov --no-run --output-path lcov.info
|
2021-02-16 11:05:27 -08:00
|
|
|
|
|
|
|
- name: Upload coverage report to Codecov
|
2024-07-10 11:49:09 -07:00
|
|
|
uses: codecov/codecov-action@v4.5.0
|