You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit ab6fbd7
Browse filesBrowse the repository at this point in the historyBrowse files
chore(lint): add doc link checker, OSS hygiene ratchets, and CI tool pins
- Add `tools/lint/check_doc_links.py`, `check_doc_links_test.py`, and Bazel targets wired into `.githooks/pre-commit`, `.github/workflows/lint.yml`, and `tools/README.md`, with shared CommonMark `opens_fence`/`INLINE_CODE_RE` in `check_agent_doc_paths.py`, balanced/angle/reference-link parsing, case-insensitive external/file scheme checks, protocol-relative handling, and `forbidden_url` deduplication.
- Add `oss_b_todo_references` and `generic_helper_filenames` ratchets to `check_legacy_imports.py` and `legacy_imports_baseline.json` (plus broadened `HandledError` guidance and unit tests).
- Pin `ruff==0.16.4`, `mypy==2.4.1`, `helm` `v3.20.1`, and `Check PR Diff Size` warning telemetry in `.github/workflows/lint.yml`.
TAG=agy
CONV=ba8411ef-c093-4f45-950a-b3bc1899268c
Copy file name to clipboardExpand all lines: .githooks/pre-commit
+14-3Lines changed: 14 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -187,9 +187,8 @@ check_matrix_contract() {
187
187
}
188
188
189
189
check_agent_doc_paths() {
190
-
# In fix mode, only run when agent docs are staged, or when staged deletes or
191
-
# renames could orphan a path an agent doc references, to keep the hook fast.
192
-
if [ "${MODE}"="fix" ] &&! staged_paths_match AM '^\.agents/.*\.md$|(^|/)AGENTS\.md$'&&! staged_paths_match D '.';then
190
+
# In fix mode, only run when agent docs, its linter, or staged deletes/renames change.
191
+
if [ "${MODE}"="fix" ] &&! staged_paths_match AM '^\.agents/.*\.md$|(^|/)AGENTS\.md$|^tools/lint/check_agent_doc_paths\.py$'&&! staged_paths_match D '.';then
193
192
return
194
193
fi
195
194
echo"--> Checking Agent Doc Path References..."
@@ -199,6 +198,17 @@ check_agent_doc_paths() {
199
198
fi
200
199
}
201
200
201
+
check_doc_links() {
202
+
if [ "${MODE}"="fix" ] &&! staged_paths_match AM '\.md$|^tools/lint/check_(doc_links|agent_doc_paths)\.py$'&&! staged_paths_match D '.';then
Copy file name to clipboardExpand all lines: tools/README.md
+2-1Lines changed: 2 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -84,8 +84,9 @@ Tooling and automation for release metadata extraction, SemVer calculations, and
84
84
### 7. `tools/lint/` (Static Analyzers & Linters)
85
85
Offline syntax walkers and static validation tooling:
86
86
-[`check_go_determinism`](lint/check_go_determinism/): Ultra-fast (<50ms) Go AST analyzer checking Go test files for `os.Setenv` usage and arbitrary second-level `time.Sleep` calls.
87
-
-[`check_legacy_imports.py`](lint/check_legacy_imports.py): Ratchet lint preventing regression of google3 migration leftovers (legacy Go import roots, unresolved `xmanager_cloud/...` module paths, `compat_go_*` targets, `gazelle:resolve` overrides, `third_party/` proto paths, google3 Helm flags, legacy UI/Python paths) against the zeroed [`legacy_imports_baseline.json`](lint/legacy_imports_baseline.json). Fails when any count grows above zero. Runs in pre-commit and the lint CI job. Tracking: [#1066](https://github.com/google/xmc/issues/1066).
87
+
-[`check_legacy_imports.py`](lint/check_legacy_imports.py): Ratchet lint preventing regression of google3 migration leftovers (legacy Go import roots, unresolved `xmanager_cloud/...` module paths, `compat_go_*` targets, `gazelle:resolve` overrides, `third_party/` proto paths, google3 Helm flags, legacy UI/Python paths), OSS `TODO(b/...)` IDs under `api/`, `cmd/`, `pkg/`, and `sdks/`, and new generic helper/util/misc/common filenames against [`legacy_imports_baseline.json`](lint/legacy_imports_baseline.json). Fails when any count grows above baseline. Runs in pre-commit and the lint CI job. Tracking: [#1066](https://github.com/google/xmc/issues/1066).
88
88
-[`check_agent_doc_paths.py`](lint/check_agent_doc_paths.py): Fails when agent docs (`.agents/**/*.md`, `AGENTS.md`) reference repo paths in code spans or fenced blocks that are not tracked files or directories. Placeholders (`<name>`, `{a,b}`, `$VAR`, `*`, `[`, `...`) only require their directory prefix to exist; runtime-created and illustrative paths live in its `ALLOWLIST` with reasons, and unreferenced entries fail. Runs in pre-commit (when agent docs are staged or files are deleted/renamed; always in `--check` mode) and the lint CI job.
89
+
-[`check_doc_links.py`](lint/check_doc_links.py): Validates relative Markdown links (`[label](path)`) against tracked files and directories and rejects non-code `file://`, `corp.google.com`, `http(s)://go/...`, and `//go/...` URLs across all tracked Markdown docs outside `.agents/`. Runs in pre-commit (when non-`.agents/` Markdown docs or doc linters are staged, or files are deleted/renamed; always in `--check` mode) and the lint CI job.
89
90
-[`check_file_naming.py`](lint/check_file_naming.py): Enforces UI and workflow file-naming conventions across tracked repository files (`*.ng.html` for HTML files under `cmd/ui/`—templates under `cmd/ui/app/` with `cmd/ui/index.html` allowlisted—`*_test.ts` for Karma unit tests under `cmd/ui/app/` while rejecting `*.spec.ts`/`*_spec.ts`/`*.test.ts` repo-wide outside `cmd/ui/screenshot_tests/`, `*.screenshot.spec.ts` for Playwright visual specs under `cmd/ui/screenshot_tests/`, and top-level `*.test.js` for Node workflow tests under `.github/scripts/`). Runs in pre-commit and the lint CI job.
90
91
-[`check_ui_selector_contract.py`](lint/check_ui_selector_contract.py): Parses every tracked `*.py` under `tools/nightly_tests/` (fails on any syntax error; `EXCLUDED_SOURCES` opts files out) and lints each file containing selectors (`*_SEL`/`*_SEL_TMPL` constants, `.locator()`/`.wait_for_selector()` string arguments, or `has_text=` literals; reported as `sources`). Fails when selectors reference `[data-testid="..."]` values or custom tags that no `cmd/ui/app` template or component selector declares (Material `mat-`/`mdc-`/`cdk-` names exempt), when selectors use custom classes or non-standard attributes without `# ui-contract: <reason>`, when code references a `ui_css_selectors` constant that does not exist, or when selectors match user-facing copy via `:has-text(...)`/`has_text=` without a `# ui-contract: <reason>` comment on the same line or a standalone comment line above. Runs on every commit in pre-commit and in the lint CI job (~0.2s; no path gate, so the source list is not duplicated).
0 commit comments