Small results-check refactor for debugging
parent
a195213baa
commit
7d6beda32f
File diff suppressed because one or more lines are too long
|
@ -9,7 +9,7 @@ import { RunMeta } from './ts/results-meta.ts';
|
||||||
class ResultsCheck {
|
class ResultsCheck {
|
||||||
static async createCheck(artifactsPath, githubToken, checkName) {
|
static async createCheck(artifactsPath, githubToken, checkName) {
|
||||||
// Validate input
|
// Validate input
|
||||||
if (!artifactsPath || !checkName || !githubToken) {
|
if (!fs.existsSync(artifactsPath) || !githubToken || !checkName) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Missing input! {"artifactsPath": "${artifactsPath}", "githubToken": "${githubToken}, "checkName": "${checkName}"`,
|
`Missing input! {"artifactsPath": "${artifactsPath}", "githubToken": "${githubToken}, "checkName": "${checkName}"`,
|
||||||
);
|
);
|
||||||
|
@ -46,24 +46,35 @@ class ResultsCheck {
|
||||||
core.info('Analyze result:');
|
core.info('Analyze result:');
|
||||||
core.info(runSummary.summary);
|
core.info(runSummary.summary);
|
||||||
|
|
||||||
// Call GitHub API
|
// Format output
|
||||||
await ResultsCheck.requestGitHubCheck(checkName, githubToken, runs, runSummary);
|
|
||||||
return runSummary.failed;
|
|
||||||
}
|
|
||||||
|
|
||||||
static async requestGitHubCheck(checkName, githubToken, runs, runSummary) {
|
|
||||||
const pullRequest = github.context.payload.pull_request;
|
|
||||||
const headSha = (pullRequest && pullRequest.head.sha) || github.context.sha;
|
|
||||||
|
|
||||||
const title = runSummary.summary;
|
const title = runSummary.summary;
|
||||||
const summary = await ResultsCheck.renderSummary(runs);
|
const summary = await ResultsCheck.renderSummary(runs);
|
||||||
|
core.debug(`Summary view: ${summary}`);
|
||||||
const details = await ResultsCheck.renderDetails(runs);
|
const details = await ResultsCheck.renderDetails(runs);
|
||||||
|
core.debug(`Details view: ${details}`);
|
||||||
const rawAnnotations = runSummary.extractAnnotations();
|
const rawAnnotations = runSummary.extractAnnotations();
|
||||||
|
core.debug(`Raw annotations: ${rawAnnotations}`);
|
||||||
const annotations = rawAnnotations.map(rawAnnotation => {
|
const annotations = rawAnnotations.map(rawAnnotation => {
|
||||||
const annotation = rawAnnotation;
|
const annotation = rawAnnotation;
|
||||||
annotation.path = rawAnnotation.path.replace('/github/workspace/', '');
|
annotation.path = rawAnnotation.path.replace('/github/workspace/', '');
|
||||||
return annotation;
|
return annotation;
|
||||||
});
|
});
|
||||||
|
core.debug(`Annotations: ${rawAnnotations}`);
|
||||||
|
const output = {
|
||||||
|
title,
|
||||||
|
summary,
|
||||||
|
text: details,
|
||||||
|
annotations: annotations.slice(0, 50),
|
||||||
|
};
|
||||||
|
|
||||||
|
// Call GitHub API
|
||||||
|
await ResultsCheck.requestGitHubCheck(githubToken, checkName, output);
|
||||||
|
return runSummary.failed;
|
||||||
|
}
|
||||||
|
|
||||||
|
static async requestGitHubCheck(githubToken, checkName, output) {
|
||||||
|
const pullRequest = github.context.payload.pull_request;
|
||||||
|
const headSha = (pullRequest && pullRequest.head.sha) || github.context.sha;
|
||||||
|
|
||||||
core.info(`Posting results for ${headSha}`);
|
core.info(`Posting results for ${headSha}`);
|
||||||
const createCheckRequest = {
|
const createCheckRequest = {
|
||||||
|
@ -72,12 +83,7 @@ class ResultsCheck {
|
||||||
head_sha: headSha,
|
head_sha: headSha,
|
||||||
status: 'completed',
|
status: 'completed',
|
||||||
conclusion: 'neutral',
|
conclusion: 'neutral',
|
||||||
output: {
|
output,
|
||||||
title,
|
|
||||||
summary,
|
|
||||||
text: details,
|
|
||||||
annotations: annotations.slice(0, 50),
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const octokit = github.getOctokit(githubToken);
|
const octokit = github.getOctokit(githubToken);
|
||||||
|
|
Loading…
Reference in New Issue