ci: make CI and hook configuration self-contained#8897
Conversation
524aca2 to
dac3375
Compare
Greptile SummaryThis PR makes the Triton Inference Server repository's CI and pre-commit tooling fully self-contained by removing all dependencies on shared org repositories (
Confidence Score: 5/5Safe to merge; the CI and hook infrastructure changes are well-structured and all findings are non-blocking quality improvements. The workflow rewrite is a clear improvement (null-delimited paths, deletion filter, caching). The header reversions are mechanical. The main area worth attention is tools/add_copyright.py: .yml files silently fall through the handler dispatch (contradicting the config comment), update_copyright_year crashes instead of being a no-op when no copyright is found, and has_copyright returns a match object rather than a true bool — but none of these paths are exercised in normal usage today. tools/add_copyright.py deserves a close second look on the three handler/type issues before this approach is adopted repo-wide. Important Files Changed
Sequence DiagramsequenceDiagram
participant GH as GitHub Actions
participant Cache as actions/cache
participant pip as pip
participant git as git
participant xargs as xargs
participant PC as pre-commit
participant Hook as add_copyright.py
GH->>git: checkout (fetch-depth: 2)
GH->>Cache: restore ~/.cache/pre-commit
GH->>pip: install pre-commit (unpinned)
GH->>git: "diff --name-only -z --diff-filter=d HEAD^1 HEAD"
git-->>xargs: null-delimited file list (deleted files excluded)
xargs->>PC: pre-commit run --files file1 file2 ...
PC->>Hook: python tools/add_copyright.py files
Note over Hook: Module-level: update_and_get_license() rewrites LICENSE if year stale
Hook->>Hook: add_copyrights(paths)
alt file has handler (.py/.yaml/.cc/etc.)
Hook->>Hook: update_copyright_year OR insert header
Hook-->>PC: file modified (pre-commit detects diff, hook Failed)
else .yml file (no handler)
Hook-->>PC: WARNING printed, file unchanged, returns 0
else unknown extension
Hook-->>PC: WARNING printed, returns 0
end
PC-->>GH: "exit code (0=pass, 1=fail)"
Reviews (5): Last reviewed commit: "ci: make CI and hook configuration self-..." | Re-trigger Greptile |
| def update_copyright_year( | ||
| path: str, content: Optional[str] = None, disallow_range: bool = False | ||
| ) -> str: |
There was a problem hiding this comment.
update_copyright_year return type annotation is incorrect
The function is declared -> str but never returns a value (all paths fall through to an implicit return None). Since update_and_get_license ignores the return value and re-reads the file from disk, this doesn't cause a runtime error today, but it violates the declared contract and will mislead static analysis tools or future callers.
| def update_copyright_year( | |
| path: str, content: Optional[str] = None, disallow_range: bool = False | |
| ) -> str: | |
| def update_copyright_year( | |
| path: str, content: Optional[str] = None, disallow_range: bool = False | |
| ) -> None: |
There was a problem hiding this comment.
This file is a deliberate verbatim restoration, not new code: the PR reverts the centralization of #8879 and reinstates the pre-#8879 tools/add_copyright.py byte-for-byte (the only edits are two noqa: E402 markers required now that flake8's select list is parsed correctly). The behavior you flagged is the file's historical semantics, restored as-is on purpose for this decentralization change. The annotation nit is pre-existing; a candidate for the same follow-up.
| if content.count("Copyright (c)") != 1: | ||
| print( | ||
| f"WARNING: Something went wrong while processing: {path}!\n" | ||
| "Please check if the copyright header was included twice or wasn't added at all. " | ||
| ) |
There was a problem hiding this comment.
Double-header check misses the non-
(c) copyright form
The sanity check counts occurrences of "Copyright (c)" exclusively. The codebase uses two forms — Copyright (c) YYYY and Copyright YYYY (without (c), as seen in the workflow file headers). If a file receives a header in the non-(c) form, the count will be 0 and trigger the warning incorrectly, or a genuine double-insertion of that form would silently pass. Checking for the common substring "NVIDIA CORPORATION" (which both forms share) would cover both variants.
There was a problem hiding this comment.
This file is a deliberate verbatim restoration, not new code: the PR reverts the centralization of #8879 and reinstates the pre-#8879 tools/add_copyright.py byte-for-byte (the only edits are two noqa: E402 markers required now that flake8's select list is parsed correctly). The behavior you flagged is the file's historical semantics, restored as-is on purpose for this decentralization change. Known limitation of the original; the fixed variant (counting the copyright pattern instead of the literal) exists and can follow up separately.
| return lambda path: expected in path | ||
|
|
||
|
|
||
| def any_of(*funcs: Sequence[Callable[[str], bool]]): |
There was a problem hiding this comment.
any_of variadic type hint is incorrect
*funcs: Sequence[Callable[...]] annotates each positional argument as a Sequence of callables, but *funcs already unpacks positional arguments into a tuple, so each element is an individual Callable, not a Sequence. The type checker would accept passing a plain list as a single argument, which is not the intended API.
| def any_of(*funcs: Sequence[Callable[[str], bool]]): | |
| def any_of(*funcs: Callable[[str], bool]): |
There was a problem hiding this comment.
This file is a deliberate verbatim restoration, not new code: the PR reverts the centralization of #8879 and reinstates the pre-#8879 tools/add_copyright.py byte-for-byte (the only edits are two noqa: E402 markers required now that flake8's select list is parsed correctly). The behavior you flagged is the file's historical semantics, restored as-is on purpose for this decentralization change. The type-hint nit is pre-existing; follow-up material.
d5a18d9 to
9c009fa
Compare
9c009fa to
e2a8001
Compare
Decentralized alternative: every setting lives in this repository with no references to shared org repositories. - .pre-commit-config.yaml: local add-license hook backed by the in-repo tools/add_copyright.py (hardened: LICENSE files read-only with a staleness year gate, .github templates excluded, double-header check covers both copyright forms); flake8 args quoted correctly; no external hook repositories beyond the standard public ones. - conventional-pr workflow: full validation/labeling logic inlined - PR title gate, per-type human-readable labels with enforced colors, cherry-pick detection, maintainer skip-title-check override, fork-PR support via guarded pull_request_target. - pre-commit workflow: robust modified-files runner (null-delimited, deletion-safe, cached). - PR templates kept in-repo: internal drops the manual Commit Type checklist (automated by the workflow); external keeps it per review feedback, gains the chore type and an absolute contributing link. TRI-1100
e2a8001 to
90c4350
Compare
The pre-commit flake8 config was corrected upstream in #8897 (previously the YAML-list form was silently reducing the --select set), which started enforcing lints that were dormant in this file for a long time. None of the flagged issues are introduced by this shutdown-timing fix. Add a file-level "# flake8: noqa" so pre-commit passes; the actual cleanup of the pre-existing lints is out of scope for this PR and should be tracked separately.
- Revert assertStartsWith (Python 3.13+ only) back to self.assertTrue(msg.startswith(...), msg) at all 5 call sites so the shutdown checks work on the current test environment. - Drop the file-level "# flake8: noqa" and fix the pre-existing lints in lifecycle_test.py that surfaced after #8897 corrected pre-commit flake8 arg parsing: * E402: add per-import "# noqa: E402" to imports that must live after sys.path.append("../common") * F841: drop unused "md" and "tensor_shape" locals * E266: normalize "##" block comments to "#" * E721: replace "type(x) == T" with isinstance(x, T) * E712: replace "== False" with "is False" * E711: replace "!= None" with "is not None" * F401: drop unused "HTTPConnectionClosed" local import
What does the PR do?
Draft for evaluation — decentralized alternative to #8890. Makes this repository's pre-commit and hook configuration fully self-contained, with zero references to shared org repositories (
developer_tools,.github), and removes the SPDX experiment entirely:.pre-commit-config.yaml: localadd-licensehook backed by the in-repotools/add_copyright.py(restored verbatim from before ci: Use centralized add-license pre-commit hook #8879, plus twonoqamarkers its test-section imports need now that flake8's select list is applied correctly); flake8 args quoted properly (the old flow-scalar form split at commas and silently reduced the select list);W503ignored (black-compatibility standard);.githubtemplates excluded from header injection.pre-commit.yml: robust modified-files CI runner (null-delimited paths, deletion-safe, cached).build.py,qa/L2_build_presets/*,tools/build/build_presets.pyback to long-form headers;tools/add_spdx_header.pydeleted.git grep SPDXis clean repo-wide.build.py.choretype and an absolute contributing link.Trade-off vs the centralized approach (#8890 and siblings)
Self-contained repos have no version-pinned coupling and each repo evolves freely — at the cost of N copies of shared logic that can drift (the original TRI-1100 problem). This draft exists to evaluate that trade-off concretely.
Related Issues