From 94f1966589c6498630ee692b20ca88a4354ff421 Mon Sep 17 00:00:00 2001 From: Michael J Mulligan Date: Mon, 5 Apr 2021 16:14:37 +0100 Subject: [PATCH] WHAT DO YOU SEEEEEE --- dist/post_run/index.js | 22 ++++++++++++++++++---- dist/run/index.js | 22 ++++++++++++++++++---- src/run.ts | 27 ++++++++++++++++++++++++--- 3 files changed, 60 insertions(+), 11 deletions(-) diff --git a/dist/post_run/index.js b/dist/post_run/index.js index 6113663..4d982bd 100644 --- a/dist/post_run/index.js +++ b/dist/post_run/index.js @@ -6852,16 +6852,29 @@ const logLintIssues = (issues) => { }); }; function annotateLintIssues(issues) { - var _a; + var _a, _b; return __awaiter(this, void 0, void 0, function* () { if (!issues.length) { return; } const ctx = github.context; - const ref = ctx.payload.after; + core.info(util_1.inspect({ + ctx: ctx, + GITHUB_WORKFLOW: process.env["GITHUB_WORKFLOW"], + GITHUB_RUN_ID: process.env["GITHUB_RUN_ID"], + GITHUB_RUN_NUMBER: process.env["GITHUB_RUN_NUMBER"], + GITHUB_JOB: process.env["GITHUB_JOB"], + GITHUB_ACTION: process.env["GITHUB_ACTION"], + GITHUB_ACTIONS: process.env["GITHUB_ACTIONS"], + GITHUB_SHA: process.env["GITHUB_SHA"], + GITHUB_REF: process.env["GITHUB_REF"], + GITHUB_HEAD_REF: process.env["GITHUB_HEAD_REF"], + GITHUB_BASE_REF: process.env["GITHUB_BASE_REF"], + }, false, 4)); + const ref = (_a = ctx.payload.after) !== null && _a !== void 0 ? _a : ctx.sha; const octokit = github.getOctokit(core.getInput(`github-token`, { required: true })); const checkRunsPromise = octokit.checks - .listForRef(Object.assign(Object.assign({}, ctx.repo), { ref, status: "in_progress" })) + .listForRef(Object.assign(Object.assign({}, ctx.repo), { ref, status: `in_progress`, filter: `latest` })) .catch((e) => { throw `Error getting Check Run Data: ${e}`; }); @@ -6906,6 +6919,7 @@ function annotateLintIssues(issues) { }); let checkRun; const { data: checkRunsResponse } = yield checkRunsPromise; + core.info(util_1.inspect(checkRunsResponse, false, 4)); if (checkRunsResponse.check_runs.length === 0) { throw `octokit.checks.listForRef(${ref}) returned no results`; } @@ -6915,7 +6929,7 @@ function annotateLintIssues(issues) { if (!(checkRun === null || checkRun === void 0 ? void 0 : checkRun.id)) { throw `Could not find current check run`; } - const title = (_a = checkRun.output.title) !== null && _a !== void 0 ? _a : `GolangCI-Lint`; + const title = (_b = checkRun.output.title) !== null && _b !== void 0 ? _b : `GolangCI-Lint`; const summary = `There are {issueCounts.failure} failures, {issueCounts.wairning} warnings, and {issueCounts.notice} notices.`; Array.from({ length: Math.ceil(githubAnnotations.length / chunkSize) }, (v, i) => githubAnnotations.slice(i * chunkSize, i * chunkSize + chunkSize)).forEach((annotations) => { octokit.checks diff --git a/dist/run/index.js b/dist/run/index.js index 4445381..caf6c46 100644 --- a/dist/run/index.js +++ b/dist/run/index.js @@ -6862,16 +6862,29 @@ const logLintIssues = (issues) => { }); }; function annotateLintIssues(issues) { - var _a; + var _a, _b; return __awaiter(this, void 0, void 0, function* () { if (!issues.length) { return; } const ctx = github.context; - const ref = ctx.payload.after; + core.info(util_1.inspect({ + ctx: ctx, + GITHUB_WORKFLOW: process.env["GITHUB_WORKFLOW"], + GITHUB_RUN_ID: process.env["GITHUB_RUN_ID"], + GITHUB_RUN_NUMBER: process.env["GITHUB_RUN_NUMBER"], + GITHUB_JOB: process.env["GITHUB_JOB"], + GITHUB_ACTION: process.env["GITHUB_ACTION"], + GITHUB_ACTIONS: process.env["GITHUB_ACTIONS"], + GITHUB_SHA: process.env["GITHUB_SHA"], + GITHUB_REF: process.env["GITHUB_REF"], + GITHUB_HEAD_REF: process.env["GITHUB_HEAD_REF"], + GITHUB_BASE_REF: process.env["GITHUB_BASE_REF"], + }, false, 4)); + const ref = (_a = ctx.payload.after) !== null && _a !== void 0 ? _a : ctx.sha; const octokit = github.getOctokit(core.getInput(`github-token`, { required: true })); const checkRunsPromise = octokit.checks - .listForRef(Object.assign(Object.assign({}, ctx.repo), { ref, status: "in_progress" })) + .listForRef(Object.assign(Object.assign({}, ctx.repo), { ref, status: `in_progress`, filter: `latest` })) .catch((e) => { throw `Error getting Check Run Data: ${e}`; }); @@ -6916,6 +6929,7 @@ function annotateLintIssues(issues) { }); let checkRun; const { data: checkRunsResponse } = yield checkRunsPromise; + core.info(util_1.inspect(checkRunsResponse, false, 4)); if (checkRunsResponse.check_runs.length === 0) { throw `octokit.checks.listForRef(${ref}) returned no results`; } @@ -6925,7 +6939,7 @@ function annotateLintIssues(issues) { if (!(checkRun === null || checkRun === void 0 ? void 0 : checkRun.id)) { throw `Could not find current check run`; } - const title = (_a = checkRun.output.title) !== null && _a !== void 0 ? _a : `GolangCI-Lint`; + const title = (_b = checkRun.output.title) !== null && _b !== void 0 ? _b : `GolangCI-Lint`; const summary = `There are {issueCounts.failure} failures, {issueCounts.wairning} warnings, and {issueCounts.notice} notices.`; Array.from({ length: Math.ceil(githubAnnotations.length / chunkSize) }, (v, i) => githubAnnotations.slice(i * chunkSize, i * chunkSize + chunkSize)).forEach((annotations) => { octokit.checks diff --git a/src/run.ts b/src/run.ts index 5badd64..4f19c78 100644 --- a/src/run.ts +++ b/src/run.ts @@ -5,7 +5,7 @@ import { exec, ExecOptions } from "child_process" import * as fs from "fs" import * as path from "path" import { dir } from "tmp" -import { promisify } from "util" +import { inspect, promisify } from "util" import { restoreCache, saveCache } from "./cache" import { installGo, installLint } from "./install" @@ -236,13 +236,33 @@ async function annotateLintIssues(issues: LintIssue[]): Promise { return } const ctx = github.context - const ref = ctx.payload.after + core.info( + inspect( + { + ctx: ctx, + GITHUB_WORKFLOW: process.env["GITHUB_WORKFLOW"], + GITHUB_RUN_ID: process.env["GITHUB_RUN_ID"], + GITHUB_RUN_NUMBER: process.env["GITHUB_RUN_NUMBER"], + GITHUB_JOB: process.env["GITHUB_JOB"], + GITHUB_ACTION: process.env["GITHUB_ACTION"], + GITHUB_ACTIONS: process.env["GITHUB_ACTIONS"], + GITHUB_SHA: process.env["GITHUB_SHA"], + GITHUB_REF: process.env["GITHUB_REF"], + GITHUB_HEAD_REF: process.env["GITHUB_HEAD_REF"], + GITHUB_BASE_REF: process.env["GITHUB_BASE_REF"], + }, + false, + 4 + ) + ) + const ref = ctx.payload.after ?? ctx.sha const octokit = github.getOctokit(core.getInput(`github-token`, { required: true })) const checkRunsPromise = octokit.checks .listForRef({ ...ctx.repo, ref, - status: "in_progress", + status: `in_progress`, + filter: `latest`, }) .catch((e) => { throw `Error getting Check Run Data: ${e}` @@ -293,6 +313,7 @@ async function annotateLintIssues(issues: LintIssue[]): Promise { ) let checkRun: CheckRun | undefined const { data: checkRunsResponse } = await checkRunsPromise + core.info(inspect(checkRunsResponse, false, 4)) if (checkRunsResponse.check_runs.length === 0) { throw `octokit.checks.listForRef(${ref}) returned no results` } else {