-
Notifications
You must be signed in to change notification settings - Fork 0
282 lines (245 loc) · 9.17 KB
/
ci.yml
File metadata and controls
282 lines (245 loc) · 9.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
name: ci
on:
pull_request:
push:
branches: [main]
permissions:
contents: read
id-token: write
env:
RUST_BACKTRACE: 1
jobs:
style:
name: Check Style
# needless matrix to make copy-pasting common steps easier
strategy:
matrix:
os:
- ubuntu-latest
rust:
- nightly
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust (${{ matrix.rust }})
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: ${{ matrix.rust }}
components: rustfmt
cache-shared-key: ${{ matrix.os }}-${{ matrix.rust }}
- name: Run Rustfmt
run: cargo fmt --all --check
check-and-test:
name: Run Clippy Checks and Tests
needs: [style]
strategy:
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-latest
rust:
- "1.91.1"
- "1.92"
- "1.93"
- "1.94"
- stable
- beta
- nightly
rustc_bootstrap:
- "0"
- "1"
exclude:
# bootstrap is only relevant for non-nightly toolchains
- os: ubuntu-latest
rust: nightly
rustc_bootstrap: "0"
- os: macos-latest
rust: nightly
rustc_bootstrap: "0"
- os: windows-latest
rust: nightly
rustc_bootstrap: "0"
runs-on: ${{ matrix.os }}
env:
RUSTFLAGS: "-D warnings"
RUSTC_BOOTSTRAP: ${{ matrix.rustc_bootstrap }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust (${{ matrix.rust }})
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: ${{ matrix.rust }}
components: clippy,llvm-tools-preview
cache-shared-key: ${{ matrix.os }}-${{ matrix.rust }}${{ matrix.rust != 'nightly' && matrix.rustc_bootstrap == '1' && '-bootstrap' || '' }}
- name: Install grcov
run: cargo install grcov --locked
- name: Fetch cargo dependencies
run: cargo fetch --verbose --locked
# Following commands use `--frozen` to ensure that the lockfile is up-to-date and
# all dependencies were downloaded with `cargo fetch`.
- name: Run Clippy (no default features)
run: cargo clippy --verbose --workspace --all-targets --no-default-features --frozen
- name: Run Clippy (default features)
run: cargo clippy --verbose --workspace --all-targets --frozen
- name: Run Clippy (all features)
run: cargo clippy --verbose --workspace --all-targets --all-features --frozen
- name: Run Tests (no default features)
run: cargo test --verbose --workspace --no-default-features --frozen
- name: Run Tests (default features)
run: cargo test --verbose --workspace --frozen
- name: Run Tests (all features)
run: cargo test --verbose --workspace --all-features --frozen
- name: Build Binaries
if: matrix.rust == 'nightly'
run: cargo build --verbose --bins --workspace --frozen --profile=release-lto
- name: Print diagnostics
if: matrix.rust == 'nightly' && runner.os == 'Windows'
shell: powershell
run: |
Get-ChildItem -Path .\target\release-lto
- name: Print diagnostics
if: matrix.rust == 'nightly' && runner.os != 'Windows'
run: |
ls -Al ./target/release-lto
- name: Upload Binaries as GitHub artifact
if: matrix.rust == 'nightly'
uses: actions/upload-artifact@v4.6.0
with:
name: git-remote-codecommit-${{ matrix.os }}
path: |
target/release-lto/git-remote-codecommit
target/release-lto/git-remote-codecommit.exe
compression-level: 0
- name: Build Documentation
if: ${{ matrix.os == 'ubuntu-latest' && matrix.rust == 'nightly'}}
run: cargo doc --verbose --workspace --document-private-items --frozen
- name: Print diagnostics
if: ${{ matrix.os == 'ubuntu-latest' && matrix.rust == 'nightly'}}
run: |
find ./target/doc -ls
du -hd1 ./target/doc | sort -h
- name: Upload Documentation as GitHub artifact
if: ${{ matrix.os == 'ubuntu-latest' && matrix.rust == 'nightly'}}
uses: actions/upload-artifact@v4.6.0
with:
name: docs
path: target/doc
compression-level: 9
- name: Configure AWS credentials
if: github.repository == 'demosdemon/git-remote-codecommit'
continue-on-error: true
uses: aws-actions/configure-aws-credentials@v6.0.0
env:
RUST_BACKTRACE: 1
AWS_REGION: us-west-2
with:
role-to-assume: arn:aws:iam::339712996426:role/github-git-remote-codecommit
aws-region: ${{ env.AWS_REGION }}
disable-retry: true
- name: Run Rust tests with coverage
env:
CARGO_INCREMENTAL: 0
RUSTFLAGS: "-Cinstrument-coverage"
shell: bash
run: |
cargo build --verbose --workspace --all-targets --frozen
export LLVM_PROFILE_FILE='cargo-test-%p-%m.profraw'
export PATH="$PWD/target/debug:$PATH"
git remote add aws codecommit://git-remote-codecommit
git fetch aws main --depth=1 || true # if this is a fork the credentials won't be set
cargo test --verbose --workspace --frozen
mkdir -p ./target/debug/coverage/
grcov . \
--source-dir . \
--binary-path ./target/debug/ \
--output-types lcov,html \
--llvm \
--branch \
--keep-only 'crates/**' \
--ignore-not-existing \
--excl-line 'grcov-excl-line|unreachable!|unreachable_unchecked()|#\[derive\(|ensure!\(|assert!\(|/!|///' \
--excl-start 'grcov-excl-start' \
--excl-stop 'grcov-excl-stop' \
--output-path ./target/debug/coverage/
- name: Upload out if failed
if: failure()
uses: actions/upload-artifact@v4
with:
name: coverage-failure-${{ matrix.rust }}-${{ matrix.os }}${{ matrix.rust != 'nightly' && matrix.rustc_bootstrap == '1' && '-bootstrap' || '' }}
path: target/debug/build/git-remote-codecommit-*
retention-days: 1
- name: Archive code coverage results
uses: actions/upload-artifact@v4
with:
name: code-coverage-report-${{ matrix.rust }}-${{ matrix.os }}${{ matrix.rust != 'nightly' && matrix.rustc_bootstrap == '1' && '-bootstrap' || '' }}
path: target/debug/coverage/html/
retention-days: 7
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v5
with:
files: target/debug/coverage/lcov
flags: unittests
use_oidc: true
- name: Coveralls Parallel
uses: coverallsapp/github-action@v2
with:
files: target/debug/coverage/lcov
flag-name: code-coverage-report-${{ matrix.rust }}-${{ matrix.os }}${{ matrix.rust != 'nightly' && matrix.rustc_bootstrap == '1' && '-bootstrap' || '' }}
parallel: true
finalize-coveralls-run:
name: Finalize Coveralls Run
needs: [check-and-test]
if: always()
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set carryforward
id: set_carryforward
run: |
echo "carryforward<<EOF" >> $GITHUB_OUTPUT
python3 .github/scripts/matrix.py >> $GITHUB_OUTPUT
echo EOF >> $GITHUB_OUTPUT
- name: Finalize Coveralls Run
uses: coverallsapp/github-action@v2
with:
parallel-finished: true
carryforward: ${{ steps.set_carryforward.outputs.carryforward }}
push-to-codecommit:
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && github.repository == 'demosdemon/git-remote-codecommit'
concurrency: push-to-codecommit
name: Push to CodeCommit
needs: [finalize-coveralls-run]
runs-on: ubuntu-latest
env:
RUST_BACKTRACE: 1
AWS_REGION: us-west-2
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # need the history in order to push to CodeCommit
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v6.0.0
with:
role-to-assume: arn:aws:iam::339712996426:role/github-git-remote-codecommit
aws-region: ${{ env.AWS_REGION }}
- name: Download git-remote-codecommit
uses: actions/download-artifact@v4
with:
name: git-remote-codecommit-ubuntu-latest
path: target/release-lto
- name: Make git-remote-codecommit executable
run: chmod +x target/release-lto/git-remote-codecommit
- name: Add git-remote-codecommit to PATH
run: echo "$PWD/target/release-lto" >> $GITHUB_PATH
- name: Check version
run: git-remote-codecommit --version
- name: Push to CodeCommit
run: |
git remote add aws codecommit://git-remote-codecommit
git push aws --tags
git push aws HEAD:refs/heads/main