-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjustfile
More file actions
210 lines (164 loc) · 6.56 KB
/
justfile
File metadata and controls
210 lines (164 loc) · 6.56 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
ld_flags := "-X 'github.com/maxthom/mir/internal/libs/build_meta.Version=$(git branch --show-current)-$(git rev-parse --short HEAD)' -X 'github.com/maxthom/mir/internal/libs/build_meta.User=$(id -u -n)' -X 'github.com/maxthom/mir/internal/libs/build_meta.Time=$(date -u)'"
# Display recipes
default:
just -l --unsorted
# Build all
build: build-cockpit
go build -ldflags="{{ ld_flags }}" -o bin/mir cmds/mir/main.go
go build -ldflags="{{ ld_flags }}" -o bin/core cmds/core/main.go
go build -ldflags="{{ ld_flags }}" -o bin/prototlm cmds/prototlm/main.go
go build -ldflags="{{ ld_flags }}" -o bin/protocmd cmds/protocmd/main.go
go build -ldflags="{{ ld_flags }}" -o bin/eventstore cmds/eventstore/main.go
go build -ldflags="{{ ld_flags }}" -o bin/eventstore cmds/cockpit/main.go
# Build Mir binary
build-mir: build-cockpit
go build -ldflags="{{ ld_flags }}" -o bin/mir cmds/mir/main.go
# Build a stripped Mir binary
build-mir-tiny: build-cockpit
go build -ldflags="{{ ld_flags }} -s -w" -trimpath -o bin/mir cmds/mir/main.go
# Build cockpit web UI (Svelte)
build-cockpit: build-ts-sdk
npm run build --prefix ./internal/ui/web
# Build cockpit Go server binary
build-cockpit-server: build-cockpit
go build -ldflags="{{ ld_flags }}" -o bin/cockpit ./cmds/cockpit
# Build TypeScript SDK
build-ts-sdk:
npm run build --prefix ./pkgs/web
# NPM install cockpit and ts sdk
install-cockpit:
npm install --prefix ./pkgs/web
npm install --prefix ./internal/ui/web
# Run core module using Air
run-core:
air -c .air/core.toml
# Run telemetry module using Air
run-prototlm:
air -c .air/prototlm.toml
# Run command module using Air
run-protocmd:
air -c .air/protocmd.toml
# Run cockpit web UI in dev mode (Svelte dev server)
run-cockpit:
npm run dev --prefix ./internal/ui/web
# Run cockpit Go server with Air for hot-reload
run-cockpit-server:
air -c .air/cockpit.toml
# See list of direct dependencies
dep-list:
go list -u -m -f '{{{{if not .Indirect}}{{{{.}}{{{{end}}' all
# Update all dependencies
dep-update:
go get -u ./...
# Test with coverage
test count="0":
mkdir -p ./.tmp
go test -count {{ count }} -coverprofile ./.tmp/coverage.out ./...
go tool cover -html ./.tmp/coverage.out
# Start test infra
test-infra:
./scripts/integration_tests.sh
# Install Mir to path
install: build-mir-tiny
sudo cp bin/mir /usr/local/bin/mir
# Compile Mir to ARCH (amd64|arm64|arm32), OS (linux|windows) and SCP to host (<usr>:<ip>)
install-scp host arch="arm64" os="linux":
GOOS={{ os }} GOARCH={{ arch }} go build -ldflags="-s -w {{ ld_flags }}" -trimpath -o bin/mir_{{ os }}_{{ arch }} cmds/mir/main.go
scp bin/mir_{{ os }}_{{ arch }} {{ host }}:mir_{{ os }}_{{ arch }}
ssh {{ host }} "sudo cp mir_{{ os }}_{{ arch }} /usr/local/bin/mir && rm mir_{{ os }}_{{ arch }}"
rm bin/mir_{{ os }}_{{ arch }}
# Start tmux layouts for local dev
tx:
tmuxifier s ./.tmux/mir.session.sh
# Start tmux layouts with mir in docker and serve using CLI
tx-serve:
tmuxifier s ./.tmux/mir-serve.session.sh
# Start tmux layouts with mir in docker
tx-full:
tmuxifier s ./.tmux/mir-full.session.sh
# Start tmux layouts with local test setup
tx-test:
tmuxifier s ./.tmux/mir-test.session.sh
# Run supporting infra with docker
infra:
docker compose -f infra/compose/local_support/compose.yaml up --force-recreate
infra-down:
docker compose -f infra/compose/local_support/compose.yaml down
# Run mir and supporting infra with docker
local:
docker compose -f infra/compose/local_mir_support/compose.yaml up --force-recreate
local-down:
docker compose -f infra/compose/local_mir_support/compose.yaml down
docker-kill:
docker stop "$(docker ps -a -q)"
docker rm "$(docker ps -a -q)"
docker ps --all
# Build docker image
docker-build tag="latest" platform="linux/amd64" version="0.0.0" user="$(id -u -n)" time="$(date -u)":
docker build -t ghcr.io/maxthom/mir:{{ tag }} --build-arg BUILDPLATFORM={{ platform }} --build-arg VERSION={{ version }} --build-arg USER="{{ user }}" --build-arg TIME="{{ time }}" .
# Run docker Mir
docker-run entry="serve":
docker run --network host ghcr.io/maxthom/mir:latest {{ entry }}
# Run docker Mir with a config file
docker-run-config entry="serve":
docker run -v $(pwd)/infra/compose/mir/local-config.yaml:/home/mir/.config/mir/mir.yaml --network host ghcr.io/maxthom/mir:latest {{ entry }}
# Run docker Mir and enter the container
docker-run-exec:
docker run -v $(pwd)/infra/compose/mir/local-config.yaml:/home/mir/.config/mir/mir.yaml --network host -it --entrypoint /bin/sh ghcr.io/maxthom/mir:latest
# Start k3d cluster for local k8s dev
k3d-create:
k3d cluster create mir-local-dev -c infra/k8s/k3d/scratch/k3d_config.yaml
# Delete k3d cluster
k3d-delete:
k3d cluster delete mir-local-dev
# Recreate k3d cluster
k3d-recreate: k3d-delete k3d-create
# Deploy mir
k3d-mir instance="local":
cd infra/k8s/charts/mir && helm install {{ instance }} . -f values-local-k3d.yaml
# Run Mir book for local documentation
book:
cd book && mdbook serve -p 5001
# Follow logs written to file from Tui
log:
tail ~/.config/mir/cli.log -f
# Seed the database with test data
seed:
./scripts/seed.sh
# Clean the database
cleandb:
./scripts/clean_db.sh
# Install development tools
tooling:
./scripts/tooling.sh
# Run protogen for all protobuf generation
protogen:
./scripts/protogen.sh
# Run the certificate manager script
certs *args:
./scripts/generate_certs.sh {{ args }}
# Go code line count
line-count:
@echo "=== Go Code ==="
@echo -n "All Go files: "
@find . -name '*.go' | xargs -I {} cat {} | wc -l
@echo -n "Go files (excluding generated): "
@find . -name '*.go' ! -name '*.pb.go' | xargs -I {} cat {} | wc -l
@echo ""
@echo "=== Svelte App (Cockpit) ==="
@echo -n "Svelte: "
@find ./internal/ui/web/src -name '*.svelte' 2>/dev/null | xargs -I {} cat {} 2>/dev/null | wc -l || echo "0"
@echo -n "TypeScript/JavaScript: "
@find ./internal/ui/web/src -name '*.ts' -o -name '*.js' 2>/dev/null | grep -v node_modules | xargs -I {} cat {} 2>/dev/null | wc -l || echo "0"
@echo -n "CSS: "
@find ./internal/ui/web/src -name '*.css' 2>/dev/null | xargs -I {} cat {} 2>/dev/null | wc -l || echo "0"
@echo -n "HTML: "
@find ./internal/ui/web/src -name '*.html' 2>/dev/null | xargs -I {} cat {} 2>/dev/null | wc -l || echo "0"
# Go test count
test-count:
find . -name '*_test.go' -exec grep -E '^func Test' {} \; | wc -l
# NSC Clean
nsc-clean:
rm -rf ~/.nsc
rm -rf ~/.local/share/nats/nsc
rm -rf ~/.config/nats/nsc