Skip to content

Commit 81c6a30

Browse files
authored
Merge pull request containerd#4318 from Shubhranshu153/update-go-license
fix: go-license dependency and fixes for provenance/sbom tests.
2 parents 401800a + 0eee948 commit 81c6a30

File tree

5 files changed

+60
-11
lines changed

5 files changed

+60
-11
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ ARG GOMODJAIL_VERSION=v0.1.2@0a86b34442a491fa8f5e4565e9c846fce310239c
4747
ARG GO_VERSION=1.24
4848
ARG UBUNTU_VERSION=24.04
4949
ARG CONTAINERIZED_SYSTEMD_VERSION=v0.1.1
50-
ARG GOTESTSUM_VERSION=v1.12.2
50+
ARG GOTESTSUM_VERSION=0d9599e513d70e5792bb9334869f82f6e8b53d4d
5151
ARG NYDUS_VERSION=v2.3.1
5252
ARG SOCI_SNAPSHOTTER_VERSION=0.9.0
5353
ARG KUBO_VERSION=v0.34.1

Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,12 +218,14 @@ install-dev-tools:
218218
# git-validation: main (2025-02-25)
219219
# ltag: main (2025-03-04)
220220
# go-licenses: v2.0.0-alpha.1 (2024-06-27)
221+
# stubbing go-licenses with dependency upgrade due to non-compatibility with golang 1.25rc1
222+
# Issue: https://github.com/google/go-licenses/issues/312
221223
@cd $(MAKEFILE_DIR) \
224+
&& go install github.com/Shubhranshu153/go-licenses/v2@f8c503d1357dffb6c97ed3b94e912ab294dde24a \
222225
&& go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@2b224c2cf4c9f261c22a16af7f8ca6408467f338 \
223226
&& go install github.com/vbatts/git-validation@7b60e35b055dd2eab5844202ffffad51d9c93922 \
224227
&& go install github.com/containerd/ltag@66e6a514664ee2d11a470735519fa22b1a9eaabd \
225-
&& go install github.com/google/go-licenses/v2@d01822334fba5896920a060f762ea7ecdbd086e8 \
226-
&& go install gotest.tools/gotestsum@ac6dad9c7d87b969004f7749d1942938526c9716
228+
&& go install gotest.tools/gotestsum@0d9599e513d70e5792bb9334869f82f6e8b53d4d
227229
@echo "Remember to add \$$HOME/go/bin to your path"
228230
$(call footer, $@)
229231

cmd/nerdctl/builder/builder_build_test.go

Lines changed: 49 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ package builder
1919
import (
2020
"errors"
2121
"fmt"
22+
"os"
2223
"path/filepath"
24+
"regexp"
2325
"runtime"
2426
"strings"
2527
"testing"
@@ -851,8 +853,9 @@ RUN curl -I http://google.com
851853
func TestBuildAttestation(t *testing.T) {
852854
nerdtest.Setup()
853855

854-
const testSBOMFileName = "sbom.spdx.json"
855-
const testProvenanceFileName = "provenance.json"
856+
// Using regex patterns to match SBOM and provenance files with optional platform suffix
857+
const testSBOMFilePattern = `sbom\.spdx(?:\.[a-z0-9_]+)?\.json`
858+
const testProvenanceFilePattern = `provenance(?:\.[a-z0-9_]+)?\.json`
856859

857860
dockerfile := fmt.Sprintf(`FROM %s`, testutil.CommonImage)
858861

@@ -892,7 +895,17 @@ func TestBuildAttestation(t *testing.T) {
892895
Expected: func(data test.Data, helpers test.Helpers) *test.Expected {
893896
return &test.Expected{
894897
Output: func(stdout, info string, t *testing.T) {
895-
data.Temp().Exists("dir-for-bom", testSBOMFileName)
898+
files, err := os.ReadDir(data.Temp().Path("dir-for-bom"))
899+
assert.NilError(t, err, "failed to read directory")
900+
901+
found := false
902+
for _, file := range files {
903+
if !file.IsDir() && regexp.MustCompile(testSBOMFilePattern).MatchString(file.Name()) {
904+
found = true
905+
break
906+
}
907+
}
908+
assert.Assert(t, found, "no SBOM file matching pattern %s found", testSBOMFilePattern)
896909
},
897910
}
898911
},
@@ -914,7 +927,17 @@ func TestBuildAttestation(t *testing.T) {
914927
Expected: func(data test.Data, helpers test.Helpers) *test.Expected {
915928
return &test.Expected{
916929
Output: func(stdout, info string, t *testing.T) {
917-
data.Temp().Exists("dir-for-prov", testProvenanceFileName)
930+
files, err := os.ReadDir(data.Temp().Path("dir-for-prov"))
931+
assert.NilError(t, err, "failed to read directory")
932+
933+
found := false
934+
for _, file := range files {
935+
if !file.IsDir() && regexp.MustCompile(testProvenanceFilePattern).MatchString(file.Name()) {
936+
found = true
937+
break
938+
}
939+
}
940+
assert.Assert(t, found, "no provenance file matching pattern %s found", testProvenanceFilePattern)
918941
},
919942
}
920943
},
@@ -937,8 +960,28 @@ func TestBuildAttestation(t *testing.T) {
937960
Expected: func(data test.Data, helpers test.Helpers) *test.Expected {
938961
return &test.Expected{
939962
Output: func(stdout, info string, t *testing.T) {
940-
data.Temp().Exists("dir-for-attest", testSBOMFileName)
941-
data.Temp().Exists("dir-for-attest", testProvenanceFileName)
963+
// Check if any file in the directory matches the SBOM file pattern
964+
files, err := os.ReadDir(data.Temp().Path("dir-for-attest"))
965+
assert.NilError(t, err, "failed to read directory")
966+
967+
sbomFound := false
968+
for _, file := range files {
969+
if !file.IsDir() && regexp.MustCompile(testSBOMFilePattern).MatchString(file.Name()) {
970+
sbomFound = true
971+
break
972+
}
973+
}
974+
assert.Assert(t, sbomFound, "no SBOM file matching pattern %s found", testSBOMFilePattern)
975+
976+
// Check if any file in the directory matches the provenance file pattern
977+
provenanceFound := false
978+
for _, file := range files {
979+
if !file.IsDir() && regexp.MustCompile(testProvenanceFilePattern).MatchString(file.Name()) {
980+
provenanceFound = true
981+
break
982+
}
983+
}
984+
assert.Assert(t, provenanceFound, "no provenance file matching pattern %s found", testProvenanceFilePattern)
942985
},
943986
}
944987
},

hack/build-integration-canary.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ readonly root
2828
# "Blacklisting" here means that any dependency which name is blacklisted will be left untouched, at the version
2929
# currently pinned in the Dockerfile.
3030
# This is convenient so that currently broken alpha/beta/RC can be held back temporarily to keep the build green
31-
blacklist=()
31+
# TODO: Blacklisting gotestsum until a new version compatible with golang v1.25rc1 is released
32+
# Issue: https://github.com/google/go-licenses/issues/312
33+
blacklist=(gotestsum)
3234

3335
# List all the repositories we depend on to build and run integration tests
3436
dependencies=(

mod/tigron/Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,11 +168,13 @@ install-dev-tools:
168168
# git-validation: main (2025-02-25)
169169
# ltag: main (2025-03-04)
170170
# go-licenses: v2.0.0-alpha.1 (2024-06-27)
171+
# stubbing go-licenses with dependency upgrade due to non-compatibility with golang 1.25rc1
172+
# Issue: https://github.com/google/go-licenses/issues/312
171173
@cd $(MAKEFILE_DIR) \
172174
&& go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@2b224c2cf4c9f261c22a16af7f8ca6408467f338 \
173175
&& go install github.com/vbatts/git-validation@7b60e35b055dd2eab5844202ffffad51d9c93922 \
174176
&& go install github.com/containerd/ltag@66e6a514664ee2d11a470735519fa22b1a9eaabd \
175-
&& go install github.com/google/go-licenses/v2@d01822334fba5896920a060f762ea7ecdbd086e8
177+
&& go install github.com/Shubhranshu153/go-licenses/v2@f8c503d1357dffb6c97ed3b94e912ab294dde24a
176178
@echo "Remember to add \$$HOME/go/bin to your path"
177179
$(call footer, $@)
178180

0 commit comments

Comments
 (0)