forked from opensandbox-group/OpenSandbox
-
Notifications
You must be signed in to change notification settings - Fork 0
249 lines (219 loc) · 8.65 KB
/
Copy pathexecd-test.yml
File metadata and controls
249 lines (219 loc) · 8.65 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
name: Execd Tests
on:
pull_request:
branches: [ main ]
permissions:
contents: read
pull-requests: read
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
changes:
uses: ./.github/workflows/detect-changes.yml
with:
area: execd
test:
needs: changes
if: needs.changes.outputs.relevant == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: '1.25.9'
- name: Check gofmt
working-directory: components/execd
run: |
files="$(gofmt -l . ../internal)"
if [ -n "$files" ]; then
echo "$files"
exit 1
fi
- name: Run golint
working-directory: components/execd
run: |
make golint
- name: Build (Multi platform compile)
working-directory: components/execd
run: |
make multi-build
- name: Run tests with coverage
working-directory: components/execd
run: |
go test -v -coverpkg=./... -coverprofile=coverage.out -covermode=atomic ./pkg/...
- name: Calculate coverage and generate summary
working-directory: components/execd
id: coverage
run: |
# Extract total coverage percentage
TOTAL_COVERAGE=$(go tool cover -func=coverage.out | grep total | awk '{print $3}')
echo "total_coverage=$TOTAL_COVERAGE" >> $GITHUB_OUTPUT
# Generate GitHub Actions job summary
echo "## 📊 execd Test Coverage Report" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Total Line Coverage:** $TOTAL_COVERAGE" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "Coverage report generated for commit \`${{ github.sha }}\`" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "---" >> $GITHUB_STEP_SUMMARY
echo "*Coverage targets: Core packages >80%, API layer >70%*" >> $GITHUB_STEP_SUMMARY
smoke:
needs: changes
if: needs.changes.outputs.relevant == 'true'
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: '1.25.9'
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.10'
- name: Install make (Windows)
if: matrix.os == 'windows-latest'
shell: powershell
run: choco install make -y
- name: Build
working-directory: components/execd
run: |
make build
- name: Run smoke test
working-directory: components/execd
run: |
chmod +x tests/smoke.sh
./tests/smoke.sh
sleep 5
python3 tests/smoke_api.py
- name: SIGTERM forward test
if: matrix.os == 'ubuntu-latest'
working-directory: components/execd
run: |
chmod +x tests/sigterm_forward.sh
./tests/sigterm_forward.sh
- name: Smoke test bwrap (Docker image build + extraction)
if: matrix.os == 'ubuntu-latest'
shell: bash
run: |
chmod +x components/execd/tests/smoke_bwrap.sh
bash components/execd/tests/smoke_bwrap.sh
- name: Show logs
if: always()
run: |
set -x
cat components/execd/startup.log || true
cat components/execd/execd.log || true
bwrap-smoke:
needs: changes
if: needs.changes.outputs.relevant == 'true'
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: '1.25.9'
- name: Build latest bubblewrap (v0.11.2)
run: |
sudo apt-get install -y meson ninja-build libcap-dev pkg-config
git clone --depth 1 --branch v0.11.2 https://github.com/containers/bubblewrap /tmp/bwrap
cd /tmp/bwrap
meson setup builddir -Dprefix=/usr -Dman=disabled -Dtests=false
ninja -C builddir
sudo cp builddir/bwrap /usr/local/bin/bwrap
bwrap --version
- name: Build and install native session workload gate
working-directory: components/execd
run: |
install_root="${RUNNER_TEMP}/execd-session-gate-root"
make build-session-gate
mkdir -p \
"${install_root}/usr/local/libexec" \
"${install_root}/opt/opensandbox"
chmod 0777 \
"${install_root}/usr/local/libexec" \
"${install_root}/opt/opensandbox"
make install-session-gate DESTDIR="${install_root}"
test -x bin/opensandbox-session-gate
test -x "${install_root}/usr/local/libexec/opensandbox-session-gate"
test -x "${install_root}/opt/opensandbox/opensandbox-session-gate"
test "$(stat -c '%a' "${install_root}/usr/local/libexec")" = "755"
test "$(stat -c '%a' "${install_root}/opt/opensandbox")" = "755"
cmp \
bin/opensandbox-session-gate \
"${install_root}/usr/local/libexec/opensandbox-session-gate"
cmp \
bin/opensandbox-session-gate \
"${install_root}/opt/opensandbox/opensandbox-session-gate"
test "$(stat -c '%a' "${install_root}/usr/local/libexec/opensandbox-session-gate")" = "555"
test "$(stat -c '%a' "${install_root}/opt/opensandbox/opensandbox-session-gate")" = "555"
file bin/opensandbox-session-gate | grep -q 'statically linked'
sudo install -d -o "$(id -u)" -g "$(id -g)" -m 0777 /opt/opensandbox
sudo make install-session-gate
test -x /usr/local/bin/bwrap
test -x /usr/local/libexec/opensandbox-session-gate
test -x /opt/opensandbox/opensandbox-session-gate
test "$(stat -c '%U:%G' /usr/local/libexec)" = "root:root"
test "$(stat -c '%U:%G' /opt/opensandbox)" = "root:root"
test "$(stat -c '%U:%G' /usr/local/libexec/opensandbox-session-gate)" = "root:root"
test "$(stat -c '%U:%G' /opt/opensandbox/opensandbox-session-gate)" = "root:root"
test "$(stat -c '%a' /usr/local/libexec)" = "755"
test "$(stat -c '%a' /opt/opensandbox)" = "755"
test "$(stat -c '%a' /usr/local/libexec/opensandbox-session-gate)" = "555"
test "$(stat -c '%a' /opt/opensandbox/opensandbox-session-gate)" = "555"
- name: Run workload lifecycle integration test
working-directory: components/execd
run: |
# Execd must authenticate a non-root workload without CAP_SYS_PTRACE.
sudo -E setpriv --bounding-set=-sys_ptrace env "PATH=$PATH" go test \
-v -count=1 -timeout=2m \
-run '^TestBwrapLifecycleEndToEnd$' \
./pkg/isolation
- name: Run namespace pin lifecycle integration test
working-directory: components/execd
run: |
# Pinning must not depend on CAP_SYS_PTRACE in either uid mode.
sudo -E setpriv --bounding-set=-sys_ptrace env "PATH=$PATH" go test \
-tags="linux,bwrap" -v -count=1 -timeout=2m \
-run '^TestPrivateSessionPinsNamespacesBeforeMarkReady$' \
./pkg/runtime
- name: Run bwrap integration tests
working-directory: components/execd
run: sudo -E env "PATH=$PATH" go test -tags="linux,bwrap" -v -count=1 -timeout=5m ./pkg/runtime/bwrap_test/
required:
name: Execd CI
if: always()
needs: [changes, test, smoke, bwrap-smoke]
runs-on: ubuntu-latest
steps:
- name: Verify required jobs
env:
RELEVANT: ${{ needs.changes.outputs.relevant }}
CHANGES_RESULT: ${{ needs.changes.result }}
TEST_RESULT: ${{ needs.test.result }}
SMOKE_RESULT: ${{ needs.smoke.result }}
BWRAP_SMOKE_RESULT: ${{ needs.bwrap-smoke.result }}
run: |
if [[ "$CHANGES_RESULT" != "success" ]]; then
echo "Change detection failed: $CHANGES_RESULT"
exit 1
fi
if [[ "$RELEVANT" == "true" ]]; then
[[ "$TEST_RESULT" == "success" && "$SMOKE_RESULT" == "success" && "$BWRAP_SMOKE_RESULT" == "success" ]]
else
[[ "$RELEVANT" == "false" && "$TEST_RESULT" == "skipped" && "$SMOKE_RESULT" == "skipped" && "$BWRAP_SMOKE_RESULT" == "skipped" ]]
fi