-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathEarthfile
66 lines (57 loc) · 2.06 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
VERSION 0.8
ARG --global BASE_IMAGE=golang:1.22-bookworm
FROM $BASE_IMAGE
WORKDIR /opt/ctrader
configure:
LOCALLY
RUN git config pull.rebase true \
&& git config remote.origin.prune true \
&& git config branch.main.mergeoptions "--ff-only"
go-base:
COPY --dir openapi .
COPY go.mod go.sum *.go .
RUN go mod download
go-build:
FROM +go-base
RUN go build -trimpath ./...
go-test:
ARG INTEGRATION_TEST="false"
FROM +go-base
RUN go install github.com/mfridman/[email protected]
IF [ "$INTEGRATION_TEST" = "true" ]
RUN --secret CTRADER_CLIENT_ID --secret CTRADER_SECRET --secret CTRADER_ACCOUNT_ID --secret CTRADER_TOKEN \
go test --tags integration -trimpath -race -cover -covermode=atomic -json ./... | tparse -all -smallscreen
ELSE
RUN go test -trimpath -race -cover -covermode=atomic -json ./... | tparse -all -smallscreen
END
go-linter:
FROM +go-base
RUN go install golang.org/x/vuln/cmd/[email protected] \
&& go install github.com/golangci/golangci-lint/cmd/[email protected]
COPY .golangci.yaml .
RUN govulncheck ./... \
&& golangci-lint run ./...
go-mod-linter:
FROM +go-base
COPY . .
RUN git checkout Earthfile \
&& go mod tidy \
&& git add . \
&& git diff --cached --exit-code
update-pkg-go-dev:
RUN curl https://proxy.golang.org/github.com/diegobernardes/ctrader/@v/main.info
# compile-proto is used to compile cTrader Open API protobuf files. In case the 'protoc-gen-go' version changes, it's
# recommended to run 'go mod tidy'.
compile-proto:
LOCALLY
RUN rm -rf openapi
FROM $BASE_IMAGE
RUN apt-get update \
&& apt-get install --yes --no-install-recommends protobuf-compiler=3.* \
&& rm -rf /var/lib/apt/lists/* \
&& go install google.golang.org/protobuf/cmd/[email protected]
GIT CLONE --branch 91 https://github.com/spotware/openapi-proto-messages.git openapi-proto-messages
RUN cd openapi-proto-messages \
&& protoc --go_out=. --go_opt=paths=source_relative *.proto \
&& find . ! \( -name '*.go' \) -delete
SAVE ARTIFACT openapi-proto-messages AS LOCAL openapi