Repository navigation
361 lines (313 loc) · 13.6 KB
/
Copy pathci.yml
File metadata and controls
361 lines (313 loc) · 13.6 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
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
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
name: CI
on:
pull_request:
push:
branches:
- main
env:
# Increment to bust Go module cache when needed.
GO_CACHE_VERSION: v4
jobs:
test-linux:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Install build deps
run: sudo apt-get update && sudo apt-get install -y libfuse-dev libfuse3-dev libseccomp-dev pkg-config
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: go.mod
cache: false
- name: Cache Go modules
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: ${{ env.GO_CACHE_VERSION }}-${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ env.GO_CACHE_VERSION }}-${{ runner.os }}-go-
- name: Free disk space
run: |
echo "=== Disk space before cleanup ==="
df -h /tmp /home/runner
sudo rm -rf /usr/local/lib/android /usr/share/dotnet /opt/ghc /usr/local/share/powershell
echo "=== Disk space after cleanup ==="
df -h /tmp /home/runner
- name: go test
run: |
mkdir -p "$GOTMPDIR"
go test -p 2 ./...
env:
GOTMPDIR: ${{ runner.temp }}/go-tmp
- name: smoke
run: make smoke
- name: macOS bundle assemble smoke test
run: scripts/test-assemble-macos-bundle.sh
test-macos:
runs-on: macos-latest
timeout-minutes: 25
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: go.mod
cache: false
- name: Cache Go modules
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: |
~/go/pkg/mod
~/Library/Caches/go-build
key: ${{ env.GO_CACHE_VERSION }}-${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ env.GO_CACHE_VERSION }}-${{ runner.os }}-go-
# nofuse matches how macOS is actually shipped (Makefile build-macos-go
# and release.yml both pass it). macOS uses the Endpoint Security
# Framework for file monitoring, never FUSE -- detect_darwin.go hardcodes
# checkAvailable() to false -- so the macFUSE/FUSE-T install this job used
# to do bought nothing but minutes.
- name: go build
run: CGO_ENABLED=1 go build -tags nofuse ./...
- name: go test (all packages)
run: CGO_ENABLED=1 go test -tags nofuse ./...
# Compile the Swift system extension. Without this the entire sysext --
# ESFClient, SessionPolicyCache, PolicySocketClient -- is built for the
# first time at release, so a Swift break reaches main undetected.
# Unsigned: CI has no certificates, and signing is exercised by the
# release workflow.
- name: xcodebuild (Swift sysext, unsigned)
run: |
xcodebuild \
-project macos/AgentMon/agentmon.xcodeproj \
-scheme agentmon \
-configuration Release \
-derivedDataPath build/DerivedData \
CODE_SIGN_IDENTITY="" \
CODE_SIGNING_REQUIRED=NO \
CODE_SIGNING_ALLOWED=NO \
-quiet
# The Swift side has no test target. This runs the one piece of it that
# is pure logic worth pinning -- CIDR matching, whose failure mode is a
# network rule that silently matches nothing.
- name: Swift CIDR matcher
run: scripts/test-swift-cidr.sh
# File rules must decide in policy order, as the Go engine does.
- name: Swift file rule order
run: scripts/test-swift-file-rules.sh
# A session process must not be able to change the daemon's directory.
- name: Swift control directory guard
run: scripts/test-swift-control-dir.sh
# The extension must drop sessions the daemon no longer has, or every
# file open on the machine stays on the slow path.
- name: Swift session sync
run: scripts/test-swift-session-sync.sh
# The approval dialog's parser, launch URL, socket path and wire format,
# checked against the JSON the Go policy socket tests pin.
- name: Swift approval dialog client
run: scripts/test-swift-approval-client.sh
# The extension must decide file and network cases as the Go engine
# does. TestPolicyParity_GoEngine runs the same table through Go.
- name: Swift policy parity
run: scripts/test-swift-policy-parity.sh
# codesign rejects entitlements that plutil accepts, and the xcodebuild
# step above signs nothing.
- name: Entitlements files sign
run: scripts/test-entitlements-sign.sh
build-matrix:
needs: [test-linux, test-macos]
runs-on: ubuntu-latest
timeout-minutes: 15
strategy:
matrix:
# darwin/amd64 is excluded: agentmon ships arm64-only macOS builds, and
# a build target nothing releases is a target nobody notices breaking.
include:
- goos: linux
goarch: amd64
- goos: linux
goarch: arm64
- goos: darwin
goarch: arm64
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: go.mod
cache: false
- name: Cache Go modules
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: ${{ env.GO_CACHE_VERSION }}-${{ runner.os }}-go-${{ matrix.goos }}-${{ matrix.goarch }}-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ env.GO_CACHE_VERSION }}-${{ runner.os }}-go-${{ matrix.goos }}-${{ matrix.goarch }}-
- name: Install build deps (linux only)
if: matrix.goos == 'linux'
run: sudo apt-get update && sudo apt-get install -y libfuse-dev libfuse3-dev libseccomp-dev pkg-config
- name: Cross-compile (build only)
run: |
if [ "${{ matrix.goos }}" = "linux" ]; then
if [ "${{ matrix.goarch }}" = "arm64" ]; then
export CGO_ENABLED=0
else
export CGO_ENABLED=1
fi
else
export CGO_ENABLED=0
fi
GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} CGO_ENABLED=$CGO_ENABLED go build ./...
build-linux-arm64-cgo:
# Pinned. This job installs amd64 and arm64 builds of the same
# libraries side by side, and multiarch needs matching versions. On
# ubuntu-latest (26.04 by 2026-10-28) the image ships newer amd64 builds
# than the arm64 ports archive, and apt can only satisfy the install by
# downgrading 38 packages.
runs-on: ubuntu-24.04
timeout-minutes: 15
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Install build deps
run: |
# Ubuntu hosts arm64 packages on ports.ubuntu.com, not
# archive.ubuntu.com. Without restricting the default sources
# to amd64 and adding a ports source for arm64, `apt-get
# update` after `dpkg --add-architecture arm64` 404s on every
# arm64 Packages file.
#
# The suite comes from the host. It was hardcoded to noble, and
# when ubuntu-latest moved past 24.04 the arm64 packages came
# from an older release than the amd64 ones: libseccomp-dev
# 2.5.5 for arm64 against 2.6.0 for amd64, which apt cannot
# install side by side.
. /etc/os-release
sudo sed -i '/^Types: deb$/a Architectures: amd64' /etc/apt/sources.list.d/ubuntu.sources
sudo tee /etc/apt/sources.list.d/arm64-ports.sources >/dev/null <<EOF
Types: deb
URIs: http://ports.ubuntu.com/ubuntu-ports
Suites: ${VERSION_CODENAME} ${VERSION_CODENAME}-updates ${VERSION_CODENAME}-security
Components: main universe restricted multiverse
Architectures: arm64
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
EOF
sudo dpkg --add-architecture arm64
sudo apt-get update
sudo apt-get install -y libfuse-dev libfuse3-dev pkg-config gcc-aarch64-linux-gnu libseccomp-dev libseccomp-dev:arm64
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: go.mod
cache: false
- name: Cache Go modules
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: ${{ env.GO_CACHE_VERSION }}-${{ runner.os }}-go-linux-arm64-cgo-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ env.GO_CACHE_VERSION }}-${{ runner.os }}-go-linux-arm64-cgo-
- name: Cross-compile (arm64 CGO)
run: go build ./...
env:
GOOS: linux
GOARCH: arm64
CGO_ENABLED: "1"
CC: aarch64-linux-gnu-gcc
PKG_CONFIG_LIBDIR: /usr/lib/aarch64-linux-gnu/pkgconfig:/usr/share/pkgconfig
integration:
needs: [test-linux]
runs-on: ubuntu-latest
timeout-minutes: 25
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Install build deps
run: |
sudo apt-get update && sudo apt-get install -y libseccomp-dev pkg-config fuse3
sudo modprobe fuse
# Ensure /dev/fuse exists and is accessible
if [ ! -e /dev/fuse ]; then
sudo mknod /dev/fuse -m 0666 c 10 229
fi
sudo chmod 666 /dev/fuse
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: go.mod
cache: false
- name: Cache Go modules
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: ${{ env.GO_CACHE_VERSION }}-${{ runner.os }}-go-integration-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ env.GO_CACHE_VERSION }}-${{ runner.os }}-go-integration-
- name: Run integration tests (docker)
env:
DOCKER_HOST: unix:///var/run/docker.sock
TESTCONTAINERS_RYUK_CONTAINER_PRIVILEGED: true
run: go test -v -tags=integration ./internal/integration/...
- name: Run API integration tests
run: go test -v -tags=integration ./internal/api/... ./internal/proxy/...
fargate-e2e:
if: >-
github.event_name == 'push' &&
github.ref == 'refs/heads/main' &&
vars.AWS_ECS_CLUSTER != ''
needs: [test-linux, integration]
continue-on-error: true
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: go.mod
cache: false
- name: Cache Go modules
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: ${{ env.GO_CACHE_VERSION }}-${{ runner.os }}-go-fargate-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ env.GO_CACHE_VERSION }}-${{ runner.os }}-go-fargate-
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@e1253824e5c10ff9df46874f81ed3ec929e19cfd # v6.3.0
with:
aws-region: ${{ vars.AWS_REGION || 'us-east-1' }}
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
- name: Login to Amazon ECR
id: ecr-login
uses: aws-actions/amazon-ecr-login@03f1aad4c6c7ffd436567f42f9384779290529bd # v2.1.7
- name: Build and push agentmon test image
env:
ECR_REGISTRY: ${{ steps.ecr-login.outputs.registry }}
IMAGE_TAG: ${{ github.sha }}
run: |
docker build -f Dockerfile.ptrace-test -t $ECR_REGISTRY/agentmon-test:$IMAGE_TAG .
docker push $ECR_REGISTRY/agentmon-test:$IMAGE_TAG
- name: Build seccomp probe
run: mkdir -p build && GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o build/seccomp-probe ./cmd/seccomp-probe/
- name: Build and push workload test image
env:
ECR_REGISTRY: ${{ steps.ecr-login.outputs.registry }}
IMAGE_TAG: ${{ github.sha }}
run: |
docker build -f Dockerfile.fargate-workload -t $ECR_REGISTRY/agentmon-fargate-workload:$IMAGE_TAG .
docker push $ECR_REGISTRY/agentmon-fargate-workload:$IMAGE_TAG
- name: Run Fargate E2E tests
env:
AWS_REGION: ${{ vars.AWS_REGION || 'us-east-1' }}
AWS_ECS_CLUSTER: ${{ vars.AWS_ECS_CLUSTER }}
AWS_ECS_SUBNET: ${{ vars.AWS_ECS_SUBNET }}
AWS_ECS_SECURITY_GROUP: ${{ vars.AWS_ECS_SECURITY_GROUP }}
AWS_ECS_EXECUTION_ROLE_ARN: ${{ vars.AWS_ECS_EXECUTION_ROLE_ARN }}
AGENTMON_TEST_IMAGE: ${{ steps.ecr-login.outputs.registry }}/agentmon-test:${{ github.sha }}
WORKLOAD_TEST_IMAGE: ${{ steps.ecr-login.outputs.registry }}/agentmon-fargate-workload:${{ github.sha }}
run: go test -v -tags=fargate -timeout 5m ./internal/integration/fargate/...