UNPKG

@dapplion/benchmark

Version:

Ensures that new code does not introduce performance regressions with CI. Tracks:

29 lines (28 loc) 1.11 kB
import * as github from "@actions/github"; import { commetToPrUpdatable, commentToCommit } from "./octokit.js"; import { getGithubEventData, renderComment } from "../utils/index.js"; export async function postGaComment(resultsComp) { switch (github.context.eventName) { case "pull_request": { const eventData = getGithubEventData(); const prNumber = eventData.number; if (!prNumber) { throw Error("github event data has no PR number"); } // Build a comment to publish to a PR const commentBody = renderComment(resultsComp); await commetToPrUpdatable(prNumber, commentBody); break; } case "push": { // Only comment on performance regression if (resultsComp.someFailed) { const commentBody = renderComment(resultsComp); await commentToCommit(github.context.sha, commentBody); } break; } default: throw Error(`event not supported ${github.context.eventName}`); } }