-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathABTaskFile
223 lines (201 loc) · 6.53 KB
/
ABTaskFile
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
name: build_tasks
description: Choria Build Tasks
commands:
- name: dependencies
type: parent
description: Manage dependencies
aliases: [d]
commands:
- name: update
description: Update dependencies
type: exec
aliases: [up]
flags:
- name: verbose
description: Log verbosely
bool: true
- name: proxy
description: Enable using go proxy
bool: true
default: "true"
banner: |
>>>
>>> Updating all dependencies
>>>
script: |
{{ if eq .Flags.proxy false }}
export GOPROXY=direct
echo ">>>"
echo ">>> Disabling go mod proxy"
echo ">>>"
echo
{{ end }}
go get -u -n -a -t {{- if .Flags.verbose }} -d -x {{ end }} ./...
echo ">>> Running go mod tidy"
go mod tidy
- name: test
type: parent
aliases: [t]
description: Perform various tests
commands:
- name: unit
type: exec
description: Run ginkgo unit tests
aliases: [u]
arguments:
- name: dir
description: Directory to test
default: .
flags:
- name: update
description: Updates the ginkgo runtime
bool: true
script: |
set -e
{{ if .Flags.update }}
echo ">>> Updating ginkgo binary"
go install github.com/onsi/ginkgo/v2/ginkgo
{{ end }}
ginkgo -r --skip Integration {{ .Arguments.dir | escape }}
- name: docs
type: parent
description: Documentation related commands
commands:
- name: serve
description: Serves documentation locally
type: exec
flags:
- name: port
description: The port to listen on
default: "8081"
command: hugo serve -p {{ .Flags.port }} -s docs
- name: build
type: parent
aliases: [b]
description: Code build steps
commands:
- name: binary
description: Build a basic test binary
type: exec
aliases: [bin]
banner: |
>>>
>>> Building 'aaasvc' locally
>>>
>>> Target: {{ if .Flags.target }}{{ .Flags.target }}{{else}}host{{end}}
>>>
flags:
- name: target
description: Target platform to build for
enum: ["linux/amd64"]
short: T
- name: verbose
description: Logs packages being build
bool: true
short: v
script: |
set -e
{{ if eq .Flags.target "linux/amd64" }}
export GOOS=linux
export GOARCH=amd64
{{ end }}
{{ if .Flags.verbose }}
echo ">>> Packages being build"
{{ end }}
go build \
{{ if .Flags.verbose }}-v{{ end }} \
-ldflags="-s -w \
-X 'github.com/choria-io/aaasvc/cmd.version=0.0.$(date +%s)' \
" -o aaasvc
echo
ls -l aaasvc
echo
file aaasvc
echo
- name: nightly-docker
description: Builds nightly docker container
type: exec
aliases: [nd]
flags:
- name: repo
description: YUM Repository to use
default: https://yum.eu.choria.io/nightly/el/nightly.repo
- name: push
description: Push the built images
default: "false"
bool: true
banner: |
>>>
>>> Building nightly docker container using {{ .Flags.repo }}
>>>
script: |
set -e
docker pull almalinux:9
DATE=$(date +%Y%m%d)
docker build \
--no-cache \
--build-arg REPO={{ .Flags.repo | escape }} \
--tag "choria/aaasvc:nightly-${DATE}" \
--tag "choria/aaasvc:nightly" \
--tag "registry.choria.io/choria-nightly/aaasvc:nightly-${DATE}" \
--tag "registry.choria.io/choria-nightly/aaasvc:nightly" \
.
{{ if .Flags.push }}
echo
echo ">>> Pushing built containers"
echo
docker push "choria/aaasvc:nightly"
docker push "choria/aaasvc:nightly-${DATE}"
docker push "registry.choria.io/choria-nightly/aaasvc:nightly-${DATE}"
docker push "registry.choria.io/choria-nightly/aaasvc:nightly"
{{ else }}
echo
echo ">>> Skipping container push"
echo
{{ end }}
- name: release-docker
description: Builds release docker container
type: exec
aliases: [rd]
flags:
- name: repo
description: YUM Repository to use
default: https://yum.eu.choria.io/release/el/release.repo
- name: push
description: Push the built images
default: "false"
bool: true
banner: |
>>>
>>> Building release docker container using {{ .Flags.repo }}
>>>
script: |
set -e
TAG=$(git tag --points-at HEAD|sed -e s/^v//)
if [ -z "${TAG}" ]
then
echo "!!! HEAD is not a tag"
exit 1
fi
docker pull almalinux:9
docker build \
--no-cache \
--build-arg REPO={{ .Flags.repo | escape }} \
--tag "choria/aaasvc:${TAG}" \
--tag "choria/aaasvc:latest" \
--tag "registry.choria.io/choria/aaasvc:${TAG}" \
--tag "registry.choria.io/choria/aaasvc:latest" \
.
{{ if .Flags.push }}
echo
echo ">>> Pushing built containers"
echo
docker push "choria/aaasvc:${TAG}"
docker push "choria/aaasvc:latest"
docker push "registry.choria.io/choria/aaasvc:${TAG}"
docker push "registry.choria.io/choria/aaasvc:latest"
{{ else }}
echo
echo ">>> Skipping container push"
echo
{{ end }}