-
Notifications
You must be signed in to change notification settings - Fork 4
210 lines (184 loc) · 7.59 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
199
200
201
202
203
204
205
206
207
208
209
210
name: Flowzone
on:
pull_request:
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-rig-partners,
balena/testbot-rig-partners-x86,
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-24.04
environment: ${{ matrix.ENVIRONMENT_URL }}
env:
SUITES: ./suites
REPORTS: ./reports
WORKSPACE: ./workspace
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
ENVIRONMENT_URL: balena-cloud.com
- DEVICE_TYPE: generic-amd64
WORKER_TYPE: qemu
WORKER_APP_ID: "1941514" # balena/leviathan-worker-amd64
ENVIRONMENT_URL: balena-cloud.com
- DEVICE_TYPE: generic-aarch64
WORKER_TYPE: qemu
WORKER_APP_ID: "1941514" # balena/leviathan-worker-aarch64
ENVIRONMENT_URL: balena-cloud.com
# 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@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
submodules: true
repository: balena-os/leviathan
ref: master
persist-credentials: false
- name: Get worker release
env:
VERSION: "v6"
TAG_KEY: "balena-ci-commit-sha"
TAG_VALUE: ${{ github.event.pull_request.head.sha }}
run: |
url=()
url+=("https://api.${{ matrix.ENVIRONMENT_URL }}/${{ 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_DEPLOY_KEY }}" | 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
env:
BALENACLOUD_API_KEY: ${{ secrets.BALENA_API_TEST_KEY }}
BALENACLOUD_API_URL: ${{ matrix.ENVIRONMENT_URL }}
BALENACLOUD_SSH_PORT: ${{ vars.BALENACLOUD_SSH_PORT }}
BALENACLOUD_SSH_URL: ${{ vars.BALENACLOUD_SSH_URL }}
DEVICE_TYPE: ${{ matrix.DEVICE_TYPE }}
WORKER_TYPE: ${{ matrix.WORKER_TYPE }}
QEMU_CPUS: 1
QEMU_MEMORY: "1G"
TEST_SUITE: e2e
BALENACLOUD_APP_NAME: ${{ vars.BALENACLOUD_APP_NAME }}
BALENACLOUD_ORG: ${{ vars.BALENACLOUD_ORG }}
REPORTS: ${{ env.REPORTS }}
SUITES: ${{ env.SUITES }}
WORKSPACE: ${{ env.WORKSPACE }}
run: |
make config
make test || exit 1
- uses: actions/upload-artifact@ff15f0306b3f739f7b6fd43fb5d26cd321bd4de5 # 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-24.04
environment: "bm.balena-dev.com"
strategy:
fail-fast: false
matrix:
include:
- WORKER_APP_ID: "1941517" # balena/leviathan-worker-armv7hf
ARCHITECTURE: "armv7hf"
FLEET_NAME: "balena/testbot-rig"
- WORKER_APP_ID: "1941514" # balena/leviathan-worker-armv7hf
ARCHITECTURE: "amd64"
FLEET_NAME: "balena/testbot-rig-x86"
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
persist-credentials: false
- name: Get worker release
env:
ENVIRONMENT_URL: "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_URL }}/${{ 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_DEPLOY_KEY }}" | 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-${{ matrix.ARCHITECTURE }}/${{ env.WORKER_RELEASE }} |' -i docker-compose.yml
cat docker-compose.yml
- name: Deploy to balenaOS balenaMachine testbot-rig
uses: balena-io/deploy-to-balena-action@master
with:
balena_token: ${{ secrets.BALENA_API_TEST_KEY }}
fleet: ${{ matrix.FLEET_NAME }}
environment: 'bm.balena-dev.com'
source: .