Skip to content

Commit eb647ac

Browse files
authored
Merge pull request #22829 from crazy-max/validate-vendor
validate vendor target
2 parents c061651 + 77ea1f9 commit eb647ac

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ jobs:
9191
- test-go-redirects
9292
- dockerfile-lint
9393
- path-warnings
94+
- validate-vendor
9495
steps:
9596
-
9697
name: Set up Docker Buildx

Dockerfile

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ RUN apk add --no-cache \
1414
git \
1515
nodejs \
1616
npm \
17-
gcompat
17+
gcompat \
18+
rsync
1819

1920
# npm downloads Node.js dependencies
2021
FROM base AS npm
@@ -87,6 +88,22 @@ FROM scratch AS vendor
8788
COPY --from=update-modules /project/_vendor /_vendor
8889
COPY --from=update-modules /project/go.* /
8990

91+
FROM base AS validate-vendor
92+
RUN --mount=target=/context \
93+
--mount=type=bind,from=vendor,target=/out \
94+
--mount=target=.,type=tmpfs <<EOT
95+
set -e
96+
rsync -a /context/. .
97+
git add -A
98+
rm -rf _vendor
99+
cp -rf /out/* .
100+
if [ -n "$(git status --porcelain -- go.mod go.sum _vendor)" ]; then
101+
echo >&2 'ERROR: Vendor result differs. Please vendor your package with "make vendor"'
102+
git status --porcelain -- go.mod go.sum _vendor
103+
exit 1
104+
fi
105+
EOT
106+
90107
# build-upstream builds an upstream project with a replacement module
91108
FROM build-base AS build-upstream
92109
# UPSTREAM_MODULE_NAME is the canonical upstream repository name and namespace (e.g. moby/buildkit)

docker-bake.hcl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ target "release" {
3636
}
3737

3838
group "validate" {
39-
targets = ["lint", "test", "unused-media", "test-go-redirects", "dockerfile-lint", "path-warnings"]
39+
targets = ["lint", "test", "unused-media", "test-go-redirects", "dockerfile-lint", "path-warnings", "validate-vendor"]
4040
}
4141

4242
target "test" {
@@ -157,6 +157,11 @@ target "vendor" {
157157
provenance = false
158158
}
159159

160+
target "validate-vendor" {
161+
target = "validate-vendor"
162+
output = ["type=cacheonly"]
163+
}
164+
160165
variable "UPSTREAM_MODULE_NAME" {
161166
default = null
162167
}

0 commit comments

Comments
 (0)