-
Notifications
You must be signed in to change notification settings - Fork 1
/
Taskfile.yml
207 lines (176 loc) · 5.12 KB
/
Taskfile.yml
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
# https://taskfile.dev
version: '3'
env:
# Disable calls to CGO, so that the binaries compiled are static.
CGO_ENABLED: "0"
vars:
GIT_REFSPEC:
sh: "git rev-parse --short HEAD"
tasks:
bin:
desc: "Build a go binary specific to an architecture and operating system"
deps:
- "protobuf/generate"
requires:
vars: [GOOS, GOARCH]
cmds:
# Generate the required files
- mkdir -p "dist/{{ .GOOS }}+{{ .GOARCH }}"
- go build -o "dist/{{ .GOOS }}+{{ .GOARCH }}/x40.link{{ exeExt }}" main.go
- go build -o "dist/{{ .GOOS }}+{{ .GOARCH }}/@{{ exeExt }}" cli/main.go
bin/all:
desc: "Builds the go binaries"
deps:
- "bin/clean"
summary: |
Builds the go binaries
Generates go binaries for all supported operating systems, and stores them under "dist/"
with the appropriate suffix.
cmds:
- for:
# Linux (both Intel and ARM)
- GOOS: "linux"
GOARCH: "amd64"
- GOOS: "linux"
GOARCH: "arm64"
# Raspberry Pi
- GOOS: "linux"
GOARCH: "arm"
# MacOS (Older Intel & Newer ARM)
- GOOS: "darwin"
GOARCH: "amd64"
- GOOS: "darwin"
GOARCH: "arm64"
# Windows
- GOOS: "windows"
GOARCH: "amd64"
- GOOS: "windows"
GOARCH: "arm64"
task: bin
vars:
GOOS: "{{ .ITEM.GOOS }}"
GOARCH: "{{ .ITEM.GOARCH }}"
bin/clean:
desc: "Clean the generated artifacts"
cmds:
- "rm -rf dist"
cloudrun/apply:
desc: "Deploy the latest state to CloudRun"
cmds:
- cat deploy/prod/cr/service.yaml | envsubst | gcloud run services replace -
env:
VERSION: "{{ .GIT_REFSPEC }}"
container/all:
desc: "Build and push containers to all registries"
cmds:
- for:
- REGISTRY: "europe-west3-docker.pkg.dev/andrewhowdencom/x40-link"
- REGISTRY: "ghcr.io/andrewhowdencom"
task: "container"
vars:
REGISTRY: "{{ .ITEM.REGISTRY }}"
container:
desc: "Build and push a container to a registry"
cmds:
- task: "container/build"
vars: { "REGISTRY": "{{ .REGISTRY }}"}
- task: "container/push"
vars: { "REGISTRY": "{{ .REGISTRY }}"}
container/build:
desc: "Build the container for the application"
cmds:
- |
podman build \
--format docker \
--build-arg VERSION="{{ .GIT_REFSPEC }}" \
--build-arg CREATED='{{now | date "2006-01-02T15:04:05Z07:00"}}' \
--tag {{ .REGISTRY | default "localhost" }}/x40.link:{{ .GIT_REFSPEC }} \
.
container/push:
desc: "Push the container"
requires:
vars: ["REGISTRY"]
cmds:
- |
podman push \
--remove-signatures \
{{ .REGISTRY }}/x40.link:{{ .GIT_REFSPEC }}
docs:
desc: "Build the static HTML for the documentation"
summary: |
Generate the static HTML for the documentation
This documentation will then be deployed to x40.app (or similar) so that it can be viewed by people looking
to reproduce the service.
dir: "./docs"
deps: ["docs/clean", "docs/install"]
cmds:
- "poetry run mkdocs build"
docs/clean:
desc: "Clean the generated documentation"
dir: "./docs"
cmds:
- "rm -rf docs/content"
docs/install:
desc: "Install the dependencies required for the documentation"
dir: "./docs"
cmds:
- "poetry install --no-root"
docs/tar:
desc: "Package the documentation for release"
deps: ["docs"]
cmds:
- mkdir -p dist
- |
tar \
--dereference --hard-dereference \
--directory docs/site/ \
-cvf dist/docs.tar.gz \
.
docs/view:
desc: "View the documentation on the local machine"
dir: "./docs"
cmds:
- "poetry run mkdocs serve"
protobuf/generate:
desc: "Generates the code required to interact with protobuf definitions"
cmds:
- cd api && buf generate
tofu/plan:
desc: "Plan the infrastructure changes, and validate their output"
requires:
vars: [ENV]
dir: "deploy/{{ .ENV }}/tf"
cmds:
- "tofu plan -out next.planfile"
tofu/apply:
requires:
vars: [ENV]
desc: "Apply previously designed infrastructure changes"
dir: "deploy/{{ .ENV }}/tf"
cmds:
- "tofu apply next.planfile"
lint:
desc: "Validate the code against common standards"
cmds:
# Containers
- hadolint Containerfile
# Golang
- golangci-lint run ./...
test:
env:
CGO_ENABLED: 1
desc: "Run the default set of unit tests"
cmds:
- go test ./... -test.v -race -vet=all
tools/apt/install:
desc: "Install a series of tools via aptitude"
cmds:
# Required for unit tests
- apt-get update
- apt-get install google-cloud-sdk-firestore-emulator
tools/go/install:
desc: "Installs a series of go tools"
cmds:
- go install "github.com/bufbuild/buf/cmd/buf"
- go install "google.golang.org/grpc/cmd/protoc-gen-go-grpc"
- go install "google.golang.org/protobuf/cmd/protoc-gen-go"