File tree Expand file tree Collapse file tree 3 files changed +51
-3
lines changed
Expand file tree Collapse file tree 3 files changed +51
-3
lines changed Original file line number Diff line number Diff 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+
Original file line number Diff line number Diff line change 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
57PACKAGES ?= apparmor seccomp
68CROSSBUILDS ?= linux/arm linux/arm64 linux/amd64 linux/ppc64le linux/s390x
79
@@ -32,9 +34,15 @@ crossbuild:
3234test : CMD=go test -v ./...
3335test : foreach
3436
37+ .PHONY : validate-codegen
38+ validate-codegen :
39+ @echo " Validating code generation..."
40+ bash $(SCRIPTDIR ) /validate/default-seccomp
41+
3542.PHONY : help
3643help :
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"
Original file line number Diff line number Diff line change 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
You can’t perform that action at this time.
0 commit comments