summaryrefslogtreecommitdiffstats
path: root/.github/workflows/integration-test-workflow.yml
blob: 9a2f393dfca5d7675abb2f17bda0895fa0c22ce9 (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
name: integration-test-workflow

on:
  workflow_dispatch:
    branches: [main]
  workflow_run:
    workflows: ["build-workflow"]
    branches: [main]
    types:
      - completed
env:
  CARGO_TERM_COLOR: always

jobs:
  install-and-use-amd64:
    runs-on: Ubuntu-20.04
    if: ${{ github.event.workflow_run.conclusion == 'success' }}

    steps:
      - name: checkout
        uses: actions/checkout@v2

      - name: Download artifact
        uses: dawidd6/action-download-artifact@v2
        # https://github.com/marketplace/actions/download-workflow-artifact
        with:
          github_token: ${{secrets.GITHUB_TOKEN}}
          workflow: build-workflow.yml
          workflow_conclusion: success
          branch: main
          name: debian-packages-amd64
          path: debian-package_unpack

      - name: Workaround Stop collectd mapper
        run: sudo systemctl stop tedge-mapper-collectd
        continue-on-error: true

      - name: disconnect c8y
        run: sudo tedge disconnect c8y
        # We need to continue when there is no tedge already installed
        continue-on-error: true

      - name: disconnect az
        run: sudo tedge disconnect az
        # We need to continue when there is no tedge already installed
        continue-on-error: true

      - name: purge
        run: sudo dpkg -P c8y_configuration_plugin tedge_agent c8y_log_plugin tedge_mapper tedge_apt_plugin tedge_apama_plugin tedge mosquitto libmosquitto1 collectd-core

      - name: install mosquitto
        run: sudo apt-get --assume-yes install mosquitto

      - name: install libmosquitto1
        run: sudo apt-get --assume-yes install libmosquitto1

      - name: install collectd-core
        run: sudo apt-get --assume-yes install collectd-core

      - name: install tedge package
        run: sudo dpkg -i ./debian-package_unpack/tedge_0.*_amd64.deb

      - name: install tedge mapper package
        run: sudo dpkg -i ./debian-package_unpack/tedge_mapper_*_amd64.deb

      - name: install tedge agent package
        run: sudo dpkg -i ./debian-package_unpack/tedge_agent_*_amd64.deb

      - name: install tedge plugin packages
        run: sudo dpkg -i ./debian-package_unpack/tedge_*_plugin_*_amd64.deb

      - name: install c8y plugin packages
        run: sudo dpkg -i ./debian-package_unpack/c8y_*_plugin_*_amd64.deb

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

        # replace the default config file with tedge custom config file
      - name: configure collectd
        run: sudo cp "/etc/tedge/contrib/collectd/collectd.conf" "/etc/collectd/collectd.conf"

  cargo-test-features:
    name: Run cargo test features
    runs-on: Ubuntu-20.04
    if: ${{ github.event.workflow_run.conclusion == 'success' }}
    needs: install-and-use-amd64

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

      - 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: Download artifact
        uses: dawidd6/action-download-artifact@v2
        # https://github.com/marketplace/actions/download-workflow-artifact
        with:
          github_token: ${{secrets.GITHUB_TOKEN}}
          workflow: build-workflow.yml
          workflow_conclusion: success
          branch: main
          name: debian-packages-amd64
          path: debian-package_unpack

      - name: install mosquitto
        run: sudo apt-get --assume-yes install mosquitto

      - name: install libmosquitto1
        run: sudo apt-get --assume-yes install libmosquitto1

      - name: install collectd-core
        run: sudo apt-get --assume-yes install collectd-core

      - name: install tedge package
        run: sudo dpkg -i ./debian-package_unpack/tedge_0.*_amd64.deb

      - name: install tedge mapper package
        run: sudo dpkg -i ./debian-package_unpack/tedge_mapper_*_amd64.deb

      - name: install tedge agent package
        run: sudo dpkg -i ./debian-package_unpack/tedge_agent_*_amd64.deb

      - name: install tedge plugin packages
        run: sudo dpkg -i ./debian-package_unpack/tedge_*_plugin_*_amd64.deb

      - name: install c8y plugin packages
        run: sudo dpkg -i ./debian-package_unpack/c8y_*_plugin_*_amd64.deb

      - name: Cargo test features (compile)
        # If we do not compile in advance the timing in the test run
        # will not work out as some parts are still compiling during the run
        uses: actions-rs/cargo@v1
        # https://github.com/marketplace/actions/rust-cargo
        with:
          command: test
          args: --verbose --no-run --features integration-test

      - name: Cargo build dummy plugin
        uses: actions-rs/cargo@v1
        with:
          command: build
          args: -p tedge_dummy_plugin

        # To run the test for features here is kind of experimental
        # they 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

  install-and-use-rpi:
    runs-on: [self-hosted, Linux, ARM, onsite]
    if: ${{ github.event.workflow_run.conclusion == 'success' }}

    steps:
      - name: checkout
        uses: actions/checkout@v2

      - name: Download artifact
        uses: dawidd6/action-download-artifact@v2
        # https://github.com/marketplace/actions/download-workflow-artifact
        with:
          github_token: ${{secrets.GITHUB_TOKEN}}
          workflow: build-workflow.yml
          workflow_conclusion: success
          branch: main
          name: debian-packages-armv7-unknown-linux-gnueabihf
          path: debian-package_unpack

      - name: Workaround Stop collectd mapper
        run: sudo systemctl stop tedge-mapper-collectd
        continue-on-error: true

      - name: disconnect c8y
        run: sudo tedge disconnect c8y
        # We need to continue when there is no tedge already installed
        continue-on-error: true

      - name: disconnect az
        run: sudo tedge disconnect az
        # We need to continue when there is no tedge already installed
        continue-on-error: true

      - name: Stop apama
        run: sudo systemctl stop apama
        continue-on-error: true

      # mosquitto-clients is required for system test only, but has dependency on libmosquitto1.
      # therefore, we need to purge it here, and mosquitto-clients is required only for RPi.
      - name: purge
        run: sudo dpkg -P c8y_configuration_plugin tedge_agent c8y_log_plugin tedge_mapper tedge_apt_plugin tedge_apama_plugin tedge mosquitto-clients mosquitto libmosquitto1 collectd-core collectd

      - name: install mosquitto
        run: sudo apt-get --assume-yes install mosquitto

      - name: install libmosquitto1
        run: sudo apt-get --assume-yes install libmosquitto1

      - name: install mosquitto-clients
        run: sudo apt-get --assume-yes install mosquitto-clients

      - name: install collectd-core
        run: sudo apt-get --assume-yes install collectd-core collectd

      - name: install tedge package
        run: sudo dpkg -i ./debian-package_unpack/tedge_0.*_armhf.deb

      - name: install tedge mapper package
        run: sudo dpkg -i ./debian-package_unpack/tedge_mapper_*_armhf.deb

      - name: install tedge agent package
        run: sudo dpkg -i ./debian-package_unpack/tedge_agent_*_armhf.deb

      - name: install tedge plugin packages
        run: sudo dpkg -i ./debian-package_unpack/tedge_*_plugin_*_armhf.deb

      - name: install c8y plugin packages
        run: sudo dpkg -i ./debian-package_unpack/c8y_*_plugin_*_armhf.deb

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

        # replace the default config file with tedge custom config file
      - name: configure collectd
        run: sudo cp "/etc/tedge/contrib/collectd/collectd.conf" "/etc/collectd/collectd.conf"

      - name: Download artifact
        uses: dawidd6/action-download-artifact@v2
        # https://github.com/marketplace/actions/download-workflow-artifact
        with:
          github_token: ${{secrets.GITHUB_TOKEN}}
          workflow: build-workflow.yml
          workflow_conclusion: success
          branch: main
          name: sawtooth_publisher_armv7-unknown-linux-gnueabihf
          path: /home/pi/examples

      - name: chmod publisher
        run: chmod +x /home/pi/examples/sawtooth_publisher

      - name: Download artifact
        uses: dawidd6/action-download-artifact@v2
        # https://github.com/marketplace/actions/download-workflow-artifact
        with:
          github_token: ${{secrets.GITHUB_TOKEN}}
          workflow: build-workflow.yml
          workflow_conclusion: success
          branch: main
          name: tedge_dummy_plugin_armv7-unknown-linux-gnueabihf
          path: /home/pi/tedge_dummy_plugin

      - name: chmod dummy_plugin
        run: chmod +x /home/pi/tedge_dummy_plugin/tedge_dummy_plugin

      - name: Configure Bridge
        run: ./ci/configure_bridge.sh
        env:
          C8YPASS: ${{ secrets.SECRET_C8YPASS }}
          C8YUSERNAME: ${{ secrets.SECRET_C8YUSERNAME }}
          C8YTENANT: ${{secrets.SECRET_C8YTENANT}}
          C8YDEVICE: ${{ secrets.SECRET_C8YDEVICE }}
          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}}
          <