diff --git a/bin/metadata.js b/bin/metadata.js index 0f97c7a0..01f3d025 100755 --- a/bin/metadata.js +++ b/bin/metadata.js @@ -55,7 +55,7 @@ async function main(prid, owner, repo) { const metadata = new MetadataGenerator(repo, pr, reviewers).getMetadata(); logger.info({ raw: metadata }, 'Generated metadata:'); - const checker = new PRChecker(pr, reviewers, comments); + const checker = new PRChecker(pr, reviewers, comments, reviews); checker.checkReviewers(); checker.checkReviews(); checker.checkPRWait(); diff --git a/lib/ci.js b/lib/ci.js index e073ac30..d286eb85 100644 --- a/lib/ci.js +++ b/lib/ci.js @@ -24,19 +24,23 @@ const CI_TYPES = new Map([ ]); class CIParser { - constructor(comments) { - this.comments = comments; + /** + * @param {{bodyText: string, publishedAt: string}[]} thread + */ + constructor(thread) { + this.thread = thread; } + /** + * @returns {Map} + */ parse() { - const comments = this.comments; - /** - * @type {Map} - */ + const thread = this.thread; const result = new Map(); - for (const c of comments) { - if (!c.bodyText.includes(CI_DOMAIN)) continue; - const cis = this.parseText(c.bodyText); + for (const c of thread) { + const text = c.bodyText; + if (!text.includes(CI_DOMAIN)) continue; + const cis = this.parseText(text); for (const ci of cis) { const entry = result.get(ci.type); if (!entry || entry.date < c.publishedAt) { @@ -48,7 +52,7 @@ class CIParser { } /** - * @param {string} text + * @param {string} text */ parseText(text) { const m = text.match(CI_RE); diff --git a/lib/pr_checker.js b/lib/pr_checker.js index 62f141a1..22c80c37 100644 --- a/lib/pr_checker.js +++ b/lib/pr_checker.js @@ -17,10 +17,11 @@ const CI_TYPES = CIParser.TYPES; const { FULL } = CIParser.constants; class PRChecker { - constructor(pr, reviewers, comments) { + constructor(pr, reviewers, comments, reviews) { this.reviewers = reviewers; this.pr = pr; this.comments = comments; + this.reviews = reviews; } checkReviews() { @@ -110,11 +111,13 @@ class PRChecker { // TODO: not all PR requires CI...labels? checkCI() { const comments = this.comments; + const reviews = this.reviews; const prNode = { publishedAt: this.pr.createdAt, bodyText: this.pr.bodyText }; - const ciMap = new CIParser(comments.concat([prNode])).parse(); + const thread = comments.concat([prNode]).concat(reviews); + const ciMap = new CIParser(thread).parse(); if (!ciMap.size) { logger.warn('No CI runs detected'); } else if (!ciMap.get(FULL)) { diff --git a/lib/reviews.js b/lib/reviews.js index 24e1571c..88717afa 100644 --- a/lib/reviews.js +++ b/lib/reviews.js @@ -11,11 +11,10 @@ const FROM_COMMENT = 'comment'; class Review { /** - * - * @param {string} state + * @param {string} state * @param {string} date // ISO date string - * @param {string} ref - * @param {string} source + * @param {string} ref + * @param {string} source */ constructor(state, date, ref, source) { this.state = state; @@ -27,8 +26,8 @@ class Review { class ReviewAnalyzer { /** - * @param {{}[]} reviewes - * @param {{}[]} comments + * @param {{}[]} reviewes + * @param {{}[]} comments * @param {Map} collaborators */ constructor(reviews, comments, collaborators) { @@ -78,7 +77,7 @@ class ReviewAnalyzer { // TODO: count -1 ...? But they should just make it explicit /** - * @param {Map} oldMap + * @param {Map} oldMap * @returns {Map} */ updateMapByRawReviews(oldMap) { diff --git a/queries/Reviews.gql b/queries/Reviews.gql index 6e9c2174..cb9374f9 100644 --- a/queries/Reviews.gql +++ b/queries/Reviews.gql @@ -8,6 +8,7 @@ query Reviews($prid: Int!, $owner: String!, $repo: String!, $after: String) { endCursor } nodes { + bodyText state author { login