mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-07 08:26:10 +00:00
130 lines
4.8 KiB
YAML
130 lines
4.8 KiB
YAML
name: Report LiteLLM Rust release wheel
|
|
|
|
on: # zizmor: ignore[dangerous-triggers] reporter executes no PR code and consumes no PR artifacts or outputs
|
|
workflow_run:
|
|
workflows:
|
|
- LiteLLM Rust
|
|
types:
|
|
- completed
|
|
|
|
permissions: {}
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.event.workflow_run.pull_requests[0].number || github.event.workflow_run.id }}
|
|
cancel-in-progress: false
|
|
|
|
jobs:
|
|
report-release-wheel:
|
|
name: report release wheel
|
|
if: >-
|
|
github.event.workflow_run.event == 'pull_request' &&
|
|
github.event.workflow_run.path == '.github/workflows/test-rust.yml' &&
|
|
github.event.workflow_run.head_repository.full_name == github.repository &&
|
|
github.event.workflow_run.pull_requests[0].number != null
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 5
|
|
permissions:
|
|
issues: write # PR comments use the issues API
|
|
pull-requests: read # Current-head validation rejects stale workflow runs
|
|
|
|
steps:
|
|
- name: Link release wheel report on PR
|
|
uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7.1.0
|
|
env:
|
|
COMMENT_MARKER: "<!-- litellm-release-wheel-size -->"
|
|
with:
|
|
script: |
|
|
const marker = process.env.COMMENT_MARKER;
|
|
const workflowRun = context.payload.workflow_run;
|
|
const allowedConclusions = new Set([
|
|
"action_required",
|
|
"cancelled",
|
|
"failure",
|
|
"neutral",
|
|
"skipped",
|
|
"stale",
|
|
"startup_failure",
|
|
"success",
|
|
"timed_out",
|
|
]);
|
|
if (
|
|
!allowedConclusions.has(workflowRun.conclusion) ||
|
|
workflowRun.event !== "pull_request" ||
|
|
workflowRun.path !== ".github/workflows/test-rust.yml" ||
|
|
workflowRun.head_repository?.full_name !==
|
|
`${context.repo.owner}/${context.repo.repo}` ||
|
|
workflowRun.pull_requests?.length !== 1
|
|
) {
|
|
throw new Error("unexpected source workflow");
|
|
}
|
|
const pullRequest = workflowRun.pull_requests[0];
|
|
const pullRequestNumber = pullRequest.number;
|
|
const headSha = workflowRun.head_sha;
|
|
const runId = workflowRun.id;
|
|
if (
|
|
!Number.isSafeInteger(pullRequestNumber) ||
|
|
pullRequestNumber <= 0 ||
|
|
!Number.isSafeInteger(runId) ||
|
|
runId <= 0 ||
|
|
!/^[0-9a-f]{40}$/.test(headSha) ||
|
|
pullRequest.head?.sha !== headSha
|
|
) {
|
|
throw new Error("invalid source workflow metadata");
|
|
}
|
|
const runUrl =
|
|
`${context.serverUrl}/${context.repo.owner}/${context.repo.repo}` +
|
|
`/actions/runs/${runId}`;
|
|
const result =
|
|
workflowRun.conclusion === "success"
|
|
? "successfully"
|
|
: `with \`${workflowRun.conclusion}\``;
|
|
const body = [
|
|
marker,
|
|
"## LiteLLM Rust workflow",
|
|
"",
|
|
`Workflow completed ${result} for \`${headSha}\``,
|
|
"",
|
|
`[View workflow run](${runUrl})`,
|
|
].join("\n");
|
|
const comments = await github.paginate(github.rest.issues.listComments, {
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
issue_number: pullRequestNumber,
|
|
per_page: 100,
|
|
});
|
|
const existing = comments.find(
|
|
(comment) =>
|
|
comment.user?.login === "github-actions[bot]" &&
|
|
comment.body?.startsWith(marker),
|
|
);
|
|
const currentPullRequest = (
|
|
await github.rest.pulls.get({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
pull_number: pullRequestNumber,
|
|
})
|
|
).data;
|
|
if (
|
|
currentPullRequest.state !== "open" ||
|
|
currentPullRequest.head.repo?.full_name !==
|
|
`${context.repo.owner}/${context.repo.repo}` ||
|
|
currentPullRequest.head.sha !== headSha
|
|
) {
|
|
core.info("source workflow no longer matches the current pull request head");
|
|
return;
|
|
}
|
|
if (existing) {
|
|
await github.rest.issues.updateComment({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
comment_id: existing.id,
|
|
body,
|
|
});
|
|
} else {
|
|
await github.rest.issues.createComment({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
issue_number: pullRequestNumber,
|
|
body,
|
|
});
|
|
}
|