Skip to content

[https://nvbugs/6702264][fix] Remove Cosmos3 offload test waiver #2044

[https://nvbugs/6702264][fix] Remove Cosmos3 offload test waiver

[https://nvbugs/6702264][fix] Remove Cosmos3 offload test waiver #2044

# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.

Check warning on line 1 in .github/workflows/post-merge-approval.yml

View workflow run for this annotation

GitHub Actions / Guard Post-Merge Approval Label

Workflow execution policy warning (evaluate mode)

On November 2, 2026, GitHub will restrict `pull_request_target` on public repositories by default. To continue allowing the event trigger, configure an Actions policy. Learn more: https://gh.io/securely-using-pull_request_target#default-policy-for-pull_request_target
# 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 Post-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-post-merge-approval:
concurrency:
group: post-merge-approval-${{ 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: post-merge approved'
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Validate post-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: post-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 post-merge approval event.');
}
} catch (error) {
core.warning(
'Could not read the latest post-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 post-merge approver ' + actor + ': ' + error.message
);
}
return 'false';
}
- name: Clear unauthorized post-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: post-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('Post-merge approval label is already absent; no cleanup needed.');
return;
}
} catch (error) {
core.warning(
'Could not read the current post-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 post-merge approval event; removing the label to fail closed.'
);
} else if (!latestActor) {
core.warning(
'Could not identify the latest post-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 post-merge approval event was found; leaving it for its own validation run.'
);
return;
}
} catch (error) {
core.warning(
'Could not re-check the latest post-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.',
});