Skip to content

ci: migrate the centralized add-license hook to the org .github repository#61

Closed
mc-nv wants to merge 18 commits into
mainfrom
mchornyi/TRI-1100/github-align-hooks-and-templates
Closed

ci: migrate the centralized add-license hook to the org .github repository#61
mc-nv wants to merge 18 commits into
mainfrom
mchornyi/TRI-1100/github-align-hooks-and-templates

Conversation

@mc-nv

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

Copy link
Copy Markdown
Contributor

What does the PR do?

Migrates the centralized add-license pre-commit hook (definition + tools/add_copyright.py) out of this repository into the org-wide defaults repo triton-inference-server/.github (see triton-inference-server/.github#5), so hooks, templates, issue routing, and reusable workflows live under one roof with a single tag line.

Existing consumers pinned to this repository's v0.x tags keep working — tags are immutable; new consumers reference .github@v1.4.3. This repository itself becomes a plain consumer, aligned with the shared baseline (conventional-commit validation, modified-files CI, org-wide templates, conventional-pr caller stub).

Depends on triton-inference-server/.github#5 being merged and tagged (current: v1.4.3).

Related Issues / PRs

  • Resolves: TRI-1100

Related PRs:

Test plan

  • pre-commit validate-config passes; hooks pass on the PR diff with the centralized hooks pinned to the .github branch SHA.
  • Consumers of the old v0.x tags verified unaffected (tags still resolve).

Caveats

  • The v0.2.x tags remain in place for any external consumer; they can be retired once nothing references them.

Checklist

  • PR title follows <commit_type>: <Title> (conventional commit)
  • I ran pre-commit locally on all files changed by this PR and it passes
  • Copyright header is correct on all changed files
  • External contributors: I have read the Contribution guidelines and signed the Contributor License Agreement

Add tools/add_spdx_header.py as a centralized pre-commit hook that
migrates each source file to the two-line SPDX header the first time it
is touched (maintain / migrate legacy NVIDIA BSD header / insert).
Exclude .github/ from add-license so GitHub issue/PR templates keep
their YAML frontmatter first. Make add-license read the LICENSE file
without rewriting its copyright year — consumer repos' LICENSE files
must never be modified by hooks. Requires tagging v0.2.0 after merge.

Also align this repository with the shared pre-commit baseline and
GitHub templates.

TRI-1100
@mc-nv mc-nv self-assigned this Jul 18, 2026
This was referenced Jul 18, 2026
CI here must validate the hook code being merged rather than an
already-published tag; consumer repositories keep referencing
rev: v0.2.0.

TRI-1100
@mc-nv
mc-nv marked this pull request as ready for review July 18, 2026 01:00
Legal's Copyright / License Header Guidance specifies the SPDX form
without a comma after the year:
  SPDX-FileCopyrightText: Copyright (c) <year> NVIDIA CORPORATION & AFFILIATES. All rights reserved.

Emit that form from add_spdx_header.py, keep both hooks tolerant of the
legacy comma variant, and normalize the headers introduced by this
change.

TRI-1100
@mc-nv
mc-nv removed request for Vinya567 and nv-rinig July 20, 2026 21:58
Human-readable type labels with enforced descriptions and colors.

TRI-1100
@github-actions github-actions Bot added CI/CD Continuous integration and workflow changes (ci: PRs) and removed ci labels Jul 20, 2026
@github-actions github-actions Bot added the chore Maintenance work, no production code change (chore: PRs) label Jul 20, 2026
mc-nv added 2 commits July 21, 2026 08:15
The add-license hook now fails when the LICENSE copyright year is
stale.

TRI-1100
Workflow files are license-processed again (only templates excluded);
refresh the stale copyright year this repo's pre-commit workflow
carried.

TRI-1100
@yinggeh

yinggeh commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Consider dropping tags in this repository (v0.1.0, v0.2.0, etc.) as they are no longer used.

@mc-nv

mc-nv commented Jul 21, 2026

Copy link
Copy Markdown
Contributor Author

Done for the safe subset: v0.2.0 and v0.2.1 are gone — nothing referenced them anymore. v0.1.0 has to stay for now: the main-branch .pre-commit-config.yaml of 15 repos still pins rev: v0.1.0, so retiring it today would break pre-commit CI on main across the org. It becomes unreferenced exactly when the TRI-1100 PRs merge (they replace the reference with the org .github repo hooks) — I'll retire it then as part of the post-merge cleanup.

Grant issues:write to the labeling job (review feedback).

TRI-1100
@mc-nv
mc-nv requested a review from pskiran1 July 22, 2026 15:11
@Vinya567

Copy link
Copy Markdown

@greptileai

@greptile-apps

greptile-apps Bot commented Jul 22, 2026

Copy link
Copy Markdown

Greptile Summary

This PR migrates the add-license pre-commit hook and its backing script (tools/add_copyright.py) out of this repository into the org-wide triton-inference-server/.github repo, making this repo a plain consumer of centralized tooling. The CI layer is also modernized: the pre-commit workflow gains a cache step and uses null-delimited file filtering, and a new thin conventional-pr.yml caller workflow is added for org-wide PR title validation.

  • Hook migration: .pre-commit-config.yaml now pulls add-license from triton-inference-server/.github@v1.4.3 instead of the local v0.1.0 tag; tools/add_copyright.py is deleted as a result.
  • CI improvements: pre-commit.yml drops the custom modified-files shell step in favor of git diff --name-only -z --diff-filter=d HEAD^1 HEAD | xargs -0 (space-safe, deletion-safe), adds a .pre-commit-config.yaml-keyed cache, and locks down job permissions to contents: read.
  • New workflow: conventional-pr.yml is a thin caller for the org reusable workflow, correctly routing same-repo PRs through the safe pull_request event and fork PRs through pull_request_target (with an explicit if guard); default_install_hook_types and the conventional-pre-commit commit-msg hook are added to enforce Conventional Commits locally.

Confidence Score: 5/5

Safe to merge — the changes are a straightforward hook migration and CI modernisation with no functional regressions.

All four changed files implement clean, well-scoped changes: the add-license hook moves to the org .github repo at a pinned immutable tag, the pre-commit workflow gains space-safe file filtering and a config-keyed cache, and the new conventional-pr.yml caller correctly guards pull_request_target to fork-only PRs. No logic that could silently break existing consumers was altered.

No files require special attention.

Important Files Changed

Filename Overview
.github/workflows/conventional-pr.yml New thin caller workflow for org-wide PR title validation; correctly uses a pull_request/pull_request_target guard to scope write permissions only to fork PRs while keeping same-repo PRs on the safer event.
.github/workflows/pre-commit.yml Replaces the custom modified-files step with null-delimited git diff
.pre-commit-config.yaml Switches add-license source to the centralized .github@v1.4.3 tag, adds conventional-pre-commit commit-msg hook, and fixes flake8 arg quoting; default_install_hook_types correctly enables the new commit-msg stage.
tools/add_copyright.py Deleted as part of the migration — the script now lives in the org .github repo and is consumed via the pre-commit hook rev pin.

Sequence Diagram

sequenceDiagram
    participant Dev as Developer
    participant GH as GitHub Actions
    participant PreCommitWF as pre-commit.yml
    participant ConvPRWF as conventional-pr.yml
    participant OrgWF as .github reusable workflow (v1.4.3)
    participant PC as pre-commit (local cache)

    Dev->>GH: Open / push PR
    GH->>PreCommitWF: trigger (pull_request)
    PreCommitWF->>PreCommitWF: "checkout (fetch-depth=2)"
    PreCommitWF->>PC: restore cache (~/.cache/pre-commit keyed on config hash)
    PreCommitWF->>PreCommitWF: "git diff HEAD^1 HEAD (null-delimited, --diff-filter=d)"
    PreCommitWF->>PC: pre-commit run --files changed files
    PC-->>PreCommitWF: pass / fail (show diff on failure)

    GH->>ConvPRWF: trigger (pull_request OR pull_request_target)
    Note over ConvPRWF: if guard: same-repo → pull_request, fork → pull_request_target
    ConvPRWF->>OrgWF: "uses conventional-pr.yml@v1.4.3 (permissions: PR write, issues write)"
    OrgWF->>GH: validate PR title (Conventional Commits)
    OrgWF->>GH: apply / remove labels via API
    OrgWF-->>ConvPRWF: result

    Dev->>Dev: git commit (local)
    Note over Dev,PC: commit-msg hook fires (conventional-pre-commit v4.4.0)
    Dev->>PC: validate commit message format
    PC-->>Dev: pass / fail
Loading

Reviews (2): Last reviewed commit: "ci: harden CI workflows and configs per ..." | Re-trigger Greptile

Comment thread .pre-commit-config.yaml Outdated
- conventional-pr stub: dual pull_request/pull_request_target triggers
  so fork PRs from external contributors get labeled too (the reusable
  workflow never checks out PR code); explicit contents:read; pinned
  v1.4.3.
- pre-commit workflow: robust modified-files runner (null-delimited
  paths, deletion-only PRs handled, deleted paths filtered, no
  undocumented -r flag, cache keyed on config hash).
- flake8 args quoted correctly (the flow-scalar form split at commas
  and silently reduced the select list).
- hooks pinned to .github v1.4.3.

TRI-1100
@mc-nv
mc-nv requested a review from Vinya567 July 22, 2026 19:40
@mc-nv

mc-nv commented Jul 22, 2026

Copy link
Copy Markdown
Contributor Author

Closing: the team is moving away from centralized org-level configuration in favor of per-repository self-contained setups (see triton-inference-server/server#8897 for the first decentralized implementation). Branch retained for reference. TRI-1100

@mc-nv mc-nv closed this Jul 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore Maintenance work, no production code change (chore: PRs) CI/CD Continuous integration and workflow changes (ci: PRs)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants