File tree Expand file tree Collapse file tree 4 files changed +75
-1
lines changed Expand file tree Collapse file tree 4 files changed +75
-1
lines changed Original file line number Diff line number Diff line change 14
14
GO_VERSION : 1.16.7
15
15
16
16
jobs :
17
+ validate :
18
+ runs-on : ubuntu-20.04
19
+ strategy :
20
+ fail-fast : false
21
+ matrix :
22
+ target :
23
+ - validate-vendor
24
+ steps :
25
+ -
26
+ name : Checkout
27
+ uses : actions/checkout@v3
28
+ -
29
+ name : Set up Docker Buildx
30
+ uses : docker/setup-buildx-action@v2
31
+ -
32
+ name : Run
33
+ run : |
34
+ make ${{ matrix.target }}
35
+
17
36
test :
18
37
runs-on : ${{ matrix.os }}
19
38
strategy :
Original file line number Diff line number Diff line change @@ -14,11 +14,40 @@ FROM crazymax/osxcross:${OSXCROSS_VERSION} AS osxcross
14
14
15
15
FROM --platform=$BUILDPLATFORM golang:${GO_VERSION}-alpine AS gobase
16
16
COPY --from=xx / /
17
- RUN apk add --no-cache clang file git lld llvm pkgconf
17
+ RUN apk add --no-cache clang file git lld llvm pkgconf rsync
18
18
ENV GOFLAGS="-mod=vendor"
19
19
ENV CGO_ENABLED="1"
20
20
WORKDIR /src
21
21
22
+ FROM gobase AS vendored
23
+ RUN --mount=target=/context \
24
+ --mount=target=.,type=tmpfs \
25
+ --mount=target=/go/pkg/mod,type=cache <<EOT
26
+ set -e
27
+ rsync -a /context/. .
28
+ go mod tidy
29
+ go mod vendor
30
+ mkdir /out
31
+ cp -r go.mod go.sum vendor /out
32
+ EOT
33
+
34
+ FROM scratch AS vendor-update
35
+ COPY --from=vendored /out /
36
+
37
+ FROM vendored AS vendor-validate
38
+ RUN --mount=type=bind,target=.,rw <<EOT
39
+ set -e
40
+ rsync -a /context/. .
41
+ git add -A
42
+ rm -rf vendor
43
+ cp -rf /out/* .
44
+ if [ -n "$(git status --porcelain -- go.mod go.sum vendor)" ]; then
45
+ echo >&2 'ERROR: Vendor result differs. Please vendor your package with "make vendor"'
46
+ git status --porcelain -- go.mod go.sum vendor
47
+ exit 1
48
+ fi
49
+ EOT
50
+
22
51
FROM gobase AS version
23
52
ARG PKG
24
53
RUN --mount=target=. \
Original file line number Diff line number Diff line change 83
83
.
84
84
docker run --rm --net=none $(BUILDIMG ) tar cf - /release | tar xf -
85
85
docker rmi $(BUILDIMG )
86
+
87
+ .PHONY : vendor
88
+ vendor :
89
+ $(eval $@ _TMP_OUT := $(shell mktemp -d -t docker-output.XXXXXXXXXX) )
90
+ docker buildx bake --set " *.output=type=local,dest=$( $@ _TMP_OUT) " vendor
91
+ rm -rf ./vendor
92
+ cp -R " $( $@ _TMP_OUT) " /* .
93
+ rm -rf " $( $@ _TMP_OUT) "
94
+
95
+ .PHONY : validate-vendor
96
+ validate-vendor :
97
+ docker buildx bake vendor-validate
Original file line number Diff line number Diff line change @@ -21,6 +21,20 @@ group "default" {
21
21
targets = [" binaries" ]
22
22
}
23
23
24
+ group "validate" {
25
+ targets = [" vendor-validate" ]
26
+ }
27
+
28
+ target "vendor-validate" {
29
+ target = " vendor-validate"
30
+ output = [" type=cacheonly" ]
31
+ }
32
+
33
+ target "vendor" {
34
+ target = " vendor-update"
35
+ output = [" ." ]
36
+ }
37
+
24
38
target "test" {
25
39
inherits = [" _common" ]
26
40
target = " test-coverage"
You can’t perform that action at this time.
0 commit comments