-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjustfile
More file actions
367 lines (289 loc) · 10.8 KB
/
justfile
File metadata and controls
367 lines (289 loc) · 10.8 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
# justfile for birch
# https://just.systems/
# Default recipe: show available commands
default:
@just --list
# Aliases
alias b := build
alias t := test
alias f := format
alias c := check
alias d := docs
alias cl := change
alias g := generate-configs
# Build the project (Erlang target)
build:
gleam build
# Build for JavaScript target
build-js:
gleam build --target javascript
# Build for all targets
build-all: build build-js
# Build with warnings as errors (Erlang target)
build-strict:
gleam build --warnings-as-errors
# Build with warnings as errors (JavaScript target)
build-strict-js:
gleam build --target javascript --warnings-as-errors
# Build with warnings as errors (all targets)
build-strict-all: build-strict build-strict-js
# Run tests on Erlang target
test-erlang:
gleam test
# Run tests on JavaScript target
test-js:
gleam test --target javascript
# Run tests on both targets
test: test-erlang test-js
# Format source code
format:
gleam format src test
# Check formatting
format-check:
gleam format --check src test
# Generate documentation
docs:
gleam docs build
# Download dependencies
deps:
gleam deps download
# Clean build artifacts
clean:
rm -rf build
# Run all checks (format + config sync + tests)
check: format-check check-configs-sync test
# Run quick checks (format + config sync + erlang tests only)
check-quick: format-check check-configs-sync test-erlang
# Full local validation (no act/Docker required)
# Covers: format, config sync, strict build, tests, examples (Erlang), integration (Node.js)
check-full: format-check check-configs-sync build-strict-all test test-examples test-integration-node demo
# CI parity recipes
pr: format-check check-configs-sync build-strict test docs demo
main: pr test-examples
# Watch and rebuild on changes (requires watchexec)
watch:
watchexec -e gleam -r -- gleam build
# Watch and run tests on changes (requires watchexec)
watch-test:
watchexec -e gleam -r -- gleam test
# Run coverage on both Erlang and JavaScript targets
coverage: coverage-erlang coverage-js
# Run JavaScript tests with code coverage (requires npm install)
coverage-js:
npm run test:all:coverage
# Run Erlang tests with code coverage (cross-platform)
coverage-erlang: build
escript scripts/gleam_cover.escript
# Run Erlang tests with coverage and generate LCOV (for CI/Codecov)
coverage-erlang-lcov: build
escript scripts/gleam_cover.escript --lcov
# Generate JavaScript coverage report (after running coverage-js)
coverage-js-report:
npm run coverage:report
# Generate JavaScript LCOV report for CI integration
coverage-js-lcov:
npm run coverage:lcov
# ============================================================================
# Integration Tests (JavaScript Target)
# ============================================================================
# Run integration tests on Node.js
test-integration-node: build-js
node --test test/integration/test_runner.mjs
# Run integration tests on Deno
test-integration-deno: build-js
deno test --allow-read --allow-env --allow-run --allow-write test/integration/test_runner.mjs
# Run integration tests targeting Bun runtime
# Note: Uses Node.js test runner but spawns Bun subprocesses for the actual test execution
test-integration-bun: build-js
INTEGRATION_TEST_RUNTIME=bun node --test test/integration/test_runner.mjs
# Run integration tests on all available runtimes
test-integration: test-integration-node
# Run full integration test suite (all runtimes, requires deno and bun installed)
test-integration-all: test-integration-node test-integration-deno test-integration-bun
# ============================================================================
# Demo
# ============================================================================
# Run the console handler demo showcasing all presentation options
demo:
cd demo && gleam run
# Run the console handler demo on JavaScript target
demo-js:
cd demo && gleam run --target javascript
# ============================================================================
# Examples
# ============================================================================
# Test all examples on Erlang target
test-examples:
#!/usr/bin/env bash
set -e
for dir in examples/*/; do
echo "Testing $dir (Erlang)..."
(cd "$dir" && gleam deps download && gleam test)
done
# Quick smoke test of representative examples (Erlang)
test-examples-smoke:
#!/usr/bin/env bash
set -e
for dir in examples/01-quick-start examples/06-json-handler examples/07-file-handler; do
echo "Testing $dir (Erlang)..."
(cd "$dir" && gleam deps download && gleam test)
done
# Test all examples on Node.js (excluding BEAM-only examples)
test-examples-node:
#!/usr/bin/env bash
set -e
for dir in examples/*/; do
if [[ "$dir" != *"16-erlang-logger"* ]]; then
echo "Testing $dir (Node.js)..."
(cd "$dir" && gleam deps download && gleam test --target javascript)
fi
done
# Test all examples on Deno (excluding BEAM-only examples)
test-examples-deno:
#!/usr/bin/env bash
set -e
for dir in examples/*/; do
if [[ "$dir" != *"16-erlang-logger"* ]]; then
name=$(basename "$dir")
pkg_name="birch_example_${name//-/_}"
echo "Testing $dir (Deno)..."
# gleam run generates gleam.main.mjs pointing to the app's main()
(cd "$dir" && gleam deps download && gleam run --target javascript > /dev/null && \
deno run --no-check --allow-read --allow-env --allow-write "build/dev/javascript/${pkg_name}/gleam.main.mjs")
fi
done
# Test all examples on Bun (excluding BEAM-only examples)
test-examples-bun:
#!/usr/bin/env bash
set -e
for dir in examples/*/; do
if [[ "$dir" != *"16-erlang-logger"* ]]; then
name=$(basename "$dir")
pkg_name="birch_example_${name//-/_}"
echo "Testing $dir (Bun)..."
# gleam run generates gleam.main.mjs pointing to the app's main()
(cd "$dir" && gleam deps download && gleam run --target javascript > /dev/null && \
bun "build/dev/javascript/${pkg_name}/gleam.main.mjs")
fi
done
# Alias for Node.js (default JavaScript runtime)
test-examples-js: test-examples-node
# Test all examples on Erlang and Node.js
test-examples-all: test-examples test-examples-node
# Test all examples on all runtimes (requires deno and bun installed)
test-examples-all-runtimes: test-examples test-examples-node test-examples-deno test-examples-bun
# Test a specific example on Erlang target
test-example-erlang example:
#!/usr/bin/env bash
cd "examples/{{example}}"
gleam deps download
gleam test
# Test a specific example on Node.js (via gleam test)
test-example-node example:
#!/usr/bin/env bash
cd "examples/{{example}}"
gleam deps download
gleam test --target javascript
# Test a specific example on Deno (runs main function via gleam.main.mjs)
test-example-deno example:
#!/usr/bin/env bash
cd "examples/{{example}}"
gleam deps download
# gleam run generates gleam.main.mjs pointing to the app's main()
gleam run --target javascript > /dev/null
pkg_name="birch_example_$(echo '{{example}}' | tr '-' '_')"
deno run --no-check --allow-read --allow-env --allow-write "build/dev/javascript/${pkg_name}/gleam.main.mjs"
# Test a specific example on Bun (runs main function via gleam.main.mjs)
test-example-bun example:
#!/usr/bin/env bash
cd "examples/{{example}}"
gleam deps download
# gleam run generates gleam.main.mjs pointing to the app's main()
gleam run --target javascript > /dev/null
pkg_name="birch_example_$(echo '{{example}}' | tr '-' '_')"
bun "build/dev/javascript/${pkg_name}/gleam.main.mjs"
# ============================================================================
# Act-based CI Testing (https://github.com/nektos/act)
# Requires: Docker running, act installed (https://nektosact.com/installation/)
# ============================================================================
# List all act CI jobs available
ci-list:
act -l
# Run full local CI validation (no Docker required)
ci: check-full
# Run a specific CI job locally
ci-job job:
act -j {{job}}
# Run CI test job for Erlang target
ci-test-erlang:
act -j test --matrix target:erlang
# Run CI test job for JavaScript target
ci-test-js:
act -j test --matrix target:javascript
# Run CI coverage job
ci-coverage:
act -j coverage
# Run CI integration tests (all runtimes)
ci-integration:
act -j integration-test
# Run CI integration test for a specific runtime (node, deno, bun)
ci-integration-runtime runtime:
act -j integration-test --matrix runtime:{{runtime}}
# Run CI docs job
ci-docs:
act -j docs
# Run CI examples job for a specific example and target
ci-example example target="erlang":
act -j examples --matrix example:{{example}} --matrix target:{{target}}
# Run all CI examples for Erlang target only (faster validation)
ci-examples-erlang:
act -j examples --matrix target:erlang
# Dry-run CI (show what would execute without running)
ci-dry:
act push --dryrun
# Run CI with verbose output for debugging
ci-verbose:
act push --verbose --concurrent-jobs 1
# Run CI on host system without Docker (uses locally installed tools)
ci-host:
act push -P ubuntu-latest=-self-hosted --concurrent-jobs 1
# Run specific CI job on host system without Docker
ci-host-job job:
act -j {{job}} -P ubuntu-latest=-self-hosted
# ============================================================================
# Configuration Generation
# Requires: commit-config-gen (go install github.com/tylerbutler/commit-config-gen@latest)
# ============================================================================
# Generate cliff.toml and .commitlintrc.json from commit-types.json
generate-configs:
commit-config-gen generate
# Check that generated configs are in sync with commit-types.json
check-configs-sync:
commit-config-gen check
# Create a new changelog entry
change:
changie new
# Preview the next version changelog
changelog-preview:
changie batch auto --dry-run
# Generate CHANGELOG.md from version files
changelog:
changie merge
# ============================================================================
# Documentation Site (Astro/Starlight)
# ============================================================================
# Install docs-site dependencies
docs-site-deps:
cd docs-site && pnpm install
# Start docs-site dev server
docs-site-dev:
cd docs-site && pnpm dev
# Build docs-site for production
docs-site-build:
cd docs-site && pnpm build
# Preview docs-site production build
docs-site-preview:
cd docs-site && pnpm preview
# Clean docs-site build artifacts
docs-site-clean:
cd docs-site && pnpm clean