-
Notifications
You must be signed in to change notification settings - Fork 3
/
Earthfile
81 lines (69 loc) · 2.55 KB
/
Earthfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
VERSION 0.7
ARG ALPINE_VERSION=3.19
ARG GO_VERSION=1.22
ARG LINTER_VERSION=v1.58.0
FROM golang:$GO_VERSION-alpine$ALPINE_VERSION
WORKDIR /app
stage:
COPY --dir go.mod go.sum ./
RUN go mod download -x
COPY --dir protoc cmd .
SAVE ARTIFACT /app
vendor:
FROM +stage
RUN go mod vendor
lint:
# Installs golangci-lint to ./bin
RUN wget -O- -nv https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s $LINTER_VERSION
COPY +stage/app .
RUN ./bin/golangci-lint run --skip-dirs=vendor --skip-dirs=./gen/ --timeout=10m --tests=true -E revive \
-E gosec -E unconvert -E goconst -E gocyclo -E goimports
build:
FROM +vendor
# compile app binary, save as artifact
ARG VERSION="dev"
ARG GOOS
ARG GOARCH
RUN go build -ldflags="-s -w -X 'main.version=${VERSION}'" -mod=vendor -o bin/protoc-gen-fieldmask ./cmd/protoc-gen-fieldmask/...
SAVE ARTIFACT ./bin/protoc-gen-fieldmask /protoc-gen-fieldmask
zip:
RUN apk add zip
WORKDIR /artifacts
ARG VERSION
ARG ZIP_FILE_NAME
ARG EXT
COPY (+build/protoc-gen-fieldmask) protoc-gen-fieldmask${EXT}
RUN zip -m protoc-gen-fieldmask-${VERSION}-${ZIP_FILE_NAME}.zip protoc-gen-fieldmask${EXT}
SAVE ARTIFACT /artifacts
build-all:
WORKDIR /artifacts
COPY (+zip/artifacts/*.zip --GOOS=darwin --GOARCH=amd64 --ZIP_FILE_NAME=osx-x86_64) .
COPY (+zip/artifacts/*.zip --GOOS=linux --GOARCH=386 --ZIP_FILE_NAME=linux-x86_32) .
COPY (+zip/artifacts/*.zip --GOOS=linux --GOARCH=amd64 --ZIP_FILE_NAME=linux-x86_64) .
COPY (+zip/artifacts/*.zip --GOOS=windows --GOARCH=386 --ZIP_FILE_NAME=win32 --EXT=.exe) .
COPY (+zip/artifacts/*.zip --GOOS=windows --GOARCH=amd64 --ZIP_FILE_NAME=win64 --EXT=.exe) .
SAVE ARTIFACT /artifacts AS LOCAL bin
test-gen:
ARG DOCKER_PROTOC_VERSION=1.51_2
FROM namely/protoc-all:$DOCKER_PROTOC_VERSION
RUN mkdir /plugins
COPY +build/protoc-gen-fieldmask /usr/local/bin/.
COPY --dir protos .
RUN entrypoint.sh -i protos -d protos/cases -l go -o gen
RUN entrypoint.sh -i protos -d protos/cases/thirdpartyimport -l go -o gen
RUN protoc -I/opt/include -Iprotos --fieldmask_out=gen protos/cases/*.proto protos/cases/thirdpartyimport/*.proto
SAVE ARTIFACT gen /gen AS LOCAL test/gen
test:
FROM +vendor
RUN apk add build-base
COPY --dir test .
COPY --dir +test-gen/gen test/.
RUN go mod vendor
RUN go test github.com/idodod/protoc-gen-fieldmask/test
all:
BUILD +lint
BUILD +test
BUILD +build-all
clean:
LOCALLY
RUN rm -rf test/gen vendor