-
Notifications
You must be signed in to change notification settings - Fork 4
198 lines (174 loc) · 7.17 KB
/
flowzone.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
name: Flowzone
on:
pull_request:
types: [opened, synchronize, closed]
branches: [main, master]
# allow external contributions to use secrets within trusted code
pull_request_target:
types: [opened, synchronize, closed]
branches: [main, master]
jobs:
flowzone:
name: Flowzone
uses: product-os/flowzone/.github/workflows/flowzone.yml@master
# prevent duplicate workflows and only allow one `pull_request` or `pull_request_target` for
# internal or external contributions respectively
if: |
(github.event.pull_request.head.repo.full_name == github.repository && github.event_name == 'pull_request') ||
(github.event.pull_request.head.repo.full_name != github.repository && github.event_name == 'pull_request_target')
secrets: inherit
with:
balena_slugs:
balena/testbot-rig,
balena/testbot-personal,
balena/leviathan-worker-amd64,
balena/leviathan-worker-aarch64,
balena/leviathan-worker-armv7hf
e2e:
needs: [flowzone]
if: |
((github.event.pull_request.head.repo.full_name == github.repository && github.event_name == 'pull_request') ||
(github.event.pull_request.head.repo.full_name != github.repository && github.event_name == 'pull_request_target')) &&
github.event.action != 'closed'
runs-on: ubuntu-22.04
env:
SUITES: ./suites
REPORTS: ./reports
WORKSPACE: ./workspace
BALENACLOUD_ORG: testbot
BALENACLOUD_API_KEY: ${{ secrets.BALENA_TESTBOT_TOKEN }}
BALENACLOUD_APP_NAME: balena/testbot-rig
BALENACLOUD_API_URL: balena-cloud.com
ENVIRONMENT: ${{ matrix.ENVIRONMENT }}
BALENAMACHINE_API_KEY: ${{ secrets.BALENAMACHINE_API_KEY }}
BALENAMACHINE_API_URL: bm.balena-dev.com
BALENACLOUD_SSH_URL: ssh.devices.bm.balena-dev.com
BALENACLOUD_SSH_PORT: 222
QEMU_CPUS: 1
QEMU_MEMORY: 1G
WORKER_TYPE: ${{ matrix.WORKER_TYPE }}
DEVICE_TYPE: ${{ matrix.DEVICE_TYPE }}
defaults:
run:
working-directory: .
shell: bash --noprofile --norc -eo pipefail -x {0}
strategy:
fail-fast: false
matrix:
include:
- DEVICE_TYPE: genericx86-64-ext
WORKER_TYPE: qemu
WORKER_APP_ID: "1941514" # balena/leviathan-worker-amd64
- DEVICE_TYPE: generic-amd64
WORKER_TYPE: qemu
WORKER_APP_ID: "1941514" # balena/leviathan-worker-amd64
- DEVICE_TYPE: generic-aarch64
WORKER_TYPE: qemu
WORKER_APP_ID: "1941514" # balena/leviathan-worker-aarch64
# Commented because testbot devices aren't available to test worker releases
# - DEVICE_TYPE: raspberrypi3
# WORKER_TYPE: testbot
# WORKER_APP_ID: "1941517" # balena/leviathan-worker-armv7hf
# - DEVICE_TYPE: raspberrypi4-64
# WORKER_TYPE: testbot
# WORKER_APP_ID: "1941515" # balena/leviathan-worker-aarch64
steps:
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
with:
submodules: true
repository: balena-os/leviathan
ref: master
- name: Get worker release
env:
ENVIRONMENT: "balena-cloud.com"
VERSION: "v6"
TAG_KEY: "balena-ci-commit-sha"
TAG_VALUE: ${{ github.event.pull_request.head.sha }}
run: |
url=()
url+=("https://api.${{ env.ENVIRONMENT }}/${{ env.VERSION }}/release")
url+=("?\$filter=")
url+=("(belongs_to__application%20eq%20${{ matrix.WORKER_APP_ID }})")
url+=("%20and%20")
url+=("(")
url+=("(status%20eq%20%27success%27)")
url+=("%20and%20")
url+=("(release_tag/any(rt:(rt/tag_key%20eq%20%27${{ env.TAG_KEY }}%27)%20and%20(rt/value%20eq%20%27${{ env.TAG_VALUE }}%27)))")
url+=(")")
url+=("&\$orderby=created_at%20desc")
url+=("&\$select=commit")
url+=("&\$top=1")
commit="$(IFS= ; curl -fsSL -X GET "${url[*]}" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${{ secrets.BALENA_API_KEY_PUSH }}" | jq -r '.d[].commit')"
test -n "${commit}" || exit 1
echo "WORKER_RELEASE=${commit}" >> $GITHUB_ENV
- name: Copy suite config
run: |
cp -a ${{ env.SUITES }}/config.js ${{ env.WORKSPACE }}/config.js
sed -r 's|(bh\.cr/balena/leviathan-worker(-[^/]+)?)/.+|\1/${{ env.WORKER_RELEASE }}|' -i docker-compose.qemu.yml
- name: Build leviathan images
run: make build
# - name: Select and repin a testbot worker
# if: ${{ env.DEVICE_TYPE }} == 'testbot'
# run: #TODO
- name: Run test suite
id: run-suite
run: |
make config
make test || exit 1
- uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3
if: steps.run-suite.conclusion == 'success'
with:
name: reports-${{ env.WORKER_TYPE }}-${{ env.DEVICE_TYPE }}
path: ${{ env.REPORTS }}
balenamachine-push:
needs: [flowzone]
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
- name: Get worker release
env:
ENVIRONMENT: "balena-cloud.com"
VERSION: "v6"
WORKER_APP_ID: "1941517" # balena/leviathan-worker-armv7hf in balenaCloud
TAG_KEY: "balena-ci-commit-sha"
TAG_VALUE: ${{ github.event.pull_request.head.sha }}
run: |
url=()
url+=("https://api.${{ env.ENVIRONMENT }}/${{ env.VERSION }}/release")
url+=("?\$filter=")
url+=("(belongs_to__application%20eq%20${{ env.WORKER_APP_ID }})")
url+=("%20and%20")
url+=("(")
url+=("(status%20eq%20%27success%27)")
url+=("%20and%20")
url+=("(release_tag/any(rt:(rt/tag_key%20eq%20%27${{ env.TAG_KEY }}%27)%20and%20(rt/value%20eq%20%27${{ env.TAG_VALUE }}%27)))")
url+=(")")
url+=("&\$orderby=created_at%20desc")
url+=("&\$select=commit")
url+=("&\$top=1")
commit="$(IFS= ; curl -fsSL -X GET "${url[*]}" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${{ secrets.BALENA_API_KEY_PUSH }}" | jq -r '.d[].commit')"
test -n "${commit}" || exit 1
echo "WORKER_RELEASE=${commit}" >> $GITHUB_ENV
- name: Update balenaMachine docker-compose.yml
shell: bash
run: |
sed -r 's|build: .|image: bh\.cr/balena/leviathan-worker-armv7hf/${{ env.WORKER_RELEASE }} |' -i docker-compose.yml
cat docker-compose.yml
# - name: Describe git state
# id: git_describe
# shell: bash
# run: |
# describe="$(git describe HEAD --tags --always)"
# semver="$(npx -q -y -- semver -c -l "${describe}")"
# echo "semver=${semver}" >> $GITHUB_OUTPUT
- name: Deploy to balenaMachine
uses: balena-io/deploy-to-balena-action@master
with:
balena_token: ${{ secrets.BALENAMACHINE_API_KEY }}
fleet: balena/testbot-rig
environment: 'bm.balena-dev.com'
source: .