Skip to content

Commit 7b0e4e8

Browse files
committed
dev
1 parent 3f21ce8 commit 7b0e4e8

File tree

4 files changed

+174
-94
lines changed

4 files changed

+174
-94
lines changed

.github/workflows/ci.yml

Lines changed: 163 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -25,114 +25,186 @@ env:
2525

2626
defaults:
2727
run:
28-
shell: bash
28+
shell: bash --noprofile --norc -CeEuxo pipefail {0}
2929

3030
concurrency:
3131
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
3232
cancel-in-progress: true
3333

3434
jobs:
35-
deny:
36-
uses: taiki-e/github-actions/.github/workflows/deny.yml@main
37-
miri:
38-
uses: taiki-e/github-actions/.github/workflows/miri.yml@main
39-
msrv:
40-
uses: taiki-e/github-actions/.github/workflows/msrv.yml@main
41-
with:
42-
event_name: ${{ github.event_name }}
43-
release-dry-run:
44-
uses: taiki-e/github-actions/.github/workflows/release-dry-run.yml@main
45-
tidy:
46-
uses: taiki-e/github-actions/.github/workflows/tidy.yml@main
35+
# deny:
36+
# uses: taiki-e/github-actions/.github/workflows/deny.yml@main
37+
# miri:
38+
# uses: taiki-e/github-actions/.github/workflows/miri.yml@main
39+
# msrv:
40+
# uses: taiki-e/github-actions/.github/workflows/msrv.yml@main
41+
# with:
42+
# event_name: ${{ github.event_name }}
43+
# release-dry-run:
44+
# uses: taiki-e/github-actions/.github/workflows/release-dry-run.yml@main
45+
# tidy:
46+
# uses: taiki-e/github-actions/.github/workflows/tidy.yml@main
4747

48-
test:
48+
# test:
49+
# strategy:
50+
# fail-fast: false
51+
# matrix:
52+
# include:
53+
# # TODO: nightly-2023-04-27 (https://github.com/rust-lang/rust/pull/97368)
54+
# # and nightly-2023-05-03 (https://github.com/rust-lang/rust/pull/111042)
55+
# # fixed bugs in report generation, so the latest report is not the
56+
# # same as the old report.
57+
# # - rust: '1.60'
58+
# - rust: stable
59+
# - rust: beta
60+
# - rust: nightly
61+
# - rust: nightly
62+
# os: macos-latest
63+
# - rust: nightly
64+
# os: windows-latest
65+
# runs-on: ${{ matrix.os || 'ubuntu-latest' }}
66+
# timeout-minutes: 60
67+
# steps:
68+
# - uses: taiki-e/checkout-action@v1
69+
# - name: Install Rust
70+
# run: rustup toolchain add "${{ matrix.rust }}" --no-self-update && rustup default "${{ matrix.rust }}"
71+
# - run: rustup toolchain add nightly --no-self-update
72+
# - uses: taiki-e/install-action@cargo-hack
73+
# - uses: taiki-e/install-action@cargo-minimal-versions
74+
# - uses: taiki-e/install-action@nextest
75+
# - run: cargo test --workspace --all-features
76+
# # TODO: move this test to tests/test.rs
77+
# - run: cargo install --path . --debug
78+
# - name: Test cargo llvm-cov nextest
79+
# run: |
80+
# cargo llvm-cov nextest --text --fail-under-lines 50
81+
# cargo llvm-cov nextest --text --fail-under-lines 50 --profile default --cargo-profile dev
82+
# cargo llvm-cov nextest --text --fail-under-lines 50 --profile ci
83+
# cargo llvm-cov nextest --text --fail-under-lines 50 --profile ci --cargo-profile dev
84+
# cd -- ../real1
85+
# cargo llvm-cov nextest-archive --archive-file a.tar.zst
86+
# cargo llvm-cov nextest --archive-file a.tar.zst --text --fail-under-lines 70
87+
# cargo llvm-cov report --nextest-archive-file a.tar.zst --fail-under-lines 70
88+
# rm -- a.tar.zst
89+
# cargo clean
90+
# cargo llvm-cov nextest-archive --archive-file a.tar.zst --release
91+
# cargo llvm-cov nextest --archive-file a.tar.zst --text --fail-under-lines 70
92+
# cargo llvm-cov report --nextest-archive-file a.tar.zst --fail-under-lines 70
93+
# rm -- a.tar.zst
94+
# cargo clean
95+
# cargo llvm-cov nextest-archive --archive-file a.tar.zst --cargo-profile custom
96+
# cargo llvm-cov nextest --archive-file a.tar.zst --text --fail-under-lines 70
97+
# cargo llvm-cov report --nextest-archive-file a.tar.zst --fail-under-lines 70
98+
# rm -- a.tar.zst
99+
# cargo clean
100+
# host=$(rustc -vV | grep -E '^host:' | cut -d' ' -f2)
101+
# cargo llvm-cov nextest-archive --archive-file a.tar.zst --target "${host}"
102+
# cargo llvm-cov nextest --archive-file a.tar.zst --text --fail-under-lines 70
103+
# cargo llvm-cov report --nextest-archive-file a.tar.zst --fail-under-lines 70
104+
# working-directory: tests/fixtures/crates/bin_crate
105+
# - name: Test nightly-specific options, old Cargo compatibility, trybuild compatibility
106+
# run: |
107+
# unset RUSTFLAGS
108+
109+
# # Test nightly-specific options
110+
# git clone https://github.com/taiki-e/easytime.git
111+
# pushd -- easytime >/dev/null
112+
# git checkout 7ecb6e6
113+
# cargo llvm-cov test --doctests --text --fail-under-lines 30
114+
# popd >/dev/null
115+
# pushd -- tests/fixtures/crates/cargo_config >/dev/null
116+
# # TODO: --fail-under-branches?
117+
# cargo llvm-cov test --branch --text --fail-under-lines 80
118+
# popd >/dev/null
119+
# pushd -- easytime >/dev/null
120+
# cargo llvm-cov test --branch --doctests --text --fail-under-lines 30
121+
# popd >/dev/null
122+
123+
# # Test minimum runnable Cargo version.
124+
# rustup toolchain add 1.60 --no-self-update
125+
# pushd -- easytime >/dev/null
126+
# cargo +1.60 llvm-cov test --text --fail-under-lines 30
127+
# popd >/dev/null
128+
129+
# # Test trybuild compatibility.
130+
# git clone --depth 1 https://github.com/taiki-e/easy-ext.git
131+
# pushd -- easy-ext >/dev/null
132+
# cargo llvm-cov --text --test compiletest --fail-under-lines 70
133+
# popd >/dev/null
134+
# if: startsWith(matrix.rust, 'nightly')
135+
# - run: cargo hack build --workspace --no-private --feature-powerset --no-dev-deps
136+
# - run: cargo minimal-versions build --workspace --no-private --detach-path-deps=skip-exact --all-features
137+
138+
test-llvm:
49139
strategy:
50140
fail-fast: false
51141
matrix:
52142
include:
53-
# TODO: nightly-2023-04-27 (https://github.com/rust-lang/rust/pull/97368)
54-
# and nightly-2023-05-03 (https://github.com/rust-lang/rust/pull/111042)
55-
# fixed bugs in report generation, so the latest report is not the
56-
# same as the old report.
57-
# - rust: '1.60'
58-
- rust: stable
59-
- rust: beta
60-
- rust: nightly
61-
- rust: nightly
62-
os: macos-latest
63-
- rust: nightly
64-
os: windows-latest
65-
runs-on: ${{ matrix.os || 'ubuntu-latest' }}
143+
# LLVM versions of official builds:
144+
# LLVM 14 1.60-1.64
145+
# LLVM 15 1.65-1.69
146+
# LLVM 16 1.70-1.72
147+
# LLVM 17 1.73-1.77
148+
# LLVM 18 1.78-
149+
# Rust 1.60's the minimum external LLVM version, but
150+
# https://github.com/rust-lang/rust/blob/1.60.0/src/bootstrap/native.rs#L403
151+
# - llvm: '12'
152+
# - llvm: '13'
153+
- llvm: '14'
154+
- llvm: '15'
155+
- llvm: '16'
156+
- llvm: '17'
157+
- llvm: '18'
158+
runs-on: ubuntu-latest
66159
timeout-minutes: 60
67160
steps:
68161
- uses: taiki-e/checkout-action@v1
69162
- name: Install Rust
70-
run: rustup toolchain add ${{ matrix.rust }} --no-self-update && rustup default ${{ matrix.rust }}
71-
- run: rustup toolchain add nightly --no-self-update
72-
- uses: taiki-e/install-action@cargo-hack
73-
- uses: taiki-e/install-action@cargo-minimal-versions
74-
- uses: taiki-e/install-action@nextest
75-
- run: cargo test --workspace --all-features
76-
# TODO: move this test to tests/test.rs
163+
run: rustup update stable --no-self-update
164+
- name: Install LLVM
165+
run: |
166+
if type -P clang-"${{ matrix.llvm }}" &>/dev/null; then
167+
exit 0
168+
fi
169+
codename=$(grep -E '^VERSION_CODENAME=' /etc/os-release | cut -d= -f2)
170+
sudo mkdir -pm755 -- /etc/apt/keyrings
171+
curl --proto '=https' --tlsv1.2 -fsSL --retry 10 --retry-connrefused https://apt.llvm.org/llvm-snapshot.gpg.key \
172+
| gpg --dearmor \
173+
| sudo tee -- /etc/apt/keyrings/llvm-snapshot.gpg >/dev/null
174+
echo "deb [signed-by=/etc/apt/keyrings/llvm-snapshot.gpg] http://apt.llvm.org/${codename}/ llvm-toolchain-${codename}-${{ matrix.llvm }} main" \
175+
| sudo tee -- "/etc/apt/sources.list.d/llvm-toolchain-${codename}-${{ matrix.llvm }}.list" >/dev/null
176+
sudo apt-get -o Acquire::Retries=10 -qq update
177+
apt_packages=(
178+
clang-"${{ matrix.llvm }}"
179+
libc++-"${{ matrix.llvm }}"-dev
180+
libc++abi-"${{ matrix.llvm }}"-dev
181+
libclang-"${{ matrix.llvm }}"-dev
182+
lld-"${{ matrix.llvm }}"
183+
llvm-"${{ matrix.llvm }}"
184+
llvm-"${{ matrix.llvm }}"-dev
185+
)
186+
if ! sudo apt-get -o Acquire::Retries=10 -o Dpkg::Use-Pty=0 install -y --no-install-recommends "${apt_packages[@]}"; then
187+
sudo apt-get -o Acquire::Retries=10 -o Dpkg::Use-Pty=0 upgrade -y
188+
sudo apt-get -o Acquire::Retries=10 -o Dpkg::Use-Pty=0 install -y --no-install-recommends "${apt_packages[@]}"
189+
fi
77190
- run: cargo install --path . --debug
78-
- name: Test cargo llvm-cov nextest
191+
- name: Test
79192
run: |
80-
set -eEuxo pipefail
81-
cargo llvm-cov nextest --text --fail-under-lines 50
82-
cargo llvm-cov nextest --text --fail-under-lines 50 --profile default --cargo-profile dev
83-
cargo llvm-cov nextest --text --fail-under-lines 50 --profile ci
84-
cargo llvm-cov nextest --text --fail-under-lines 50 --profile ci --cargo-profile dev
85-
cd ../real1
86-
cargo llvm-cov nextest-archive --archive-file a.tar.zst
87-
cargo llvm-cov nextest --archive-file a.tar.zst --text --fail-under-lines 70
88-
cargo llvm-cov report --nextest-archive-file a.tar.zst --fail-under-lines 70
89-
rm a.tar.zst
193+
export CC="clang-${{ matrix.llvm }}"
194+
export CXX="clang++-${{ matrix.llvm }}"
195+
export LLVM_COV="llvm-cov-${{ matrix.llvm }}"
196+
export LLVM_PROFDATA="llvm-profdata-${{ matrix.llvm }}"
197+
rustup toolchain add 1.60 1.65 1.70 1.73 1.77 1.78 --no-self-update
90198
cargo clean
91-
cargo llvm-cov nextest-archive --archive-file a.tar.zst --release
92-
cargo llvm-cov nextest --archive-file a.tar.zst --text --fail-under-lines 70
93-
cargo llvm-cov report --nextest-archive-file a.tar.zst --fail-under-lines 70
94-
rm a.tar.zst
199+
cargo +1.60 llvm-cov test --text --include-ffi --fail-under-lines 70 -vv
95200
cargo clean
96-
cargo llvm-cov nextest-archive --archive-file a.tar.zst --cargo-profile custom
97-
cargo llvm-cov nextest --archive-file a.tar.zst --text --fail-under-lines 70
98-
cargo llvm-cov report --nextest-archive-file a.tar.zst --fail-under-lines 70
99-
rm a.tar.zst
201+
cargo +1.65 llvm-cov test --text --include-ffi --fail-under-lines 70 -vv
100202
cargo clean
101-
host=$(rustc -vV | grep '^host:' | cut -d' ' -f2)
102-
cargo llvm-cov nextest-archive --archive-file a.tar.zst --target "${host}"
103-
cargo llvm-cov nextest --archive-file a.tar.zst --text --fail-under-lines 70
104-
cargo llvm-cov report --nextest-archive-file a.tar.zst --fail-under-lines 70
105-
working-directory: tests/fixtures/crates/bin_crate
106-
- name: Test nightly-specific options, old Cargo compatibility, trybuild compatibility
107-
run: |
108-
set -eEuxo pipefail
109-
unset RUSTFLAGS
110-
111-
# Test nightly-specific options
112-
git clone https://github.com/taiki-e/easytime.git
113-
pushd easytime >/dev/null
114-
git checkout 7ecb6e6
115-
cargo llvm-cov test --doctests --text --fail-under-lines 30
116-
popd >/dev/null
117-
pushd tests/fixtures/crates/cargo_config >/dev/null
118-
# TODO: --fail-under-branches?
119-
cargo llvm-cov test --branch --text --fail-under-lines 80
120-
popd >/dev/null
121-
pushd easytime >/dev/null
122-
cargo llvm-cov test --branch --doctests --text --fail-under-lines 30
123-
popd >/dev/null
124-
125-
# Test minimum runnable Cargo version.
126-
rustup toolchain add 1.60 --no-self-update
127-
pushd easytime >/dev/null
128-
cargo +1.60 llvm-cov test --text --fail-under-lines 30
129-
popd >/dev/null
130-
131-
# Test trybuild compatibility.
132-
git clone --depth 1 https://github.com/taiki-e/easy-ext.git
133-
pushd easy-ext >/dev/null
134-
cargo llvm-cov --text --test compiletest --fail-under-lines 70
135-
popd >/dev/null
136-
if: startsWith(matrix.rust, 'nightly')
137-
- run: cargo hack build --workspace --no-private --feature-powerset --no-dev-deps
138-
- run: cargo minimal-versions build --workspace --no-private --detach-path-deps=skip-exact --all-features
203+
cargo +1.70 llvm-cov test --text --include-ffi --fail-under-lines 70 -vv
204+
cargo clean
205+
cargo +1.73 llvm-cov test --text --include-ffi --fail-under-lines 70 -vv
206+
cargo clean
207+
cargo +1.77 llvm-cov test --text --include-ffi --fail-under-lines 70 -vv
208+
cargo clean
209+
cargo +1.78 llvm-cov test --text --include-ffi --fail-under-lines 70 -vv
210+
working-directory: tests/fixtures/crates/ffi

tests/fixtures/crates/ffi/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ edition = "2021"
55
publish = false
66

77
[build-dependencies]
8-
cc = "1"
8+
cc = "=1.0.83"
99

1010
[workspace]

tests/fixtures/crates/ffi/hello_c.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
#include <stdio.h>
22

33
void hello_c() {
4-
printf("Hello C from Rust!\n");
4+
if (1) {
5+
printf("Hello C from Rust!\n");
6+
} else {
7+
printf("this line in C is not covered\n");
8+
}
59
}
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
#include <iostream>
22

33
extern "C" void hello_cpp() {
4-
std::cout << "Hello C++ from Rust!" << std::endl;
4+
if (1) {
5+
std::cout << "Hello C++ from Rust!" << std::endl;
6+
} else {
7+
std::cout << "this line in C++ is not covered" << std::endl;
8+
}
59
}

0 commit comments

Comments
 (0)