generated from TBD54566975/tbd-project-template
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Justfile
141 lines (112 loc) · 5.81 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
set positional-arguments
set shell := ["bash", "-c"]
WATCHEXEC_ARGS := "-d 1s -e proto -e go -e sql -f sqlc.yaml"
RELEASE := "build/release"
VERSION := `git describe --tags --always --dirty | sed -e 's/^v//'`
KT_RUNTIME_OUT := "kotlin-runtime/ftl-runtime/target/ftl-runtime-1.0-SNAPSHOT.jar"
KT_RUNTIME_RUNNER_TEMPLATE_OUT := "build/template/ftl/jars/ftl-runtime.jar"
RUNNER_TEMPLATE_ZIP := "backend/controller/scaling/localscaling/template.zip"
TIMESTAMP := `date +%s`
SCHEMA_OUT := "backend/protos/xyz/block/ftl/v1/schema/schema.proto"
ZIP_DIRS := "go-runtime/compile/build-template go-runtime/compile/external-module-template go-runtime/scaffolding kotlin-runtime/scaffolding kotlin-runtime/external-module-template"
FRONTEND_OUT := "frontend/dist/index.html"
EXTENSION_OUT := "extensions/vscode/dist/extension.js"
PROTOS_IN := "backend/protos/xyz/block/ftl/v1/schema/schema.proto backend/protos/xyz/block/ftl/v1/console/console.proto backend/protos/xyz/block/ftl/v1/ftl.proto backend/protos/xyz/block/ftl/v1/schema/runtime.proto"
PROTOS_OUT := "backend/protos/xyz/block/ftl/v1/console/console.pb.go backend/protos/xyz/block/ftl/v1/ftl.pb.go backend/protos/xyz/block/ftl/v1/schema/runtime.pb.go backend/protos/xyz/block/ftl/v1/schema/schema.pb.go frontend/src/protos/xyz/block/ftl/v1/console/console_pb.ts frontend/src/protos/xyz/block/ftl/v1/ftl_pb.ts frontend/src/protos/xyz/block/ftl/v1/schema/runtime_pb.ts frontend/src/protos/xyz/block/ftl/v1/schema/schema_pb.ts"
_help:
@just -l
# Run errtrace on Go files to add stacks
errtrace:
git ls-files -z -- '*.go' | grep -zv /_ | xargs -0 errtrace -w && go mod tidy
# Clean the build directory
clean:
rm -rf build
rm -rf frontend/node_modules
find . -name '*.zip' -exec rm {} \;
mvn -f kotlin-runtime/ftl-runtime clean
# Live rebuild the ftl binary whenever source changes.
live-rebuild:
watchexec {{WATCHEXEC_ARGS}} -- "just build-sqlc && just build ftl"
# Run "ftl dev" with live-reloading whenever source changes.
dev *args:
watchexec -r {{WATCHEXEC_ARGS}} -- "just build-sqlc && ftl dev {{args}}"
# Build everything
build-all: build-protos build-frontend build-generate build-sqlc build-zips
@just build ftl ftl-controller ftl-runner ftl-initdb
# Run "go generate" on all packages
build-generate:
@mk backend/schema/aliaskind_enumer.go : backend/schema/metadataalias.go -- go generate -x ./backend/schema
@mk internal/log/log_level_string.go : internal/log/api.go -- go generate -x ./internal/log
# Build command-line tools
build +tools: build-protos build-zips build-frontend
#!/bin/bash
shopt -s extglob
for tool in $@; do mk "{{RELEASE}}/$tool" : !(build|integration) -- go build -o "{{RELEASE}}/$tool" -tags release -ldflags "-X github.com/TBD54566975/ftl.Version={{VERSION}} -X github.com/TBD54566975/ftl.Timestamp={{TIMESTAMP}}" "./cmd/$tool"; done
# Build all backend binaries
build-backend:
just build ftl ftl-controller ftl-runner
export DATABASE_URL := "postgres://postgres:secret@localhost:54320/ftl?sslmode=disable"
# Explicitly initialise the database
init-db:
dbmate drop || true
dbmate create
dbmate --migrations-dir backend/controller/sql/schema up
# Regenerate SQLC code (requires init-db to be run first)
build-sqlc:
@mk backend/controller/sql/{db.go,models.go,querier.go,queries.sql.go} : backend/controller/sql/queries.sql backend/controller/sql/schema sqlc.yaml -- "just init-db && sqlc generate"
# Build the ZIP files that are embedded in the FTL release binaries
build-zips: build-kt-runtime
@for dir in {{ZIP_DIRS}}; do (cd $dir && mk ../$(basename ${dir}).zip : . -- "rm -f $(basename ${dir}.zip) && zip -q --symlinks -r ../$(basename ${dir}).zip ."); done
# Rebuild frontend
build-frontend: npm-install
@mk {{FRONTEND_OUT}} : frontend/src -- "cd frontend && npm run build"
# Rebuild VSCode extension
build-extension: npm-install
@mk {{EXTENSION_OUT}} : extensions/vscode/src -- "cd extensions/vscode && npm run compile"
# Install development version of VSCode extension
install-extension: build-extension
@mk {{EXTENSION_OUT}} : extensions/vscode/src -- "cd extensions/vscode && npm run compile"
@cd extensions/vscode && vsce package && code --install-extension ftl-*.vsix
# Build and package the VSCode extension
package-extension: build-extension
@cd extensions/vscode && vsce package
# Publish the VSCode extension
publish-extension: package-extension
@cd extensions/vscode && vsce publish
# Kotlin runtime is temporarily disabled; these instructions create a dummy zip in place of the kotlin runtime jar for
# the runner.
build-kt-runtime:
@mkdir -p build/template/ftl && touch build/template/ftl/temp.txt
@cd build/template && zip -q --symlinks -r ../../{{RUNNER_TEMPLATE_ZIP}} .
# Install Node dependencies
npm-install:
@mk frontend/node_modules : frontend/package.json frontend/src -- "cd frontend && npm install"
@mk extensions/vscode/node_modules : extensions/vscode/package.json extensions/vscode/src -- "cd extensions/vscode && npm install"
# Regenerate protos
build-protos: npm-install
@mk {{SCHEMA_OUT}} : backend/schema -- "ftl-schema > {{SCHEMA_OUT}} && buf format -w && buf lint"
@mk {{PROTOS_OUT}} : {{PROTOS_IN}} -- "cd backend/protos && buf generate"
# Run integration test(s)
integration-tests *test:
#!/bin/bash
set -euo pipefail
testName=${1:-}
go test -fullpath -count 1 -v -tags integration -run "$testName" ./...
# Run README doc tests
test-readme *args:
mdcode run {{args}} README.md -- bash test.sh
# Run "go mod tidy" on all packages including tests
tidy:
find . -name go.mod -execdir go mod tidy \;
# Run backend tests
test-backend:
@gotestsum --hide-summary skipped --format-hide-empty-pkg -- -short -fullpath ./...
# Run frontend tests
test-frontend:
@cd frontend && npm run test
# Lint the frontend
lint-frontend: build-frontend
@cd frontend && npm run lint && tsc
# Lint the backend
lint-backend:
@golangci-lint run ./...