94057c3d3e
PR Test (NPU) / check-changes (push) Has been cancelled
PR Test (NPU) / pr-gate (push) Has been cancelled
PR Test (NPU) / set-image-config (push) Has been cancelled
PR Test (NPU) / stage-b-test-1-npu-a2 (0) (push) Has been cancelled
PR Test (NPU) / stage-b-test-1-npu-a2 (1) (push) Has been cancelled
PR Test (NPU) / stage-b-test-2-npu-a2 (0) (push) Has been cancelled
PR Test (NPU) / stage-b-test-2-npu-a2 (1) (push) Has been cancelled
PR Test (NPU) / stage-b-test-4-npu-a3 (push) Has been cancelled
PR Test (NPU) / stage-b-test-16-npu-a3 (push) Has been cancelled
PR Test (NPU) / multimodal-gen-test-1-npu-a3 (push) Has been cancelled
PR Test (NPU) / multimodal-gen-test-2-npu-a3 (push) Has been cancelled
PR Test (Arm64) / pr-gate (push) Has been cancelled
PR Test (Arm64) / check-changes (push) Has been cancelled
PR Test (Arm64) / build-test (push) Has been cancelled
PR Test (sgl-router) / gate (push) Has been cancelled
PR Test (sgl-router) / tier-1 — lint (push) Has been cancelled
PR Test (sgl-router) / tier-2 — build + test (push) Has been cancelled
PR Test (sgl-router) / tier-3 — docker (placeholder) (push) Has been cancelled
PR Test (sgl-router) / tier-3 — k8s integration (push) Has been cancelled
PR Test (sgl-router) / tier-3 — e2e (push) Has been cancelled
PR Test (sgl-router) / finish (push) Has been cancelled
PR Test (NPU) / single-node-poc (map[name:qwen3_6_27b_w8a8_1p_in64k_out1k_50ms runner:linux-aarch64-a3-2 test_case:test/registered/ascend/performance/qwen3_6_27b/test_npu_qwen3_6_27b_w8a8_1p_in64k_out1k_50ms.py test_type:perf]) (push) Has been cancelled
PR Test (NPU) / pr-test-npu-finish (push) Has been cancelled
PR Test (Xeon) / pr-gate (push) Has been cancelled
PR Test (Xeon) / check-changes (push) Has been cancelled
PR Test (Xeon) / build-test (, xeon-gnr, base-b-test-cpu) (push) Has been cancelled
PR Test (XPU) / check-changes (push) Has been cancelled
PR Test (XPU) / pr-gate (push) Has been cancelled
PR Test (XPU) / stage-a-test-1-gpu-xpu (push) Has been cancelled
PR Test (XPU) / wait-for-stage-a (push) Has been cancelled
PR Test (XPU) / stage-b-test-1-gpu-xpu (push) Has been cancelled
PR Test (XPU) / finish (push) Has been cancelled
CI Model Inventory / build-inventory (push) Has been cancelled
Lint / lint (push) Has been cancelled
PR Benchmark (SMG Components) / Benchmark Compilation Check (push) Has been cancelled
PR Benchmark (SMG Components) / Benchmark - Manual Policy (push) Has been cancelled
PR Benchmark (SMG Components) / Benchmark - Request Processing (push) Has been cancelled
PR Benchmark (SMG Components) / Benchmark Summary (push) Has been cancelled
PR Test (SMG) / build-wheel (push) Has been cancelled
Release SGLang Model Gateway to PyPI / build on windows (x86_64 - auto) (push) Has been cancelled
Release SGLang Model Gateway to PyPI / build on macos (x86_64 - auto) (push) Has been cancelled
PR Test (SMG) / python-unit-tests (push) Has been cancelled
PR Test (SMG) / unit-tests (push) Has been cancelled
PR Test (SMG) / benchmarks (push) Has been cancelled
PR Test (SMG) / chat-completions (push) Has been cancelled
PR Test (SMG) / chat-completions-4gpu (push) Has been cancelled
PR Test (SMG) / e2e (push) Has been cancelled
PR Test (SMG) / docker-build-test (push) Has been cancelled
PR Test (SMG) / k8s-integration (push) Has been cancelled
PR Test (SMG) / finish (push) Has been cancelled
PR Test (SMG) / summarize-benchmarks (push) Has been cancelled
Release SGLang Model Gateway Docker Image / publish (push) Has been cancelled
Release SGLang Model Gateway to PyPI / build on macos (aarch64 - auto) (push) Has been cancelled
Release SGLang Model Gateway to PyPI / build on linux (aarch64 - auto) (push) Has been cancelled
Release SGLang Model Gateway to PyPI / build on linux (x86_64 - auto) (push) Has been cancelled
Release SGLang Model Gateway to PyPI / build on linux (aarch64 - musllinux_1_1) (push) Has been cancelled
Release SGLang Model Gateway to PyPI / build on linux (x86_64 - musllinux_1_1) (push) Has been cancelled
Release SGLang Model Gateway to PyPI / Build SDist (push) Has been cancelled
Release SGLang Model Gateway to PyPI / Upload to PyPI (push) Has been cancelled
Release SGLang Kernels / build-cu129-matrix (aarch64, 12.9, 3.10, arm-kernel-build-node) (push) Has been cancelled
Release SGLang Kernels / build-cu129-matrix (x86_64, 12.9, 3.10, x64-kernel-build-node) (push) Has been cancelled
Release SGLang Kernels / release-cu129 (push) Has been cancelled
Release SGLang Kernels / build-cu130-matrix (aarch64, 13.0, 3.10, arm-kernel-build-node) (push) Has been cancelled
Release SGLang Kernels / build-cu130-matrix (x86_64, 13.0, 3.10, x64-kernel-build-node) (push) Has been cancelled
Release SGLang Kernels / release-cu130 (push) Has been cancelled
Release SGLang Kernels / build-rocm-matrix (3.10, 700) (push) Has been cancelled
Release SGLang Kernels / build-rocm-matrix (3.10, 720) (push) Has been cancelled
Release SGLang Kernels / release-rocm700 (push) Has been cancelled
Release SGLang Kernels / release-rocm720 (push) Has been cancelled
Release SGLang Kernels / build-musa43 (43, 3.10) (push) Has been cancelled
Release SGLang Kernels / release-musa43 (push) Has been cancelled
273 lines
12 KiB
YAML
273 lines
12 KiB
YAML
on:
|
|
workflow_call:
|
|
inputs:
|
|
require-run-ci:
|
|
description: "Whether the PR must have the run-ci label"
|
|
type: boolean
|
|
default: true
|
|
require-run-ci-extra:
|
|
description: "Whether the PR must also have the run-ci-extra label (in addition to run-ci)"
|
|
type: boolean
|
|
default: false
|
|
cool-down-minutes:
|
|
description: "Cooldown period in minutes for low-permission users; 0 disables rate limiting"
|
|
type: number
|
|
default: 120
|
|
|
|
jobs:
|
|
pr-gate:
|
|
# 1. for commits on main: no gating needed
|
|
# 2. for workflow_dispatch: this can only be triggered by users with write access
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Fetch latest PR info
|
|
if: github.event_name == 'pull_request'
|
|
id: pr
|
|
uses: actions/github-script@v8
|
|
with:
|
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
script: |
|
|
const pr = await github.rest.pulls.get({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
pull_number: context.issue.number
|
|
});
|
|
core.setOutput("labels", JSON.stringify(pr.data.labels.map(l => l.name)));
|
|
core.setOutput("draft", pr.data.draft);
|
|
core.setOutput("user", pr.data.user.login);
|
|
|
|
- name: Log PR info
|
|
if: github.event_name == 'pull_request'
|
|
run: |
|
|
echo "===== PR Info ====="
|
|
echo "PR Event: ${{ github.event_name }}"
|
|
echo "PR Labels: ${{ steps.pr.outputs.labels }}"
|
|
echo "PR Draft: ${{ steps.pr.outputs.draft }}"
|
|
echo "PR User: ${{ steps.pr.outputs.user }}"
|
|
echo "Require run-ci: ${{ inputs.require-run-ci }}"
|
|
echo "Require run-ci-extra: ${{ inputs.require-run-ci-extra }}"
|
|
echo "Cool down minutes: ${{ inputs.cool-down-minutes }}"
|
|
echo "==================="
|
|
|
|
- name: Block draft PR
|
|
if: github.event_name == 'pull_request' && fromJson(steps.pr.outputs.draft)
|
|
run: |
|
|
echo "PR is draft. Blocking CI."
|
|
exit 1
|
|
|
|
- name: Require run-ci label (optional)
|
|
if: github.event_name == 'pull_request' && inputs.require-run-ci == true
|
|
run: |
|
|
labels='${{ steps.pr.outputs.labels }}'
|
|
if [[ "${{ contains(fromJson(steps.pr.outputs.labels), 'run-ci') }}" == "false" ]]; then
|
|
echo "Missing required label 'run-ci'. See https://docs.sglang.io/developer_guide/contribution_guide.html#how-to-trigger-ci-tests for more details."
|
|
exit 1
|
|
fi
|
|
|
|
# Live-fetch label gate for pr-test-extra.yml. Workflow-level `if`
|
|
# checks would read the frozen event payload, which doesn't update on
|
|
# rerun — so /tag-and-rerun-ci extra (slash handler adds the label
|
|
# then reruns) could never un-skip. A runtime step using gh-api-fetched
|
|
# labels lets reruns pick up the new label set.
|
|
- name: Require run-ci-extra label (optional)
|
|
if: github.event_name == 'pull_request' && inputs.require-run-ci-extra == true
|
|
run: |
|
|
if [[ "${{ contains(fromJson(steps.pr.outputs.labels), 'run-ci-extra') }}" == "false" ]]; then
|
|
echo "Missing required label 'run-ci-extra'. Add the label (e.g. via /tag-and-rerun-ci extra) to opt this PR into the extra test workflow."
|
|
exit 1
|
|
fi
|
|
|
|
- name: Enforce rate limit for low-permission actors (optional)
|
|
if: github.event_name == 'pull_request' && inputs.cool-down-minutes > 0
|
|
uses: actions/github-script@v8
|
|
with:
|
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
script: |
|
|
const DEFAULT_MINUTES = Number("${{ inputs.cool-down-minutes }}");
|
|
const owner = context.repo.owner;
|
|
const repo = context.repo.repo;
|
|
const eventName = context.eventName;
|
|
const curRun = await github.rest.actions.getWorkflowRun({
|
|
owner, repo, run_id: context.runId
|
|
});
|
|
let triggeringActor = curRun.data.triggering_actor?.login || context.actor;
|
|
if (triggeringActor === "github-actions[bot]") {
|
|
triggeringActor = `${{ steps.pr.outputs.user }}`;
|
|
core.info(
|
|
`triggering_actor is github-actions[bot]; substituting PR author '${triggeringActor}'.`
|
|
);
|
|
}
|
|
|
|
async function hasHighPermission(username) {
|
|
try {
|
|
const { data } = await github.rest.repos.getCollaboratorPermissionLevel({ owner, repo, username });
|
|
const perm = data.permission || 'none';
|
|
return perm === 'write' || perm === 'maintain' || perm === 'admin';
|
|
} catch (e) {
|
|
if (e.status === 404 || e.status === 403) return false;
|
|
throw e;
|
|
}
|
|
}
|
|
|
|
if (await hasHighPermission(triggeringActor)) {
|
|
core.info(`Triggering user '${triggeringActor}' has high permission. No rate limit applied.`);
|
|
return;
|
|
}
|
|
|
|
let effectiveCooldownMinutes = DEFAULT_MINUTES;
|
|
let perUserCooldownMinutes = null;
|
|
|
|
try {
|
|
const contentResp = await github.rest.repos.getContent({
|
|
owner,
|
|
repo,
|
|
path: ".github/CI_PERMISSIONS.json",
|
|
ref: "main",
|
|
});
|
|
|
|
if (!Array.isArray(contentResp.data) && contentResp.data && "content" in contentResp.data) {
|
|
const raw = Buffer.from(
|
|
contentResp.data.content,
|
|
contentResp.data.encoding || "base64"
|
|
).toString();
|
|
const ciPermissions = JSON.parse(raw);
|
|
|
|
const userPerm = ciPermissions[triggeringActor];
|
|
if (userPerm && typeof userPerm.cooldown_interval_minutes === "number") {
|
|
perUserCooldownMinutes = userPerm.cooldown_interval_minutes;
|
|
core.info(
|
|
`Per-user cooldown for '${triggeringActor}' from CI_PERMISSIONS.json: ${perUserCooldownMinutes} minutes.`
|
|
);
|
|
} else {
|
|
core.info(`No per-user cooldown found for '${triggeringActor}' in CI_PERMISSIONS.json.`);
|
|
}
|
|
} else {
|
|
core.info("CI_PERMISSIONS.json content response is not a file; skipping per-user cooldown.");
|
|
}
|
|
} catch (e) {
|
|
core.info(`CI_PERMISSIONS.json not found or unreadable: ${e.message}. Using default rate limit only.`);
|
|
}
|
|
|
|
if (perUserCooldownMinutes !== null) {
|
|
effectiveCooldownMinutes = Math.min(effectiveCooldownMinutes, perUserCooldownMinutes);
|
|
}
|
|
|
|
if (effectiveCooldownMinutes <= 0) {
|
|
core.info(
|
|
`Effective cooldown for '${triggeringActor}' is 0 minutes; no rate limit enforced for this user.`
|
|
);
|
|
return;
|
|
}
|
|
|
|
const cutoff = new Date(Date.now() - effectiveCooldownMinutes * 60 * 1000);
|
|
core.info(
|
|
`Checking for workflow runs since ${cutoff.toISOString()} (last ${effectiveCooldownMinutes} minutes) for event '${eventName}'.`
|
|
);
|
|
|
|
const { data } = await github.rest.actions.listWorkflowRuns({
|
|
owner,
|
|
repo,
|
|
workflow_id: 'pr-test.yml',
|
|
event: eventName,
|
|
per_page: 100,
|
|
});
|
|
|
|
const runs = data.workflow_runs || [];
|
|
|
|
// Rate Limiting Logic:
|
|
// We only count workflow runs that actually consumed CI resources (i.e., passed the gate).
|
|
// A run "passes the gate" if any jobs beyond the gate jobs (check-changes, pr-gate, call-gate)
|
|
// actually executed (not skipped/cancelled). This prevents scenarios where:
|
|
// - User has PR A with missing 'run-ci' label (fails at gate)
|
|
// - User opens PR B with 'run-ci' label
|
|
// - PR B should be able to run even though PR A triggered a run recently
|
|
|
|
// Helper function to check if a run passed the gate (i.e., actually consumed CI resources)
|
|
async function didRunPassGate(run) {
|
|
try {
|
|
// Note: Fetching up to 100 jobs (API maximum). If a workflow has >100 jobs,
|
|
// we may miss some, but this is unlikely in practice.
|
|
const { data: jobsData } = await github.rest.actions.listJobsForWorkflowRun({
|
|
owner, repo, run_id: run.id, per_page: 100
|
|
});
|
|
const jobs = jobsData.jobs || [];
|
|
|
|
// If no jobs exist yet, the run hasn't started consuming resources
|
|
if (jobs.length === 0) {
|
|
core.info(`Run ${run.id} has no jobs yet; not counting against rate limit.`);
|
|
return false;
|
|
}
|
|
|
|
// Gate jobs that don't consume significant CI resources
|
|
const gateJobs = ['check-changes', 'pr-gate', 'call-gate', 'pr-test-finish'];
|
|
const jobsBeyondGate = jobs.filter(j => !gateJobs.some(g => j.name === g || j.name.startsWith(g + ' ')));
|
|
|
|
// A job "ran" if it reached a terminal conclusion state that indicates actual execution
|
|
const ranStates = ['success', 'failure', 'timed_out', 'action_required'];
|
|
const hasJobsThatRan = jobsBeyondGate.some(j => j.conclusion && ranStates.includes(j.conclusion));
|
|
return hasJobsThatRan;
|
|
} catch (e) {
|
|
core.warning(`Could not check jobs for run ${run.id}: ${e.message}`);
|
|
|
|
// If it's a rate limit error, count it conservatively to prevent abuse
|
|
if (e.status === 429) {
|
|
core.warning(`Hit rate limit checking run ${run.id}; counting it to be safe.`);
|
|
return true;
|
|
}
|
|
|
|
// For cancelled/skipped runs, they likely didn't consume resources
|
|
if (run.conclusion === 'cancelled' || run.conclusion === 'skipped') {
|
|
return false;
|
|
}
|
|
|
|
// Default to counting it to prevent abuse
|
|
return true;
|
|
}
|
|
}
|
|
|
|
// Limit the number of runs we'll check in detail to avoid API rate limits
|
|
const MAX_RUNS_TO_CHECK = 5;
|
|
let runsChecked = 0;
|
|
let runsSkippedAtGate = 0;
|
|
let recentFound = null;
|
|
|
|
for (const run of runs) {
|
|
if (String(run.id) === String(context.runId)) continue;
|
|
if (new Date(run.created_at) < cutoff) continue;
|
|
const isUserRun = (run.actor?.login === triggeringActor) || (run.triggering_actor?.login === triggeringActor);
|
|
if (!isUserRun) continue;
|
|
|
|
runsChecked++;
|
|
core.info(`Checking run ${run.id} (created: ${run.created_at}, conclusion: ${run.conclusion})`);
|
|
|
|
// Safety limit: if we've checked too many runs, assume the next one passed to be conservative
|
|
if (runsChecked > MAX_RUNS_TO_CHECK) {
|
|
core.warning(`Checked ${MAX_RUNS_TO_CHECK} runs; assuming this one passed gate to avoid API limits.`);
|
|
recentFound = run;
|
|
break;
|
|
}
|
|
|
|
// Only count runs that actually passed the gate and consumed CI resources
|
|
if (await didRunPassGate(run)) {
|
|
recentFound = run;
|
|
core.info(`Found recent run ${run.id} that passed gate.`);
|
|
break;
|
|
} else {
|
|
runsSkippedAtGate++;
|
|
core.info(`Run ${run.id} failed at gate; not counting against rate limit.`);
|
|
}
|
|
}
|
|
|
|
core.info(`Rate limit check summary: checked ${runsChecked} runs, ${runsSkippedAtGate} failed at gate.`);
|
|
|
|
if (recentFound) {
|
|
core.setFailed(
|
|
`User '${triggeringActor}' already triggered '${context.workflow}' via '${eventName}' at ${recentFound.created_at}. ` +
|
|
`Please wait ${effectiveCooldownMinutes} minutes before triggering again.`
|
|
);
|
|
} else {
|
|
core.info(
|
|
`No recent runs detected for '${triggeringActor}' within the last ${effectiveCooldownMinutes} minutes; proceeding.`
|
|
);
|
|
}
|