Skip to content

Commit 1d1f87c

Browse files
samuel-jimenezsylvestre
authored andcommitted
ci: Consolidate testing, coverage
1 parent 636662f commit 1d1f87c

File tree

1 file changed

+58
-96
lines changed

1 file changed

+58
-96
lines changed

.github/workflows/ci.yml

Lines changed: 58 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ jobs:
5656
- name: Check
5757
run: npx --yes @taplo/cli fmt --check
5858

59+
60+
5961
test:
6062
name: test ${{ matrix.os }} rust ${{ matrix.rustc || 'stable' }} ${{ matrix.extra_desc }}
6163
runs-on: ${{ matrix.os }}
@@ -91,6 +93,7 @@ jobs:
9193
rustc: "1.75.0"
9294
extra_desc: cuda12.8
9395
- os: macos-13
96+
no_coverage: true
9497
# # M1 CPU
9598
- os: macos-14
9699
- os: windows-2019
@@ -105,6 +108,7 @@ jobs:
105108
allow_failure: true
106109
extra_args: --features=unstable
107110
extra_desc: cuda11.8
111+
no_coverage: true
108112
- os: windows-2019
109113
cuda: "11.8"
110114
rustc: beta
@@ -125,8 +129,14 @@ jobs:
125129
cuda: "12.8"
126130
rustc: beta
127131
extra_desc: cuda12.8
132+
no_coverage: true
128133
env:
129134
RUST_BACKTRACE: 1
135+
COVERAGE_REPORT_DIR: "target/debug"
136+
COVERAGE_REPORT_FILE: "target/debug/lcov.info"
137+
BINARY_DIR: "target/debug"
138+
GRCOV_IGNORE_OPTION: '--ignore build.rs --ignore "/*" --ignore "[a-zA-Z]:/*"'
139+
GRCOV_EXCLUDE_OPTION: '--excl-br-line "^\s*((debug_)?assert(_eq|_ne)?!|#\[derive\()"'
130140
steps:
131141
- uses: ilammy/msvc-dev-cmd@v1
132142

@@ -137,6 +147,7 @@ jobs:
137147
uses: ./.github/actions/rust-toolchain
138148
with:
139149
toolchain: ${{ matrix.rustc }}
150+
components: llvm-tools-preview
140151

141152
- if: ${{ contains(matrix.os, 'ubuntu') }}
142153
name: Install gcc & clang for tests
@@ -161,18 +172,62 @@ jobs:
161172
with:
162173
cuda-version: ${{ matrix.cuda }}
163174

164-
- name: Build tests
165-
run: cargo test --no-run --locked --all-targets ${{ matrix.extra_args }}
175+
- name: "`grcov` ~ install"
176+
if: ${{ ! matrix.no_coverage }}
177+
run: cargo install grcov
178+
179+
- name: Create config for testing
180+
if: ${{ ! matrix.no_coverage }}
181+
run: |
182+
mkdir -p .cargo
183+
echo '[env]
184+
LLVM_PROFILE_FILE = { value = "target/debug/coverage/default-%p-%8m.profraw", relative = true }' >> .cargo/config.toml
185+
166186
167-
- name: Run tests
187+
- name: Execute tests
168188
run: cargo test --locked --all-targets ${{ matrix.extra_args }}
189+
env:
190+
CARGO_INCREMENTAL: "0"
191+
RUSTC_WRAPPER: ""
192+
RUSTFLAGS: "-Cinstrument-coverage -Ccodegen-units=1 -Copt-level=0 -Coverflow-checks=off"
169193

170194
- name: Upload failure
171195
if: failure()
172196
uses: ./.github/actions/artifact_failure
173197
with:
174198
name: test-${{ matrix.os }}-${{ matrix.rustc || 'stable' }}-${{ matrix.extra_desc }}
175199

200+
# coverage:
201+
- name: Display coverage files
202+
if: ${{ ! matrix.no_coverage }}
203+
shell: bash
204+
run:
205+
grcov . -s . --binary-path $BINARY_DIR --output-type files $GRCOV_IGNORE_OPTION $GRCOV_EXCLUDE_OPTION | sort --unique
206+
207+
- name: Generate coverage data (via `grcov`)
208+
if: ${{ ! matrix.no_coverage }}
209+
id: coverage
210+
shell: bash
211+
run: |
212+
mkdir -p "${COVERAGE_REPORT_DIR}"
213+
grcov . -s . --binary-path $BINARY_DIR --output-type lcov --output-path "${COVERAGE_REPORT_FILE}" --branch $GRCOV_IGNORE_OPTION $GRCOV_EXCLUDE_OPTION
214+
echo "report=${COVERAGE_REPORT_FILE}" >> $GITHUB_OUTPUT
215+
216+
- name: Upload coverage results (to Codecov.io)
217+
if: ${{ ! matrix.no_coverage }}
218+
uses: codecov/codecov-action@v5
219+
with:
220+
files: ${{ steps.coverage.outputs.report }}
221+
## flags: IntegrationTests, UnitTests, ${{ steps.vars.outputs.CODECOV_FLAGS }}
222+
flags: ${{ steps.vars.outputs.CODECOV_FLAGS }}
223+
name: codecov-umbrella-${{ matrix.os }}-rust_${{ matrix.rustc || 'stable' }}-${{ matrix.extra_desc }}
224+
fail_ci_if_error: true
225+
# verbose: true
226+
env:
227+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
228+
229+
230+
176231
build:
177232
name: build ${{ matrix.binary || 'sccache' }} ${{ matrix.target }}
178233
runs-on: ${{ matrix.os }}
@@ -245,99 +300,6 @@ jobs:
245300
path: target/${{ matrix.target }}/release/${{ matrix.binary || 'sccache' }}${{ endsWith(matrix.target, '-msvc') && '.exe' || '' }}
246301
if-no-files-found: error
247302

248-
coverage:
249-
name: coverage ${{ matrix.os }} rust ${{ matrix.rustc || 'stable' }} ${{ matrix.extra_desc }}
250-
runs-on: ${{ matrix.os }}
251-
continue-on-error: ${{ matrix.allow_failure || false }}
252-
timeout-minutes: 30
253-
strategy:
254-
fail-fast: false
255-
matrix:
256-
include:
257-
- os: ubuntu-22.04
258-
cuda: "11.8"
259-
rustc: nightly
260-
allow_failure: true
261-
extra_args: --features=unstable
262-
- os: ubuntu-22.04
263-
rustc: "1.75.0"
264-
extra_desc: dist-server
265-
extra_args: --no-default-features --features=dist-tests test_dist_ -- --test-threads 1
266-
- os: macos-13
267-
rustc: nightly
268-
# Disable on Windows for now as it fails with:
269-
# found invalid metadata files for crate `vte_generate_state_changes`
270-
# - os: windows-2019
271-
# rustc: nightly
272-
env:
273-
RUST_BACKTRACE: 1
274-
COVERAGE_REPORT_DIR: "target/debug"
275-
COVERAGE_REPORT_FILE: "target/debug/lcov.info"
276-
BINARY_DIR: "target/debug"
277-
GRCOV_IGNORE_OPTION: '--ignore build.rs --ignore "/*" --ignore "[a-zA-Z]:/*"'
278-
GRCOV_EXCLUDE_OPTION: '--excl-br-line "^\s*((debug_)?assert(_eq|_ne)?!|#\[derive\()"'
279-
steps:
280-
- name: Clone repository
281-
uses: actions/checkout@v4
282-
283-
- name: Install rust
284-
uses: ./.github/actions/rust-toolchain
285-
with:
286-
toolchain: ${{ matrix.rustc }}
287-
components: llvm-tools-preview
288-
289-
- name: Install gcc & clang for tests
290-
run: sudo apt-get install -y clang gcc
291-
if: ${{ matrix.os == 'ubuntu-20.04' }}
292-
293-
- if: matrix.cuda != '' && contains(fromJSON('["Linux", "Windows"]'), runner.os)
294-
name: Install nvcc
295-
uses: ./.github/actions/nvcc-toolchain
296-
with:
297-
cuda-version: ${{ matrix.cuda }}
298-
299-
- name: "`grcov` ~ install"
300-
run: cargo install grcov
301-
302-
- name: Create config for testing
303-
run: |
304-
mkdir -p .cargo
305-
echo '[env]
306-
LLVM_PROFILE_FILE = { value = "target/debug/coverage/default-%p-%8m.profraw", relative = true }' >> .cargo/config.toml
307-
308-
- name: Execute tests
309-
run: cargo test --no-fail-fast --locked --all-targets ${{ matrix.extra_args }}
310-
env:
311-
CARGO_INCREMENTAL: "0"
312-
RUSTC_WRAPPER: ""
313-
RUSTFLAGS: "-Cinstrument-coverage -Ccodegen-units=1 -Copt-level=0 -Coverflow-checks=off"
314-
315-
316-
- name: Display coverage files
317-
shell: bash
318-
run:
319-
grcov . -s . --binary-path $BINARY_DIR --output-type files $GRCOV_IGNORE_OPTION $GRCOV_EXCLUDE_OPTION | sort --unique
320-
321-
- name: Generate coverage data (via `grcov`)
322-
id: coverage
323-
shell: bash
324-
run: |
325-
mkdir -p "${COVERAGE_REPORT_DIR}"
326-
grcov . -s . --binary-path $BINARY_DIR --output-type lcov --output-path "${COVERAGE_REPORT_FILE}" --branch $GRCOV_IGNORE_OPTION $GRCOV_EXCLUDE_OPTION
327-
echo "report=${COVERAGE_REPORT_FILE}" >> $GITHUB_OUTPUT
328-
329-
330-
- name: Upload coverage results (to Codecov.io)
331-
uses: codecov/codecov-action@v5
332-
with:
333-
files: ${{ steps.coverage.outputs.report }}
334-
## flags: IntegrationTests, UnitTests, ${{ steps.vars.outputs.CODECOV_FLAGS }}
335-
flags: ${{ steps.vars.outputs.CODECOV_FLAGS }}
336-
name: codecov-umbrella
337-
fail_ci_if_error: false
338-
# verbose: true
339-
env:
340-
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
341303

342304
test_freebsd:
343305
name: test freebsd-14.1 rust stable

0 commit comments

Comments
 (0)