Skip to content

Commit c02a5cf

Browse files
committed
gha: skip modules on unsupported Go versions
Some modules require a more recent version of Go and must be skipped in tests. Previously we manually kept a list, but we can detect the version of Go that's required from the go.mod. Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent f4c0392 commit c02a5cf

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

.github/workflows/test.yml

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,21 @@ jobs:
2424
- name: Set PACKAGES env
2525
if: ${{ matrix.go-version == '1.18.x' }}
2626
run: |
27-
# This corresponds with the list in Makefile:1, but omits the "userns"
28-
# and "capability" modules, which require go1.21 as minimum, and "reexec",
29-
# which requires go1.20 in tests.
30-
echo 'PACKAGES=atomicwriter mountinfo mount sequential signal symlink user' >> $GITHUB_ENV
27+
# Check if the module supports this version of Go.
28+
go_version="$(go env GOVERSION)"
29+
go_version="${go_version#go}"
30+
31+
packages=""
32+
for p in */; do
33+
[ -f "$p/go.mod" ] || continue
34+
if ! (cd "$p" && go list -m -f "{{if gt .GoVersion \"$go_version\"}}ko{{end}}" | grep -q ko); then
35+
packages+="${p%/} "
36+
else
37+
echo "::notice::SKIP: github.com/moby/sys/${p%/} requires a more recent version of Go"
38+
fi
39+
done
40+
41+
echo "PACKAGES=${packages}" >> "$GITHUB_ENV"
3142
- name: go mod tidy
3243
run: |
3344
make foreach CMD="go mod tidy"

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
PACKAGES ?= atomicwriter capability mountinfo mount reexec sequential signal symlink user userns # IMPORTANT: when updating this list, also update the conditional one in .github/workflows/test.yml
1+
PACKAGES ?= atomicwriter capability mountinfo mount reexec sequential signal symlink user userns
22
BINDIR ?= _build/bin
33
CROSS ?= linux/arm linux/arm64 linux/ppc64le linux/s390x \
44
freebsd/amd64 openbsd/amd64 darwin/amd64 darwin/arm64 windows/amd64

0 commit comments

Comments
 (0)