Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return a promise #2308

Merged
merged 5 commits into from
Apr 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions .github/actions/checkDeployBlockers/checkDeployBlockers.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ const run = function () {
})
.then(({data}) => {
console.log('Checking for unverified PRs or unresolved deploy blockers', data);
const pattern = /-\s\[\s]/g;
const matches = pattern.exec(data.body);

// Check the issue description to see if there are any unfinished/un-QAed items in the checklist.
const uncheckedBoxRegex = /-\s\[\s]/g;
const matches = uncheckedBoxRegex.exec(data.body);
if (matches !== null) {
console.log('An unverified PR or unresolved deploy blocker was found.');
core.setOutput('HAS_DEPLOY_BLOCKERS', true);
Expand All @@ -28,21 +30,27 @@ const run = function () {
owner: GITHUB_OWNER,
repo: EXPENSIFY_CASH_REPO,
issue_number: issueNumber,
per_page: 100,
});
})
.then((issues) => {
if (_.isUndefined(issues)) {
.then((comments) => {
console.log('Checking the last comment for the :shipit: seal of approval', comments);

// If comments is undefined that means we found an unchecked QA item in the
// issue description, so there's nothing more to do but return early.
if (_.isUndefined(comments)) {
return;
}

if (_.isEmpty(issues.data)) {
// If there are no comments, then we have not yet gotten the :shipit: seal of approval.
if (_.isEmpty(comments.data)) {
console.log('No comments found on issue');
core.setOutput('HAS_DEPLOY_BLOCKERS', true);
return;
}

console.log('Verifying that the last comment is :shipit:');
const lastComment = issues.data[issues.data.length - 1];
console.log('Verifying that the last comment is the :shipit: seal of approval');
const lastComment = comments.data.pop();
const shipItRegex = /^:shipit:/g;
if (_.isNull(shipItRegex.exec(lastComment.body))) {
console.log('The last comment on the issue was not :shipit');
Expand Down
22 changes: 15 additions & 7 deletions .github/actions/checkDeployBlockers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ const run = function () {
})
.then(({data}) => {
console.log('Checking for unverified PRs or unresolved deploy blockers', data);
const pattern = /-\s\[\s]/g;
const matches = pattern.exec(data.body);

// Check the issue description to see if there are any unfinished/un-QAed items in the checklist.
const uncheckedBoxRegex = /-\s\[\s]/g;
const matches = uncheckedBoxRegex.exec(data.body);
if (matches !== null) {
console.log('An unverified PR or unresolved deploy blocker was found.');
core.setOutput('HAS_DEPLOY_BLOCKERS', true);
Expand All @@ -38,21 +40,27 @@ const run = function () {
owner: GITHUB_OWNER,
repo: EXPENSIFY_CASH_REPO,
issue_number: issueNumber,
per_page: 100,
});
})
.then((issues) => {
if (_.isUndefined(issues)) {
.then((comments) => {
console.log('Checking the last comment for the :shipit: seal of approval', comments);

// If comments is undefined that means we found an unchecked QA item in the
// issue description, so there's nothing more to do but return early.
if (_.isUndefined(comments)) {
return;
}

if (_.isEmpty(issues.data)) {
// If there are no comments, then we have not yet gotten the :shipit: seal of approval.
if (_.isEmpty(comments.data)) {
console.log('No comments found on issue');
core.setOutput('HAS_DEPLOY_BLOCKERS', true);
return;
}

console.log('Verifying that the last comment is :shipit:');
const lastComment = issues.data[issues.data.length - 1];
console.log('Verifying that the last comment is the :shipit: seal of approval');
const lastComment = comments.data.pop();
const shipItRegex = /^:shipit:/g;
if (_.isNull(shipItRegex.exec(lastComment.body))) {
console.log('The last comment on the issue was not :shipit');
Expand Down
4 changes: 2 additions & 2 deletions .github/actions/reopenIssueWithComment/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ const comment = core.getInput('COMMENT', {required: true});

function reopenIssueWithComment() {
console.log(`Reopening issue #${issueNumber}`);
octokit.issues.update({
return octokit.issues.update({
owner: GITHUB_OWNER,
repo: EXPENSIFY_CASH_REPO,
issue_number: issueNumber,
state: 'open',
})
.then(() => {
console.log(`Commenting on issue #${issueNumber}`);
octokit.issues.createComment({
return octokit.issues.createComment({
owner: GITHUB_OWNER,
repo: EXPENSIFY_CASH_REPO,
issue_number: issueNumber,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ const comment = core.getInput('COMMENT', {required: true});

function reopenIssueWithComment() {
console.log(`Reopening issue #${issueNumber}`);
octokit.issues.update({
return octokit.issues.update({
owner: GITHUB_OWNER,
repo: EXPENSIFY_CASH_REPO,
issue_number: issueNumber,
state: 'open',
})
.then(() => {
console.log(`Commenting on issue #${issueNumber}`);
octokit.issues.createComment({
return octokit.issues.createComment({
owner: GITHUB_OWNER,
repo: EXPENSIFY_CASH_REPO,
issue_number: issueNumber,
Expand Down