Skip to content

Commit 1605fa9

Browse files
committed
ci: expand matrix to include older rusts
1 parent acfc394 commit 1605fa9

File tree

2 files changed

+88
-35
lines changed

2 files changed

+88
-35
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: 49 additions & 35 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,8 @@ 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' || '' }}
6988

7089
- name: Fetch cargo dependencies
7190
run: cargo fetch --verbose --locked
@@ -90,48 +109,43 @@ jobs:
90109
- name: Run Tests (all features)
91110
run: cargo test --verbose --workspace --all-features --frozen
92111

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-
115112
- name: Install grcov
116113
run: cargo install grcov
117114

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+
run: |
120+
cargo build --verbose --workspace --tests --frozen
121+
export LLVM_PROFILE_FILE='cargo-test-%p-%m.profraw'
122+
cargo test --verbose --workspace --frozen
123+
mkdir -p ./target/debug/coverage/
124+
grcov . \
125+
--source-dir . \
126+
--binary-path ./target/debug/ \
127+
--output-types lcov,html \
128+
--llvm \
129+
--branch \
130+
--keep-only 'crates/**' \
131+
--ignore-not-existing \
132+
--excl-line 'grcov-excl-line|#\[derive\(|ensure!\(|assert!\(|/!|///' \
133+
--excl-start 'grcov-excl-start' \
134+
--excl-stop 'grcov-excl-stop' \
135+
--output-path ./target/debug/coverage/
122136
123137
- name: Upload out if failed
124138
if: failure()
125139
uses: actions/upload-artifact@v4
126140
with:
127-
name: coverage-failure-${{ matrix.rust }}-${{ matrix.os }}
141+
name: coverage-failure-${{ matrix.rust }}-${{ matrix.os }}${{ matrix.rust != 'nightly' && matrix.rustc_bootstrap == '1' && '-bootstrap' || '' }}
128142
path: target/debug/build/git-remote-codecommit-*
129143
retention-days: 1
130144

131145
- name: Archive code coverage results
132146
uses: actions/upload-artifact@v4
133147
with:
134-
name: code-coverage-report-${{ matrix.rust }}-${{ matrix.os }}
148+
name: code-coverage-report-${{ matrix.rust }}-${{ matrix.os }}${{ matrix.rust != 'nightly' && matrix.rustc_bootstrap == '1' && '-bootstrap' || '' }}
135149
path: target/debug/coverage/html/
136150
retention-days: 7
137151

@@ -146,12 +160,12 @@ jobs:
146160
uses: coverallsapp/github-action@v2
147161
with:
148162
files: target/debug/coverage/lcov
149-
flag-name: code-coverage-report-${{ matrix.rust }}-${{ matrix.os }}
163+
flag-name: code-coverage-report-${{ matrix.rust }}-${{ matrix.os }}${{ matrix.rust != 'nightly' && matrix.rustc_bootstrap == '1' && '-bootstrap' || '' }}
150164
parallel: true
151165

152166
finalize-coveralls-run:
153167
name: Finalize Coveralls Run
154-
needs: [coverage]
168+
needs: [check-and-test]
155169
if: always()
156170
runs-on: ubuntu-latest
157171
steps:
@@ -161,7 +175,7 @@ jobs:
161175
uses: coverallsapp/github-action@v2
162176
with:
163177
parallel-finished: true
164-
carryforward: code-coverage-report-stable-ubuntu-latest,code-coverage-report-nightly-ubuntu-latest
178+
carryforward: code-coverage-report-1.86-macos-latest,code-coverage-report-1.86-macos-latest-bootstrap,code-coverage-report-1.87-macos-latest,code-coverage-report-1.87-macos-latest-bootstrap,code-coverage-report-1.88-macos-latest,code-coverage-report-1.88-macos-latest-bootstrap,code-coverage-report-1.89-macos-latest,code-coverage-report-1.89-macos-latest-bootstrap,code-coverage-report-1.90-macos-latest,code-coverage-report-1.90-macos-latest-bootstrap,code-coverage-report-beta-macos-latest,code-coverage-report-beta-macos-latest-bootstrap,code-coverage-report-nightly-macos-latest,code-coverage-report-stable-macos-latest,code-coverage-report-stable-macos-latest-bootstrap,code-coverage-report-1.86-ubuntu-latest,code-coverage-report-1.86-ubuntu-latest-bootstrap,code-coverage-report-1.87-ubuntu-latest,code-coverage-report-1.87-ubuntu-latest-bootstrap,code-coverage-report-1.88-ubuntu-latest,code-coverage-report-1.88-ubuntu-latest-bootstrap,code-coverage-report-1.89-ubuntu-latest,code-coverage-report-1.89-ubuntu-latest-bootstrap,code-coverage-report-1.90-ubuntu-latest,code-coverage-report-1.90-ubuntu-latest-bootstrap,code-coverage-report-beta-ubuntu-latest,code-coverage-report-beta-ubuntu-latest-bootstrap,code-coverage-report-nightly-ubuntu-latest,code-coverage-report-stable-ubuntu-latest,code-coverage-report-stable-ubuntu-latest-bootstrap,code-coverage-report-nightly-windows-latest
165179

166180
build-docs:
167181
name: Build Documentation

0 commit comments

Comments
 (0)