forked from Tochemey/gokv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Earthfile
97 lines (65 loc) · 2.49 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
VERSION 0.8
FROM golang:1.23.1-alpine
# install gcc dependencies into alpine for CGO
RUN apk --no-cache add git ca-certificates gcc musl-dev libc-dev binutils-gold curl openssh
# install docker tools
# https://docs.docker.com/engine/install/debian/
RUN apk add --update --no-cache docker
# install the go generator plugins
RUN go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
RUN go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
RUN export PATH="$PATH:$(go env GOPATH)/bin"
# install buf from source
RUN GO111MODULE=on GOBIN=/usr/local/bin go install github.com/bufbuild/buf/cmd/[email protected]
# install the various tools to generate connect-go
RUN go install github.com/fullstorydev/grpcurl/cmd/grpcurl@latest
RUN go install connectrpc.com/connect/cmd/protoc-gen-connect-go@latest
# install linter
# binary will be $(go env GOPATH)/bin/golangci-lint
RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.60.1
RUN ls -la $(which golangci-lint)
RUN go install github.com/ory/go-acc@latest
# install vektra/mockery
RUN go install github.com/vektra/mockery/[email protected]
test:
BUILD +lint
BUILD +local-test
code:
WORKDIR /app
# download deps
COPY go.mod go.sum ./
RUN go mod download -x
# copy in code
COPY --dir . ./
vendor:
FROM +code
COPY +mock/mocks ./mocks
RUN go mod tidy && go mod vendor
SAVE ARTIFACT /app /files
mock:
# copy in the necessary files that need mock generated code
FROM +code
# generate the mocks
RUN mockery --dir discovery --name Provider --keeptree --exported=true --with-expecter=true --inpackage=true --disable-version-string=true --output ./mocks/discovery --case snake
SAVE ARTIFACT ./mocks mocks AS LOCAL mocks
lint:
FROM +vendor
COPY .golangci.yml ./
# Runs golangci-lint with settings:
RUN golangci-lint run --timeout 10m
local-test:
FROM +vendor
RUN go-acc ./... -o coverage.out --ignore goaktpb,mocks,internal/internalpb -- -mod=vendor -race -v
SAVE ARTIFACT coverage.out AS LOCAL coverage.out
protogen:
# copy the proto files to generate
COPY --dir protos/ ./
COPY buf.yaml buf.gen.yaml ./
# generate the pbs
RUN buf generate \
--template buf.gen.yaml \
--path protos/internal \
--path protos/test
# save artifact to
SAVE ARTIFACT gen/internal AS LOCAL internal/internalpb
SAVE ARTIFACT gen/test AS LOCAL test/data/testpb