Skip to content

Commit 65052cf

Browse files
committed
Add seccomp codegen check to CI
Signed-off-by: Austin Vazquez <[email protected]>
1 parent 8c4e31c commit 65052cf

File tree

3 files changed

+51
-3
lines changed

3 files changed

+51
-3
lines changed

.github/workflows/ci.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,3 +101,19 @@ jobs:
101101
run: |
102102
echo "One or more lint checks failed"
103103
exit 1
104+
105+
check-codegen:
106+
name: Check seccomp code generation
107+
runs-on: ubuntu-latest
108+
steps:
109+
- name: Checkout code
110+
uses: actions/checkout@v4
111+
112+
- name: Set up Go
113+
uses: actions/setup-go@v5
114+
with:
115+
go-version: stable
116+
117+
- name: Validate seccomp code generation
118+
run: make validate-codegen
119+

Makefile

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
# SPDX-License-Identifier: Apache-2.0
33

44
# Makefile for building and testing Moby profiles packages
5+
PROJECT_ROOT ?= $(shell pwd)
6+
SCRIPTDIR ?= $(PROJECT_ROOT)/script
57
PACKAGES ?= apparmor seccomp
68
CROSSBUILDS ?= linux/arm linux/arm64 linux/amd64 linux/ppc64le linux/s390x
79

@@ -32,9 +34,15 @@ crossbuild:
3234
test: CMD=go test -v ./...
3335
test: foreach
3436

37+
.PHONY: validate-codegen
38+
validate-codegen:
39+
@echo "Validating code generation..."
40+
bash $(SCRIPTDIR)/validate/default-seccomp
41+
3542
.PHONY: help
3643
help:
3744
@echo "Available targets:"
38-
@echo " crossbuild - Cross build all modules"
39-
@echo " test - Run tests for all modules"
40-
@echo " help - Display this help message"
45+
@echo " crossbuild - Cross build all modules"
46+
@echo " test - Run tests for all modules"
47+
@echo " validate-codegen - Validate code generation for seccomp"
48+
@echo " help - Display this help message"

script/validate/default-seccomp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright The Moby Authors.
4+
# SPDX-License-Identifier: Apache-2.0
5+
6+
# This script validates that the seccomp profile generation is done correctly.
7+
8+
# We run 'go generate' and see if we have a diff afterwards
9+
go generate ./seccomp/ > /dev/null
10+
# Let see if the working directory is clean
11+
diffs="$(git status --porcelain -- seccomp 2> /dev/null)"
12+
if [ "$diffs" ]; then
13+
{
14+
echo 'The result of go generate ./seccomp/ differs'
15+
echo
16+
echo "$diffs"
17+
echo
18+
echo 'Please re-run go generate ./seccomp/'
19+
echo
20+
} >&2
21+
false
22+
else
23+
echo 'Congratulations! Seccomp profile generation is done correctly.'
24+
fi

0 commit comments

Comments
 (0)