Skip to content

ci: org-wide defaults - templates, issue routing, hooks, and reusable workflows - #5

Closed
mc-nv wants to merge 15 commits into
mainfrom
mchornyi/TRI-1100-poc-org-defaults
Closed

ci: org-wide defaults - templates, issue routing, hooks, and reusable workflows#5
mc-nv wants to merge 15 commits into
mainfrom
mchornyi/TRI-1100-poc-org-defaults

Conversation

@mc-nv

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

Copy link
Copy Markdown

What does the PR do?

Establishes this repository as the single org-wide home for shared GitHub assets and tooling:

Inherited defaults (apply automatically to every org repo without local copies):

  • pull_request_template.md + PULL_REQUEST_TEMPLATE/ — canonical PR templates (internal/external), without the manual "Commit Type" checklist (enforced automatically instead).
  • ISSUE_TEMPLATE/config.yml — blank issues disabled; the new-issue chooser redirects to the server repository (server keeps its own local ISSUE_TEMPLATE/, which overrides this default and remains the org's issue intake point).

Reusable workflow.github/workflows/conventional-pr.yml (workflow_call):

  • Validates the PR title against Conventional Commits (<type>: <Title>; types: build, chore, ci, docs, feat, fix, perf, refactor, revert, style, test) — hard gate, since the title becomes the squash-merge commit.
  • Derives one label per distinct type found in the title and all conforming commit subjects, using human-readable names (featfeature, ciCI/CD, docsdocumentation, fixfix, …) with org-wide enforced colors and descriptions (drifted labels are corrected; stale/legacy auto-managed labels removed). Non-conforming commit subjects produce warnings; merge commits are ignored.
  • Fail-safe: if no type is derivable from title or commits and no type label is manually assigned, the check fails.
  • Detects cherry-pick PRs (git cherry-pick -x commit trailer, or a title/branch hint) and applies a cherry-pick label (additive — manual labels are never removed).
  • Self-contained actions/github-script; no third-party actions. Consumers add a ~10-line caller stub pinned by tag.

Centralized pre-commit hook (migrated from developer_tools):

  • .pre-commit-hooks.yaml + tools/add_copyright.py — the add-license hook, hardened: .github/ excluded (templates keep YAML frontmatter first) and consumer LICENSE files are never rewritten. Consumers reference repo: .../.github + a pinned tag.

Also adds this repo's own pre-commit baseline + CI and a self-check caller (conventional-pr-check.yml, local uses: ./) so PRs here validate themselves with the code they ship.

Tags v1.4.3 through v1.4.3 are cut at the corresponding commits of this branch; consumers currently pin v1.4.3 (workflow) and v1.4.3+ (hooks). Tags are write-once — future changes ship as a new tag plus rev bumps.

Checklist

  • PR title reflects the change and is of format <commit_type>: <Title>
  • Changes are described in the pull request.
  • Related issues are referenced.
  • Populated github labels field
  • Added test plan and verified test passes.
  • Verified that the PR passes existing CI.
  • Verified copyright is correct on all changed files.
  • Added succinct git squash message before merging ref.
  • All template sections are filled out.
  • Optional: Additional screenshots for behavior/output changes with before/after.

Related PRs:

Where should the reviewer start?

  • .github/workflows/conventional-pr.yml — the reusable workflow (validation, labeling, cherry-pick detection)
  • .pre-commit-hooks.yaml + tools/add_copyright.py — the migrated add-license hook (note get_license() is read-only)
  • ISSUE_TEMPLATE/config.yml and the template files — the inherited defaults

Test plan:

  • pre-commit validate-config and all hooks pass on the PR diff (pre-commit check green on this PR).

  • The self-check runs this PR's own workflow version: title validated and the CI/CD label applied with the org color (#bfd4f2) — visible on this PR.

  • add-license verified from a consumer repo with a stale LICENSE year: LICENSE byte-identical after the run; headers inserted with the correct year range.

  • Live across all 24 consumer PRs (pinned @v1.4.3): pre-commit and conventional-pr green everywhere; multi-type labeling verified (e.g. backend#127 shows CI/CD + chore derived from its commit history).

  • CI Pipeline ID: N/A — GitHub Actions only (no internal GitLab pipeline for this repository)

Caveats:

  • This repository must remain public for template inheritance to work.
  • Workflows are not inherited — consumers need the small caller stub (an org ruleset with required workflows could remove even those, as a follow-up).
  • This repository has no LICENSE file, so the exported add-license hook is not enabled on itself.

Background

TRI-1100 first aligned hooks and templates by placing identical copies in every repo; this PR completes the follow-up decision to consolidate all shared assets under one roof so a single change propagates org-wide. The add-license hook migrates here from developer_tools (its v0.x tags remain functional for anything still pinned).

Related Issues: (use one of the action keywords Closes / Fixes / Resolves / Relates to)

  • Resolves: TRI-1100

Summary by CodeRabbit

  • New Features

    • Added automated pull request title and commit-type validation, labeling, and cherry-pick detection.
    • Added automated pre-commit checks for formatting, spelling, configuration files, and license headers.
    • Added structured templates for internal and external pull requests.
    • Added an issue contact link for reporting bugs or requesting features.
  • Documentation

    • Updated contribution guidance and licensing information.
    • Added repository-wide copyright and formatting configuration.

- pull_request_template.md + PULL_REQUEST_TEMPLATE/ (internal/external):
  canonical PR templates inherited by every org repo without local copies
- ISSUE_TEMPLATE/config.yml: disables blank issues and routes the
  new-issue chooser to the server repository
- .github/workflows/conventional-pr.yml: reusable workflow validating PR
  titles against Conventional Commits and labeling the PR with its type

TRI-1100
Migrate the add-license pre-commit hook (hardened: .github/ excluded,
LICENSE files never rewritten) from developer_tools into this org-wide
defaults repository, so hooks, PR/issue templates, and reusable
workflows live under one roof with a single tag line. Add this repo's
own pre-commit baseline + CI and a self-check caller for the reusable
conventional-pr workflow.

Consumers reference:
  - repo: https://github.com/triton-inference-server/.github
    rev: v1.0.0
    hooks:
    - id: add-license

TRI-1100
@github-actions github-actions Bot added the ci label Jul 20, 2026
@mc-nv mc-nv changed the title ci: add org-wide defaults and reusable conventional-pr workflow ci: org-wide defaults - templates, issue routing, hooks, and reusable workflows Jul 20, 2026
A trailing "(#N)" squash-merge reference to a different PR in the title
or any commit subject now also triggers the cherry-pick label. Ships as
v1.3.1.

TRI-1100
@mc-nv
mc-nv marked this pull request as ready for review July 20, 2026 23:09
@mc-nv
mc-nv requested a review from yinggeh July 20, 2026 23:11
…is repo

The repository ships code (the centralized copyright tool and the
reusable conventional-pr workflow) whose file headers assert BSD terms;
add the license text itself and run the in-tree add-license hook in
this repo's own pre-commit config (templates stay excluded).

TRI-1100
@github-actions github-actions Bot added the chore Maintenance work, no production code change (chore: PRs) label Jul 20, 2026
Per-repository config-as-code pilot, this repository only: chill
profile, auto-review incl. drafts (pilot), path instructions for the
org-wide workflows, centralized hook tooling, and inherited templates.
Fleet rollout is decided after evaluation; requires the CodeRabbit
GitHub App on the organization. No tag changes - this file is not part
of any hook or workflow export.

TRI-1100
Comment thread tools/add_copyright.py
mc-nv added 3 commits July 21, 2026 07:53
The hook never modifies LICENSE files; instead it now verifies that an
NVIDIA copyright line's highest year is the current year and fails with
guidance to update it in a deliberate commit. Repos without an NVIDIA
copyright line in LICENSE (Apache text, third-party attribution) are
not affected. Ships as v1.4.0.

TRI-1100
The add-license exclude was too broad: ^\.github/ also skipped
workflow files, leaving their copyright headers unmaintained and
unchecked. Narrow it to the template paths (frontmatter must stay
first) and bump the stale header this repo's own workflow carried.
Ships as v1.4.1.

TRI-1100
Review feedback (Greptile P1 on backend#127): label creation and
mutation use the issues API surface; labeling worked empirically under
pull-requests:write alone, but the explicit grant is correct
belt-and-braces. Ships as v1.4.2.

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

Copy link
Copy Markdown

@greptileai

@greptile-apps

greptile-apps Bot commented Jul 22, 2026

Copy link
Copy Markdown

Greptile Summary

This PR establishes the triton-inference-server/.github repository as the org-wide home for shared GitHub assets: a reusable Conventional Commits validation workflow, canonical PR/issue templates, and the centralized add-license pre-commit hook migrated from developer_tools.

  • conventional-pr.yml validates PR titles against Conventional Commits format, enforces org-wide label colors/descriptions, derives labels from commit history, and detects cherry-picks — consumed by 24+ consumer repos pinned at @v1.3.0.
  • add_copyright.py is the migrated hook for inserting/updating NVIDIA copyright headers, hardened to skip .github/ templates and never touch consumer LICENSE files.
  • PR/issue templates are placed for GitHub's template-inheritance mechanism; blank issues are disabled and routed to the server repo.

Confidence Score: 4/5

Safe to merge after removing the committed .pyc binary; all functional logic is correct and has been validated live across 24 consumer repos.

A compiled Python bytecode file (tools/__pycache__/add_copyright.cpython-312-pytest-9.1.1.pyc) was accidentally committed — there is no .gitignore in this new repo to prevent it. Because this repo is consumed org-wide, the binary blob will appear in every consumer checkout and will grow stale as Python versions change. Everything else — workflow logic, hook behavior, templates — is well-constructed and has been exercised end-to-end.

tools/__pycache__/add_copyright.cpython-312-pytest-9.1.1.pyc must be removed from the index; a .gitignore covering __pycache__/ should be added before merging.

Important Files Changed

Filename Overview
tools/pycache/add_copyright.cpython-312-pytest-9.1.1.pyc Compiled Python bytecode artifact accidentally committed; no .gitignore exists to prevent this — must be removed from the index and a .gitignore added.
.github/workflows/conventional-pr.yml Reusable workflow for validating Conventional Commits PR titles and applying type labels; logic is sound but the in-file example stub is pinned to @v1.1.0 instead of the current @v1.3.0.
tools/add_copyright.py Centralized add-license pre-commit hook; update_copyright_year crashes with AttributeError when copyright is absent despite the docstring promising no effect — not reachable today but the contract is broken.
pull_request_template.md Default org-wide PR template redirecting to sub-templates; fallback raw URLs still point to the server repo rather than the new canonical location in this .github repo.
.github/workflows/pre-commit.yml Pre-commit CI workflow using null-delimited file list to avoid spaces in paths; file-list injection via extra_args was flagged in a prior thread.
.pre-commit-hooks.yaml Exported hook definition for the add-license hook; exclude pattern correctly targets ISSUE_TEMPLATE and PULL_REQUEST_TEMPLATE to preserve YAML frontmatter.
.pre-commit-config.yaml Self-repo pre-commit baseline; pins standard linters and runs the in-tree add-license hook for CI validation of the hook code itself.
ISSUE_TEMPLATE/config.yml Org-wide issue template config disabling blank issues and routing all new issues to the server repository — correct and minimal.
.github/workflows/conventional-pr-check.yml Self-check caller that exercises the reusable conventional-pr workflow on this repo's own PRs using a local path reference.
PULL_REQUEST_TEMPLATE/pull_request_template_external_contrib.md External contributor PR template; previously flagged issues (broken CONTRIBUTING.md anchor, missing chore type) are noted in prior threads.

Sequence Diagram

sequenceDiagram
    participant PR as Pull Request (any org repo)
    participant Caller as consumer caller stub
    participant RW as conventional-pr.yml (reusable)
    participant GH as GitHub API

    PR->>Caller: opened / edited / synchronize
    Caller->>RW: workflow_call
    RW->>GH: get PR title
    RW->>RW: validate title vs TYPES regex
    alt title invalid
        RW-->>PR: core.setFailed (PR blocked)
    else title valid
        RW->>GH: paginate listCommits
        RW->>RW: derive type set from commits (warnings for non-conforming)
        RW->>GH: listLabelsOnIssue
        RW->>GH: ensureLabel (create or update color/description)
        RW->>GH: removeLabel (stale type labels)
        RW->>GH: addLabels (wanted labels)
        RW->>RW: cherry-pick detection (trailer / hint / prRef)
        opt cherry-pick detected
            RW->>GH: ensureLabel + addLabels cherry-pick
        end
        RW-->>PR: success
    end
Loading

Comments Outside Diff (1)

  1. tools/__pycache__/add_copyright.cpython-312-pytest-9.1.1.pyc, line 1 (link)

    P1 Compiled bytecode file committed without a .gitignore

    This binary .pyc file is a pytest-generated bytecode artifact from a local test run and should never be committed. There is no .gitignore in this repository, so nothing prevents __pycache__/ from being staged. Because this repo is consumed org-wide (consumers git clone or pip install the hook), the committed .pyc will be present in every checkout, polluting the working tree and potentially causing confusion if the file's Python version mismatches the consumer's interpreter.

    Add a .gitignore at the repo root that includes at minimum __pycache__/ and *.py[cod], and remove this file from the index (git rm --cached tools/__pycache__/add_copyright.cpython-312-pytest-9.1.1.pyc).

Reviews (2): Last reviewed commit: "ci: address fleet-wide review findings" | Re-trigger Greptile

Comment on lines +134 to +140
if (derived.size === 0 &&
!current.some((l) => typeLabels.includes(l.name))) {
core.setFailed(
'No conventional commit type could be determined from the PR ' +
'title or its commits, and no type label is assigned.');
return;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Fail-safe condition is unreachable dead code

derived is initialised on line 121 as new Set([match[1]]), and the early return on lines 109–115 guarantees that match[1] is always a valid type token before execution reaches this point. Consequently derived.size is always ≥ 1 here and the derived.size === 0 branch can never fire. The fail-safe described in the PR description ("if no type is derivable … the check fails") is silently a no-op, so any future refactor that removes the new Set([match[1]]) initialiser would produce incorrect labels with no warning.

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
Author

Choose a reason for hiding this comment

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

Intentionally defensive: the explicit requirement was 'if no type is derivable and none is manually assigned, fail'. Today the title gate makes the branch unreachable, but the fail-safe is load-bearing the moment the title requirement is ever relaxed (a direction that has been discussed). Keeping it, with this thread as the record of why.

Comment thread PULL_REQUEST_TEMPLATE/pull_request_template_external_contrib.md Outdated
Comment thread PULL_REQUEST_TEMPLATE/pull_request_template_external_contrib.md
Comment thread tools/add_copyright.py Outdated
Comment thread .github/workflows/pre-commit.yml Outdated
- add_copyright.py: the double-header sanity check now uses
  COPYRIGHT_YEAR_PAT so LICENSE forms without '(c)' are covered; the
  test-section imports carry explicit noqa markers now that flake8's
  select list is actually applied.
- pre-commit workflow: robust modified-files runner - null-delimited
  paths (spaces survive), --no-run-if-empty (deletion-only PRs),
  --diff-filter=d (no deleted paths), no undocumented -r flag, explicit
  contents:read, pre-commit cache keyed on the config hash.
- conventional-pr reusable + self-check: contents:read granted
  explicitly.
- add-license exclude also covers the single-file
  .github/PULL_REQUEST_TEMPLATE.md form.
- external PR template: absolute CONTRIBUTING link (relative anchors
  break in org-inherited templates) and the missing 'chore' type.
- flake8 args quoted correctly - the previous flow-scalar form split at
  commas and silently reduced the select list.

Ships as v1.4.3.

TRI-1100
coderabbitai[bot]

This comment was marked as duplicate.

@Vinya567 Vinya567 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM. Greptile P1 on unreachable fail-safe noted; Misha’s rationale for keeping defensive branch makes sense while title gate is required.

@mc-nv

mc-nv commented Jul 22, 2026

Copy link
Copy Markdown
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) documentation Improvements or additions to documentation (docs: PRs)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants