This repository has been archived by the owner on Jul 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEarthfile
212 lines (152 loc) · 4.77 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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
VERSION 0.7
COPY_CI_DATA:
COMMAND
COPY --dir "ci/" ".github/" "./"
COPY ".goreleaser.yaml" "./"
COPY_METADATA:
COMMAND
DO +COPY_CI_DATA
COPY --dir ".git/" "./"
rust-base:
FROM rust:1.70.0
WORKDIR /tmp/starling-bank-technical-challenge
check-clean-git-history:
FROM +rust-base
RUN cargo install clean_git_history --version 0.1.2 --locked
DO +COPY_METADATA
ARG from_reference="origin/HEAD"
RUN ./ci/check-clean-git-history.sh --from-reference "${from_reference}"
check-conventional-commits-linting:
FROM +rust-base
RUN cargo install conventional_commits_linter --version 0.12.3 --locked
DO +COPY_METADATA
ARG from_reference="origin/HEAD"
RUN ./ci/check-conventional-commits-linting.sh --from-reference "${from_reference}"
INSTALL_DEPENDENCIES:
COMMAND
COPY "go.mod" "go.sum" "./"
RUN go mod download
COPY_SOURCECODE:
COMMAND
DO +COPY_CI_DATA
COPY --dir "cmd/" "api/" "./"
golang-base:
FROM golang:1.22.1
WORKDIR /tmp/starling-bank-technical-challenge
ENV GOPROXY=direct
ENV CGO_ENABLED=0
ENV GOOS=linux
ENV GOARCH=amd64
check-go-formatting:
FROM +golang-base
DO +INSTALL_DEPENDENCIES
DO +COPY_SOURCECODE
RUN ./ci/check-go-formatting.sh
sh-formatting-base:
FROM +golang-base
RUN go install mvdan.cc/sh/v3/cmd/[email protected]
DO +COPY_CI_DATA
check-shell-formatting:
FROM +sh-formatting-base
RUN ./ci/check-shell-formatting.sh
yaml-formatting-base:
FROM +golang-base
RUN go install github.com/google/yamlfmt/cmd/[email protected]
COPY ".yamlfmt" "./"
DO +COPY_CI_DATA
check-yaml-formatting:
FROM +yaml-formatting-base
RUN ./ci/check-yaml-formatting.sh
check-formatting:
BUILD +check-go-formatting
BUILD +check-shell-formatting
BUILD +check-yaml-formatting
fix-go-formatting:
FROM +golang-base
DO +INSTALL_DEPENDENCIES
DO +COPY_SOURCECODE
RUN ./ci/fix-go-formatting.sh
SAVE ARTIFACT "src/" AS LOCAL "./"
fix-shell-formatting:
FROM +sh-formatting-base
RUN ./ci/fix-shell-formatting.sh
SAVE ARTIFACT "ci/" AS LOCAL "./"
fix-yaml-formatting:
FROM +yaml-formatting-base
RUN ./ci/fix-yaml-formatting.sh
SAVE ARTIFACT ".github/" AS LOCAL "./"
SAVE ARTIFACT ".goreleaser.yaml" AS LOCAL "./"
fix-formatting:
BUILD +fix-go-formatting
BUILD +fix-shell-formatting
BUILD +fix-yaml-formatting
check-go-linting:
FROM +golang-base
RUN go install github.com/golangci/golangci-lint/cmd/[email protected]
DO +INSTALL_DEPENDENCIES
DO +COPY_SOURCECODE
RUN ./ci/check-go-linting.sh
ubuntu-base:
FROM ubuntu:22.04
# https://askubuntu.com/questions/462690/what-does-apt-get-fix-missing-do-and-when-is-it-useful
RUN apt-get update --fix-missing
WORKDIR /tmp/starling-bank-technical-challenge
check-shell-linting:
FROM +ubuntu-base
RUN apt-get install shellcheck -y
DO +COPY_CI_DATA
RUN ./ci/check-shell-linting.sh
check-github-actions-workflows-linting:
FROM +golang-base
RUN go install github.com/rhysd/actionlint/cmd/[email protected]
DO +COPY_CI_DATA
RUN ./ci/check-github-actions-workflows-linting.sh
check-linting:
BUILD +check-go-linting
BUILD +check-shell-linting
BUILD +check-github-actions-workflows-linting
check-modules:
FROM +golang-base
DO +INSTALL_DEPENDENCIES
DO +COPY_SOURCECODE
RUN ./ci/check-modules.sh
fix-modules:
FROM +golang-base
DO +INSTALL_DEPENDENCIES
DO +COPY_SOURCECODE
RUN ./ci/fix-modules.sh
SAVE ARTIFACT "go.mod" AS LOCAL "./"
SAVE ARTIFACT "go.sum" AS LOCAL "./"
INSTALL_GORELEASER:
COMMAND
ENV GORELEASER_VERSION=1.22.1
RUN wget "https://github.com/goreleaser/goreleaser/releases/download/v${GORELEASER_VERSION}/goreleaser_Linux_x86_64.tar.gz"
RUN tar -xzvf "goreleaser_Linux_x86_64.tar.gz"
RUN cp "goreleaser" /bin/goreleaser
compile:
FROM +golang-base
DO +INSTALL_GORELEASER
DO +INSTALL_DEPENDENCIES
DO +COPY_SOURCECODE
RUN ./ci/compile.sh
SAVE ARTIFACT "dist/" AS LOCAL "./"
SAVE ARTIFACT "go.sum" AS LOCAL "./"
unit-test:
FROM +golang-base
DO +INSTALL_DEPENDENCIES
DO +COPY_SOURCECODE
RUN ./ci/unit-test.sh
INSTALL_GITHUB_CLI:
COMMAND
ENV GITHUB_CLI_VERSION=2.30.0
RUN wget "https://github.com/cli/cli/releases/download/v${GITHUB_CLI_VERSION}/gh_${GITHUB_CLI_VERSION}_linux_amd64.tar.gz"
RUN tar -xzvf "gh_${GITHUB_CLI_VERSION}_linux_amd64.tar.gz"
RUN cp "./gh_${GITHUB_CLI_VERSION}_linux_amd64/bin/gh" /bin/gh
release-artifacts:
FROM +ubuntu-base
RUN apt-get install git wget jq -y
DO +INSTALL_GITHUB_CLI
COPY "+compile/dist/" "./"
DO +COPY_METADATA
ARG release
RUN --secret GH_TOKEN ./ci/release-artifacts.sh --release "${release}"