summaryrefslogtreecommitdiffstats
path: root/.github/workflows/ci_pipeline.yml
blob: 6e8bc6cf31dbb36297bbe176d0320d3aaff9f032 (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
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: 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
        uses: dtolnay/rust-toolchain@1.62.1

      - 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

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

  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
        uses: dtolnay/rust-toolchain@1.62.1
        with:
          targets: ${{ matrix.target }}

      - 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 }}