From c99ce964bada195c2d866e628de95cb8319a5075 Mon Sep 17 00:00:00 2001 From: Filip Solecki Date: Tue, 13 Feb 2024 12:48:14 +0100 Subject: [PATCH 01/13] Migrate GitUtils and GitUtilsTests --- .../createOrUpdateStagingDeploy.js | 2 +- .../getDeployPullRequestList.js | 2 +- .github/libs/{GitUtils.js => GitUtils.ts} | 52 ++++++++----------- .github/libs/versionUpdater.js | 6 +-- tests/unit/CIGitLogicTest.sh | 12 ++--- .../unit/{GitUtilsTest.js => GitUtilsTest.ts} | 46 +++++++++------- tests/unit/createOrUpdateStagingDeployTest.js | 2 +- tests/unit/markPullRequestsAsDeployedTest.js | 2 +- .../utils/{bumpVersion.mjs => bumpVersion.ts} | 2 +- ...viousVersion.mjs => getPreviousVersion.ts} | 2 +- tests/utils/getPullRequestsMergedBetween.mjs | 14 ----- tests/utils/getPullRequestsMergedBetween.ts | 17 ++++++ 12 files changed, 81 insertions(+), 78 deletions(-) rename .github/libs/{GitUtils.js => GitUtils.ts} (76%) rename tests/unit/{GitUtilsTest.js => GitUtilsTest.ts} (57%) rename tests/utils/{bumpVersion.mjs => bumpVersion.ts} (98%) rename tests/utils/{getPreviousVersion.mjs => getPreviousVersion.ts} (97%) delete mode 100755 tests/utils/getPullRequestsMergedBetween.mjs create mode 100755 tests/utils/getPullRequestsMergedBetween.ts diff --git a/.github/actions/javascript/createOrUpdateStagingDeploy/createOrUpdateStagingDeploy.js b/.github/actions/javascript/createOrUpdateStagingDeploy/createOrUpdateStagingDeploy.js index f0e45257bbef..4441348a3c36 100644 --- a/.github/actions/javascript/createOrUpdateStagingDeploy/createOrUpdateStagingDeploy.js +++ b/.github/actions/javascript/createOrUpdateStagingDeploy/createOrUpdateStagingDeploy.js @@ -4,7 +4,7 @@ const _ = require('underscore'); const core = require('@actions/core'); const CONST = require('../../../libs/CONST'); const GithubUtils = require('../../../libs/GithubUtils'); -const GitUtils = require('../../../libs/GitUtils'); +const GitUtils = require('../../../libs/GitUtils').default; async function run() { // Note: require('package.json').version does not work because ncc will resolve that to a plain string at compile time diff --git a/.github/actions/javascript/getDeployPullRequestList/getDeployPullRequestList.js b/.github/actions/javascript/getDeployPullRequestList/getDeployPullRequestList.js index a64ebfc240ba..da0dde4ff1ca 100644 --- a/.github/actions/javascript/getDeployPullRequestList/getDeployPullRequestList.js +++ b/.github/actions/javascript/getDeployPullRequestList/getDeployPullRequestList.js @@ -2,7 +2,7 @@ const _ = require('underscore'); const core = require('@actions/core'); const github = require('@actions/github'); const ActionUtils = require('../../../libs/ActionUtils'); -const GitUtils = require('../../../libs/GitUtils'); +const GitUtils = require('../../../libs/GitUtils').default; const GithubUtils = require('../../../libs/GithubUtils'); async function run() { diff --git a/.github/libs/GitUtils.js b/.github/libs/GitUtils.ts similarity index 76% rename from .github/libs/GitUtils.js rename to .github/libs/GitUtils.ts index 2076763fbb55..051a3f3dc40b 100644 --- a/.github/libs/GitUtils.js +++ b/.github/libs/GitUtils.ts @@ -1,14 +1,18 @@ -const _ = require('underscore'); -const {spawn, execSync} = require('child_process'); -const CONST = require('./CONST'); -const sanitizeStringForJSONParse = require('./sanitizeStringForJSONParse'); -const {getPreviousVersion, SEMANTIC_VERSION_LEVELS} = require('../libs/versionUpdater'); +import {execSync, spawn} from 'child_process'; +import * as CONST from './CONST'; +import sanitizeStringForJSONParse from './sanitizeStringForJSONParse'; +import * as VERSION_UPDATER from './versionUpdater'; + +type CommitType = { + commit: string; + subject: string; + authorName: string; +}; /** - * @param {String} tag - * @param {String} [shallowExcludeTag] when fetching the given tag, exclude all history reachable by the shallowExcludeTag (used to make fetch much faster) + * When fetching the given tag, exclude all history reachable by the shallowExcludeTag (used to make fetch much faster) */ -function fetchTag(tag, shallowExcludeTag = '') { +function fetchTag(tag: string, shallowExcludeTag = '') { let shouldRetry = true; let needsRepack = false; while (shouldRetry) { @@ -47,19 +51,15 @@ function fetchTag(tag, shallowExcludeTag = '') { /** * Get merge logs between two tags (inclusive) as a JavaScript object. - * - * @param {String} fromTag - * @param {String} toTag - * @returns {Promise>>} */ -function getCommitHistoryAsJSON(fromTag, toTag) { +function getCommitHistoryAsJSON(fromTag: string, toTag: string): Promise { // Fetch tags, exclude commits reachable from the previous patch version (i.e: previous checklist), so that we don't have to fetch the full history - const previousPatchVersion = getPreviousVersion(fromTag, SEMANTIC_VERSION_LEVELS.PATCH); + const previousPatchVersion = VERSION_UPDATER.getPreviousVersion(fromTag, VERSION_UPDATER.SEMANTIC_VERSION_LEVELS.PATCH); fetchTag(fromTag, previousPatchVersion); fetchTag(toTag, previousPatchVersion); console.log('Getting pull requests merged between the following tags:', fromTag, toTag); - return new Promise((resolve, reject) => { + return new Promise((resolve, reject) => { let stdout = ''; let stderr = ''; const args = ['log', '--format={"commit": "%H", "authorName": "%an", "subject": "%s"},', `${fromTag}...${toTag}`]; @@ -89,26 +89,23 @@ function getCommitHistoryAsJSON(fromTag, toTag) { // Then remove newlines, format as JSON and convert to a proper JS object const json = `[${sanitizedOutput}]`.replace(/(\r\n|\n|\r)/gm, '').replace('},]', '}]'); - return JSON.parse(json); + return JSON.parse(json) as CommitType[]; }); } /** * Parse merged PRs, excluding those from irrelevant branches. - * - * @param {Array>} commits - * @returns {Array} */ -function getValidMergedPRs(commits) { - const mergedPRs = new Set(); - _.each(commits, (commit) => { +function getValidMergedPRs(commits: CommitType[]): number[] { + const mergedPRs = new Set(); + commits.forEach((commit) => { const author = commit.authorName; if (author === CONST.OS_BOTIFY) { return; } const match = commit.subject.match(/Merge pull request #(\d+) from (?!Expensify\/.*-cherry-pick-staging)/); - if (!_.isArray(match) || match.length < 2) { + if (!Array.isArray(match) || match.length < 2) { return; } @@ -128,12 +125,8 @@ function getValidMergedPRs(commits) { /** * Takes in two git tags and returns a list of PR numbers of all PRs merged between those two tags - * - * @param {String} fromTag - * @param {String} toTag - * @returns {Promise>} – Pull request numbers */ -async function getPullRequestsMergedBetween(fromTag, toTag) { +async function getPullRequestsMergedBetween(fromTag: string, toTag: string) { console.log(`Looking for commits made between ${fromTag} and ${toTag}...`); const commitList = await getCommitHistoryAsJSON(fromTag, toTag); console.log(`Commits made between ${fromTag} and ${toTag}:`, commitList); @@ -144,7 +137,8 @@ async function getPullRequestsMergedBetween(fromTag, toTag) { return pullRequestNumbers; } -module.exports = { +export default { getValidMergedPRs, getPullRequestsMergedBetween, }; +export type {CommitType}; diff --git a/.github/libs/versionUpdater.js b/.github/libs/versionUpdater.js index 78e8085621bd..5526ee38d2ea 100644 --- a/.github/libs/versionUpdater.js +++ b/.github/libs/versionUpdater.js @@ -65,8 +65,8 @@ const incrementPatch = (major, minor, patch) => { /** * Increments a build version * - * @param {Number} version - * @param {Number} level + * @param {String} version + * @param {String} level * @returns {String} */ const incrementVersion = (version, level) => { @@ -127,7 +127,7 @@ function getPreviousVersion(currentVersion, level) { return getVersionStringFromNumber(major, minor, patch, build - 1); } -module.exports = { +export { getVersionNumberFromString, getVersionStringFromNumber, incrementVersion, diff --git a/tests/unit/CIGitLogicTest.sh b/tests/unit/CIGitLogicTest.sh index f35ead3542d3..73fd01f5c0a0 100755 --- a/tests/unit/CIGitLogicTest.sh +++ b/tests/unit/CIGitLogicTest.sh @@ -10,9 +10,9 @@ declare -r GIT_REMOTE="$HOME/dummyGitRemotes/DumDumRepo" declare -r SEMVER_LEVEL_BUILD='BUILD' declare -r SEMVER_LEVEL_PATCH='PATCH' -declare -r bumpVersion="$TEST_DIR/utils/bumpVersion.mjs" -declare -r getPreviousVersion="$TEST_DIR/utils/getPreviousVersion.mjs" -declare -r getPullRequestsMergedBetween="$TEST_DIR/utils/getPullRequestsMergedBetween.mjs" +declare -r bumpVersion="$TEST_DIR/utils/bumpVersion.ts" +declare -r getPreviousVersion="$TEST_DIR/utils/getPreviousVersion.ts" +declare -r getPullRequestsMergedBetween="$TEST_DIR/utils/getPullRequestsMergedBetween.ts" source "$SCRIPTS_DIR/shellUtils.sh" @@ -76,7 +76,7 @@ function bump_version { info "Bumping version..." setup_git_as_osbotify git switch main - npm --no-git-tag-version version "$(node "$bumpVersion" "$(print_version)" "$1")" + npm --no-git-tag-version version "$(ts-node "$bumpVersion" "$(print_version)" "$1")" git add package.json package-lock.json git commit -m "Update version to $(print_version)" git push origin main @@ -142,7 +142,7 @@ function cherry_pick_pr { checkout_repo setup_git_as_osbotify - PREVIOUS_PATCH_VERSION="$(node "$getPreviousVersion" "$(print_version)" "$SEMVER_LEVEL_PATCH")" + PREVIOUS_PATCH_VERSION="$(ts-node "$getPreviousVersion" "$(print_version)" "$SEMVER_LEVEL_PATCH")" git fetch origin main staging --no-tags --shallow-exclude="$PREVIOUS_PATCH_VERSION" git switch staging @@ -201,7 +201,7 @@ function deploy_production { function assert_prs_merged_between { checkout_repo - output=$(node "$getPullRequestsMergedBetween" "$1" "$2") + output=$(ts-node "$getPullRequestsMergedBetween" "$1" "$2") info "Checking output of getPullRequestsMergedBetween $1 $2" assert_equal "$output" "$3" } diff --git a/tests/unit/GitUtilsTest.js b/tests/unit/GitUtilsTest.ts similarity index 57% rename from tests/unit/GitUtilsTest.js rename to tests/unit/GitUtilsTest.ts index 945a97a8ddd7..f82fa0e28ada 100644 --- a/tests/unit/GitUtilsTest.js +++ b/tests/unit/GitUtilsTest.ts @@ -1,38 +1,44 @@ -const GitUtils = require('../../.github/libs/GitUtils'); +import type {CommitType} from '../../.github/libs/GitUtils'; +import GitUtils from '../../.github/libs/GitUtils'; -const data = [ +type ExampleDataType = { + input: CommitType[]; + expectedOutput: number[]; +}; + +const data: ExampleDataType[] = [ { input: [], expectedOutput: [], }, { - input: [{commit: '1', subject: 'Some random commit message', author: 'test@gmail.com'}], + input: [{commit: '1', subject: 'Some random commit message', authorName: 'test@gmail.com'}], expectedOutput: [], }, { input: [ - {commit: '1', subject: 'Start adding StagingDeployCash logic', author: 'test@gmail.com'}, - {commit: '2', subject: 'Setting up bones', author: 'test@gmail.com'}, - {commit: '3', subject: 'Merge pull request #337 from Expensify/francoisUpdateQbdSyncManager', author: 'test@gmail.com'}, - {commit: '4', subject: 'Merge pull request #336 from Expensify/andrew-pr-cla', author: 'test@gmail.com'}, - {commit: '5', subject: 'Update QBD Sync Manager version', author: 'test@gmail.com'}, - {commit: '6', subject: 'Only run CLA on PR comments or events', author: 'test@gmail.com'}, - {commit: '7', subject: 'Merge pull request #331 from Expensify/marcaaron-killMoment', author: 'test@gmail.com'}, - {commit: '8', subject: 'Merge pull request #330 from Expensify/andrew-cla-update', author: 'test@gmail.com'}, - {commit: '9', subject: 'Merge pull request #333 from Expensify/Rory-AddOnOffSwitchTooltip', author: 'test@gmail.com'}, - {commit: '10', subject: 'Setup OnOffSwitch component with tooltips', author: 'test@gmail.com'}, - {commit: '11', subject: 'Merge pull request #332 from Expensify/alex-mechler-patch-1', author: 'test@gmail.com'}, - {commit: '12', subject: 'Return to old hash-based deploy instrcutions', author: 'test@gmail.com'}, - {commit: '12', subject: 'Remove DEFAULT_START_DATE & DEFAULT_END_DATE altogether', author: 'test@gmail.com'}, + {commit: '1', subject: 'Start adding StagingDeployCash logic', authorName: 'test@gmail.com'}, + {commit: '2', subject: 'Setting up bones', authorName: 'test@gmail.com'}, + {commit: '3', subject: 'Merge pull request #337 from Expensify/francoisUpdateQbdSyncManager', authorName: 'test@gmail.com'}, + {commit: '4', subject: 'Merge pull request #336 from Expensify/andrew-pr-cla', authorName: 'test@gmail.com'}, + {commit: '5', subject: 'Update QBD Sync Manager version', authorName: 'test@gmail.com'}, + {commit: '6', subject: 'Only run CLA on PR comments or events', authorName: 'test@gmail.com'}, + {commit: '7', subject: 'Merge pull request #331 from Expensify/marcaaron-killMoment', authorName: 'test@gmail.com'}, + {commit: '8', subject: 'Merge pull request #330 from Expensify/andrew-cla-update', authorName: 'test@gmail.com'}, + {commit: '9', subject: 'Merge pull request #333 from Expensify/Rory-AddOnOffSwitchTooltip', authorName: 'test@gmail.com'}, + {commit: '10', subject: 'Setup OnOffSwitch component with tooltips', authorName: 'test@gmail.com'}, + {commit: '11', subject: 'Merge pull request #332 from Expensify/alex-mechler-patch-1', authorName: 'test@gmail.com'}, + {commit: '12', subject: 'Return to old hash-based deploy instrcutions', authorName: 'test@gmail.com'}, + {commit: '12', subject: 'Remove DEFAULT_START_DATE & DEFAULT_END_DATE altogether', authorName: 'test@gmail.com'}, ], expectedOutput: [337, 336, 331, 330, 333, 332], }, { input: [ - {commit: '1', subject: 'Merge pull request #1521 from parasharrajat/parasharrajat/pdf-render', author: 'test@gmail.com'}, - {commit: '3', subject: 'Update version to 1.0.1-470', author: 'test@gmail.com'}, - {commit: '4', subject: '[IS-1500] Updated textalignInput utility', author: 'test@gmail.com'}, - {commit: '5', subject: 'fix: set pdf width on large screens', author: 'test@gmail.com'}, + {commit: '1', subject: 'Merge pull request #1521 from parasharrajat/parasharrajat/pdf-render', authorName: 'test@gmail.com'}, + {commit: '3', subject: 'Update version to 1.0.1-470', authorName: 'test@gmail.com'}, + {commit: '4', subject: '[IS-1500] Updated textalignInput utility', authorName: 'test@gmail.com'}, + {commit: '5', subject: 'fix: set pdf width on large screens', authorName: 'test@gmail.com'}, ], expectedOutput: [1521], }, diff --git a/tests/unit/createOrUpdateStagingDeployTest.js b/tests/unit/createOrUpdateStagingDeployTest.js index 31b1a9346169..15a795842667 100644 --- a/tests/unit/createOrUpdateStagingDeployTest.js +++ b/tests/unit/createOrUpdateStagingDeployTest.js @@ -6,7 +6,7 @@ const fns = require('date-fns'); const {vol} = require('memfs'); const path = require('path'); const CONST = require('../../.github/libs/CONST'); -const GitUtils = require('../../.github/libs/GitUtils'); +const GitUtils = require('../../.github/libs/GitUtils').default; const GithubUtils = require('../../.github/libs/GithubUtils'); const run = require('../../.github/actions/javascript/createOrUpdateStagingDeploy/createOrUpdateStagingDeploy'); diff --git a/tests/unit/markPullRequestsAsDeployedTest.js b/tests/unit/markPullRequestsAsDeployedTest.js index e9e68236ef99..81da0a5c9371 100644 --- a/tests/unit/markPullRequestsAsDeployedTest.js +++ b/tests/unit/markPullRequestsAsDeployedTest.js @@ -2,7 +2,7 @@ * @jest-environment node */ const _ = require('underscore'); -const GitUtils = require('../../.github/libs/GitUtils'); +const GitUtils = require('../../.github/libs/GitUtils').default; const GithubUtils = require('../../.github/libs/GithubUtils'); let run; diff --git a/tests/utils/bumpVersion.mjs b/tests/utils/bumpVersion.ts similarity index 98% rename from tests/utils/bumpVersion.mjs rename to tests/utils/bumpVersion.ts index 19471ee7f905..e187de508dab 100644 --- a/tests/utils/bumpVersion.mjs +++ b/tests/utils/bumpVersion.ts @@ -1,5 +1,5 @@ #!/usr/bin/env node -import {incrementVersion} from '../../.github/libs/versionUpdater.js'; +import {incrementVersion} from '../../.github/libs/versionUpdater'; const version = process.argv[2]; const level = process.argv[3]; diff --git a/tests/utils/getPreviousVersion.mjs b/tests/utils/getPreviousVersion.ts similarity index 97% rename from tests/utils/getPreviousVersion.mjs rename to tests/utils/getPreviousVersion.ts index 31ca672776fa..1eecf2fe5180 100644 --- a/tests/utils/getPreviousVersion.mjs +++ b/tests/utils/getPreviousVersion.ts @@ -1,5 +1,5 @@ #!/usr/bin/env node -import {getPreviousVersion} from '../../.github/libs/versionUpdater.js'; +import {getPreviousVersion} from '../../.github/libs/versionUpdater'; const currentVersion = process.argv[2]; const level = process.argv[3]; diff --git a/tests/utils/getPullRequestsMergedBetween.mjs b/tests/utils/getPullRequestsMergedBetween.mjs deleted file mode 100755 index 0afb1499e67f..000000000000 --- a/tests/utils/getPullRequestsMergedBetween.mjs +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env node -import GitUtils from '../../.github/libs/GitUtils.js'; - -const fromRef = process.argv[2]; -const toRef = process.argv[3]; - -/* eslint-disable no-console */ -const realConsoleLog = console.log; -console.log = () => {}; - -const output = await GitUtils.getPullRequestsMergedBetween(fromRef, toRef); - -console.log = realConsoleLog; -console.log(output); diff --git a/tests/utils/getPullRequestsMergedBetween.ts b/tests/utils/getPullRequestsMergedBetween.ts new file mode 100755 index 000000000000..2bf5a0835710 --- /dev/null +++ b/tests/utils/getPullRequestsMergedBetween.ts @@ -0,0 +1,17 @@ +#!/usr/bin/env node +import GitUtils from '../../.github/libs/GitUtils'; + +const fromRef = process.argv[2]; +const toRef = process.argv[3]; + +/* eslint-disable no-console */ +const realConsoleLog = console.log; +console.log = () => {}; + +async function main() { + const output = await GitUtils.getPullRequestsMergedBetween(fromRef, toRef); + + console.log = realConsoleLog; + console.log(output); +} +main(); From 63ce097ea2d01054d32a8197a58a550460c94b14 Mon Sep 17 00:00:00 2001 From: Filip Solecki Date: Tue, 13 Feb 2024 12:53:38 +0100 Subject: [PATCH 02/13] Install ts-node --- tests/unit/CIGitLogicTest.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/unit/CIGitLogicTest.sh b/tests/unit/CIGitLogicTest.sh index 73fd01f5c0a0..49a916d7b9dc 100755 --- a/tests/unit/CIGitLogicTest.sh +++ b/tests/unit/CIGitLogicTest.sh @@ -76,6 +76,7 @@ function bump_version { info "Bumping version..." setup_git_as_osbotify git switch main + npm i ts-node npm --no-git-tag-version version "$(ts-node "$bumpVersion" "$(print_version)" "$1")" git add package.json package-lock.json git commit -m "Update version to $(print_version)" @@ -142,6 +143,7 @@ function cherry_pick_pr { checkout_repo setup_git_as_osbotify + npm i ts-node PREVIOUS_PATCH_VERSION="$(ts-node "$getPreviousVersion" "$(print_version)" "$SEMVER_LEVEL_PATCH")" git fetch origin main staging --no-tags --shallow-exclude="$PREVIOUS_PATCH_VERSION" @@ -201,6 +203,7 @@ function deploy_production { function assert_prs_merged_between { checkout_repo + npm i ts-node output=$(ts-node "$getPullRequestsMergedBetween" "$1" "$2") info "Checking output of getPullRequestsMergedBetween $1 $2" assert_equal "$output" "$3" From a3e8a8d550800171414bb598cc3f4e3cbaf6583a Mon Sep 17 00:00:00 2001 From: Filip Solecki Date: Tue, 13 Feb 2024 12:57:55 +0100 Subject: [PATCH 03/13] rebuild gh actions --- .../javascript/authorChecklist/index.js | 33 +- .../actions/javascript/bumpVersion/index.js | 59 ++- .../createOrUpdateStagingDeploy/index.js | 376 ++++++++++-------- .../getDeployPullRequestList/index.js | 376 ++++++++++-------- .../javascript/getPreviousVersion/index.js | 57 ++- .../javascript/verifySignedCommits/index.js | 31 +- 6 files changed, 526 insertions(+), 406 deletions(-) diff --git a/.github/actions/javascript/authorChecklist/index.js b/.github/actions/javascript/authorChecklist/index.js index 137020670c10..26277693e888 100644 --- a/.github/actions/javascript/authorChecklist/index.js +++ b/.github/actions/javascript/authorChecklist/index.js @@ -1,6 +1,7 @@ /** * NOTE: This is a compiled file. DO NOT directly edit this file. */ +import { createRequire as __WEBPACK_EXTERNAL_createRequire } from "module"; /******/ (() => { // webpackBootstrap /******/ var __webpack_modules__ = ({ @@ -18686,7 +18687,7 @@ module.exports = eval("require")("encoding"); /***/ ((module) => { "use strict"; -module.exports = require("assert"); +module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("assert"); /***/ }), @@ -18694,7 +18695,7 @@ module.exports = require("assert"); /***/ ((module) => { "use strict"; -module.exports = require("crypto"); +module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("crypto"); /***/ }), @@ -18702,7 +18703,7 @@ module.exports = require("crypto"); /***/ ((module) => { "use strict"; -module.exports = require("events"); +module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("events"); /***/ }), @@ -18710,7 +18711,7 @@ module.exports = require("events"); /***/ ((module) => { "use strict"; -module.exports = require("fs"); +module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("fs"); /***/ }), @@ -18718,7 +18719,7 @@ module.exports = require("fs"); /***/ ((module) => { "use strict"; -module.exports = require("http"); +module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("http"); /***/ }), @@ -18726,7 +18727,7 @@ module.exports = require("http"); /***/ ((module) => { "use strict"; -module.exports = require("https"); +module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("https"); /***/ }), @@ -18734,7 +18735,7 @@ module.exports = require("https"); /***/ ((module) => { "use strict"; -module.exports = require("net"); +module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("net"); /***/ }), @@ -18742,7 +18743,7 @@ module.exports = require("net"); /***/ ((module) => { "use strict"; -module.exports = require("os"); +module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("os"); /***/ }), @@ -18750,7 +18751,7 @@ module.exports = require("os"); /***/ ((module) => { "use strict"; -module.exports = require("path"); +module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("path"); /***/ }), @@ -18758,7 +18759,7 @@ module.exports = require("path"); /***/ ((module) => { "use strict"; -module.exports = require("punycode"); +module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("punycode"); /***/ }), @@ -18766,7 +18767,7 @@ module.exports = require("punycode"); /***/ ((module) => { "use strict"; -module.exports = require("stream"); +module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("stream"); /***/ }), @@ -18774,7 +18775,7 @@ module.exports = require("stream"); /***/ ((module) => { "use strict"; -module.exports = require("tls"); +module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("tls"); /***/ }), @@ -18782,7 +18783,7 @@ module.exports = require("tls"); /***/ ((module) => { "use strict"; -module.exports = require("tty"); +module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("tty"); /***/ }), @@ -18790,7 +18791,7 @@ module.exports = require("tty"); /***/ ((module) => { "use strict"; -module.exports = require("url"); +module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("url"); /***/ }), @@ -18798,7 +18799,7 @@ module.exports = require("url"); /***/ ((module) => { "use strict"; -module.exports = require("util"); +module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("util"); /***/ }), @@ -18806,7 +18807,7 @@ module.exports = require("util"); /***/ ((module) => { "use strict"; -module.exports = require("zlib"); +module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("zlib"); /***/ }), diff --git a/.github/actions/javascript/bumpVersion/index.js b/.github/actions/javascript/bumpVersion/index.js index 1132c137061e..d17760baa91f 100644 --- a/.github/actions/javascript/bumpVersion/index.js +++ b/.github/actions/javascript/bumpVersion/index.js @@ -104,8 +104,20 @@ exports.updateiOSVersion = function updateiOSVersion(version) { /***/ }), /***/ 8007: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { +/***/ ((__unused_webpack_module, __webpack_exports__, __nccwpck_require__) => { +"use strict"; +__nccwpck_require__.r(__webpack_exports__); +/* harmony export */ __nccwpck_require__.d(__webpack_exports__, { +/* harmony export */ "MAX_INCREMENTS": () => (/* binding */ MAX_INCREMENTS), +/* harmony export */ "SEMANTIC_VERSION_LEVELS": () => (/* binding */ SEMANTIC_VERSION_LEVELS), +/* harmony export */ "getPreviousVersion": () => (/* binding */ getPreviousVersion), +/* harmony export */ "getVersionNumberFromString": () => (/* binding */ getVersionNumberFromString), +/* harmony export */ "getVersionStringFromNumber": () => (/* binding */ getVersionStringFromNumber), +/* harmony export */ "incrementMinor": () => (/* binding */ incrementMinor), +/* harmony export */ "incrementPatch": () => (/* binding */ incrementPatch), +/* harmony export */ "incrementVersion": () => (/* binding */ incrementVersion) +/* harmony export */ }); const _ = __nccwpck_require__(5067); const SEMANTIC_VERSION_LEVELS = { @@ -173,8 +185,8 @@ const incrementPatch = (major, minor, patch) => { /** * Increments a build version * - * @param {Number} version - * @param {Number} level + * @param {String} version + * @param {String} level * @returns {String} */ const incrementVersion = (version, level) => { @@ -235,18 +247,7 @@ function getPreviousVersion(currentVersion, level) { return getVersionStringFromNumber(major, minor, patch, build - 1); } -module.exports = { - getVersionNumberFromString, - getVersionStringFromNumber, - incrementVersion, - - // For tests - MAX_INCREMENTS, - SEMANTIC_VERSION_LEVELS, - incrementMinor, - incrementPatch, - getPreviousVersion, -}; + /***/ }), @@ -5954,6 +5955,34 @@ module.exports = underscoreNodeF._; /******/ } /******/ /************************************************************************/ +/******/ /* webpack/runtime/define property getters */ +/******/ (() => { +/******/ // define getter functions for harmony exports +/******/ __nccwpck_require__.d = (exports, definition) => { +/******/ for(var key in definition) { +/******/ if(__nccwpck_require__.o(definition, key) && !__nccwpck_require__.o(exports, key)) { +/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); +/******/ } +/******/ } +/******/ }; +/******/ })(); +/******/ +/******/ /* webpack/runtime/hasOwnProperty shorthand */ +/******/ (() => { +/******/ __nccwpck_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) +/******/ })(); +/******/ +/******/ /* webpack/runtime/make namespace object */ +/******/ (() => { +/******/ // define __esModule on exports +/******/ __nccwpck_require__.r = (exports) => { +/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { +/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); +/******/ } +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ })(); +/******/ /******/ /* webpack/runtime/compat */ /******/ /******/ if (typeof __nccwpck_require__ !== 'undefined') __nccwpck_require__.ab = __dirname + "/"; diff --git a/.github/actions/javascript/createOrUpdateStagingDeploy/index.js b/.github/actions/javascript/createOrUpdateStagingDeploy/index.js index 4116862da777..c09c1b8621f3 100644 --- a/.github/actions/javascript/createOrUpdateStagingDeploy/index.js +++ b/.github/actions/javascript/createOrUpdateStagingDeploy/index.js @@ -13,7 +13,7 @@ const _ = __nccwpck_require__(5067); const core = __nccwpck_require__(2186); const CONST = __nccwpck_require__(4097); const GithubUtils = __nccwpck_require__(7999); -const GitUtils = __nccwpck_require__(669); +const GitUtils = (__nccwpck_require__(1547)["default"]); async function run() { // Note: require('package.json').version does not work because ncc will resolve that to a plain string at compile time @@ -177,163 +177,6 @@ CONST.APP_REPO_GIT_URL = `git@github.com:${CONST.GITHUB_OWNER}/${CONST.APP_REPO} module.exports = CONST; -/***/ }), - -/***/ 669: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - -const _ = __nccwpck_require__(5067); -const {spawn, execSync} = __nccwpck_require__(2081); -const CONST = __nccwpck_require__(4097); -const sanitizeStringForJSONParse = __nccwpck_require__(9338); -const {getPreviousVersion, SEMANTIC_VERSION_LEVELS} = __nccwpck_require__(8007); - -/** - * @param {String} tag - * @param {String} [shallowExcludeTag] when fetching the given tag, exclude all history reachable by the shallowExcludeTag (used to make fetch much faster) - */ -function fetchTag(tag, shallowExcludeTag = '') { - let shouldRetry = true; - let needsRepack = false; - while (shouldRetry) { - try { - let command = ''; - if (needsRepack) { - // We have seen some scenarios where this fixes the git fetch. - // Why? Who knows... https://github.com/Expensify/App/pull/31459 - command = 'git repack -d'; - console.log(`Running command: ${command}`); - execSync(command); - } - - command = `git fetch origin tag ${tag} --no-tags`; - - // Note that this condition is only ever NOT true in the 1.0.0-0 edge case - if (shallowExcludeTag && shallowExcludeTag !== tag) { - command += ` --shallow-exclude=${shallowExcludeTag}`; - } - - console.log(`Running command: ${command}`); - execSync(command); - shouldRetry = false; - } catch (e) { - console.error(e); - if (!needsRepack) { - console.log('Attempting to repack and retry...'); - needsRepack = true; - } else { - console.error("Repack didn't help, giving up..."); - shouldRetry = false; - } - } - } -} - -/** - * Get merge logs between two tags (inclusive) as a JavaScript object. - * - * @param {String} fromTag - * @param {String} toTag - * @returns {Promise>>} - */ -function getCommitHistoryAsJSON(fromTag, toTag) { - // Fetch tags, exclude commits reachable from the previous patch version (i.e: previous checklist), so that we don't have to fetch the full history - const previousPatchVersion = getPreviousVersion(fromTag, SEMANTIC_VERSION_LEVELS.PATCH); - fetchTag(fromTag, previousPatchVersion); - fetchTag(toTag, previousPatchVersion); - - console.log('Getting pull requests merged between the following tags:', fromTag, toTag); - return new Promise((resolve, reject) => { - let stdout = ''; - let stderr = ''; - const args = ['log', '--format={"commit": "%H", "authorName": "%an", "subject": "%s"},', `${fromTag}...${toTag}`]; - console.log(`Running command: git ${args.join(' ')}`); - const spawnedProcess = spawn('git', args); - spawnedProcess.on('message', console.log); - spawnedProcess.stdout.on('data', (chunk) => { - console.log(chunk.toString()); - stdout += chunk.toString(); - }); - spawnedProcess.stderr.on('data', (chunk) => { - console.error(chunk.toString()); - stderr += chunk.toString(); - }); - spawnedProcess.on('close', (code) => { - if (code !== 0) { - return reject(new Error(`${stderr}`)); - } - - resolve(stdout); - }); - spawnedProcess.on('error', (err) => reject(err)); - }).then((stdout) => { - // Sanitize just the text within commit subjects as that's the only potentially un-parseable text. - const sanitizedOutput = stdout.replace(/(?<="subject": ").*?(?="})/g, (subject) => sanitizeStringForJSONParse(subject)); - - // Then remove newlines, format as JSON and convert to a proper JS object - const json = `[${sanitizedOutput}]`.replace(/(\r\n|\n|\r)/gm, '').replace('},]', '}]'); - - return JSON.parse(json); - }); -} - -/** - * Parse merged PRs, excluding those from irrelevant branches. - * - * @param {Array>} commits - * @returns {Array} - */ -function getValidMergedPRs(commits) { - const mergedPRs = new Set(); - _.each(commits, (commit) => { - const author = commit.authorName; - if (author === CONST.OS_BOTIFY) { - return; - } - - const match = commit.subject.match(/Merge pull request #(\d+) from (?!Expensify\/.*-cherry-pick-staging)/); - if (!_.isArray(match) || match.length < 2) { - return; - } - - const pr = Number.parseInt(match[1], 10); - if (mergedPRs.has(pr)) { - // If a PR shows up in the log twice, that means that the PR was deployed in the previous checklist. - // That also means that we don't want to include it in the current checklist, so we remove it now. - mergedPRs.delete(pr); - return; - } - - mergedPRs.add(pr); - }); - - return Array.from(mergedPRs); -} - -/** - * Takes in two git tags and returns a list of PR numbers of all PRs merged between those two tags - * - * @param {String} fromTag - * @param {String} toTag - * @returns {Promise>} – Pull request numbers - */ -async function getPullRequestsMergedBetween(fromTag, toTag) { - console.log(`Looking for commits made between ${fromTag} and ${toTag}...`); - const commitList = await getCommitHistoryAsJSON(fromTag, toTag); - console.log(`Commits made between ${fromTag} and ${toTag}:`, commitList); - - // Find which commit messages correspond to merged PR's - const pullRequestNumbers = getValidMergedPRs(commitList).sort((a, b) => a - b); - console.log(`List of pull requests merged between ${fromTag} and ${toTag}`, pullRequestNumbers); - return pullRequestNumbers; -} - -module.exports = { - getValidMergedPRs, - getPullRequestsMergedBetween, -}; - - /***/ }), /***/ 7999: @@ -909,8 +752,20 @@ module.exports = function (inputString) { /***/ }), /***/ 8007: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { +/***/ ((__unused_webpack_module, __webpack_exports__, __nccwpck_require__) => { +"use strict"; +__nccwpck_require__.r(__webpack_exports__); +/* harmony export */ __nccwpck_require__.d(__webpack_exports__, { +/* harmony export */ "MAX_INCREMENTS": () => (/* binding */ MAX_INCREMENTS), +/* harmony export */ "SEMANTIC_VERSION_LEVELS": () => (/* binding */ SEMANTIC_VERSION_LEVELS), +/* harmony export */ "getPreviousVersion": () => (/* binding */ getPreviousVersion), +/* harmony export */ "getVersionNumberFromString": () => (/* binding */ getVersionNumberFromString), +/* harmony export */ "getVersionStringFromNumber": () => (/* binding */ getVersionStringFromNumber), +/* harmony export */ "incrementMinor": () => (/* binding */ incrementMinor), +/* harmony export */ "incrementPatch": () => (/* binding */ incrementPatch), +/* harmony export */ "incrementVersion": () => (/* binding */ incrementVersion) +/* harmony export */ }); const _ = __nccwpck_require__(5067); const SEMANTIC_VERSION_LEVELS = { @@ -978,8 +833,8 @@ const incrementPatch = (major, minor, patch) => { /** * Increments a build version * - * @param {Number} version - * @param {Number} level + * @param {String} version + * @param {String} level * @returns {String} */ const incrementVersion = (version, level) => { @@ -1040,18 +895,7 @@ function getPreviousVersion(currentVersion, level) { return getVersionStringFromNumber(major, minor, patch, build - 1); } -module.exports = { - getVersionNumberFromString, - getVersionStringFromNumber, - incrementVersion, - - // For tests - MAX_INCREMENTS, - SEMANTIC_VERSION_LEVELS, - incrementMinor, - incrementPatch, - getPreviousVersion, -}; + /***/ }), @@ -16836,6 +16680,164 @@ function wrappy (fn, cb) { } +/***/ }), + +/***/ 1547: +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { + +"use strict"; + +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", ({ value: true })); +const child_process_1 = __nccwpck_require__(2081); +const CONST = __importStar(__nccwpck_require__(4097)); +const sanitizeStringForJSONParse_1 = __importDefault(__nccwpck_require__(9338)); +const VERSION_UPDATER = __importStar(__nccwpck_require__(8007)); +/** + * When fetching the given tag, exclude all history reachable by the shallowExcludeTag (used to make fetch much faster) + */ +function fetchTag(tag, shallowExcludeTag = '') { + let shouldRetry = true; + let needsRepack = false; + while (shouldRetry) { + try { + let command = ''; + if (needsRepack) { + // We have seen some scenarios where this fixes the git fetch. + // Why? Who knows... https://github.com/Expensify/App/pull/31459 + command = 'git repack -d'; + console.log(`Running command: ${command}`); + (0, child_process_1.execSync)(command); + } + command = `git fetch origin tag ${tag} --no-tags`; + // Note that this condition is only ever NOT true in the 1.0.0-0 edge case + if (shallowExcludeTag && shallowExcludeTag !== tag) { + command += ` --shallow-exclude=${shallowExcludeTag}`; + } + console.log(`Running command: ${command}`); + (0, child_process_1.execSync)(command); + shouldRetry = false; + } + catch (e) { + console.error(e); + if (!needsRepack) { + console.log('Attempting to repack and retry...'); + needsRepack = true; + } + else { + console.error("Repack didn't help, giving up..."); + shouldRetry = false; + } + } + } +} +/** + * Get merge logs between two tags (inclusive) as a JavaScript object. + */ +function getCommitHistoryAsJSON(fromTag, toTag) { + // Fetch tags, exclude commits reachable from the previous patch version (i.e: previous checklist), so that we don't have to fetch the full history + const previousPatchVersion = VERSION_UPDATER.getPreviousVersion(fromTag, VERSION_UPDATER.SEMANTIC_VERSION_LEVELS.PATCH); + fetchTag(fromTag, previousPatchVersion); + fetchTag(toTag, previousPatchVersion); + console.log('Getting pull requests merged between the following tags:', fromTag, toTag); + return new Promise((resolve, reject) => { + let stdout = ''; + let stderr = ''; + const args = ['log', '--format={"commit": "%H", "authorName": "%an", "subject": "%s"},', `${fromTag}...${toTag}`]; + console.log(`Running command: git ${args.join(' ')}`); + const spawnedProcess = (0, child_process_1.spawn)('git', args); + spawnedProcess.on('message', console.log); + spawnedProcess.stdout.on('data', (chunk) => { + console.log(chunk.toString()); + stdout += chunk.toString(); + }); + spawnedProcess.stderr.on('data', (chunk) => { + console.error(chunk.toString()); + stderr += chunk.toString(); + }); + spawnedProcess.on('close', (code) => { + if (code !== 0) { + return reject(new Error(`${stderr}`)); + } + resolve(stdout); + }); + spawnedProcess.on('error', (err) => reject(err)); + }).then((stdout) => { + // Sanitize just the text within commit subjects as that's the only potentially un-parseable text. + const sanitizedOutput = stdout.replace(/(?<="subject": ").*?(?="})/g, (subject) => (0, sanitizeStringForJSONParse_1.default)(subject)); + // Then remove newlines, format as JSON and convert to a proper JS object + const json = `[${sanitizedOutput}]`.replace(/(\r\n|\n|\r)/gm, '').replace('},]', '}]'); + return JSON.parse(json); + }); +} +/** + * Parse merged PRs, excluding those from irrelevant branches. + */ +function getValidMergedPRs(commits) { + const mergedPRs = new Set(); + commits.forEach((commit) => { + const author = commit.authorName; + if (author === CONST.OS_BOTIFY) { + return; + } + const match = commit.subject.match(/Merge pull request #(\d+) from (?!Expensify\/.*-cherry-pick-staging)/); + if (!Array.isArray(match) || match.length < 2) { + return; + } + const pr = Number.parseInt(match[1], 10); + if (mergedPRs.has(pr)) { + // If a PR shows up in the log twice, that means that the PR was deployed in the previous checklist. + // That also means that we don't want to include it in the current checklist, so we remove it now. + mergedPRs.delete(pr); + return; + } + mergedPRs.add(pr); + }); + return Array.from(mergedPRs); +} +/** + * Takes in two git tags and returns a list of PR numbers of all PRs merged between those two tags + */ +async function getPullRequestsMergedBetween(fromTag, toTag) { + console.log(`Looking for commits made between ${fromTag} and ${toTag}...`); + const commitList = await getCommitHistoryAsJSON(fromTag, toTag); + console.log(`Commits made between ${fromTag} and ${toTag}:`, commitList); + // Find which commit messages correspond to merged PR's + const pullRequestNumbers = getValidMergedPRs(commitList).sort((a, b) => a - b); + console.log(`List of pull requests merged between ${fromTag} and ${toTag}`, pullRequestNumbers); + return pullRequestNumbers; +} +exports["default"] = { + getValidMergedPRs, + getPullRequestsMergedBetween, +}; + + /***/ }), /***/ 2877: @@ -19226,6 +19228,34 @@ module.exports = JSON.parse('[[[0,44],"disallowed_STD3_valid"],[[45,46],"valid"] /******/ } /******/ /************************************************************************/ +/******/ /* webpack/runtime/define property getters */ +/******/ (() => { +/******/ // define getter functions for harmony exports +/******/ __nccwpck_require__.d = (exports, definition) => { +/******/ for(var key in definition) { +/******/ if(__nccwpck_require__.o(definition, key) && !__nccwpck_require__.o(exports, key)) { +/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); +/******/ } +/******/ } +/******/ }; +/******/ })(); +/******/ +/******/ /* webpack/runtime/hasOwnProperty shorthand */ +/******/ (() => { +/******/ __nccwpck_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) +/******/ })(); +/******/ +/******/ /* webpack/runtime/make namespace object */ +/******/ (() => { +/******/ // define __esModule on exports +/******/ __nccwpck_require__.r = (exports) => { +/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { +/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); +/******/ } +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ })(); +/******/ /******/ /* webpack/runtime/compat */ /******/ /******/ if (typeof __nccwpck_require__ !== 'undefined') __nccwpck_require__.ab = __dirname + "/"; diff --git a/.github/actions/javascript/getDeployPullRequestList/index.js b/.github/actions/javascript/getDeployPullRequestList/index.js index ac5d0e26998a..837dfd82adf1 100644 --- a/.github/actions/javascript/getDeployPullRequestList/index.js +++ b/.github/actions/javascript/getDeployPullRequestList/index.js @@ -11,7 +11,7 @@ const _ = __nccwpck_require__(5067); const core = __nccwpck_require__(2186); const github = __nccwpck_require__(5438); const ActionUtils = __nccwpck_require__(970); -const GitUtils = __nccwpck_require__(669); +const GitUtils = (__nccwpck_require__(1547)["default"]); const GithubUtils = __nccwpck_require__(7999); async function run() { @@ -120,163 +120,6 @@ CONST.APP_REPO_GIT_URL = `git@github.com:${CONST.GITHUB_OWNER}/${CONST.APP_REPO} module.exports = CONST; -/***/ }), - -/***/ 669: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - -const _ = __nccwpck_require__(5067); -const {spawn, execSync} = __nccwpck_require__(2081); -const CONST = __nccwpck_require__(4097); -const sanitizeStringForJSONParse = __nccwpck_require__(9338); -const {getPreviousVersion, SEMANTIC_VERSION_LEVELS} = __nccwpck_require__(8007); - -/** - * @param {String} tag - * @param {String} [shallowExcludeTag] when fetching the given tag, exclude all history reachable by the shallowExcludeTag (used to make fetch much faster) - */ -function fetchTag(tag, shallowExcludeTag = '') { - let shouldRetry = true; - let needsRepack = false; - while (shouldRetry) { - try { - let command = ''; - if (needsRepack) { - // We have seen some scenarios where this fixes the git fetch. - // Why? Who knows... https://github.com/Expensify/App/pull/31459 - command = 'git repack -d'; - console.log(`Running command: ${command}`); - execSync(command); - } - - command = `git fetch origin tag ${tag} --no-tags`; - - // Note that this condition is only ever NOT true in the 1.0.0-0 edge case - if (shallowExcludeTag && shallowExcludeTag !== tag) { - command += ` --shallow-exclude=${shallowExcludeTag}`; - } - - console.log(`Running command: ${command}`); - execSync(command); - shouldRetry = false; - } catch (e) { - console.error(e); - if (!needsRepack) { - console.log('Attempting to repack and retry...'); - needsRepack = true; - } else { - console.error("Repack didn't help, giving up..."); - shouldRetry = false; - } - } - } -} - -/** - * Get merge logs between two tags (inclusive) as a JavaScript object. - * - * @param {String} fromTag - * @param {String} toTag - * @returns {Promise>>} - */ -function getCommitHistoryAsJSON(fromTag, toTag) { - // Fetch tags, exclude commits reachable from the previous patch version (i.e: previous checklist), so that we don't have to fetch the full history - const previousPatchVersion = getPreviousVersion(fromTag, SEMANTIC_VERSION_LEVELS.PATCH); - fetchTag(fromTag, previousPatchVersion); - fetchTag(toTag, previousPatchVersion); - - console.log('Getting pull requests merged between the following tags:', fromTag, toTag); - return new Promise((resolve, reject) => { - let stdout = ''; - let stderr = ''; - const args = ['log', '--format={"commit": "%H", "authorName": "%an", "subject": "%s"},', `${fromTag}...${toTag}`]; - console.log(`Running command: git ${args.join(' ')}`); - const spawnedProcess = spawn('git', args); - spawnedProcess.on('message', console.log); - spawnedProcess.stdout.on('data', (chunk) => { - console.log(chunk.toString()); - stdout += chunk.toString(); - }); - spawnedProcess.stderr.on('data', (chunk) => { - console.error(chunk.toString()); - stderr += chunk.toString(); - }); - spawnedProcess.on('close', (code) => { - if (code !== 0) { - return reject(new Error(`${stderr}`)); - } - - resolve(stdout); - }); - spawnedProcess.on('error', (err) => reject(err)); - }).then((stdout) => { - // Sanitize just the text within commit subjects as that's the only potentially un-parseable text. - const sanitizedOutput = stdout.replace(/(?<="subject": ").*?(?="})/g, (subject) => sanitizeStringForJSONParse(subject)); - - // Then remove newlines, format as JSON and convert to a proper JS object - const json = `[${sanitizedOutput}]`.replace(/(\r\n|\n|\r)/gm, '').replace('},]', '}]'); - - return JSON.parse(json); - }); -} - -/** - * Parse merged PRs, excluding those from irrelevant branches. - * - * @param {Array>} commits - * @returns {Array} - */ -function getValidMergedPRs(commits) { - const mergedPRs = new Set(); - _.each(commits, (commit) => { - const author = commit.authorName; - if (author === CONST.OS_BOTIFY) { - return; - } - - const match = commit.subject.match(/Merge pull request #(\d+) from (?!Expensify\/.*-cherry-pick-staging)/); - if (!_.isArray(match) || match.length < 2) { - return; - } - - const pr = Number.parseInt(match[1], 10); - if (mergedPRs.has(pr)) { - // If a PR shows up in the log twice, that means that the PR was deployed in the previous checklist. - // That also means that we don't want to include it in the current checklist, so we remove it now. - mergedPRs.delete(pr); - return; - } - - mergedPRs.add(pr); - }); - - return Array.from(mergedPRs); -} - -/** - * Takes in two git tags and returns a list of PR numbers of all PRs merged between those two tags - * - * @param {String} fromTag - * @param {String} toTag - * @returns {Promise>} – Pull request numbers - */ -async function getPullRequestsMergedBetween(fromTag, toTag) { - console.log(`Looking for commits made between ${fromTag} and ${toTag}...`); - const commitList = await getCommitHistoryAsJSON(fromTag, toTag); - console.log(`Commits made between ${fromTag} and ${toTag}:`, commitList); - - // Find which commit messages correspond to merged PR's - const pullRequestNumbers = getValidMergedPRs(commitList).sort((a, b) => a - b); - console.log(`List of pull requests merged between ${fromTag} and ${toTag}`, pullRequestNumbers); - return pullRequestNumbers; -} - -module.exports = { - getValidMergedPRs, - getPullRequestsMergedBetween, -}; - - /***/ }), /***/ 7999: @@ -852,8 +695,20 @@ module.exports = function (inputString) { /***/ }), /***/ 8007: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { +/***/ ((__unused_webpack_module, __webpack_exports__, __nccwpck_require__) => { +"use strict"; +__nccwpck_require__.r(__webpack_exports__); +/* harmony export */ __nccwpck_require__.d(__webpack_exports__, { +/* harmony export */ "MAX_INCREMENTS": () => (/* binding */ MAX_INCREMENTS), +/* harmony export */ "SEMANTIC_VERSION_LEVELS": () => (/* binding */ SEMANTIC_VERSION_LEVELS), +/* harmony export */ "getPreviousVersion": () => (/* binding */ getPreviousVersion), +/* harmony export */ "getVersionNumberFromString": () => (/* binding */ getVersionNumberFromString), +/* harmony export */ "getVersionStringFromNumber": () => (/* binding */ getVersionStringFromNumber), +/* harmony export */ "incrementMinor": () => (/* binding */ incrementMinor), +/* harmony export */ "incrementPatch": () => (/* binding */ incrementPatch), +/* harmony export */ "incrementVersion": () => (/* binding */ incrementVersion) +/* harmony export */ }); const _ = __nccwpck_require__(5067); const SEMANTIC_VERSION_LEVELS = { @@ -921,8 +776,8 @@ const incrementPatch = (major, minor, patch) => { /** * Increments a build version * - * @param {Number} version - * @param {Number} level + * @param {String} version + * @param {String} level * @returns {String} */ const incrementVersion = (version, level) => { @@ -983,18 +838,7 @@ function getPreviousVersion(currentVersion, level) { return getVersionStringFromNumber(major, minor, patch, build - 1); } -module.exports = { - getVersionNumberFromString, - getVersionStringFromNumber, - incrementVersion, - - // For tests - MAX_INCREMENTS, - SEMANTIC_VERSION_LEVELS, - incrementMinor, - incrementPatch, - getPreviousVersion, -}; + /***/ }), @@ -14068,6 +13912,164 @@ function wrappy (fn, cb) { } +/***/ }), + +/***/ 1547: +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { + +"use strict"; + +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", ({ value: true })); +const child_process_1 = __nccwpck_require__(2081); +const CONST = __importStar(__nccwpck_require__(4097)); +const sanitizeStringForJSONParse_1 = __importDefault(__nccwpck_require__(9338)); +const VERSION_UPDATER = __importStar(__nccwpck_require__(8007)); +/** + * When fetching the given tag, exclude all history reachable by the shallowExcludeTag (used to make fetch much faster) + */ +function fetchTag(tag, shallowExcludeTag = '') { + let shouldRetry = true; + let needsRepack = false; + while (shouldRetry) { + try { + let command = ''; + if (needsRepack) { + // We have seen some scenarios where this fixes the git fetch. + // Why? Who knows... https://github.com/Expensify/App/pull/31459 + command = 'git repack -d'; + console.log(`Running command: ${command}`); + (0, child_process_1.execSync)(command); + } + command = `git fetch origin tag ${tag} --no-tags`; + // Note that this condition is only ever NOT true in the 1.0.0-0 edge case + if (shallowExcludeTag && shallowExcludeTag !== tag) { + command += ` --shallow-exclude=${shallowExcludeTag}`; + } + console.log(`Running command: ${command}`); + (0, child_process_1.execSync)(command); + shouldRetry = false; + } + catch (e) { + console.error(e); + if (!needsRepack) { + console.log('Attempting to repack and retry...'); + needsRepack = true; + } + else { + console.error("Repack didn't help, giving up..."); + shouldRetry = false; + } + } + } +} +/** + * Get merge logs between two tags (inclusive) as a JavaScript object. + */ +function getCommitHistoryAsJSON(fromTag, toTag) { + // Fetch tags, exclude commits reachable from the previous patch version (i.e: previous checklist), so that we don't have to fetch the full history + const previousPatchVersion = VERSION_UPDATER.getPreviousVersion(fromTag, VERSION_UPDATER.SEMANTIC_VERSION_LEVELS.PATCH); + fetchTag(fromTag, previousPatchVersion); + fetchTag(toTag, previousPatchVersion); + console.log('Getting pull requests merged between the following tags:', fromTag, toTag); + return new Promise((resolve, reject) => { + let stdout = ''; + let stderr = ''; + const args = ['log', '--format={"commit": "%H", "authorName": "%an", "subject": "%s"},', `${fromTag}...${toTag}`]; + console.log(`Running command: git ${args.join(' ')}`); + const spawnedProcess = (0, child_process_1.spawn)('git', args); + spawnedProcess.on('message', console.log); + spawnedProcess.stdout.on('data', (chunk) => { + console.log(chunk.toString()); + stdout += chunk.toString(); + }); + spawnedProcess.stderr.on('data', (chunk) => { + console.error(chunk.toString()); + stderr += chunk.toString(); + }); + spawnedProcess.on('close', (code) => { + if (code !== 0) { + return reject(new Error(`${stderr}`)); + } + resolve(stdout); + }); + spawnedProcess.on('error', (err) => reject(err)); + }).then((stdout) => { + // Sanitize just the text within commit subjects as that's the only potentially un-parseable text. + const sanitizedOutput = stdout.replace(/(?<="subject": ").*?(?="})/g, (subject) => (0, sanitizeStringForJSONParse_1.default)(subject)); + // Then remove newlines, format as JSON and convert to a proper JS object + const json = `[${sanitizedOutput}]`.replace(/(\r\n|\n|\r)/gm, '').replace('},]', '}]'); + return JSON.parse(json); + }); +} +/** + * Parse merged PRs, excluding those from irrelevant branches. + */ +function getValidMergedPRs(commits) { + const mergedPRs = new Set(); + commits.forEach((commit) => { + const author = commit.authorName; + if (author === CONST.OS_BOTIFY) { + return; + } + const match = commit.subject.match(/Merge pull request #(\d+) from (?!Expensify\/.*-cherry-pick-staging)/); + if (!Array.isArray(match) || match.length < 2) { + return; + } + const pr = Number.parseInt(match[1], 10); + if (mergedPRs.has(pr)) { + // If a PR shows up in the log twice, that means that the PR was deployed in the previous checklist. + // That also means that we don't want to include it in the current checklist, so we remove it now. + mergedPRs.delete(pr); + return; + } + mergedPRs.add(pr); + }); + return Array.from(mergedPRs); +} +/** + * Takes in two git tags and returns a list of PR numbers of all PRs merged between those two tags + */ +async function getPullRequestsMergedBetween(fromTag, toTag) { + console.log(`Looking for commits made between ${fromTag} and ${toTag}...`); + const commitList = await getCommitHistoryAsJSON(fromTag, toTag); + console.log(`Commits made between ${fromTag} and ${toTag}:`, commitList); + // Find which commit messages correspond to merged PR's + const pullRequestNumbers = getValidMergedPRs(commitList).sort((a, b) => a - b); + console.log(`List of pull requests merged between ${fromTag} and ${toTag}`, pullRequestNumbers); + return pullRequestNumbers; +} +exports["default"] = { + getValidMergedPRs, + getPullRequestsMergedBetween, +}; + + /***/ }), /***/ 2877: @@ -16430,6 +16432,34 @@ module.exports = JSON.parse('[[[0,44],"disallowed_STD3_valid"],[[45,46],"valid"] /******/ } /******/ /************************************************************************/ +/******/ /* webpack/runtime/define property getters */ +/******/ (() => { +/******/ // define getter functions for harmony exports +/******/ __nccwpck_require__.d = (exports, definition) => { +/******/ for(var key in definition) { +/******/ if(__nccwpck_require__.o(definition, key) && !__nccwpck_require__.o(exports, key)) { +/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); +/******/ } +/******/ } +/******/ }; +/******/ })(); +/******/ +/******/ /* webpack/runtime/hasOwnProperty shorthand */ +/******/ (() => { +/******/ __nccwpck_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) +/******/ })(); +/******/ +/******/ /* webpack/runtime/make namespace object */ +/******/ (() => { +/******/ // define __esModule on exports +/******/ __nccwpck_require__.r = (exports) => { +/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { +/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); +/******/ } +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ })(); +/******/ /******/ /* webpack/runtime/compat */ /******/ /******/ if (typeof __nccwpck_require__ !== 'undefined') __nccwpck_require__.ab = __dirname + "/"; diff --git a/.github/actions/javascript/getPreviousVersion/index.js b/.github/actions/javascript/getPreviousVersion/index.js index 63498e68fcdf..545f4472ec72 100644 --- a/.github/actions/javascript/getPreviousVersion/index.js +++ b/.github/actions/javascript/getPreviousVersion/index.js @@ -5,8 +5,20 @@ /******/ var __webpack_modules__ = ({ /***/ 7: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { +/***/ ((__unused_webpack_module, __webpack_exports__, __nccwpck_require__) => { +"use strict"; +__nccwpck_require__.r(__webpack_exports__); +/* harmony export */ __nccwpck_require__.d(__webpack_exports__, { +/* harmony export */ "MAX_INCREMENTS": () => (/* binding */ MAX_INCREMENTS), +/* harmony export */ "SEMANTIC_VERSION_LEVELS": () => (/* binding */ SEMANTIC_VERSION_LEVELS), +/* harmony export */ "getPreviousVersion": () => (/* binding */ getPreviousVersion), +/* harmony export */ "getVersionNumberFromString": () => (/* binding */ getVersionNumberFromString), +/* harmony export */ "getVersionStringFromNumber": () => (/* binding */ getVersionStringFromNumber), +/* harmony export */ "incrementMinor": () => (/* binding */ incrementMinor), +/* harmony export */ "incrementPatch": () => (/* binding */ incrementPatch), +/* harmony export */ "incrementVersion": () => (/* binding */ incrementVersion) +/* harmony export */ }); const _ = __nccwpck_require__(67); const SEMANTIC_VERSION_LEVELS = { @@ -74,8 +86,8 @@ const incrementPatch = (major, minor, patch) => { /** * Increments a build version * - * @param {Number} version - * @param {Number} level + * @param {String} version + * @param {String} level * @returns {String} */ const incrementVersion = (version, level) => { @@ -136,18 +148,7 @@ function getPreviousVersion(currentVersion, level) { return getVersionStringFromNumber(major, minor, patch, build - 1); } -module.exports = { - getVersionNumberFromString, - getVersionStringFromNumber, - incrementVersion, - // For tests - MAX_INCREMENTS, - SEMANTIC_VERSION_LEVELS, - incrementMinor, - incrementPatch, - getPreviousVersion, -}; /***/ }), @@ -5143,6 +5144,34 @@ module.exports = underscoreNodeF._; /******/ } /******/ /************************************************************************/ +/******/ /* webpack/runtime/define property getters */ +/******/ (() => { +/******/ // define getter functions for harmony exports +/******/ __nccwpck_require__.d = (exports, definition) => { +/******/ for(var key in definition) { +/******/ if(__nccwpck_require__.o(definition, key) && !__nccwpck_require__.o(exports, key)) { +/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); +/******/ } +/******/ } +/******/ }; +/******/ })(); +/******/ +/******/ /* webpack/runtime/hasOwnProperty shorthand */ +/******/ (() => { +/******/ __nccwpck_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) +/******/ })(); +/******/ +/******/ /* webpack/runtime/make namespace object */ +/******/ (() => { +/******/ // define __esModule on exports +/******/ __nccwpck_require__.r = (exports) => { +/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { +/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); +/******/ } +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ })(); +/******/ /******/ /* webpack/runtime/compat */ /******/ /******/ if (typeof __nccwpck_require__ !== 'undefined') __nccwpck_require__.ab = __dirname + "/"; diff --git a/.github/actions/javascript/verifySignedCommits/index.js b/.github/actions/javascript/verifySignedCommits/index.js index 61b0e2063d30..f32bda6bae1e 100644 --- a/.github/actions/javascript/verifySignedCommits/index.js +++ b/.github/actions/javascript/verifySignedCommits/index.js @@ -1,6 +1,7 @@ /** * NOTE: This is a compiled file. DO NOT directly edit this file. */ +import { createRequire as __WEBPACK_EXTERNAL_createRequire } from "module"; /******/ (() => { // webpackBootstrap /******/ var __webpack_modules__ = ({ @@ -13649,7 +13650,7 @@ module.exports = eval("require")("encoding"); /***/ ((module) => { "use strict"; -module.exports = require("assert"); +module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("assert"); /***/ }), @@ -13657,7 +13658,7 @@ module.exports = require("assert"); /***/ ((module) => { "use strict"; -module.exports = require("crypto"); +module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("crypto"); /***/ }), @@ -13665,7 +13666,7 @@ module.exports = require("crypto"); /***/ ((module) => { "use strict"; -module.exports = require("events"); +module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("events"); /***/ }), @@ -13673,7 +13674,7 @@ module.exports = require("events"); /***/ ((module) => { "use strict"; -module.exports = require("fs"); +module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("fs"); /***/ }), @@ -13681,7 +13682,7 @@ module.exports = require("fs"); /***/ ((module) => { "use strict"; -module.exports = require("http"); +module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("http"); /***/ }), @@ -13689,7 +13690,7 @@ module.exports = require("http"); /***/ ((module) => { "use strict"; -module.exports = require("https"); +module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("https"); /***/ }), @@ -13697,7 +13698,7 @@ module.exports = require("https"); /***/ ((module) => { "use strict"; -module.exports = require("net"); +module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("net"); /***/ }), @@ -13705,7 +13706,7 @@ module.exports = require("net"); /***/ ((module) => { "use strict"; -module.exports = require("os"); +module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("os"); /***/ }), @@ -13713,7 +13714,7 @@ module.exports = require("os"); /***/ ((module) => { "use strict"; -module.exports = require("path"); +module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("path"); /***/ }), @@ -13721,7 +13722,7 @@ module.exports = require("path"); /***/ ((module) => { "use strict"; -module.exports = require("punycode"); +module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("punycode"); /***/ }), @@ -13729,7 +13730,7 @@ module.exports = require("punycode"); /***/ ((module) => { "use strict"; -module.exports = require("stream"); +module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("stream"); /***/ }), @@ -13737,7 +13738,7 @@ module.exports = require("stream"); /***/ ((module) => { "use strict"; -module.exports = require("tls"); +module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("tls"); /***/ }), @@ -13745,7 +13746,7 @@ module.exports = require("tls"); /***/ ((module) => { "use strict"; -module.exports = require("url"); +module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("url"); /***/ }), @@ -13753,7 +13754,7 @@ module.exports = require("url"); /***/ ((module) => { "use strict"; -module.exports = require("util"); +module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("util"); /***/ }), @@ -13761,7 +13762,7 @@ module.exports = require("util"); /***/ ((module) => { "use strict"; -module.exports = require("zlib"); +module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("zlib"); /***/ }), From 2a48805c5e26f5eb6e77185d52c51d9238e3465e Mon Sep 17 00:00:00 2001 From: Filip Solecki Date: Tue, 13 Feb 2024 14:20:48 +0100 Subject: [PATCH 04/13] GH actions fix --- .../javascript/authorChecklist/index.js | 33 +++++++++---------- .../javascript/verifySignedCommits/index.js | 31 +++++++++-------- 2 files changed, 31 insertions(+), 33 deletions(-) diff --git a/.github/actions/javascript/authorChecklist/index.js b/.github/actions/javascript/authorChecklist/index.js index 26277693e888..137020670c10 100644 --- a/.github/actions/javascript/authorChecklist/index.js +++ b/.github/actions/javascript/authorChecklist/index.js @@ -1,7 +1,6 @@ /** * NOTE: This is a compiled file. DO NOT directly edit this file. */ -import { createRequire as __WEBPACK_EXTERNAL_createRequire } from "module"; /******/ (() => { // webpackBootstrap /******/ var __webpack_modules__ = ({ @@ -18687,7 +18686,7 @@ module.exports = eval("require")("encoding"); /***/ ((module) => { "use strict"; -module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("assert"); +module.exports = require("assert"); /***/ }), @@ -18695,7 +18694,7 @@ module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("assert"); /***/ ((module) => { "use strict"; -module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("crypto"); +module.exports = require("crypto"); /***/ }), @@ -18703,7 +18702,7 @@ module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("crypto"); /***/ ((module) => { "use strict"; -module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("events"); +module.exports = require("events"); /***/ }), @@ -18711,7 +18710,7 @@ module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("events"); /***/ ((module) => { "use strict"; -module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("fs"); +module.exports = require("fs"); /***/ }), @@ -18719,7 +18718,7 @@ module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("fs"); /***/ ((module) => { "use strict"; -module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("http"); +module.exports = require("http"); /***/ }), @@ -18727,7 +18726,7 @@ module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("http"); /***/ ((module) => { "use strict"; -module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("https"); +module.exports = require("https"); /***/ }), @@ -18735,7 +18734,7 @@ module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("https"); /***/ ((module) => { "use strict"; -module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("net"); +module.exports = require("net"); /***/ }), @@ -18743,7 +18742,7 @@ module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("net"); /***/ ((module) => { "use strict"; -module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("os"); +module.exports = require("os"); /***/ }), @@ -18751,7 +18750,7 @@ module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("os"); /***/ ((module) => { "use strict"; -module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("path"); +module.exports = require("path"); /***/ }), @@ -18759,7 +18758,7 @@ module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("path"); /***/ ((module) => { "use strict"; -module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("punycode"); +module.exports = require("punycode"); /***/ }), @@ -18767,7 +18766,7 @@ module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("punycode"); /***/ ((module) => { "use strict"; -module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("stream"); +module.exports = require("stream"); /***/ }), @@ -18775,7 +18774,7 @@ module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("stream"); /***/ ((module) => { "use strict"; -module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("tls"); +module.exports = require("tls"); /***/ }), @@ -18783,7 +18782,7 @@ module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("tls"); /***/ ((module) => { "use strict"; -module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("tty"); +module.exports = require("tty"); /***/ }), @@ -18791,7 +18790,7 @@ module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("tty"); /***/ ((module) => { "use strict"; -module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("url"); +module.exports = require("url"); /***/ }), @@ -18799,7 +18798,7 @@ module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("url"); /***/ ((module) => { "use strict"; -module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("util"); +module.exports = require("util"); /***/ }), @@ -18807,7 +18806,7 @@ module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("util"); /***/ ((module) => { "use strict"; -module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("zlib"); +module.exports = require("zlib"); /***/ }), diff --git a/.github/actions/javascript/verifySignedCommits/index.js b/.github/actions/javascript/verifySignedCommits/index.js index f32bda6bae1e..61b0e2063d30 100644 --- a/.github/actions/javascript/verifySignedCommits/index.js +++ b/.github/actions/javascript/verifySignedCommits/index.js @@ -1,7 +1,6 @@ /** * NOTE: This is a compiled file. DO NOT directly edit this file. */ -import { createRequire as __WEBPACK_EXTERNAL_createRequire } from "module"; /******/ (() => { // webpackBootstrap /******/ var __webpack_modules__ = ({ @@ -13650,7 +13649,7 @@ module.exports = eval("require")("encoding"); /***/ ((module) => { "use strict"; -module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("assert"); +module.exports = require("assert"); /***/ }), @@ -13658,7 +13657,7 @@ module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("assert"); /***/ ((module) => { "use strict"; -module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("crypto"); +module.exports = require("crypto"); /***/ }), @@ -13666,7 +13665,7 @@ module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("crypto"); /***/ ((module) => { "use strict"; -module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("events"); +module.exports = require("events"); /***/ }), @@ -13674,7 +13673,7 @@ module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("events"); /***/ ((module) => { "use strict"; -module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("fs"); +module.exports = require("fs"); /***/ }), @@ -13682,7 +13681,7 @@ module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("fs"); /***/ ((module) => { "use strict"; -module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("http"); +module.exports = require("http"); /***/ }), @@ -13690,7 +13689,7 @@ module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("http"); /***/ ((module) => { "use strict"; -module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("https"); +module.exports = require("https"); /***/ }), @@ -13698,7 +13697,7 @@ module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("https"); /***/ ((module) => { "use strict"; -module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("net"); +module.exports = require("net"); /***/ }), @@ -13706,7 +13705,7 @@ module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("net"); /***/ ((module) => { "use strict"; -module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("os"); +module.exports = require("os"); /***/ }), @@ -13714,7 +13713,7 @@ module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("os"); /***/ ((module) => { "use strict"; -module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("path"); +module.exports = require("path"); /***/ }), @@ -13722,7 +13721,7 @@ module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("path"); /***/ ((module) => { "use strict"; -module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("punycode"); +module.exports = require("punycode"); /***/ }), @@ -13730,7 +13729,7 @@ module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("punycode"); /***/ ((module) => { "use strict"; -module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("stream"); +module.exports = require("stream"); /***/ }), @@ -13738,7 +13737,7 @@ module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("stream"); /***/ ((module) => { "use strict"; -module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("tls"); +module.exports = require("tls"); /***/ }), @@ -13746,7 +13745,7 @@ module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("tls"); /***/ ((module) => { "use strict"; -module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("url"); +module.exports = require("url"); /***/ }), @@ -13754,7 +13753,7 @@ module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("url"); /***/ ((module) => { "use strict"; -module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("util"); +module.exports = require("util"); /***/ }), @@ -13762,7 +13761,7 @@ module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("util"); /***/ ((module) => { "use strict"; -module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("zlib"); +module.exports = require("zlib"); /***/ }), From 43e97c2bf8fc52ce90292f88447bf2f15b0d6b58 Mon Sep 17 00:00:00 2001 From: Filip Solecki Date: Tue, 13 Feb 2024 14:30:17 +0100 Subject: [PATCH 05/13] Change method of ts-node install --- .github/workflows/test.yml | 3 +++ tests/unit/CIGitLogicTest.sh | 3 --- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6540a0fdd583..9e4891b4662e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -62,5 +62,8 @@ jobs: - name: Setup Node uses: ./.github/actions/composite/setupNode + - name: Install ts-node + uses: npm i ts-node + - name: Test CI git logic run: tests/unit/CIGitLogicTest.sh diff --git a/tests/unit/CIGitLogicTest.sh b/tests/unit/CIGitLogicTest.sh index 49a916d7b9dc..73fd01f5c0a0 100755 --- a/tests/unit/CIGitLogicTest.sh +++ b/tests/unit/CIGitLogicTest.sh @@ -76,7 +76,6 @@ function bump_version { info "Bumping version..." setup_git_as_osbotify git switch main - npm i ts-node npm --no-git-tag-version version "$(ts-node "$bumpVersion" "$(print_version)" "$1")" git add package.json package-lock.json git commit -m "Update version to $(print_version)" @@ -143,7 +142,6 @@ function cherry_pick_pr { checkout_repo setup_git_as_osbotify - npm i ts-node PREVIOUS_PATCH_VERSION="$(ts-node "$getPreviousVersion" "$(print_version)" "$SEMVER_LEVEL_PATCH")" git fetch origin main staging --no-tags --shallow-exclude="$PREVIOUS_PATCH_VERSION" @@ -203,7 +201,6 @@ function deploy_production { function assert_prs_merged_between { checkout_repo - npm i ts-node output=$(ts-node "$getPullRequestsMergedBetween" "$1" "$2") info "Checking output of getPullRequestsMergedBetween $1 $2" assert_equal "$output" "$3" From 7fd32965c786992a7e87651eee8455f9f04da9e6 Mon Sep 17 00:00:00 2001 From: Filip Solecki Date: Tue, 13 Feb 2024 14:50:33 +0100 Subject: [PATCH 06/13] Fix test.yml --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9e4891b4662e..4f0203ec5e09 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -63,7 +63,7 @@ jobs: uses: ./.github/actions/composite/setupNode - name: Install ts-node - uses: npm i ts-node + run: npm i ts-node - name: Test CI git logic run: tests/unit/CIGitLogicTest.sh From 381320cee46c0054b8450a4a5e2a7e1d41473b56 Mon Sep 17 00:00:00 2001 From: Filip Solecki Date: Tue, 13 Feb 2024 14:59:54 +0100 Subject: [PATCH 07/13] install ts-node globally --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4f0203ec5e09..bdc14950a337 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -63,7 +63,7 @@ jobs: uses: ./.github/actions/composite/setupNode - name: Install ts-node - run: npm i ts-node + run: npm i -g ts-node - name: Test CI git logic run: tests/unit/CIGitLogicTest.sh From 0ea67f499eff3ac16ecc2ff16cd78de6a61b9d2c Mon Sep 17 00:00:00 2001 From: Filip Solecki Date: Wed, 14 Feb 2024 15:55:33 +0100 Subject: [PATCH 08/13] Use es6 imports and exports --- tests/e2e/compare/compare.js | 16 ++++++------ tests/e2e/compare/math.js | 5 +--- tests/e2e/compare/output/console.js | 6 ++--- tests/e2e/compare/output/format.js | 10 +------ tests/e2e/compare/output/markdown.js | 25 +++++++++--------- tests/e2e/compare/output/markdownTable.js | 2 +- tests/e2e/config.dev.js | 2 +- tests/e2e/config.js | 2 +- tests/e2e/config.local.js | 2 +- tests/e2e/measure/math.js | 7 +++-- tests/e2e/measure/writeTestStats.js | 7 +++-- tests/e2e/merge.js | 10 +++---- .../nativeCommands/NativeCommandsAction.js | 6 +---- tests/e2e/nativeCommands/adbBackspace.js | 6 ++--- tests/e2e/nativeCommands/adbTypeText.js | 6 ++--- tests/e2e/nativeCommands/index.js | 13 ++++------ tests/e2e/server/index.js | 16 ++++++------ tests/e2e/server/routes.js | 2 +- tests/e2e/testRunner.js | 26 +++++++++---------- tests/e2e/utils/androidReversePort.js | 10 +++---- tests/e2e/utils/execAsync.js | 6 ++--- tests/e2e/utils/getCurrentBranchName.js | 4 +-- tests/e2e/utils/installApp.js | 8 +++--- tests/e2e/utils/killApp.js | 8 +++--- tests/e2e/utils/launchApp.js | 8 +++--- tests/e2e/utils/logger.js | 26 ++++++------------- tests/e2e/utils/sleep.js | 4 +-- tests/e2e/utils/withFailTimeout.js | 6 ++--- tests/unit/GithubUtilsTest.js | 4 +-- tests/unit/PaymentUtilsTest.js | 3 +-- tests/unit/TranslateTest.js | 18 ++++++------- tests/unit/UrlTest.js | 2 +- tests/unit/ValidationUtilsTest.js | 3 +-- tests/unit/awaitStagingDeploysTest.js | 8 +++--- tests/unit/checkDeployBlockersTest.js | 8 +++--- tests/unit/createOrUpdateStagingDeployTest.js | 16 ++++++------ tests/unit/isStagingDeployLockedTest.js | 6 ++--- tests/unit/markPullRequestsAsDeployedTest.js | 6 ++--- tests/unit/nativeVersionUpdaterTest.js | 9 ++++--- tests/unit/postTestBuildComment.js | 10 +++---- tests/unit/versionUpdaterTest.js | 2 +- 41 files changed, 155 insertions(+), 189 deletions(-) diff --git a/tests/e2e/compare/compare.js b/tests/e2e/compare/compare.js index 3be7abc91188..b7d5c15c5f82 100644 --- a/tests/e2e/compare/compare.js +++ b/tests/e2e/compare/compare.js @@ -1,8 +1,8 @@ -const _ = require('underscore'); -const {computeProbability, computeZ} = require('./math'); -const {getStats} = require('../measure/math'); -const printToConsole = require('./output/console'); -const writeToMarkdown = require('./output/markdown'); +import _ from 'underscore'; +import getStats from '../measure/math'; +import math from './math'; +import printToConsole from './output/console'; +import writeToMarkdown from './output/markdown'; /* * base implementation from: https://github.com/callstack/reassure/blob/main/packages/reassure-compare/src/compare.ts @@ -36,8 +36,8 @@ function buildCompareEntry(name, compare, baseline) { const diff = compare.mean - baseline.mean; const relativeDurationDiff = diff / baseline.mean; - const z = computeZ(baseline.mean, baseline.stdev, compare.mean, compare.runs); - const prob = computeProbability(z); + const z = math.computeZ(baseline.mean, baseline.stdev, compare.mean, compare.runs); + const prob = math.computeProbability(z); const isDurationDiffOfSignificance = prob < PROBABILITY_CONSIDERED_SIGNIFICANCE && Math.abs(diff) >= DURATION_DIFF_THRESHOLD_SIGNIFICANCE; @@ -106,7 +106,7 @@ function compareResults(compareEntries, baselineEntries) { }; } -module.exports = (main, delta, outputFile, outputFormat = 'all') => { +export default (main, delta, outputFile, outputFormat = 'all') => { const outputData = compareResults(main, delta); if (outputFormat === 'console' || outputFormat === 'all') { diff --git a/tests/e2e/compare/math.js b/tests/e2e/compare/math.js index a7dbe1c95a86..a87c58c4dff3 100644 --- a/tests/e2e/compare/math.js +++ b/tests/e2e/compare/math.js @@ -89,7 +89,4 @@ const computeProbability = (z) => { return 0.2; }; -module.exports = { - computeZ, - computeProbability, -}; +export {computeZ, computeProbability}; diff --git a/tests/e2e/compare/output/console.js b/tests/e2e/compare/output/console.js index cfcd7019bbdd..61645baf38b8 100644 --- a/tests/e2e/compare/output/console.js +++ b/tests/e2e/compare/output/console.js @@ -1,14 +1,14 @@ -const {formatDurationDiffChange} = require('./format'); +import format from './format'; const printRegularLine = (entry) => { - console.debug(` - ${entry.name}: ${formatDurationDiffChange(entry)}`); + console.debug(` - ${entry.name}: ${format.formatDurationDiffChange(entry)}`); }; /** * Prints the result simply to console. * @param {Object} data */ -module.exports = (data) => { +export default (data) => { // No need to log errors or warnings as these were be logged on the fly console.debug(''); console.debug('❇️ Performance comparison results:'); diff --git a/tests/e2e/compare/output/format.js b/tests/e2e/compare/output/format.js index c31ac547b41d..18b49cf03028 100644 --- a/tests/e2e/compare/output/format.js +++ b/tests/e2e/compare/output/format.js @@ -82,12 +82,4 @@ const formatDurationDiffChange = (entry) => { return output; }; -module.exports = { - formatPercent, - formatPercentChange, - formatDuration, - formatDurationChange, - formatChange, - getDurationSymbols, - formatDurationDiffChange, -}; +export {formatPercent, formatPercentChange, formatDuration, formatDurationChange, formatChange, getDurationSymbols, formatDurationDiffChange}; diff --git a/tests/e2e/compare/output/markdown.js b/tests/e2e/compare/output/markdown.js index 2015d8de6cc3..1f9626678498 100644 --- a/tests/e2e/compare/output/markdown.js +++ b/tests/e2e/compare/output/markdown.js @@ -1,11 +1,10 @@ // From: https://raw.githubusercontent.com/callstack/reassure/main/packages/reassure-compare/src/output/markdown.ts - -const fs = require('node:fs/promises'); -const path = require('path'); -const _ = require('underscore'); -const markdownTable = require('./markdownTable'); -const {formatDuration, formatPercent, formatDurationDiffChange} = require('./format'); -const Logger = require('../../utils/logger'); +import fs from 'node:fs/promises'; +import path from 'path'; +import _ from 'underscore'; +import Logger from '../../utils/logger'; +import format from './format'; +import markdownTable from './markdownTable'; const tableHeader = ['Name', 'Duration']; @@ -17,8 +16,8 @@ const buildDurationDetails = (title, entry) => { return _.filter( [ `**${title}**`, - `Mean: ${formatDuration(entry.mean)}`, - `Stdev: ${formatDuration(entry.stdev)} (${formatPercent(relativeStdev)})`, + `Mean: ${format.formatDuration(entry.mean)}`, + `Stdev: ${format.formatDuration(entry.stdev)} (${format.formatPercent(relativeStdev)})`, entry.entries ? `Runs: ${entry.entries.join(' ')}` : '', ], Boolean, @@ -32,13 +31,13 @@ const buildDurationDetailsEntry = (entry) => const formatEntryDuration = (entry) => { if ('baseline' in entry && 'current' in entry) { - return formatDurationDiffChange(entry); + return format.formatDurationDiffChange(entry); } if ('baseline' in entry) { - return formatDuration(entry.baseline.mean); + return format.formatDuration(entry.baseline.mean); } if ('current' in entry) { - return formatDuration(entry.current.mean); + return format.formatDuration(entry.current.mean); } return ''; }; @@ -115,4 +114,4 @@ const writeToMarkdown = (filePath, data) => { }); }; -module.exports = writeToMarkdown; +export default writeToMarkdown; diff --git a/tests/e2e/compare/output/markdownTable.js b/tests/e2e/compare/output/markdownTable.js index 3b580bcfc116..198ae17daba5 100644 --- a/tests/e2e/compare/output/markdownTable.js +++ b/tests/e2e/compare/output/markdownTable.js @@ -365,4 +365,4 @@ function toAlignment(value) { : 0; } -module.exports = markdownTable; +export default markdownTable; diff --git a/tests/e2e/config.dev.js b/tests/e2e/config.dev.js index 894b4737c36f..8d12fb5ce007 100644 --- a/tests/e2e/config.dev.js +++ b/tests/e2e/config.dev.js @@ -1,7 +1,7 @@ const packageName = 'com.expensify.chat.dev'; const appPath = './android/app/build/outputs/apk/development/debug/app-development-debug.apk'; -module.exports = { +export default { MAIN_APP_PACKAGE: packageName, DELTA_APP_PACKAGE: packageName, MAIN_APP_PATH: appPath, diff --git a/tests/e2e/config.js b/tests/e2e/config.js index a7447a29c954..d51119e77430 100644 --- a/tests/e2e/config.js +++ b/tests/e2e/config.js @@ -17,7 +17,7 @@ const TEST_NAMES = { * npm run test:e2e -- --config ./path/to/your/config.js * ``` */ -module.exports = { +export default { MAIN_APP_PACKAGE: 'com.expensify.chat.e2e', DELTA_APP_PACKAGE: 'com.expensify.chat.e2edelta', diff --git a/tests/e2e/config.local.js b/tests/e2e/config.local.js index 45b946b91aeb..605b1ddd57d7 100644 --- a/tests/e2e/config.local.js +++ b/tests/e2e/config.local.js @@ -1,4 +1,4 @@ -module.exports = { +export default { MAIN_APP_PACKAGE: 'com.expensify.chat.e2e', DELTA_APP_PACKAGE: 'com.expensify.chat.e2edelta', MAIN_APP_PATH: './android/app/build/outputs/apk/e2e/release/app-e2e-release.apk', diff --git a/tests/e2e/measure/math.js b/tests/e2e/measure/math.js index 712e197d367b..14f75a7f980e 100644 --- a/tests/e2e/measure/math.js +++ b/tests/e2e/measure/math.js @@ -1,4 +1,4 @@ -const _ = require('underscore'); +import _ from 'underscore'; const filterOutliersViaIQR = (data) => { let q1; @@ -46,6 +46,5 @@ const getStats = (entries) => { }; }; -module.exports = { - getStats, -}; +// eslint-disable-next-line import/prefer-default-export +export default getStats; diff --git a/tests/e2e/measure/writeTestStats.js b/tests/e2e/measure/writeTestStats.js index c4074dbdd08f..6de9dcc79db4 100644 --- a/tests/e2e/measure/writeTestStats.js +++ b/tests/e2e/measure/writeTestStats.js @@ -1,6 +1,5 @@ -const fs = require('fs'); - -const {OUTPUT_FILE_CURRENT} = require('../config'); +import fs from 'fs'; +import config from '../config'; /** * Writes the results of `getStats` to the {@link OUTPUT_FILE_CURRENT} file. @@ -13,7 +12,7 @@ const {OUTPUT_FILE_CURRENT} = require('../config'); * @param {number} stats.runs - The number of times the test was run. * @param {string} [path] - The path to write to. Defaults to {@link OUTPUT_FILE_CURRENT}. */ -module.exports = (stats, path = OUTPUT_FILE_CURRENT) => { +export default (stats, path = config.OUTPUT_FILE_CURRENT) => { if (!stats.name || stats.mean == null || stats.stdev == null || !stats.entries || !stats.runs) { throw new Error(`Invalid stats object:\n${JSON.stringify(stats, null, 2)}\n\n`); } diff --git a/tests/e2e/merge.js b/tests/e2e/merge.js index 0ee476137315..d7c1b8699c7d 100644 --- a/tests/e2e/merge.js +++ b/tests/e2e/merge.js @@ -1,19 +1,19 @@ -const compare = require('./compare/compare'); -const {OUTPUT_DIR} = require('./config'); +import compare from './compare/compare'; +import CONFIG from './config'; const args = process.argv.slice(2); -let mainPath = `${OUTPUT_DIR}/main.json`; +let mainPath = `${CONFIG.OUTPUT_DIR}/main.json`; if (args.includes('--mainPath')) { mainPath = args[args.indexOf('--mainPath') + 1]; } -let deltaPath = `${OUTPUT_DIR}/delta.json`; +let deltaPath = `${CONFIG.OUTPUT_DIR}/delta.json`; if (args.includes('--deltaPath')) { deltaPath = args[args.indexOf('--deltaPath') + 1]; } -let outputPath = `${OUTPUT_DIR}/output.md`; +let outputPath = `${CONFIG.OUTPUT_DIR}/output.md`; if (args.includes('--outputPath')) { outputPath = args[args.indexOf('--outputPath') + 1]; } diff --git a/tests/e2e/nativeCommands/NativeCommandsAction.js b/tests/e2e/nativeCommands/NativeCommandsAction.js index f2aa4644f7ff..24ceefb5acb7 100644 --- a/tests/e2e/nativeCommands/NativeCommandsAction.js +++ b/tests/e2e/nativeCommands/NativeCommandsAction.js @@ -15,8 +15,4 @@ const makeBackspaceCommand = () => ({ actionName: NativeCommandsAction.backspace, }); -module.exports = { - NativeCommandsAction, - makeTypeTextCommand, - makeBackspaceCommand, -}; +export {NativeCommandsAction, makeTypeTextCommand, makeBackspaceCommand}; diff --git a/tests/e2e/nativeCommands/adbBackspace.js b/tests/e2e/nativeCommands/adbBackspace.js index 8f41364daed3..c0dcf65c240c 100644 --- a/tests/e2e/nativeCommands/adbBackspace.js +++ b/tests/e2e/nativeCommands/adbBackspace.js @@ -1,5 +1,5 @@ -const execAsync = require('../utils/execAsync'); -const Logger = require('../utils/logger'); +import execAsync from '../utils/execAsync'; +import Logger from '../utils/logger'; const adbBackspace = async () => { Logger.log(`🔙 Pressing backspace`); @@ -7,4 +7,4 @@ const adbBackspace = async () => { return true; }; -module.exports = adbBackspace; +export default adbBackspace; diff --git a/tests/e2e/nativeCommands/adbTypeText.js b/tests/e2e/nativeCommands/adbTypeText.js index cbaa9f4434a2..7a4c3b31b7fd 100644 --- a/tests/e2e/nativeCommands/adbTypeText.js +++ b/tests/e2e/nativeCommands/adbTypeText.js @@ -1,5 +1,5 @@ -const execAsync = require('../utils/execAsync'); -const Logger = require('../utils/logger'); +import execAsync from '../utils/execAsync'; +import Logger from '../utils/logger'; const adbTypeText = async (text) => { Logger.log(`📝 Typing text: ${text}`); @@ -7,4 +7,4 @@ const adbTypeText = async (text) => { return true; }; -module.exports = adbTypeText; +export default adbTypeText; diff --git a/tests/e2e/nativeCommands/index.js b/tests/e2e/nativeCommands/index.js index bb87c16a6f42..90dcb00bbcae 100644 --- a/tests/e2e/nativeCommands/index.js +++ b/tests/e2e/nativeCommands/index.js @@ -1,6 +1,7 @@ -const adbBackspace = require('./adbBackspace'); -const adbTypeText = require('./adbTypeText'); -const {NativeCommandsAction} = require('./NativeCommandsAction'); +import adbBackspace from './adbBackspace'; +import adbTypeText from './adbTypeText'; +// eslint-disable-next-line rulesdir/prefer-import-module-contents +import {NativeCommandsAction} from './NativeCommandsAction'; const executeFromPayload = (actionName, payload) => { switch (actionName) { @@ -15,8 +16,4 @@ const executeFromPayload = (actionName, payload) => { } }; -module.exports = { - NativeCommandsAction, - executeFromPayload, - adbTypeText, -}; +export {NativeCommandsAction, executeFromPayload, adbTypeText}; diff --git a/tests/e2e/server/index.js b/tests/e2e/server/index.js index c2365f259bb7..b90e96696525 100644 --- a/tests/e2e/server/index.js +++ b/tests/e2e/server/index.js @@ -1,10 +1,10 @@ -const {createServer} = require('http'); -const Routes = require('./routes'); -const Logger = require('../utils/logger'); -const {SERVER_PORT} = require('../config'); -const {executeFromPayload} = require('../nativeCommands'); +import {createServer} from 'http'; +import config from '../config'; +import * as nativeCommands from '../nativeCommands'; +import Logger from '../utils/logger'; +import Routes from './routes'; -const PORT = process.env.PORT || SERVER_PORT; +const PORT = process.env.PORT || config.SERVER_PORT; // Gets the request data as a string const getReqData = (req) => { @@ -130,7 +130,7 @@ const createServerInstance = () => { case Routes.testNativeCommand: { getPostJSONRequestData(req, res) .then((data) => - executeFromPayload(data.actionName, data.payload).then((status) => { + nativeCommands.executeFromPayload(data.actionName, data.payload).then((status) => { if (status) { res.end('ok'); return; @@ -196,4 +196,4 @@ const createServerInstance = () => { }; }; -module.exports = createServerInstance; +export default createServerInstance; diff --git a/tests/e2e/server/routes.js b/tests/e2e/server/routes.js index 0d23866ec808..ffab3b01d297 100644 --- a/tests/e2e/server/routes.js +++ b/tests/e2e/server/routes.js @@ -1,4 +1,4 @@ -module.exports = { +export default { // The app calls this endpoint to know which test to run testConfig: '/test_config', diff --git a/tests/e2e/testRunner.js b/tests/e2e/testRunner.js index 63c88d207581..f6e874c4f421 100644 --- a/tests/e2e/testRunner.js +++ b/tests/e2e/testRunner.js @@ -14,19 +14,19 @@ */ /* eslint-disable @lwc/lwc/no-async-await,no-restricted-syntax,no-await-in-loop */ -const fs = require('fs'); -const _ = require('underscore'); -const defaultConfig = require('./config'); -const Logger = require('./utils/logger'); -const execAsync = require('./utils/execAsync'); -const killApp = require('./utils/killApp'); -const launchApp = require('./utils/launchApp'); -const createServerInstance = require('./server'); -const installApp = require('./utils/installApp'); -const withFailTimeout = require('./utils/withFailTimeout'); -const reversePort = require('./utils/androidReversePort'); -const sleep = require('./utils/sleep'); -const compare = require('./compare/compare'); +import fs from 'fs'; +import _ from 'underscore'; +import compare from './compare/compare'; +import defaultConfig from './config'; +import createServerInstance from './server'; +import reversePort from './utils/androidReversePort'; +import execAsync from './utils/execAsync'; +import installApp from './utils/installApp'; +import killApp from './utils/killApp'; +import launchApp from './utils/launchApp'; +import Logger from './utils/logger'; +import sleep from './utils/sleep'; +import withFailTimeout from './utils/withFailTimeout'; // VARIABLE CONFIGURATION const args = process.argv.slice(2); diff --git a/tests/e2e/utils/androidReversePort.js b/tests/e2e/utils/androidReversePort.js index b644ca1538dd..55851daf59bf 100644 --- a/tests/e2e/utils/androidReversePort.js +++ b/tests/e2e/utils/androidReversePort.js @@ -1,6 +1,6 @@ -const {SERVER_PORT} = require('../config'); -const execAsync = require('./execAsync'); +import config from '../config'; +import execAsync from './execAsync'; -module.exports = function () { - return execAsync(`adb reverse tcp:${SERVER_PORT} tcp:${SERVER_PORT}`); -}; +export default function () { + return execAsync(`adb reverse tcp:${config.SERVER_PORT} tcp:${config.SERVER_PORT}`); +} diff --git a/tests/e2e/utils/execAsync.js b/tests/e2e/utils/execAsync.js index be80452c8acb..fad44082e40c 100644 --- a/tests/e2e/utils/execAsync.js +++ b/tests/e2e/utils/execAsync.js @@ -1,5 +1,5 @@ -const {exec} = require('child_process'); -const Logger = require('./logger'); +import {exec} from 'child_process'; +import Logger from './logger'; /** * Executes a command none-blocking by wrapping it in a promise. @@ -8,7 +8,7 @@ const Logger = require('./logger'); * @param {object} env environment variables * @returns {Promise} */ -module.exports = (command, env = {}) => { +export default (command, env = {}) => { let childProcess; const promise = new Promise((resolve, reject) => { const finalEnv = { diff --git a/tests/e2e/utils/getCurrentBranchName.js b/tests/e2e/utils/getCurrentBranchName.js index ca2f0cba97b0..55df11010214 100644 --- a/tests/e2e/utils/getCurrentBranchName.js +++ b/tests/e2e/utils/getCurrentBranchName.js @@ -1,4 +1,4 @@ -const {execSync} = require('child_process'); +import {execSync} from 'child_process'; const getCurrentBranchName = () => { const stdout = execSync('git rev-parse --abbrev-ref HEAD', { @@ -7,4 +7,4 @@ const getCurrentBranchName = () => { return stdout.trim(); }; -module.exports = getCurrentBranchName; +export default getCurrentBranchName; diff --git a/tests/e2e/utils/installApp.js b/tests/e2e/utils/installApp.js index 3741e459ea83..331ae5e99dee 100644 --- a/tests/e2e/utils/installApp.js +++ b/tests/e2e/utils/installApp.js @@ -1,5 +1,5 @@ -const execAsync = require('./execAsync'); -const Logger = require('./logger'); +import execAsync from './execAsync'; +import Logger from './logger'; /** * Installs the app on the currently connected device for the given platform. @@ -10,7 +10,7 @@ const Logger = require('./logger'); * @param {String} path * @returns {Promise} */ -module.exports = function (platform = 'android', packageName, path) { +export default function (platform = 'android', packageName, path) { if (platform !== 'android') { throw new Error(`installApp() missing implementation for platform: ${platform}`); } @@ -22,4 +22,4 @@ module.exports = function (platform = 'android', packageName, path) { Logger.warn('Failed to uninstall app:', e); }) .finally(() => execAsync(`adb install ${path}`)); -}; +} diff --git a/tests/e2e/utils/killApp.js b/tests/e2e/utils/killApp.js index bdef215bf752..32cc75d3ef8a 100644 --- a/tests/e2e/utils/killApp.js +++ b/tests/e2e/utils/killApp.js @@ -1,11 +1,11 @@ -const {APP_PACKAGE} = require('../config'); -const execAsync = require('./execAsync'); +import config from '../config'; +import execAsync from './execAsync'; -module.exports = function (platform = 'android', packageName = APP_PACKAGE) { +export default function (platform = 'android', packageName = config.APP_PACKAGE) { if (platform !== 'android') { throw new Error(`killApp() missing implementation for platform: ${platform}`); } // Use adb to kill the app return execAsync(`adb shell am force-stop ${packageName}`); -}; +} diff --git a/tests/e2e/utils/launchApp.js b/tests/e2e/utils/launchApp.js index f63e2e71cd8b..d5177794bbda 100644 --- a/tests/e2e/utils/launchApp.js +++ b/tests/e2e/utils/launchApp.js @@ -1,8 +1,8 @@ /* eslint-disable rulesdir/prefer-underscore-method */ -const {APP_PACKAGE, ACTIVITY_PATH} = require('../config'); -const execAsync = require('./execAsync'); +import config from '../config'; +import execAsync from './execAsync'; -module.exports = function (platform = 'android', packageName = APP_PACKAGE, activityPath = ACTIVITY_PATH, launchArgs = {}) { +export default function (platform = 'android', packageName = config.APP_PACKAGE, activityPath = config.ACTIVITY_PATH, launchArgs = {}) { if (platform !== 'android') { throw new Error(`launchApp() missing implementation for platform: ${platform}`); } @@ -12,4 +12,4 @@ module.exports = function (platform = 'android', packageName = APP_PACKAGE, acti .map((key) => `${typeof launchArgs[key] === 'boolean' ? '--ez' : '--es'} ${key} ${launchArgs[key]}`) .join(' '); return execAsync(`adb shell am start -n ${packageName}/${activityPath} ${launchArgsString}`); -}; +} diff --git a/tests/e2e/utils/logger.js b/tests/e2e/utils/logger.js index 7da1e8330bfc..aa8be5b84b26 100644 --- a/tests/e2e/utils/logger.js +++ b/tests/e2e/utils/logger.js @@ -1,6 +1,6 @@ -const fs = require('fs'); -const path = require('path'); -const {LOG_FILE} = require('../config'); +import fs from 'fs'; +import path from 'path'; +import CONST from '../config'; let isVerbose = true; const setLogLevelVerbose = (value) => { @@ -23,18 +23,18 @@ const log = (...args) => { } // Write to log file - if (!fs.existsSync(LOG_FILE)) { + if (!fs.existsSync(CONST.LOG_FILE)) { // Check that the directory exists - const logDir = path.dirname(LOG_FILE); + const logDir = path.dirname(CONST.LOG_FILE); if (!fs.existsSync(logDir)) { fs.mkdirSync(logDir); } - fs.writeFileSync(LOG_FILE, ''); + fs.writeFileSync(CONST.LOG_FILE, ''); } const time = new Date(); const timeStr = `${time.getHours()}:${time.getMinutes()}:${time.getSeconds()} ${time.getMilliseconds()}`; - fs.appendFileSync(LOG_FILE, `[${timeStr}] ${args.join(' ')}\n`); + fs.appendFileSync(CONST.LOG_FILE, `[${timeStr}] ${args.join(' ')}\n`); }; const info = (...args) => { @@ -99,14 +99,4 @@ const progressInfo = (textParam) => { }; }; -module.exports = { - log, - info, - warn, - note, - error, - success, - important, - progressInfo, - setLogLevelVerbose, -}; +export {log, info, warn, note, error, success, important, progressInfo, setLogLevelVerbose}; diff --git a/tests/e2e/utils/sleep.js b/tests/e2e/utils/sleep.js index 6cc4f3bb89d1..6d37ca3cd510 100644 --- a/tests/e2e/utils/sleep.js +++ b/tests/e2e/utils/sleep.js @@ -1,5 +1,5 @@ -module.exports = function sleep(ms) { +export default function sleep(ms) { return new Promise((resolve) => { setTimeout(resolve, ms); }); -}; +} diff --git a/tests/e2e/utils/withFailTimeout.js b/tests/e2e/utils/withFailTimeout.js index 64c92966cdbc..3a314cd23562 100644 --- a/tests/e2e/utils/withFailTimeout.js +++ b/tests/e2e/utils/withFailTimeout.js @@ -1,6 +1,6 @@ -const {INTERACTION_TIMEOUT} = require('../config'); +import CONFIG from '../config'; -const TIMEOUT = process.env.INTERACTION_TIMEOUT || INTERACTION_TIMEOUT; +const TIMEOUT = process.env.INTERACTION_TIMEOUT || CONFIG.INTERACTION_TIMEOUT; const withFailTimeout = (promise, name) => new Promise((resolve, reject) => { @@ -20,4 +20,4 @@ const withFailTimeout = (promise, name) => }); }); -module.exports = withFailTimeout; +export default withFailTimeout; diff --git a/tests/unit/GithubUtilsTest.js b/tests/unit/GithubUtilsTest.js index b2b84dfd9d9f..ba4510794686 100644 --- a/tests/unit/GithubUtilsTest.js +++ b/tests/unit/GithubUtilsTest.js @@ -1,8 +1,8 @@ /** * @jest-environment node */ -const core = require('@actions/core'); -const GithubUtils = require('../../.github/libs/GithubUtils'); +import * as core from '@actions/core'; +import GithubUtils from '../../.github/libs/GithubUtils'; const mockGetInput = jest.fn(); const mockListIssues = jest.fn(); diff --git a/tests/unit/PaymentUtilsTest.js b/tests/unit/PaymentUtilsTest.js index d4524027353a..209e062b764e 100644 --- a/tests/unit/PaymentUtilsTest.js +++ b/tests/unit/PaymentUtilsTest.js @@ -1,6 +1,5 @@ import CONST from '../../src/CONST'; - -const paymentUtils = require('../../src/libs/PaymentUtils'); +import * as paymentUtils from '../../src/libs/PaymentUtils'; describe('PaymentUtils', () => { it('Test rounding wallet transfer instant fee', () => { diff --git a/tests/unit/TranslateTest.js b/tests/unit/TranslateTest.js index 45d4a12b61f5..d23fa52fc798 100644 --- a/tests/unit/TranslateTest.js +++ b/tests/unit/TranslateTest.js @@ -1,9 +1,9 @@ -const _ = require('underscore'); -const {error: AnnotationError} = require('@actions/core'); -const Localize = require('../../src/libs/Localize'); -const CONFIG = require('../../src/CONFIG'); -const translations = require('../../src/languages/translations'); -const CONST = require('../../src/CONST').default; +import {AnnotationError} from '@actions/core'; +import _ from 'underscore'; +import CONFIG from '../../src/CONFIG'; +import CONST from '../../src/CONST'; +import * as translations from '../../src/languages/translations'; +import * as Localize from '../../src/libs/Localize'; const originalTranslations = _.clone(translations); translations.default = { @@ -41,10 +41,10 @@ describe('translate', () => { }); test('Test when key is not found in default (Production Mode)', () => { - const ORIGINAL_IS_IN_PRODUCTION = CONFIG.default.IS_IN_PRODUCTION; - CONFIG.default.IS_IN_PRODUCTION = true; + const ORIGINAL_IS_IN_PRODUCTION = CONFIG.IS_IN_PRODUCTION; + CONFIG.IS_IN_PRODUCTION = true; expect(Localize.translate(CONST.LOCALES.ES_ES, 'testKey4')).toBe('testKey4'); - CONFIG.default.IS_IN_PRODUCTION = ORIGINAL_IS_IN_PRODUCTION; + CONFIG.IS_IN_PRODUCTION = ORIGINAL_IS_IN_PRODUCTION; }); it('Test when translation value is a function', () => { diff --git a/tests/unit/UrlTest.js b/tests/unit/UrlTest.js index 90ffb9b12d5b..74776ecf791d 100644 --- a/tests/unit/UrlTest.js +++ b/tests/unit/UrlTest.js @@ -1,4 +1,4 @@ -const Url = require('../../src/libs/Url'); +import * as Url from '../../src/libs/Url'; describe('Url', () => { describe('getPathFromURL()', () => { diff --git a/tests/unit/ValidationUtilsTest.js b/tests/unit/ValidationUtilsTest.js index 45de052f714d..43e389600d62 100644 --- a/tests/unit/ValidationUtilsTest.js +++ b/tests/unit/ValidationUtilsTest.js @@ -1,7 +1,6 @@ import {addDays, format, startOfDay, subYears} from 'date-fns'; import CONST from '../../src/CONST'; - -const ValidationUtils = require('../../src/libs/ValidationUtils'); +import * as ValidationUtils from '../../src/libs/ValidationUtils'; describe('ValidationUtils', () => { describe('isValidDate', () => { diff --git a/tests/unit/awaitStagingDeploysTest.js b/tests/unit/awaitStagingDeploysTest.js index 88a78d9260a7..8b8327e99047 100644 --- a/tests/unit/awaitStagingDeploysTest.js +++ b/tests/unit/awaitStagingDeploysTest.js @@ -1,10 +1,10 @@ /** * @jest-environment node */ -const core = require('@actions/core'); -const _ = require('underscore'); -const run = require('../../.github/actions/javascript/awaitStagingDeploys/awaitStagingDeploys'); -const GithubUtils = require('../../.github/libs/GithubUtils'); +import * as core from '@actions/core'; +import _ from 'underscore'; +import run from '../../.github/actions/javascript/awaitStagingDeploys/awaitStagingDeploys'; +import GithubUtils from '../../.github/libs/GithubUtils'; // Lower poll rate to speed up tests const TEST_POLL_RATE = 1; diff --git a/tests/unit/checkDeployBlockersTest.js b/tests/unit/checkDeployBlockersTest.js index dca8d5752767..354ab132f601 100644 --- a/tests/unit/checkDeployBlockersTest.js +++ b/tests/unit/checkDeployBlockersTest.js @@ -1,10 +1,10 @@ /** * @jest-environment node */ -const _ = require('underscore'); -const core = require('@actions/core'); -const GithubUtils = require('../../.github/libs/GithubUtils'); -const run = require('../../.github/actions/javascript/checkDeployBlockers/checkDeployBlockers'); +import * as core from '@actions/core'; +import _ from 'underscore'; +import run from '../../.github/actions/javascript/checkDeployBlockers/checkDeployBlockers'; +import GithubUtils from '../../.github/libs/GithubUtils'; // Static mock function for core.getInput const mockGetInput = jest.fn().mockImplementation((arg) => { diff --git a/tests/unit/createOrUpdateStagingDeployTest.js b/tests/unit/createOrUpdateStagingDeployTest.js index 15a795842667..75600f0d4fc8 100644 --- a/tests/unit/createOrUpdateStagingDeployTest.js +++ b/tests/unit/createOrUpdateStagingDeployTest.js @@ -1,14 +1,14 @@ /** * @jest-environment node */ -const core = require('@actions/core'); -const fns = require('date-fns'); -const {vol} = require('memfs'); -const path = require('path'); -const CONST = require('../../.github/libs/CONST'); -const GitUtils = require('../../.github/libs/GitUtils').default; -const GithubUtils = require('../../.github/libs/GithubUtils'); -const run = require('../../.github/actions/javascript/createOrUpdateStagingDeploy/createOrUpdateStagingDeploy'); +import * as core from '@actions/core'; +import * as fns from 'date-fns'; +import {vol} from 'memfs'; +import path from 'path'; +import run from '../../.github/actions/javascript/createOrUpdateStagingDeploy/createOrUpdateStagingDeploy'; +import CONST from '../../.github/libs/CONST'; +import GithubUtils from '../../.github/libs/GithubUtils'; +import GitUtils from '../../.github/libs/GitUtils'; const PATH_TO_PACKAGE_JSON = path.resolve(__dirname, '../../package.json'); diff --git a/tests/unit/isStagingDeployLockedTest.js b/tests/unit/isStagingDeployLockedTest.js index 5a4e81414393..bddd3d851c00 100644 --- a/tests/unit/isStagingDeployLockedTest.js +++ b/tests/unit/isStagingDeployLockedTest.js @@ -1,6 +1,6 @@ -const core = require('@actions/core'); -const run = require('../../.github/actions/javascript/isStagingDeployLocked/isStagingDeployLocked'); -const GithubUtils = require('../../.github/libs/GithubUtils'); +import * as core from '@actions/core'; +import run from '../../.github/actions/javascript/isStagingDeployLocked/isStagingDeployLocked'; +import GithubUtils from '../../.github/libs/GithubUtils'; // Mock the entire GithubUtils module jest.mock('../../.github/libs/GithubUtils'); diff --git a/tests/unit/markPullRequestsAsDeployedTest.js b/tests/unit/markPullRequestsAsDeployedTest.js index 81da0a5c9371..a401a9f96a67 100644 --- a/tests/unit/markPullRequestsAsDeployedTest.js +++ b/tests/unit/markPullRequestsAsDeployedTest.js @@ -1,9 +1,9 @@ /** * @jest-environment node */ -const _ = require('underscore'); -const GitUtils = require('../../.github/libs/GitUtils').default; -const GithubUtils = require('../../.github/libs/GithubUtils'); +import _ from 'underscore'; +import GithubUtils from '../../.github/libs/GithubUtils'; +import GitUtils from '../../.github/libs/GitUtils'; let run; diff --git a/tests/unit/nativeVersionUpdaterTest.js b/tests/unit/nativeVersionUpdaterTest.js index 6e30073fbbdc..198583a3f4e1 100644 --- a/tests/unit/nativeVersionUpdaterTest.js +++ b/tests/unit/nativeVersionUpdaterTest.js @@ -1,7 +1,8 @@ -const fs = require('fs'); -const path = require('path'); -const {vol} = require('memfs'); -const {updateAndroidVersion, generateAndroidVersionCode} = require('../../.github/libs/nativeVersionUpdater'); +import fs from 'fs'; +import {vol} from 'memfs'; +import path from 'path'; +// eslint-disable-next-line rulesdir/prefer-import-module-contents +import {generateAndroidVersionCode, updateAndroidVersion} from '../../.github/libs/nativeVersionUpdater'; const BUILD_GRADLE_PATH = path.resolve(__dirname, '../../android/app/build.gradle'); diff --git a/tests/unit/postTestBuildComment.js b/tests/unit/postTestBuildComment.js index 50389808b77d..ff77ca190c08 100644 --- a/tests/unit/postTestBuildComment.js +++ b/tests/unit/postTestBuildComment.js @@ -1,7 +1,7 @@ -const {when} = require('jest-when'); - -const core = require('@actions/core'); -const GithubUtils = require('../../.github/libs/GithubUtils'); +import * as core from '@actions/core'; +import {when} from 'jest-when'; +import ghAction from '../../.github/actions/javascript/postTestBuildComment/postTestBuildComment'; +import GithubUtils from '../../.github/libs/GithubUtils'; const mockGetInput = jest.fn(); const mockCreateComment = jest.fn(); @@ -25,8 +25,6 @@ jest.mock('@actions/github', () => ({ }, })); -const ghAction = require('../../.github/actions/javascript/postTestBuildComment/postTestBuildComment'); - const androidLink = 'https://expensify.app/ANDROID_LINK'; const iOSLink = 'https://expensify.app/IOS_LINK'; const webLink = 'https://expensify.app/WEB_LINK'; diff --git a/tests/unit/versionUpdaterTest.js b/tests/unit/versionUpdaterTest.js index 2e88f8dde3f7..cb0b0754f930 100644 --- a/tests/unit/versionUpdaterTest.js +++ b/tests/unit/versionUpdaterTest.js @@ -1,4 +1,4 @@ -const versionUpdater = require('../../.github/libs/versionUpdater'); +import * as versionUpdater from '../../.github/libs/versionUpdater'; const VERSION = '2.3.9-80'; const VERSION_NUMBER = [2, 3, 9, 80]; From 98648cad03ce3bd86211f38c2723a9f9dc04da57 Mon Sep 17 00:00:00 2001 From: Filip Solecki Date: Wed, 14 Feb 2024 20:03:45 +0100 Subject: [PATCH 09/13] Fix imports --- tests/e2e/compare/compare.js | 2 +- tests/e2e/compare/output/console.js | 2 +- tests/e2e/compare/output/markdown.js | 4 ++-- tests/e2e/nativeCommands/adbBackspace.js | 2 +- tests/e2e/nativeCommands/adbTypeText.js | 2 +- tests/e2e/server/index.js | 2 +- tests/e2e/testRunner.js | 13 +++++++------ tests/e2e/utils/execAsync.js | 2 +- tests/e2e/utils/installApp.js | 2 +- 9 files changed, 16 insertions(+), 15 deletions(-) diff --git a/tests/e2e/compare/compare.js b/tests/e2e/compare/compare.js index b7d5c15c5f82..5ae8c8b74578 100644 --- a/tests/e2e/compare/compare.js +++ b/tests/e2e/compare/compare.js @@ -1,6 +1,6 @@ import _ from 'underscore'; import getStats from '../measure/math'; -import math from './math'; +import * as math from './math'; import printToConsole from './output/console'; import writeToMarkdown from './output/markdown'; diff --git a/tests/e2e/compare/output/console.js b/tests/e2e/compare/output/console.js index 61645baf38b8..45d665bf8404 100644 --- a/tests/e2e/compare/output/console.js +++ b/tests/e2e/compare/output/console.js @@ -1,4 +1,4 @@ -import format from './format'; +import * as format from './format'; const printRegularLine = (entry) => { console.debug(` - ${entry.name}: ${format.formatDurationDiffChange(entry)}`); diff --git a/tests/e2e/compare/output/markdown.js b/tests/e2e/compare/output/markdown.js index 1f9626678498..119830a5bb2c 100644 --- a/tests/e2e/compare/output/markdown.js +++ b/tests/e2e/compare/output/markdown.js @@ -2,8 +2,8 @@ import fs from 'node:fs/promises'; import path from 'path'; import _ from 'underscore'; -import Logger from '../../utils/logger'; -import format from './format'; +import * as Logger from '../../utils/logger'; +import * as format from './format'; import markdownTable from './markdownTable'; const tableHeader = ['Name', 'Duration']; diff --git a/tests/e2e/nativeCommands/adbBackspace.js b/tests/e2e/nativeCommands/adbBackspace.js index c0dcf65c240c..7b01ed58080d 100644 --- a/tests/e2e/nativeCommands/adbBackspace.js +++ b/tests/e2e/nativeCommands/adbBackspace.js @@ -1,5 +1,5 @@ import execAsync from '../utils/execAsync'; -import Logger from '../utils/logger'; +import * as Logger from '../utils/logger'; const adbBackspace = async () => { Logger.log(`🔙 Pressing backspace`); diff --git a/tests/e2e/nativeCommands/adbTypeText.js b/tests/e2e/nativeCommands/adbTypeText.js index 7a4c3b31b7fd..b8c6cfd09c29 100644 --- a/tests/e2e/nativeCommands/adbTypeText.js +++ b/tests/e2e/nativeCommands/adbTypeText.js @@ -1,5 +1,5 @@ import execAsync from '../utils/execAsync'; -import Logger from '../utils/logger'; +import * as Logger from '../utils/logger'; const adbTypeText = async (text) => { Logger.log(`📝 Typing text: ${text}`); diff --git a/tests/e2e/server/index.js b/tests/e2e/server/index.js index b90e96696525..82152245d8e2 100644 --- a/tests/e2e/server/index.js +++ b/tests/e2e/server/index.js @@ -1,7 +1,7 @@ import {createServer} from 'http'; import config from '../config'; import * as nativeCommands from '../nativeCommands'; -import Logger from '../utils/logger'; +import * as Logger from '../utils/logger'; import Routes from './routes'; const PORT = process.env.PORT || config.SERVER_PORT; diff --git a/tests/e2e/testRunner.js b/tests/e2e/testRunner.js index f6e874c4f421..2b928ce3dc73 100644 --- a/tests/e2e/testRunner.js +++ b/tests/e2e/testRunner.js @@ -14,6 +14,7 @@ */ /* eslint-disable @lwc/lwc/no-async-await,no-restricted-syntax,no-await-in-loop */ +import {execSync} from 'child_process'; import fs from 'fs'; import _ from 'underscore'; import compare from './compare/compare'; @@ -24,7 +25,7 @@ import execAsync from './utils/execAsync'; import installApp from './utils/installApp'; import killApp from './utils/killApp'; import launchApp from './utils/launchApp'; -import Logger from './utils/logger'; +import * as Logger from './utils/logger'; import sleep from './utils/sleep'; import withFailTimeout from './utils/withFailTimeout'; @@ -413,13 +414,13 @@ const run = async () => { Logger.info('\n\nE2E test suite failed due to error:', e, '\nPrinting full logs:\n\n'); // Write logcat, meminfo, emulator info to file as well: - require('child_process').execSync(`adb logcat -d > ${config.OUTPUT_DIR}/logcat.txt`); - require('child_process').execSync(`adb shell "cat /proc/meminfo" > ${config.OUTPUT_DIR}/meminfo.txt`); - require('child_process').execSync(`adb shell "getprop" > ${config.OUTPUT_DIR}/emulator-properties.txt`); + execSync(`adb logcat -d > ${config.OUTPUT_DIR}/logcat.txt`); + execSync(`adb shell "cat /proc/meminfo" > ${config.OUTPUT_DIR}/meminfo.txt`); + execSync(`adb shell "getprop" > ${config.OUTPUT_DIR}/emulator-properties.txt`); - require('child_process').execSync(`cat ${config.LOG_FILE}`); + execSync(`cat ${config.LOG_FILE}`); try { - require('child_process').execSync(`cat ~/.android/avd/${process.env.AVD_NAME || 'test'}.avd/config.ini > ${config.OUTPUT_DIR}/emulator-config.ini`); + execSync(`cat ~/.android/avd/${process.env.AVD_NAME || 'test'}.avd/config.ini > ${config.OUTPUT_DIR}/emulator-config.ini`); } catch (ignoredError) { // the error is ignored, as the file might not exist if the test // run wasn't started with an emulator diff --git a/tests/e2e/utils/execAsync.js b/tests/e2e/utils/execAsync.js index fad44082e40c..9abc41105f7e 100644 --- a/tests/e2e/utils/execAsync.js +++ b/tests/e2e/utils/execAsync.js @@ -1,5 +1,5 @@ import {exec} from 'child_process'; -import Logger from './logger'; +import * as Logger from './logger'; /** * Executes a command none-blocking by wrapping it in a promise. diff --git a/tests/e2e/utils/installApp.js b/tests/e2e/utils/installApp.js index 331ae5e99dee..50fc8602762e 100644 --- a/tests/e2e/utils/installApp.js +++ b/tests/e2e/utils/installApp.js @@ -1,5 +1,5 @@ import execAsync from './execAsync'; -import Logger from './logger'; +import * as Logger from './logger'; /** * Installs the app on the currently connected device for the given platform. From f32c3a7dacca9a148d217a500ed849276235af01 Mon Sep 17 00:00:00 2001 From: filip-solecki <153545991+filip-solecki@users.noreply.github.com> Date: Thu, 15 Feb 2024 15:08:43 +0100 Subject: [PATCH 10/13] Update .github/libs/GitUtils.ts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Błażej Kustra <46095609+blazejkustra@users.noreply.github.com> --- .github/libs/GitUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/libs/GitUtils.ts b/.github/libs/GitUtils.ts index 051a3f3dc40b..e7423f97a934 100644 --- a/.github/libs/GitUtils.ts +++ b/.github/libs/GitUtils.ts @@ -10,7 +10,7 @@ type CommitType = { }; /** - * When fetching the given tag, exclude all history reachable by the shallowExcludeTag (used to make fetch much faster) + * @param [shallowExcludeTag] When fetching the given tag, exclude all history reachable by the shallowExcludeTag (used to make fetch much faster) */ function fetchTag(tag: string, shallowExcludeTag = '') { let shouldRetry = true; From 51d248fbb7e525a9881797b685cd3d4358e61873 Mon Sep 17 00:00:00 2001 From: Filip Solecki Date: Thu, 15 Feb 2024 15:22:59 +0100 Subject: [PATCH 11/13] Fix gh-actions --- .github/actions/javascript/createOrUpdateStagingDeploy/index.js | 2 +- .github/actions/javascript/getDeployPullRequestList/index.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/actions/javascript/createOrUpdateStagingDeploy/index.js b/.github/actions/javascript/createOrUpdateStagingDeploy/index.js index c09c1b8621f3..541a0b9683d0 100644 --- a/.github/actions/javascript/createOrUpdateStagingDeploy/index.js +++ b/.github/actions/javascript/createOrUpdateStagingDeploy/index.js @@ -16719,7 +16719,7 @@ const CONST = __importStar(__nccwpck_require__(4097)); const sanitizeStringForJSONParse_1 = __importDefault(__nccwpck_require__(9338)); const VERSION_UPDATER = __importStar(__nccwpck_require__(8007)); /** - * When fetching the given tag, exclude all history reachable by the shallowExcludeTag (used to make fetch much faster) + * @param [shallowExcludeTag] When fetching the given tag, exclude all history reachable by the shallowExcludeTag (used to make fetch much faster) */ function fetchTag(tag, shallowExcludeTag = '') { let shouldRetry = true; diff --git a/.github/actions/javascript/getDeployPullRequestList/index.js b/.github/actions/javascript/getDeployPullRequestList/index.js index 837dfd82adf1..e1d50f61da1f 100644 --- a/.github/actions/javascript/getDeployPullRequestList/index.js +++ b/.github/actions/javascript/getDeployPullRequestList/index.js @@ -13951,7 +13951,7 @@ const CONST = __importStar(__nccwpck_require__(4097)); const sanitizeStringForJSONParse_1 = __importDefault(__nccwpck_require__(9338)); const VERSION_UPDATER = __importStar(__nccwpck_require__(8007)); /** - * When fetching the given tag, exclude all history reachable by the shallowExcludeTag (used to make fetch much faster) + * @param [shallowExcludeTag] When fetching the given tag, exclude all history reachable by the shallowExcludeTag (used to make fetch much faster) */ function fetchTag(tag, shallowExcludeTag = '') { let shouldRetry = true; From 76401c1183c9e45db7a7d9ec3032fb407cfff154 Mon Sep 17 00:00:00 2001 From: Filip Solecki Date: Thu, 15 Feb 2024 22:18:49 +0100 Subject: [PATCH 12/13] rename import --- tests/e2e/utils/logger.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/e2e/utils/logger.js b/tests/e2e/utils/logger.js index aa8be5b84b26..5a7046d8c8b0 100644 --- a/tests/e2e/utils/logger.js +++ b/tests/e2e/utils/logger.js @@ -1,6 +1,6 @@ import fs from 'fs'; import path from 'path'; -import CONST from '../config'; +import CONFIG from '../config'; let isVerbose = true; const setLogLevelVerbose = (value) => { @@ -23,18 +23,18 @@ const log = (...args) => { } // Write to log file - if (!fs.existsSync(CONST.LOG_FILE)) { + if (!fs.existsSync(CONFIG.LOG_FILE)) { // Check that the directory exists - const logDir = path.dirname(CONST.LOG_FILE); + const logDir = path.dirname(CONFIG.LOG_FILE); if (!fs.existsSync(logDir)) { fs.mkdirSync(logDir); } - fs.writeFileSync(CONST.LOG_FILE, ''); + fs.writeFileSync(CONFIG.LOG_FILE, ''); } const time = new Date(); const timeStr = `${time.getHours()}:${time.getMinutes()}:${time.getSeconds()} ${time.getMilliseconds()}`; - fs.appendFileSync(CONST.LOG_FILE, `[${timeStr}] ${args.join(' ')}\n`); + fs.appendFileSync(CONFIG.LOG_FILE, `[${timeStr}] ${args.join(' ')}\n`); }; const info = (...args) => { From 806fc72526bc6d59ac3268ed58d074aa40b9bd6e Mon Sep 17 00:00:00 2001 From: Filip Solecki Date: Mon, 19 Feb 2024 14:54:47 +0100 Subject: [PATCH 13/13] Add default to require import path --- tests/e2e/testRunner.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/e2e/testRunner.js b/tests/e2e/testRunner.js index d8dd523894dc..cbdb22de6c63 100644 --- a/tests/e2e/testRunner.js +++ b/tests/e2e/testRunner.js @@ -55,7 +55,7 @@ const setConfigPath = (configPathParam) => { if (!configPath.startsWith('.')) { configPath = `./${configPath}`; } - const customConfig = require(configPath); + const customConfig = require(configPath).default; config = _.extend(defaultConfig, customConfig); };