-
Notifications
You must be signed in to change notification settings - Fork 5
238 lines (197 loc) · 6.9 KB
/
ci.yml
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
# SPDX-FileCopyrightText: The Ferrocene Developers
# SPDX-License-Identifier: MIT OR Apache-2.0
---
name: CI
on:
push:
branches: [staging, trying]
pull_request: {}
permissions:
# Allow write access to the source code to enable GitHub Pages publishing.
contents: read
jobs:
build-test:
name: Build and test
strategy:
fail-fast: false
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
# Windows seems to have an existing non-RustUp tools in `~/.cargo/bin/` which have to be removed
- if: ${{ matrix.os == 'windows-latest' }}
shell: bash
run: |
rm -rv C://Users/runneradmin/.cargo/bin/rust-analyzer.exe
rm -rv C://Users/runneradmin/.cargo/bin/rustfmt.exe
rm -rv C://Users/runneradmin/.cargo/bin/cargo-fmt.exe
- name: Make sure Rust stable is installed
shell: bash
run: |
rustup update stable --no-self-update
rustup default stable
- name: Cache Rust dependencies
uses: ferrous-systems/shared-github-actions/cache-rust@main
- name: Check formatting
if: ${{ matrix.os == 'ubuntu-latest' }}
shell: bash
run: cargo fmt --all --check
- name: Check Clippy warnings
shell: bash
run: cargo clippy --workspace --tests --locked -- -Dwarnings
- name: Prepare file to record snapshots used by insta
shell: bash
run: echo "INSTA_SNAPSHOT_REFERENCES_FILE=$(mktemp)" >> "${GITHUB_ENV}"
- name: Run the test suite (Without AWS KMS)
if: ${{ runner.os != 'Linux' }}
shell: bash
run: cargo test --timings --workspace --locked
- name: Run the test suite (With AWS KMS)
if: ${{ runner.os == 'Linux' }}
shell: bash
run: cargo test --timings --workspace --locked --features aws-kms -- --test-threads=1
# Incompatible with Windows, insta snapshots output Windows paths
# Incompatible with Mac, find does not have `-n`, diff does not have `--color`
- if: ${{ matrix.os == 'ubuntu-latest' }}
name: Ensure there are no unused insta snapshots
shell: bash
run: diff -u --color <(find -name "*.snap" | xargs realpath | sort | uniq) <(cat "${INSTA_SNAPSHOT_REFERENCES_FILE}" | xargs realpath | sort | uniq)
- name: Build debug builds
shell: bash
run: cargo build --workspace
- name: Upload criticalup debug build
uses: actions/upload-artifact@v4
with:
name: criticalup-${{ matrix.os }}
path: target/debug/criticalup${{ (runner.os == 'Windows' && '.exe') || '' }}
retention-days: 7
- name: Upload upload criticalup-dev debug build
uses: actions/upload-artifact@v4
with:
name: criticalup-dev-${{ matrix.os }}
path: target/debug/criticalup-dev${{ (runner.os == 'Windows' && '.exe') || '' }}
retention-days: 7
- name: Upload cargo timings
uses: actions/upload-artifact@v4
with:
name: cargo-timings-${{ matrix.os }}
path: target/cargo-timings/cargo-timing.html
retention-days: 7
runner-test:
name: Test CriticalUp on GHA Runners
needs: [build-test]
strategy:
fail-fast: false
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
env:
CRITICALUP_TOKEN: ${{ secrets.CRITICALUP_TOKEN }}
steps:
- name: "Define toolchain"
shell: bash # Powershell does not do heredocs
run: |
mkdir -p crab-boil
cd crab-boil
cat <<- EOF > criticalup.toml
manifest-version = 1
[products.ferrocene]
release = "stable-24.11.0"
packages = [
"cargo-\${rustc-host}",
"rustc-\${rustc-host}",
"rust-std-\${rustc-host}",
]
EOF
- uses: actions/download-artifact@v4
with:
name: criticalup-${{ matrix.os }}
path: crab-boil
- name: Make executable
if: ${{ runner.os != 'Windows' }}
working-directory: crab-boil
run: chmod +x ./criticalup
- name: Auth Criticalup
working-directory: crab-boil
run: ./criticalup auth set $CRITICALUP_TOKEN
- name: Install toolchain
working-directory: crab-boil
run: |
./criticalup install
- name: Run test workflow
working-directory: crab-boil
run: |
./criticalup run -- cargo init
./criticalup run -- cargo build
./criticalup run -- cargo run
./criticalup which rustc
./criticalup remove
./criticalup clean
# Windows allows the `.exe` or not, at the users option.
- name: Run Windows exclusive commands
if: ${{ runner.os == 'Windows' }}
working-directory: crab-boil
run: |
./criticalup.exe run -- cargo --version
./criticalup run -- cargo.exe --version
./criticalup.exe run -- cargo.exe --version
license:
name: Check licenses
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install REUSE
run: pipx install reuse
- name: Check compliance with REUSE
run: reuse lint
docs:
name: Build documentation
runs-on: ubuntu-22.04
steps:
- name: Checkout the source code
uses: actions/checkout@v4
- name: Build documentation and check links
working-directory: ./docs
run: ./make.py --check-links
- name: Install Python dependencies
working-directory: ./docs
run: python3 -m pip install reuse black flake8
- name: Verify Python code formatting
working-directory: ./docs
run: black . --check --diff --color
- name: Lint Python code with flake8
working-directory: ./docs
run: flake8 . --exclude .venv
- name: Upload GitHub Pages artifact
uses: actions/upload-pages-artifact@v3
with:
path: docs/build/html
deploy-docs:
if: github.event_name == 'push' && github.ref == 'refs/heads/staging'
needs:
- docs
environment:
name: github-pages
url: ${{ steps.github-pages.outputs.page_url }}
# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
permissions:
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source
runs-on: ubuntu-latest
steps:
- name: Deploy to GitHub Pages
uses: actions/deploy-pages@v4
id: github-pages
build-finished:
name: CI build successful
runs-on: ubuntu-latest
if: success()
needs:
- build-test
- runner-test
- docs
- deploy-docs
steps:
- name: Mark the build as successful
run: exit 0