Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
174 lines (142 loc) · 6.33 KB
/
Copy pathMakefile
File metadata and controls
174 lines (142 loc) · 6.33 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
# Operator developer tasks.
#
# The three verbs stripe across every module: `make fmt` rewrites, `make
# fmt-check`, `make lint` and `make test` gate. `make check` runs all three
# gates and is the pre-PR bar. `make install-hooks` wires the committed pre-push
# hook, which runs the fast gate (root fmt-check + clippy, no tests).
.PHONY: check fmt fmt-check lint test clippy build run install-hooks bindings \
webcomponents storybook ui docs vscode-extension relay opr8r e2e \
fmt-rust fmt-ts fmt-tf fmt-check-rust fmt-check-ts fmt-check-tf \
lint-rust lint-ts lint-shell lint-helm lint-tf test-rust test-ts
# CI installs terraform; local dev machines may only have OpenTofu.
TF := $(shell command -v terraform >/dev/null 2>&1 && echo terraform || echo tofu)
# Full gate. The commands below are the same ones CI runs, so a clean local run
# means a clean CI run.
check: fmt-check lint test
# Rewrite formatting in every module. `fmt-check` is the same pass in report
# mode, and is what `check` and the pre-push hook run.
fmt: fmt-rust fmt-ts fmt-tf
fmt-check: fmt-check-rust fmt-check-ts fmt-check-tf
# crates/relay, opr8r and zed-extension have their own Cargo.lock and are not
# workspace members, so `--all` never reaches them.
fmt-rust:
cargo fmt --all
cd crates/relay && cargo fmt
cd opr8r && cargo fmt
cd zed-extension && cargo fmt
fmt-check-rust:
cargo fmt --all -- --check
cd crates/relay && cargo fmt -- --check
cd opr8r && cargo fmt -- --check
cd zed-extension && cargo fmt -- --check
# oxfmt is installed once at the repo root and covers every hand-written JS/TS
# subproject.
fmt-ts:
bun install --frozen-lockfile
bun run fmt
fmt-check-ts:
bun install --frozen-lockfile
bun run fmt:check
fmt-tf:
cd coder-module && $(TF) fmt
fmt-check-tf:
cd coder-module && $(TF) fmt -check -diff
lint: lint-rust lint-ts lint-shell lint-helm lint-tf
# Root workspace only: the fast gate the pre-push hook pairs with fmt-check.
clippy:
cargo clippy --locked --all-targets --all-features -- -D warnings
# zed-extension compiles to wasm, so its lints only resolve under that target.
lint-rust: clippy
cd crates/relay && cargo clippy --locked --all-targets --all-features -- -D warnings
cd opr8r && cargo clippy --locked --all-targets --all-features -- -D warnings
cd zed-extension && cargo clippy --locked --target wasm32-wasip1 -- -D warnings
# The type-aware lints resolve each subproject's node_modules and copy-types
# output, so install those first (`make ui`, `make vscode-extension`).
lint-ts:
bun run lint:ui
bun run lint:webcomponents
bun run lint:vscode
bun run lint:agnt
bun run lint:coder-module
cd e2e && bun install --frozen-lockfile
bun run lint:e2e
lint-shell:
shellcheck -S warning scripts/*.sh scripts/ci/*.sh
lint-helm:
helm lint charts/operator
# The rendered coder_script is what actually runs in a workspace, so a bash
# syntax error there is a broken module.
lint-tf:
cd coder-module && $(TF) init -input=false && $(TF) validate
scripts/ci/check-coder-module.sh
test: test-rust test-ts
test-rust:
cargo test --locked --all-features
cd crates/relay && cargo test --locked --all-features
cd opr8r && cargo test --locked --all-features
# Display-bound suites (vscode-extension, storybook) stay on their own targets.
test-ts:
bun install --frozen-lockfile
cd webcomponents && bun install --frozen-lockfile && bun run test
cd coder-module && bun test
bun test agnt-plugin
# Every gate for one module, for when only that module changed.
relay:
cd crates/relay && cargo fmt -- --check
cd crates/relay && cargo clippy --locked --all-targets --all-features -- -D warnings
cd crates/relay && cargo test --locked --all-features
opr8r:
cd opr8r && cargo fmt -- --check
cd opr8r && cargo clippy --locked --all-targets --all-features -- -D warnings
cd opr8r && cargo test --locked --all-features
# Playwright suites against a fresh Dockerfile.local image, run the way the Forgejo PR check runs them.
# The license suite skips unless OPERATOR_E2E_ISSUER_URL and OPERATOR_E2E_LICENSE_TOKEN are set.
e2e:
docker build --file Dockerfile.local --tag operator-e2e:local .
scripts/ci/e2e.sh operator-e2e:local
# Optimized release binary at target/release/operator.
build:
cargo build --release
# Run the TUI from source (development).
run:
cargo run
# TypeScript types generated from the Rust domain types. ts-rs writes bindings/
# as a side effect of the `export_bindings_*` tests it generates, so this is the
# first link in the chain: cargo -> bindings/ -> copy-types -> tsc/vite.
bindings:
cargo test --locked export_bindings_
# Shared frontend components. Built ahead of both consumers so the SPA and the
# docs site render collections from one implementation, and so neither needs a
# prebuilt artifact committed to the repo. Depends on `bindings` because the
# components are typed against the generated Rust types.
webcomponents: bindings
cd webcomponents && bun install --frozen-lockfile && bun run typecheck && bun test && bun run build
# Deterministic visual fixtures consumed locally by Storybook and later by Pixel.
storybook: webcomponents
cd webcomponents && bun run typecheck:stories
cd webcomponents && bun run storybook:build && bun run test:storybook
# The embedded SPA, which resolves @operator/webcomponents from its dist/.
ui: webcomponents
cd ui && bun install --frozen-lockfile && bun run build
# The VS Code extension. Mirrors the compile steps of the CI
# `test-vscode-extension` job; `compile:webview` type-checks the webview bundle,
# which no other target reaches. Depends on `bindings` because copy-types copies
# them into vscode-extension/src/generated.
vscode-extension: bindings
cd vscode-extension && npm ci
cd vscode-extension && npm run compile
cd vscode-extension && npm run compile:webview
cd vscode-extension && npm run lint
cd vscode-extension && npm run fmt:check
# Full docs pipeline: bindings, generated reference docs and the hosted
# collection bundle, the shared components bundle, then Jekyll. Mirrors the
# ordering in .github/workflows/docs.yml.
docs: webcomponents
cargo test --locked
cargo run --locked -- docs
mkdir -p docs/assets/js
cp webcomponents/dist/elements.js webcomponents/dist/elements.css docs/assets/js/
cd docs && bundle exec jekyll build
# The collection bundle is excluded from Jekyll (see docs/_config.yml) and
# copied in verbatim, so the bytes operator fetches match their checksums.
cp -R docs/collections docs/_site/