forked from Gruntfuggly/todo-tree
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjustfile
More file actions
305 lines (265 loc) · 9.86 KB
/
Copy pathjustfile
File metadata and controls
305 lines (265 loc) · 9.86 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
set shell := ["bash", "-euo", "pipefail", "-c"]
node_bootstrap := '''
export NVM_DIR="${NVM_DIR:-$HOME/.nvm}"
# Under sudo, $HOME is root's home and the user's nvm is invisible.
# Re-anchor NVM_DIR onto $SUDO_USER's real home directory whenever the
# default location does not contain an nvm install.
if [[ -n "${SUDO_USER:-}" ]] && [[ ! -s "$NVM_DIR/nvm.sh" ]]; then
sudo_user_home="$(getent passwd "$SUDO_USER" 2>/dev/null | cut -d: -f6)"
if [[ -n "$sudo_user_home" ]] && [[ -s "$sudo_user_home/.nvm/nvm.sh" ]]; then
export NVM_DIR="$sudo_user_home/.nvm"
fi
fi
if ! command -v node >/dev/null 2>&1 || ! command -v npm >/dev/null 2>&1 || ! command -v npx >/dev/null 2>&1; then
if [[ -s "$NVM_DIR/nvm.sh" ]]; then
. "$NVM_DIR/nvm.sh"
nvm use --silent default >/dev/null 2>&1 || nvm use --silent >/dev/null 2>&1 || true
fi
fi
if ! command -v node >/dev/null 2>&1; then
latest_nvm_node="$(find "$NVM_DIR/versions/node" -mindepth 1 -maxdepth 1 -type d 2>/dev/null | sort -V | tail -n 1)"
if [[ -n "$latest_nvm_node" ]]; then
export PATH="$latest_nvm_node/bin:$PATH"
fi
fi
# Linuxbrew installs Node at a deterministic system-wide path; surface it
# whenever PATH is otherwise stripped (e.g. sudo's secure_path).
if ! command -v node >/dev/null 2>&1 && [[ -x /home/linuxbrew/.linuxbrew/bin/node ]]; then
export PATH="/home/linuxbrew/.linuxbrew/bin:$PATH"
fi
command -v node >/dev/null 2>&1 || { echo "error: Node.js was not found in PATH or $NVM_DIR." >&2; exit 1; }
command -v npm >/dev/null 2>&1 || { echo "error: npm was not found after activating Node.js." >&2; exit 1; }
command -v npx >/dev/null 2>&1 || { echo "error: npx was not found after activating Node.js." >&2; exit 1; }
'''
actions_bootstrap := '''
tools_root="$PWD/.tools"
bin_dir="$tools_root/bin"
downloads_dir="$tools_root/downloads"
mkdir -p "$bin_dir" "$downloads_dir"
if [[ ! -x "$bin_dir/actionlint" ]]; then
curl -fsSL "https://github.com/rhysd/actionlint/releases/download/v1.7.12/actionlint_1.7.12_linux_amd64.tar.gz" -o "$downloads_dir/actionlint_1.7.12_linux_amd64.tar.gz"
tar -xzf "$downloads_dir/actionlint_1.7.12_linux_amd64.tar.gz" -C "$bin_dir" actionlint
chmod +x "$bin_dir/actionlint"
fi
if [[ ! -x "$bin_dir/act" ]]; then
curl -fsSL "https://github.com/nektos/act/releases/download/v0.2.87/act_Linux_x86_64.tar.gz" -o "$downloads_dir/act_Linux_x86_64.tar.gz"
tar -xzf "$downloads_dir/act_Linux_x86_64.tar.gz" -C "$bin_dir" act
chmod +x "$bin_dir/act"
fi
export PATH="$bin_dir:$PATH"
command -v actionlint >/dev/null 2>&1 || { echo "error: actionlint is not available." >&2; exit 1; }
command -v act >/dev/null 2>&1 || { echo "error: act is not available." >&2; exit 1; }
command -v docker >/dev/null 2>&1 || { echo "error: docker is required for workflow verification." >&2; exit 1; }
command -v curl >/dev/null 2>&1 || { echo "error: curl is required for workflow verifier bootstrap." >&2; exit 1; }
command -v tar >/dev/null 2>&1 || { echo "error: tar is required for workflow verifier bootstrap." >&2; exit 1; }
'''
# Examples:
# just
# just default
default:
@just --list --unsorted
# Examples:
# just setup
setup:
#!/usr/bin/env bash
set -euo pipefail
{{node_bootstrap}}
npm ci
# Examples:
# just test
test:
#!/usr/bin/env bash
set -euo pipefail
{{node_bootstrap}}
npm test
# Examples:
# just perf --list-scenarios
# just perf --scenario config-ripgrep-path-resolution --skip-readme-update --allow-unstable-machine
perf *args:
#!/usr/bin/env bash
set -euo pipefail
{{node_bootstrap}}
node --expose-gc scripts/perf/run-all.js {{args}}
# Examples:
# just bootstrap-release-env
bootstrap-release-env:
#!/usr/bin/env bash
set -euo pipefail
bash scripts/release/bootstrap-release-environment.sh
# Examples:
# just next-release --bump patch
# just next-release --bump patch --push
next-release *args:
#!/usr/bin/env bash
set -euo pipefail
{{node_bootstrap}}
bash scripts/release/create-next-release.sh {{args}}
# Examples:
# just lint-actions
lint-actions:
#!/usr/bin/env bash
set -euo pipefail
{{actions_bootstrap}}
actionlint .github/workflows/*.yml
# Examples:
# just test-actions-ci
test-actions-ci:
#!/usr/bin/env bash
set -euo pipefail
{{actions_bootstrap}}
rm -rf .act-artifacts
mkdir -p .act-artifacts
act pull_request \
-W .github/workflows/ci.yml \
-j test-build \
-P ubuntu-24.04=ghcr.io/catthehacker/ubuntu:act-24.04 \
--container-architecture linux/amd64 \
--artifact-server-path .act-artifacts
# Examples:
# just test-actions-release-build
test-actions-release-build:
#!/usr/bin/env bash
set -euo pipefail
{{node_bootstrap}}
temp_root="$(mktemp -d)"
trap 'rm -rf "$temp_root"' EXIT
temp_repo="$temp_root/repo"
git clone --quiet --no-local --shared --branch master "$PWD" "$temp_repo"
rsync -a \
--exclude '.git' \
--exclude 'node_modules' \
--exclude 'dist' \
--exclude 'artifacts' \
--exclude '.tools' \
--exclude '.act-artifacts' \
./ "$temp_repo/"
(
cd "$temp_repo"
temp_remote="$temp_repo/.act-origin.git"
release_version="$(node -p "require('./package.json').version")"
expected_count="$(node -e "console.log(require('./scripts/release/targets.json').length)")"
git config user.name Codex
git config user.email codex@example.invalid
if [[ -n "$(git status --porcelain)" ]]; then
git add .
git commit -m 'test release workflow' >/dev/null
fi
git tag -d "v$release_version" >/dev/null 2>&1 || true
git tag -a "v$release_version" -m "release"
git init --bare "$temp_remote" >/dev/null
git remote remove origin >/dev/null 2>&1 || true
git remote remove github >/dev/null 2>&1 || true
git remote add origin "$temp_remote"
git remote add github https://github.com/FanaticPythoner/better-todo-tree
git push -u origin master >/dev/null
git push origin --tags >/dev/null
GITHUB_OUTPUT="$temp_root/release-meta.out" \
INPUT_TAG="v$release_version" \
REF_NAME=master \
REF_TYPE=branch \
bash scripts/release/resolve-release-metadata.sh
rm -rf "$temp_remote"
npm ci
npm test
npm run vscode:prepublish
rm -rf artifacts/vsix
node scripts/release/build-vsix.mjs
actual_count="$(find artifacts/vsix -maxdepth 1 -type f -name '*.vsix' | wc -l | tr -d '[:space:]')"
[[ "$actual_count" == "$expected_count" ]]
unzip -l "artifacts/vsix/better-todo-tree-${release_version}-linux-x64.vsix" | grep -q 'extension/readme.md'
if unzip -l "artifacts/vsix/better-todo-tree-${release_version}-linux-x64.vsix" | grep -Eq 'extension/(\\.tools|MIGRATION\\.md|OPEN_VSX_CERTIFICATE_REPORT\\.md|\\.act-origin\\.git)'; then
echo 'error: release VSIX contains local workflow tooling or migration-only documents.' >&2
exit 1
fi
)
# Examples:
# just test-actions-latest-build
test-actions-latest-build:
#!/usr/bin/env bash
set -euo pipefail
{{node_bootstrap}}
npx qunit test/workflows.github.test.js test/release.workflow-scripts.test.js
# Examples:
# just test-actions
test-actions:
#!/usr/bin/env bash
set -euo pipefail
just test
just lint-actions
just test-actions-ci
just test-actions-release-build
just test-actions-latest-build
# Examples:
# just build-ext
# just build-ext linux-x64
# just build-ext linux-x64 darwin-arm64 win32-x64
build-ext *platforms:
#!/usr/bin/env bash
set -euo pipefail
{{node_bootstrap}}
node scripts/release/build-vsix.mjs {{platforms}}
# Whole flow: prepare local branch, stage local source changes, wait, push branch, prompt PR.
# Examples:
# just issue-branch-all https://github.com/FanaticPythoner/better-todo-tree/issues/28 https://github.com/FanaticPythoner/better-todo-tree/issues/36
issue-branch-all *args:
#!/usr/bin/env bash
set -euo pipefail
bash scripts/branch/issue-branch.sh flow {{args}}
# Step only: print derived branch name.
# Examples:
# just issue-branch-name https://github.com/FanaticPythoner/better-todo-tree/issues/28 https://github.com/FanaticPythoner/better-todo-tree/issues/36
issue-branch-name *args:
#!/usr/bin/env bash
set -euo pipefail
bash scripts/branch/issue-branch.sh name {{args}}
# Step only: create local and remote branch from remote base.
# Examples:
# just issue-branch-create https://github.com/FanaticPythoner/better-todo-tree/issues/28 https://github.com/FanaticPythoner/better-todo-tree/issues/36
issue-branch-create *args:
#!/usr/bin/env bash
set -euo pipefail
bash scripts/branch/issue-branch.sh create {{args}}
# Step only: move current source-branch changes onto target branch and stage.
# Examples:
# just issue-branch-stage https://github.com/FanaticPythoner/better-todo-tree/issues/28 https://github.com/FanaticPythoner/better-todo-tree/issues/36
issue-branch-stage *args:
#!/usr/bin/env bash
set -euo pipefail
bash scripts/branch/issue-branch.sh stage {{args}}
# Step only: wait for local commit, then push target branch.
# Examples:
# just issue-branch-push https://github.com/FanaticPythoner/better-todo-tree/issues/28 https://github.com/FanaticPythoner/better-todo-tree/issues/36
issue-branch-push *args:
#!/usr/bin/env bash
set -euo pipefail
bash scripts/branch/issue-branch.sh push {{args}}
# Step only: create PR for target branch.
# Examples:
# just issue-branch-pr https://github.com/FanaticPythoner/better-todo-tree/issues/28 https://github.com/FanaticPythoner/better-todo-tree/issues/36
issue-branch-pr *args:
#!/usr/bin/env bash
set -euo pipefail
bash scripts/branch/issue-branch.sh pr {{args}}
# Examples:
# just clean
# just clean --force
# just clean force
clean *flags:
#!/usr/bin/env bash
set -euo pipefail
force=0
for flag in {{flags}}; do
case "$flag" in
force|--force|-f)
force=1
;;
*)
echo "error: unsupported clean flag '$flag'. Supported flag: force" >&2
exit 1
;;
esac
done
rm -rf dist artifacts
if [[ "$force" -eq 1 ]]; then
rm -rf node_modules
fi