-
Notifications
You must be signed in to change notification settings - Fork 4
373 lines (339 loc) · 14.2 KB
/
pr.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
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
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
# PR workflow.
#
# Runs full suite of checks, with warnings treated as errors.
# Gather code coverage stats and publish them on coveralls.io.
name: PR
on: pull_request
env:
RUST_BACKTRACE: 1
RUSTFLAGS: "-D warnings"
CLIENT_VERSION: 0.77.27
NODE_VERSION: 0.83.25
NODE_MANAGER_VERSION: 0.1.8
NODE_LAUNCHPAD_VERSION: 0.2.0
jobs:
# The code in this crate uses lots of conditional compilation for cross-platform capabilities.
# Therefore, it's important we make sure it can build on both the Windows and Unix OS families.
build:
name: build
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: windows-latest
target: x86_64-pc-windows-msvc
- os: macos-latest
target: x86_64-apple-darwin
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
id: toolchain
with:
profile: minimal
toolchain: stable
override: true
- shell: bash
run: cargo build --all-targets --all-features
checks:
if: "!startsWith(github.event.pull_request.title, 'Automated version bump')"
name: Clippy & fmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
components: rustfmt, clippy
- name: Cargo cache registry, index and build
uses: actions/cache@v2.1.4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-cache-${{ hashFiles('**/Cargo.lock') }}-${{ hashFiles('**/Cargo.toml') }}
- name: Check formatting
run: cargo fmt --all -- --check
- name: Clippy checks
run: cargo clippy --all-targets
cargo-udeps:
if: "!startsWith(github.event.pull_request.title, 'Automated version bump')"
name: Unused dependency check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true
- name: Run cargo-udeps
uses: aig787/cargo-udeps-action@v1
with:
version: 'latest'
args: '--all-targets'
cargo-deny:
if: "!startsWith(github.event.pull_request.title, 'Automated version bump')"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- shell: bash
run: wget https://raw.githubusercontent.com/maidsafe/QA/master/misc-scripts/deny.toml
- uses: EmbarkStudios/cargo-deny-action@v1
unit-test:
if: "!startsWith(github.event.pull_request.title, 'Automated version bump')"
name: Test
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: Cargo cache registry, index and build
uses: actions/cache@v2.1.4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-cache-${{ hashFiles('**/Cargo.lock') }}
- uses: actions-rs/cargo@v1
with:
command: test
args: --release
test-install-windows:
if: "!startsWith(github.event.pull_request.title, 'Automated version bump')"
name: Install test (Windows)
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: Install binaries
shell: pwsh
run: |
cargo run -- client --version $env:CLIENT_VERSION
cargo run -- node --version $env:NODE_VERSION
cargo run -- node-manager --version $env:NODE_MANAGER_VERSION
cargo run -- node-launchpad --version $env:NODE_LAUNCHPAD_VERSION
- name: Check if binaries are available in new shell session
shell: pwsh
run: |
if (!(Test-Path "$env:USERPROFILE\safe\safe.exe")) {
Write-Host "safe.exe does not exist"
exit 1
}
if (!(Test-Path "$env:USERPROFILE\safe\safenode.exe")) {
Write-Host "safenode.exe does not exist"
exit 1
}
if (!(Test-Path "$env:USERPROFILE\safe\safenode-manager.exe")) {
Write-Host "safenode-manager.exe does not exist"
exit 1
}
if (!(Test-Path "$env:USERPROFILE\safe\node-launchpad.exe")) {
Write-Host "node-launchpad.exe does not exist"
exit 1
}
# For security reasons, the GHA infrastructure prevents environment variables
# being modified easily, so we need to refer to the binaries with their full paths.
# Other manual testing has proven that the changes to the Path environment variable do
# take effect.
$output = & "${env:USERPROFILE}\safe\safe.exe" --version
$version = $output | Select-String -Pattern "sn_cli (\d+\.\d+\.\d+)"
$versionNumber = $version.Matches.Groups[1].Value
if ($versionNumber -eq "$env:CLIENT_VERSION") {
Write-Host "The correct version of safe has been installed"
} else {
Write-Host "The correct version of safe has not been installed"
Write-Host "We expected version $env:CLIENT_VERSION"
Write-Host "The downloaded binary has $versionNumber"
exit 1
}
$output = & "${env:USERPROFILE}\safe\safenode.exe" --version
$version = $output | Select-String -Pattern "safenode cli (\d+\.\d+\.\d+)"
$versionNumber = $version.Matches.Groups[1].Value
if ($versionNumber -eq "$env:NODE_VERSION") {
Write-Host "The correct version of safenode has been installed"
} else {
Write-Host "The correct version of safenode has not been installed"
Write-Host "We expected version $env:NODE_VERSION"
Write-Host "The downloaded binary has $versionNumber"
exit 1
}
$output = & "${env:USERPROFILE}\safe\safenode-manager.exe" --version
$version = $output | Select-String -Pattern "sn-node-manager (\d+\.\d+\.\d+)"
$versionNumber = $version.Matches.Groups[1].Value
if ($versionNumber -eq "$env:NODE_MANAGER_VERSION") {
Write-Host "The correct version of safenode-manager has been installed"
} else {
Write-Host "The correct version of safenode-manager has not been installed"
Write-Host "We expected version $env:NODE_MANAGER_VERSION"
Write-Host "The downloaded binary has $versionNumber"
exit 1
}
$output = & "${env:USERPROFILE}\safe\node-launchpad.exe" --version
$version = $output | Select-String -Pattern "node-launchpad (\d+\.\d+\.\d+)"
$versionNumber = $version.Matches.Groups[1].Value
if ($versionNumber -eq "$env:NODE_LAUNCHPAD_VERSION") {
Write-Host "The correct version of safenode-manager has been installed"
} else {
Write-Host "The correct version of safenode-manager has not been installed"
Write-Host "We expected version $env:NODE_LAUNCHPAD_VERSION"
Write-Host "The downloaded binary has $versionNumber"
exit 1
}
test-install-linux:
if: "!startsWith(github.event.pull_request.title, 'Automated version bump')"
name: Install test (Linux)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: Install binaries
shell: bash
run: |
cargo run -- client --version $CLIENT_VERSION
cargo run -- node --version $NODE_VERSION
cargo run -- node-manager --version $NODE_MANAGER_VERSION
cargo run -- node-launchpad --version $NODE_LAUNCHPAD_VERSION
- name: Check if binaries are available in new shell session
shell: bash
run: |
# The installer adds this to the .bashrc file, but even though
# there's a new shell session for each step, the new bashrc isn't
# being sourced. Perhaps it's not a login shell or something. So
# unfortunately we need to explicitly source the env file. However,
# the test does prove that the env file modifies PATH correctly and
# that the installs of the binaries are available from their local
# locations.
source ~/.config/safe/env
[[ -f "$HOME/.local/bin/safe" ]] || { echo "safe not in expected location"; exit 1; }
[[ -f "$HOME/.local/bin/safenode" ]] || { echo "safenode not in expected location"; exit 1; }
[[ -f "$HOME/.local/bin/safenode-manager" ]] || { echo "safenode-manager not in expected location"; exit 1; }
[[ -f "$HOME/.local/bin/node-launchpad" ]] || { echo "node-launchpad not in expected location"; exit 1; }
version=$(safe --version | awk '{ print $2 }')
if [[ "$version" == "$CLIENT_VERSION" ]]; then
echo "The correct version of safe has been installed"
else
echo "The correct version of safe has not been installed"
echo "We expected $CLIENT_VERSION"
echo "The downloaded binary has $version"
exit 1
fi
version=$(safenode --version | awk '{ print $3 }')
if [[ "$version" == "$NODE_VERSION" ]]; then
echo "The correct version of safenode has been installed"
else
echo "The correct version of safenode has not been installed"
echo "We expected $NODE_VERSION"
echo "The downloaded binary has $version"
exit 1
fi
version=$(safenode-manager --version | awk '{ print $2 }')
if [[ "$version" == "$NODE_MANAGER_VERSION" ]]; then
echo "The correct version of safenode-manager has been installed"
else
echo "The correct version of safenode-manager has not been installed"
echo "We expected $NODE_MANAGER_VERSION"
echo "The downloaded binary has $version"
exit 1
fi
version=$(node-launchpad --version | awk '{ print $2 }')
if [[ "$version" == "$NODE_LAUNCHPAD_VERSION" ]]; then
echo "The correct version of node-launchpad has been installed"
else
echo "The correct version of node-launchpad has not been installed"
echo "We expected $NODE_LAUNCHPAD_VERSION"
echo "The downloaded binary has $version"
exit 1
fi
test-install-macos:
if: "!startsWith(github.event.pull_request.title, 'Automated version bump')"
name: Install test (macOS)
runs-on: macOS-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: Install binaries
run: |
cargo run -- client --version $CLIENT_VERSION
cargo run -- node --version $NODE_VERSION
cargo run -- node-manager --version $NODE_MANAGER_VERSION
cargo run -- node-launchpad --version $NODE_LAUNCHPAD_VERSION
- name: Check if binaries are available in new shell session
run: |
# As with the Ubuntu test, we need to source the env file to get the binaries on PATH.
source "/Users/runner/Library/Application Support/safe/env"
[[ -f "$HOME/.local/bin/safe" ]] || { echo "safe not in expected location"; exit 1; }
[[ -f "$HOME/.local/bin/safenode" ]] || { echo "safenode not in expected location"; exit 1; }
[[ -f "$HOME/.local/bin/safenode-manager" ]] || { echo "safenode-manager not in expected location"; exit 1; }
[[ -f "$HOME/.local/bin/node-launchpad" ]] || { echo "node-launchpad not in expected location"; exit 1; }
version=$(safe --version | awk '{ print $2 }')
if [[ "$version" == "$CLIENT_VERSION" ]]; then
echo "The correct version of safe has been installed"
else
echo "The correct version of safe has not been installed"
echo "We expected $CLIENT_VERSION"
echo "The downloaded binary has $version"
exit 1
fi
version=$(safenode --version | awk '{ print $3 }')
if [[ "$version" == "$NODE_VERSION" ]]; then
echo "The correct version of safenode has been installed"
else
echo "The correct version of safenode has not been installed"
echo "We expected $NODE_VERSION"
echo "The downloaded binary has $version"
exit 1
fi
version=$(safenode-manager --version | awk '{ print $2 }')
if [[ "$version" == "$NODE_MANAGER_VERSION" ]]; then
echo "The correct version of safenode-manager has been installed"
else
echo "The correct version of safenode-manager has not been installed"
echo "We expected $NODE_MANAGER_VERSION"
echo "The downloaded binary has $version"
exit 1
fi
version=$(node-launchpad --version | awk '{ print $2 }')
if [[ "$version" == "$NODE_LAUNCHPAD_VERSION" ]]; then
echo "The correct version of node-launchpad has been installed"
else
echo "The correct version of node-launchpad has not been installed"
echo "We expected $NODE_LAUNCHPAD_VERSION"
echo "The downloaded binary has $version"
exit 1
fi
test-publish:
if: "!startsWith(github.event.pull_request.title, 'Automated version bump')"
name: Test Publish
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: dry run publish
run: cargo publish --dry-run