-
Notifications
You must be signed in to change notification settings - Fork 5
317 lines (280 loc) · 9.23 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
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
name: CI
on:
push:
branches:
- master
pull_request:
jobs:
cancel_previous_runs:
name: Cancel previous runs
runs-on: ubuntu-latest
steps:
- uses: styfle/[email protected]
with:
access_token: ${{ secrets.GITHUB_TOKEN }}
test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Checkout source code
uses: actions/checkout@v2
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
target: thumbv7m-none-eabi
override: true
- name: Build
uses: actions-rs/cargo@v1
with:
command: build
args: --all --target thumbv7m-none-eabi
- name: Test
uses: actions-rs/cargo@v1
with:
command: test
args: --lib --features "log"
integration:
name: Integration Test
runs-on: ubuntu-latest
needs: test
steps:
- name: Checkout source code
uses: actions/checkout@v2
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
target: thumbv7m-none-eabi
override: true
- name: Run integration test
uses: actions-rs/cargo@v1
with:
command: run
args: --features=log --example echo
device_advisor:
name: AWS IoT Device Advisor
runs-on: ubuntu-latest
needs: test
env:
AWS_EC2_METADATA_DISABLED: true
AWS_DEFAULT_REGION: ${{ secrets.MGMT_AWS_DEFAULT_REGION }}
AWS_ACCESS_KEY_ID: ${{ secrets.MGMT_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.MGMT_AWS_SECRET_ACCESS_KEY }}
SUITE_ID: greb3uy2wtq3
THING_ARN: arn:aws:iot:eu-west-1:274906834921:thing/mqttrust
CERTIFICATE_ARN: arn:aws:iot:eu-west-1:274906834921:cert/e7280d8d316b58da3058037a2c1730d9eb15de50e96f4d47e54ea655266b76db
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: Get AWS_HOSTNAME
id: hostname
run: |
hostname=$(aws iotdeviceadvisor get-endpoint --output text --query endpoint)
ret=$?
echo "::set-output name=AWS_HOSTNAME::$hostname"
exit $ret
- name: Build test binary
uses: actions-rs/cargo@v1
env:
AWS_HOSTNAME: ${{ steps.hostname.outputs.AWS_HOSTNAME }}
with:
command: build
args: --features=log --example aws_device_advisor --release
- name: Start test suite
id: test_suite
run: |
suite_id=$(aws iotdeviceadvisor start-suite-run --suite-definition-id ${{ env.SUITE_ID }} --suite-run-configuration "primaryDevice={thingArn=${{ env.THING_ARN }},certificateArn=${{ env.CERTIFICATE_ARN }}}" --output text --query suiteRunId)
ret=$?
echo "::set-output name=SUITE_RUN_ID::$suite_id"
exit $ret
- name: Execute test binary
id: binary
env:
DEVICE_ADVISOR_PASSWORD: ${{ secrets.DEVICE_ADVISOR_PASSWORD }}
RUST_LOG: trace
run: |
nohup ./target/release/examples/aws_device_advisor > device_advisor_integration.log &
echo "::set-output name=PID::$!"
- name: Monitor test run
run: |
chmod +x ./.github/scripts/da_monitor.sh
echo ${{ env.SUITE_ID }} ${{ steps.test_suite.outputs.SUITE_RUN_ID }} ${{ steps.binary.outputs.PID }}
./.github/scripts/da_monitor.sh ${{ env.SUITE_ID }} ${{ steps.test_suite.outputs.SUITE_RUN_ID }} ${{ steps.binary.outputs.PID }}
- name: Kill test binary process
if: ${{ always() }}
run: kill ${{ steps.binary.outputs.PID }} || true
- name: Log binary output
if: ${{ always() }}
run: cat device_advisor_integration.log
- name: Stop test suite
if: ${{ failure() }}
run: aws iotdeviceadvisor stop-suite-run --suite-definition-id ${{ env.SUITE_ID }} --suite-run-id ${{ steps.test_suite.outputs.SUITE_RUN_ID }}
rustfmt:
name: rustfmt
runs-on: ubuntu-latest
steps:
- name: Checkout source code
uses: actions/checkout@v2
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
override: true
components: rustfmt
- name: Run rustfmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check --verbose
# tomlfmt:
# name: tomlfmt
# runs-on: ubuntu-latest
# steps:
# - name: Checkout source code
# uses: actions/checkout@v2
# - name: Install Rust
# uses: actions-rs/toolchain@v1
# with:
# profile: minimal
# toolchain: nightly
# override: true
# - name: Install tomlfmt
# uses: actions-rs/[email protected]
# with:
# crate: cargo-tomlfmt
# version: latest
# use-tool-cache: true
# - name: Run Tomlfmt
# uses: actions-rs/cargo@v1
# with:
# command: tomlfmt
# args: --dryrun
clippy:
name: clippy
runs-on: ubuntu-latest
env:
CLIPPY_PARAMS: -W clippy::all -W clippy::pedantic -W clippy::nursery -W clippy::cargo
steps:
- name: Checkout source code
uses: actions/checkout@v2
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
components: clippy
- name: Run clippy
uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --features "log" -- ${{ env.CLIPPY_PARAMS }}
grcov:
name: Coverage
runs-on: ubuntu-latest
steps:
- name: Checkout source code
uses: actions/checkout@v2
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
target: thumbv7m-none-eabi
override: true
- name: Install grcov
uses: actions-rs/cargo@v1
# uses: actions-rs/[email protected]
with:
# crate: grcov
# version: latest
# use-tool-cache: true
command: install
args: grcov --git https://github.com/mozilla/grcov
- name: Test
uses: actions-rs/cargo@v1
with:
command: test
args: --lib --no-fail-fast --features "log"
env:
CARGO_INCREMENTAL: "0"
RUSTFLAGS: "-Zprofile -Ccodegen-units=1 -Copt-level=0 -Coverflow-checks=off -Cpanic=unwind -Zpanic_abort_tests"
RUSTDOCFLAGS: "-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Coverflow-checks=off -Cpanic=unwind -Zpanic_abort_tests"
- name: Generate coverage data
id: grcov
# uses: actions-rs/[email protected]
run: |
grcov target/debug/ \
--branch \
--llvm \
--source-dir . \
--output-file lcov.info \
--ignore='/**' \
--ignore='C:/**' \
--ignore='../**' \
--ignore-not-existing \
--excl-line "#\\[derive\\(" \
--excl-br-line "(#\\[derive\\()|(debug_assert)" \
--excl-start "#\\[cfg\\(test\\)\\]" \
--excl-br-start "#\\[cfg\\(test\\)\\]" \
--commit-sha ${{ github.sha }} \
--service-job-id ${{ github.job }} \
--service-name "GitHub Actions" \
--service-number ${{ github.run_id }}
- name: Upload coverage as artifact
uses: actions/upload-artifact@v2
with:
name: lcov.info
# path: ${{ steps.grcov.outputs.report }}
path: lcov.info
- name: Upload coverage to codecov.io
uses: codecov/codecov-action@v1
with:
# file: ${{ steps.grcov.outputs.report }}
file: lcov.info
fail_ci_if_error: true
docs:
name: Documentation
runs-on: ubuntu-latest
steps:
- name: Checkout source code
uses: actions/checkout@v2
with:
persist-credentials: false
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
override: true
- name: Build documentation
uses: actions-rs/cargo@v1
with:
command: doc
args: --verbose --no-deps
# - name: Finalize documentation
# run: |
# CRATE_NAME=$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]' | cut -f2 -d"/")
# echo "<meta http-equiv=\"refresh\" content=\"0; url=${CRATE_NAME/-/_}\">" > target/doc/index.html
# touch target/doc/.nojekyll
# - name: Upload as artifact
# uses: actions/upload-artifact@v2
# with:
# name: Documentation
# path: target/doc
# - name: Deploy
# uses: JamesIves/github-pages-deploy-action@releases/v3
# with:
# ACCESS_TOKEN: ${{ secrets.GH_PAT }}
# BRANCH: gh-pages
# FOLDER: target/doc