Skip to content

Commit

Permalink
Highlight with warning colors for progressing jobs filename (#824)
Browse files Browse the repository at this point in the history
* Add `isCompleted` property in summary
* Highlight with warning colors for progressing jobs filename
  • Loading branch information
kachick authored Jun 2, 2024
1 parent 40238b2 commit 7c2c8d7
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 21 deletions.
12 changes: 7 additions & 5 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32350,10 +32350,12 @@ function groupBy(items, callback) {
// src/report.ts
function summarize(check, trigger) {
const { checkRun: run2, checkSuite: suite, workflow, workflowRun } = check;
const acceptable = run2.conclusion == "SUCCESS" || run2.conclusion === "SKIPPED" || run2.conclusion === "NEUTRAL" && (suite.conclusion === "SUCCESS" || suite.conclusion === "SKIPPED");
const isCompleted = run2.status === "COMPLETED";
const isAcceptable = run2.conclusion == "SUCCESS" || run2.conclusion === "SKIPPED" || run2.conclusion === "NEUTRAL" && (suite.conclusion === "SUCCESS" || suite.conclusion === "SKIPPED");
return {
acceptable,
severity: acceptable ? run2.status === "COMPLETED" ? "notice" : "warning" : "error",
isAcceptable,
isCompleted,
severity: isCompleted ? isAcceptable ? "notice" : "error" : "warning",
workflowBasename: relative(`/${trigger.owner}/${trigger.repo}/actions/workflows/`, workflow.resourcePath),
// Another file can set same workflow name. So you should filter workfrows from runId or the filename
isSameWorkflow: suite.workflowRun?.databaseId === trigger.runId,
Expand Down Expand Up @@ -32393,11 +32395,11 @@ function seekWaitList(summaries, waitList, elapsed) {
return { filtered, unmatches, unstarted };
}
function judge(summaries) {
const summariesByCompleted = groupBy(summaries, (summary) => summary.runStatus === "COMPLETED");
const summariesByCompleted = groupBy(summaries, (summary) => summary.isCompleted);
const completed = summariesByCompleted.get(true) || [];
const incompleted = summariesByCompleted.get(false) || [];
const done = incompleted.length === 0;
const failures = completed.filter((summary) => !summary.acceptable);
const failures = completed.filter((summary) => !summary.isAcceptable);
const ok = failures.length === 0;
const logs = [];
if (!ok) {
Expand Down
27 changes: 17 additions & 10 deletions src/report.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import { Temporal } from 'temporal-polyfill';

const exampleSummary = Object.freeze(
{
acceptable: false,
isAcceptable: false,
isCompleted: false,
workflowBasename: '.github/workflows/example.yml',
isSameWorkflow: false,

Expand Down Expand Up @@ -113,7 +114,8 @@ test('wait-list', async (t) => {
severity: 'info',
resource: [
{
acceptable: false,
isAcceptable: false,
isCompleted: false,
checkRunUrl: 'https://github.com/kachick/wait-other-jobs/actions/runs/9281068681/job/25536443631',
checkSuiteConclusion: null,
checkSuiteStatus: 'QUEUED',
Expand All @@ -123,7 +125,7 @@ test('wait-list', async (t) => {
runConclusion: null,
runDatabaseId: 25536443631,
runStatus: 'QUEUED',
severity: 'error',
severity: 'warning',
workflowBasename: 'GH-820-graceperiod.yml',
},
],
Expand Down Expand Up @@ -182,7 +184,8 @@ test('wait-list', async (t) => {
severity: 'info',
resource: [
{
acceptable: false,
isAcceptable: false,
isCompleted: false,
checkRunUrl: 'https://github.com/kachick/wait-other-jobs/actions/runs/9281068681/job/25536443631',
checkSuiteConclusion: null,
checkSuiteStatus: 'QUEUED',
Expand All @@ -192,7 +195,7 @@ test('wait-list', async (t) => {
runConclusion: null,
runDatabaseId: 25536443631,
runStatus: 'QUEUED',
severity: 'error',
severity: 'warning',
workflowBasename: 'GH-820-graceperiod.yml',
},
],
Expand Down Expand Up @@ -248,7 +251,8 @@ test('wait-list', async (t) => {
severity: 'info',
resource: [
{
acceptable: false,
isAcceptable: false,
isCompleted: false,
checkRunUrl: 'https://github.com/kachick/wait-other-jobs/actions/runs/9281068681/job/25536443631',
checkSuiteConclusion: null,
checkSuiteStatus: 'QUEUED',
Expand All @@ -258,7 +262,7 @@ test('wait-list', async (t) => {
runConclusion: null,
runDatabaseId: 25536443631,
runStatus: 'QUEUED',
severity: 'error',
severity: 'warning',
workflowBasename: 'GH-820-graceperiod.yml',
},
],
Expand Down Expand Up @@ -287,13 +291,15 @@ test('wait-list', async (t) => {
const report = generateReport(
[{
...exampleSummary,
acceptable: true,
isAcceptable: true,
isCompleted: true,
runStatus: 'COMPLETED',
workflowBasename: 'ci.yml',
jobName: 'quickstarter-success',
}, {
...exampleSummary,
acceptable: false,
isAcceptable: false,
isCompleted: true,
runStatus: 'COMPLETED',
workflowBasename: 'ci.yml',
jobName: 'quickstarter-fail',
Expand Down Expand Up @@ -334,7 +340,8 @@ test('wait-list', async (t) => {
severity: 'error',
resource: [
{
acceptable: false,
isAcceptable: false,
isCompleted: true,
checkRunUrl: 'https://example.com',
checkSuiteConclusion: 'FAILURE',
checkSuiteStatus: 'IN_PROGRESS',
Expand Down
15 changes: 9 additions & 6 deletions src/report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import { Temporal } from 'temporal-polyfill';
import { groupBy } from './util.ts';

export interface Summary {
acceptable: boolean;
isAcceptable: boolean;
isCompleted: boolean;
severity: Severity;
workflowBasename: string;
isSameWorkflow: boolean;
Expand All @@ -24,13 +25,15 @@ export interface Summary {

function summarize(check: Check, trigger: Trigger): Summary {
const { checkRun: run, checkSuite: suite, workflow, workflowRun } = check;
const acceptable = (run.conclusion == 'SUCCESS')
const isCompleted = run.status === 'COMPLETED';
const isAcceptable = (run.conclusion == 'SUCCESS')
|| (run.conclusion === 'SKIPPED')
|| (run.conclusion === 'NEUTRAL' && (suite.conclusion === 'SUCCESS' || suite.conclusion === 'SKIPPED'));

return {
acceptable,
severity: acceptable ? (run.status === 'COMPLETED' ? 'notice' : 'warning') : 'error',
isAcceptable,
isCompleted,
severity: isCompleted ? (isAcceptable ? 'notice' : 'error') : 'warning',
workflowBasename: relative(`/${trigger.owner}/${trigger.repo}/actions/workflows/`, workflow.resourcePath),
// Another file can set same workflow name. So you should filter workfrows from runId or the filename
isSameWorkflow: suite.workflowRun?.databaseId === trigger.runId,
Expand Down Expand Up @@ -98,11 +101,11 @@ function seekWaitList(
}

function judge(summaries: readonly Summary[]): { done: boolean; ok: boolean; logs: Log[] } {
const summariesByCompleted = groupBy(summaries, (summary) => summary.runStatus === 'COMPLETED');
const summariesByCompleted = groupBy(summaries, (summary) => summary.isCompleted);
const completed = summariesByCompleted.get(true) || [];
const incompleted = summariesByCompleted.get(false) || [];
const done = incompleted.length === 0;
const failures = completed.filter((summary) => !summary.acceptable);
const failures = completed.filter((summary) => !summary.isAcceptable);
const ok = failures.length === 0;
const logs: Log[] = [];

Expand Down

0 comments on commit 7c2c8d7

Please sign in to comment.