Skip to content

Commit 4f2a4eb

Browse files
committed
ci: expand matrix to include older rusts
1 parent acfc394 commit 4f2a4eb

File tree

2 files changed

+98
-38
lines changed

2 files changed

+98
-38
lines changed

.github/scripts/matrix.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/usr/bin/env python3
2+
3+
import itertools
4+
import json
5+
import subprocess
6+
7+
output = subprocess.check_output(
8+
"yq -ojson '.jobs.check-and-test.strategy.matrix' .github/workflows/ci.yml",
9+
shell=True,
10+
)
11+
12+
matrix = json.loads(output)
13+
14+
exclude = matrix.pop("exclude", [])
15+
include = matrix.pop("include", [])
16+
17+
keys = sorted(matrix.keys())
18+
values = [matrix[key] for key in keys]
19+
20+
excluded = {tuple((key, item[key]) for key in keys) for item in exclude}
21+
included = {tuple((key, item[key]) for key in keys) for item in include}
22+
23+
generated = {tuple(zip(keys, items)) for items in itertools.product(*values)}
24+
25+
final = (generated - excluded) | included
26+
final_list = [{key: value for key, value in items} for items in sorted(final)]
27+
28+
items = []
29+
for item in final_list:
30+
os = item["os"]
31+
rust = item["rust"]
32+
rustc_bootstrap = item["rustc_bootstrap"]
33+
34+
bootstrap = "" if rust == "nightly" or rustc_bootstrap == "0" else "-bootstrap"
35+
36+
items.append(f"code-coverage-report-{rust}-{os}{bootstrap}")
37+
38+
39+
print(",".join(items))

.github/workflows/ci.yml

Lines changed: 59 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -41,21 +41,40 @@ jobs:
4141
os:
4242
- ubuntu-latest
4343
- macos-latest
44-
- windows-latest
44+
# - windows-latest
4545
rust:
46+
- "1.86"
47+
- "1.87"
48+
- "1.88"
49+
- "1.89"
50+
- "1.90"
4651
- stable
4752
- beta
4853
- nightly
54+
rustc_bootstrap:
55+
- "0"
56+
- "1"
4957
exclude:
58+
# bootstrap is only relevant for non-nightly toolchains
59+
- os: ubuntu-latest
60+
rust: nightly
61+
rustc_bootstrap: "0"
62+
- os: macos-latest
63+
rust: nightly
64+
rustc_bootstrap: "0"
65+
# - os: windows-latest
66+
# rust: nightly
67+
# rustc_bootstrap: "0"
68+
include:
5069
# Windows builds depend on an unstable feature: windows_process_exit_code_from
5170
# TODO: find a better way to handle this for windows without nightly
5271
- os: windows-latest
53-
rust: stable
54-
- os: windows-latest
55-
rust: beta
72+
rust: nightly
73+
rustc_bootstrap: "1"
5674
runs-on: ${{ matrix.os }}
5775
env:
5876
RUSTFLAGS: "-D warnings"
77+
RUSTC_BOOTSTRAP: ${{ matrix.rustc_bootstrap }}
5978
steps:
6079
- name: Checkout
6180
uses: actions/checkout@v4
@@ -64,8 +83,11 @@ jobs:
6483
uses: actions-rust-lang/setup-rust-toolchain@v1
6584
with:
6685
toolchain: ${{ matrix.rust }}
67-
components: clippy
68-
cache-shared-key: ${{ matrix.os }}-${{ matrix.rust }}
86+
components: clippy,llvm-tools-preview
87+
cache-shared-key: ${{ matrix.os }}-${{ matrix.rust }}${{ matrix.rust != 'nightly' && matrix.rustc_bootstrap == '1' && '-bootstrap' || '' }}
88+
89+
- name: Install grcov
90+
run: cargo install grcov --locked
6991

7092
- name: Fetch cargo dependencies
7193
run: cargo fetch --verbose --locked
@@ -90,48 +112,41 @@ jobs:
90112
- name: Run Tests (all features)
91113
run: cargo test --verbose --workspace --all-features --frozen
92114

93-
coverage:
94-
name: Run tests with coverage
95-
needs: [check-and-test]
96-
strategy:
97-
matrix:
98-
os:
99-
- ubuntu-latest
100-
rust:
101-
- stable
102-
- nightly
103-
runs-on: ${{ matrix.os }}
104-
steps:
105-
- name: Checkout
106-
uses: actions/checkout@v4
107-
108-
- name: Install Rust (${{ matrix.rust }})
109-
uses: actions-rust-lang/setup-rust-toolchain@v1
110-
with:
111-
toolchain: ${{ matrix.rust }}
112-
components: llvm-tools-preview
113-
cache-shared-key: ${{ matrix.os }}-${{ matrix.rust }}
114-
115-
- name: Install grcov
116-
run: cargo install grcov
117-
118115
- name: Run Rust tests with coverage
119-
run: .github/scripts/collect-coverage.sh
120116
env:
121-
RUSTC_PROBE_KEEP_PROBE: ${{ matrix.rust == 'nightly' && '1' || '0'}}
117+
CARGO_INCREMENTAL: 0
118+
RUSTFLAGS: "-Cinstrument-coverage"
119+
shell: bash
120+
run: |
121+
cargo build --verbose --workspace --tests --frozen
122+
export LLVM_PROFILE_FILE='cargo-test-%p-%m.profraw'
123+
cargo test --verbose --workspace --frozen
124+
mkdir -p ./target/debug/coverage/
125+
grcov . \
126+
--source-dir . \
127+
--binary-path ./target/debug/ \
128+
--output-types lcov,html \
129+
--llvm \
130+
--branch \
131+
--keep-only 'crates/**' \
132+
--ignore-not-existing \
133+
--excl-line 'grcov-excl-line|#\[derive\(|ensure!\(|assert!\(|/!|///' \
134+
--excl-start 'grcov-excl-start' \
135+
--excl-stop 'grcov-excl-stop' \
136+
--output-path ./target/debug/coverage/
122137
123138
- name: Upload out if failed
124139
if: failure()
125140
uses: actions/upload-artifact@v4
126141
with:
127-
name: coverage-failure-${{ matrix.rust }}-${{ matrix.os }}
142+
name: coverage-failure-${{ matrix.rust }}-${{ matrix.os }}${{ matrix.rust != 'nightly' && matrix.rustc_bootstrap == '1' && '-bootstrap' || '' }}
128143
path: target/debug/build/git-remote-codecommit-*
129144
retention-days: 1
130145

131146
- name: Archive code coverage results
132147
uses: actions/upload-artifact@v4
133148
with:
134-
name: code-coverage-report-${{ matrix.rust }}-${{ matrix.os }}
149+
name: code-coverage-report-${{ matrix.rust }}-${{ matrix.os }}${{ matrix.rust != 'nightly' && matrix.rustc_bootstrap == '1' && '-bootstrap' || '' }}
135150
path: target/debug/coverage/html/
136151
retention-days: 7
137152

@@ -146,22 +161,28 @@ jobs:
146161
uses: coverallsapp/github-action@v2
147162
with:
148163
files: target/debug/coverage/lcov
149-
flag-name: code-coverage-report-${{ matrix.rust }}-${{ matrix.os }}
164+
flag-name: code-coverage-report-${{ matrix.rust }}-${{ matrix.os }}${{ matrix.rust != 'nightly' && matrix.rustc_bootstrap == '1' && '-bootstrap' || '' }}
150165
parallel: true
151166

152167
finalize-coveralls-run:
153168
name: Finalize Coveralls Run
154-
needs: [coverage]
169+
needs: [check-and-test]
155170
if: always()
156171
runs-on: ubuntu-latest
157172
steps:
158173
- name: Checkout
159174
uses: actions/checkout@v4
175+
- name: Set carryforward
176+
id: set_carryforward
177+
run: |
178+
echo "carryforward<<EOF" >> $GITHUB_OUTPUT
179+
python3 .github/scripts/matrix.py >> $GITHUB_OUTPUT
180+
echo EOF >> $GITHUB_OUTPUT
160181
- name: Finalize Coveralls Run
161182
uses: coverallsapp/github-action@v2
162183
with:
163184
parallel-finished: true
164-
carryforward: code-coverage-report-stable-ubuntu-latest,code-coverage-report-nightly-ubuntu-latest
185+
carryforward: ${{ steps.set_carryforward.outputs.carryforward }}
165186

166187
build-docs:
167188
name: Build Documentation

0 commit comments

Comments
 (0)