Skip to content

Commit 9d5fef3

Browse files
authored
Merge pull request #38800 from ruben-rebelo/group21
[No QA][TS migration][g21] Migrate multiple Github utils
2 parents 398636a + 4a0cdf6 commit 9d5fef3

File tree

26 files changed

+1002
-7498
lines changed

26 files changed

+1002
-7498
lines changed

.github/actions/javascript/authorChecklist/index.js

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,6 @@
44
/******/ (() => { // webpackBootstrap
55
/******/ var __webpack_modules__ = ({
66

7-
/***/ 4097:
8-
/***/ ((module) => {
9-
10-
const CONST = {
11-
GITHUB_OWNER: 'Expensify',
12-
APP_REPO: 'App',
13-
APPLAUSE_BOT: 'applausebot',
14-
OS_BOTIFY: 'OSBotify',
15-
LABELS: {
16-
STAGING_DEPLOY: 'StagingDeployCash',
17-
DEPLOY_BLOCKER: 'DeployBlockerCash',
18-
INTERNAL_QA: 'InternalQA',
19-
},
20-
DATE_FORMAT_STRING: 'yyyy-MM-dd',
21-
};
22-
23-
CONST.APP_REPO_URL = `https://github.com/${CONST.GITHUB_OWNER}/${CONST.APP_REPO}`;
24-
CONST.APP_REPO_GIT_URL = `git@github.com:${CONST.GITHUB_OWNER}/${CONST.APP_REPO}.git`;
25-
26-
module.exports = CONST;
27-
28-
29-
/***/ }),
30-
317
/***/ 7351:
328
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
339

@@ -16617,7 +16593,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
1661716593
const core = __importStar(__nccwpck_require__(2186));
1661816594
const github = __importStar(__nccwpck_require__(5438));
1661916595
const escapeRegExp_1 = __importDefault(__nccwpck_require__(8415));
16620-
const CONST_1 = __importDefault(__nccwpck_require__(4097));
16596+
const CONST_1 = __importDefault(__nccwpck_require__(9873));
1662116597
const GithubUtils_1 = __importDefault(__nccwpck_require__(9296));
1662216598
const newComponentCategory_1 = __importDefault(__nccwpck_require__(9032));
1662316599
const pathToAuthorChecklist = `https://raw.githubusercontent.com/${CONST_1.default.GITHUB_OWNER}/${CONST_1.default.APP_REPO}/main/.github/PULL_REQUEST_TEMPLATE.md`;
@@ -16770,7 +16746,7 @@ exports.detectReactComponent = void 0;
1677016746
const github_1 = __importDefault(__nccwpck_require__(5438));
1677116747
const parser_1 = __nccwpck_require__(5026);
1677216748
const traverse_1 = __importDefault(__nccwpck_require__(1380));
16773-
const CONST_1 = __importDefault(__nccwpck_require__(4097));
16749+
const CONST_1 = __importDefault(__nccwpck_require__(9873));
1677416750
const GithubUtils_1 = __importDefault(__nccwpck_require__(9296));
1677516751
const promiseSome_1 = __importDefault(__nccwpck_require__(8534));
1677616752
const items = [
@@ -16862,6 +16838,33 @@ const newComponentCategory = {
1686216838
exports["default"] = newComponentCategory;
1686316839

1686416840

16841+
/***/ }),
16842+
16843+
/***/ 9873:
16844+
/***/ ((__unused_webpack_module, exports) => {
16845+
16846+
"use strict";
16847+
16848+
Object.defineProperty(exports, "__esModule", ({ value: true }));
16849+
const CONST = {
16850+
GITHUB_OWNER: 'Expensify',
16851+
APP_REPO: 'App',
16852+
APPLAUSE_BOT: 'applausebot',
16853+
OS_BOTIFY: 'OSBotify',
16854+
LABELS: {
16855+
STAGING_DEPLOY: 'StagingDeployCash',
16856+
DEPLOY_BLOCKER: 'DeployBlockerCash',
16857+
INTERNAL_QA: 'InternalQA',
16858+
},
16859+
DATE_FORMAT_STRING: 'yyyy-MM-dd',
16860+
APP_REPO_URL: '',
16861+
APP_REPO_GIT_URL: '',
16862+
};
16863+
CONST.APP_REPO_URL = `https://github.com/${CONST.GITHUB_OWNER}/${CONST.APP_REPO}`;
16864+
CONST.APP_REPO_GIT_URL = `git@github.com:${CONST.GITHUB_OWNER}/${CONST.APP_REPO}.git`;
16865+
exports["default"] = CONST;
16866+
16867+
1686516868
/***/ }),
1686616869

1686716870
/***/ 9296:
@@ -16904,7 +16907,7 @@ const plugin_paginate_rest_1 = __nccwpck_require__(4193);
1690416907
const plugin_throttling_1 = __nccwpck_require__(9968);
1690516908
const EmptyObject_1 = __nccwpck_require__(8227);
1690616909
const arrayDifference_1 = __importDefault(__nccwpck_require__(7034));
16907-
const CONST_1 = __importDefault(__nccwpck_require__(4097));
16910+
const CONST_1 = __importDefault(__nccwpck_require__(9873));
1690816911
const GITHUB_BASE_URL_REGEX = new RegExp('https?://(?:github\\.com|api\\.github\\.com)');
1690916912
const PULL_REQUEST_REGEX = new RegExp(`${GITHUB_BASE_URL_REGEX.source}/.*/.*/pull/([0-9]+).*`);
1691016913
const ISSUE_REGEX = new RegExp(`${GITHUB_BASE_URL_REGEX.source}/.*/.*/issues/([0-9]+).*`);
@@ -17250,7 +17253,6 @@ class GithubUtils {
1725017253
* Generate the URL of an New Expensify pull request given the PR number.
1725117254
*/
1725217255
static getPullRequestURLFromNumber(value) {
17253-
// @ts-expect-error TODO: Remove this once CONST.js (https://github.com/Expensify/App/issues/25362) is migrated to TypeScript
1725417256
return `${CONST_1.default.APP_REPO_URL}/pull/${value}`;
1725517257
}
1725617258
/**

.github/actions/javascript/awaitStagingDeploys/awaitStagingDeploys.js renamed to .github/actions/javascript/awaitStagingDeploys/awaitStagingDeploys.ts

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
const _ = require('underscore');
2-
const lodashThrottle = require('lodash/throttle');
3-
const CONST = require('../../../libs/CONST');
4-
const ActionUtils = require('../../../libs/ActionUtils');
5-
const GitHubUtils = require('../../../libs/GithubUtils');
6-
const {promiseDoWhile} = require('../../../libs/promiseWhile');
1+
/* eslint-disable @typescript-eslint/naming-convention */
2+
import lodashThrottle from 'lodash/throttle';
3+
import ActionUtils from '@github/libs/ActionUtils';
4+
import CONST from '@github/libs/CONST';
5+
import GitHubUtils, {POLL_RATE} from '@github/libs/GithubUtils';
6+
import {promiseDoWhile} from '@github/libs/promiseWhile';
7+
8+
type CurrentStagingDeploys = Awaited<ReturnType<typeof GitHubUtils.octokit.actions.listWorkflowRuns>>['data']['workflow_runs'];
79

810
function run() {
911
console.info('[awaitStagingDeploys] run()');
@@ -14,9 +16,9 @@ function run() {
1416
const tag = ActionUtils.getStringInput('TAG', {required: false});
1517
console.info('[awaitStagingDeploys] run() tag', tag);
1618

17-
let currentStagingDeploys = [];
19+
let currentStagingDeploys: CurrentStagingDeploys = [];
1820

19-
console.info('[awaitStagingDeploys] run() _.throttle', _.throttle);
21+
console.info('[awaitStagingDeploys] run() _.throttle', lodashThrottle);
2022

2123
const throttleFunc = () =>
2224
Promise.all([
@@ -40,28 +42,28 @@ function run() {
4042
])
4143
.then((responses) => {
4244
const workflowRuns = responses[0].data.workflow_runs;
43-
if (!tag) {
45+
if (!tag && typeof responses[1] === 'object') {
4446
workflowRuns.push(...responses[1].data.workflow_runs);
4547
}
4648
return workflowRuns;
4749
})
48-
.then((workflowRuns) => (currentStagingDeploys = _.filter(workflowRuns, (workflowRun) => workflowRun.status !== 'completed')))
50+
.then((workflowRuns) => (currentStagingDeploys = workflowRuns.filter((workflowRun) => workflowRun.status !== 'completed')))
4951
.then(() =>
5052
console.log(
51-
_.isEmpty(currentStagingDeploys)
53+
!currentStagingDeploys.length
5254
? 'No current staging deploys found'
5355
: `Found ${currentStagingDeploys.length} staging deploy${currentStagingDeploys.length > 1 ? 's' : ''} still running...`,
5456
),
5557
);
5658
console.info('[awaitStagingDeploys] run() throttleFunc', throttleFunc);
5759

5860
return promiseDoWhile(
59-
() => !_.isEmpty(currentStagingDeploys),
61+
() => !!currentStagingDeploys.length,
6062
lodashThrottle(
6163
throttleFunc,
6264

6365
// Poll every 60 seconds instead of every 10 seconds
64-
GitHubUtils.POLL_RATE * 6,
66+
POLL_RATE * 6,
6567
),
6668
);
6769
}
@@ -70,4 +72,4 @@ if (require.main === module) {
7072
run();
7173
}
7274

73-
module.exports = run;
75+
export default run;

0 commit comments

Comments
 (0)