-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcheck.bash
More file actions
executable file
·100 lines (87 loc) · 4.27 KB
/
Copy pathcheck.bash
File metadata and controls
executable file
·100 lines (87 loc) · 4.27 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
#!/usr/bin/env bash
set -euo pipefail
RED='\033[0;31m'
GREEN='\033[0;32m'
BOLD='\033[1m'
RESET='\033[0m'
pass() { echo -e "${GREEN}✓${RESET} $1"; }
fail() { echo -e "${RED}✗${RESET} $1"; exit 1; }
step() { echo -e "\n${BOLD}▸ $1${RESET}"; }
step 'Prerequisites'
command -v git > /dev/null 2>&1 || fail 'Cannot find `git`'
command -v jj > /dev/null 2>&1 || fail 'Cannot find jujutsu `jj`. To install, run `cargo install --locked jj-cli --bin jj`'
command -v bwrap > /dev/null 2>&1 || command -v sandbox-exec > /dev/null 2>&1 || fail 'Cannot find bubblewrap `bwrap` or `sandbox-exec`'
pass 'All prerequisite executables found'
# Set all local crates to DEBUG, keeping any existing RUST_LOG.
export RUST_LOG="${RUST_LOG:-warn},$(cargo tree --workspace --depth 0 | grep -oE '^[a-z][a-z0-9_-]+' | sed 's/-/_/g' | sed 's/$/=debug/' | paste -sd, -)"
export RUST_BACKTRACE=1
step "Formatting"
# Suppress diff output so AI agents run `cargo fmt` instead of manually applying each diff.
cargo fmt --all --check > /dev/null 2>&1 || fail "formatting issues found (run 'cargo fmt --all' to fix)"
pass "All Rust code is formatted"
step "Docs formatting"
if [ -f docs/node_modules/.bin/prettier ]; then
(cd docs && npm run format:check) || fail "docs formatting issues found (run 'cd docs && npm run format' to fix)"
pass "All docs code is formatted"
else
echo " (skipped: docs node_modules not installed)"
fi
step "infinity-ui formatting"
if [ -f infinity-ui/node_modules/.bin/prettier ]; then
(cd infinity-ui && npm run format:check) || fail "infinity-ui formatting issues found (run 'cd infinity-ui && npm run format' to fix)"
pass "All infinity-ui code is formatted"
else
echo " (skipped: infinity-ui node_modules not installed)"
fi
step "Clippy (warnings denied)"
cargo clippy --all-targets -- -D warnings || fail "clippy warnings found"
pass "No clippy warnings"
step "Check"
cargo check --all-targets || fail "test targets failed to compile"
pass "Test targets compile"
step "Tests"
cargo test --all-targets || fail "tests failed"
pass "All tests passed"
step "Web UI e2e (Playwright)"
# Requires npm (the bundled-web build script runs vite) and the Playwright
# chromium build matching playwright-rs's bundled driver (1.60 → r1223):
# npx playwright@1.60.0 install chromium
#
# On hosts where the bundled driver is unusable — its download CDN has
# been known to 404, and its bundled node binary needs a newer glibc than
# some hosts have ("Server process exited immediately") — point
# playwright-rs at an npm-installed driver instead by exporting, before
# running this script:
# export PLAYWRIGHT_SKIP_DRIVER_DOWNLOAD=1 # don't bake in the bundled driver
# export PLAYWRIGHT_NODE_EXE="$(command -v node)"
# export PLAYWRIGHT_CLI_JS=/path/to/node_modules/playwright/cli.js # from `npm i playwright@1.60.0`
# (cargo forwards these to both the build script and the test binary.)
if command -v npm > /dev/null 2>&1 && ls "${HOME}/.cache/ms-playwright"/chromium*-1223 > /dev/null 2>&1; then
# npm needs a writable cache; fall back to a temp dir when ~/.npm isn't
# writable (e.g. sandboxed environments).
if ! [ -w "${HOME}/.npm" ]; then
export npm_config_cache="${npm_config_cache:-${TMPDIR:-/tmp}/npm-cache}"
fi
cargo clippy -p infinity-daemon --features e2e-web --all-targets -- -D warnings || fail "web e2e clippy warnings found"
cargo test -p infinity-daemon --features e2e-web --test web_e2e || fail "web e2e tests failed"
pass "Web UI e2e tests passed"
else
echo " (skipped: npm or Playwright 1.60 chromium not installed — run 'npx playwright@1.60.0 install chromium')"
fi
step "THIRD-PARTY file"
if command -v cargo-about > /dev/null 2>&1; then
EXPECTED="$(mktemp)"
cp THIRD-PARTY "$EXPECTED" 2>/dev/null || true
bash scripts/generate-third-party.sh > /dev/null 2>&1
if [ -f "$EXPECTED" ] && diff -q "$EXPECTED" THIRD-PARTY > /dev/null 2>&1; then
pass "THIRD-PARTY file is up to date"
elif [ ! -f "$EXPECTED" ] || [ ! -s "$EXPECTED" ]; then
pass "THIRD-PARTY file generated (commit it)"
else
fail "THIRD-PARTY file is stale (run 'bash scripts/generate-third-party.sh' and commit)"
fi
rm -f "$EXPECTED"
else
echo " (skipped: cargo-about not installed)"
fi
echo -e "\n${GREEN}${BOLD}All checks passed.${RESET}"