diff --git a/.github/actions/javascript/createOrUpdateStagingDeploy/index.js b/.github/actions/javascript/createOrUpdateStagingDeploy/index.js index 48751162fd10..86840c9ae4fa 100644 --- a/.github/actions/javascript/createOrUpdateStagingDeploy/index.js +++ b/.github/actions/javascript/createOrUpdateStagingDeploy/index.js @@ -317,16 +317,15 @@ function getValidMergedPRs(commits) { * @param {String} toTag * @returns {Promise>} – Pull request numbers */ -function getPullRequestsMergedBetween(fromTag, toTag) { +async function getPullRequestsMergedBetween(fromTag, toTag) { console.log(`Looking for commits made between ${fromTag} and ${toTag}...`); - return getCommitHistoryAsJSON(fromTag, toTag).then((commitList) => { - console.log(`Commits made between ${fromTag} and ${toTag}:`, commitList); + 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(); - console.log(`List of pull requests merged between ${fromTag} and ${toTag}`, pullRequestNumbers); - return _.map(pullRequestNumbers, (prNum) => Number.parseInt(prNum, 10)); - }); + // 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 = { diff --git a/.github/actions/javascript/getDeployPullRequestList/index.js b/.github/actions/javascript/getDeployPullRequestList/index.js index c02e86099b5b..af691cfb6d1d 100644 --- a/.github/actions/javascript/getDeployPullRequestList/index.js +++ b/.github/actions/javascript/getDeployPullRequestList/index.js @@ -260,16 +260,15 @@ function getValidMergedPRs(commits) { * @param {String} toTag * @returns {Promise>} – Pull request numbers */ -function getPullRequestsMergedBetween(fromTag, toTag) { +async function getPullRequestsMergedBetween(fromTag, toTag) { console.log(`Looking for commits made between ${fromTag} and ${toTag}...`); - return getCommitHistoryAsJSON(fromTag, toTag).then((commitList) => { - console.log(`Commits made between ${fromTag} and ${toTag}:`, commitList); + 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(); - console.log(`List of pull requests merged between ${fromTag} and ${toTag}`, pullRequestNumbers); - return _.map(pullRequestNumbers, (prNum) => Number.parseInt(prNum, 10)); - }); + // 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 = { diff --git a/.github/libs/GitUtils.js b/.github/libs/GitUtils.js index 6b1350996fc1..fa2cf430b277 100644 --- a/.github/libs/GitUtils.js +++ b/.github/libs/GitUtils.js @@ -133,16 +133,15 @@ function getValidMergedPRs(commits) { * @param {String} toTag * @returns {Promise>} – Pull request numbers */ -function getPullRequestsMergedBetween(fromTag, toTag) { +async function getPullRequestsMergedBetween(fromTag, toTag) { console.log(`Looking for commits made between ${fromTag} and ${toTag}...`); - return getCommitHistoryAsJSON(fromTag, toTag).then((commitList) => { - console.log(`Commits made between ${fromTag} and ${toTag}:`, commitList); + 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(); - console.log(`List of pull requests merged between ${fromTag} and ${toTag}`, pullRequestNumbers); - return _.map(pullRequestNumbers, (prNum) => Number.parseInt(prNum, 10)); - }); + // 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 = { diff --git a/tests/unit/CIGitLogicTest.sh b/tests/unit/CIGitLogicTest.sh index 5ddc9bbdcf4b..8374bcaf1f89 100755 --- a/tests/unit/CIGitLogicTest.sh +++ b/tests/unit/CIGitLogicTest.sh @@ -238,7 +238,7 @@ cherry_pick_pr 3 tag_staging # Verify output for checklist -assert_prs_merged_between '1.0.0-0' '1.0.0-2' "[ 3, 1 ]" +assert_prs_merged_between '1.0.0-0' '1.0.0-2' "[ 1, 3 ]" # Verify output for deploy comment assert_prs_merged_between '1.0.0-1' '1.0.0-2' "[ 3 ]" @@ -252,7 +252,7 @@ title "Scenario #4A: Run the production deploy" update_production_from_staging # Verify output for release body and production deploy comments -assert_prs_merged_between '1.0.0-0' '1.0.0-2' "[ 3, 1 ]" +assert_prs_merged_between '1.0.0-0' '1.0.0-2' "[ 1, 3 ]" success "Scenario #4A completed successfully!" @@ -284,7 +284,7 @@ update_staging_from_main tag_staging # Verify output for checklist -assert_prs_merged_between '1.0.0-2' '1.0.1-1' "[ 5, 2 ]" +assert_prs_merged_between '1.0.0-2' '1.0.1-1' "[ 2, 5 ]" # Verify output for deploy comment assert_prs_merged_between '1.0.1-0' '1.0.1-1' "[ 5 ]" @@ -307,7 +307,7 @@ update_staging_from_main tag_staging # Verify output for checklist -assert_prs_merged_between '1.0.0-2' '1.0.1-2' "[ 6, 5, 2 ]" +assert_prs_merged_between '1.0.0-2' '1.0.1-2' "[ 2, 5, 6 ]" # Verify output for deploy comment assert_prs_merged_between '1.0.1-1' '1.0.1-2' "[ 6 ]" @@ -329,7 +329,7 @@ update_staging_from_main tag_staging # Verify output for checklist -assert_prs_merged_between '1.0.0-2' '1.0.1-3' "[ 7, 6, 5, 2 ]" +assert_prs_merged_between '1.0.0-2' '1.0.1-3' "[ 2, 5, 6, 7 ]" # Verify output for deploy comment assert_prs_merged_between '1.0.1-2' '1.0.1-3' "[ 7 ]" @@ -389,10 +389,10 @@ update_staging_from_main tag_staging # Verify production release list -assert_prs_merged_between '1.0.0-2' '1.0.1-4' '[ 9, 7, 6, 5, 2 ]' +assert_prs_merged_between '1.0.0-2' '1.0.1-4' '[ 2, 5, 6, 7, 9 ]' # Verify PR list for the new checklist -assert_prs_merged_between '1.0.1-4' '1.0.2-0' '[ 10, 8 ]' +assert_prs_merged_between '1.0.1-4' '1.0.2-0' '[ 8, 10 ]' success "Scenario #6 completed successfully!"