Skip to content

Commit 6b0533b

Browse files
committed
ci: harden CI workflows and configs per fleet-wide review feedback
- 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
1 parent 91ed92a commit 6b0533b

3 files changed

Lines changed: 29 additions & 8 deletions

File tree

.github/workflows/conventional-pr.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,22 @@ name: conventional-pr
3333
on:
3434
pull_request:
3535
types: [opened, edited, synchronize, reopened]
36+
pull_request_target:
37+
types: [opened, edited, synchronize, reopened]
3638

3739
jobs:
3840
conventional-pr:
41+
# Same-repo PRs run on the safe pull_request event; fork PRs run on
42+
# pull_request_target so the labeling job gets a writable token (safe
43+
# here: the reusable workflow never checks out PR code - it only reads
44+
# PR metadata via the API and manages labels).
45+
if: >-
46+
(github.event_name == 'pull_request' &&
47+
github.event.pull_request.head.repo.full_name == github.repository) ||
48+
(github.event_name == 'pull_request_target' &&
49+
github.event.pull_request.head.repo.full_name != github.repository)
3950
permissions:
4051
pull-requests: write
4152
issues: write
42-
uses: triton-inference-server/.github/.github/workflows/conventional-pr.yml@v1.4.2
53+
contents: read
54+
uses: triton-inference-server/.github/.github/workflows/conventional-pr.yml@v1.4.3

.github/workflows/pre-commit.yml

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,23 @@ on:
3232
jobs:
3333
pre-commit:
3434
runs-on: ubuntu-latest
35+
permissions:
36+
contents: read
3537
steps:
3638
- uses: actions/checkout@v5.0.0
3739
with:
3840
fetch-depth: 2
39-
- name: Get modified files
40-
id: modified-files
41-
run: echo "modified_files=$(git diff --name-only -r HEAD^1 HEAD | xargs)" >> $GITHUB_OUTPUT
4241
- uses: actions/setup-python@v6.0.0
43-
- uses: pre-commit/action@v3.0.1
42+
- uses: actions/cache@v4
4443
with:
45-
extra_args: --files ${{ steps.modified-files.outputs.modified_files }}
44+
path: ~/.cache/pre-commit
45+
key: pre-commit-${{ runner.os }}-${{ hashFiles('.pre-commit-config.yaml') }}
46+
- name: Run pre-commit on the files modified by the PR
47+
# Null-delimited so paths with spaces survive; --no-run-if-empty
48+
# handles deletion-only PRs; deleted paths are filtered out before
49+
# being handed to pre-commit.
50+
run: |
51+
python -m pip install --quiet pre-commit
52+
git diff --name-only -z --diff-filter=d HEAD^1 HEAD \
53+
| xargs -0 --no-run-if-empty \
54+
pre-commit run --show-diff-on-failure --color=always --files

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ repos:
4141
rev: 7.3.0
4242
hooks:
4343
- id: flake8
44-
args: [--max-line-length=88, --select=C,E,F,W,B,B950, --extend-ignore = E203,E501]
44+
args: ["--max-line-length=88", "--select=C,E,F,W,B,B950", "--extend-ignore=E203,E501"]
4545
types_or: [python, cython]
4646
- repo: https://github.com/pre-commit/mirrors-clang-format
4747
rev: v16.0.5
@@ -84,6 +84,6 @@ repos:
8484
- id: trailing-whitespace
8585

8686
- repo: https://github.com/triton-inference-server/.github
87-
rev: v1.4.2
87+
rev: v1.4.3
8888
hooks:
8989
- id: add-license

0 commit comments

Comments
 (0)