2021-07-07 07:36:54 -07:00
|
|
|
name: Coverage
|
2021-02-16 11:05:27 -08:00
|
|
|
|
|
|
|
on:
|
2021-06-14 18:36:33 -07:00
|
|
|
workflow_dispatch:
|
2021-02-16 11:05:27 -08:00
|
|
|
pull_request:
|
|
|
|
branches:
|
|
|
|
- main
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- main
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
|
|
|
|
coverage:
|
|
|
|
name: Coverage (+nightly)
|
2021-11-25 08:26:32 -08:00
|
|
|
# The large timeout is to accommodate:
|
|
|
|
# - nightly builds (75 minutes, typically 30-50 minutes)
|
|
|
|
# - parameter downloads (40 minutes, but only when the cache expires)
|
|
|
|
timeout-minutes: 115
|
2021-02-16 14:56:12 -08:00
|
|
|
runs-on: ubuntu-latest
|
2021-11-19 15:02:56 -08:00
|
|
|
env:
|
|
|
|
CARGO_INCREMENTAL: 0
|
|
|
|
RUST_BACKTRACE: full
|
|
|
|
|
2021-02-16 11:05:27 -08:00
|
|
|
steps:
|
2021-11-04 22:08:39 -07:00
|
|
|
- uses: actions/checkout@v2.4.0
|
2021-05-16 16:32:38 -07:00
|
|
|
with:
|
|
|
|
persist-credentials: false
|
2021-02-16 11:05:27 -08:00
|
|
|
|
2021-06-14 18:35:26 -07:00
|
|
|
- uses: actions-rs/toolchain@v1.0.7
|
2021-02-16 11:05:27 -08:00
|
|
|
with:
|
2022-01-18 11:31:09 -08:00
|
|
|
# Pinned to workaround issue making cargo-llvm-cov fail, see
|
|
|
|
# https://github.com/taiki-e/cargo-llvm-cov/issues/128
|
|
|
|
# TODO: restore to just `nightly` after it's fixed
|
|
|
|
toolchain: nightly-2022-01-14
|
2021-02-16 11:05:27 -08:00
|
|
|
override: true
|
|
|
|
profile: minimal
|
|
|
|
components: llvm-tools-preview
|
|
|
|
|
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: |
|
|
|
|
echo "PROPTEST_CASES=1" >> $GITHUB_ENV
|
|
|
|
echo "PROPTEST_MAX_SHRINK_ITERS=0" >> $GITHUB_ENV
|
|
|
|
|
2021-11-19 15:02:56 -08:00
|
|
|
# Modified from:
|
|
|
|
# https://github.com/zcash/librustzcash/blob/c48bb4def2e122289843ddb3cb2984c325c03ca0/.github/workflows/ci.yml#L20-L33
|
|
|
|
- name: Fetch path to Zcash parameters
|
|
|
|
working-directory: ./zebra-consensus
|
|
|
|
shell: bash
|
|
|
|
# cargo-llvm-cov doesn't have a silent mode, so we have to extract the path from stderr
|
|
|
|
run: echo "ZCASH_PARAMS=$(cargo llvm-cov --lcov --no-report run --example get-params-path 2>&1 >/dev/null | tail -1)" >> $GITHUB_ENV
|
|
|
|
- name: Cache Zcash parameters
|
|
|
|
id: cache-params
|
|
|
|
uses: actions/cache@v2
|
|
|
|
with:
|
|
|
|
path: ${{ env.ZCASH_PARAMS }}
|
2021-11-25 08:26:32 -08:00
|
|
|
key: ${{ runner.os }}-sprout-and-sapling-params
|
2021-11-19 15:02:56 -08:00
|
|
|
- name: Fetch Zcash parameters
|
|
|
|
if: steps.cache-params.outputs.cache-hit != 'true'
|
|
|
|
working-directory: ./zebra-consensus
|
|
|
|
run: cargo llvm-cov --lcov --no-report run --example download-params
|
|
|
|
|
|
|
|
- name: Show env vars
|
|
|
|
run: |
|
2021-11-22 09:26:07 -08:00
|
|
|
echo "Test env vars:"
|
2021-11-19 15:02:56 -08:00
|
|
|
echo "ZEBRA_SKIP_NETWORK_TESTS=${{ env.ZEBRA_SKIP_NETWORK_TESTS }}"
|
|
|
|
echo "ZCASH_PARAMS=${{ env.ZCASH_PARAMS }}"
|
2021-11-22 09:26:07 -08:00
|
|
|
echo "PROPTEST_CASES=${{ env.PROPTEST_CASES }}"
|
|
|
|
echo "PROPTEST_MAX_SHRINK_ITERS=${{ env.PROPTEST_MAX_SHRINK_ITERS }}"
|
|
|
|
echo "Common env vars:"
|
|
|
|
echo "RUST_BACKTRACE=${{ env.RUST_BACKTRACE }}"
|
|
|
|
echo "Build env vars:"
|
2021-11-19 15:02:56 -08:00
|
|
|
echo "CARGO_INCREMENTAL=${{ env.CARGO_INCREMENTAL }}"
|
|
|
|
echo "CARGO_TARGET_DIR=${{ env.CARGO_TARGET_DIR }}"
|
|
|
|
|
|
|
|
- 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
|
2021-09-13 11:28:37 -07:00
|
|
|
uses: codecov/codecov-action@v2.1.0
|