From 86308826f9b29ad749707d8911e5d2a117cecbc1 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 | 10 ++++++---- dist/run/index.js | 10 ++++++---- src/run.ts | 9 ++++++--- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/dist/post_run/index.js b/dist/post_run/index.js index 6113663d8f..836618c67a 100644 --- a/dist/post_run/index.js +++ b/dist/post_run/index.js @@ -6852,16 +6852,17 @@ 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, 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 +6907,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 +6917,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 4445381970..252831deff 100644 --- a/dist/run/index.js +++ b/dist/run/index.js @@ -6862,16 +6862,17 @@ 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, 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 +6917,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 +6927,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 5badd64f0e..b1f49ade0f 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,15 @@ async function annotateLintIssues(issues: LintIssue[]): Promise { return } const ctx = github.context - const ref = ctx.payload.after + core.info(inspect(ctx, 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 +295,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 {