-
Notifications
You must be signed in to change notification settings - Fork 1
/
justfile
272 lines (207 loc) · 6.13 KB
/
justfile
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
alias a := all
alias b := build
alias c := clean
alias co := cover
alias l := lint
alias r := run
alias t := test
alias v := version
_ci := env_var_or_default("CI", "false")
_cmd := "./cmd/publisher"
_debug := env_var_or_default("DEBUG", "false")
_github_actions := env_var_or_default("GITHUB_ACTIONS", "false")
_interactive := `tty -s && echo "-it" || echo ""`
_mode := env_var_or_default("MODE", if _ci == "true" { "prod" } else { "dev" })
_target_platform := env("TARGETPLATFORM", "`go env GOOS`/`go env GOARCH`")
_with_debug := if _debug == "true" {
"set -x pipefail"
} else {
""
}
_uid_args := if os_family() == "unix" {
"-u $(id -u):$(id -g)"
} else {
""
}
PYTHON_VERSION := env("PYTHON_VERSION", "3.12.1")
QUARTO_VERSION := env("QUARTO_VERSION", "1.4.553")
# Quick start
default:
#!/usr/bin/env bash
set -eou pipefail
{{ _with_debug }}
just clean
just build
just package
just archive
os:
#!/usr/bin/env bash
set -eou pipefail
{{ _with_debug }}
go env GOOS
arch:
#!/usr/bin/env bash
set -eou pipefail
{{ _with_debug }}
go env GOARCH
# Executes command against every justfile where avaiable. WARNING your mileage may very.
all +args='default':
#!/usr/bin/env bash
set -eou pipefail
{{ _with_debug }}
# For each justfile, check if the first argument exists, and then execute it.
for f in `find . -name justfile`; do
arg=`echo {{ args }} | awk '{print $1;}'`
if just -f $f --show $arg &>/dev/null; then
just -f $f {{ args }}
fi
done
# Archives the application for distribution. Archives are written to `./archives`. If invoked with `env CI=true` then archives are create for all architectures supported by the Go toolchain.
archive:
#!/usr/bin/env bash
set -eou pipefail
{{ _with_debug }}
./scripts/archive.bash {{ _cmd }}
# Executes commands in ./test/bats/justfile. Equivalent to `just test/bats/`.
bats *args:
#!/usr/bin/env bash
set -eou pipefail
{{ _with_debug }}
just test/bats/{{ args }}
# Compiles the application using Go. Executables are written to `./bin`. If invoked with `env CI=true` then executables for all supported architectures using the Go toolchain.
build:
#!/usr/bin/env bash
set -eou pipefail
{{ _with_debug }}
env MODE={{ _mode }} ./scripts/build.bash {{ _cmd }}
# Deletes ephemeral project files (i.e., cleans the project).
clean:
#!/usr/bin/env bash
set -eou pipefail
{{ _with_debug }}
rm -rf ./archives
rm -rf ./bin
rm -rf ./dist
# Prints shell commands to configure executable on path. Configure your shell via: eval "$(just configure)"
configure:
#!/usr/bin/env bash
set -eou pipefail
{{ _with_debug }}
pathname=`just executable-path`
if ! [ -f $pathname ]; then
echo "info: ${pathname} not found. Running 'just build'." 1>&2
just build 1>&2
fi
dir=`dirname $pathname`
base=`basename "$pathname"`
echo export PATH=`printf "%q" $PATH:$dir`
# Display the code coverage collected during the last execution of `just test`.
cover:
#!/usr/bin/env bash
set -eou pipefail
{{ _with_debug }}
go tool cover -html=cover.out
# Prints the executable path for this operating system. It may not exist yet (see `just build`).
executable-path os="$(just os)" arch="$(just arch)":
#!/usr/bin/env bash
set -eou pipefail
{{ _with_debug }}
./scripts/get-executable-path.bash {{ _cmd }} $(just version) {{ os }} {{ arch }}
# Fixes linting errors
fix:
#!/usr/bin/env bash
set -eou pipefail
{{ _with_debug }}
./scripts/ccheck.py ./scripts/ccheck.config --fix
install:
#!/usr/bin/env bash
set -eou pipefail
{{ _with_debug }}
if [ ! `which staticcheck` ]; then
go install honnef.co/go/tools/cmd/staticcheck@latest
if [ ! `which staticcheck` ]; then
echo "error: \`staticcheck\` not found. Is '\$GOPATH/bin' in your '\$PATH'?" 1>&2
exit 1
fi
fi
npm-install:
#!/usr/bin/env bash
set -eou pipefail
{{ _with_debug }}
if [ {{ _ci }} = "true" ]; then
npm ci --no-audit --no-fund
else
npm install --no-audit --no-fund
fi
# staticcheck, vet, and format check
lint:
#!/usr/bin/env bash
set -eou pipefail
{{ _with_debug }}
./scripts/ccheck.py ./scripts/ccheck.config
staticcheck ./...
go vet -all ./...
./scripts/fmt-check.bash
format:
#!/usr/bin/env bash
set -eou pipefail
{{ _with_debug }}
npm run format
check-format:
#!/usr/bin/env bash
set -eou pipefail
{{ _with_debug }}
npm run check-format
name:
#!/usr/bin/env bash
set -eou pipefail
{{ _with_debug }}
basename {{ _cmd }}
package:
#!/usr/bin/env bash
set -eou pipefail
{{ _with_debug }}
just vscode set-version
./scripts/package.bash {{ _cmd }}
# Prints the pre-release status based on the version (see `just version`).
pre-release:
#!/usr/bin/env bash
set -eou pipefail
{{ _with_debug }}
./scripts/is-pre-release.bash
# Runs the CLI via `go run`.
run *args:
#!/usr/bin/env bash
set -eou pipefail
{{ _with_debug }}
pathname=`just executable-path`
${pathname} {{ args }}
# Execute unit tests.
test *args=("./..."):
#!/usr/bin/env bash
set -eou pipefail
{{ _with_debug }}
go test {{ args }} -covermode set -coverprofile=cover.out
# Uploads distributions to object storage. If invoked with `env CI=true` then all architectures supported by the Go toolchain are uploaded.
upload *args:
#!/usr/bin/env bash
set -eou pipefail
{{ _with_debug }}
./scripts/upload.bash {{ _cmd }} {{ args }}
# Print the version.
version:
#!/usr/bin/env bash
set -eou pipefail
{{ _with_debug }}
./scripts/get-version.bash
# Executes commands in ./extensions/vscode/Justfile. Equivalent to `just extensions/vscode`.
vscode *args:
#!/usr/bin/env bash
set -eou pipefail
{{ _with_debug }}
just extensions/vscode/{{ args }}
vscode-ui *args:
#!/usr/bin/env bash
set -eou pipefail
{{ _with_debug }}
just test/vscode-ui/{{ args }}