Repository navigation
Expand file tree
/
Copy pathTaskfile.yml
More file actions
237 lines (207 loc) · 9.22 KB
/
Copy pathTaskfile.yml
File metadata and controls
237 lines (207 loc) · 9.22 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
version: "3"
includes:
consumer-swift: .task/consumer-swift.yml
zig-diagnostics: .task/zig-diagnostics.yml
vars:
RUST_LOG: info
tasks:
setup:
desc: "Set up the development environment"
cmds:
- rustup update stable
- cargo install cargo-deny || true
- cargo install cargo-machete || true
- cargo install cargo-sort || true
- cargo install cargo-edit || true
- command -v poly >/dev/null 2>&1 || brew install goldziher/tap/poly
- task: governance:hooks:install
update:
desc: "Update dependencies"
cmds:
- cargo update
- gau --update .
upgrade:
desc: "Upgrade dependencies to latest (including incompatible) then update"
cmds:
- cargo upgrade --incompatible
- task: update
build:
desc: "Build all crates"
cmds:
- cargo build --workspace
build:release:
desc: "Build release binary"
cmds:
- cargo build --release -p alef
test:
desc: "Run all tests"
cmds:
# Derived from `cargo metadata`, not a hard-coded `target/`, so a custom `CARGO_TARGET_DIR`
# or `.cargo/config.toml` `build.target-dir` resets the same directory `test:census` (via
# `scripts/toolchain-census.sh`'s own default) reads back below.
- rm -rf "$(scripts/toolchain-census-dir.sh)"
- task: test:run
- task: test:census
test:run:
desc: "Run Rust tests with platform-specific test profile settings"
vars:
# Apple's compact-unwind offsets overflow for the unoptimized unit-test executable.
# Optimize only alef's test profile to shrink it while retaining panic unwinding. ~keep
TEST_CONFIG: '{{if eq OS "darwin"}}--config profile.test.package.alef.opt-level=1{{end}}'
cmds:
- cargo {{.TEST_CONFIG}} test --workspace {{.CLI_ARGS}}
gate:swift-callback-policy:
desc: "Compile and verify emitted Swift callback link policy"
cmds:
- task test:run -- --lib swift_callback_link_tests -- --ignored --test-threads=1
test:census:
desc: "Report how many toolchain-dependent fixtures the last test run actually executed"
cmds:
# No `--require` locally: a contributor without Go or Swift installed should see the ratio,
# not a failure. CI passes `--require` for the toolchains its runner installs, which is
# where a zero-execution run has to be fatal.
- ./scripts/toolchain-census.sh
test:release:
desc: "Run all tests in release mode (catches release-only optimizer/lifetime issues)"
cmds:
- cargo test --release --workspace
gate:generated-output:
desc: "Run the consumer toolchain gate (clippy, cargo sort, poly fmt) over an emitted tree"
cmds:
- cargo test --test generated_output_downstream_gate -- --nocapture
- cargo test --test generated_output_downstream_gate -- --ignored --nocapture --test-threads=1
gate:generated-output:text:
desc: "Generated-output gate, text lanes only (cargo sort + poly fmt + cargo manifest bytes; compiles nothing)"
cmds:
- cargo test --test generated_output_downstream_gate -- --ignored --nocapture --test-threads=1 cargo_sort
- cargo test --test generated_output_downstream_gate -- --ignored --nocapture --test-threads=1 poly_fmt
- cargo test --test generated_output_downstream_gate -- --ignored --nocapture --test-threads=1 cargo_manifest_byte
bench:
desc: "Run codegen benchmarks (criterion)"
cmds:
- cargo bench
check:
desc: "Type-check all crates"
cmds:
- cargo check --workspace
fmt:
desc: "Format all code via poly"
cmds:
- poly fmt --fix .
format:
desc: "Format all code via poly"
cmds:
- poly fmt --fix .
format:check:
desc: "Check formatting via poly (CI)"
cmds:
- poly fmt --check .
lint:
desc: "Run all linters via poly"
cmds:
- poly lint .
lint:check:
desc: "Run check-only linting via poly (CI)"
cmds:
- poly lint .
lint:file-size:
desc: "Enforce the 1,000-line file cap: over-cap files may shrink, never grow"
cmds:
- cargo test --test file_size_ratchet
lint:file-size:tighten:
desc: "Rewrite tests/file_size_baseline.txt from the working tree (run after splitting a file)"
cmds:
# `--ignored` is load-bearing while the ratchet's tests carry #[ignore]: without it
# this task reports `test result: ok. 0 passed; 4 ignored` and rewrites nothing, which is
# indistinguishable from a successful regeneration (alef#482).
- UPDATE_FILE_SIZE_BASELINE=1 cargo test --test file_size_ratchet -- --ignored --nocapture
gate:publish-verify:
desc: "Verify package Task arguments and archive guards with synthetic Cargo output"
cmds:
- python3 scripts/test_publish_verify.py
publish:verify:
desc: "Package and verify all three release crates without publishing"
env:
PUBLISH_VERSION: "{{.CLI_ARGS}}"
cmds:
- |
set -eu
manifest_version=$(awk -F '"' '/^version = / { print $2; exit }' Cargo.toml)
version="${PUBLISH_VERSION:-$manifest_version}"
case "$version" in
""|*[!0-9A-Za-z.+-]*) echo "Invalid release version" >&2; exit 1 ;;
esac
[ -f Cargo.toml ] && [ -f crates/alef-component-abi/Cargo.toml ] && [ -f crates/alef-component-runtime/Cargo.toml ]
[ "$version" = "$manifest_version" ]
target=$(mktemp -d "${TMPDIR:-/tmp}/alef-publish-verify.XXXXXX")
[ -n "$target" ] && [ -d "$target" ]
case "$target" in /*) ;; *) echo "Package target must be absolute" >&2; exit 1 ;; esac
echo "Verifying release packages in $target"
cargo package --workspace --locked --target-dir "$target" -j1
set -- "$target"/package/*.crate
[ "$#" -eq 3 ] || { echo "Expected 3 crate archives, found $#" >&2; exit 1; }
for crate in alef-component-abi alef-component-runtime alef; do
[ -s "$target/package/$crate-$version.crate" ] || { echo "Missing or empty archive for $crate" >&2; exit 1; }
done
echo "Verified 3 nonempty release crate archives for $version"
set-version:
desc: "Set package version (usage: task set-version -- 0.18.0 or 0.18.0-rc.1)"
requires:
vars: [CLI_ARGS]
cmds:
- |
version="{{.CLI_ARGS}}"
version="${version#v}"
if ! printf '%s\n' "$version" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z._-]+)?$'; then
echo "set-version: expected semver like '0.18.0' or '0.18.0-rc.1' (with or without leading 'v'); got '{{.CLI_ARGS}}'" >&2
exit 2
fi
sed -i.bak "s/^version = \".*\"/version = \"$version\"/" Cargo.toml
rm -f Cargo.toml.bak
# The two component crates ship in lockstep with the root `alef` crate (one
# release, one `cargo publish` per crate, all at the same version) — see
# tests/component_crate_versions_test.rs. Their own `[package] version` and the
# dependency pins that reference them all move together here.
sed -i.bak "s/^version = \".*\"/version = \"$version\"/" crates/alef-component-abi/Cargo.toml
rm -f crates/alef-component-abi/Cargo.toml.bak
sed -i.bak "s/^version = \".*\"/version = \"$version\"/" crates/alef-component-runtime/Cargo.toml
rm -f crates/alef-component-runtime/Cargo.toml.bak
sed -i.bak -E "s#(alef-component-abi = \{ path = \"[^\"]*\", version = \")[^\"]*(\" \})#\1$version\2#" crates/alef-component-runtime/Cargo.toml
rm -f crates/alef-component-runtime/Cargo.toml.bak
sed -i.bak -E "s#(alef-component-(abi|runtime) = \{ path = \"[^\"]*\", version = \")[^\"]*(\" \})#\1$version\3#" Cargo.toml
rm -f Cargo.toml.bak
sed -i.bak "s/^alef_version = \".*\"/alef_version = \"$version\"/" alef.toml
rm -f alef.toml.bak
sed -i.bak -E "s|pub const ALEF_REV: &str = \"v?[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z._-]+)?\";|pub const ALEF_REV: \&str = \"v$version\";|" src/core/template_versions.rs
rm -f src/core/template_versions.rs.bak
CARGO_TARGET_DIR=target/schema-task cargo run --quiet -- schema --schema-version "$version" --output schemas/alef.schema.json
- cargo update
clean:
desc: "Clean build artifacts"
cmds:
- cargo clean
- rm -rf .alef/
governance:hooks:install:
desc: Provision machine preferences and install reviewed AI governance hooks
cmds:
- |
python3 - <<'PYTHON'
import pathlib
import shutil
import subprocess
import tomllib
if shutil.which("ai-rulez") is None:
raise SystemExit("Install the reviewed ai-rulez CLI before installing hooks")
preferences = pathlib.Path("poly.local.toml")
text = preferences.read_text() if preferences.exists() else ""
data = tomllib.loads(text)
if "hook_preferences" not in data:
preferences.write_text(text.rstrip() + '\n\n[hook_preferences]\nchannels = ["system"]\n')
elif "system" not in data["hook_preferences"].get("channels", []):
raise SystemExit("Add system to hook_preferences.channels in poly.local.toml")
subprocess.run(["poly", "hooks", "install"], check=True)
PYTHON
governance:check:
desc: Check materialized local governance outputs against shared sources
cmds:
- ai-rulez generate --check --no-local --strict-config