-
-
Notifications
You must be signed in to change notification settings - Fork 115
/
cmdx.yaml
309 lines (269 loc) · 6.92 KB
/
cmdx.yaml
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
---
# the configuration file of cmdx - task runner
# https://github.com/suzuki-shunsuke/cmdx
tasks:
- name: scaffold
short: s
usage: Scaffold the configuration for a given package
description: |
Scaffold the configuration for a given package
e.g.
$ cmdx s cli/cli
After scaffolding, tests are run.
flags:
- name: recreate
short: r
type: bool
usage: Recreate the container
script_envs:
- IS_RECREATE
- name: no-create-branch
short: B
type: bool
usage: Don't create a branch
script_envs:
- NO_CREATE_BRANCH
- name: cmd
type: string
usage: A list of commands joined with commas ','
script_envs:
- CMD
- name: limit
type: string
usage: The maximum number of versions
script_envs:
- LIMIT
shell:
- "bash"
- "-c"
script: |
set -eu
PACKAGE=${PACKAGE#https://github.com/}
bash scripts/check_commands.sh
bash scripts/check_gpgsign.sh
bash scripts/check_diff.sh
bash scripts/checkout.sh "$PACKAGE"
if [ "$IS_RECREATE" = true ]; then
aqua exec -- cmdx rm
fi
bash scripts/start.sh
bash scripts/scaffold.sh "$PACKAGE" "$CMD" "$LIMIT"
aqua exec -- cmdx gr
bash scripts/commit.sh "$PACKAGE"
bash scripts/test.sh "$PACKAGE"
bash scripts/start.sh aqua-registry-windows
bash scripts/test-windows.sh "$PACKAGE"
args:
- name: package
usage: a package name. e.g. `cli/cli`
required: true
script_envs:
- PACKAGE
- name: test
short: t
usage: Test a given package in the container
description: |
Test a given package in the container.
$ cmdx t [-r] <package name>
Tests are run on all platforms with AQUA_GOOS and AQUA_GOARCH same with CI in a container.
If the test fails, bash is attached to the container for debugging.
If you want to exit from the container, please run exit.
flags:
- name: recreate
short: r
type: bool
usage: Recreate the container
script_envs:
- IS_RECREATE
args:
- name: package
usage: a package name. e.g. `cli/cli`
script_envs:
- PACKAGE
shell:
- "bash"
- "-c"
script: |
set -eu
PACKAGE=${PACKAGE#https://github.com/}
pkg=$(bash scripts/get_test_pkg.sh "$PACKAGE")
if [ "$IS_RECREATE" = true ]; then
cmdx rm
fi
bash scripts/start.sh
bash scripts/test.sh "$pkg"
bash scripts/start.sh aqua-registry-windows
bash scripts/test-windows.sh "$pkg"
aqua exec -- aqua-registry gr
- name: connect
short: con
usage: Connect to the container
description: |
Connect to the container
$ cmdx connect <os> <arch>
e.g.
$ cmdx connect linux amd64
You need to specify os and arch.
These arguments are set to AQUA_GOOS and AQUA_GOARCH.
args:
- name: os
required: false
default: linux
script_envs:
- OS
- name: arch
required: false
script_envs:
- ARCH
shell:
- "bash"
- "-c"
script: bash scripts/connect.sh
- name: generate-registry
short: gr
usage: Update registry.yaml
description: |
Update registry.yaml
$ cmdx gr
shell:
- "bash"
- "-c"
script: aqua exec -- aqua-registry gr
- name: new
usage: Create a branch, a commit, and a pull request to add a given package
description: |
Create a branch, a commit, and a pull request to add a given package.
$ cmdx new <package name>
e.g.
$ cmdx new cli/cli
script: |
set -eu
if ! bash scripts/new.sh; then
bash scripts/ask_report.sh
fi
args:
- name: package
usage: a package name. e.g. cli/cli
script_envs:
- PACKAGE
- name: stop
usage: Stop containers
description: |
Stop containers.
$ cmdx stop
script: |
set -eu
bash scripts/stop.sh
bash scripts/stop.sh aqua-registry-windows
- name: remove
short: rm
usage: Remove containers
description: |
Remove containers.
$ cmdx rm
script: |
set -eu
bash scripts/remove_container.sh
bash scripts/remove_container.sh aqua-registry-windows
- name: remove-package
short: rmp
usage: Remove a package from containers
description: |
Remove a package from containers
$ cmdx rmp [<package name>]
args:
- name: package
usage: a package name. e.g. cli/cli
script_envs:
- PACKAGE
script: |
set -eu
pkg=$(bash scripts/get_test_pkg.sh "$PACKAGE")
bash scripts/remove_package.sh "$pkg"
- name: start
usage: Start containers
description: |
Start containers.
$ cmdx start
flags:
- name: recreate
short: r
type: bool
usage: Recreate the container
script_envs:
- IS_RECREATE
shell:
- "bash"
- "-c"
script: |
set -eu
if [ "$IS_RECREATE" = true ]; then
cmdx rm
fi
bash scripts/start.sh
bash scripts/start.sh aqua-registry-windows
- name: release
short: r
description: Release the new version
usage: Release the new version
script: |
set -eu
git tag -m "chore: release $VERSION" "$VERSION"
git push origin "$VERSION"
args:
- name: version
required: true
script_envs:
- VERSION
validate:
- regexp: "^v\\d+\\.\\d+.\\d+(-\\d+)?$"
- name: resolve-conflict
description: Resolve the conflict of registry.yaml
usage: Resolve the conflict of registry.yaml
args:
- name: pr
required: true
script_envs:
- PR_NUMBER
script: |
set -eu
git fetch origin main
gh pr checkout "$PR_NUMBER"
tempfile=$(mktemp)
cp registry.yaml "$tempfile"
git merge origin/main || :
mv "$tempfile" registry.yaml
cmdx gr
git add registry.yaml
git commit
- name: summarize
short: sum
description: Summarize a given pull request
usage: Summarize a given pull request
args:
- name: pr
required: true
script_envs:
- PR_NUMBER
script: |
bash scripts/summarize.sh "$PR_NUMBER"
- name: ls-assets
short: lsa
description: List asset names
usage: List asset names
flags:
- name: repo
short: r
type: string
usage: Repo name
script_envs:
- REPO
args:
- name: version
required: true
script_envs:
- VERSION
script: |
REPO=${REPO#https://github.com/}
repo=$(bash scripts/get_test_pkg.sh "$REPO")
gh release view --json assets --jq ".assets[].name" -R "$repo" "$VERSION"