Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
299 lines (249 loc) · 14.1 KB
/
Copy pathMakefile
File metadata and controls
299 lines (249 loc) · 14.1 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
.PHONY: contracts-generate contracts-verify computer-release-local source-archive source-dependencies
.PHONY: check-teamhub-cli check-installer check-desktop
.PHONY: check check-planned check-heavy-lane check-web check-web-static check-web-tests
.PHONY: check-computer check-computer-go check-computer-release check-node-services check-voice-runtime
.PHONY: check-teamhub check-teamhub-tooling check-teamhub-integration
.PHONY: check-teamhub-integration-process check-teamhub-integration-migrations
.PHONY: check-contracts check-packages check-scripts check-scripts-fast check-scripts-heavy check-docs check-repository check-repository-gate
.PHONY: check-web-build check-node-services-build check-build check-voice-runtime-build
.PHONY: check-release-cache-core check-release-cache
.PHONY: check-container-web check-container-node-services check-container-other check-containers
.PHONY: check-e2e-room-document check-e2e check-all
OAPI_CODEGEN_VERSION := v2.7.1
OAPI_CODEGEN_COMMAND ?= go run github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen@$(OAPI_CODEGEN_VERSION)
BASE ?=
SCRIPT_TEST_FILTER ?= %
SCRIPT_PROCESS_TEST_FILTER ?= $(SCRIPT_TEST_FILTER)
SCRIPT_INSTALLER_TEST := scripts/local-computer-installer.test.ts
SCRIPT_COMPUTER_RELEASE_TEST := scripts/prepare-local-computer-release.test.ts
COMPUTER_TEST_RUNNER := bash "$(CURDIR)/apps/computer/run-test.sh"
# Reviewed readers/private mkdtemp fixtures, no shared ports or process state.
SCRIPT_ISOLATED_PROCESS_TESTS := scripts/local-runner-smoke-entrypoints.test.ts
# New scripts/ci tests join the process group and must use private temp dirs
# and listen(0) ports.
SCRIPT_FAST_PROCESS_TESTS := $(filter-out $(SCRIPT_ISOLATED_PROCESS_TESTS),$(wildcard scripts/ci/*.test.ts)) \
scripts/managed-tools-install.test.ts \
scripts/managed-tools-runtime.test.ts \
scripts/local-env.test.ts \
scripts/computer-test-isolation.test.ts \
scripts/check-web.test.ts \
scripts/development-workflow.test.ts
SCRIPT_HEAVY_OTHER_TESTS := \
scripts/local-computer-windows-installer.test.ts \
scripts/local-computer-windows-native.test.ts \
$(SCRIPT_COMPUTER_RELEASE_TEST)
SCRIPT_HEAVY_TESTS := $(SCRIPT_INSTALLER_TEST) $(SCRIPT_HEAVY_OTHER_TESTS)
SCRIPT_FAST_PARALLEL_TESTS := $(filter-out $(SCRIPT_HEAVY_TESTS) $(SCRIPT_FAST_PROCESS_TESTS) $(SCRIPT_ISOLATED_PROCESS_TESTS),$(wildcard scripts/*.test.ts))
# Fast files that spawn child processes get the process timeout budget; the rest keep the 5s default.
# Guarded because a bare grep reads stdin when a foreign-root make finds no test files.
SCRIPT_FAST_SPAWN_TESTS = $(if $(SCRIPT_FAST_PARALLEL_TESTS),$(shell grep -l child_process $(SCRIPT_FAST_PARALLEL_TESTS) 2>/dev/null))
SCRIPT_FAST_PURE_TESTS = $(filter-out $(SCRIPT_FAST_SPAWN_TESTS),$(SCRIPT_FAST_PARALLEL_TESTS))
# Every fast check. Integration, build, container, E2E and the heavy script
# tests stay separate targets. `make check` runs only the checks that
# scripts/check-plan.mjs selects for the changes since merge-base(BASE, HEAD),
# including uncommitted and untracked files; ALL=1 runs every check. CI's
# changes job reads the same plan. The light checks run CHECK_JOBS at a time
# beside one lane that runs the heavy test suites one after another: their
# timed tests fail when they share the CPU. BASE reaches the built-in Skill
# immutability check inside check-teamhub.
FAST_CHECKS := check-repository check-docs check-contracts check-packages \
check-voice-runtime check-teamhub-cli check-installer check-desktop \
check-teamhub check-teamhub-tooling check-scripts-fast
HEAVY_CHECKS := check-web check-node-services check-computer
CHECK_JOBS ?= 4
# The planned targets; `make check` sets them for its sub-make.
CHECK_TARGETS ?= $(FAST_CHECKS) $(HEAVY_CHECKS)
CHECK_PLAN = node scripts/check-plan.mjs $(if $(ALL),--all,--base '$(BASE)')
# GNU Make 3.81 (macOS) has no --output-sync.
OUTPUT_SYNC := $(if $(filter 3.%,$(MAKE_VERSION)),,--output-sync=target)
check:
@test -n "$(strip $(BASE))" || { echo "Usage: make check BASE=<target-ref> [ALL=1]" >&2; exit 2; }
@$(CHECK_PLAN)
@targets="$$($(CHECK_PLAN) --format make)" && test -n "$$targets" || { echo "check-plan selected no checks" >&2; exit 1; }; \
$(MAKE) -j$(CHECK_JOBS) $(OUTPUT_SYNC) CHECK_TARGETS="$$targets" check-planned
check-planned: $(filter $(CHECK_TARGETS),$(FAST_CHECKS)) check-heavy-lane
check-heavy-lane:
$(if $(filter $(CHECK_TARGETS),$(HEAVY_CHECKS)),$(MAKE) -j1 $(filter $(CHECK_TARGETS),$(HEAVY_CHECKS)))
# With a BASE, formats and lints only the changed files unless ALL=1 or the
# plan selects every check; without one, the whole repository.
check-repository:
pnpm env:inventory:check
@if [ -z "$(strip $(BASE))" ] || [ "$$($(CHECK_PLAN) --format scope)" = all ]; then \
echo "pnpm format:check && pnpm lint"; pnpm format:check && pnpm lint; \
else \
echo "scripts/ci/check-changed-files.sh (changes since $(BASE))"; \
bash scripts/ci/check-changed-files.sh "$$(git merge-base '$(BASE)^{commit}' HEAD)" --worktree; \
fi
# React Doctor compares against BASE. Without one it scans the whole repository,
# which exceeds its lint budget on CI runners and fails. A push that creates a
# branch reports the all-zero commit, which is not a ref.
DOCTOR_BASE = $(if $(filter-out 0000000000000000000000000000000000000000,$(BASE)),--base '$(BASE)')
WEB_TYPES = pnpm --filter @linger/web typecheck
WEB_LINT = pnpm --filter @linger/web lint
WEB_TESTS = pnpm --filter @linger/web test
WEB_DOCTOR = pnpm react:doctor $(DOCTOR_BASE)
check-web:
pnpm exec concurrently --success all --names types,lint,tests,doctor \
"$(WEB_TYPES)" \
"$(WEB_LINT)" \
"$(WEB_TESTS)" \
"$(WEB_DOCTOR)"
# CI runs these as separate jobs (tests in shards, e.g. SHARD=2/2);
# check-web stays the local entry point.
check-web-static:
pnpm exec concurrently --success all --names types,lint,doctor \
"$(WEB_TYPES)" \
"$(WEB_LINT)" \
"$(WEB_DOCTOR)"
check-web-tests:
$(WEB_TESTS)$(if $(SHARD), --shard=$(SHARD))
check-node-services:
pnpm --filter @linger/node-services check
check-computer:
pnpm --filter @linger/computer typecheck
pnpm --filter @linger/computer lint
$(COMPUTER_TEST_RUNNER) pnpm --filter @linger/computer test
$(MAKE) -C apps/teamhub lint-go-daemon
$(MAKE) check-computer-go
LINGER_GO_LOCAL_DAEMON_TEST=1 $(COMPUTER_TEST_RUNNER) pnpm --filter @linger/node-services exec vitest run --project agent tests/agent/runner-gateway/go-local-daemon-process.test.ts --maxWorkers=2
check-teamhub-cli:
pnpm --filter @linger/teamhub-cli typecheck
pnpm --filter @linger/teamhub-cli lint
pnpm --filter @linger/teamhub-cli test
pnpm --filter @linger/teamhub-cli build
# check-packages covers @linger/local-installation.
check-installer:
pnpm --filter @linger/linger-installer typecheck
pnpm --filter @linger/linger-installer lint
pnpm --filter @linger/linger-installer test
check-desktop:
pnpm --filter @linger/desktop typecheck
pnpm --filter @linger/desktop lint
pnpm --filter @linger/desktop test
python3 -m unittest discover -s apps/desktop/packaging -p '*_test.py'
# The Go daemon that packaging bundles, for every platform the app ships on.
cd apps/desktop && node scripts/build-daemon.mjs --all
# The Go unit tests of check-computer, which CI runs on its own.
check-computer-go:
cd apps/computer/local-daemon && go test ./... -run '^$$'
cd apps/computer/local-daemon && $(COMPUTER_TEST_RUNNER) go test ./internal/platform/...
cd apps/computer/local-daemon && $(COMPUTER_TEST_RUNNER) go test ./cmd/linger-computer-daemon ./cmd/linger-computer-launcher ./internal/computercli ./internal/computerconfig ./internal/daemon ./internal/linger/context ./internal/linger/assignment ./internal/linger/control ./internal/linger/registration ./internal/linger/localskills ./internal/linger/mcpproxy ./internal/linger/transport ./internal/linger/runtimehistory ./internal/linger/localtools ./internal/process ./internal/workspace ./internal/provider ./internal/provider/redact ./internal/permission ./internal/localmodels
cd apps/computer/local-daemon && $(COMPUTER_TEST_RUNNER) go test ./internal/provider/native ./internal/uiruntime
check-computer-release:
pnpm vitest run --no-file-parallelism $(SCRIPT_COMPUTER_RELEASE_TEST)
check-voice-runtime:
pnpm --filter @linger/voice-runtime check
check-teamhub:
$(MAKE) -C apps/teamhub check-code sqlc-verify
check-teamhub-tooling:
$(MAKE) -C apps/teamhub test-scripts
check-teamhub-integration:
$(MAKE) -C apps/teamhub test-integration
check-teamhub-integration-process:
$(MAKE) -C apps/teamhub test-integration-process
check-teamhub-integration-migrations:
$(MAKE) -C apps/teamhub test-integration-migrations
check-contracts:
$(MAKE) contracts-verify
pnpm --filter @linger/wire-contracts typecheck
pnpm exec vitest run --config contracts/vitest.config.ts --no-file-parallelism
cd contracts/generated/go && go test ./...
check-packages:
pnpm --filter './packages/*' exec node -e 'const p = require("./package.json"); for (const gate of ["typecheck", "lint", "test"]) { if (!p.scripts?.[gate]) { console.error(`Package $${p.name ?? process.cwd()} must define scripts.$${gate}`); process.exitCode = 1; } }'
pnpm --filter './packages/*' typecheck
pnpm --filter './packages/*' lint
pnpm --workspace-concurrency=1 --filter './packages/*' test
check-scripts:
$(MAKE) check-scripts-fast
$(MAKE) check-scripts-heavy
check-scripts-fast:
ifneq ($(strip $(filter $(SCRIPT_TEST_FILTER),$(SCRIPT_FAST_PURE_TESTS))),)
pnpm vitest run --maxWorkers="$${SCRIPT_TEST_FAST_WORKERS:-4}" $(filter $(SCRIPT_TEST_FILTER),$(SCRIPT_FAST_PURE_TESTS))
endif
ifneq ($(strip $(filter $(SCRIPT_TEST_FILTER),$(SCRIPT_FAST_SPAWN_TESTS))),)
pnpm vitest run --maxWorkers="$${SCRIPT_TEST_FAST_WORKERS:-4}" --testTimeout="$${SCRIPT_TEST_PROCESS_TIMEOUT_MS:-30000}" $(filter $(SCRIPT_TEST_FILTER),$(SCRIPT_FAST_SPAWN_TESTS))
endif
ifneq ($(strip $(filter $(SCRIPT_PROCESS_TEST_FILTER),$(SCRIPT_ISOLATED_PROCESS_TESTS))),)
pnpm vitest run --maxWorkers="$${SCRIPT_TEST_ISOLATED_WORKERS:-2}" --testTimeout="$${SCRIPT_TEST_PROCESS_TIMEOUT_MS:-30000}" $(filter $(SCRIPT_PROCESS_TEST_FILTER),$(SCRIPT_ISOLATED_PROCESS_TESTS))
endif
ifneq ($(strip $(filter $(SCRIPT_PROCESS_TEST_FILTER),$(SCRIPT_FAST_PROCESS_TESTS))),)
pnpm vitest run --maxWorkers="$${SCRIPT_TEST_PROCESS_WORKERS:-1}" --testTimeout="$${SCRIPT_TEST_PROCESS_TIMEOUT_MS:-30000}" $(filter $(SCRIPT_PROCESS_TEST_FILTER),$(SCRIPT_FAST_PROCESS_TESTS))
endif
check-scripts-heavy:
pnpm vitest run --no-file-parallelism --maxConcurrency="$${SCRIPT_TEST_INSTALLER_CONCURRENCY:-2}" $(SCRIPT_INSTALLER_TEST)
pnpm vitest run --maxWorkers="$${SCRIPT_TEST_HEAVY_WORKERS:-2}" $(SCRIPT_HEAVY_OTHER_TESTS)
check-docs:
node scripts/check-doc-links.mjs
check-repository-gate:
@test -n "$(strip $(BASE))" || { echo "Usage: make check-repository-gate BASE=<target-ref>" >&2; exit 2; }
BASE="$(BASE)" scripts/ci/check-repository-gate.sh
check-web-build:
pnpm --filter @linger/web test:build
pnpm --filter @linger/web run build:assets
check-node-services-build:
pnpm --filter @linger/node-services build
check-voice-runtime-build:
pnpm --filter @linger/voice-runtime build
check-build:
pnpm build
check-release-cache-core:
pnpm release-lockfiles:check
pnpm exec vitest run --testTimeout="$${SCRIPT_TEST_PROCESS_TIMEOUT_MS:-15000}" scripts/release-lockfiles.test.ts scripts/local-computer-node-distributions.test.ts scripts/prepare-local-computer-release.test.ts scripts/development-workflow.test.ts
check-release-cache: check-release-cache-core check-container-web check-container-node-services
check-container-web:
docker buildx build --check -f apps/web/Dockerfile .
check-container-node-services:
docker buildx build --check -f apps/node-services/Dockerfile .
check-container-other:
docker buildx build --check -f apps/teamhub/Dockerfile .
LOCAL_ENV_FILE=.env.example docker compose config --quiet
docker compose -f apps/teamhub/deployments/compose/docker-compose.yml config --quiet
TEAMHUB_TEST_CONTAINER_NAME=teamhub-test-config-postgres \
TEAMHUB_TEST_NETWORK_NAME=teamhub-test-config-network \
TEAMHUB_TEST_RUN_TOKEN=teamhub-test-config \
docker compose -f apps/teamhub/deployments/compose/docker-compose.test.yml config --quiet
check-containers: check-container-web check-container-node-services check-container-other
check-e2e-room-document:
@if [ -z "$${ROOM_DOCUMENT_E2E_SHARD:-}" ] || [ "$${ROOM_DOCUMENT_E2E_SHARD%%/*}" = "1" ]; then \
pnpm test:e2e:config; \
fi
pnpm test:e2e:room-document
check-e2e:
pnpm test:e2e:config
pnpm test:e2e:room-document
check-all:
pnpm format:check
pnpm typecheck
pnpm lint
pnpm react:doctor
pnpm build
pnpm test
$(MAKE) -C apps/teamhub check
$(MAKE) check-docs
$(MAKE) check-teamhub-integration
$(MAKE) check-containers
pnpm test:e2e
# The host's Computer release for `pnpm dev`, served by the Agent Service on
# /install/. COMPUTER_RELEASE_TARGETS selects other targets.
computer-release-local:
COMPUTER_RELEASE_TARGETS="$${COMPUTER_RELEASE_TARGETS:-$$(node -p 'process.platform + "-" + process.arch')}" \
node scripts/prepare-local-computer-release.mjs --output .linger-runtime/computer-release
# The linger source package that desktop builds download for "Run on This
# Computer". SOURCE_ARCHIVE_REF picks the tag; SOURCE_ARCHIVE_URL_BASE is where
# the release hosts it, recorded in source-archive.json for the desktop build.
source-archive:
node scripts/prepare-source-archive.mjs --ref "$${SOURCE_ARCHIVE_REF:-HEAD}" \
$${SOURCE_ARCHIVE_URL_BASE:+--url-base "$$SOURCE_ARCHIVE_URL_BASE"}
# The dependency store published beside that package for one platform, so
# the desktop installs its packages without a registry. Build it on the
# platform it serves (SOURCE_DEPENDENCIES_TARGET, the host by default) to
# include compiled native modules; source-dependencies-<target>.json records
# it for that platform's desktop build.
source-dependencies:
node scripts/prepare-source-dependencies.mjs --ref "$${SOURCE_ARCHIVE_REF:-HEAD}" \
$${SOURCE_DEPENDENCIES_TARGET:+--target "$$SOURCE_DEPENDENCIES_TARGET"} \
$${SOURCE_ARCHIVE_URL_BASE:+--url-base "$$SOURCE_ARCHIVE_URL_BASE"}
contracts-generate:
OAPI_CODEGEN_COMMAND='$(OAPI_CODEGEN_COMMAND)' pnpm exec tsx contracts/codegen/contracts.ts generate
contracts-verify:
OAPI_CODEGEN_COMMAND='$(OAPI_CODEGEN_COMMAND)' pnpm exec tsx contracts/codegen/contracts.ts verify