-
Notifications
You must be signed in to change notification settings - Fork 0
252 lines (213 loc) · 7.96 KB
/
test-scripts.yml
File metadata and controls
252 lines (213 loc) · 7.96 KB
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
name: Test Setup Scripts
on:
push:
branches: [main, master, develop]
pull_request:
branches: [main, master]
workflow_dispatch:
jobs:
test-prepare-pi:
name: Test prepare_pi.sh
runs-on: ubuntu-latest
strategy:
matrix:
pi-os-version: ["12", "13"]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up QEMU for ARM emulation
uses: docker/setup-qemu-action@v3
with:
platforms: arm64
- name: Create test container
id: container
run: |
docker run -d --platform linux/arm64 \
-v "$PWD:/workspace" \
-w /workspace \
--privileged \
--name test-prepare-pi-${{ matrix.pi-os-version }} \
debian:bookworm-slim \
tail -f /dev/null
echo "container=test-prepare-pi-${{ matrix.pi-os-version }}" >> $GITHUB_OUTPUT
- name: Setup mock Pi environment
run: |
docker exec ${{ steps.container.outputs.container }} bash -c "
chmod +x .github/scripts/*.sh
source ./.github/scripts/setup-pi-mock.sh ${{ matrix.pi-os-version == '12' && '4' || '5' }} ${{ matrix.pi-os-version }}
"
- name: Setup boot files
run: |
docker exec ${{ steps.container.outputs.container }} \
./.github/scripts/setup-boot-files.sh
- name: Install mock systemctl
run: |
docker exec ${{ steps.container.outputs.container }} \
./.github/scripts/mock-systemctl.sh
- name: Run prepare_pi.sh
run: |
docker exec ${{ steps.container.outputs.container }} bash -c "
source /etc/profile.d/pi-test-env.sh
chmod +x prepare_pi.sh
./prepare_pi.sh
"
- name: Validate changes
run: |
docker exec ${{ steps.container.outputs.container }} \
./.github/scripts/validate-prepare-pi.sh ${{ matrix.pi-os-version }}
- name: Test idempotency
run: |
docker exec ${{ steps.container.outputs.container }} bash -c "
source /etc/profile.d/pi-test-env.sh
echo 'Testing idempotency (running script again)...'
./prepare_pi.sh
echo '✓ Script is idempotent'
"
- name: Cleanup container
if: always()
run: docker rm -f ${{ steps.container.outputs.container }} || true
test-install-dvmhost:
name: Test install_dvmhost.sh
runs-on: ubuntu-latest
strategy:
matrix:
pi-os-version: ["12", "13"]
pi-model: ["4", "5"]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up QEMU for ARM emulation
uses: docker/setup-qemu-action@v3
with:
platforms: arm64
- name: Create test container
id: container
run: |
docker run -d --platform linux/arm64 \
-v "$PWD:/workspace" \
-w /workspace \
--name test-dvmhost-${{ matrix.pi-os-version }}-pi${{ matrix.pi-model }} \
debian:bookworm-slim \
tail -f /dev/null
echo "container=test-dvmhost-${{ matrix.pi-os-version }}-pi${{ matrix.pi-model }}" >> $GITHUB_OUTPUT
- name: Setup mock Pi environment
run: |
docker exec ${{ steps.container.outputs.container }} bash -c "
chmod +x .github/scripts/*.sh
source ./.github/scripts/setup-pi-mock.sh ${{ matrix.pi-model }} ${{ matrix.pi-os-version }}
"
- name: Update packages
run: |
docker exec ${{ steps.container.outputs.container }} bash -c "
apt-get update -qq
apt-get install -y curl
"
- name: Setup mock NetBird
run: |
docker exec ${{ steps.container.outputs.container }} \
./.github/scripts/mock-netbird.sh
- name: Run install_dvmhost.sh
run: |
docker exec ${{ steps.container.outputs.container }} bash -c "
source /etc/profile.d/pi-test-env.sh
chmod +x install_dvmhost.sh
./install_dvmhost.sh
"
- name: Restore curl
if: always()
run: |
docker exec ${{ steps.container.outputs.container }} \
./.github/scripts/restore-curl.sh || true
- name: Validate installation
run: |
docker exec ${{ steps.container.outputs.container }} \
./.github/scripts/validate-dvmhost.sh
- name: Cleanup container
if: always()
run: docker rm -f ${{ steps.container.outputs.container }} || true
test-setup-dvmhost:
name: Test setup_dvmhost.sh
runs-on: ubuntu-latest
strategy:
matrix:
pi-os-version: ["12", "13"]
site-type: ["CC/VC", "CONVENTIONAL"]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up QEMU for ARM emulation
uses: docker/setup-qemu-action@v3
with:
platforms: arm64
- name: Create test container
id: container
run: |
docker run -d --platform linux/arm64 \
-v "$PWD:/workspace" \
-w /workspace \
--name test-setup-dvmhost-${{ matrix.pi-os-version }}-${{ matrix.site-type == 'CC/VC' && 'ccvc' || 'conv' }} \
debian:bookworm-slim \
tail -f /dev/null
echo "container=test-setup-dvmhost-${{ matrix.pi-os-version }}-${{ matrix.site-type == 'CC/VC' && 'ccvc' || 'conv' }}" >> $GITHUB_OUTPUT
- name: Setup mock Pi environment
run: |
docker exec ${{ steps.container.outputs.container }} bash -c "
chmod +x .github/scripts/*.sh
source ./.github/scripts/setup-pi-mock.sh 5 ${{ matrix.pi-os-version }}
"
- name: Update packages and install dependencies
run: |
docker exec ${{ steps.container.outputs.container }} bash -c "
apt-get update -qq
apt-get install -y curl
"
- name: Setup config directory
run: |
docker exec ${{ steps.container.outputs.container }} bash -c "
mkdir -p /opt/centrunk/configs
mkdir -p /opt/centrunk/dvmhost
touch /opt/centrunk/dvmhost/dummy
"
- name: Setup mock config templates
run: |
docker exec ${{ steps.container.outputs.container }} \
./.github/scripts/setup-mock-templates.sh
- name: Run setup_dvmhost.sh (automated)
run: |
docker exec ${{ steps.container.outputs.container }} bash -c "
source /etc/profile.d/pi-test-env.sh
chmod +x setup_dvmhost.sh
./.github/scripts/run-setup-dvmhost-automated.sh '${{ matrix.site-type }}'
"
- name: Validate configuration
run: |
docker exec ${{ steps.container.outputs.container }} \
./.github/scripts/validate-setup-dvmhost.sh '${{ matrix.site-type }}'
- name: Cleanup container
if: always()
run: docker rm -f ${{ steps.container.outputs.container }} || true
validation-summary:
name: Validation Summary
needs: [test-prepare-pi, test-install-dvmhost, test-setup-dvmhost]
runs-on: ubuntu-latest
if: always()
steps:
- name: Check test results
run: |
if [ "${{ needs.test-prepare-pi.result }}" != "success" ]; then
echo "❌ prepare_pi.sh tests failed"
exit 1
fi
if [ "${{ needs.test-install-dvmhost.result }}" != "success" ]; then
echo "❌ install_dvmhost.sh tests failed"
exit 1
fi
if [ "${{ needs.test-setup-dvmhost.result }}" != "success" ]; then
echo "❌ setup_dvmhost.sh tests failed"
exit 1
fi
echo "✅ All tests passed successfully!"
echo "Scripts validated in:"
echo " - Raspberry Pi OS 12 (Pi 4 & 5)"
echo " - Raspberry Pi OS 13 (Pi 4 & 5)"
echo " - CC/VC and Conventional configurations"