Skip to content

Commit

Permalink
Merge pull request #39197 from callstack-internal/pac-guerreiro/refac…
Browse files Browse the repository at this point in the history
…tor/migrate-25370-25371-25372-25373-to-typescript

[No QA][TS migration] Migrate 'reviewerChecklist.js', 'getReleaseBody.js', 'getPreviousVersion.js' and 'checkDeployBlockers.js' .github files to Typescript
  • Loading branch information
Beamanator authored Apr 4, 2024
2 parents f82f863 + c75db74 commit 0477ad1
Show file tree
Hide file tree
Showing 10 changed files with 373 additions and 4,644 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
const _ = require('underscore');
const core = require('@actions/core');
const CONST = require('../../../libs/CONST');
const GithubUtils = require('../../../libs/GithubUtils');
/* eslint-disable @typescript-eslint/naming-convention */
import * as core from '@actions/core';
import CONST from '@github/libs/CONST';
import GithubUtils from '@github/libs/GithubUtils';
import {isEmptyObject} from '@src/types/utils/EmptyObject';

const run = function () {
const run = function (): Promise<void> {
const issueNumber = Number(core.getInput('ISSUE_NUMBER', {required: true}));

console.log(`Fetching issue number ${issueNumber}`);
Expand All @@ -19,7 +20,7 @@ const run = function () {

// Check the issue description to see if there are any unfinished/un-QAed items in the checklist.
const uncheckedBoxRegex = /-\s\[\s]\s/;
if (uncheckedBoxRegex.test(data.body)) {
if (uncheckedBoxRegex.test(data.body ?? '')) {
console.log('An unverified PR or unresolved deploy blocker was found.');
core.setOutput('HAS_DEPLOY_BLOCKERS', true);
return;
Expand All @@ -37,12 +38,12 @@ const run = function () {

// 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)) {
if (comments === undefined) {
return;
}

// If there are no comments, then we have not yet gotten the :shipit: seal of approval.
if (_.isEmpty(comments.data)) {
if (isEmptyObject(comments.data)) {
console.log('No comments found on issue');
core.setOutput('HAS_DEPLOY_BLOCKERS', true);
return;
Expand All @@ -51,7 +52,7 @@ const run = function () {
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))) {
if (!shipItRegex.exec(lastComment?.body ?? '')) {
console.log('The last comment on the issue was not :shipit');
core.setOutput('HAS_DEPLOY_BLOCKERS', true);
} else {
Expand All @@ -69,4 +70,4 @@ if (require.main === module) {
run();
}

module.exports = run;
export default run;
Loading

0 comments on commit 0477ad1

Please sign in to comment.