Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,10 @@ jobs:
- run: typos
- run: oxlint --deny-warnings .
- run: scripts/ci/shellcheck.sh
# Source files' length (caps for the long ones in scripts/ci/file_lengths.txt), and every lint suppression
# listed with its reason (scripts/ci/suppressions.txt).
- run: scripts/ci/check_file_length.py
- run: scripts/ci/check_suppressions.py
# The renderer's two warnings (a `cd` and a pipe in the PDFBox download step) wait for its next rebuild: any edit
# to renderer.Dockerfile rebuilds the renderer image (its inputs hash), so it isn't touched for lint alone.
- run: hadolint docker/app.Dockerfile && hadolint --ignore DL3003 --ignore DL4006 docker/renderer.Dockerfile
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ target/
frontend/dist
frontend/dist-site
.dev-host

# Python bytecode (scripts/ci)
__pycache__/
8 changes: 7 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,13 @@ design is in `docs/design.md`; read it before changing the architecture, and upd
2026, sc-9611), so a commit made without the hooks lands unformatted: never commit with `--no-verify`.
- **Workflows, secrets, spelling, JS/TS and shell scripts are checked** by CI's `security` job and the pre-commit
hook: actionlint, zizmor, Betterleaks, typos (`_typos.toml`), oxlint (`.oxlintrc.json`) and ShellCheck
(`scripts/ci/shellcheck.sh`); mise.toml pins them. Allow a word or turn a lint rule off for a file only in those
(`scripts/ci/shellcheck.sh`); mise.toml pins them.
- **Source files stay under 500 lines** (1,000 for tests and migrations; `scripts/ci/check_file_length.py`). The files
that were already longer have their own caps in `scripts/ci/file_lengths.txt`: split one rather than grow it past its
cap, never raise a cap, and delete its line once it's under the limit. **Every lint suppression** (`#[allow(...)]`,
`@ts-expect-error`, `# noqa`, a zizmor ignore and the rest) is listed in `scripts/ci/suppressions.txt` with its
reason, added in the change that adds it (`scripts/ci/check_suppressions.py`). Fix what a lint finds before you
reach for a suppression. Allow a word or turn a lint rule off for a file only in those
files, with the reason beside it. Pin every action by commit SHA with its version in a comment (`pinact run` does
it). Ignore a zizmor finding only inline (`# zizmor: ignore[audit]`) with the reason beside it; allow a made-up
value in `.betterleaks.toml` only with a description of what it is. A real secret that reached a commit is revoked,
Expand Down
6 changes: 6 additions & 0 deletions lefthook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ pre-commit:
shellcheck:
glob: "{*.sh,scripts/*,scripts/**/*,**/bin/*}"
run: scripts/ci/shellcheck.sh {staged_files}
# Source files stay under 500 lines (1,000 for tests and migrations; scripts/ci/file_lengths.txt caps the older long
# ones), and every lint suppression is listed with its reason (scripts/ci/suppressions.txt).
file-length:
run: scripts/ci/check_file_length.py {staged_files}
suppressions:
run: scripts/ci/check_suppressions.py
# The workflows and actions: actionlint (with shellcheck on their scripts) and zizmor (.github/zizmor.yml).
actionlint:
glob: ".github/workflows/*.{yml,yaml}"
Expand Down
Binary file not shown.
Binary file not shown.
63 changes: 63 additions & 0 deletions scripts/ci/check_file_length.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/usr/bin/env python3
"""Source files stay short enough to read whole (sc-9611): at most 500 lines, 1,000 for tests and migrations.

Files that were already longer when this check arrived are listed in scripts/ci/file_lengths.txt, each with its own cap
(its length then, rounded up to the next hundred, so branches open at the time still fit). Such a file can't grow past
its cap: split it instead. When one is split below the limit, delete its line (a line for a file that no longer needs
it fails the check). Never raise a cap to make room.

scripts/ci/check_file_length.py [<file>...] (no files: every tracked one)
"""

import os
import re
import subprocess
import sys

CODE = re.compile(r"\.(rs|ts|tsx|js|mjs|cjs|jsx|py|rb|sh|astro|vue|svelte|css|scss)$")
LONGER = re.compile(r"(^|/)(tests?|spec|e2e)/|[._-](test|spec)\.[a-z]+$|_test\.[a-z]+$|(^|/)test_[^/]+\.py$|^app/database/migrations/")
LIMIT, LONGER_LIMIT = 500, 1000
CAPS = "scripts/ci/file_lengths.txt"


def limit(path):
return LONGER_LIMIT if LONGER.search(path) else LIMIT


def main(args):
os.chdir(subprocess.check_output(["git", "rev-parse", "--show-toplevel"], text=True).strip())
caps = {}
for line in open(CAPS):
line = line.split("#", 1)[0].strip()
if line:
path, cap = line.rsplit(None, 1)
caps[path] = int(cap)
tracked = subprocess.check_output(["git", "ls-files", "-z"], text=True).split("\0")
paths = args or tracked
failed = []
checked = 0
for path in paths:
if not CODE.search(path) or not os.path.isfile(path):
continue
checked += 1
with open(path, "rb") as f:
lines = f.read().count(b"\n")
cap = max(limit(path), caps.get(path, 0))
if lines > cap:
how = f"its cap in {CAPS}" if path in caps else "the limit"
hint = "" if path in caps else f" (A capped file you renamed: move its line in {CAPS} to the new path.)"
failed.append(f"{path}: {lines} lines, over {how} ({cap}). Split it (never raise the cap).{hint}")
elif path in caps and lines <= limit(path):
failed.append(f"{path}: {lines} lines, within the limit now: delete its line in {CAPS}.")
if not args:
failed += [f"{CAPS}: {p} isn't a tracked file any more: delete its line." for p in caps if p not in tracked]
for message in failed:
print(message, file=sys.stderr)
if failed:
return 1
print(f"File length: {checked} files checked, {len(caps)} with their own caps.")
return 0


if __name__ == "__main__":
sys.exit(main(sys.argv[1:]))
77 changes: 77 additions & 0 deletions scripts/ci/check_suppressions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#!/usr/bin/env python3
"""Every lint suppression in the repository is one somebody agreed to (sc-9611).

A suppression (Rust's #[allow(...)], `@ts-expect-error`, `# noqa`, `rubocop:disable`, `shellcheck disable=`, a zizmor
or hadolint ignore, and the like) silences a check for good, so each one is listed in scripts/ci/suppressions.txt with
the reason for it. A new one fails until it's added there (and the reason is in the diff a reviewer reads). One that's
gone must be deleted from the list, so it never quietly allows a later one.

scripts/ci/check_suppressions.py
"""

import collections
import os
import re
import subprocess
import sys

LIST = "scripts/ci/suppressions.txt"
SKIP = re.compile(r"\.(md|txt|png|jpe?g|gif|webp|ico|pdf|woff2?|ttf|otf|svg|lock)$|^scripts/ci/(check_suppressions\.py|suppressions\.txt)$")
RULES = r"(?: (?!--)[\w/@-]+(?:, ?[\w/@-]+)*)?"
PATTERNS = [
r"#!?\[(?:allow|expect)\([^)]*\)",
r"#!?\[cfg_attr\([^]]*?\b(?:allow|expect)\([^)]*\)",
r"@ts-(?:ignore|expect-error|nocheck)",
r"(?:eslint|oxlint)-disable(?:-next-line|-line)?" + RULES,
r"biome-ignore" + RULES,
r"(?:ruff: )?noqa(?:: ?[A-Z]+\d+(?:, ?[A-Z]+\d+)*)?",
r"type: ignore(?:\[[\w-]+\])?",
r"pyright: ignore(?:\[[\w-]+\])?",
r"pylint: disable=[\w,-]+",
r"pragma: no cover",
r"\bnosec\b",
r"(?:rubocop|standard):(?:disable|todo) [\w/,]+",
r"shellcheck disable=[\w,]+",
r"zizmor: ignore\[[\w, -]+\]",
r"hadolint ignore=[\w,]+",
r"--ignore DL\d{4}",
r"nosemgrep",
r"(?:gitleaks|betterleaks):allow",
]
# Case-insensitive: `# NOQA` silences as well as `# noqa`.
FOUND = re.compile("|".join(f"(?:{p})" for p in PATTERNS), re.I)


def main():
os.chdir(subprocess.check_output(["git", "rev-parse", "--show-toplevel"], text=True).strip())
allowed = collections.Counter()
for line in open(LIST):
line = line.rsplit(" -- ", 1)[0].strip()
if line and not line.startswith("#"):
path, found = line.split(" ", 1)
allowed[(path, found)] += 1
present = collections.Counter()
for path in subprocess.check_output(["git", "ls-files", "-z"], text=True).split("\0"):
if not path or SKIP.search(path) or not os.path.isfile(path):
continue
try:
text = open(path, encoding="utf-8").read()
except UnicodeDecodeError:
continue
for m in FOUND.finditer(text):
present[(path, re.sub(r"\s+", " ", m.group(0)))] += 1
failed = False
for key, n in sorted((present - allowed).items()):
failed = True
print(f"{key[0]}: a new `{key[1]}` ({n}). Fix what it silences, or add `{key[0]} {key[1]} -- <why>` to {LIST}.", file=sys.stderr)
for key, n in sorted((allowed - present).items()):
failed = True
print(f"{LIST}: `{key[0]} {key[1]}` is listed but gone ({n}): delete its line.", file=sys.stderr)
if failed:
return 1
print(f"Suppressions: {sum(present.values())}, each listed with its reason in {LIST}.")
return 0


if __name__ == "__main__":
sys.exit(main())
45 changes: 45 additions & 0 deletions scripts/ci/file_lengths.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Files already over the limit when scripts/ci/check_file_length.py arrived (5 Dec 2026), each with its cap: its
# length then, rounded up to the next hundred. Split a file rather than raise its cap; delete its line once it's under
# the limit.
app/database/migrations/0001_01_01_000000_initial_schema.rs 1400
app/src/auth/invitations.rs 600
app/src/auth/oauth.rs 700
app/src/auth/sign_in.rs 600
app/src/config.rs 900
app/src/domain/baselines.rs 600
app/src/domain/builds.rs 600
app/src/domain/bundles.rs 700
app/src/domain/credits.rs 600
app/src/domain/demo.rs 800
app/src/domain/downloads.rs 600
app/src/domain/gallery.rs 600
app/src/domain/processing.rs 1400
app/src/forge/deliveries.rs 800
app/src/forge/installations.rs 1100
app/src/forge/pr_comment.rs 600
app/src/forge/webhooks.rs 1200
app/src/http/api/builds.rs 600
app/src/mcp/admin.rs 1000
app/src/mcp/args.rs 600
app/src/mcp/mod.rs 2500
app/src/notify/render.rs 600
app/tests/abuse.rs 1400
app/tests/mcp.rs 1400
clients/gallery/js/src/hydrate.ts 600
clients/gallery/rust/src/model.rs 700
crates/envschema/src/lib.rs 900
crates/snapshot-diff/src/lib.rs 1000
crates/visualci-cli/src/ci.rs 600
crates/visualci-cli/src/client.rs 1700
crates/visualci-cli/src/main.rs 1500
crates/visualci-core/src/config.rs 800
crates/visualci-core/src/pdf.rs 900
frontend/src/api/hooks.ts 700
frontend/src/api/types.ts 700
frontend/src/components/Comments.tsx 600
frontend/src/pages/BillingPage.tsx 700
frontend/src/pages/BuildPage.tsx 700
frontend/src/pages/ProjectPage.tsx 1000
frontend/src/pages/SnapshotPage.tsx 1200
frontend/src/styles.css 5800
scripts/screenshots/journeys.mjs 800
38 changes: 38 additions & 0 deletions scripts/ci/suppressions.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Every lint suppression in the repository, with the reason for it (scripts/ci/check_suppressions.py; sc-9611).
# One line per suppression: `<path> <suppression> -- <why>`. Add a line, with its reason, in the change that adds the
# suppression; delete it in the change that removes one. Fixing what a suppression silences beats adding one.

# Workflows
.github/workflows/ci.yml shellcheck disable=SC2086 -- the renderer inputs hash splits $paths into one argument per crate path on purpose
.github/workflows/release-gallery-gem.yml zizmor: ignore[cache-poisoning] -- setup-node there sets no cache; zizmor flags the action itself
.github/workflows/release-gallery-npm.yml zizmor: ignore[cache-poisoning] -- setup-node there sets no cache; zizmor flags the action itself
.github/workflows/release-gallery-python.yml zizmor: ignore[cache-poisoning] -- setup-node there sets no cache; zizmor flags the action itself
.github/workflows/release.yml zizmor: ignore[dangerous-triggers] -- workflow_run is how the release waits for CI; every job checks for a successful CI run of a push to main
.github/zizmor.yml zizmor: ignore[audit] -- not a suppression: the file's comment showing the syntax
clients/github-action/action.yml zizmor: ignore[github-env] -- GITHUB_PATH gets a directory under RUNNER_TEMP named from the workflow author's own inputs

# docker/renderer.Dockerfile's two hadolint warnings wait for the renderer's next rebuild (sc-9674): any edit to that file rebuilds the renderer image.
.github/workflows/ci.yml --ignore DL3003 -- the renderer's PDFBox step cds; fixed in its rebuild (sc-9674)
.github/workflows/ci.yml --ignore DL4006 -- the renderer's PDFBox step pipes without pipefail; fixed in its rebuild (sc-9674)
lefthook.yml --ignore DL3003 -- the same two renderer warnings in the hook (sc-9674)
lefthook.yml --ignore DL4006 -- the same two renderer warnings in the hook (sc-9674)

# Rust
app/src/domain/compare.rs #[allow(clippy::too_many_arguments) -- page_state takes the snapshot, store, project, both pages, the diff options and the mask; a struct would only be built to be taken apart
app/src/domain/detail.rs #[allow(clippy::cast_precision_loss) -- changed and total line counts as f64 for a fraction; counts never come near 2^52
app/src/domain/processing.rs #[allow(clippy::too_many_lines) -- process() is the build pipeline, kept in one function so its steps (and what holds no transaction) read in order
app/src/domain/retention.rs #[allow(clippy::cast_precision_loss) -- a byte total shown in MB with one decimal; precision past 2^52 doesn't matter there
app/src/mcp/admin.rs #![allow(clippy::doc_markdown) -- doc comments here are the tools' descriptions agents read, as prose, not rustdoc
app/src/mcp/args.rs #![allow(clippy::doc_markdown) -- doc comments here become the JSON schemas' descriptions agents read, as prose
app/tests/oauth_client/mod.rs #![allow(dead_code) -- the OAuth test client's helpers; not every one has a test using it yet
clients/gallery/rust/tests/examples.rs #[allow(dead_code) -- the examples are compiled as modules to test them, so their main() is unused
clients/gallery/rust/tests/examples.rs #[allow(dead_code) -- the examples are compiled as modules to test them, so their main() is unused
clients/gallery/rust/tests/examples.rs #[allow(dead_code) -- the examples are compiled as modules to test them, so their main() is unused
crates/visualci-cli/src/client.rs #[allow(clippy::type_complexity) -- a test helper's return type (the server's URL and request count, and the last bundle); a type alias for it would be used twice
crates/visualci-wasm/src/lib.rs #![allow(unsafe_code) -- the wasm exports hand the page raw pointers into linear memory; there is no safe form
crates/visualci-wasm/src/lib.rs #[allow(clippy::too_many_arguments) -- a wasm export takes plain numbers and pointers, never a struct

# Others
clients/gallery/js/test/hydrate.test.ts @ts-expect-error -- deletes a DOM method to test the fallback for Safari before 15.4
clients/gallery/ruby/lib/visualci/gallery/engine.rb rubocop:disable Rails/OutputSafety -- the gallery renderer escapes everything it outputs
scripts/ci/test_migration_safety.py noqa: E402 -- the import has to follow the sys.path change that finds the module
Loading