summaryrefslogtreecommitdiffstats
path: root/.github/workflows/ci_pipeline.yml
blob: ccd0e43d00dc8b5fe68eb87ef0e505e978665a87 (plain)
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
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
name: ci_pipeline

# All in one ci pipeline
#  Note that the jobs system-test_offsite_{abcd} , install-and-use-rpi_m32sd10{abcd}
#  are there four times and are almost identical. They only differ in a character
#  a,b,c,d that we use to select a runner.
#
# TODO: Safely move cargo test on amd64 to bash script
# TODO: Reduce complexity by moving functionality to bash scripts
# TODO: Smoke testing on Azure is disabled, we should check if it works out
#   with 4 runners in parallel or enable only one

on:
  push:
    branches: [ main, 'release-*' ]
  workflow_dispatch:

env:
  CARGO_TERM_COLOR: always
  RUSTFLAGS: -D warnings

jobs:
  build-amd64:
    name: Build for amd64
    runs-on: Ubuntu-20.04
    steps:
      - name: Checkout
        uses: actions/checkout@v3

      - name: Enable toolchain via github action
        # https://github.com/actions-rs/toolchain
        uses: actions-rs/toolchain@v1
        with:
          toolchain: 1.58.1
          override: true

      - name: Enable cache
        # https://github.com/marketplace/actions/rust-cache
        uses: Swatinem/rust-cache@v1

      - name: Build packages for amd64
        run: ./ci/build_scripts/build_for_amd64.sh

      - name: Upload artifacts as zip
        # https://github.com/marketplace/actions/upload-a-build-artifact
        uses: actions/upload-artifact@v3
        with:
          name: debian-packages-amd64
          path: target/debian/*.deb

#################################################################################

  install-and-use-amd64:
    name: Install artifacts on amd64
    runs-on: Ubuntu-20.04
    needs: build-amd64

    steps:
      - name: Checkout
        uses: actions/checkout@v3

      - name: Download release artifacts
        uses: actions/download-artifact@v3
        # https://github.com/marketplace/actions/download-a-build-artifact
        with:
          name: debian-packages-amd64
          path: debian-package_unpack

      - name: Install artifacts on amd64
        run: ./ci/installation_scripts/install_for_amd64.sh debian-package_unpack

      - name: Run tedge help
        run: tedge --help

#################################################################################

  cargo-test-features-amd64:
    name: Run cargo test features
    runs-on: Ubuntu-20.04
    needs: build-amd64

    steps:
      - name: Checkout
        uses: actions/checkout@v3

      - name: Enable toolchain via github action
        uses: actions-rs/toolchain@v1
        with:
          toolchain: 1.58.1
          override: true

      - name: Enable cache
        # https://github.com/marketplace/actions/rust-cache
        uses: Swatinem/rust-cache@v1

      - name: Compile test
        run: ./ci/integration_test/cargo_test_for_amd64.sh

        # If this command is ported to bash script, it runs tests that should be skipped.
        # The tests could fail if GitHub blocks external connections.
        # It seems like they rarely do.
      - name: Cargo test features
        uses: actions-rs/cargo@v1
        # https://github.com/marketplace/actions/rust-cargo
        with:
          command: test
          args: --verbose --features integration-test,requires-sudo -- \
            --skip sending_and_receiving_a_message

##################################################################################

  build-arm-matrix:
    name: Build for ${{ matrix.target }}
    runs-on: Ubuntu-20.04
    strategy:
      matrix:
        # Add only arm targets here as we use a custom strip binary!
        target:
          [
            aarch64-unknown-linux-gnu,
            aarch64-unknown-linux-musl,
            arm-unknown-linux-gnueabihf,
            armv7-unknown-linux-gnueabihf,
            armv7-unknown-linux-musleabihf,
          ]

    steps:
      - name: Checkout
        uses: actions/checkout@v3

      - name: Enable toolchain via github action
        # https://github.com/actions-rs/toolchain
        uses: actions-rs/toolchain@v1
        with:
          toolchain: 1.58.1
          target: ${{ matrix.target }}
          override: true

      - name: Enable cache
        # https://github.com/marketplace/actions/rust-cache
        uses: Swatinem/rust-cache@v1

      - name: Build for ${{ matrix.target }}
        run: ./ci/build_scripts/build_for_arm.sh ${{ matrix.target }}

      - name: Upload debian packages as zip
        # https://github.com/marketplace/actions/upload-a-build-artifact
        uses: actions/upload-artifact@v3
        with:
          name: debian-packages-${{ matrix.target }}
          path: target/${{ matrix.target }}/debian/*.deb

      - name: Upload sawtooth publisher as zip
        # https://github.com/marketplace/actions/upload-a-build-artifact
        uses: actions/upload-artifact@v3
        with:
          name: sawtooth_publisher_${{ matrix.target }}
          path: target/${{ matrix.target }}/release/sawtooth_publisher

      - name: Upload dummy-plugin as zip
        # https://github.com/marketplace/actions/upload-a-build-artifact
        uses: actions/upload-artifact@v3
        with:
          name: tedge_dummy_plugin_${{ matrix.target }}
          path: target/${{ matrix.target }}/release/tedge_dummy_plugin

#################################################################################

  clean-up-rpi-matrix:
    strategy:
      matrix:
        rpi: [ m32sd10a, m32sd10b, m32sd10c, m32sd10d ]
    runs-on:
      - self-hosted
      - Linux
      - ARM
      - offsite_${{ matrix.rpi }}
    needs: build-arm-matrix

    steps:
      - name: Checkout
        uses: actions/checkout@v3

      - name: Clean up ${{ matrix.rpi }}
        run: ./ci/installation_scripts/clean_up_rpi.sh
        continue-on-error: true

#################################################################################

  install-and-use-rpi-matrix:
    strategy:
      matrix:
        rpi: [ m32sd10a, m32sd10b, m32sd10c, m32sd10d ]
    runs-on:
      - self-hosted
      - Linux
      - ARM
      - offsite_${{ matrix.rpi }}
    needs: clean-up-rpi-matrix

    steps:
      - name: Checkout
        uses: actions/checkout@v3

      - name: Download release artifacts
        uses: actions/download-artifact@v3
        # https://github.com/marketplace/actions/download-a-build-artifact
        with:
          name: debian-packages-armv7-unknown-linux-gnueabihf
          path: debian-package_unpack

      - name: Download sawtooth publisher
        uses: actions/download-artifact@v3
        # https://github.com/marketplace/actions/download-a-build-artifact
        with:
          name: sawtooth_publisher_armv7-unknown-linux-gnueabihf
          path: /home/pi/examples

      - name: Download tedge_dummy_plugin
        uses: actions/download-artifact@v3
        # https://github.com/marketplace/actions/download-a-build-artifact
        with:
          name: tedge_dummy_plugin_armv7-unknown-linux-gnueabihf
          path: /home/pi/tedge_dummy_plugin

      - name: Install all
        run: ./ci/installation_scripts/install_for_arm.sh debian-package_unpack

      - name: Configure Bridge
        run: ./ci/configure_bridge.sh
        env:
          C8YPASS: ${{ secrets.SECRET_C8YPASS }}
          C8YUSERNAME: ${{ secrets.SECRET_C8YUSERNAME }}
          C8YTENANT: ${{ secrets.SECRET_C8YTENANT }}
          C8YDEVICE: ${{ matrix.rpi }}
          TEBASEDIR: /home/pi/actions-runner/_work/thin-edge.io/thin-edge.io/
          EXAMPLEDIR: /home/pi/examples
          C8YURL: https://thin-edge-io.eu-latest.cumulocity.com
          IOTHUBNAME: ${{ secrets.IOTHUBNAME }}

      - name: Run smoke test for Cumulocity
        run: ./ci/ci_smoke_test_c8y.sh
        env:
          C8YPASS: ${{ secrets.SECRET_C8YPASS }}
          C8YUSERNAME: ${{ secrets.SECRET_C8YUSERNAME }}
          C8YTENANT: ${{ secrets.SECRET_C8YTENANT }}
          C8YDEVICE: ${{ matrix.rpi }}
          TEBASEDIR: /home/pi/actions-runner/_work/thin-edge.io/thin-edge.io/
          EXAMPLEDIR: /home/pi/examples
          C8YURL: https://thin-edge-io.eu-latest.cumulocity.com
          IOTHUBNAME: ${{ secrets.IOTHUBNAME }}

# Run tests for Azure
# Enable this, when we have decided about how many runners we use
#
#      - name: Run Smoke Test for Azure
#        run: ./ci/ci_smoke_test_az.sh
#        env:
#          SASKEYQUEUE: ${{ secrets.SASKEYQUEUE }}
#          SASKEYIOTHUB: ${{ secrets.SASKEYIOTHUB }}
#          AZUREENDPOINT: ${{ secrets.AZUREENDPOINT }}
#          AZUREEVENTHUB: ${{ secrets.AZUREEVENTHUB }}
#          IOTHUBNAME: ${{ secrets.IOTHUBNAME }}

#################################################################################

  system-test-offsite-matrix:
    strategy:
      matrix:
        rpi: [ m32sd10a, m32sd10b, m32sd10c, m32sd10d ]
    runs-on:
      - self-hosted
      - Linux
      - ARM
      - offsite_${{ matrix.rpi }}
    needs: install-and-use-rpi-matrix

    steps:
      - name: Checkout
        uses: actions/checkout@v3

      - name: Run all Tests
        run:  bash ./ci/ci_run_all_tests.sh
        continue-on-error: true
        if: true
        env:
          C8YPASS: ${{ secrets.SECRET_C8YPASS }}