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 1414 GO_VERSION : 1.16.7
1515
1616jobs :
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+
1736 test :
1837 runs-on : ${{ matrix.os }}
1938 strategy :
Original file line number Diff line number Diff line change @@ -14,11 +14,40 @@ FROM crazymax/osxcross:${OSXCROSS_VERSION} AS osxcross
1414
1515FROM --platform=$BUILDPLATFORM golang:${GO_VERSION}-alpine AS gobase
1616COPY --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
1818ENV GOFLAGS="-mod=vendor"
1919ENV CGO_ENABLED="1"
2020WORKDIR /src
2121
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+
2251FROM gobase AS version
2352ARG PKG
2453RUN --mount=target=. \
Original file line number Diff line number Diff line change 8383 .
8484 docker run --rm --net=none $(BUILDIMG ) tar cf - /release | tar xf -
8585 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" {
2121 targets = [" binaries" ]
2222}
2323
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+
2438target "test" {
2539 inherits = [" _common" ]
2640 target = " test-coverage"
You can’t perform that action at this time.
0 commit comments