forked from semaphoreui/semaphore
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskfile.yml
More file actions
394 lines (350 loc) · 12.5 KB
/
Copy pathTaskfile.yml
File metadata and controls
394 lines (350 loc) · 12.5 KB
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
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
version: "3"
includes:
enhanced:
taskfile: ./Taskfile.ex.yml
flatten: true
vars:
DOCKER_ORG: ghcr.io/freefair
DOCKER_SERVER: semaphore-ex
DOCKER_RUNNER: semaphore-ex-runner
DOCKER_CMD: docker
CORE_REVISION:
sh: git rev-parse HEAD
ENHANCED_REVISION:
sh: git rev-parse HEAD
SOURCE_DATE_EPOCH:
sh: git show -s --format=%ct HEAD
tasks:
all:
desc: Install, test and build Semaphore for local architecture
cmds:
- task: deps
- task: test
- task: build
vars:
GOOS: ""
GOARCH: ""
deps:
desc: Install all build dependencies
cmds:
- task: deps:tools
- task: deps:be
- task: deps:fe
deps:tools:
desc: Installs required tools to build and publish
vars:
SWAGGER_VERSION: v0.30.5
GORELEASER_VERSION: v2.11.2
GOLINTER_VERSION: v2.13.2
cmds:
- go install github.com/go-swagger/go-swagger/cmd/swagger@latest
- go install github.com/goreleaser/goreleaser/v2@{{ .GORELEASER_VERSION }}
- go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@{{ .GOLINTER_VERSION }}
dir: /tmp
deps:be:
desc: Vendor application dependencies
cmds:
- go work vendor
deps:fe:
desc: Installs nodejs requirements
dir: web
cmds:
- npm ci
build:
desc: Build a full set of release binaries and packages
cmds:
- task: build:fe
- task: build:be
build:debug:
desc: Build DEBUG server binary
cmds:
- >-
env CGO_ENABLED=0 GOOS={{ .GOOS }} GOARCH={{ .GOARCH }}
go build -trimpath -buildvcs=false -o bin/semaphore{{ if eq OS "windows" }}.exe{{ end }}
-tags "netgo"
-gcflags="all=-N -l"
-ldflags "-X {{ .IMPORT }}/util.Ver={{ .VERSION }} -X {{ .IMPORT }}/util.Commit={{ .SHA }} -X {{ .IMPORT }}/util.Date={{ .DATE }} -X {{ .IMPORT }}/util.BuildEdition={{ .EDITION }} -X {{ .IMPORT }}/util.CoreRevision={{ .CORE_REVISION }} -X {{ .IMPORT }}/util.EnhancedRevision={{ .ENHANCED_REVISION }} -X {{ .IMPORT }}/util.EditionImplementation={{ .IMPLEMENTATION_VERSION }}" ./cli
vars:
EDITION: enhanced
IMPLEMENTATION_VERSION:
sh: echo "{{ .ENHANCED_REVISION }}" | cut -c1-12 | sed 's/^/enhanced-/'
TAG:
sh: git name-rev --name-only --tags --no-undefined HEAD 2>/dev/null || git rev-parse --abbrev-ref HEAD
SHA:
sh: git log --pretty=format:'%h' -n 1
VERSION: "{{ if eq .GITHUB_REF_TYPE \"tag\" }}{{ .GITHUB_REF_NAME }}{{ else }}{{ .TAG }}{{ end }}"
DATE: "{{ .SOURCE_DATE_EPOCH }}"
IMPORT: "github.com/semaphoreui/semaphore"
build:fe:
desc: Build VueJS project
dir: web
sources:
- src/*.*
- src/**/*.*
- public/index.html
- public/favicon.ico
- ../api-docs.yml
- package.json
- package-lock.json
- babel.config.js
- vue.config.js
generates:
- ../api/public/css/*.css
- ../api/public/js/*.js
- ../api/public/index.html
- ../api/public/favicon.ico
cmds:
- >-
{{ if eq OS "windows" }}set VUE_APP_SOURCE_MAP_MODE=none && {{ else }}env VUE_APP_SOURCE_MAP_MODE=none{{ end }}
npm run build
build:be:
desc: Build server binary
cmds:
- >-
{{ if eq OS "windows" }}set CGO_ENABLED=0 && GOOS={{ .GOOS }} && GOARCH={{ .GOARCH }} && {{ else }}env CGO_ENABLED=0 GOOS={{ .GOOS }} GOARCH={{ .GOARCH }}{{ end }}
go build -trimpath -buildvcs=false -o bin/semaphore{{ if eq OS "windows" }}.exe{{ end }}
-tags "netgo"
-ldflags "-s -w -X {{ .IMPORT }}/util.Ver={{ .VERSION }} -X {{ .IMPORT }}/util.Commit={{ .SHA }} -X {{ .IMPORT }}/util.Date={{ .DATE }} -X {{ .IMPORT }}/util.BuildEdition={{ .EDITION }} -X {{ .IMPORT }}/util.CoreRevision={{ .CORE_REVISION }} -X {{ .IMPORT }}/util.EnhancedRevision={{ .ENHANCED_REVISION }} -X {{ .IMPORT }}/util.EditionImplementation={{ .IMPLEMENTATION_VERSION }}" ./cli
vars:
EDITION: enhanced
IMPLEMENTATION_VERSION:
sh: echo "{{ .ENHANCED_REVISION }}" | cut -c1-12 | sed 's/^/enhanced-/'
TAG:
sh: if [ -n "${SEMAPHORE_SOURCE_TAG:-}" ]; then printf '%s\n' "${SEMAPHORE_SOURCE_TAG}"; else git name-rev --name-only --tags --no-undefined HEAD 2>/dev/null || git rev-parse --abbrev-ref HEAD; fi
SHA:
sh: if [ -n "${SEMAPHORE_SOURCE_SHA:-}" ]; then printf '%s\n' "${SEMAPHORE_SOURCE_SHA}"; else git log --pretty=format:'%h' -n 1; fi
VERSION: "{{ if eq .GITHUB_REF_TYPE \"tag\" }}{{ .GITHUB_REF_NAME }}{{ else }}{{ .TAG }}{{ end }}"
DATE: "{{ .SOURCE_DATE_EPOCH }}"
IMPORT: "github.com/semaphoreui/semaphore"
docs:gen:
desc: Regenerate the generated documentation reference pages from the source
cmds:
- go run ./tools/docsref -out docs/docs/reference/configuration.md
- go run ./tools/clidocs -out docs/docs/reference/cli/commands.md
docs:check:
desc: Fail if the generated documentation pages are out of date
cmds:
- task: docs:gen
- |
# --porcelain rather than `diff --quiet` so that a brand new generated
# page, which is untracked rather than modified, also fails the check.
changed=$(git -C docs status --porcelain -- docs/reference)
if [ -n "$changed" ]; then
echo "The generated documentation reference is out of date."
echo "Run 'task docs:gen' and commit docs/docs/reference."
echo "$changed"
exit 1
fi
lint:
cmds:
- task: lint:fe
- task: lint:be
lint:fe:
dir: web
cmds:
- npm run lint
lint:be:
cmds:
- golangci-lint run
- swagger validate ./api-docs.yml
test:
cmds:
- task: test:fe
- task: test:be
test:fe:
dir: web
cmds:
- npm run test:unit
test:be:
desc: Run go code tests
cmds:
- go test -v -coverprofile=coverage.out ./...
dredd:goodman:
desc: Installs goodman which is required by dredd
cmds:
- go install github.com/snikch/goodman/cmd/goodman@latest
dredd:deps:
desc: Installs dredd dep for integration testing
dir: web
cmds:
- npm install dredd@13.1.2
dredd:hooks:
desc: Compile required dredd hooks built
dir: ./.dredd/hooks
cmds:
- go build -o ../compiled_hooks{{ if eq OS "windows" }}.exe{{ end }}
dredd:test:
desc: Run end to end test for API with dredd
cmds:
- go run ./tools/openapibundle
- ./web/node_modules/.bin/dredd --config .dredd/dredd.testing.yml
dredd:test:local:
desc: Run end to end test for API with dredd
cmds:
- go run ./tools/openapibundle
- ./web/node_modules/.bin/dredd --config .dredd/dredd.local.yml
release:prod:
desc: Create and publish a release
vars:
EDITION: enhanced
IMPLEMENTATION_VERSION:
sh: echo "{{ .ENHANCED_REVISION }}" | cut -c1-12 | sed 's/^/enhanced-/'
cmds:
- >-
env BUILD_EDITION="{{ .EDITION }}"
CORE_REVISION="{{ .CORE_REVISION }}"
ENHANCED_REVISION="{{ .ENHANCED_REVISION }}"
EDITION_IMPLEMENTATION="{{ .IMPLEMENTATION_VERSION }}"
SOURCE_DATE_EPOCH="{{ .SOURCE_DATE_EPOCH }}"
goreleaser release {{ .GORELEASER_ARGS }}
release:test:
desc: Create a local test release
vars:
EDITION: enhanced
IMPLEMENTATION_VERSION:
sh: echo "{{ .ENHANCED_REVISION }}" | cut -c1-12 | sed 's/^/enhanced-/'
cmds:
- >-
env BUILD_EDITION="{{ .EDITION }}"
CORE_REVISION="{{ .CORE_REVISION }}"
ENHANCED_REVISION="{{ .ENHANCED_REVISION }}"
EDITION_IMPLEMENTATION="{{ .IMPLEMENTATION_VERSION }}"
SOURCE_DATE_EPOCH="{{ .SOURCE_DATE_EPOCH }}"
goreleaser --auto-snapshot --clean --skip=sign
docker:test:
desc: Test containers by building, running, testing and deleting them
deps:
- task: docker:deps
cmds:
- task: docker:build
vars:
tag: test
- task: docker:goss
- task: docker:lint
- "{{ .DOCKER_CMD }} rmi {{ .DOCKER_ORG }}/{{ .DOCKER_SERVER }}:test"
- "{{ .DOCKER_CMD }} rmi {{ .DOCKER_ORG }}/{{ .DOCKER_RUNNER }}:test"
docker:lint:
desc: Lint all dockerfiles based on Hadolint
deps:
- task: docker:deps
cmds:
- task: docker:lint:server
- task: docker:lint:runner
docker:lint:server:
desc: Lint server dockerfile based on Hadolint
dir: deployment/docker/server
cmds:
- hadolint Dockerfile --ignore DL3018
docker:lint:runner:
desc: Lint runner dockerfile based on Hadolint
dir: deployment/docker/runner
cmds:
- hadolint Dockerfile --ignore DL3018
docker:goss:
desc: Check if container contains defined files
deps:
- task: docker:deps
cmds:
- task: docker:goss:server
- task: docker:goss:runner
docker:goss:server:
desc: Check if server contains defined files
dir: deployment/docker/server
env:
GOSS_FILES_STRATEGY: cp
cmds:
- dgoss run -it "{{ .DOCKER_ORG }}/{{ .DOCKER_SERVER }}:test"
docker:goss:runner:
desc: Check if runner contains defined files
dir: deployment/docker/runner
env:
GOSS_FILES_STRATEGY: cp
cmds:
- dgoss run -it "{{ .DOCKER_ORG }}/{{ .DOCKER_RUNNER }}:test"
docker:build:
desc: Build all defined images for Semaphore
vars:
tag: "{{ if .tag }}{{ .tag }}{{ else }}latest{{ end }}"
cmds:
- task: docker:build:server
vars:
tag: "{{ .tag }}"
- task: docker:build:runner
vars:
tag: "{{ .tag }}"
docker:build:debug:
desc: Build an DEBUG image for Semaphore server
vars:
tag: "debug"
cmds:
- "{{ .DOCKER_CMD }} build -f deployment/docker/debug/Dockerfile -t {{ .DOCKER_ORG }}/{{ .DOCKER_SERVER }}:{{ .tag }} ."
docker:build:server:
desc: Build an image for Semaphore server
vars:
tag: "{{ if .tag }}{{ .tag }}{{ else }}latest{{ end }}"
cmds:
- "{{ .DOCKER_CMD }} build -f deployment/docker/server/Dockerfile -t {{ .DOCKER_ORG }}/{{ .DOCKER_SERVER }}:{{ .tag }} ."
docker:build:runner:
desc: Build an image for Semaphore runner
vars:
tag: "{{ if .tag }}{{ .tag }}{{ else }}latest{{ end }}"
cmds:
- "{{ .DOCKER_CMD }} build -f deployment/docker/runner/Dockerfile -t {{ .DOCKER_ORG }}/{{ .DOCKER_RUNNER }}:{{ .tag }} ."
docker:push:
desc: Push the images to registry
cmds:
- docker push {{ .DOCKER_ORG }}/{{ .DOCKER_SERVER }}:{{ .tag }}
- docker push {{ .DOCKER_ORG }}/{{ .DOCKER_RUNNER }}:{{ .tag }}
docker:deps:
desc: Install docker testing dependencies
vars:
INSTALL_PATH: '{{ .INSTALL_PATH | default "/usr/local/bin" }}'
REQUIRE_SUDO: '{{ .REQUIRE_SUDO | default "true" }}'
cmds:
- task: docker:deps:hadolint
vars:
INSTALL_PATH: "{{ .INSTALL_PATH }}"
REQUIRE_SUDO: "{{ .REQUIRE_SUDO }}"
- task: docker:deps:goss
vars:
INSTALL_PATH: "{{ .INSTALL_PATH }}"
REQUIRE_SUDO: "{{ .REQUIRE_SUDO }}"
- task: docker:deps:dgoss
vars:
INSTALL_PATH: "{{ .INSTALL_PATH }}"
REQUIRE_SUDO: "{{ .REQUIRE_SUDO }}"
docker:deps:hadolint:
platforms:
- linux/amd64
- linux/arm64
- darwin/amd64
- darwin/arm64
vars:
HADOLINT_VERSION: v2.10.0
status:
- test -f "{{ .INSTALL_PATH }}/hadolint"
cmds:
- '{{ if eq .REQUIRE_SUDO "true" }}sudo {{ end }}curl -sSL https://github.com/hadolint/hadolint/releases/download/{{ .HADOLINT_VERSION }}/hadolint-{{ if eq OS "linux" }}Linux{{ end }}{{ if eq OS "darwin" }}Darwin{{ end }}-{{ if eq ARCH "amd64" }}x86_64{{ else }}{{ ARCH }}{{ end }} -o {{ .INSTALL_PATH }}/hadolint'
- '{{ if eq .REQUIRE_SUDO "true" }}sudo {{ end }}chmod +x {{ .INSTALL_PATH }}/hadolint'
docker:deps:goss:
platforms:
- linux
- darwin
vars:
GOSS_VERSION: v0.3.5
status:
- test -f "{{ .INSTALL_PATH }}/goss"
cmds:
- '{{ if eq .REQUIRE_SUDO "true" }}sudo {{ end }}curl -sSL https://github.com/aelsabbahy/goss/releases/download/{{ .GOSS_VERSION }}/goss-{{ OS }}-{{ ARCH }} -o {{ .INSTALL_PATH }}/goss'
- '{{ if eq .REQUIRE_SUDO "true" }}sudo {{ end }}chmod +x {{ .INSTALL_PATH }}/goss'
docker:deps:dgoss:
platforms:
- linux
- darwin
vars:
GOSS_VERSION: v0.3.5
status:
- test -f "{{ .INSTALL_PATH }}/dgoss"
cmds:
- '{{ if eq .REQUIRE_SUDO "true" }}sudo {{ end }}curl -sSL https://raw.githubusercontent.com/aelsabbahy/goss/{{ .GOSS_VERSION }}/extras/dgoss/dgoss -o {{ .INSTALL_PATH }}/dgoss'
- '{{ if eq .REQUIRE_SUDO "true" }}sudo {{ end }}chmod +x {{ .INSTALL_PATH }}/dgoss'