Repository navigation
130 lines (120 loc) · 4.81 KB
/
Copy pathnvx-coverage.yml
File metadata and controls
130 lines (120 loc) · 4.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
name: nvx coverage
# Measures which code of the nvx crate its own tests reach, on Linux and
# Windows, with scripts/nvx_coverage.py (doc/ci.md, "nvx coverage"). It
# runs for the pushes to dev and the ready pull requests that change the crate
# or how it is measured, and on demand. A pull request's summary also lists the
# lines of production code that it adds or changes and that no test reaches.
# Draft pull requests skip it, as they skip CI's other jobs, and no required
# check depends on it.
on:
push:
branches:
- dev
paths:
- nvx/**
- rust-toolchain.toml
- scripts/nvx_coverage.py
- scripts/setup/tool-versions.conf
- .github/workflows/nvx-coverage.yml
# As in ci.yml, a pull request runs for any base, so that one stacked on
# another pull request's branch lists the lines of its own changes.
pull_request:
types:
- opened
- synchronize
- reopened
- ready_for_review
paths:
- nvx/**
- rust-toolchain.toml
- scripts/nvx_coverage.py
- scripts/setup/tool-versions.conf
- .github/workflows/nvx-coverage.yml
workflow_dispatch:
permissions:
contents: read
# A push replaces the measurement of an earlier push to the same branch or pull
# request that is still running.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
measure:
name: measure / ${{ matrix.os }}
if: github.event_name != 'pull_request' || github.event.pull_request.draft == false
runs-on: ${{ matrix.os }}
timeout-minutes: 90
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
steps:
# A pull request measures its head, rather than its merge with its base,
# so that the summary names the lines of its own changes, and fetches the
# history that their merge base needs. The expression gives a pull request
# the string '0', which, unlike the number 0, is truthy.
- name: Checkout
uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5.1.0
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: ${{ github.event_name == 'pull_request' && '0' || '1' }}
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
with:
python-version: "3.12"
# The Rust release that rust-toolchain.toml pins, and the cargo-llvm-cov
# release that the setup tool manifest pins.
- name: Resolve the pinned tools
id: tools
shell: bash
run: |
set -euo pipefail
toolchain=$(sed -n 's/^channel = "\([^"]*\)".*/\1/p' rust-toolchain.toml)
cargo_llvm_cov=$(sed -n 's/^cargo_llvm_cov\.version=//p' \
scripts/setup/tool-versions.conf)
test -n "${toolchain}"
test -n "${cargo_llvm_cov}"
{
echo "toolchain=${toolchain}"
echo "cargo_llvm_cov=${cargo_llvm_cov}"
} >> "${GITHUB_OUTPUT}"
- name: Install Rust, its llvm-tools, and cargo-llvm-cov
shell: bash
env:
TOOLCHAIN: ${{ steps.tools.outputs.toolchain }}
CARGO_LLVM_COV: ${{ steps.tools.outputs.cargo_llvm_cov }}
run: |
set -euo pipefail
rustup toolchain install "${TOOLCHAIN}" --profile minimal --component llvm-tools
cargo "+${TOOLCHAIN}" install --locked cargo-llvm-cov --version "${CARGO_LLVM_COV}"
# Fails when the measurement misses something, such as what tests that
# failed twice would have reached, after it writes the reports. For a
# pull request, the summary also lists the lines of production code that
# it adds or changes since its merge base with its base and that no test
# reaches.
- name: Measure
shell: bash
env:
BASE: ${{ github.event.pull_request.base.sha }}
run: |
set -euo pipefail
options=(--output build/nvx-coverage)
if [[ -n "${BASE}" ]]; then
options+=(--base "${BASE}")
fi
python scripts/nvx_coverage.py "${options[@]}"
- name: Write the summary
if: ${{ !cancelled() && hashFiles('build/nvx-coverage/summary.md') != '' }}
shell: bash
run: cat build/nvx-coverage/summary.md >> "${GITHUB_STEP_SUMMARY}"
# A rerun of the job replaces the reports of its earlier attempt.
- name: Upload the reports
if: ${{ !cancelled() && hashFiles('build/nvx-coverage/**') != '' }}
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: nvx-coverage-${{ runner.os }}-${{ github.run_id }}
path: build/nvx-coverage
if-no-files-found: error
overwrite: true
retention-days: 30