Skip to content

ci: align pre-commit hooks and GitHub templates#8890

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

ci: align pre-commit hooks and GitHub templates#8890
mc-nv wants to merge 16 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?

Aligns this repository with the org-wide setup consolidated in triton-inference-server/.github:

  • .pre-commit-config.yaml: shared baseline hooks, conventional-commit message validation (commit-msg stage), and the centralized add-license hook from the org .github repository (rev: v1.4.3 — excludes .github/ templates, never rewrites LICENSE files).
  • Pre-commit CI runs only on files modified by the PR.
  • Caller stub for the org-wide reusable conventional-pr workflow (@v1.4.3): validates the PR title against Conventional Commits (hard gate — it becomes the squash-merge commit), derives one human-readable label per distinct type found in the title and all conforming commit subjects (e.g. ci:CI/CD, feat:feature, fix:fix), enforces org-wide label colors/descriptions, detects cherry-picks, and fails if no type is derivable and no type label is assigned.
  • No per-repo templates: PR templates and issue routing are inherited from the org-wide defaults in triton-inference-server/.github (issues route to the server repository).

Repo-specific: keeps the deploy/templates check-yaml exclude; ISSUE_TEMPLATE/ stays local — this repository is the org-wide issue intake point; the unused local SPDX script is removed.

Best merged after triton-inference-server/.github#5 (full org-defaults diff: https://github.com/triton-inference-server/.github/pull/5/files). The pinned tags (current: v1.4.3) already exist, so CI is green.

Pros / Cons

Pros

  • Single home (org .github repo) for hooks, templates, issue routing, and the PR-title workflow — one change propagates everywhere.
  • Repos carry only a config file and two small workflow stubs; no template copies to drift.
  • Commit/PR title format enforced both locally (commit-msg hook) and in CI (reusable workflow), with automatic type labels.
  • License hooks never modify LICENSE files.

Cons / risks

  • Version-pinned dependency on the org .github repository (tags are write-once; changes ship as a new tag + rev bump).
  • Template inheritance requires the org .github repository to remain public.

Related Issues / PRs

  • Resolves: TRI-1100

Related PRs:

Test plan

  • pre-commit validate-config passes; pre-commit run --files <PR diff> passes locally with the centralized hooks pinned to the .github branch SHA.
  • After .github#5 merges and v1.4.3 exists: the conventional-pr check validates this PR's own title and applies the ci label.
  • No LICENSE file content is changed by this PR.

Caveats

  • None beyond the merge-order note above.

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

Adopt the shared pre-commit baseline: two-line SPDX header, conventional
commit message validation (commit-msg stage), and the centralized
add-license / add-spdx-license hooks from developer_tools v0.2.0. The
local add-spdx-license hook and its script move to developer_tools.
Run pre-commit CI only on files modified by the PR, and roll out the
simplified single PR template.

TRI-1100
@mc-nv mc-nv self-assigned this Jul 18, 2026
This was referenced Jul 18, 2026
Legal's Copyright / License Header Guidance specifies the SPDX form
without a comma after the year.

TRI-1100
@mc-nv
mc-nv marked this pull request as ready for review July 18, 2026 02:05
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
mc-nv added a commit to triton-inference-server/.github that referenced this pull request Jul 20, 2026
Review feedback on triton-inference-server/server#8890: external
contributors keep the visual commit-type checklist for now; internal
contributors rely on the enforced conventional-pr workflow and
commit-msg hook.

TRI-1100
@github-actions github-actions Bot added the chore Maintenance work, no production code change (chore: PRs) label Jul 20, 2026
@yinggeh

yinggeh commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Add https://github.com/triton-inference-server/.github/pull/5/changes to description.

mc-nv added 2 commits July 21, 2026 08:16
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
@mc-nv

mc-nv commented Jul 21, 2026

Copy link
Copy Markdown
Contributor Author

Done — the description now links the full org-defaults diff (https://github.com/triton-inference-server/.github/pull/5/files) in the merge-order note.

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

TRI-1100
@greptile-apps

greptile-apps Bot commented Jul 22, 2026

Copy link
Copy Markdown

Greptile Summary

This PR aligns the repository's CI and developer tooling with the org-wide setup consolidated in triton-inference-server/.github. Local PR templates are removed in favour of inherited org defaults, a thin caller stub delegates conventional-commit PR-title validation and auto-labeling to a pinned reusable workflow, and the pre-commit configuration is modernised with a commit-msg stage and a centralized add-license hook.

  • conventional-pr.yml: New caller for conventional-pr.yml@v1.4.3; correctly splits same-repo PRs onto pull_request and fork PRs onto pull_request_target (with write permissions limited to labels/PR metadata, never code checkout), with all three required permissions present.
  • pre-commit.yml: Switches from pre-commit/action to a manual install, adds an actions/cache@v4 step for hook environments, and uses null-delimited xargs with --diff-filter=d for robust file-list handling (spaces in paths, deletion-only PRs).
  • .pre-commit-config.yaml: Adds commit-msg stage + conventional-pre-commit hook, fixes the long-standing flake8 --extend-ignore = (space) bug, and replaces the local add-spdx-license hook with the org-central add-license hook pinned at v1.4.3.

Confidence Score: 5/5

Safe to merge; all changes are CI/tooling configuration with no impact on application code or production behaviour.

Every changed file is a workflow YAML, a pre-commit config, a deleted PR template, or a deleted utility script. The pull_request_target fork path is correctly guarded so the writable token is only used to manage labels via the pinned reusable workflow, never to execute contributor code. The one practical improvement is adding a restore-keys fallback to the pre-commit cache step so config rev-bumps don't force a full cold rebuild.

No files require special attention.

Important Files Changed

Filename Overview
.github/workflows/conventional-pr.yml New caller stub for the org-wide conventional-pr reusable workflow; correctly guards pull_request_target to fork PRs only and includes all necessary permissions (pull-requests: write, issues: write, contents: read).
.github/workflows/pre-commit.yml Updated to use actions/cache for pre-commit hook environments, null-delimited file diffing to handle paths with spaces, and --diff-filter=d to skip deleted files; minor: no restore-keys fallback means a full cache miss on every config rev bump.
.pre-commit-config.yaml Adds commit-msg stage and conventional-pre-commit hook, fixes flake8 --extend-ignore= argument (was space-separated, now correct), switches add-license to the centralized org .github repo hook, and removes the local SPDX script hook.
tools/add_spdx_header.py Deleted: the local SPDX header migration script is superseded by the centralized add-license hook from the org .github repository.
.github/pull_request_template.md Deleted: PR template is now inherited from the org-wide .github repository defaults.

Sequence Diagram

sequenceDiagram
    participant Dev as Developer
    participant GH as GitHub
    participant PC as pre-commit.yml
    participant CP as conventional-pr.yml
    participant OW as org .github reusable workflow

    Dev->>GH: Open / update PR
    GH->>PC: pull_request event
    activate PC
    PC->>PC: "checkout (depth=2)"
    PC->>PC: restore pre-commit cache
    PC->>PC: "git diff --name-only -z --diff-filter=d HEAD^1 HEAD"
    PC->>PC: pre-commit run --files changed-files
    PC-->>GH: pass / fail
    deactivate PC

    alt Same-repo PR
        GH->>CP: pull_request event
    else Fork PR
        GH->>CP: pull_request_target event
    end
    activate CP
    CP->>OW: "uses conventional-pr.yml@v1.4.3"
    activate OW
    OW->>GH: Validate PR title (Conventional Commits)
    OW->>GH: Derive type labels (ci→CI/CD, feat→feature, fix→fix)
    OW->>GH: Enforce org-wide label colors/descriptions
    OW->>GH: Detect cherry-picks
    OW-->>CP: pass / fail
    deactivate OW
    CP-->>GH: status check + labels applied
    deactivate CP
Loading

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

Comment thread .github/workflows/conventional-pr.yml Outdated
Comment thread .github/workflows/conventional-pr.yml Outdated
permissions:
pull-requests: write
issues: write
uses: triton-inference-server/.github/.github/workflows/conventional-pr.yml@v1.4.2

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 Version tag mismatch with PR description

The PR description references @v1.4.1 throughout (including in the test plan), but the actual pinned tag here is v1.4.2. The same discrepancy exists in .pre-commit-config.yaml (line 88, also v1.4.2). This is purely a documentation drift in the PR body, but if a future reviewer audits the description against the committed YAML it will look like an unintentional bump. Consider updating the PR description to reflect v1.4.2.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

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.

Fixed - documentation drift: the descriptions have been refreshed to the current pinned tag v1.4.3 (they lagged behind the tag revisions; the tag exists and CI is green fleet-wide).

@mc-nv
mc-nv requested a review from pskiran1 July 22, 2026 15:12
- 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

@Vinya567 Vinya567 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM.

@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 #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)

Development

Successfully merging this pull request may close these issues.

3 participants