Skip to content

ci: make CI and hook configuration self-contained#8897

Merged
mc-nv merged 1 commit into
mainfrom
mchornyi/TRI-1100/decentralized-config
Jul 22, 2026
Merged

ci: make CI and hook configuration self-contained#8897
mc-nv merged 1 commit into
mainfrom
mchornyi/TRI-1100/decentralized-config

Conversation

@mc-nv

@mc-nv mc-nv commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

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: local add-license hook backed by the in-repo tools/add_copyright.py (restored verbatim from before ci: Use centralized add-license pre-commit hook #8879, plus two noqa markers 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); W503 ignored (black-compatibility standard); .github templates excluded from header injection.
  • pre-commit.yml: robust modified-files CI runner (null-delimited paths, deletion-safe, cached).
  • All old SPDX headers reverted (absorbs ci: Remove SPDX pre-commit hook #8891): build.py, qa/L2_build_presets/*, tools/build/build_presets.py back to long-form headers; tools/add_spdx_header.py deleted. git grep SPDX is clean repo-wide.
  • Incidental fixes surfaced by the corrected linting: four placeholder-less f-strings in build.py.
  • PR templates stay in-repo and unchanged except the external template gaining the chore type and an absolute contributing link.
  • No conventional-PR title validation workflow and no commit-msg hook — commit/PR conventions are unenforced in this variant.

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

@github-actions github-actions Bot added the CI/CD Continuous integration and workflow changes (ci: PRs) label Jul 22, 2026
@mc-nv
mc-nv force-pushed the mchornyi/TRI-1100/decentralized-config branch 2 times, most recently from 524aca2 to dac3375 Compare July 22, 2026 20:39
@mc-nv mc-nv self-assigned this Jul 22, 2026
@mc-nv
mc-nv requested a review from yinggeh July 22, 2026 20:40
@mc-nv
mc-nv marked this pull request as ready for review July 22, 2026 20:40
@greptile-apps

greptile-apps Bot commented Jul 22, 2026

Copy link
Copy Markdown

Greptile Summary

This PR makes the Triton Inference Server repository's CI and pre-commit tooling fully self-contained by removing all dependencies on shared org repositories (developer_tools, .github), reverting the SPDX header experiment, and restoring the original long-form BSD copyright headers across affected files.

  • Replaces the external add-license hook and the add-spdx-license local hook with a single local hook backed by an in-repo tools/add_copyright.py (restored verbatim from before ci: Use centralized add-license pre-commit hook #8879); four placeholder-less f-strings in build.py are fixed as an incidental linting improvement.
  • Rewrites the pre-commit.yml CI runner to use null-delimited file paths, deletion-safe --diff-filter=d, and a pre-commit cache keyed on the config hash — a solid improvement over the previous xargs-without-null approach.
  • tools/add_spdx_header.py is deleted and all SPDX headers in changed files are reverted to long-form BSD blocks, absorbing ci: Remove SPDX pre-commit hook #8891.

Confidence Score: 5/5

Safe 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

Filename Overview
.github/workflows/pre-commit.yml Improved CI runner using null-delimited paths and pre-commit caching; pre-commit version is unpinned which can cause non-reproducible runs
.pre-commit-config.yaml Switches to local add-license hook backed by in-repo add_copyright.py; comment claims workflows ARE processed but .yml files have no handler in the script
tools/add_copyright.py Restored copyright hook; .yml extension missing from handler, update_copyright_year crashes on match=None despite docstring claiming 'no effect', has_copyright annotated -> bool but returns Match
build.py Reverted SPDX header to long-form BSD; four placeholder-less f-strings correctly fixed to plain strings

Sequence Diagram

sequenceDiagram
    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)"
Loading

Reviews (5): Last reviewed commit: "ci: make CI and hook configuration self-..." | Re-trigger Greptile

Comment thread tools/add_copyright.py
Comment thread tools/add_copyright.py
Comment on lines +48 to +50
def update_copyright_year(
path: str, content: Optional[str] = None, disallow_range: bool = False
) -> str:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 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.

Suggested change
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:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread tools/add_copyright.py
Comment on lines +155 to +159
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. "
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread tools/add_copyright.py
return lambda path: expected in path


def any_of(*funcs: Sequence[Callable[[str], bool]]):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 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.

Suggested change
def any_of(*funcs: Sequence[Callable[[str], bool]]):
def any_of(*funcs: Callable[[str], bool]):

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@mc-nv
mc-nv requested a review from Vinya567 July 22, 2026 20:48
@mc-nv
mc-nv force-pushed the mchornyi/TRI-1100/decentralized-config branch 3 times, most recently from d5a18d9 to 9c009fa Compare July 22, 2026 21:53
This was referenced Jul 22, 2026
Vinya567
Vinya567 previously approved these changes Jul 22, 2026
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
@mc-nv
mc-nv force-pushed the mchornyi/TRI-1100/decentralized-config branch from e2a8001 to 90c4350 Compare July 22, 2026 22:37
@mc-nv
mc-nv requested a review from Vinya567 July 22, 2026 22:37
Comment thread .pre-commit-config.yaml
@mc-nv
mc-nv requested a review from yinggeh July 22, 2026 22:59
@mc-nv
mc-nv merged commit a6c1466 into main Jul 22, 2026
4 checks passed
@mc-nv
mc-nv deleted the mchornyi/TRI-1100/decentralized-config branch July 22, 2026 23:05
Vinya567 added a commit that referenced this pull request Jul 23, 2026
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.
Vinya567 added a commit that referenced this pull request Jul 23, 2026
- 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI/CD Continuous integration and workflow changes (ci: PRs)

Development

Successfully merging this pull request may close these issues.

3 participants