chore: tweak debugging output
This commit is contained in:
@@ -41,19 +41,30 @@ async function ghActionBot() {
|
|||||||
// keep track of comments that have been processed
|
// keep track of comments that have been processed
|
||||||
history.add(comment);
|
history.add(comment);
|
||||||
|
|
||||||
|
logger.debug(`PROCESS COMMENT ON #${comment.number}`);
|
||||||
|
|
||||||
const pull = await getPull(repo, comment.number);
|
const pull = await getPull(repo, comment.number);
|
||||||
|
|
||||||
|
// filter out any closed pulls
|
||||||
if (pull.state !== 'open') {
|
if (pull.state !== 'open') {
|
||||||
logger.debug(`SKIP #${pull.number}: state is ${pull.state}`);
|
logger.debug(`SKIP PULL #${pull.number}: state is ${pull.state}`);
|
||||||
return false; // filter out any closed pulls
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// filter on owner
|
||||||
if (PULL_AUTHOR_FILTER && pull.owner !== PULL_AUTHOR_FILTER) {
|
if (PULL_AUTHOR_FILTER && pull.owner !== PULL_AUTHOR_FILTER) {
|
||||||
logger.debug(`SKIP #${pull.number}: author is ${pull.owner}`);
|
logger.debug(`SKIP PULL #${pull.number}: author is ${pull.owner}`);
|
||||||
return false; // filter on owner
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// filter on label
|
||||||
if (PULL_LABEL_FILTER && !pull.labels.includes(PULL_LABEL_FILTER)) {
|
if (PULL_LABEL_FILTER && !pull.labels.includes(PULL_LABEL_FILTER)) {
|
||||||
logger.debug(`SKIP #${pull.number}: labels are ${pull.labels.join(',')}`);
|
logger.debug(
|
||||||
return false; // filter on label
|
`SKIP PULL #${
|
||||||
|
pull.number
|
||||||
|
}: labels missing '${PULL_LABEL_FILTER}', found ${pull.labels.join(',')}`
|
||||||
|
);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return { comment, pull };
|
return { comment, pull };
|
||||||
@@ -64,20 +75,18 @@ async function ghActionBot() {
|
|||||||
pulls.map(async ({ pull, comment }) => {
|
pulls.map(async ({ pull, comment }) => {
|
||||||
const commit = await getCommits(repo, pull.number, true);
|
const commit = await getCommits(repo, pull.number, true);
|
||||||
const buildStatus = await getCommitStatus(repo, commit.sha);
|
const buildStatus = await getCommitStatus(repo, commit.sha);
|
||||||
|
|
||||||
// do nothing if the build has not started, or is pending or successful
|
// do nothing if the build has not started, or is pending or successful
|
||||||
if (!buildStatus || buildStatus.state === 'pending' || buildStatus.state === 'success') {
|
if (!buildStatus || buildStatus.state === 'pending' || buildStatus.state === 'success') {
|
||||||
logger.debug(`SKIP #${pull.number}: build status is ${buildStatus.state}`);
|
logger.debug(`SKIP PULL #${pull.number}: build status is ${buildStatus.state}`);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return { comment, pull, commit, buildStatus };
|
return { comment, pull, commit, buildStatus };
|
||||||
})
|
})
|
||||||
)).filter(Boolean);
|
)).filter(Boolean);
|
||||||
|
|
||||||
if (records.length) {
|
logger.log(`${records.length ? `Found ${records.length}` : `≧(´▽`)≦ No`} outstanding failures`);
|
||||||
logger.log(`Found ${records.length} outstanding failures`);
|
|
||||||
} else {
|
|
||||||
logger.debug(`Found ${records.length} outstanding failures`);
|
|
||||||
}
|
|
||||||
|
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
records.map(record =>
|
records.map(record =>
|
||||||
|
|||||||
@@ -1,5 +1,10 @@
|
|||||||
import logger from './logger.mjs';
|
import logger from './logger.mjs';
|
||||||
|
|
||||||
|
function truncate(str, len = 26) {
|
||||||
|
if (str.length <= len) return str;
|
||||||
|
return `${str.slice(0, len)}...`;
|
||||||
|
}
|
||||||
|
|
||||||
export default async function getEvents(repo, { body, actor } = {}) {
|
export default async function getEvents(repo, { body, actor } = {}) {
|
||||||
const events = await repo.events.fetch();
|
const events = await repo.events.fetch();
|
||||||
|
|
||||||
@@ -32,14 +37,12 @@ export default async function getEvents(repo, { body, actor } = {}) {
|
|||||||
`SKIP EVENT ${isComment ? `#${comment.payload.issue.number}` : comment.id}: ${
|
`SKIP EVENT ${isComment ? `#${comment.payload.issue.number}` : comment.id}: ${
|
||||||
comment.type
|
comment.type
|
||||||
} ${comment.payload.action} by ${comment.actor.login}`,
|
} ${comment.payload.action} by ${comment.actor.login}`,
|
||||||
isComment && !bodyMatch && `(${comment.payload.comment.body.slice(0, 30)})`
|
isComment && !bodyMatch && `(${truncate(comment.payload.comment.body)})`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.debug(`PROCESS #${comment.payload.issue.number}`);
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
id: comment.id,
|
id: comment.id,
|
||||||
number: comment.payload.issue.number,
|
number: comment.payload.issue.number,
|
||||||
|
|||||||
Reference in New Issue
Block a user