-
Notifications
You must be signed in to change notification settings - Fork 2.7k
[TRTLLMINF-218][infra] Gate multi-GPU CI stages behind 'ci: full pre-merge approved' label #16578
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
juney-nvidia
merged 6 commits into
NVIDIA:main
from
ZhanruiSunCh:user/zhanruis/0716_multi_gpu_label_gate
Aug 4, 2026
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
cb085f7
[TRTLLMINF-218][infra] Gate multi-GPU CI stages behind 'ci: full pre-…
ZhanruiSunCh 593cf39
[TRTLLMINF-218][infra] Address CodeRabbit review feedback
ZhanruiSunCh 6a7fb58
[TRTLLMINF-218][infra] Use shared lib for label+author validation and…
ZhanruiSunCh 3bd3833
[TRTLLMINF-218][infra] Show specific block reason in Blocked stage er…
ZhanruiSunCh e52c615
[TRTLLMINF-218][test] TEST-ONLY: use trt-llm-infra-devs team and mini…
ZhanruiSunCh 7703c47
Revert "[TRTLLMINF-218][test] TEST-ONLY: use trt-llm-infra-devs team …
ZhanruiSunCh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,222 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| name: Guard Full Pre-Merge Approval Label | ||
|
|
||
| on: | ||
| # Intentional: this runs static default-branch API logic only. It never checks | ||
| # out or executes PR code; it uses GitHub APIs to validate membership and | ||
| # manage this PR's approval label/comment. | ||
| pull_request_target: | ||
| types: [labeled] | ||
|
|
||
| permissions: | ||
| contents: read | ||
| pull-requests: write | ||
|
|
||
| jobs: | ||
| guard-full-premerge-approval: | ||
| concurrency: | ||
| group: premerge-label-guard-${{ github.event.pull_request.number }} | ||
| cancel-in-progress: false | ||
| # Keep a started job eligible to reach fail-closed cleanup after cancellation. | ||
| if: >- | ||
| always() && | ||
| github.repository == 'NVIDIA/TensorRT-LLM' && | ||
| github.event.action == 'labeled' && | ||
| github.event.label.name == 'ci: full pre-merge approved' | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 5 | ||
| steps: | ||
| - name: Validate full pre-merge approver | ||
| id: validate | ||
| if: github.event.action == 'labeled' | ||
| uses: actions/github-script@v8 | ||
| with: | ||
| github-token: ${{ secrets.TRTLLM_AGENT_SHARED_TOKEN }} | ||
| result-encoding: string | ||
| script: | | ||
| const approvalLabel = 'ci: full pre-merge approved'; | ||
| const owner = context.repo.owner; | ||
| const repo = context.repo.repo; | ||
| const issueNumber = context.payload.pull_request.number; | ||
| let actor = context.payload.sender?.login || context.actor; | ||
| let labelEventId = ''; | ||
| let timelineVerified = false; | ||
|
|
||
| try { | ||
| const events = await github.paginate( | ||
| github.rest.issues.listEventsForTimeline, | ||
| { owner, repo, issue_number: issueNumber, per_page: 100 } | ||
| ); | ||
| const latestApprovalEvent = events | ||
| .filter( | ||
| (event) => | ||
| event.event === 'labeled' && | ||
| event.label?.name?.toLowerCase() === approvalLabel.toLowerCase() | ||
| ) | ||
| .at(-1); | ||
| if (latestApprovalEvent) { | ||
| actor = latestApprovalEvent.actor?.login || actor; | ||
| labelEventId = String(latestApprovalEvent.id); | ||
| timelineVerified = true; | ||
| } else { | ||
| core.warning('Could not identify the latest full pre-merge approval event.'); | ||
| } | ||
| } catch (error) { | ||
| core.warning( | ||
| 'Could not read the latest full pre-merge approval event: ' + error.message | ||
| ); | ||
| } | ||
|
|
||
| core.setOutput('validated_actor', actor); | ||
| core.setOutput('label_event_id', labelEventId); | ||
| if (!timelineVerified) { | ||
| return 'false'; | ||
| } | ||
| try { | ||
| const response = await github.request( | ||
| 'GET /orgs/{org}/teams/{team_slug}/memberships/{username}', | ||
| { | ||
| org: 'NVIDIA', | ||
| team_slug: 'trt-llm-ci-approvers', | ||
| username: actor, | ||
| } | ||
| ); | ||
| const authorized = response.data.state === 'active'; | ||
| console.log( | ||
| actor + ' active membership in NVIDIA/trt-llm-ci-approvers: ' + authorized | ||
| ); | ||
| return authorized ? 'true' : 'false'; | ||
| } catch (error) { | ||
| if (error.status === 404) { | ||
| console.log( | ||
| actor + ' is not an active member of NVIDIA/trt-llm-ci-approvers.' | ||
| ); | ||
| } else { | ||
| core.warning( | ||
| 'Could not verify full pre-merge approver ' + actor + ': ' + error.message | ||
| ); | ||
| } | ||
| return 'false'; | ||
| } | ||
|
|
||
| - name: Clear unauthorized full pre-merge approval | ||
| # Let a started job attempt fail-closed cleanup after normal cancellation. | ||
| if: always() && steps.validate.outputs.result != 'true' | ||
| uses: actions/github-script@v8 | ||
| env: | ||
| VALIDATED_ACTOR: ${{ steps.validate.outputs.validated_actor }} | ||
| VALIDATED_LABEL_EVENT_ID: ${{ steps.validate.outputs.label_event_id }} | ||
| with: | ||
| github-token: ${{ secrets.GITHUB_TOKEN }} | ||
| script: | | ||
| const approvalLabel = 'ci: full pre-merge approved'; | ||
| const actor = | ||
| process.env.VALIDATED_ACTOR || | ||
| context.payload.sender?.login || | ||
| context.actor; | ||
| const validatedEventId = process.env.VALIDATED_LABEL_EVENT_ID || ''; | ||
| const owner = context.repo.owner; | ||
| const repo = context.repo.repo; | ||
| const issueNumber = context.payload.pull_request.number; | ||
|
|
||
| try { | ||
| const pullRequest = await github.rest.pulls.get({ | ||
| owner, | ||
| repo, | ||
| pull_number: issueNumber, | ||
| }); | ||
| const labelIsPresent = pullRequest.data.labels.some( | ||
| (label) => | ||
| label.name?.toLowerCase() === approvalLabel.toLowerCase() | ||
| ); | ||
| if (!labelIsPresent) { | ||
| console.log('Full pre-merge approval label is already absent; no cleanup needed.'); | ||
| return; | ||
| } | ||
| } catch (error) { | ||
| core.warning( | ||
| 'Could not read the current full pre-merge approval label state; continuing validation: ' + | ||
| error.message | ||
| ); | ||
| } | ||
|
|
||
| try { | ||
| const events = await github.paginate( | ||
| github.rest.issues.listEventsForTimeline, | ||
| { owner, repo, issue_number: issueNumber, per_page: 100 } | ||
| ); | ||
| const latestApprovalEvent = events | ||
| .filter( | ||
| (event) => | ||
| event.event === 'labeled' && | ||
| event.label?.name?.toLowerCase() === approvalLabel.toLowerCase() | ||
| ) | ||
| .at(-1); | ||
| const latestEventId = latestApprovalEvent | ||
| ? String(latestApprovalEvent.id) | ||
| : ''; | ||
| const latestActor = latestApprovalEvent?.actor?.login || ''; | ||
| if (!latestApprovalEvent) { | ||
| core.warning( | ||
| 'Could not identify the latest full pre-merge approval event; removing the label to fail closed.' | ||
| ); | ||
| } else if (!latestActor) { | ||
| core.warning( | ||
| 'Could not identify the latest full pre-merge approval actor; removing the label to fail closed.' | ||
| ); | ||
| } else if (!validatedEventId) { | ||
| core.warning( | ||
| 'The validation run did not bind an approval event; removing the label to fail closed.' | ||
| ); | ||
| } else if ( | ||
| latestEventId !== validatedEventId || | ||
| latestActor !== actor | ||
| ) { | ||
| console.log( | ||
| 'A newer full pre-merge approval event was found; leaving it for its own validation run.' | ||
| ); | ||
| return; | ||
| } | ||
| } catch (error) { | ||
| core.warning( | ||
| 'Could not re-check the latest full pre-merge approval event; removing the label to fail closed: ' + | ||
| error.message | ||
| ); | ||
| } | ||
|
|
||
| try { | ||
| await github.rest.issues.removeLabel({ | ||
| owner, | ||
| repo, | ||
| issue_number: issueNumber, | ||
| name: approvalLabel, | ||
| }); | ||
| } catch (error) { | ||
| if (error.status !== 404) { | ||
| throw error; | ||
| } | ||
| } | ||
|
|
||
| await github.rest.issues.createComment({ | ||
| owner, | ||
| repo, | ||
| issue_number: issueNumber, | ||
| body: | ||
| 'Removed the "' + approvalLabel + '" label because @' + actor + | ||
| ' could not be verified as an active member of ' + | ||
| 'NVIDIA/trt-llm-ci-approvers. Ask a member of that team to apply it.', | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.