-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEarthfile
136 lines (116 loc) · 3.86 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
VERSION 0.8
IMPORT github.com/formancehq/earthly:tags/v0.19.0 AS core
IMPORT github.com/formancehq/operator:main AS operator
FROM core+base-image
sources:
WORKDIR src
COPY (operator+sources/*) /src
WORKDIR /src
COPY go.* .
COPY --dir cmd internal tests .
COPY main.go .
SAVE ARTIFACT /src
compile:
FROM core+builder-image
COPY (+sources/*) /src
WORKDIR /src
ARG VERSION=latest
DO --pass-args core+GO_COMPILE --VERSION=$VERSION
build-image:
FROM core+final-image
ENTRYPOINT ["/bin/agent"]
COPY (+compile/main) /bin/agent
ARG REPOSITORY=ghcr.io
ARG tag=latest
DO core+SAVE_IMAGE --COMPONENT=agent --REPOSITORY=${REPOSITORY} --TAG=$tag
lint:
FROM core+builder-image
COPY (+sources/*) /src
COPY --pass-args +tidy/go.* .
WORKDIR /src
DO --pass-args core+GO_LINT
SAVE ARTIFACT cmd AS LOCAL cmd
SAVE ARTIFACT internal AS LOCAL internal
SAVE ARTIFACT main.go AS LOCAL main.go
openapi:
RUN echo "not implemented"
tidy:
FROM core+builder-image
COPY --pass-args (+sources/src) /src
WORKDIR /src
DO --pass-args core+GO_TIDY
generate:
FROM core+builder-image
DO --pass-args core+GO_INSTALL --package=go.uber.org/mock/mockgen@latest
COPY (+sources/*) /src
WORKDIR /src
RUN go generate -run mockgen ./...
SAVE ARTIFACT internal AS LOCAL internal
grpc-generate:
FROM core+grpc-base
LET protoName=agent.proto
COPY $protoName .
DO core+GRPC_GEN --protoName=$protoName
SAVE ARTIFACT generated AS LOCAL internal/generated
tests:
FROM core+builder-image
RUN apk update && apk add bash
DO --pass-args core+GO_INSTALL --package=sigs.k8s.io/controller-runtime/tools/setup-envtest@v0.0.0-20240320141353-395cfc7486e6
ENV ENVTEST_VERSION 1.28.0
RUN setup-envtest use $ENVTEST_VERSION -p path
ENV KUBEBUILDER_ASSETS /root/.local/share/kubebuilder-envtest/k8s/$ENVTEST_VERSION-linux-$(go env GOHOSTARCH)
DO --pass-args core+GO_INSTALL --package=github.com/onsi/ginkgo/v2/ginkgo@v2.14.0
COPY --pass-args +sources/* /src
COPY --pass-args operator+manifests/config /components/operator/config
COPY (operator+sources/*) /src
WORKDIR /src
COPY tests tests
COPY internal internal
ARG GOPROXY
ARG focus
RUN --mount=type=cache,id=gomod,target=$GOPATH/pkg/mod \
--mount=type=cache,id=gobuild,target=/root/.cache/go-build \
go test ./internal/...
RUN --mount=type=cache,id=gomod,target=$GOPATH/pkg/mod \
--mount=type=cache,id=gobuild,target=/root/.cache/go-build \
ginkgo --focus=$focus -p ./tests/...
deploy-staging:
FROM --pass-args core+base-argocd
ARG --required TAG
ARG APPLICATION=staging-eu-west-1-hosting-regions
LET SERVER=argocd.internal.formance.cloud
RUN --secret AUTH_TOKEN \
argocd app set $APPLICATION \
--parameter agent.image.tag=$TAG \
--auth-token=$AUTH_TOKEN --server=$SERVER --grpc-web
BUILD --pass-args core+deploy-staging
deploy:
COPY (+sources/*) /src
LET tag=$(tar cf - /src | sha1sum | awk '{print $1}')
WAIT
BUILD --pass-args +build-image --tag=$tag
END
FROM --pass-args core+vcluster-deployer-image
ARG branch=main
COPY --dir (github.com/formancehq/helm/charts/agent:$branch+validate/*) helm/
COPY .earthly .earthly
ARG --required user
RUN --secret tld helm upgrade --namespace formance-system \
--create-namespace \
--install \
--wait \
-f .earthly/values.yaml \
--set image.tag=$tag \
--set agent.baseUrl=https://$user.$tld \
--set server.address=$user.$tld:443 \
formance-membership-agent ./helm
pre-commit:
WAIT
BUILD --pass-args +tidy
END
BUILD --pass-args +lint
release:
FROM core+builder-image
ARG mode=local
COPY --dir . /src
DO core+GORELEASER --mode=$mode