Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(Help required) Tests for nextest partitions #274

Open
wants to merge 39 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 37 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
474a8a2
nextest profile
taiki-e May 3, 2023
02d8dee
test with artifacts from nextest --partition
TriplEight May 3, 2023
9362b6d
tidy happy
TriplEight May 3, 2023
0d84154
install llvm-cov
TriplEight May 3, 2023
cc4426c
nextest doesn't like --text?
TriplEight May 3, 2023
9cd12f1
debug then
TriplEight May 3, 2023
c29d197
debug more
TriplEight May 3, 2023
088fdc0
maybe workdir
TriplEight May 3, 2023
513d0ed
maybe workdir could be smarter
TriplEight May 3, 2023
8d197be
something weird with target dir
TriplEight May 3, 2023
e4a7d69
env
TriplEight May 3, 2023
2f3d169
borken download-artifacts
TriplEight May 3, 2023
9bdd2b1
new test
TriplEight May 4, 2023
968c041
copycat
TriplEight May 4, 2023
7bc9fda
copycat2
TriplEight May 4, 2023
cb368ac
debug
TriplEight May 4, 2023
9be7ec1
debug more
TriplEight May 4, 2023
6b5adca
move to root for more tests
TriplEight May 4, 2023
61ca252
analysis and test flags
TriplEight May 4, 2023
54f69ad
skip test in 1/2, restore archive in 2/3
TriplEight May 4, 2023
6e4ce6a
nightly
TriplEight May 4, 2023
4563d01
move second test to the default workspace; add explicit CARGO_LLVM_CO…
TriplEight May 4, 2023
e29e40f
put CARGO_LLVM_COV_TARGET_DIR into CARGO_TARGET_DIR as it fails tests
TriplEight May 4, 2023
5ae5903
remove working_dir
TriplEight May 4, 2023
8412675
remove working_dir paths
TriplEight May 4, 2023
acae45c
debug tests
TriplEight May 4, 2023
fb7b658
fix 2/3 .
TriplEight May 4, 2023
8b0af77
fix 2/3 with correct flags
TriplEight May 5, 2023
584c571
2/3 '--extract-to <DIR>' cannot be used multiple times, rm --all-feat…
TriplEight May 5, 2023
2850e60
2/3 '--extract-to <DIR>' cannot be used multiple times, s --all-featu…
TriplEight May 5, 2023
c0e44ff
rm --workspace --all-features from 2/3, add to 1/3
TriplEight May 5, 2023
b807e96
rm CARGO_LLVM_COV_TARGET_DIR
TriplEight May 5, 2023
d9dec86
2/3 extract-to
TriplEight May 5, 2023
edcdd04
2/3 extract-to non-target dir
TriplEight May 5, 2023
7394898
cleanup
TriplEight May 5, 2023
ecfda36
some comments edits
TriplEight May 5, 2023
b3a855c
cleanup
TriplEight May 5, 2023
87848cc
Update .github/workflows/ci.yml
TriplEight May 6, 2023
6400e1a
fix Rust installation according to review
TriplEight May 6, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
190 changes: 190 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ jobs:
set -euxo pipefail
cargo llvm-cov nextest --text
cargo llvm-cov nextest --text --profile default --cargo-profile dev
cargo llvm-cov nextest --text --profile ci
working-directory: tests/fixtures/crates/bin_crate
- run: |
set -euxo pipefail
Expand All @@ -87,6 +88,195 @@ jobs:
if: startsWith(matrix.rust, 'nightly')
- run: cargo minimal-versions build --workspace --all-features --ignore-private

llvm-cov-nextest-partitioned:
name: 1/2 Run tests and coverage with partitioning
runs-on: ubuntu-latest
strategy:
matrix:
partition: [1, 2]
env:
CARGO_TARGET_DIR: target
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true
components: llvm-tools-preview
TriplEight marked this conversation as resolved.
Show resolved Hide resolved
- name: Install nextest
uses: taiki-e/install-action@nextest
- name: Install llvm-cov
run: cargo install --path . --debug
- name: Run tests and coverage
# Reports from each partition will show only the partial coverage
run: |
set -euxo pipefail
cargo llvm-cov --color always --summary-only nextest --workspace --no-fail-fast --all-features --partition count:${{ matrix.partition }}/2
find $CARGO_TARGET_DIR -type d
tar czf llvm-cov-artifacts-${{ matrix.partition }}.tar.gz $CARGO_TARGET_DIR/llvm-cov-target
- name: Upload archive to workflow
uses: actions/upload-artifact@v3
with:
name: llvm-cov-artifacts
path: |
llvm-cov-artifacts-1.tar.gz
llvm-cov-artifacts-2.tar.gz

report-from-partitions:
name: 2/2 Collect coverage artifacts from partitions and generate the report
runs-on: ubuntu-latest
needs: llvm-cov-nextest-partitioned
env:
CARGO_TARGET_DIR: target
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
TriplEight marked this conversation as resolved.
Show resolved Hide resolved
with:
toolchain: nightly
override: true
components: llvm-tools-preview
- name: Install llvm-cov
run: cargo install --path . --debug
- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: llvm-cov-artifacts
- name: Run tests
# This is expected to show the full coverage
run: |
set -euxo pipefail
for i in {1..2}; do tar xzf llvm-cov-artifacts-$i.tar.gz -C . ; done
find $CARGO_TARGET_DIR -type d
cargo llvm-cov report --color always --summary-only
# Filename Regions Missed Regions Cover Functions Missed Functions Executed Lines Missed Lines Cover Branches Missed Branches Cover
# 1 TOTAL 2493 1127 54.79% 262 91 65.27% 2920 976 66.58% 0 0 -
# 2 TOTAL 2493 1264 49.30% 262 101 61.45% 2920 1134 61.16% 0 0 -
# 2/2 TOTAL 2493 963 61.37% 262 69 73.66% 2920 754 74.18% 0 0 -

nextest-archive:
name: 1/3 Build nextest artifacts
runs-on: ubuntu-latest
env:
CARGO_TARGET_DIR: target
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
TriplEight marked this conversation as resolved.
Show resolved Hide resolved
with:
toolchain: nightly
override: true
- name: Install nextest
uses: taiki-e/install-action@nextest
- name: Build and archive tests
run: |
set -euxo pipefail
cargo nextest archive --color always --workspace --all-features --archive-file nextest-artifacts.tar.zst
find $CARGO_TARGET_DIR -type d
tar tvf nextest-artifacts.tar.zst
- name: Upload archive to workflow
uses: actions/upload-artifact@v3
with:
name: nextest-artifacts
path: nextest-artifacts.tar.zst

llvm-cov-nextest-archive-partitioned:
name: 2/3 Run tests and coverage with partitioning on archived nextest artifacts
runs-on: ubuntu-latest
needs: nextest-archive
strategy:
matrix:
partition: [1, 2]
env:
CARGO_TARGET_DIR: target
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
TriplEight marked this conversation as resolved.
Show resolved Hide resolved
with:
toolchain: nightly
override: true
components: llvm-tools-preview
- name: Install nextest
uses: taiki-e/install-action@nextest
- name: Install llvm-cov
# workaround https://github.com/taiki-e/cargo-llvm-cov/issues/265 with https://github.com/TriplEight/cargo-llvm-cov/pull/1
# run: cargo install --path . --debug
run: cargo install -f --git https://github.com/TriplEight/cargo-llvm-cov cargo-llvm-cov --rev a9ada936f2c3da5d759145ebe6a5b9a38593f104
- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: nextest-artifacts
- name: Run tests and coverage
# Reports from each partition will show only the partial coverage
#
# this is supposed to be the test of llvm-cov generating coverage from the nextest archive, but it fails with
#
# 1. with --text flag (cargo llvm-cov --text nextest --archive-file nextest-artifacts.tar.zst --partition count:${{ matrix.partition }}/2) :
# error: no input files specified. See llvm-profdata merge -help
# error: failed to merge profile data: process didn't exit successfully:
# `/home/runner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin/llvm-profdata
# merge -sparse -f /home/runner/work/cargo-llvm-cov/cargo-llvm-cov/tests/fixtures/crates/bin_crate/target/llvm-cov-target/bin_crate-profraw-list
# -o /home/runner/work/cargo-llvm-cov/cargo-llvm-cov/tests/fixtures/crates/bin_crate/target/llvm-cov-target/bin_crate.profdata` (exit status: 1)
# which is weird because the (first) command should be nextest reading the archive.
#
# 2. without --text flag (cargo llvm-cov nextest --archive-file nextest-artifacts.tar.zst --partition count:${{ matrix.partition }}/2) :
# Caused by:
# No such file or directory (os error 2)', tests/test.rs:223:14 (maybe https://github.com/nextest-rs/nextest/issues/260?)
# ...
# error: test run failed
# error: process didn't exit successfully:
# `/home/runner/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/cargo nextest run
# --manifest-path /home/runner/work/cargo-llvm-cov/cargo-llvm-cov/Cargo.toml
# --extract-to /home/runner/work/cargo-llvm-cov/cargo-llvm-cov/target/llvm-cov-target
# --archive-file nextest-artifacts.tar.zst --partition 'count:1/2'` (exit status: 100)
# Which is weird: target/llvm-cov-target is not the expected place for the nextest artifacts, they should go to target/nextest and target/debug.
# And I couldn't change it by assigning a custom CARGO_TARGET_DIR and CARGO_LLVM_COV_TARGET_DIR.
# Also I tried to set a custom --extract-to to override the default-who-knows-where-it-comes-from
# --extract-to value that appears when I use --archive-file, like this:
# --extract-to /home/runner/work/cargo-llvm-cov/cargo-llvm-cov/target/llvm-cov-target
# but got an
# error: the argument '--extract-to <DIR>' cannot be used multiple times
#
# I assume https://github.com/taiki-e/cargo-llvm-cov/issues/265 should be improved to fix this.
run: |
set -euxo pipefail
cargo llvm-cov show-env
cargo llvm-cov --color always --summary-only nextest --no-fail-fast --archive-file nextest-artifacts.tar.zst --extract-to nextest-artifacts --partition count:${{ matrix.partition }}/2
find $CARGO_TARGET_DIR -type d
tar czvf llvm-cov-artifacts-${{ matrix.partition }}.tar.gz $CARGO_TARGET_DIR/llvm-cov-target
- name: Upload archive to workflow
uses: actions/upload-artifact@v3
with:
name: llvm-cov-archive-artifacts
path: |
llvm-cov-artifacts-1.tar.gz
llvm-cov-artifacts-2.tar.gz

report-from-archive-partitions:
name: 3/3 Collect artifacts from partitions and generate the report
runs-on: ubuntu-latest
needs: llvm-cov-nextest-archive-partitioned
env:
CARGO_TARGET_DIR: target
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
TriplEight marked this conversation as resolved.
Show resolved Hide resolved
with:
toolchain: nightly
override: true
components: llvm-tools-preview
- name: Install llvm-cov
run: cargo install --path . --debug
- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: llvm-cov-archive-artifacts
- name: Run tests
# This is expected to show the full coverage
run: |
set -euxo pipefail
for i in {1..2}; do tar xzf llvm-cov-artifacts-$i.tar.gz -C . ; done
find $CARGO_TARGET_DIR -type d
cargo llvm-cov report --color always --summary-only

build:
name: build (${{ matrix.target }})
env:
Expand Down
1 change: 1 addition & 0 deletions tests/fixtures/crates/bin_crate/.config/nextest.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[profile.ci]