diff --git a/.github/actions/javascript/authorChecklist/index.js b/.github/actions/javascript/authorChecklist/index.js index 586ba3285500..f09d586b629c 100644 --- a/.github/actions/javascript/authorChecklist/index.js +++ b/.github/actions/javascript/authorChecklist/index.js @@ -77,6 +77,29 @@ getNumberOfItemsFromAuthorChecklist() }); +/***/ }), + +/***/ 4097: +/***/ ((module) => { + +const CONST = { + GITHUB_OWNER: 'Expensify', + APP_REPO: 'App', + APPLAUSE_BOT: 'applausebot', + OS_BOTIFY: 'OSBotify', + LABELS: { + STAGING_DEPLOY: 'StagingDeployCash', + DEPLOY_BLOCKER: 'DeployBlockerCash', + INTERNAL_QA: 'InternalQA', + }, +}; + +CONST.APP_REPO_URL = `https://github.com/${CONST.GITHUB_OWNER}/${CONST.APP_REPO}`; +CONST.APP_REPO_GIT_URL = `git@github.com:${CONST.GITHUB_OWNER}/${CONST.APP_REPO}.git`; + +module.exports = CONST; + + /***/ }), /***/ 7999: @@ -88,21 +111,13 @@ const core = __nccwpck_require__(2186); const {GitHub, getOctokitOptions} = __nccwpck_require__(3030); const {throttling} = __nccwpck_require__(9968); const {paginateRest} = __nccwpck_require__(4193); - -const GITHUB_OWNER = 'Expensify'; -const APP_REPO = 'App'; -const APP_REPO_URL = 'https://github.com/Expensify/App'; +const CONST = __nccwpck_require__(4097); const GITHUB_BASE_URL_REGEX = new RegExp('https?://(?:github\\.com|api\\.github\\.com)'); const PULL_REQUEST_REGEX = new RegExp(`${GITHUB_BASE_URL_REGEX.source}/.*/.*/pull/([0-9]+).*`); const ISSUE_REGEX = new RegExp(`${GITHUB_BASE_URL_REGEX.source}/.*/.*/issues/([0-9]+).*`); const ISSUE_OR_PULL_REQUEST_REGEX = new RegExp(`${GITHUB_BASE_URL_REGEX.source}/.*/.*/(?:pull|issues)/([0-9]+).*`); -const APPLAUSE_BOT = 'applausebot'; -const STAGING_DEPLOY_CASH_LABEL = 'StagingDeployCash'; -const DEPLOY_BLOCKER_CASH_LABEL = 'DeployBlockerCash'; -const INTERNAL_QA_LABEL = 'InternalQA'; - /** * The standard rate in ms at which we'll poll the GitHub API to check for status changes. * It's 10 seconds :) @@ -180,20 +195,20 @@ class GithubUtils { static getStagingDeployCash() { return this.octokit.issues .listForRepo({ - owner: GITHUB_OWNER, - repo: APP_REPO, - labels: STAGING_DEPLOY_CASH_LABEL, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, + labels: CONST.LABELS.STAGING_DEPLOY, state: 'open', }) .then(({data}) => { if (!data.length) { - const error = new Error(`Unable to find ${STAGING_DEPLOY_CASH_LABEL} issue.`); + const error = new Error(`Unable to find ${CONST.LABELS.STAGING_DEPLOY} issue.`); error.code = 404; throw error; } if (data.length > 1) { - const error = new Error(`Found more than one ${STAGING_DEPLOY_CASH_LABEL} issue.`); + const error = new Error(`Found more than one ${CONST.LABELS.STAGING_DEPLOY} issue.`); error.code = 500; throw error; } @@ -226,7 +241,7 @@ class GithubUtils { tag, }; } catch (exception) { - throw new Error(`Unable to find ${STAGING_DEPLOY_CASH_LABEL} issue with correct data.`); + throw new Error(`Unable to find ${CONST.LABELS.STAGING_DEPLOY} issue with correct data.`); } } @@ -334,7 +349,7 @@ class GithubUtils { // 'https://github.com/Expensify/App/pull/9642': [ 'mountiny', 'kidroca' ] // } const internalQAPRMap = _.reduce( - _.filter(data, (pr) => !_.isEmpty(_.findWhere(pr.labels, {name: INTERNAL_QA_LABEL}))), + _.filter(data, (pr) => !_.isEmpty(_.findWhere(pr.labels, {name: CONST.LABELS.INTERNAL_QA}))), (map, pr) => { // eslint-disable-next-line no-param-reassign map[pr.html_url] = _.compact(_.pluck(pr.assignees, 'login')); @@ -422,8 +437,8 @@ class GithubUtils { return this.paginate( this.octokit.pulls.list, { - owner: GITHUB_OWNER, - repo: APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, state: 'all', sort: 'created', direction: 'desc', @@ -447,8 +462,8 @@ class GithubUtils { static getPullRequestBody(pullRequestNumber) { return this.octokit.pulls .get({ - owner: GITHUB_OWNER, - repo: APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, pull_number: pullRequestNumber, }) .then(({data: pullRequestComment}) => pullRequestComment.body); @@ -462,8 +477,8 @@ class GithubUtils { return this.paginate( this.octokit.pulls.listReviews, { - owner: GITHUB_OWNER, - repo: APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, pull_number: pullRequestNumber, per_page: 100, }, @@ -479,8 +494,8 @@ class GithubUtils { return this.paginate( this.octokit.issues.listComments, { - owner: GITHUB_OWNER, - repo: APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, issue_number: issueNumber, per_page: 100, }, @@ -499,7 +514,7 @@ class GithubUtils { static createComment(repo, number, messageBody) { console.log(`Writing comment on #${number}`); return this.octokit.issues.createComment({ - owner: GITHUB_OWNER, + owner: CONST.GITHUB_OWNER, repo, issue_number: number, body: messageBody, @@ -516,8 +531,8 @@ class GithubUtils { console.log(`Fetching New Expensify workflow runs for ${workflow}...`); return this.octokit.actions .listWorkflowRuns({ - owner: GITHUB_OWNER, - repo: APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, workflow_id: workflow, }) .then((response) => lodashGet(response, 'data.workflow_runs[0].id')); @@ -540,7 +555,7 @@ class GithubUtils { * @returns {String} */ static getPullRequestURLFromNumber(number) { - return `${APP_REPO_URL}/pull/${number}`; + return `${CONST.APP_REPO_URL}/pull/${number}`; } /** @@ -595,7 +610,7 @@ class GithubUtils { * @returns {Boolean} */ static isAutomatedPullRequest(pullRequest) { - return _.isEqual(lodashGet(pullRequest, 'user.login', ''), 'OSBotify'); + return _.isEqual(lodashGet(pullRequest, 'user.login', ''), CONST.OS_BOTIFY); } /** @@ -606,8 +621,8 @@ class GithubUtils { */ static getActorWhoClosedIssue(issueNumber) { return this.paginate(this.octokit.issues.listEvents, { - owner: GITHUB_OWNER, - repo: APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, issue_number: issueNumber, per_page: 100, }) @@ -617,12 +632,6 @@ class GithubUtils { } module.exports = GithubUtils; -module.exports.GITHUB_OWNER = GITHUB_OWNER; -module.exports.APP_REPO = APP_REPO; -module.exports.APP_REPO_URL = APP_REPO_URL; -module.exports.STAGING_DEPLOY_CASH_LABEL = STAGING_DEPLOY_CASH_LABEL; -module.exports.DEPLOY_BLOCKER_CASH_LABEL = DEPLOY_BLOCKER_CASH_LABEL; -module.exports.APPLAUSE_BOT = APPLAUSE_BOT; module.exports.ISSUE_OR_PULL_REQUEST_REGEX = ISSUE_OR_PULL_REQUEST_REGEX; module.exports.POLL_RATE = POLL_RATE; diff --git a/.github/actions/javascript/awaitStagingDeploys/awaitStagingDeploys.js b/.github/actions/javascript/awaitStagingDeploys/awaitStagingDeploys.js index d645e669bc91..02cdcfa5e11f 100644 --- a/.github/actions/javascript/awaitStagingDeploys/awaitStagingDeploys.js +++ b/.github/actions/javascript/awaitStagingDeploys/awaitStagingDeploys.js @@ -1,4 +1,5 @@ const _ = require('underscore'); +const CONST = require('../../../libs/CONST'); const ActionUtils = require('../../../libs/ActionUtils'); const GitHubUtils = require('../../../libs/GithubUtils'); const {promiseDoWhile} = require('../../../libs/promiseWhile'); @@ -13,8 +14,8 @@ function run() { Promise.all([ // These are active deploys GitHubUtils.octokit.actions.listWorkflowRuns({ - owner: GitHubUtils.GITHUB_OWNER, - repo: GitHubUtils.APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, workflow_id: 'platformDeploy.yml', event: 'push', branch: tag, @@ -24,8 +25,8 @@ function run() { // In this context, we'll refer to unresolved preDeploy workflow runs as staging deploys as well !tag && GitHubUtils.octokit.actions.listWorkflowRuns({ - owner: GitHubUtils.GITHUB_OWNER, - repo: GitHubUtils.APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, workflow_id: 'preDeploy.yml', }), ]) diff --git a/.github/actions/javascript/awaitStagingDeploys/index.js b/.github/actions/javascript/awaitStagingDeploys/index.js index b705112bc1ba..c2948688b83a 100644 --- a/.github/actions/javascript/awaitStagingDeploys/index.js +++ b/.github/actions/javascript/awaitStagingDeploys/index.js @@ -9,6 +9,7 @@ module.exports = /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { const _ = __nccwpck_require__(3571); +const CONST = __nccwpck_require__(4097); const ActionUtils = __nccwpck_require__(970); const GitHubUtils = __nccwpck_require__(7999); const {promiseDoWhile} = __nccwpck_require__(4502); @@ -23,8 +24,8 @@ function run() { Promise.all([ // These are active deploys GitHubUtils.octokit.actions.listWorkflowRuns({ - owner: GitHubUtils.GITHUB_OWNER, - repo: GitHubUtils.APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, workflow_id: 'platformDeploy.yml', event: 'push', branch: tag, @@ -34,8 +35,8 @@ function run() { // In this context, we'll refer to unresolved preDeploy workflow runs as staging deploys as well !tag && GitHubUtils.octokit.actions.listWorkflowRuns({ - owner: GitHubUtils.GITHUB_OWNER, - repo: GitHubUtils.APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, workflow_id: 'preDeploy.yml', }), ]) @@ -114,6 +115,29 @@ module.exports = { }; +/***/ }), + +/***/ 4097: +/***/ ((module) => { + +const CONST = { + GITHUB_OWNER: 'Expensify', + APP_REPO: 'App', + APPLAUSE_BOT: 'applausebot', + OS_BOTIFY: 'OSBotify', + LABELS: { + STAGING_DEPLOY: 'StagingDeployCash', + DEPLOY_BLOCKER: 'DeployBlockerCash', + INTERNAL_QA: 'InternalQA', + }, +}; + +CONST.APP_REPO_URL = `https://github.com/${CONST.GITHUB_OWNER}/${CONST.APP_REPO}`; +CONST.APP_REPO_GIT_URL = `git@github.com:${CONST.GITHUB_OWNER}/${CONST.APP_REPO}.git`; + +module.exports = CONST; + + /***/ }), /***/ 7999: @@ -125,21 +149,13 @@ const core = __nccwpck_require__(2186); const {GitHub, getOctokitOptions} = __nccwpck_require__(3030); const {throttling} = __nccwpck_require__(9968); const {paginateRest} = __nccwpck_require__(4193); - -const GITHUB_OWNER = 'Expensify'; -const APP_REPO = 'App'; -const APP_REPO_URL = 'https://github.com/Expensify/App'; +const CONST = __nccwpck_require__(4097); const GITHUB_BASE_URL_REGEX = new RegExp('https?://(?:github\\.com|api\\.github\\.com)'); const PULL_REQUEST_REGEX = new RegExp(`${GITHUB_BASE_URL_REGEX.source}/.*/.*/pull/([0-9]+).*`); const ISSUE_REGEX = new RegExp(`${GITHUB_BASE_URL_REGEX.source}/.*/.*/issues/([0-9]+).*`); const ISSUE_OR_PULL_REQUEST_REGEX = new RegExp(`${GITHUB_BASE_URL_REGEX.source}/.*/.*/(?:pull|issues)/([0-9]+).*`); -const APPLAUSE_BOT = 'applausebot'; -const STAGING_DEPLOY_CASH_LABEL = 'StagingDeployCash'; -const DEPLOY_BLOCKER_CASH_LABEL = 'DeployBlockerCash'; -const INTERNAL_QA_LABEL = 'InternalQA'; - /** * The standard rate in ms at which we'll poll the GitHub API to check for status changes. * It's 10 seconds :) @@ -217,20 +233,20 @@ class GithubUtils { static getStagingDeployCash() { return this.octokit.issues .listForRepo({ - owner: GITHUB_OWNER, - repo: APP_REPO, - labels: STAGING_DEPLOY_CASH_LABEL, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, + labels: CONST.LABELS.STAGING_DEPLOY, state: 'open', }) .then(({data}) => { if (!data.length) { - const error = new Error(`Unable to find ${STAGING_DEPLOY_CASH_LABEL} issue.`); + const error = new Error(`Unable to find ${CONST.LABELS.STAGING_DEPLOY} issue.`); error.code = 404; throw error; } if (data.length > 1) { - const error = new Error(`Found more than one ${STAGING_DEPLOY_CASH_LABEL} issue.`); + const error = new Error(`Found more than one ${CONST.LABELS.STAGING_DEPLOY} issue.`); error.code = 500; throw error; } @@ -263,7 +279,7 @@ class GithubUtils { tag, }; } catch (exception) { - throw new Error(`Unable to find ${STAGING_DEPLOY_CASH_LABEL} issue with correct data.`); + throw new Error(`Unable to find ${CONST.LABELS.STAGING_DEPLOY} issue with correct data.`); } } @@ -371,7 +387,7 @@ class GithubUtils { // 'https://github.com/Expensify/App/pull/9642': [ 'mountiny', 'kidroca' ] // } const internalQAPRMap = _.reduce( - _.filter(data, (pr) => !_.isEmpty(_.findWhere(pr.labels, {name: INTERNAL_QA_LABEL}))), + _.filter(data, (pr) => !_.isEmpty(_.findWhere(pr.labels, {name: CONST.LABELS.INTERNAL_QA}))), (map, pr) => { // eslint-disable-next-line no-param-reassign map[pr.html_url] = _.compact(_.pluck(pr.assignees, 'login')); @@ -459,8 +475,8 @@ class GithubUtils { return this.paginate( this.octokit.pulls.list, { - owner: GITHUB_OWNER, - repo: APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, state: 'all', sort: 'created', direction: 'desc', @@ -484,8 +500,8 @@ class GithubUtils { static getPullRequestBody(pullRequestNumber) { return this.octokit.pulls .get({ - owner: GITHUB_OWNER, - repo: APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, pull_number: pullRequestNumber, }) .then(({data: pullRequestComment}) => pullRequestComment.body); @@ -499,8 +515,8 @@ class GithubUtils { return this.paginate( this.octokit.pulls.listReviews, { - owner: GITHUB_OWNER, - repo: APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, pull_number: pullRequestNumber, per_page: 100, }, @@ -516,8 +532,8 @@ class GithubUtils { return this.paginate( this.octokit.issues.listComments, { - owner: GITHUB_OWNER, - repo: APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, issue_number: issueNumber, per_page: 100, }, @@ -536,7 +552,7 @@ class GithubUtils { static createComment(repo, number, messageBody) { console.log(`Writing comment on #${number}`); return this.octokit.issues.createComment({ - owner: GITHUB_OWNER, + owner: CONST.GITHUB_OWNER, repo, issue_number: number, body: messageBody, @@ -553,8 +569,8 @@ class GithubUtils { console.log(`Fetching New Expensify workflow runs for ${workflow}...`); return this.octokit.actions .listWorkflowRuns({ - owner: GITHUB_OWNER, - repo: APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, workflow_id: workflow, }) .then((response) => lodashGet(response, 'data.workflow_runs[0].id')); @@ -577,7 +593,7 @@ class GithubUtils { * @returns {String} */ static getPullRequestURLFromNumber(number) { - return `${APP_REPO_URL}/pull/${number}`; + return `${CONST.APP_REPO_URL}/pull/${number}`; } /** @@ -632,7 +648,7 @@ class GithubUtils { * @returns {Boolean} */ static isAutomatedPullRequest(pullRequest) { - return _.isEqual(lodashGet(pullRequest, 'user.login', ''), 'OSBotify'); + return _.isEqual(lodashGet(pullRequest, 'user.login', ''), CONST.OS_BOTIFY); } /** @@ -643,8 +659,8 @@ class GithubUtils { */ static getActorWhoClosedIssue(issueNumber) { return this.paginate(this.octokit.issues.listEvents, { - owner: GITHUB_OWNER, - repo: APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, issue_number: issueNumber, per_page: 100, }) @@ -654,12 +670,6 @@ class GithubUtils { } module.exports = GithubUtils; -module.exports.GITHUB_OWNER = GITHUB_OWNER; -module.exports.APP_REPO = APP_REPO; -module.exports.APP_REPO_URL = APP_REPO_URL; -module.exports.STAGING_DEPLOY_CASH_LABEL = STAGING_DEPLOY_CASH_LABEL; -module.exports.DEPLOY_BLOCKER_CASH_LABEL = DEPLOY_BLOCKER_CASH_LABEL; -module.exports.APPLAUSE_BOT = APPLAUSE_BOT; module.exports.ISSUE_OR_PULL_REQUEST_REGEX = ISSUE_OR_PULL_REQUEST_REGEX; module.exports.POLL_RATE = POLL_RATE; diff --git a/.github/actions/javascript/checkDeployBlockers/checkDeployBlockers.js b/.github/actions/javascript/checkDeployBlockers/checkDeployBlockers.js index 46cb6413f893..08e4857112f7 100644 --- a/.github/actions/javascript/checkDeployBlockers/checkDeployBlockers.js +++ b/.github/actions/javascript/checkDeployBlockers/checkDeployBlockers.js @@ -1,5 +1,6 @@ const _ = require('underscore'); const core = require('@actions/core'); +const CONST = require('../../../libs/CONST'); const GithubUtils = require('../../../libs/GithubUtils'); const run = function () { @@ -9,8 +10,8 @@ const run = function () { return GithubUtils.octokit.issues .get({ - owner: GithubUtils.GITHUB_OWNER, - repo: GithubUtils.APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, issue_number: issueNumber, }) .then(({data}) => { @@ -25,8 +26,8 @@ const run = function () { } return GithubUtils.octokit.issues.listComments({ - owner: GithubUtils.GITHUB_OWNER, - repo: GithubUtils.APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, issue_number: issueNumber, per_page: 100, }); diff --git a/.github/actions/javascript/checkDeployBlockers/index.js b/.github/actions/javascript/checkDeployBlockers/index.js index 01f4c536cfa9..80e39e8d1285 100644 --- a/.github/actions/javascript/checkDeployBlockers/index.js +++ b/.github/actions/javascript/checkDeployBlockers/index.js @@ -10,6 +10,7 @@ module.exports = const _ = __nccwpck_require__(3571); const core = __nccwpck_require__(2186); +const CONST = __nccwpck_require__(4097); const GithubUtils = __nccwpck_require__(7999); const run = function () { @@ -19,8 +20,8 @@ const run = function () { return GithubUtils.octokit.issues .get({ - owner: GithubUtils.GITHUB_OWNER, - repo: GithubUtils.APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, issue_number: issueNumber, }) .then(({data}) => { @@ -35,8 +36,8 @@ const run = function () { } return GithubUtils.octokit.issues.listComments({ - owner: GithubUtils.GITHUB_OWNER, - repo: GithubUtils.APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, issue_number: issueNumber, per_page: 100, }); @@ -81,6 +82,29 @@ if (require.main === require.cache[eval('__filename')]) { module.exports = run; +/***/ }), + +/***/ 4097: +/***/ ((module) => { + +const CONST = { + GITHUB_OWNER: 'Expensify', + APP_REPO: 'App', + APPLAUSE_BOT: 'applausebot', + OS_BOTIFY: 'OSBotify', + LABELS: { + STAGING_DEPLOY: 'StagingDeployCash', + DEPLOY_BLOCKER: 'DeployBlockerCash', + INTERNAL_QA: 'InternalQA', + }, +}; + +CONST.APP_REPO_URL = `https://github.com/${CONST.GITHUB_OWNER}/${CONST.APP_REPO}`; +CONST.APP_REPO_GIT_URL = `git@github.com:${CONST.GITHUB_OWNER}/${CONST.APP_REPO}.git`; + +module.exports = CONST; + + /***/ }), /***/ 7999: @@ -92,21 +116,13 @@ const core = __nccwpck_require__(2186); const {GitHub, getOctokitOptions} = __nccwpck_require__(3030); const {throttling} = __nccwpck_require__(9968); const {paginateRest} = __nccwpck_require__(4193); - -const GITHUB_OWNER = 'Expensify'; -const APP_REPO = 'App'; -const APP_REPO_URL = 'https://github.com/Expensify/App'; +const CONST = __nccwpck_require__(4097); const GITHUB_BASE_URL_REGEX = new RegExp('https?://(?:github\\.com|api\\.github\\.com)'); const PULL_REQUEST_REGEX = new RegExp(`${GITHUB_BASE_URL_REGEX.source}/.*/.*/pull/([0-9]+).*`); const ISSUE_REGEX = new RegExp(`${GITHUB_BASE_URL_REGEX.source}/.*/.*/issues/([0-9]+).*`); const ISSUE_OR_PULL_REQUEST_REGEX = new RegExp(`${GITHUB_BASE_URL_REGEX.source}/.*/.*/(?:pull|issues)/([0-9]+).*`); -const APPLAUSE_BOT = 'applausebot'; -const STAGING_DEPLOY_CASH_LABEL = 'StagingDeployCash'; -const DEPLOY_BLOCKER_CASH_LABEL = 'DeployBlockerCash'; -const INTERNAL_QA_LABEL = 'InternalQA'; - /** * The standard rate in ms at which we'll poll the GitHub API to check for status changes. * It's 10 seconds :) @@ -184,20 +200,20 @@ class GithubUtils { static getStagingDeployCash() { return this.octokit.issues .listForRepo({ - owner: GITHUB_OWNER, - repo: APP_REPO, - labels: STAGING_DEPLOY_CASH_LABEL, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, + labels: CONST.LABELS.STAGING_DEPLOY, state: 'open', }) .then(({data}) => { if (!data.length) { - const error = new Error(`Unable to find ${STAGING_DEPLOY_CASH_LABEL} issue.`); + const error = new Error(`Unable to find ${CONST.LABELS.STAGING_DEPLOY} issue.`); error.code = 404; throw error; } if (data.length > 1) { - const error = new Error(`Found more than one ${STAGING_DEPLOY_CASH_LABEL} issue.`); + const error = new Error(`Found more than one ${CONST.LABELS.STAGING_DEPLOY} issue.`); error.code = 500; throw error; } @@ -230,7 +246,7 @@ class GithubUtils { tag, }; } catch (exception) { - throw new Error(`Unable to find ${STAGING_DEPLOY_CASH_LABEL} issue with correct data.`); + throw new Error(`Unable to find ${CONST.LABELS.STAGING_DEPLOY} issue with correct data.`); } } @@ -338,7 +354,7 @@ class GithubUtils { // 'https://github.com/Expensify/App/pull/9642': [ 'mountiny', 'kidroca' ] // } const internalQAPRMap = _.reduce( - _.filter(data, (pr) => !_.isEmpty(_.findWhere(pr.labels, {name: INTERNAL_QA_LABEL}))), + _.filter(data, (pr) => !_.isEmpty(_.findWhere(pr.labels, {name: CONST.LABELS.INTERNAL_QA}))), (map, pr) => { // eslint-disable-next-line no-param-reassign map[pr.html_url] = _.compact(_.pluck(pr.assignees, 'login')); @@ -426,8 +442,8 @@ class GithubUtils { return this.paginate( this.octokit.pulls.list, { - owner: GITHUB_OWNER, - repo: APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, state: 'all', sort: 'created', direction: 'desc', @@ -451,8 +467,8 @@ class GithubUtils { static getPullRequestBody(pullRequestNumber) { return this.octokit.pulls .get({ - owner: GITHUB_OWNER, - repo: APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, pull_number: pullRequestNumber, }) .then(({data: pullRequestComment}) => pullRequestComment.body); @@ -466,8 +482,8 @@ class GithubUtils { return this.paginate( this.octokit.pulls.listReviews, { - owner: GITHUB_OWNER, - repo: APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, pull_number: pullRequestNumber, per_page: 100, }, @@ -483,8 +499,8 @@ class GithubUtils { return this.paginate( this.octokit.issues.listComments, { - owner: GITHUB_OWNER, - repo: APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, issue_number: issueNumber, per_page: 100, }, @@ -503,7 +519,7 @@ class GithubUtils { static createComment(repo, number, messageBody) { console.log(`Writing comment on #${number}`); return this.octokit.issues.createComment({ - owner: GITHUB_OWNER, + owner: CONST.GITHUB_OWNER, repo, issue_number: number, body: messageBody, @@ -520,8 +536,8 @@ class GithubUtils { console.log(`Fetching New Expensify workflow runs for ${workflow}...`); return this.octokit.actions .listWorkflowRuns({ - owner: GITHUB_OWNER, - repo: APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, workflow_id: workflow, }) .then((response) => lodashGet(response, 'data.workflow_runs[0].id')); @@ -544,7 +560,7 @@ class GithubUtils { * @returns {String} */ static getPullRequestURLFromNumber(number) { - return `${APP_REPO_URL}/pull/${number}`; + return `${CONST.APP_REPO_URL}/pull/${number}`; } /** @@ -599,7 +615,7 @@ class GithubUtils { * @returns {Boolean} */ static isAutomatedPullRequest(pullRequest) { - return _.isEqual(lodashGet(pullRequest, 'user.login', ''), 'OSBotify'); + return _.isEqual(lodashGet(pullRequest, 'user.login', ''), CONST.OS_BOTIFY); } /** @@ -610,8 +626,8 @@ class GithubUtils { */ static getActorWhoClosedIssue(issueNumber) { return this.paginate(this.octokit.issues.listEvents, { - owner: GITHUB_OWNER, - repo: APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, issue_number: issueNumber, per_page: 100, }) @@ -621,12 +637,6 @@ class GithubUtils { } module.exports = GithubUtils; -module.exports.GITHUB_OWNER = GITHUB_OWNER; -module.exports.APP_REPO = APP_REPO; -module.exports.APP_REPO_URL = APP_REPO_URL; -module.exports.STAGING_DEPLOY_CASH_LABEL = STAGING_DEPLOY_CASH_LABEL; -module.exports.DEPLOY_BLOCKER_CASH_LABEL = DEPLOY_BLOCKER_CASH_LABEL; -module.exports.APPLAUSE_BOT = APPLAUSE_BOT; module.exports.ISSUE_OR_PULL_REQUEST_REGEX = ISSUE_OR_PULL_REQUEST_REGEX; module.exports.POLL_RATE = POLL_RATE; diff --git a/.github/actions/javascript/createOrUpdateStagingDeploy/createOrUpdateStagingDeploy.js b/.github/actions/javascript/createOrUpdateStagingDeploy/createOrUpdateStagingDeploy.js index 2cddc84c3dfb..a514f8a9bcab 100644 --- a/.github/actions/javascript/createOrUpdateStagingDeploy/createOrUpdateStagingDeploy.js +++ b/.github/actions/javascript/createOrUpdateStagingDeploy/createOrUpdateStagingDeploy.js @@ -1,6 +1,7 @@ const _ = require('underscore'); const core = require('@actions/core'); const moment = require('moment'); +const CONST = require('../../../libs/CONST'); const GithubUtils = require('../../../libs/GithubUtils'); const GitUtils = require('../../../libs/GitUtils'); @@ -18,16 +19,16 @@ const run = function () { return Promise.all([ GithubUtils.octokit.issues.listForRepo({ log: console, - owner: GithubUtils.GITHUB_OWNER, - repo: GithubUtils.APP_REPO, - labels: GithubUtils.STAGING_DEPLOY_CASH_LABEL, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, + labels: CONST.LABELS.STAGING_DEPLOY, state: 'all', }), GithubUtils.octokit.issues.listForRepo({ log: console, - owner: GithubUtils.GITHUB_OWNER, - repo: GithubUtils.APP_REPO, - labels: GithubUtils.DEPLOY_BLOCKER_CASH_LABEL, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, + labels: CONST.LABELS.DEPLOY_BLOCKER, }), ]) .then(([stagingDeployResponse, deployBlockerResponse]) => { @@ -136,8 +137,8 @@ const run = function () { }) .then((body) => { const defaultPayload = { - owner: GithubUtils.GITHUB_OWNER, - repo: GithubUtils.APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, body, }; @@ -145,8 +146,8 @@ const run = function () { return GithubUtils.octokit.issues.create({ ...defaultPayload, title: `Deploy Checklist: New Expensify ${moment().format('YYYY-MM-DD')}`, - labels: [GithubUtils.STAGING_DEPLOY_CASH_LABEL], - assignees: [GithubUtils.APPLAUSE_BOT], + labels: [CONST.LABELS.STAGING_DEPLOY], + assignees: [CONST.APPLAUSE_BOT], }); } diff --git a/.github/actions/javascript/createOrUpdateStagingDeploy/index.js b/.github/actions/javascript/createOrUpdateStagingDeploy/index.js index bb3e210898db..4a1d8792bd73 100644 --- a/.github/actions/javascript/createOrUpdateStagingDeploy/index.js +++ b/.github/actions/javascript/createOrUpdateStagingDeploy/index.js @@ -11,6 +11,7 @@ module.exports = const _ = __nccwpck_require__(3571); const core = __nccwpck_require__(2186); const moment = __nccwpck_require__(9623); +const CONST = __nccwpck_require__(4097); const GithubUtils = __nccwpck_require__(7999); const GitUtils = __nccwpck_require__(669); @@ -28,16 +29,16 @@ const run = function () { return Promise.all([ GithubUtils.octokit.issues.listForRepo({ log: console, - owner: GithubUtils.GITHUB_OWNER, - repo: GithubUtils.APP_REPO, - labels: GithubUtils.STAGING_DEPLOY_CASH_LABEL, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, + labels: CONST.LABELS.STAGING_DEPLOY, state: 'all', }), GithubUtils.octokit.issues.listForRepo({ log: console, - owner: GithubUtils.GITHUB_OWNER, - repo: GithubUtils.APP_REPO, - labels: GithubUtils.DEPLOY_BLOCKER_CASH_LABEL, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, + labels: CONST.LABELS.DEPLOY_BLOCKER, }), ]) .then(([stagingDeployResponse, deployBlockerResponse]) => { @@ -146,8 +147,8 @@ const run = function () { }) .then((body) => { const defaultPayload = { - owner: GithubUtils.GITHUB_OWNER, - repo: GithubUtils.APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, body, }; @@ -155,8 +156,8 @@ const run = function () { return GithubUtils.octokit.issues.create({ ...defaultPayload, title: `Deploy Checklist: New Expensify ${moment().format('YYYY-MM-DD')}`, - labels: [GithubUtils.STAGING_DEPLOY_CASH_LABEL], - assignees: [GithubUtils.APPLAUSE_BOT], + labels: [CONST.LABELS.STAGING_DEPLOY], + assignees: [CONST.APPLAUSE_BOT], }); } @@ -183,6 +184,29 @@ if (require.main === require.cache[eval('__filename')]) { module.exports = run; +/***/ }), + +/***/ 4097: +/***/ ((module) => { + +const CONST = { + GITHUB_OWNER: 'Expensify', + APP_REPO: 'App', + APPLAUSE_BOT: 'applausebot', + OS_BOTIFY: 'OSBotify', + LABELS: { + STAGING_DEPLOY: 'StagingDeployCash', + DEPLOY_BLOCKER: 'DeployBlockerCash', + INTERNAL_QA: 'InternalQA', + }, +}; + +CONST.APP_REPO_URL = `https://github.com/${CONST.GITHUB_OWNER}/${CONST.APP_REPO}`; +CONST.APP_REPO_GIT_URL = `git@github.com:${CONST.GITHUB_OWNER}/${CONST.APP_REPO}.git`; + +module.exports = CONST; + + /***/ }), /***/ 669: @@ -316,21 +340,13 @@ const core = __nccwpck_require__(2186); const {GitHub, getOctokitOptions} = __nccwpck_require__(3030); const {throttling} = __nccwpck_require__(9968); const {paginateRest} = __nccwpck_require__(4193); - -const GITHUB_OWNER = 'Expensify'; -const APP_REPO = 'App'; -const APP_REPO_URL = 'https://github.com/Expensify/App'; +const CONST = __nccwpck_require__(4097); const GITHUB_BASE_URL_REGEX = new RegExp('https?://(?:github\\.com|api\\.github\\.com)'); const PULL_REQUEST_REGEX = new RegExp(`${GITHUB_BASE_URL_REGEX.source}/.*/.*/pull/([0-9]+).*`); const ISSUE_REGEX = new RegExp(`${GITHUB_BASE_URL_REGEX.source}/.*/.*/issues/([0-9]+).*`); const ISSUE_OR_PULL_REQUEST_REGEX = new RegExp(`${GITHUB_BASE_URL_REGEX.source}/.*/.*/(?:pull|issues)/([0-9]+).*`); -const APPLAUSE_BOT = 'applausebot'; -const STAGING_DEPLOY_CASH_LABEL = 'StagingDeployCash'; -const DEPLOY_BLOCKER_CASH_LABEL = 'DeployBlockerCash'; -const INTERNAL_QA_LABEL = 'InternalQA'; - /** * The standard rate in ms at which we'll poll the GitHub API to check for status changes. * It's 10 seconds :) @@ -408,20 +424,20 @@ class GithubUtils { static getStagingDeployCash() { return this.octokit.issues .listForRepo({ - owner: GITHUB_OWNER, - repo: APP_REPO, - labels: STAGING_DEPLOY_CASH_LABEL, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, + labels: CONST.LABELS.STAGING_DEPLOY, state: 'open', }) .then(({data}) => { if (!data.length) { - const error = new Error(`Unable to find ${STAGING_DEPLOY_CASH_LABEL} issue.`); + const error = new Error(`Unable to find ${CONST.LABELS.STAGING_DEPLOY} issue.`); error.code = 404; throw error; } if (data.length > 1) { - const error = new Error(`Found more than one ${STAGING_DEPLOY_CASH_LABEL} issue.`); + const error = new Error(`Found more than one ${CONST.LABELS.STAGING_DEPLOY} issue.`); error.code = 500; throw error; } @@ -454,7 +470,7 @@ class GithubUtils { tag, }; } catch (exception) { - throw new Error(`Unable to find ${STAGING_DEPLOY_CASH_LABEL} issue with correct data.`); + throw new Error(`Unable to find ${CONST.LABELS.STAGING_DEPLOY} issue with correct data.`); } } @@ -562,7 +578,7 @@ class GithubUtils { // 'https://github.com/Expensify/App/pull/9642': [ 'mountiny', 'kidroca' ] // } const internalQAPRMap = _.reduce( - _.filter(data, (pr) => !_.isEmpty(_.findWhere(pr.labels, {name: INTERNAL_QA_LABEL}))), + _.filter(data, (pr) => !_.isEmpty(_.findWhere(pr.labels, {name: CONST.LABELS.INTERNAL_QA}))), (map, pr) => { // eslint-disable-next-line no-param-reassign map[pr.html_url] = _.compact(_.pluck(pr.assignees, 'login')); @@ -650,8 +666,8 @@ class GithubUtils { return this.paginate( this.octokit.pulls.list, { - owner: GITHUB_OWNER, - repo: APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, state: 'all', sort: 'created', direction: 'desc', @@ -675,8 +691,8 @@ class GithubUtils { static getPullRequestBody(pullRequestNumber) { return this.octokit.pulls .get({ - owner: GITHUB_OWNER, - repo: APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, pull_number: pullRequestNumber, }) .then(({data: pullRequestComment}) => pullRequestComment.body); @@ -690,8 +706,8 @@ class GithubUtils { return this.paginate( this.octokit.pulls.listReviews, { - owner: GITHUB_OWNER, - repo: APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, pull_number: pullRequestNumber, per_page: 100, }, @@ -707,8 +723,8 @@ class GithubUtils { return this.paginate( this.octokit.issues.listComments, { - owner: GITHUB_OWNER, - repo: APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, issue_number: issueNumber, per_page: 100, }, @@ -727,7 +743,7 @@ class GithubUtils { static createComment(repo, number, messageBody) { console.log(`Writing comment on #${number}`); return this.octokit.issues.createComment({ - owner: GITHUB_OWNER, + owner: CONST.GITHUB_OWNER, repo, issue_number: number, body: messageBody, @@ -744,8 +760,8 @@ class GithubUtils { console.log(`Fetching New Expensify workflow runs for ${workflow}...`); return this.octokit.actions .listWorkflowRuns({ - owner: GITHUB_OWNER, - repo: APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, workflow_id: workflow, }) .then((response) => lodashGet(response, 'data.workflow_runs[0].id')); @@ -768,7 +784,7 @@ class GithubUtils { * @returns {String} */ static getPullRequestURLFromNumber(number) { - return `${APP_REPO_URL}/pull/${number}`; + return `${CONST.APP_REPO_URL}/pull/${number}`; } /** @@ -823,7 +839,7 @@ class GithubUtils { * @returns {Boolean} */ static isAutomatedPullRequest(pullRequest) { - return _.isEqual(lodashGet(pullRequest, 'user.login', ''), 'OSBotify'); + return _.isEqual(lodashGet(pullRequest, 'user.login', ''), CONST.OS_BOTIFY); } /** @@ -834,8 +850,8 @@ class GithubUtils { */ static getActorWhoClosedIssue(issueNumber) { return this.paginate(this.octokit.issues.listEvents, { - owner: GITHUB_OWNER, - repo: APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, issue_number: issueNumber, per_page: 100, }) @@ -845,12 +861,6 @@ class GithubUtils { } module.exports = GithubUtils; -module.exports.GITHUB_OWNER = GITHUB_OWNER; -module.exports.APP_REPO = APP_REPO; -module.exports.APP_REPO_URL = APP_REPO_URL; -module.exports.STAGING_DEPLOY_CASH_LABEL = STAGING_DEPLOY_CASH_LABEL; -module.exports.DEPLOY_BLOCKER_CASH_LABEL = DEPLOY_BLOCKER_CASH_LABEL; -module.exports.APPLAUSE_BOT = APPLAUSE_BOT; module.exports.ISSUE_OR_PULL_REQUEST_REGEX = ISSUE_OR_PULL_REQUEST_REGEX; module.exports.POLL_RATE = POLL_RATE; diff --git a/.github/actions/javascript/getDeployPullRequestList/index.js b/.github/actions/javascript/getDeployPullRequestList/index.js index 7b3ad4fd76d5..a4a34d73cd97 100644 --- a/.github/actions/javascript/getDeployPullRequestList/index.js +++ b/.github/actions/javascript/getDeployPullRequestList/index.js @@ -118,6 +118,29 @@ module.exports = { }; +/***/ }), + +/***/ 4097: +/***/ ((module) => { + +const CONST = { + GITHUB_OWNER: 'Expensify', + APP_REPO: 'App', + APPLAUSE_BOT: 'applausebot', + OS_BOTIFY: 'OSBotify', + LABELS: { + STAGING_DEPLOY: 'StagingDeployCash', + DEPLOY_BLOCKER: 'DeployBlockerCash', + INTERNAL_QA: 'InternalQA', + }, +}; + +CONST.APP_REPO_URL = `https://github.com/${CONST.GITHUB_OWNER}/${CONST.APP_REPO}`; +CONST.APP_REPO_GIT_URL = `git@github.com:${CONST.GITHUB_OWNER}/${CONST.APP_REPO}.git`; + +module.exports = CONST; + + /***/ }), /***/ 669: @@ -251,21 +274,13 @@ const core = __nccwpck_require__(2186); const {GitHub, getOctokitOptions} = __nccwpck_require__(3030); const {throttling} = __nccwpck_require__(9968); const {paginateRest} = __nccwpck_require__(4193); - -const GITHUB_OWNER = 'Expensify'; -const APP_REPO = 'App'; -const APP_REPO_URL = 'https://github.com/Expensify/App'; +const CONST = __nccwpck_require__(4097); const GITHUB_BASE_URL_REGEX = new RegExp('https?://(?:github\\.com|api\\.github\\.com)'); const PULL_REQUEST_REGEX = new RegExp(`${GITHUB_BASE_URL_REGEX.source}/.*/.*/pull/([0-9]+).*`); const ISSUE_REGEX = new RegExp(`${GITHUB_BASE_URL_REGEX.source}/.*/.*/issues/([0-9]+).*`); const ISSUE_OR_PULL_REQUEST_REGEX = new RegExp(`${GITHUB_BASE_URL_REGEX.source}/.*/.*/(?:pull|issues)/([0-9]+).*`); -const APPLAUSE_BOT = 'applausebot'; -const STAGING_DEPLOY_CASH_LABEL = 'StagingDeployCash'; -const DEPLOY_BLOCKER_CASH_LABEL = 'DeployBlockerCash'; -const INTERNAL_QA_LABEL = 'InternalQA'; - /** * The standard rate in ms at which we'll poll the GitHub API to check for status changes. * It's 10 seconds :) @@ -343,20 +358,20 @@ class GithubUtils { static getStagingDeployCash() { return this.octokit.issues .listForRepo({ - owner: GITHUB_OWNER, - repo: APP_REPO, - labels: STAGING_DEPLOY_CASH_LABEL, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, + labels: CONST.LABELS.STAGING_DEPLOY, state: 'open', }) .then(({data}) => { if (!data.length) { - const error = new Error(`Unable to find ${STAGING_DEPLOY_CASH_LABEL} issue.`); + const error = new Error(`Unable to find ${CONST.LABELS.STAGING_DEPLOY} issue.`); error.code = 404; throw error; } if (data.length > 1) { - const error = new Error(`Found more than one ${STAGING_DEPLOY_CASH_LABEL} issue.`); + const error = new Error(`Found more than one ${CONST.LABELS.STAGING_DEPLOY} issue.`); error.code = 500; throw error; } @@ -389,7 +404,7 @@ class GithubUtils { tag, }; } catch (exception) { - throw new Error(`Unable to find ${STAGING_DEPLOY_CASH_LABEL} issue with correct data.`); + throw new Error(`Unable to find ${CONST.LABELS.STAGING_DEPLOY} issue with correct data.`); } } @@ -497,7 +512,7 @@ class GithubUtils { // 'https://github.com/Expensify/App/pull/9642': [ 'mountiny', 'kidroca' ] // } const internalQAPRMap = _.reduce( - _.filter(data, (pr) => !_.isEmpty(_.findWhere(pr.labels, {name: INTERNAL_QA_LABEL}))), + _.filter(data, (pr) => !_.isEmpty(_.findWhere(pr.labels, {name: CONST.LABELS.INTERNAL_QA}))), (map, pr) => { // eslint-disable-next-line no-param-reassign map[pr.html_url] = _.compact(_.pluck(pr.assignees, 'login')); @@ -585,8 +600,8 @@ class GithubUtils { return this.paginate( this.octokit.pulls.list, { - owner: GITHUB_OWNER, - repo: APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, state: 'all', sort: 'created', direction: 'desc', @@ -610,8 +625,8 @@ class GithubUtils { static getPullRequestBody(pullRequestNumber) { return this.octokit.pulls .get({ - owner: GITHUB_OWNER, - repo: APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, pull_number: pullRequestNumber, }) .then(({data: pullRequestComment}) => pullRequestComment.body); @@ -625,8 +640,8 @@ class GithubUtils { return this.paginate( this.octokit.pulls.listReviews, { - owner: GITHUB_OWNER, - repo: APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, pull_number: pullRequestNumber, per_page: 100, }, @@ -642,8 +657,8 @@ class GithubUtils { return this.paginate( this.octokit.issues.listComments, { - owner: GITHUB_OWNER, - repo: APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, issue_number: issueNumber, per_page: 100, }, @@ -662,7 +677,7 @@ class GithubUtils { static createComment(repo, number, messageBody) { console.log(`Writing comment on #${number}`); return this.octokit.issues.createComment({ - owner: GITHUB_OWNER, + owner: CONST.GITHUB_OWNER, repo, issue_number: number, body: messageBody, @@ -679,8 +694,8 @@ class GithubUtils { console.log(`Fetching New Expensify workflow runs for ${workflow}...`); return this.octokit.actions .listWorkflowRuns({ - owner: GITHUB_OWNER, - repo: APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, workflow_id: workflow, }) .then((response) => lodashGet(response, 'data.workflow_runs[0].id')); @@ -703,7 +718,7 @@ class GithubUtils { * @returns {String} */ static getPullRequestURLFromNumber(number) { - return `${APP_REPO_URL}/pull/${number}`; + return `${CONST.APP_REPO_URL}/pull/${number}`; } /** @@ -758,7 +773,7 @@ class GithubUtils { * @returns {Boolean} */ static isAutomatedPullRequest(pullRequest) { - return _.isEqual(lodashGet(pullRequest, 'user.login', ''), 'OSBotify'); + return _.isEqual(lodashGet(pullRequest, 'user.login', ''), CONST.OS_BOTIFY); } /** @@ -769,8 +784,8 @@ class GithubUtils { */ static getActorWhoClosedIssue(issueNumber) { return this.paginate(this.octokit.issues.listEvents, { - owner: GITHUB_OWNER, - repo: APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, issue_number: issueNumber, per_page: 100, }) @@ -780,12 +795,6 @@ class GithubUtils { } module.exports = GithubUtils; -module.exports.GITHUB_OWNER = GITHUB_OWNER; -module.exports.APP_REPO = APP_REPO; -module.exports.APP_REPO_URL = APP_REPO_URL; -module.exports.STAGING_DEPLOY_CASH_LABEL = STAGING_DEPLOY_CASH_LABEL; -module.exports.DEPLOY_BLOCKER_CASH_LABEL = DEPLOY_BLOCKER_CASH_LABEL; -module.exports.APPLAUSE_BOT = APPLAUSE_BOT; module.exports.ISSUE_OR_PULL_REQUEST_REGEX = ISSUE_OR_PULL_REQUEST_REGEX; module.exports.POLL_RATE = POLL_RATE; diff --git a/.github/actions/javascript/getPullRequestDetails/getPullRequestDetails.js b/.github/actions/javascript/getPullRequestDetails/getPullRequestDetails.js index e87c58ebaa65..4ebf7a749fc9 100644 --- a/.github/actions/javascript/getPullRequestDetails/getPullRequestDetails.js +++ b/.github/actions/javascript/getPullRequestDetails/getPullRequestDetails.js @@ -1,11 +1,12 @@ const _ = require('underscore'); const core = require('@actions/core'); +const CONST = require('../../../libs/CONST'); const ActionUtils = require('../../../libs/ActionUtils'); const GithubUtils = require('../../../libs/GithubUtils'); const DEFAULT_PAYLOAD = { - owner: GithubUtils.GITHUB_OWNER, - repo: GithubUtils.APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, }; const pullRequestNumber = ActionUtils.getJSONInput('PULL_REQUEST_NUMBER', {required: false}, null); @@ -31,7 +32,7 @@ if (titleRegex) { * @param {Object} PR */ function outputMergeActor(PR) { - if (user === 'OSBotify') { + if (user === CONST.OS_BOTIFY) { core.setOutput('MERGE_ACTOR', PR.merged_by.login); } else { core.setOutput('MERGE_ACTOR', user); @@ -44,7 +45,7 @@ function outputMergeActor(PR) { * @param {Object} PR */ function outputForkedRepoUrl(PR) { - if (PR.head.repo.html_url === GithubUtils.APP_REPO_URL) { + if (PR.head.repo.html_url === CONST.APP_REPO_URL) { core.setOutput('FORKED_REPO_URL', ''); } else { core.setOutput('FORKED_REPO_URL', `${PR.head.repo.html_url}.git`); diff --git a/.github/actions/javascript/getPullRequestDetails/index.js b/.github/actions/javascript/getPullRequestDetails/index.js index 1748d98e2495..7653719c990b 100644 --- a/.github/actions/javascript/getPullRequestDetails/index.js +++ b/.github/actions/javascript/getPullRequestDetails/index.js @@ -10,12 +10,13 @@ module.exports = const _ = __nccwpck_require__(3571); const core = __nccwpck_require__(2186); +const CONST = __nccwpck_require__(4097); const ActionUtils = __nccwpck_require__(970); const GithubUtils = __nccwpck_require__(7999); const DEFAULT_PAYLOAD = { - owner: GithubUtils.GITHUB_OWNER, - repo: GithubUtils.APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, }; const pullRequestNumber = ActionUtils.getJSONInput('PULL_REQUEST_NUMBER', {required: false}, null); @@ -41,7 +42,7 @@ if (titleRegex) { * @param {Object} PR */ function outputMergeActor(PR) { - if (user === 'OSBotify') { + if (user === CONST.OS_BOTIFY) { core.setOutput('MERGE_ACTOR', PR.merged_by.login); } else { core.setOutput('MERGE_ACTOR', user); @@ -54,7 +55,7 @@ function outputMergeActor(PR) { * @param {Object} PR */ function outputForkedRepoUrl(PR) { - if (PR.head.repo.html_url === GithubUtils.APP_REPO_URL) { + if (PR.head.repo.html_url === CONST.APP_REPO_URL) { core.setOutput('FORKED_REPO_URL', ''); } else { core.setOutput('FORKED_REPO_URL', `${PR.head.repo.html_url}.git`); @@ -175,6 +176,29 @@ module.exports = { }; +/***/ }), + +/***/ 4097: +/***/ ((module) => { + +const CONST = { + GITHUB_OWNER: 'Expensify', + APP_REPO: 'App', + APPLAUSE_BOT: 'applausebot', + OS_BOTIFY: 'OSBotify', + LABELS: { + STAGING_DEPLOY: 'StagingDeployCash', + DEPLOY_BLOCKER: 'DeployBlockerCash', + INTERNAL_QA: 'InternalQA', + }, +}; + +CONST.APP_REPO_URL = `https://github.com/${CONST.GITHUB_OWNER}/${CONST.APP_REPO}`; +CONST.APP_REPO_GIT_URL = `git@github.com:${CONST.GITHUB_OWNER}/${CONST.APP_REPO}.git`; + +module.exports = CONST; + + /***/ }), /***/ 7999: @@ -186,21 +210,13 @@ const core = __nccwpck_require__(2186); const {GitHub, getOctokitOptions} = __nccwpck_require__(3030); const {throttling} = __nccwpck_require__(9968); const {paginateRest} = __nccwpck_require__(4193); - -const GITHUB_OWNER = 'Expensify'; -const APP_REPO = 'App'; -const APP_REPO_URL = 'https://github.com/Expensify/App'; +const CONST = __nccwpck_require__(4097); const GITHUB_BASE_URL_REGEX = new RegExp('https?://(?:github\\.com|api\\.github\\.com)'); const PULL_REQUEST_REGEX = new RegExp(`${GITHUB_BASE_URL_REGEX.source}/.*/.*/pull/([0-9]+).*`); const ISSUE_REGEX = new RegExp(`${GITHUB_BASE_URL_REGEX.source}/.*/.*/issues/([0-9]+).*`); const ISSUE_OR_PULL_REQUEST_REGEX = new RegExp(`${GITHUB_BASE_URL_REGEX.source}/.*/.*/(?:pull|issues)/([0-9]+).*`); -const APPLAUSE_BOT = 'applausebot'; -const STAGING_DEPLOY_CASH_LABEL = 'StagingDeployCash'; -const DEPLOY_BLOCKER_CASH_LABEL = 'DeployBlockerCash'; -const INTERNAL_QA_LABEL = 'InternalQA'; - /** * The standard rate in ms at which we'll poll the GitHub API to check for status changes. * It's 10 seconds :) @@ -278,20 +294,20 @@ class GithubUtils { static getStagingDeployCash() { return this.octokit.issues .listForRepo({ - owner: GITHUB_OWNER, - repo: APP_REPO, - labels: STAGING_DEPLOY_CASH_LABEL, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, + labels: CONST.LABELS.STAGING_DEPLOY, state: 'open', }) .then(({data}) => { if (!data.length) { - const error = new Error(`Unable to find ${STAGING_DEPLOY_CASH_LABEL} issue.`); + const error = new Error(`Unable to find ${CONST.LABELS.STAGING_DEPLOY} issue.`); error.code = 404; throw error; } if (data.length > 1) { - const error = new Error(`Found more than one ${STAGING_DEPLOY_CASH_LABEL} issue.`); + const error = new Error(`Found more than one ${CONST.LABELS.STAGING_DEPLOY} issue.`); error.code = 500; throw error; } @@ -324,7 +340,7 @@ class GithubUtils { tag, }; } catch (exception) { - throw new Error(`Unable to find ${STAGING_DEPLOY_CASH_LABEL} issue with correct data.`); + throw new Error(`Unable to find ${CONST.LABELS.STAGING_DEPLOY} issue with correct data.`); } } @@ -432,7 +448,7 @@ class GithubUtils { // 'https://github.com/Expensify/App/pull/9642': [ 'mountiny', 'kidroca' ] // } const internalQAPRMap = _.reduce( - _.filter(data, (pr) => !_.isEmpty(_.findWhere(pr.labels, {name: INTERNAL_QA_LABEL}))), + _.filter(data, (pr) => !_.isEmpty(_.findWhere(pr.labels, {name: CONST.LABELS.INTERNAL_QA}))), (map, pr) => { // eslint-disable-next-line no-param-reassign map[pr.html_url] = _.compact(_.pluck(pr.assignees, 'login')); @@ -520,8 +536,8 @@ class GithubUtils { return this.paginate( this.octokit.pulls.list, { - owner: GITHUB_OWNER, - repo: APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, state: 'all', sort: 'created', direction: 'desc', @@ -545,8 +561,8 @@ class GithubUtils { static getPullRequestBody(pullRequestNumber) { return this.octokit.pulls .get({ - owner: GITHUB_OWNER, - repo: APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, pull_number: pullRequestNumber, }) .then(({data: pullRequestComment}) => pullRequestComment.body); @@ -560,8 +576,8 @@ class GithubUtils { return this.paginate( this.octokit.pulls.listReviews, { - owner: GITHUB_OWNER, - repo: APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, pull_number: pullRequestNumber, per_page: 100, }, @@ -577,8 +593,8 @@ class GithubUtils { return this.paginate( this.octokit.issues.listComments, { - owner: GITHUB_OWNER, - repo: APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, issue_number: issueNumber, per_page: 100, }, @@ -597,7 +613,7 @@ class GithubUtils { static createComment(repo, number, messageBody) { console.log(`Writing comment on #${number}`); return this.octokit.issues.createComment({ - owner: GITHUB_OWNER, + owner: CONST.GITHUB_OWNER, repo, issue_number: number, body: messageBody, @@ -614,8 +630,8 @@ class GithubUtils { console.log(`Fetching New Expensify workflow runs for ${workflow}...`); return this.octokit.actions .listWorkflowRuns({ - owner: GITHUB_OWNER, - repo: APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, workflow_id: workflow, }) .then((response) => lodashGet(response, 'data.workflow_runs[0].id')); @@ -638,7 +654,7 @@ class GithubUtils { * @returns {String} */ static getPullRequestURLFromNumber(number) { - return `${APP_REPO_URL}/pull/${number}`; + return `${CONST.APP_REPO_URL}/pull/${number}`; } /** @@ -693,7 +709,7 @@ class GithubUtils { * @returns {Boolean} */ static isAutomatedPullRequest(pullRequest) { - return _.isEqual(lodashGet(pullRequest, 'user.login', ''), 'OSBotify'); + return _.isEqual(lodashGet(pullRequest, 'user.login', ''), CONST.OS_BOTIFY); } /** @@ -704,8 +720,8 @@ class GithubUtils { */ static getActorWhoClosedIssue(issueNumber) { return this.paginate(this.octokit.issues.listEvents, { - owner: GITHUB_OWNER, - repo: APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, issue_number: issueNumber, per_page: 100, }) @@ -715,12 +731,6 @@ class GithubUtils { } module.exports = GithubUtils; -module.exports.GITHUB_OWNER = GITHUB_OWNER; -module.exports.APP_REPO = APP_REPO; -module.exports.APP_REPO_URL = APP_REPO_URL; -module.exports.STAGING_DEPLOY_CASH_LABEL = STAGING_DEPLOY_CASH_LABEL; -module.exports.DEPLOY_BLOCKER_CASH_LABEL = DEPLOY_BLOCKER_CASH_LABEL; -module.exports.APPLAUSE_BOT = APPLAUSE_BOT; module.exports.ISSUE_OR_PULL_REQUEST_REGEX = ISSUE_OR_PULL_REQUEST_REGEX; module.exports.POLL_RATE = POLL_RATE; diff --git a/.github/actions/javascript/getReleaseBody/index.js b/.github/actions/javascript/getReleaseBody/index.js index b8dbae648ed3..cdf97f3d2818 100644 --- a/.github/actions/javascript/getReleaseBody/index.js +++ b/.github/actions/javascript/getReleaseBody/index.js @@ -69,6 +69,29 @@ module.exports = { }; +/***/ }), + +/***/ 4097: +/***/ ((module) => { + +const CONST = { + GITHUB_OWNER: 'Expensify', + APP_REPO: 'App', + APPLAUSE_BOT: 'applausebot', + OS_BOTIFY: 'OSBotify', + LABELS: { + STAGING_DEPLOY: 'StagingDeployCash', + DEPLOY_BLOCKER: 'DeployBlockerCash', + INTERNAL_QA: 'InternalQA', + }, +}; + +CONST.APP_REPO_URL = `https://github.com/${CONST.GITHUB_OWNER}/${CONST.APP_REPO}`; +CONST.APP_REPO_GIT_URL = `git@github.com:${CONST.GITHUB_OWNER}/${CONST.APP_REPO}.git`; + +module.exports = CONST; + + /***/ }), /***/ 7999: @@ -80,21 +103,13 @@ const core = __nccwpck_require__(2186); const {GitHub, getOctokitOptions} = __nccwpck_require__(3030); const {throttling} = __nccwpck_require__(9968); const {paginateRest} = __nccwpck_require__(4193); - -const GITHUB_OWNER = 'Expensify'; -const APP_REPO = 'App'; -const APP_REPO_URL = 'https://github.com/Expensify/App'; +const CONST = __nccwpck_require__(4097); const GITHUB_BASE_URL_REGEX = new RegExp('https?://(?:github\\.com|api\\.github\\.com)'); const PULL_REQUEST_REGEX = new RegExp(`${GITHUB_BASE_URL_REGEX.source}/.*/.*/pull/([0-9]+).*`); const ISSUE_REGEX = new RegExp(`${GITHUB_BASE_URL_REGEX.source}/.*/.*/issues/([0-9]+).*`); const ISSUE_OR_PULL_REQUEST_REGEX = new RegExp(`${GITHUB_BASE_URL_REGEX.source}/.*/.*/(?:pull|issues)/([0-9]+).*`); -const APPLAUSE_BOT = 'applausebot'; -const STAGING_DEPLOY_CASH_LABEL = 'StagingDeployCash'; -const DEPLOY_BLOCKER_CASH_LABEL = 'DeployBlockerCash'; -const INTERNAL_QA_LABEL = 'InternalQA'; - /** * The standard rate in ms at which we'll poll the GitHub API to check for status changes. * It's 10 seconds :) @@ -172,20 +187,20 @@ class GithubUtils { static getStagingDeployCash() { return this.octokit.issues .listForRepo({ - owner: GITHUB_OWNER, - repo: APP_REPO, - labels: STAGING_DEPLOY_CASH_LABEL, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, + labels: CONST.LABELS.STAGING_DEPLOY, state: 'open', }) .then(({data}) => { if (!data.length) { - const error = new Error(`Unable to find ${STAGING_DEPLOY_CASH_LABEL} issue.`); + const error = new Error(`Unable to find ${CONST.LABELS.STAGING_DEPLOY} issue.`); error.code = 404; throw error; } if (data.length > 1) { - const error = new Error(`Found more than one ${STAGING_DEPLOY_CASH_LABEL} issue.`); + const error = new Error(`Found more than one ${CONST.LABELS.STAGING_DEPLOY} issue.`); error.code = 500; throw error; } @@ -218,7 +233,7 @@ class GithubUtils { tag, }; } catch (exception) { - throw new Error(`Unable to find ${STAGING_DEPLOY_CASH_LABEL} issue with correct data.`); + throw new Error(`Unable to find ${CONST.LABELS.STAGING_DEPLOY} issue with correct data.`); } } @@ -326,7 +341,7 @@ class GithubUtils { // 'https://github.com/Expensify/App/pull/9642': [ 'mountiny', 'kidroca' ] // } const internalQAPRMap = _.reduce( - _.filter(data, (pr) => !_.isEmpty(_.findWhere(pr.labels, {name: INTERNAL_QA_LABEL}))), + _.filter(data, (pr) => !_.isEmpty(_.findWhere(pr.labels, {name: CONST.LABELS.INTERNAL_QA}))), (map, pr) => { // eslint-disable-next-line no-param-reassign map[pr.html_url] = _.compact(_.pluck(pr.assignees, 'login')); @@ -414,8 +429,8 @@ class GithubUtils { return this.paginate( this.octokit.pulls.list, { - owner: GITHUB_OWNER, - repo: APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, state: 'all', sort: 'created', direction: 'desc', @@ -439,8 +454,8 @@ class GithubUtils { static getPullRequestBody(pullRequestNumber) { return this.octokit.pulls .get({ - owner: GITHUB_OWNER, - repo: APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, pull_number: pullRequestNumber, }) .then(({data: pullRequestComment}) => pullRequestComment.body); @@ -454,8 +469,8 @@ class GithubUtils { return this.paginate( this.octokit.pulls.listReviews, { - owner: GITHUB_OWNER, - repo: APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, pull_number: pullRequestNumber, per_page: 100, }, @@ -471,8 +486,8 @@ class GithubUtils { return this.paginate( this.octokit.issues.listComments, { - owner: GITHUB_OWNER, - repo: APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, issue_number: issueNumber, per_page: 100, }, @@ -491,7 +506,7 @@ class GithubUtils { static createComment(repo, number, messageBody) { console.log(`Writing comment on #${number}`); return this.octokit.issues.createComment({ - owner: GITHUB_OWNER, + owner: CONST.GITHUB_OWNER, repo, issue_number: number, body: messageBody, @@ -508,8 +523,8 @@ class GithubUtils { console.log(`Fetching New Expensify workflow runs for ${workflow}...`); return this.octokit.actions .listWorkflowRuns({ - owner: GITHUB_OWNER, - repo: APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, workflow_id: workflow, }) .then((response) => lodashGet(response, 'data.workflow_runs[0].id')); @@ -532,7 +547,7 @@ class GithubUtils { * @returns {String} */ static getPullRequestURLFromNumber(number) { - return `${APP_REPO_URL}/pull/${number}`; + return `${CONST.APP_REPO_URL}/pull/${number}`; } /** @@ -587,7 +602,7 @@ class GithubUtils { * @returns {Boolean} */ static isAutomatedPullRequest(pullRequest) { - return _.isEqual(lodashGet(pullRequest, 'user.login', ''), 'OSBotify'); + return _.isEqual(lodashGet(pullRequest, 'user.login', ''), CONST.OS_BOTIFY); } /** @@ -598,8 +613,8 @@ class GithubUtils { */ static getActorWhoClosedIssue(issueNumber) { return this.paginate(this.octokit.issues.listEvents, { - owner: GITHUB_OWNER, - repo: APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, issue_number: issueNumber, per_page: 100, }) @@ -609,12 +624,6 @@ class GithubUtils { } module.exports = GithubUtils; -module.exports.GITHUB_OWNER = GITHUB_OWNER; -module.exports.APP_REPO = APP_REPO; -module.exports.APP_REPO_URL = APP_REPO_URL; -module.exports.STAGING_DEPLOY_CASH_LABEL = STAGING_DEPLOY_CASH_LABEL; -module.exports.DEPLOY_BLOCKER_CASH_LABEL = DEPLOY_BLOCKER_CASH_LABEL; -module.exports.APPLAUSE_BOT = APPLAUSE_BOT; module.exports.ISSUE_OR_PULL_REQUEST_REGEX = ISSUE_OR_PULL_REQUEST_REGEX; module.exports.POLL_RATE = POLL_RATE; diff --git a/.github/actions/javascript/isPullRequestMergeable/index.js b/.github/actions/javascript/isPullRequestMergeable/index.js index 01971aa8457f..9b9945473892 100644 --- a/.github/actions/javascript/isPullRequestMergeable/index.js +++ b/.github/actions/javascript/isPullRequestMergeable/index.js @@ -10,6 +10,7 @@ module.exports = const _ = __nccwpck_require__(3571); const core = __nccwpck_require__(2186); +const CONST = __nccwpck_require__(4097); const GithubUtils = __nccwpck_require__(7999); const {promiseWhile} = __nccwpck_require__(4502); @@ -25,8 +26,8 @@ const run = function () { console.log(`Checking the mergeability of PR #${pullRequestNumber}`); return GithubUtils.octokit.pulls .get({ - owner: GithubUtils.GITHUB_OWNER, - repo: GithubUtils.APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, pull_number: pullRequestNumber, }) .then(({data}) => data.head.sha) @@ -37,13 +38,13 @@ const run = function () { () => Promise.all([ GithubUtils.octokit.pulls.get({ - owner: GithubUtils.GITHUB_OWNER, - repo: GithubUtils.APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, pull_number: pullRequestNumber, }), GithubUtils.octokit.checks.listForRef({ - owner: GithubUtils.GITHUB_OWNER, - repo: GithubUtils.APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, ref: headRef, }), ]) @@ -105,6 +106,29 @@ if (require.main === require.cache[eval('__filename')]) { module.exports = run; +/***/ }), + +/***/ 4097: +/***/ ((module) => { + +const CONST = { + GITHUB_OWNER: 'Expensify', + APP_REPO: 'App', + APPLAUSE_BOT: 'applausebot', + OS_BOTIFY: 'OSBotify', + LABELS: { + STAGING_DEPLOY: 'StagingDeployCash', + DEPLOY_BLOCKER: 'DeployBlockerCash', + INTERNAL_QA: 'InternalQA', + }, +}; + +CONST.APP_REPO_URL = `https://github.com/${CONST.GITHUB_OWNER}/${CONST.APP_REPO}`; +CONST.APP_REPO_GIT_URL = `git@github.com:${CONST.GITHUB_OWNER}/${CONST.APP_REPO}.git`; + +module.exports = CONST; + + /***/ }), /***/ 7999: @@ -116,21 +140,13 @@ const core = __nccwpck_require__(2186); const {GitHub, getOctokitOptions} = __nccwpck_require__(3030); const {throttling} = __nccwpck_require__(9968); const {paginateRest} = __nccwpck_require__(4193); - -const GITHUB_OWNER = 'Expensify'; -const APP_REPO = 'App'; -const APP_REPO_URL = 'https://github.com/Expensify/App'; +const CONST = __nccwpck_require__(4097); const GITHUB_BASE_URL_REGEX = new RegExp('https?://(?:github\\.com|api\\.github\\.com)'); const PULL_REQUEST_REGEX = new RegExp(`${GITHUB_BASE_URL_REGEX.source}/.*/.*/pull/([0-9]+).*`); const ISSUE_REGEX = new RegExp(`${GITHUB_BASE_URL_REGEX.source}/.*/.*/issues/([0-9]+).*`); const ISSUE_OR_PULL_REQUEST_REGEX = new RegExp(`${GITHUB_BASE_URL_REGEX.source}/.*/.*/(?:pull|issues)/([0-9]+).*`); -const APPLAUSE_BOT = 'applausebot'; -const STAGING_DEPLOY_CASH_LABEL = 'StagingDeployCash'; -const DEPLOY_BLOCKER_CASH_LABEL = 'DeployBlockerCash'; -const INTERNAL_QA_LABEL = 'InternalQA'; - /** * The standard rate in ms at which we'll poll the GitHub API to check for status changes. * It's 10 seconds :) @@ -208,20 +224,20 @@ class GithubUtils { static getStagingDeployCash() { return this.octokit.issues .listForRepo({ - owner: GITHUB_OWNER, - repo: APP_REPO, - labels: STAGING_DEPLOY_CASH_LABEL, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, + labels: CONST.LABELS.STAGING_DEPLOY, state: 'open', }) .then(({data}) => { if (!data.length) { - const error = new Error(`Unable to find ${STAGING_DEPLOY_CASH_LABEL} issue.`); + const error = new Error(`Unable to find ${CONST.LABELS.STAGING_DEPLOY} issue.`); error.code = 404; throw error; } if (data.length > 1) { - const error = new Error(`Found more than one ${STAGING_DEPLOY_CASH_LABEL} issue.`); + const error = new Error(`Found more than one ${CONST.LABELS.STAGING_DEPLOY} issue.`); error.code = 500; throw error; } @@ -254,7 +270,7 @@ class GithubUtils { tag, }; } catch (exception) { - throw new Error(`Unable to find ${STAGING_DEPLOY_CASH_LABEL} issue with correct data.`); + throw new Error(`Unable to find ${CONST.LABELS.STAGING_DEPLOY} issue with correct data.`); } } @@ -362,7 +378,7 @@ class GithubUtils { // 'https://github.com/Expensify/App/pull/9642': [ 'mountiny', 'kidroca' ] // } const internalQAPRMap = _.reduce( - _.filter(data, (pr) => !_.isEmpty(_.findWhere(pr.labels, {name: INTERNAL_QA_LABEL}))), + _.filter(data, (pr) => !_.isEmpty(_.findWhere(pr.labels, {name: CONST.LABELS.INTERNAL_QA}))), (map, pr) => { // eslint-disable-next-line no-param-reassign map[pr.html_url] = _.compact(_.pluck(pr.assignees, 'login')); @@ -450,8 +466,8 @@ class GithubUtils { return this.paginate( this.octokit.pulls.list, { - owner: GITHUB_OWNER, - repo: APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, state: 'all', sort: 'created', direction: 'desc', @@ -475,8 +491,8 @@ class GithubUtils { static getPullRequestBody(pullRequestNumber) { return this.octokit.pulls .get({ - owner: GITHUB_OWNER, - repo: APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, pull_number: pullRequestNumber, }) .then(({data: pullRequestComment}) => pullRequestComment.body); @@ -490,8 +506,8 @@ class GithubUtils { return this.paginate( this.octokit.pulls.listReviews, { - owner: GITHUB_OWNER, - repo: APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, pull_number: pullRequestNumber, per_page: 100, }, @@ -507,8 +523,8 @@ class GithubUtils { return this.paginate( this.octokit.issues.listComments, { - owner: GITHUB_OWNER, - repo: APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, issue_number: issueNumber, per_page: 100, }, @@ -527,7 +543,7 @@ class GithubUtils { static createComment(repo, number, messageBody) { console.log(`Writing comment on #${number}`); return this.octokit.issues.createComment({ - owner: GITHUB_OWNER, + owner: CONST.GITHUB_OWNER, repo, issue_number: number, body: messageBody, @@ -544,8 +560,8 @@ class GithubUtils { console.log(`Fetching New Expensify workflow runs for ${workflow}...`); return this.octokit.actions .listWorkflowRuns({ - owner: GITHUB_OWNER, - repo: APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, workflow_id: workflow, }) .then((response) => lodashGet(response, 'data.workflow_runs[0].id')); @@ -568,7 +584,7 @@ class GithubUtils { * @returns {String} */ static getPullRequestURLFromNumber(number) { - return `${APP_REPO_URL}/pull/${number}`; + return `${CONST.APP_REPO_URL}/pull/${number}`; } /** @@ -623,7 +639,7 @@ class GithubUtils { * @returns {Boolean} */ static isAutomatedPullRequest(pullRequest) { - return _.isEqual(lodashGet(pullRequest, 'user.login', ''), 'OSBotify'); + return _.isEqual(lodashGet(pullRequest, 'user.login', ''), CONST.OS_BOTIFY); } /** @@ -634,8 +650,8 @@ class GithubUtils { */ static getActorWhoClosedIssue(issueNumber) { return this.paginate(this.octokit.issues.listEvents, { - owner: GITHUB_OWNER, - repo: APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, issue_number: issueNumber, per_page: 100, }) @@ -645,12 +661,6 @@ class GithubUtils { } module.exports = GithubUtils; -module.exports.GITHUB_OWNER = GITHUB_OWNER; -module.exports.APP_REPO = APP_REPO; -module.exports.APP_REPO_URL = APP_REPO_URL; -module.exports.STAGING_DEPLOY_CASH_LABEL = STAGING_DEPLOY_CASH_LABEL; -module.exports.DEPLOY_BLOCKER_CASH_LABEL = DEPLOY_BLOCKER_CASH_LABEL; -module.exports.APPLAUSE_BOT = APPLAUSE_BOT; module.exports.ISSUE_OR_PULL_REQUEST_REGEX = ISSUE_OR_PULL_REQUEST_REGEX; module.exports.POLL_RATE = POLL_RATE; diff --git a/.github/actions/javascript/isPullRequestMergeable/isPullRequestMergeable.js b/.github/actions/javascript/isPullRequestMergeable/isPullRequestMergeable.js index 4034502aed76..25d08e7583ba 100644 --- a/.github/actions/javascript/isPullRequestMergeable/isPullRequestMergeable.js +++ b/.github/actions/javascript/isPullRequestMergeable/isPullRequestMergeable.js @@ -1,5 +1,6 @@ const _ = require('underscore'); const core = require('@actions/core'); +const CONST = require('../../../libs/CONST'); const GithubUtils = require('../../../libs/GithubUtils'); const {promiseWhile} = require('../../../libs/promiseWhile'); @@ -15,8 +16,8 @@ const run = function () { console.log(`Checking the mergeability of PR #${pullRequestNumber}`); return GithubUtils.octokit.pulls .get({ - owner: GithubUtils.GITHUB_OWNER, - repo: GithubUtils.APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, pull_number: pullRequestNumber, }) .then(({data}) => data.head.sha) @@ -27,13 +28,13 @@ const run = function () { () => Promise.all([ GithubUtils.octokit.pulls.get({ - owner: GithubUtils.GITHUB_OWNER, - repo: GithubUtils.APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, pull_number: pullRequestNumber, }), GithubUtils.octokit.checks.listForRef({ - owner: GithubUtils.GITHUB_OWNER, - repo: GithubUtils.APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, ref: headRef, }), ]) diff --git a/.github/actions/javascript/isStagingDeployLocked/index.js b/.github/actions/javascript/isStagingDeployLocked/index.js index 4f37c96260b8..650021e3cbb3 100644 --- a/.github/actions/javascript/isStagingDeployLocked/index.js +++ b/.github/actions/javascript/isStagingDeployLocked/index.js @@ -33,6 +33,29 @@ if (require.main === require.cache[eval('__filename')]) { module.exports = run; +/***/ }), + +/***/ 4097: +/***/ ((module) => { + +const CONST = { + GITHUB_OWNER: 'Expensify', + APP_REPO: 'App', + APPLAUSE_BOT: 'applausebot', + OS_BOTIFY: 'OSBotify', + LABELS: { + STAGING_DEPLOY: 'StagingDeployCash', + DEPLOY_BLOCKER: 'DeployBlockerCash', + INTERNAL_QA: 'InternalQA', + }, +}; + +CONST.APP_REPO_URL = `https://github.com/${CONST.GITHUB_OWNER}/${CONST.APP_REPO}`; +CONST.APP_REPO_GIT_URL = `git@github.com:${CONST.GITHUB_OWNER}/${CONST.APP_REPO}.git`; + +module.exports = CONST; + + /***/ }), /***/ 7999: @@ -44,21 +67,13 @@ const core = __nccwpck_require__(2186); const {GitHub, getOctokitOptions} = __nccwpck_require__(3030); const {throttling} = __nccwpck_require__(9968); const {paginateRest} = __nccwpck_require__(4193); - -const GITHUB_OWNER = 'Expensify'; -const APP_REPO = 'App'; -const APP_REPO_URL = 'https://github.com/Expensify/App'; +const CONST = __nccwpck_require__(4097); const GITHUB_BASE_URL_REGEX = new RegExp('https?://(?:github\\.com|api\\.github\\.com)'); const PULL_REQUEST_REGEX = new RegExp(`${GITHUB_BASE_URL_REGEX.source}/.*/.*/pull/([0-9]+).*`); const ISSUE_REGEX = new RegExp(`${GITHUB_BASE_URL_REGEX.source}/.*/.*/issues/([0-9]+).*`); const ISSUE_OR_PULL_REQUEST_REGEX = new RegExp(`${GITHUB_BASE_URL_REGEX.source}/.*/.*/(?:pull|issues)/([0-9]+).*`); -const APPLAUSE_BOT = 'applausebot'; -const STAGING_DEPLOY_CASH_LABEL = 'StagingDeployCash'; -const DEPLOY_BLOCKER_CASH_LABEL = 'DeployBlockerCash'; -const INTERNAL_QA_LABEL = 'InternalQA'; - /** * The standard rate in ms at which we'll poll the GitHub API to check for status changes. * It's 10 seconds :) @@ -136,20 +151,20 @@ class GithubUtils { static getStagingDeployCash() { return this.octokit.issues .listForRepo({ - owner: GITHUB_OWNER, - repo: APP_REPO, - labels: STAGING_DEPLOY_CASH_LABEL, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, + labels: CONST.LABELS.STAGING_DEPLOY, state: 'open', }) .then(({data}) => { if (!data.length) { - const error = new Error(`Unable to find ${STAGING_DEPLOY_CASH_LABEL} issue.`); + const error = new Error(`Unable to find ${CONST.LABELS.STAGING_DEPLOY} issue.`); error.code = 404; throw error; } if (data.length > 1) { - const error = new Error(`Found more than one ${STAGING_DEPLOY_CASH_LABEL} issue.`); + const error = new Error(`Found more than one ${CONST.LABELS.STAGING_DEPLOY} issue.`); error.code = 500; throw error; } @@ -182,7 +197,7 @@ class GithubUtils { tag, }; } catch (exception) { - throw new Error(`Unable to find ${STAGING_DEPLOY_CASH_LABEL} issue with correct data.`); + throw new Error(`Unable to find ${CONST.LABELS.STAGING_DEPLOY} issue with correct data.`); } } @@ -290,7 +305,7 @@ class GithubUtils { // 'https://github.com/Expensify/App/pull/9642': [ 'mountiny', 'kidroca' ] // } const internalQAPRMap = _.reduce( - _.filter(data, (pr) => !_.isEmpty(_.findWhere(pr.labels, {name: INTERNAL_QA_LABEL}))), + _.filter(data, (pr) => !_.isEmpty(_.findWhere(pr.labels, {name: CONST.LABELS.INTERNAL_QA}))), (map, pr) => { // eslint-disable-next-line no-param-reassign map[pr.html_url] = _.compact(_.pluck(pr.assignees, 'login')); @@ -378,8 +393,8 @@ class GithubUtils { return this.paginate( this.octokit.pulls.list, { - owner: GITHUB_OWNER, - repo: APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, state: 'all', sort: 'created', direction: 'desc', @@ -403,8 +418,8 @@ class GithubUtils { static getPullRequestBody(pullRequestNumber) { return this.octokit.pulls .get({ - owner: GITHUB_OWNER, - repo: APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, pull_number: pullRequestNumber, }) .then(({data: pullRequestComment}) => pullRequestComment.body); @@ -418,8 +433,8 @@ class GithubUtils { return this.paginate( this.octokit.pulls.listReviews, { - owner: GITHUB_OWNER, - repo: APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, pull_number: pullRequestNumber, per_page: 100, }, @@ -435,8 +450,8 @@ class GithubUtils { return this.paginate( this.octokit.issues.listComments, { - owner: GITHUB_OWNER, - repo: APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, issue_number: issueNumber, per_page: 100, }, @@ -455,7 +470,7 @@ class GithubUtils { static createComment(repo, number, messageBody) { console.log(`Writing comment on #${number}`); return this.octokit.issues.createComment({ - owner: GITHUB_OWNER, + owner: CONST.GITHUB_OWNER, repo, issue_number: number, body: messageBody, @@ -472,8 +487,8 @@ class GithubUtils { console.log(`Fetching New Expensify workflow runs for ${workflow}...`); return this.octokit.actions .listWorkflowRuns({ - owner: GITHUB_OWNER, - repo: APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, workflow_id: workflow, }) .then((response) => lodashGet(response, 'data.workflow_runs[0].id')); @@ -496,7 +511,7 @@ class GithubUtils { * @returns {String} */ static getPullRequestURLFromNumber(number) { - return `${APP_REPO_URL}/pull/${number}`; + return `${CONST.APP_REPO_URL}/pull/${number}`; } /** @@ -551,7 +566,7 @@ class GithubUtils { * @returns {Boolean} */ static isAutomatedPullRequest(pullRequest) { - return _.isEqual(lodashGet(pullRequest, 'user.login', ''), 'OSBotify'); + return _.isEqual(lodashGet(pullRequest, 'user.login', ''), CONST.OS_BOTIFY); } /** @@ -562,8 +577,8 @@ class GithubUtils { */ static getActorWhoClosedIssue(issueNumber) { return this.paginate(this.octokit.issues.listEvents, { - owner: GITHUB_OWNER, - repo: APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, issue_number: issueNumber, per_page: 100, }) @@ -573,12 +588,6 @@ class GithubUtils { } module.exports = GithubUtils; -module.exports.GITHUB_OWNER = GITHUB_OWNER; -module.exports.APP_REPO = APP_REPO; -module.exports.APP_REPO_URL = APP_REPO_URL; -module.exports.STAGING_DEPLOY_CASH_LABEL = STAGING_DEPLOY_CASH_LABEL; -module.exports.DEPLOY_BLOCKER_CASH_LABEL = DEPLOY_BLOCKER_CASH_LABEL; -module.exports.APPLAUSE_BOT = APPLAUSE_BOT; module.exports.ISSUE_OR_PULL_REQUEST_REGEX = ISSUE_OR_PULL_REQUEST_REGEX; module.exports.POLL_RATE = POLL_RATE; diff --git a/.github/actions/javascript/markPullRequestsAsDeployed/index.js b/.github/actions/javascript/markPullRequestsAsDeployed/index.js index f6f72552286c..6174a21f629f 100644 --- a/.github/actions/javascript/markPullRequestsAsDeployed/index.js +++ b/.github/actions/javascript/markPullRequestsAsDeployed/index.js @@ -12,6 +12,7 @@ const _ = __nccwpck_require__(3571); const lodashGet = __nccwpck_require__(6908); const core = __nccwpck_require__(2186); const {context} = __nccwpck_require__(5438); +const CONST = __nccwpck_require__(4097); const ActionUtils = __nccwpck_require__(970); const GithubUtils = __nccwpck_require__(7999); @@ -88,9 +89,9 @@ const run = function () { // First find the deployer (who closed the last deploy checklist)? return GithubUtils.octokit.issues .listForRepo({ - owner: GithubUtils.GITHUB_OWNER, - repo: GithubUtils.APP_REPO, - labels: GithubUtils.STAGING_DEPLOY_CASH_LABEL, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, + labels: CONST.LABELS.STAGING_DEPLOY, state: 'closed', }) .then(({data}) => _.first(data).number) @@ -105,15 +106,15 @@ const run = function () { // First find out if this is a normal staging deploy or a CP by looking at the commit message on the tag return GithubUtils.octokit.repos .listTags({ - owner: GithubUtils.GITHUB_OWNER, - repo: GithubUtils.APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, per_page: 100, }) .then(({data}) => { const tagSHA = _.find(data, (tag) => tag.name === version).commit.sha; return GithubUtils.octokit.git.getCommit({ - owner: GithubUtils.GITHUB_OWNER, - repo: GithubUtils.APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, commit_sha: tagSHA, }); }) @@ -127,8 +128,8 @@ const run = function () { // Then, for each PR, find out who merged it and determine the deployer .then(() => GithubUtils.octokit.pulls.get({ - owner: GithubUtils.GITHUB_OWNER, - repo: GithubUtils.APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, pull_number: PR, }), ) @@ -143,7 +144,7 @@ const run = function () { let deployer = lodashGet(response, 'data.merged_by.login', ''); const issueTitle = lodashGet(response, 'data.title', ''); const CPActorMatches = data.message.match(/Merge pull request #\d+ from Expensify\/(.+)-cherry-pick-staging-\d+/); - if (_.isArray(CPActorMatches) && CPActorMatches.length === 2 && CPActorMatches[1] !== 'OSBotify') { + if (_.isArray(CPActorMatches) && CPActorMatches.length === 2 && CPActorMatches[1] !== CONST.OS_BOTIFY) { deployer = CPActorMatches[1]; } @@ -209,6 +210,29 @@ module.exports = { }; +/***/ }), + +/***/ 4097: +/***/ ((module) => { + +const CONST = { + GITHUB_OWNER: 'Expensify', + APP_REPO: 'App', + APPLAUSE_BOT: 'applausebot', + OS_BOTIFY: 'OSBotify', + LABELS: { + STAGING_DEPLOY: 'StagingDeployCash', + DEPLOY_BLOCKER: 'DeployBlockerCash', + INTERNAL_QA: 'InternalQA', + }, +}; + +CONST.APP_REPO_URL = `https://github.com/${CONST.GITHUB_OWNER}/${CONST.APP_REPO}`; +CONST.APP_REPO_GIT_URL = `git@github.com:${CONST.GITHUB_OWNER}/${CONST.APP_REPO}.git`; + +module.exports = CONST; + + /***/ }), /***/ 7999: @@ -220,21 +244,13 @@ const core = __nccwpck_require__(2186); const {GitHub, getOctokitOptions} = __nccwpck_require__(3030); const {throttling} = __nccwpck_require__(9968); const {paginateRest} = __nccwpck_require__(4193); - -const GITHUB_OWNER = 'Expensify'; -const APP_REPO = 'App'; -const APP_REPO_URL = 'https://github.com/Expensify/App'; +const CONST = __nccwpck_require__(4097); const GITHUB_BASE_URL_REGEX = new RegExp('https?://(?:github\\.com|api\\.github\\.com)'); const PULL_REQUEST_REGEX = new RegExp(`${GITHUB_BASE_URL_REGEX.source}/.*/.*/pull/([0-9]+).*`); const ISSUE_REGEX = new RegExp(`${GITHUB_BASE_URL_REGEX.source}/.*/.*/issues/([0-9]+).*`); const ISSUE_OR_PULL_REQUEST_REGEX = new RegExp(`${GITHUB_BASE_URL_REGEX.source}/.*/.*/(?:pull|issues)/([0-9]+).*`); -const APPLAUSE_BOT = 'applausebot'; -const STAGING_DEPLOY_CASH_LABEL = 'StagingDeployCash'; -const DEPLOY_BLOCKER_CASH_LABEL = 'DeployBlockerCash'; -const INTERNAL_QA_LABEL = 'InternalQA'; - /** * The standard rate in ms at which we'll poll the GitHub API to check for status changes. * It's 10 seconds :) @@ -312,20 +328,20 @@ class GithubUtils { static getStagingDeployCash() { return this.octokit.issues .listForRepo({ - owner: GITHUB_OWNER, - repo: APP_REPO, - labels: STAGING_DEPLOY_CASH_LABEL, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, + labels: CONST.LABELS.STAGING_DEPLOY, state: 'open', }) .then(({data}) => { if (!data.length) { - const error = new Error(`Unable to find ${STAGING_DEPLOY_CASH_LABEL} issue.`); + const error = new Error(`Unable to find ${CONST.LABELS.STAGING_DEPLOY} issue.`); error.code = 404; throw error; } if (data.length > 1) { - const error = new Error(`Found more than one ${STAGING_DEPLOY_CASH_LABEL} issue.`); + const error = new Error(`Found more than one ${CONST.LABELS.STAGING_DEPLOY} issue.`); error.code = 500; throw error; } @@ -358,7 +374,7 @@ class GithubUtils { tag, }; } catch (exception) { - throw new Error(`Unable to find ${STAGING_DEPLOY_CASH_LABEL} issue with correct data.`); + throw new Error(`Unable to find ${CONST.LABELS.STAGING_DEPLOY} issue with correct data.`); } } @@ -466,7 +482,7 @@ class GithubUtils { // 'https://github.com/Expensify/App/pull/9642': [ 'mountiny', 'kidroca' ] // } const internalQAPRMap = _.reduce( - _.filter(data, (pr) => !_.isEmpty(_.findWhere(pr.labels, {name: INTERNAL_QA_LABEL}))), + _.filter(data, (pr) => !_.isEmpty(_.findWhere(pr.labels, {name: CONST.LABELS.INTERNAL_QA}))), (map, pr) => { // eslint-disable-next-line no-param-reassign map[pr.html_url] = _.compact(_.pluck(pr.assignees, 'login')); @@ -554,8 +570,8 @@ class GithubUtils { return this.paginate( this.octokit.pulls.list, { - owner: GITHUB_OWNER, - repo: APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, state: 'all', sort: 'created', direction: 'desc', @@ -579,8 +595,8 @@ class GithubUtils { static getPullRequestBody(pullRequestNumber) { return this.octokit.pulls .get({ - owner: GITHUB_OWNER, - repo: APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, pull_number: pullRequestNumber, }) .then(({data: pullRequestComment}) => pullRequestComment.body); @@ -594,8 +610,8 @@ class GithubUtils { return this.paginate( this.octokit.pulls.listReviews, { - owner: GITHUB_OWNER, - repo: APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, pull_number: pullRequestNumber, per_page: 100, }, @@ -611,8 +627,8 @@ class GithubUtils { return this.paginate( this.octokit.issues.listComments, { - owner: GITHUB_OWNER, - repo: APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, issue_number: issueNumber, per_page: 100, }, @@ -631,7 +647,7 @@ class GithubUtils { static createComment(repo, number, messageBody) { console.log(`Writing comment on #${number}`); return this.octokit.issues.createComment({ - owner: GITHUB_OWNER, + owner: CONST.GITHUB_OWNER, repo, issue_number: number, body: messageBody, @@ -648,8 +664,8 @@ class GithubUtils { console.log(`Fetching New Expensify workflow runs for ${workflow}...`); return this.octokit.actions .listWorkflowRuns({ - owner: GITHUB_OWNER, - repo: APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, workflow_id: workflow, }) .then((response) => lodashGet(response, 'data.workflow_runs[0].id')); @@ -672,7 +688,7 @@ class GithubUtils { * @returns {String} */ static getPullRequestURLFromNumber(number) { - return `${APP_REPO_URL}/pull/${number}`; + return `${CONST.APP_REPO_URL}/pull/${number}`; } /** @@ -727,7 +743,7 @@ class GithubUtils { * @returns {Boolean} */ static isAutomatedPullRequest(pullRequest) { - return _.isEqual(lodashGet(pullRequest, 'user.login', ''), 'OSBotify'); + return _.isEqual(lodashGet(pullRequest, 'user.login', ''), CONST.OS_BOTIFY); } /** @@ -738,8 +754,8 @@ class GithubUtils { */ static getActorWhoClosedIssue(issueNumber) { return this.paginate(this.octokit.issues.listEvents, { - owner: GITHUB_OWNER, - repo: APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, issue_number: issueNumber, per_page: 100, }) @@ -749,12 +765,6 @@ class GithubUtils { } module.exports = GithubUtils; -module.exports.GITHUB_OWNER = GITHUB_OWNER; -module.exports.APP_REPO = APP_REPO; -module.exports.APP_REPO_URL = APP_REPO_URL; -module.exports.STAGING_DEPLOY_CASH_LABEL = STAGING_DEPLOY_CASH_LABEL; -module.exports.DEPLOY_BLOCKER_CASH_LABEL = DEPLOY_BLOCKER_CASH_LABEL; -module.exports.APPLAUSE_BOT = APPLAUSE_BOT; module.exports.ISSUE_OR_PULL_REQUEST_REGEX = ISSUE_OR_PULL_REQUEST_REGEX; module.exports.POLL_RATE = POLL_RATE; diff --git a/.github/actions/javascript/markPullRequestsAsDeployed/markPullRequestsAsDeployed.js b/.github/actions/javascript/markPullRequestsAsDeployed/markPullRequestsAsDeployed.js index a1f23706caa9..708d001892c2 100644 --- a/.github/actions/javascript/markPullRequestsAsDeployed/markPullRequestsAsDeployed.js +++ b/.github/actions/javascript/markPullRequestsAsDeployed/markPullRequestsAsDeployed.js @@ -2,6 +2,7 @@ const _ = require('underscore'); const lodashGet = require('lodash/get'); const core = require('@actions/core'); const {context} = require('@actions/github'); +const CONST = require('../../../libs/CONST'); const ActionUtils = require('../../../libs/ActionUtils'); const GithubUtils = require('../../../libs/GithubUtils'); @@ -78,9 +79,9 @@ const run = function () { // First find the deployer (who closed the last deploy checklist)? return GithubUtils.octokit.issues .listForRepo({ - owner: GithubUtils.GITHUB_OWNER, - repo: GithubUtils.APP_REPO, - labels: GithubUtils.STAGING_DEPLOY_CASH_LABEL, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, + labels: CONST.LABELS.STAGING_DEPLOY, state: 'closed', }) .then(({data}) => _.first(data).number) @@ -95,15 +96,15 @@ const run = function () { // First find out if this is a normal staging deploy or a CP by looking at the commit message on the tag return GithubUtils.octokit.repos .listTags({ - owner: GithubUtils.GITHUB_OWNER, - repo: GithubUtils.APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, per_page: 100, }) .then(({data}) => { const tagSHA = _.find(data, (tag) => tag.name === version).commit.sha; return GithubUtils.octokit.git.getCommit({ - owner: GithubUtils.GITHUB_OWNER, - repo: GithubUtils.APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, commit_sha: tagSHA, }); }) @@ -117,8 +118,8 @@ const run = function () { // Then, for each PR, find out who merged it and determine the deployer .then(() => GithubUtils.octokit.pulls.get({ - owner: GithubUtils.GITHUB_OWNER, - repo: GithubUtils.APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, pull_number: PR, }), ) @@ -133,7 +134,7 @@ const run = function () { let deployer = lodashGet(response, 'data.merged_by.login', ''); const issueTitle = lodashGet(response, 'data.title', ''); const CPActorMatches = data.message.match(/Merge pull request #\d+ from Expensify\/(.+)-cherry-pick-staging-\d+/); - if (_.isArray(CPActorMatches) && CPActorMatches.length === 2 && CPActorMatches[1] !== 'OSBotify') { + if (_.isArray(CPActorMatches) && CPActorMatches.length === 2 && CPActorMatches[1] !== CONST.OS_BOTIFY) { deployer = CPActorMatches[1]; } diff --git a/.github/actions/javascript/postTestBuildComment/index.js b/.github/actions/javascript/postTestBuildComment/index.js index 8aaeeac8999f..c52177037668 100644 --- a/.github/actions/javascript/postTestBuildComment/index.js +++ b/.github/actions/javascript/postTestBuildComment/index.js @@ -77,6 +77,29 @@ if (require.main === require.cache[eval('__filename')]) { module.exports = run; +/***/ }), + +/***/ 4097: +/***/ ((module) => { + +const CONST = { + GITHUB_OWNER: 'Expensify', + APP_REPO: 'App', + APPLAUSE_BOT: 'applausebot', + OS_BOTIFY: 'OSBotify', + LABELS: { + STAGING_DEPLOY: 'StagingDeployCash', + DEPLOY_BLOCKER: 'DeployBlockerCash', + INTERNAL_QA: 'InternalQA', + }, +}; + +CONST.APP_REPO_URL = `https://github.com/${CONST.GITHUB_OWNER}/${CONST.APP_REPO}`; +CONST.APP_REPO_GIT_URL = `git@github.com:${CONST.GITHUB_OWNER}/${CONST.APP_REPO}.git`; + +module.exports = CONST; + + /***/ }), /***/ 7999: @@ -88,21 +111,13 @@ const core = __nccwpck_require__(2186); const {GitHub, getOctokitOptions} = __nccwpck_require__(3030); const {throttling} = __nccwpck_require__(9968); const {paginateRest} = __nccwpck_require__(4193); - -const GITHUB_OWNER = 'Expensify'; -const APP_REPO = 'App'; -const APP_REPO_URL = 'https://github.com/Expensify/App'; +const CONST = __nccwpck_require__(4097); const GITHUB_BASE_URL_REGEX = new RegExp('https?://(?:github\\.com|api\\.github\\.com)'); const PULL_REQUEST_REGEX = new RegExp(`${GITHUB_BASE_URL_REGEX.source}/.*/.*/pull/([0-9]+).*`); const ISSUE_REGEX = new RegExp(`${GITHUB_BASE_URL_REGEX.source}/.*/.*/issues/([0-9]+).*`); const ISSUE_OR_PULL_REQUEST_REGEX = new RegExp(`${GITHUB_BASE_URL_REGEX.source}/.*/.*/(?:pull|issues)/([0-9]+).*`); -const APPLAUSE_BOT = 'applausebot'; -const STAGING_DEPLOY_CASH_LABEL = 'StagingDeployCash'; -const DEPLOY_BLOCKER_CASH_LABEL = 'DeployBlockerCash'; -const INTERNAL_QA_LABEL = 'InternalQA'; - /** * The standard rate in ms at which we'll poll the GitHub API to check for status changes. * It's 10 seconds :) @@ -180,20 +195,20 @@ class GithubUtils { static getStagingDeployCash() { return this.octokit.issues .listForRepo({ - owner: GITHUB_OWNER, - repo: APP_REPO, - labels: STAGING_DEPLOY_CASH_LABEL, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, + labels: CONST.LABELS.STAGING_DEPLOY, state: 'open', }) .then(({data}) => { if (!data.length) { - const error = new Error(`Unable to find ${STAGING_DEPLOY_CASH_LABEL} issue.`); + const error = new Error(`Unable to find ${CONST.LABELS.STAGING_DEPLOY} issue.`); error.code = 404; throw error; } if (data.length > 1) { - const error = new Error(`Found more than one ${STAGING_DEPLOY_CASH_LABEL} issue.`); + const error = new Error(`Found more than one ${CONST.LABELS.STAGING_DEPLOY} issue.`); error.code = 500; throw error; } @@ -226,7 +241,7 @@ class GithubUtils { tag, }; } catch (exception) { - throw new Error(`Unable to find ${STAGING_DEPLOY_CASH_LABEL} issue with correct data.`); + throw new Error(`Unable to find ${CONST.LABELS.STAGING_DEPLOY} issue with correct data.`); } } @@ -334,7 +349,7 @@ class GithubUtils { // 'https://github.com/Expensify/App/pull/9642': [ 'mountiny', 'kidroca' ] // } const internalQAPRMap = _.reduce( - _.filter(data, (pr) => !_.isEmpty(_.findWhere(pr.labels, {name: INTERNAL_QA_LABEL}))), + _.filter(data, (pr) => !_.isEmpty(_.findWhere(pr.labels, {name: CONST.LABELS.INTERNAL_QA}))), (map, pr) => { // eslint-disable-next-line no-param-reassign map[pr.html_url] = _.compact(_.pluck(pr.assignees, 'login')); @@ -422,8 +437,8 @@ class GithubUtils { return this.paginate( this.octokit.pulls.list, { - owner: GITHUB_OWNER, - repo: APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, state: 'all', sort: 'created', direction: 'desc', @@ -447,8 +462,8 @@ class GithubUtils { static getPullRequestBody(pullRequestNumber) { return this.octokit.pulls .get({ - owner: GITHUB_OWNER, - repo: APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, pull_number: pullRequestNumber, }) .then(({data: pullRequestComment}) => pullRequestComment.body); @@ -462,8 +477,8 @@ class GithubUtils { return this.paginate( this.octokit.pulls.listReviews, { - owner: GITHUB_OWNER, - repo: APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, pull_number: pullRequestNumber, per_page: 100, }, @@ -479,8 +494,8 @@ class GithubUtils { return this.paginate( this.octokit.issues.listComments, { - owner: GITHUB_OWNER, - repo: APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, issue_number: issueNumber, per_page: 100, }, @@ -499,7 +514,7 @@ class GithubUtils { static createComment(repo, number, messageBody) { console.log(`Writing comment on #${number}`); return this.octokit.issues.createComment({ - owner: GITHUB_OWNER, + owner: CONST.GITHUB_OWNER, repo, issue_number: number, body: messageBody, @@ -516,8 +531,8 @@ class GithubUtils { console.log(`Fetching New Expensify workflow runs for ${workflow}...`); return this.octokit.actions .listWorkflowRuns({ - owner: GITHUB_OWNER, - repo: APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, workflow_id: workflow, }) .then((response) => lodashGet(response, 'data.workflow_runs[0].id')); @@ -540,7 +555,7 @@ class GithubUtils { * @returns {String} */ static getPullRequestURLFromNumber(number) { - return `${APP_REPO_URL}/pull/${number}`; + return `${CONST.APP_REPO_URL}/pull/${number}`; } /** @@ -595,7 +610,7 @@ class GithubUtils { * @returns {Boolean} */ static isAutomatedPullRequest(pullRequest) { - return _.isEqual(lodashGet(pullRequest, 'user.login', ''), 'OSBotify'); + return _.isEqual(lodashGet(pullRequest, 'user.login', ''), CONST.OS_BOTIFY); } /** @@ -606,8 +621,8 @@ class GithubUtils { */ static getActorWhoClosedIssue(issueNumber) { return this.paginate(this.octokit.issues.listEvents, { - owner: GITHUB_OWNER, - repo: APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, issue_number: issueNumber, per_page: 100, }) @@ -617,12 +632,6 @@ class GithubUtils { } module.exports = GithubUtils; -module.exports.GITHUB_OWNER = GITHUB_OWNER; -module.exports.APP_REPO = APP_REPO; -module.exports.APP_REPO_URL = APP_REPO_URL; -module.exports.STAGING_DEPLOY_CASH_LABEL = STAGING_DEPLOY_CASH_LABEL; -module.exports.DEPLOY_BLOCKER_CASH_LABEL = DEPLOY_BLOCKER_CASH_LABEL; -module.exports.APPLAUSE_BOT = APPLAUSE_BOT; module.exports.ISSUE_OR_PULL_REQUEST_REGEX = ISSUE_OR_PULL_REQUEST_REGEX; module.exports.POLL_RATE = POLL_RATE; diff --git a/.github/actions/javascript/reopenIssueWithComment/index.js b/.github/actions/javascript/reopenIssueWithComment/index.js index 0ed6a74df75a..4c5167ca3275 100644 --- a/.github/actions/javascript/reopenIssueWithComment/index.js +++ b/.github/actions/javascript/reopenIssueWithComment/index.js @@ -9,6 +9,7 @@ module.exports = /***/ ((__unused_webpack_module, __unused_webpack_exports, __nccwpck_require__) => { const core = __nccwpck_require__(2186); +const CONST = __nccwpck_require__(4097); const GithubUtils = __nccwpck_require__(7999); const issueNumber = core.getInput('ISSUE_NUMBER', {required: true}); @@ -18,16 +19,16 @@ function reopenIssueWithComment() { console.log(`Reopening issue #${issueNumber}`); return GithubUtils.octokit.issues .update({ - owner: GithubUtils.GITHUB_OWNER, - repo: GithubUtils.APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, issue_number: issueNumber, state: 'open', }) .then(() => { console.log(`Commenting on issue #${issueNumber}`); return GithubUtils.octokit.issues.createComment({ - owner: GithubUtils.GITHUB_OWNER, - repo: GithubUtils.APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, issue_number: issueNumber, body: comment, }); @@ -45,6 +46,29 @@ reopenIssueWithComment() }); +/***/ }), + +/***/ 4097: +/***/ ((module) => { + +const CONST = { + GITHUB_OWNER: 'Expensify', + APP_REPO: 'App', + APPLAUSE_BOT: 'applausebot', + OS_BOTIFY: 'OSBotify', + LABELS: { + STAGING_DEPLOY: 'StagingDeployCash', + DEPLOY_BLOCKER: 'DeployBlockerCash', + INTERNAL_QA: 'InternalQA', + }, +}; + +CONST.APP_REPO_URL = `https://github.com/${CONST.GITHUB_OWNER}/${CONST.APP_REPO}`; +CONST.APP_REPO_GIT_URL = `git@github.com:${CONST.GITHUB_OWNER}/${CONST.APP_REPO}.git`; + +module.exports = CONST; + + /***/ }), /***/ 7999: @@ -56,21 +80,13 @@ const core = __nccwpck_require__(2186); const {GitHub, getOctokitOptions} = __nccwpck_require__(3030); const {throttling} = __nccwpck_require__(9968); const {paginateRest} = __nccwpck_require__(4193); - -const GITHUB_OWNER = 'Expensify'; -const APP_REPO = 'App'; -const APP_REPO_URL = 'https://github.com/Expensify/App'; +const CONST = __nccwpck_require__(4097); const GITHUB_BASE_URL_REGEX = new RegExp('https?://(?:github\\.com|api\\.github\\.com)'); const PULL_REQUEST_REGEX = new RegExp(`${GITHUB_BASE_URL_REGEX.source}/.*/.*/pull/([0-9]+).*`); const ISSUE_REGEX = new RegExp(`${GITHUB_BASE_URL_REGEX.source}/.*/.*/issues/([0-9]+).*`); const ISSUE_OR_PULL_REQUEST_REGEX = new RegExp(`${GITHUB_BASE_URL_REGEX.source}/.*/.*/(?:pull|issues)/([0-9]+).*`); -const APPLAUSE_BOT = 'applausebot'; -const STAGING_DEPLOY_CASH_LABEL = 'StagingDeployCash'; -const DEPLOY_BLOCKER_CASH_LABEL = 'DeployBlockerCash'; -const INTERNAL_QA_LABEL = 'InternalQA'; - /** * The standard rate in ms at which we'll poll the GitHub API to check for status changes. * It's 10 seconds :) @@ -148,20 +164,20 @@ class GithubUtils { static getStagingDeployCash() { return this.octokit.issues .listForRepo({ - owner: GITHUB_OWNER, - repo: APP_REPO, - labels: STAGING_DEPLOY_CASH_LABEL, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, + labels: CONST.LABELS.STAGING_DEPLOY, state: 'open', }) .then(({data}) => { if (!data.length) { - const error = new Error(`Unable to find ${STAGING_DEPLOY_CASH_LABEL} issue.`); + const error = new Error(`Unable to find ${CONST.LABELS.STAGING_DEPLOY} issue.`); error.code = 404; throw error; } if (data.length > 1) { - const error = new Error(`Found more than one ${STAGING_DEPLOY_CASH_LABEL} issue.`); + const error = new Error(`Found more than one ${CONST.LABELS.STAGING_DEPLOY} issue.`); error.code = 500; throw error; } @@ -194,7 +210,7 @@ class GithubUtils { tag, }; } catch (exception) { - throw new Error(`Unable to find ${STAGING_DEPLOY_CASH_LABEL} issue with correct data.`); + throw new Error(`Unable to find ${CONST.LABELS.STAGING_DEPLOY} issue with correct data.`); } } @@ -302,7 +318,7 @@ class GithubUtils { // 'https://github.com/Expensify/App/pull/9642': [ 'mountiny', 'kidroca' ] // } const internalQAPRMap = _.reduce( - _.filter(data, (pr) => !_.isEmpty(_.findWhere(pr.labels, {name: INTERNAL_QA_LABEL}))), + _.filter(data, (pr) => !_.isEmpty(_.findWhere(pr.labels, {name: CONST.LABELS.INTERNAL_QA}))), (map, pr) => { // eslint-disable-next-line no-param-reassign map[pr.html_url] = _.compact(_.pluck(pr.assignees, 'login')); @@ -390,8 +406,8 @@ class GithubUtils { return this.paginate( this.octokit.pulls.list, { - owner: GITHUB_OWNER, - repo: APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, state: 'all', sort: 'created', direction: 'desc', @@ -415,8 +431,8 @@ class GithubUtils { static getPullRequestBody(pullRequestNumber) { return this.octokit.pulls .get({ - owner: GITHUB_OWNER, - repo: APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, pull_number: pullRequestNumber, }) .then(({data: pullRequestComment}) => pullRequestComment.body); @@ -430,8 +446,8 @@ class GithubUtils { return this.paginate( this.octokit.pulls.listReviews, { - owner: GITHUB_OWNER, - repo: APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, pull_number: pullRequestNumber, per_page: 100, }, @@ -447,8 +463,8 @@ class GithubUtils { return this.paginate( this.octokit.issues.listComments, { - owner: GITHUB_OWNER, - repo: APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, issue_number: issueNumber, per_page: 100, }, @@ -467,7 +483,7 @@ class GithubUtils { static createComment(repo, number, messageBody) { console.log(`Writing comment on #${number}`); return this.octokit.issues.createComment({ - owner: GITHUB_OWNER, + owner: CONST.GITHUB_OWNER, repo, issue_number: number, body: messageBody, @@ -484,8 +500,8 @@ class GithubUtils { console.log(`Fetching New Expensify workflow runs for ${workflow}...`); return this.octokit.actions .listWorkflowRuns({ - owner: GITHUB_OWNER, - repo: APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, workflow_id: workflow, }) .then((response) => lodashGet(response, 'data.workflow_runs[0].id')); @@ -508,7 +524,7 @@ class GithubUtils { * @returns {String} */ static getPullRequestURLFromNumber(number) { - return `${APP_REPO_URL}/pull/${number}`; + return `${CONST.APP_REPO_URL}/pull/${number}`; } /** @@ -563,7 +579,7 @@ class GithubUtils { * @returns {Boolean} */ static isAutomatedPullRequest(pullRequest) { - return _.isEqual(lodashGet(pullRequest, 'user.login', ''), 'OSBotify'); + return _.isEqual(lodashGet(pullRequest, 'user.login', ''), CONST.OS_BOTIFY); } /** @@ -574,8 +590,8 @@ class GithubUtils { */ static getActorWhoClosedIssue(issueNumber) { return this.paginate(this.octokit.issues.listEvents, { - owner: GITHUB_OWNER, - repo: APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, issue_number: issueNumber, per_page: 100, }) @@ -585,12 +601,6 @@ class GithubUtils { } module.exports = GithubUtils; -module.exports.GITHUB_OWNER = GITHUB_OWNER; -module.exports.APP_REPO = APP_REPO; -module.exports.APP_REPO_URL = APP_REPO_URL; -module.exports.STAGING_DEPLOY_CASH_LABEL = STAGING_DEPLOY_CASH_LABEL; -module.exports.DEPLOY_BLOCKER_CASH_LABEL = DEPLOY_BLOCKER_CASH_LABEL; -module.exports.APPLAUSE_BOT = APPLAUSE_BOT; module.exports.ISSUE_OR_PULL_REQUEST_REGEX = ISSUE_OR_PULL_REQUEST_REGEX; module.exports.POLL_RATE = POLL_RATE; diff --git a/.github/actions/javascript/reopenIssueWithComment/reopenIssueWithComment.js b/.github/actions/javascript/reopenIssueWithComment/reopenIssueWithComment.js index 2eadfc6e89d1..2542372ec75e 100644 --- a/.github/actions/javascript/reopenIssueWithComment/reopenIssueWithComment.js +++ b/.github/actions/javascript/reopenIssueWithComment/reopenIssueWithComment.js @@ -1,4 +1,5 @@ const core = require('@actions/core'); +const CONST = require('../../../libs/CONST'); const GithubUtils = require('../../../libs/GithubUtils'); const issueNumber = core.getInput('ISSUE_NUMBER', {required: true}); @@ -8,16 +9,16 @@ function reopenIssueWithComment() { console.log(`Reopening issue #${issueNumber}`); return GithubUtils.octokit.issues .update({ - owner: GithubUtils.GITHUB_OWNER, - repo: GithubUtils.APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, issue_number: issueNumber, state: 'open', }) .then(() => { console.log(`Commenting on issue #${issueNumber}`); return GithubUtils.octokit.issues.createComment({ - owner: GithubUtils.GITHUB_OWNER, - repo: GithubUtils.APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, issue_number: issueNumber, body: comment, }); diff --git a/.github/actions/javascript/reviewerChecklist/index.js b/.github/actions/javascript/reviewerChecklist/index.js index b79ad2aa3092..6a7434946447 100644 --- a/.github/actions/javascript/reviewerChecklist/index.js +++ b/.github/actions/javascript/reviewerChecklist/index.js @@ -112,6 +112,29 @@ getNumberOfItemsFromReviewerChecklist() }); +/***/ }), + +/***/ 4097: +/***/ ((module) => { + +const CONST = { + GITHUB_OWNER: 'Expensify', + APP_REPO: 'App', + APPLAUSE_BOT: 'applausebot', + OS_BOTIFY: 'OSBotify', + LABELS: { + STAGING_DEPLOY: 'StagingDeployCash', + DEPLOY_BLOCKER: 'DeployBlockerCash', + INTERNAL_QA: 'InternalQA', + }, +}; + +CONST.APP_REPO_URL = `https://github.com/${CONST.GITHUB_OWNER}/${CONST.APP_REPO}`; +CONST.APP_REPO_GIT_URL = `git@github.com:${CONST.GITHUB_OWNER}/${CONST.APP_REPO}.git`; + +module.exports = CONST; + + /***/ }), /***/ 7999: @@ -123,21 +146,13 @@ const core = __nccwpck_require__(2186); const {GitHub, getOctokitOptions} = __nccwpck_require__(3030); const {throttling} = __nccwpck_require__(9968); const {paginateRest} = __nccwpck_require__(4193); - -const GITHUB_OWNER = 'Expensify'; -const APP_REPO = 'App'; -const APP_REPO_URL = 'https://github.com/Expensify/App'; +const CONST = __nccwpck_require__(4097); const GITHUB_BASE_URL_REGEX = new RegExp('https?://(?:github\\.com|api\\.github\\.com)'); const PULL_REQUEST_REGEX = new RegExp(`${GITHUB_BASE_URL_REGEX.source}/.*/.*/pull/([0-9]+).*`); const ISSUE_REGEX = new RegExp(`${GITHUB_BASE_URL_REGEX.source}/.*/.*/issues/([0-9]+).*`); const ISSUE_OR_PULL_REQUEST_REGEX = new RegExp(`${GITHUB_BASE_URL_REGEX.source}/.*/.*/(?:pull|issues)/([0-9]+).*`); -const APPLAUSE_BOT = 'applausebot'; -const STAGING_DEPLOY_CASH_LABEL = 'StagingDeployCash'; -const DEPLOY_BLOCKER_CASH_LABEL = 'DeployBlockerCash'; -const INTERNAL_QA_LABEL = 'InternalQA'; - /** * The standard rate in ms at which we'll poll the GitHub API to check for status changes. * It's 10 seconds :) @@ -215,20 +230,20 @@ class GithubUtils { static getStagingDeployCash() { return this.octokit.issues .listForRepo({ - owner: GITHUB_OWNER, - repo: APP_REPO, - labels: STAGING_DEPLOY_CASH_LABEL, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, + labels: CONST.LABELS.STAGING_DEPLOY, state: 'open', }) .then(({data}) => { if (!data.length) { - const error = new Error(`Unable to find ${STAGING_DEPLOY_CASH_LABEL} issue.`); + const error = new Error(`Unable to find ${CONST.LABELS.STAGING_DEPLOY} issue.`); error.code = 404; throw error; } if (data.length > 1) { - const error = new Error(`Found more than one ${STAGING_DEPLOY_CASH_LABEL} issue.`); + const error = new Error(`Found more than one ${CONST.LABELS.STAGING_DEPLOY} issue.`); error.code = 500; throw error; } @@ -261,7 +276,7 @@ class GithubUtils { tag, }; } catch (exception) { - throw new Error(`Unable to find ${STAGING_DEPLOY_CASH_LABEL} issue with correct data.`); + throw new Error(`Unable to find ${CONST.LABELS.STAGING_DEPLOY} issue with correct data.`); } } @@ -369,7 +384,7 @@ class GithubUtils { // 'https://github.com/Expensify/App/pull/9642': [ 'mountiny', 'kidroca' ] // } const internalQAPRMap = _.reduce( - _.filter(data, (pr) => !_.isEmpty(_.findWhere(pr.labels, {name: INTERNAL_QA_LABEL}))), + _.filter(data, (pr) => !_.isEmpty(_.findWhere(pr.labels, {name: CONST.LABELS.INTERNAL_QA}))), (map, pr) => { // eslint-disable-next-line no-param-reassign map[pr.html_url] = _.compact(_.pluck(pr.assignees, 'login')); @@ -457,8 +472,8 @@ class GithubUtils { return this.paginate( this.octokit.pulls.list, { - owner: GITHUB_OWNER, - repo: APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, state: 'all', sort: 'created', direction: 'desc', @@ -482,8 +497,8 @@ class GithubUtils { static getPullRequestBody(pullRequestNumber) { return this.octokit.pulls .get({ - owner: GITHUB_OWNER, - repo: APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, pull_number: pullRequestNumber, }) .then(({data: pullRequestComment}) => pullRequestComment.body); @@ -497,8 +512,8 @@ class GithubUtils { return this.paginate( this.octokit.pulls.listReviews, { - owner: GITHUB_OWNER, - repo: APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, pull_number: pullRequestNumber, per_page: 100, }, @@ -514,8 +529,8 @@ class GithubUtils { return this.paginate( this.octokit.issues.listComments, { - owner: GITHUB_OWNER, - repo: APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, issue_number: issueNumber, per_page: 100, }, @@ -534,7 +549,7 @@ class GithubUtils { static createComment(repo, number, messageBody) { console.log(`Writing comment on #${number}`); return this.octokit.issues.createComment({ - owner: GITHUB_OWNER, + owner: CONST.GITHUB_OWNER, repo, issue_number: number, body: messageBody, @@ -551,8 +566,8 @@ class GithubUtils { console.log(`Fetching New Expensify workflow runs for ${workflow}...`); return this.octokit.actions .listWorkflowRuns({ - owner: GITHUB_OWNER, - repo: APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, workflow_id: workflow, }) .then((response) => lodashGet(response, 'data.workflow_runs[0].id')); @@ -575,7 +590,7 @@ class GithubUtils { * @returns {String} */ static getPullRequestURLFromNumber(number) { - return `${APP_REPO_URL}/pull/${number}`; + return `${CONST.APP_REPO_URL}/pull/${number}`; } /** @@ -630,7 +645,7 @@ class GithubUtils { * @returns {Boolean} */ static isAutomatedPullRequest(pullRequest) { - return _.isEqual(lodashGet(pullRequest, 'user.login', ''), 'OSBotify'); + return _.isEqual(lodashGet(pullRequest, 'user.login', ''), CONST.OS_BOTIFY); } /** @@ -641,8 +656,8 @@ class GithubUtils { */ static getActorWhoClosedIssue(issueNumber) { return this.paginate(this.octokit.issues.listEvents, { - owner: GITHUB_OWNER, - repo: APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, issue_number: issueNumber, per_page: 100, }) @@ -652,12 +667,6 @@ class GithubUtils { } module.exports = GithubUtils; -module.exports.GITHUB_OWNER = GITHUB_OWNER; -module.exports.APP_REPO = APP_REPO; -module.exports.APP_REPO_URL = APP_REPO_URL; -module.exports.STAGING_DEPLOY_CASH_LABEL = STAGING_DEPLOY_CASH_LABEL; -module.exports.DEPLOY_BLOCKER_CASH_LABEL = DEPLOY_BLOCKER_CASH_LABEL; -module.exports.APPLAUSE_BOT = APPLAUSE_BOT; module.exports.ISSUE_OR_PULL_REQUEST_REGEX = ISSUE_OR_PULL_REQUEST_REGEX; module.exports.POLL_RATE = POLL_RATE; diff --git a/.github/actions/javascript/triggerWorkflowAndWait/index.js b/.github/actions/javascript/triggerWorkflowAndWait/index.js index e5f4270be0de..091b759a95ce 100644 --- a/.github/actions/javascript/triggerWorkflowAndWait/index.js +++ b/.github/actions/javascript/triggerWorkflowAndWait/index.js @@ -10,6 +10,7 @@ module.exports = const _ = __nccwpck_require__(3571); const core = __nccwpck_require__(2186); +const CONST = __nccwpck_require__(4097); const ActionUtils = __nccwpck_require__(970); const GithubUtils = __nccwpck_require__(7999); const {promiseWhile} = __nccwpck_require__(4502); @@ -65,8 +66,8 @@ const run = function () { console.log(`Dispatching workflow: ${workflow}`); return GithubUtils.octokit.actions.createWorkflowDispatch({ - owner: GithubUtils.GITHUB_OWNER, - repo: GithubUtils.APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, workflow_id: workflow, ref: 'main', inputs, @@ -124,8 +125,8 @@ const run = function () { console.log(`\n⏳ Waiting for workflow run ${newWorkflowRunURL} to finish...`); return GithubUtils.octokit.actions .getWorkflowRun({ - owner: GithubUtils.GITHUB_OWNER, - repo: GithubUtils.APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, run_id: newWorkflowRunID, }) .then(({data}) => { @@ -210,6 +211,29 @@ module.exports = { }; +/***/ }), + +/***/ 4097: +/***/ ((module) => { + +const CONST = { + GITHUB_OWNER: 'Expensify', + APP_REPO: 'App', + APPLAUSE_BOT: 'applausebot', + OS_BOTIFY: 'OSBotify', + LABELS: { + STAGING_DEPLOY: 'StagingDeployCash', + DEPLOY_BLOCKER: 'DeployBlockerCash', + INTERNAL_QA: 'InternalQA', + }, +}; + +CONST.APP_REPO_URL = `https://github.com/${CONST.GITHUB_OWNER}/${CONST.APP_REPO}`; +CONST.APP_REPO_GIT_URL = `git@github.com:${CONST.GITHUB_OWNER}/${CONST.APP_REPO}.git`; + +module.exports = CONST; + + /***/ }), /***/ 7999: @@ -221,21 +245,13 @@ const core = __nccwpck_require__(2186); const {GitHub, getOctokitOptions} = __nccwpck_require__(3030); const {throttling} = __nccwpck_require__(9968); const {paginateRest} = __nccwpck_require__(4193); - -const GITHUB_OWNER = 'Expensify'; -const APP_REPO = 'App'; -const APP_REPO_URL = 'https://github.com/Expensify/App'; +const CONST = __nccwpck_require__(4097); const GITHUB_BASE_URL_REGEX = new RegExp('https?://(?:github\\.com|api\\.github\\.com)'); const PULL_REQUEST_REGEX = new RegExp(`${GITHUB_BASE_URL_REGEX.source}/.*/.*/pull/([0-9]+).*`); const ISSUE_REGEX = new RegExp(`${GITHUB_BASE_URL_REGEX.source}/.*/.*/issues/([0-9]+).*`); const ISSUE_OR_PULL_REQUEST_REGEX = new RegExp(`${GITHUB_BASE_URL_REGEX.source}/.*/.*/(?:pull|issues)/([0-9]+).*`); -const APPLAUSE_BOT = 'applausebot'; -const STAGING_DEPLOY_CASH_LABEL = 'StagingDeployCash'; -const DEPLOY_BLOCKER_CASH_LABEL = 'DeployBlockerCash'; -const INTERNAL_QA_LABEL = 'InternalQA'; - /** * The standard rate in ms at which we'll poll the GitHub API to check for status changes. * It's 10 seconds :) @@ -313,20 +329,20 @@ class GithubUtils { static getStagingDeployCash() { return this.octokit.issues .listForRepo({ - owner: GITHUB_OWNER, - repo: APP_REPO, - labels: STAGING_DEPLOY_CASH_LABEL, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, + labels: CONST.LABELS.STAGING_DEPLOY, state: 'open', }) .then(({data}) => { if (!data.length) { - const error = new Error(`Unable to find ${STAGING_DEPLOY_CASH_LABEL} issue.`); + const error = new Error(`Unable to find ${CONST.LABELS.STAGING_DEPLOY} issue.`); error.code = 404; throw error; } if (data.length > 1) { - const error = new Error(`Found more than one ${STAGING_DEPLOY_CASH_LABEL} issue.`); + const error = new Error(`Found more than one ${CONST.LABELS.STAGING_DEPLOY} issue.`); error.code = 500; throw error; } @@ -359,7 +375,7 @@ class GithubUtils { tag, }; } catch (exception) { - throw new Error(`Unable to find ${STAGING_DEPLOY_CASH_LABEL} issue with correct data.`); + throw new Error(`Unable to find ${CONST.LABELS.STAGING_DEPLOY} issue with correct data.`); } } @@ -467,7 +483,7 @@ class GithubUtils { // 'https://github.com/Expensify/App/pull/9642': [ 'mountiny', 'kidroca' ] // } const internalQAPRMap = _.reduce( - _.filter(data, (pr) => !_.isEmpty(_.findWhere(pr.labels, {name: INTERNAL_QA_LABEL}))), + _.filter(data, (pr) => !_.isEmpty(_.findWhere(pr.labels, {name: CONST.LABELS.INTERNAL_QA}))), (map, pr) => { // eslint-disable-next-line no-param-reassign map[pr.html_url] = _.compact(_.pluck(pr.assignees, 'login')); @@ -555,8 +571,8 @@ class GithubUtils { return this.paginate( this.octokit.pulls.list, { - owner: GITHUB_OWNER, - repo: APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, state: 'all', sort: 'created', direction: 'desc', @@ -580,8 +596,8 @@ class GithubUtils { static getPullRequestBody(pullRequestNumber) { return this.octokit.pulls .get({ - owner: GITHUB_OWNER, - repo: APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, pull_number: pullRequestNumber, }) .then(({data: pullRequestComment}) => pullRequestComment.body); @@ -595,8 +611,8 @@ class GithubUtils { return this.paginate( this.octokit.pulls.listReviews, { - owner: GITHUB_OWNER, - repo: APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, pull_number: pullRequestNumber, per_page: 100, }, @@ -612,8 +628,8 @@ class GithubUtils { return this.paginate( this.octokit.issues.listComments, { - owner: GITHUB_OWNER, - repo: APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, issue_number: issueNumber, per_page: 100, }, @@ -632,7 +648,7 @@ class GithubUtils { static createComment(repo, number, messageBody) { console.log(`Writing comment on #${number}`); return this.octokit.issues.createComment({ - owner: GITHUB_OWNER, + owner: CONST.GITHUB_OWNER, repo, issue_number: number, body: messageBody, @@ -649,8 +665,8 @@ class GithubUtils { console.log(`Fetching New Expensify workflow runs for ${workflow}...`); return this.octokit.actions .listWorkflowRuns({ - owner: GITHUB_OWNER, - repo: APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, workflow_id: workflow, }) .then((response) => lodashGet(response, 'data.workflow_runs[0].id')); @@ -673,7 +689,7 @@ class GithubUtils { * @returns {String} */ static getPullRequestURLFromNumber(number) { - return `${APP_REPO_URL}/pull/${number}`; + return `${CONST.APP_REPO_URL}/pull/${number}`; } /** @@ -728,7 +744,7 @@ class GithubUtils { * @returns {Boolean} */ static isAutomatedPullRequest(pullRequest) { - return _.isEqual(lodashGet(pullRequest, 'user.login', ''), 'OSBotify'); + return _.isEqual(lodashGet(pullRequest, 'user.login', ''), CONST.OS_BOTIFY); } /** @@ -739,8 +755,8 @@ class GithubUtils { */ static getActorWhoClosedIssue(issueNumber) { return this.paginate(this.octokit.issues.listEvents, { - owner: GITHUB_OWNER, - repo: APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, issue_number: issueNumber, per_page: 100, }) @@ -750,12 +766,6 @@ class GithubUtils { } module.exports = GithubUtils; -module.exports.GITHUB_OWNER = GITHUB_OWNER; -module.exports.APP_REPO = APP_REPO; -module.exports.APP_REPO_URL = APP_REPO_URL; -module.exports.STAGING_DEPLOY_CASH_LABEL = STAGING_DEPLOY_CASH_LABEL; -module.exports.DEPLOY_BLOCKER_CASH_LABEL = DEPLOY_BLOCKER_CASH_LABEL; -module.exports.APPLAUSE_BOT = APPLAUSE_BOT; module.exports.ISSUE_OR_PULL_REQUEST_REGEX = ISSUE_OR_PULL_REQUEST_REGEX; module.exports.POLL_RATE = POLL_RATE; diff --git a/.github/actions/javascript/triggerWorkflowAndWait/triggerWorkflowAndWait.js b/.github/actions/javascript/triggerWorkflowAndWait/triggerWorkflowAndWait.js index f843392ab5cb..82bfafc32d9e 100644 --- a/.github/actions/javascript/triggerWorkflowAndWait/triggerWorkflowAndWait.js +++ b/.github/actions/javascript/triggerWorkflowAndWait/triggerWorkflowAndWait.js @@ -1,5 +1,6 @@ const _ = require('underscore'); const core = require('@actions/core'); +const CONST = require('../../../libs/CONST'); const ActionUtils = require('../../../libs/ActionUtils'); const GithubUtils = require('../../../libs/GithubUtils'); const {promiseWhile} = require('../../../libs/promiseWhile'); @@ -55,8 +56,8 @@ const run = function () { console.log(`Dispatching workflow: ${workflow}`); return GithubUtils.octokit.actions.createWorkflowDispatch({ - owner: GithubUtils.GITHUB_OWNER, - repo: GithubUtils.APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, workflow_id: workflow, ref: 'main', inputs, @@ -114,8 +115,8 @@ const run = function () { console.log(`\n⏳ Waiting for workflow run ${newWorkflowRunURL} to finish...`); return GithubUtils.octokit.actions .getWorkflowRun({ - owner: GithubUtils.GITHUB_OWNER, - repo: GithubUtils.APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, run_id: newWorkflowRunID, }) .then(({data}) => { diff --git a/.github/actions/javascript/verifySignedCommits/index.js b/.github/actions/javascript/verifySignedCommits/index.js index eb97e4561c2a..3283ab4f6c9a 100644 --- a/.github/actions/javascript/verifySignedCommits/index.js +++ b/.github/actions/javascript/verifySignedCommits/index.js @@ -11,14 +11,15 @@ module.exports = const _ = __nccwpck_require__(3571); const core = __nccwpck_require__(2186); const github = __nccwpck_require__(5438); +const CONST = __nccwpck_require__(4097); const GitHubUtils = __nccwpck_require__(7999); const PR_NUMBER = Number.parseInt(core.getInput('PR_NUMBER'), 10) || github.context.payload.pull_request.number; GitHubUtils.octokit.pulls .listCommits({ - owner: GitHubUtils.GITHUB_OWNER, - repo: GitHubUtils.APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, pull_number: PR_NUMBER, }) .then(({data}) => { @@ -34,6 +35,29 @@ GitHubUtils.octokit.pulls }); +/***/ }), + +/***/ 4097: +/***/ ((module) => { + +const CONST = { + GITHUB_OWNER: 'Expensify', + APP_REPO: 'App', + APPLAUSE_BOT: 'applausebot', + OS_BOTIFY: 'OSBotify', + LABELS: { + STAGING_DEPLOY: 'StagingDeployCash', + DEPLOY_BLOCKER: 'DeployBlockerCash', + INTERNAL_QA: 'InternalQA', + }, +}; + +CONST.APP_REPO_URL = `https://github.com/${CONST.GITHUB_OWNER}/${CONST.APP_REPO}`; +CONST.APP_REPO_GIT_URL = `git@github.com:${CONST.GITHUB_OWNER}/${CONST.APP_REPO}.git`; + +module.exports = CONST; + + /***/ }), /***/ 7999: @@ -45,21 +69,13 @@ const core = __nccwpck_require__(2186); const {GitHub, getOctokitOptions} = __nccwpck_require__(3030); const {throttling} = __nccwpck_require__(9968); const {paginateRest} = __nccwpck_require__(4193); - -const GITHUB_OWNER = 'Expensify'; -const APP_REPO = 'App'; -const APP_REPO_URL = 'https://github.com/Expensify/App'; +const CONST = __nccwpck_require__(4097); const GITHUB_BASE_URL_REGEX = new RegExp('https?://(?:github\\.com|api\\.github\\.com)'); const PULL_REQUEST_REGEX = new RegExp(`${GITHUB_BASE_URL_REGEX.source}/.*/.*/pull/([0-9]+).*`); const ISSUE_REGEX = new RegExp(`${GITHUB_BASE_URL_REGEX.source}/.*/.*/issues/([0-9]+).*`); const ISSUE_OR_PULL_REQUEST_REGEX = new RegExp(`${GITHUB_BASE_URL_REGEX.source}/.*/.*/(?:pull|issues)/([0-9]+).*`); -const APPLAUSE_BOT = 'applausebot'; -const STAGING_DEPLOY_CASH_LABEL = 'StagingDeployCash'; -const DEPLOY_BLOCKER_CASH_LABEL = 'DeployBlockerCash'; -const INTERNAL_QA_LABEL = 'InternalQA'; - /** * The standard rate in ms at which we'll poll the GitHub API to check for status changes. * It's 10 seconds :) @@ -137,20 +153,20 @@ class GithubUtils { static getStagingDeployCash() { return this.octokit.issues .listForRepo({ - owner: GITHUB_OWNER, - repo: APP_REPO, - labels: STAGING_DEPLOY_CASH_LABEL, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, + labels: CONST.LABELS.STAGING_DEPLOY, state: 'open', }) .then(({data}) => { if (!data.length) { - const error = new Error(`Unable to find ${STAGING_DEPLOY_CASH_LABEL} issue.`); + const error = new Error(`Unable to find ${CONST.LABELS.STAGING_DEPLOY} issue.`); error.code = 404; throw error; } if (data.length > 1) { - const error = new Error(`Found more than one ${STAGING_DEPLOY_CASH_LABEL} issue.`); + const error = new Error(`Found more than one ${CONST.LABELS.STAGING_DEPLOY} issue.`); error.code = 500; throw error; } @@ -183,7 +199,7 @@ class GithubUtils { tag, }; } catch (exception) { - throw new Error(`Unable to find ${STAGING_DEPLOY_CASH_LABEL} issue with correct data.`); + throw new Error(`Unable to find ${CONST.LABELS.STAGING_DEPLOY} issue with correct data.`); } } @@ -291,7 +307,7 @@ class GithubUtils { // 'https://github.com/Expensify/App/pull/9642': [ 'mountiny', 'kidroca' ] // } const internalQAPRMap = _.reduce( - _.filter(data, (pr) => !_.isEmpty(_.findWhere(pr.labels, {name: INTERNAL_QA_LABEL}))), + _.filter(data, (pr) => !_.isEmpty(_.findWhere(pr.labels, {name: CONST.LABELS.INTERNAL_QA}))), (map, pr) => { // eslint-disable-next-line no-param-reassign map[pr.html_url] = _.compact(_.pluck(pr.assignees, 'login')); @@ -379,8 +395,8 @@ class GithubUtils { return this.paginate( this.octokit.pulls.list, { - owner: GITHUB_OWNER, - repo: APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, state: 'all', sort: 'created', direction: 'desc', @@ -404,8 +420,8 @@ class GithubUtils { static getPullRequestBody(pullRequestNumber) { return this.octokit.pulls .get({ - owner: GITHUB_OWNER, - repo: APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, pull_number: pullRequestNumber, }) .then(({data: pullRequestComment}) => pullRequestComment.body); @@ -419,8 +435,8 @@ class GithubUtils { return this.paginate( this.octokit.pulls.listReviews, { - owner: GITHUB_OWNER, - repo: APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, pull_number: pullRequestNumber, per_page: 100, }, @@ -436,8 +452,8 @@ class GithubUtils { return this.paginate( this.octokit.issues.listComments, { - owner: GITHUB_OWNER, - repo: APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, issue_number: issueNumber, per_page: 100, }, @@ -456,7 +472,7 @@ class GithubUtils { static createComment(repo, number, messageBody) { console.log(`Writing comment on #${number}`); return this.octokit.issues.createComment({ - owner: GITHUB_OWNER, + owner: CONST.GITHUB_OWNER, repo, issue_number: number, body: messageBody, @@ -473,8 +489,8 @@ class GithubUtils { console.log(`Fetching New Expensify workflow runs for ${workflow}...`); return this.octokit.actions .listWorkflowRuns({ - owner: GITHUB_OWNER, - repo: APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, workflow_id: workflow, }) .then((response) => lodashGet(response, 'data.workflow_runs[0].id')); @@ -497,7 +513,7 @@ class GithubUtils { * @returns {String} */ static getPullRequestURLFromNumber(number) { - return `${APP_REPO_URL}/pull/${number}`; + return `${CONST.APP_REPO_URL}/pull/${number}`; } /** @@ -552,7 +568,7 @@ class GithubUtils { * @returns {Boolean} */ static isAutomatedPullRequest(pullRequest) { - return _.isEqual(lodashGet(pullRequest, 'user.login', ''), 'OSBotify'); + return _.isEqual(lodashGet(pullRequest, 'user.login', ''), CONST.OS_BOTIFY); } /** @@ -563,8 +579,8 @@ class GithubUtils { */ static getActorWhoClosedIssue(issueNumber) { return this.paginate(this.octokit.issues.listEvents, { - owner: GITHUB_OWNER, - repo: APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, issue_number: issueNumber, per_page: 100, }) @@ -574,12 +590,6 @@ class GithubUtils { } module.exports = GithubUtils; -module.exports.GITHUB_OWNER = GITHUB_OWNER; -module.exports.APP_REPO = APP_REPO; -module.exports.APP_REPO_URL = APP_REPO_URL; -module.exports.STAGING_DEPLOY_CASH_LABEL = STAGING_DEPLOY_CASH_LABEL; -module.exports.DEPLOY_BLOCKER_CASH_LABEL = DEPLOY_BLOCKER_CASH_LABEL; -module.exports.APPLAUSE_BOT = APPLAUSE_BOT; module.exports.ISSUE_OR_PULL_REQUEST_REGEX = ISSUE_OR_PULL_REQUEST_REGEX; module.exports.POLL_RATE = POLL_RATE; diff --git a/.github/actions/javascript/verifySignedCommits/verifySignedCommits.js b/.github/actions/javascript/verifySignedCommits/verifySignedCommits.js index 6c76dd66d23a..61d48c0c6f44 100644 --- a/.github/actions/javascript/verifySignedCommits/verifySignedCommits.js +++ b/.github/actions/javascript/verifySignedCommits/verifySignedCommits.js @@ -1,14 +1,15 @@ const _ = require('underscore'); const core = require('@actions/core'); const github = require('@actions/github'); +const CONST = require('../../../libs/CONST'); const GitHubUtils = require('../../../libs/GithubUtils'); const PR_NUMBER = Number.parseInt(core.getInput('PR_NUMBER'), 10) || github.context.payload.pull_request.number; GitHubUtils.octokit.pulls .listCommits({ - owner: GitHubUtils.GITHUB_OWNER, - repo: GitHubUtils.APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, pull_number: PR_NUMBER, }) .then(({data}) => { diff --git a/.github/libs/CONST.js b/.github/libs/CONST.js new file mode 100644 index 000000000000..36eeb804aa00 --- /dev/null +++ b/.github/libs/CONST.js @@ -0,0 +1,16 @@ +const CONST = { + GITHUB_OWNER: 'Expensify', + APP_REPO: 'App', + APPLAUSE_BOT: 'applausebot', + OS_BOTIFY: 'OSBotify', + LABELS: { + STAGING_DEPLOY: 'StagingDeployCash', + DEPLOY_BLOCKER: 'DeployBlockerCash', + INTERNAL_QA: 'InternalQA', + }, +}; + +CONST.APP_REPO_URL = `https://github.com/${CONST.GITHUB_OWNER}/${CONST.APP_REPO}`; +CONST.APP_REPO_GIT_URL = `git@github.com:${CONST.GITHUB_OWNER}/${CONST.APP_REPO}.git`; + +module.exports = CONST; diff --git a/.github/libs/GithubUtils.js b/.github/libs/GithubUtils.js index ce5cd58e8528..4babce9d769d 100644 --- a/.github/libs/GithubUtils.js +++ b/.github/libs/GithubUtils.js @@ -4,21 +4,13 @@ const core = require('@actions/core'); const {GitHub, getOctokitOptions} = require('@actions/github/lib/utils'); const {throttling} = require('@octokit/plugin-throttling'); const {paginateRest} = require('@octokit/plugin-paginate-rest'); - -const GITHUB_OWNER = 'Expensify'; -const APP_REPO = 'App'; -const APP_REPO_URL = 'https://github.com/Expensify/App'; +const CONST = require('./CONST'); const GITHUB_BASE_URL_REGEX = new RegExp('https?://(?:github\\.com|api\\.github\\.com)'); const PULL_REQUEST_REGEX = new RegExp(`${GITHUB_BASE_URL_REGEX.source}/.*/.*/pull/([0-9]+).*`); const ISSUE_REGEX = new RegExp(`${GITHUB_BASE_URL_REGEX.source}/.*/.*/issues/([0-9]+).*`); const ISSUE_OR_PULL_REQUEST_REGEX = new RegExp(`${GITHUB_BASE_URL_REGEX.source}/.*/.*/(?:pull|issues)/([0-9]+).*`); -const APPLAUSE_BOT = 'applausebot'; -const STAGING_DEPLOY_CASH_LABEL = 'StagingDeployCash'; -const DEPLOY_BLOCKER_CASH_LABEL = 'DeployBlockerCash'; -const INTERNAL_QA_LABEL = 'InternalQA'; - /** * The standard rate in ms at which we'll poll the GitHub API to check for status changes. * It's 10 seconds :) @@ -96,20 +88,20 @@ class GithubUtils { static getStagingDeployCash() { return this.octokit.issues .listForRepo({ - owner: GITHUB_OWNER, - repo: APP_REPO, - labels: STAGING_DEPLOY_CASH_LABEL, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, + labels: CONST.LABELS.STAGING_DEPLOY, state: 'open', }) .then(({data}) => { if (!data.length) { - const error = new Error(`Unable to find ${STAGING_DEPLOY_CASH_LABEL} issue.`); + const error = new Error(`Unable to find ${CONST.LABELS.STAGING_DEPLOY} issue.`); error.code = 404; throw error; } if (data.length > 1) { - const error = new Error(`Found more than one ${STAGING_DEPLOY_CASH_LABEL} issue.`); + const error = new Error(`Found more than one ${CONST.LABELS.STAGING_DEPLOY} issue.`); error.code = 500; throw error; } @@ -142,7 +134,7 @@ class GithubUtils { tag, }; } catch (exception) { - throw new Error(`Unable to find ${STAGING_DEPLOY_CASH_LABEL} issue with correct data.`); + throw new Error(`Unable to find ${CONST.LABELS.STAGING_DEPLOY} issue with correct data.`); } } @@ -250,7 +242,7 @@ class GithubUtils { // 'https://github.com/Expensify/App/pull/9642': [ 'mountiny', 'kidroca' ] // } const internalQAPRMap = _.reduce( - _.filter(data, (pr) => !_.isEmpty(_.findWhere(pr.labels, {name: INTERNAL_QA_LABEL}))), + _.filter(data, (pr) => !_.isEmpty(_.findWhere(pr.labels, {name: CONST.LABELS.INTERNAL_QA}))), (map, pr) => { // eslint-disable-next-line no-param-reassign map[pr.html_url] = _.compact(_.pluck(pr.assignees, 'login')); @@ -338,8 +330,8 @@ class GithubUtils { return this.paginate( this.octokit.pulls.list, { - owner: GITHUB_OWNER, - repo: APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, state: 'all', sort: 'created', direction: 'desc', @@ -363,8 +355,8 @@ class GithubUtils { static getPullRequestBody(pullRequestNumber) { return this.octokit.pulls .get({ - owner: GITHUB_OWNER, - repo: APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, pull_number: pullRequestNumber, }) .then(({data: pullRequestComment}) => pullRequestComment.body); @@ -378,8 +370,8 @@ class GithubUtils { return this.paginate( this.octokit.pulls.listReviews, { - owner: GITHUB_OWNER, - repo: APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, pull_number: pullRequestNumber, per_page: 100, }, @@ -395,8 +387,8 @@ class GithubUtils { return this.paginate( this.octokit.issues.listComments, { - owner: GITHUB_OWNER, - repo: APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, issue_number: issueNumber, per_page: 100, }, @@ -415,7 +407,7 @@ class GithubUtils { static createComment(repo, number, messageBody) { console.log(`Writing comment on #${number}`); return this.octokit.issues.createComment({ - owner: GITHUB_OWNER, + owner: CONST.GITHUB_OWNER, repo, issue_number: number, body: messageBody, @@ -432,8 +424,8 @@ class GithubUtils { console.log(`Fetching New Expensify workflow runs for ${workflow}...`); return this.octokit.actions .listWorkflowRuns({ - owner: GITHUB_OWNER, - repo: APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, workflow_id: workflow, }) .then((response) => lodashGet(response, 'data.workflow_runs[0].id')); @@ -456,7 +448,7 @@ class GithubUtils { * @returns {String} */ static getPullRequestURLFromNumber(number) { - return `${APP_REPO_URL}/pull/${number}`; + return `${CONST.APP_REPO_URL}/pull/${number}`; } /** @@ -511,7 +503,7 @@ class GithubUtils { * @returns {Boolean} */ static isAutomatedPullRequest(pullRequest) { - return _.isEqual(lodashGet(pullRequest, 'user.login', ''), 'OSBotify'); + return _.isEqual(lodashGet(pullRequest, 'user.login', ''), CONST.OS_BOTIFY); } /** @@ -522,8 +514,8 @@ class GithubUtils { */ static getActorWhoClosedIssue(issueNumber) { return this.paginate(this.octokit.issues.listEvents, { - owner: GITHUB_OWNER, - repo: APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, issue_number: issueNumber, per_page: 100, }) @@ -533,11 +525,5 @@ class GithubUtils { } module.exports = GithubUtils; -module.exports.GITHUB_OWNER = GITHUB_OWNER; -module.exports.APP_REPO = APP_REPO; -module.exports.APP_REPO_URL = APP_REPO_URL; -module.exports.STAGING_DEPLOY_CASH_LABEL = STAGING_DEPLOY_CASH_LABEL; -module.exports.DEPLOY_BLOCKER_CASH_LABEL = DEPLOY_BLOCKER_CASH_LABEL; -module.exports.APPLAUSE_BOT = APPLAUSE_BOT; module.exports.ISSUE_OR_PULL_REQUEST_REGEX = ISSUE_OR_PULL_REQUEST_REGEX; module.exports.POLL_RATE = POLL_RATE; diff --git a/.github/scripts/verifyActions.sh b/.github/scripts/verifyActions.sh index 28495eee14b9..ddc8fa0a3226 100755 --- a/.github/scripts/verifyActions.sh +++ b/.github/scripts/verifyActions.sh @@ -22,7 +22,7 @@ if [[ EXIT_CODE -eq 0 ]]; then echo -e "${GREEN}Github Actions are up to date!${NC}" exit 0 else - echo -e "${RED}Error: Diff found when Github Actions were rebuilt. Did you forget to run \`npm run gh-actions-build\` after a clean install (\`rm -rf node_modules && npm i\`)? Do you need to merge main?${NC}" + echo -e "${RED}Error: Diff found when Github Actions were rebuilt. Did you forget to run \`npm run gh-actions-build\` after a clean install (\`rm -rf node_modules && npm i\`)? Do you need to merge main? Did you try running \`git config --global core.autocrlf false\` then \`npm run gh-actions-build\` again?${NC}" echo "$DIFF_OUTPUT" | "$LIB_PATH/diff-so-fancy" | less --tabs=4 -RFX exit 1 fi diff --git a/tests/unit/GithubUtilsTest.js b/tests/unit/GithubUtilsTest.js index ea9fdc8849ea..02b051257168 100644 --- a/tests/unit/GithubUtilsTest.js +++ b/tests/unit/GithubUtilsTest.js @@ -2,6 +2,7 @@ * @jest-environment node */ const core = require('@actions/core'); +const CONST = require('../../.github/libs/CONST'); const GithubUtils = require('../../.github/libs/GithubUtils'); const mockGetInput = jest.fn(); @@ -281,7 +282,7 @@ describe('GithubUtils', () => { number: 4, title: 'Test Automated PR', html_url: 'https://github.com/Expensify/App/pull/4', - user: {login: 'OSBotify'}, + user: {login: CONST.OS_BOTIFY}, labels: [{name: 'automerge'}], }, { diff --git a/tests/unit/createOrUpdateStagingDeployTest.js b/tests/unit/createOrUpdateStagingDeployTest.js index c22ad4e13268..679653fb2822 100644 --- a/tests/unit/createOrUpdateStagingDeployTest.js +++ b/tests/unit/createOrUpdateStagingDeployTest.js @@ -3,6 +3,7 @@ */ const core = require('@actions/core'); const moment = require('moment'); +const CONST = require('../../.github/libs/CONST'); const GitUtils = require('../../.github/libs/GitUtils'); const GithubUtils = require('../../.github/libs/GithubUtils'); const run = require('../../.github/actions/javascript/createOrUpdateStagingDeploy/createOrUpdateStagingDeploy'); @@ -66,7 +67,7 @@ const LABELS = { id: 2783847782, node_id: 'MDU6TGFiZWwyNzgzODQ3Nzgy', url: 'https://api.github.com/repos/Expensify/App/labels/StagingDeployCash', - name: GithubUtils.STAGING_DEPLOY_CASH_LABEL, + name: CONST.LABELS.STAGING_DEPLOY, color: '6FC269', default: false, description: '', @@ -75,7 +76,7 @@ const LABELS = { id: 2810597462, node_id: 'MDU6TGFiZWwyODEwNTk3NDYy', url: 'https://api.github.com/repos/Expensify/App/labels/DeployBlockerCash', - name: GithubUtils.DEPLOY_BLOCKER_CASH_LABEL, + name: CONST.LABELS.DEPLOY_BLOCKER, color: '000000', default: false, description: 'This issue or pull request should block deployment', @@ -158,7 +159,7 @@ describe('createOrUpdateStagingDeployCash', () => { }); mockListIssues.mockImplementation((args) => { - if (args.labels === GithubUtils.STAGING_DEPLOY_CASH_LABEL) { + if (args.labels === CONST.LABELS.STAGING_DEPLOY) { return {data: [closedStagingDeployCash]}; } @@ -167,12 +168,12 @@ describe('createOrUpdateStagingDeployCash', () => { return run().then((result) => { expect(result).toStrictEqual({ - owner: GithubUtils.GITHUB_OWNER, - repo: GithubUtils.APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, title: `Deploy Checklist: New Expensify ${moment().format('YYYY-MM-DD')}`, - labels: [GithubUtils.STAGING_DEPLOY_CASH_LABEL], + labels: [CONST.LABELS.STAGING_DEPLOY], html_url: 'https://github.com/Expensify/App/issues/29', - assignees: [GithubUtils.APPLAUSE_BOT], + assignees: [CONST.APPLAUSE_BOT], body: `${baseExpectedOutput()}` + `${openCheckbox}${basePRList[5]}` + @@ -253,11 +254,11 @@ describe('createOrUpdateStagingDeployCash', () => { }); mockListIssues.mockImplementation((args) => { - if (args.labels === GithubUtils.STAGING_DEPLOY_CASH_LABEL) { + if (args.labels === CONST.LABELS.STAGING_DEPLOY) { return {data: [openStagingDeployCashBefore, closedStagingDeployCash]}; } - if (args.labels === GithubUtils.DEPLOY_BLOCKER_CASH_LABEL) { + if (args.labels === CONST.LABELS.DEPLOY_BLOCKER) { return { data: [ ...currentDeployBlockers, @@ -282,8 +283,8 @@ describe('createOrUpdateStagingDeployCash', () => { return run().then((result) => { expect(result).toStrictEqual({ - owner: GithubUtils.GITHUB_OWNER, - repo: GithubUtils.APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, issue_number: openStagingDeployCashBefore.number, // eslint-disable-next-line max-len html_url: `https://github.com/Expensify/App/issues/${openStagingDeployCashBefore.number}`, @@ -325,11 +326,11 @@ describe('createOrUpdateStagingDeployCash', () => { return []; }); mockListIssues.mockImplementation((args) => { - if (args.labels === GithubUtils.STAGING_DEPLOY_CASH_LABEL) { + if (args.labels === CONST.LABELS.STAGING_DEPLOY) { return {data: [openStagingDeployCashBefore, closedStagingDeployCash]}; } - if (args.labels === GithubUtils.DEPLOY_BLOCKER_CASH_LABEL) { + if (args.labels === CONST.LABELS.DEPLOY_BLOCKER) { return { data: [ ...currentDeployBlockers, @@ -354,8 +355,8 @@ describe('createOrUpdateStagingDeployCash', () => { return run().then((result) => { expect(result).toStrictEqual({ - owner: GithubUtils.GITHUB_OWNER, - repo: GithubUtils.APP_REPO, + owner: CONST.GITHUB_OWNER, + repo: CONST.APP_REPO, issue_number: openStagingDeployCashBefore.number, // eslint-disable-next-line max-len html_url: `https://github.com/Expensify/App/issues/${openStagingDeployCashBefore.number}`,