-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: add checks for consistent vendoring
Signed-off-by: Justin Chadwell <me@jedevc.com>
- Loading branch information
Showing
4 changed files
with
79 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ jobs: | |
matrix: | ||
target: | ||
- validate-license | ||
- validate-vendor | ||
steps: | ||
- | ||
name: Checkout | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,18 @@ | ||
.PHONY: all dev examples | ||
|
||
.PHONY: all | ||
all: | ||
|
||
.PHONY: dev | ||
dev: | ||
IMAGE_LOCAL=$(IMAGE) docker buildx bake --push | ||
|
||
.PHONY: examples | ||
examples: | ||
./hack/check-example.sh $(IMAGE) ./examples/* | ||
|
||
.PHONY: vendor | ||
vendor: | ||
$(eval $@_TMP_OUT := $(shell mktemp -d -t buildkit-output.XXXXXXXXXX)) | ||
docker buildx bake --set "*.output=type=local,dest=$($@_TMP_OUT)" update-vendor | ||
rm -rf ./vendor | ||
cp -R "$($@_TMP_OUT)"/out/* . | ||
rm -rf "$($@_TMP_OUT)"/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# syntax=docker/dockerfile:1 | ||
|
||
# Copyright 2022 buildkit authors | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
# upstream at https://github.com/moby/buildkit/blob/master/hack/dockerfiles/vendor.Dockerfile | ||
|
||
ARG GO_VERSION=1.20 | ||
|
||
FROM golang:${GO_VERSION}-alpine AS base | ||
RUN apk add --no-cache git rsync | ||
WORKDIR /src | ||
|
||
FROM base AS vendored | ||
RUN --mount=target=/context \ | ||
--mount=target=.,type=tmpfs \ | ||
--mount=target=/go/pkg/mod,type=cache <<EOT | ||
set -e | ||
rsync -a /context/. . | ||
go mod tidy | ||
go mod vendor | ||
mkdir /out | ||
cp -r go.mod go.sum vendor /out | ||
EOT | ||
|
||
FROM scratch AS update | ||
COPY --from=vendored /out /out | ||
|
||
FROM vendored AS validate | ||
RUN --mount=target=/context \ | ||
--mount=target=.,type=tmpfs <<EOT | ||
set -e | ||
rsync -a /context/. . | ||
git add -A | ||
rm -rf vendor | ||
cp -rf /out/* . | ||
if [ -n "$(git status --porcelain -- go.mod go.sum vendor)" ]; then | ||
echo >&2 'ERROR: Vendor result differs. Please vendor your package with "make vendor"' | ||
git status --porcelain -- go.mod go.sum vendor | ||
exit 1 | ||
fi | ||
EOT |