From 209a0e27f02f19f56d3df6ce264004984a11aef2 Mon Sep 17 00:00:00 2001 From: rory Date: Thu, 15 Aug 2024 15:39:45 -0700 Subject: [PATCH 01/12] Dont compare with the same version, and print the reason a version was skipped --- .../getDeployPullRequestList.ts | 46 ++++++++++++++----- .../getDeployPullRequestList/index.js | 42 +++++++++++++---- 2 files changed, 68 insertions(+), 20 deletions(-) diff --git a/.github/actions/javascript/getDeployPullRequestList/getDeployPullRequestList.ts b/.github/actions/javascript/getDeployPullRequestList/getDeployPullRequestList.ts index b9d01702e66e..9b2f90aef01d 100644 --- a/.github/actions/javascript/getDeployPullRequestList/getDeployPullRequestList.ts +++ b/.github/actions/javascript/getDeployPullRequestList/getDeployPullRequestList.ts @@ -25,18 +25,27 @@ async function run() { // because if a build fails on even one platform, then it will have the status 'failure' .filter((workflowRun) => workflowRun.conclusion !== 'cancelled'); + // 9.0.20-6 -> data.prerelease is false and isProductionDeploy is true + // 9.0.20-5 -> data.prerelease is false and isProductionDeploy is false + // Find the most recent deploy workflow targeting the correct environment, for which at least one of the build jobs finished successfully let lastSuccessfulDeploy = completedDeploys.shift(); + let invalidReleaseBranch = false; + let sameAsInputTag = false; + let wrongEnvironment = false; + let unsuccessfulDeploy = false; while ( - lastSuccessfulDeploy?.head_branch && - (( - await GithubUtils.octokit.repos.getReleaseByTag({ - owner: github.context.repo.owner, - repo: github.context.repo.repo, - tag: lastSuccessfulDeploy.head_branch, - }) - ).data.prerelease === isProductionDeploy || - !( + (invalidReleaseBranch = !!lastSuccessfulDeploy?.head_branch) && + ((sameAsInputTag = lastSuccessfulDeploy?.head_branch === inputTag) || + (wrongEnvironment = + ( + await GithubUtils.octokit.repos.getReleaseByTag({ + owner: github.context.repo.owner, + repo: github.context.repo.repo, + tag: lastSuccessfulDeploy.head_branch, + }) + ).data.prerelease === isProductionDeploy) || + (unsuccessfulDeploy = !( await GithubUtils.octokit.actions.listJobsForWorkflowRun({ owner: github.context.repo.owner, repo: github.context.repo.repo, @@ -44,9 +53,24 @@ async function run() { run_id: lastSuccessfulDeploy.id, filter: 'latest', }) - ).data.jobs.some((job) => job.name.startsWith('Build and deploy') && job.conclusion === 'success')) + ).data.jobs.some((job) => job.name.startsWith('Build and deploy') && job.conclusion === 'success'))) ) { - console.log(`Deploy was not a success: ${lastSuccessfulDeploy.html_url}, looking at the next one`); + let reason; + if (invalidReleaseBranch) { + reason = 'Invalid release branch'; + } else if (sameAsInputTag) { + reason = `Same as input tag ${inputTag}`; + } else if (wrongEnvironment) { + reason = `Was a ${isProductionDeploy ? 'staging' : 'production'} deploy, we only want to compare with ${isProductionDeploy ? 'production' : 'staging'} deploys`; + } else if (unsuccessfulDeploy) { + reason = 'Was an unsuccessful deploy'; + } else { + reason = 'WTF?!'; + } + console.log( + `Deploy of tag ${lastSuccessfulDeploy?.head_branch} was not valid as a base for comparison, looking at the next one. Reason: ${reason}`, + lastSuccessfulDeploy.html_url, + ); lastSuccessfulDeploy = completedDeploys.shift(); } diff --git a/.github/actions/javascript/getDeployPullRequestList/index.js b/.github/actions/javascript/getDeployPullRequestList/index.js index 05ae086fcc24..3e24c8e85c8c 100644 --- a/.github/actions/javascript/getDeployPullRequestList/index.js +++ b/.github/actions/javascript/getDeployPullRequestList/index.js @@ -11518,22 +11518,46 @@ async function run() { // Note: we filter out cancelled runs instead of looking only for success runs // because if a build fails on even one platform, then it will have the status 'failure' .filter((workflowRun) => workflowRun.conclusion !== 'cancelled'); + // 9.0.20-6 -> data.prerelease is false and isProductionDeploy is true + // 9.0.20-5 -> data.prerelease is false and isProductionDeploy is false // Find the most recent deploy workflow targeting the correct environment, for which at least one of the build jobs finished successfully let lastSuccessfulDeploy = completedDeploys.shift(); - while (lastSuccessfulDeploy?.head_branch && - ((await GithubUtils_1.default.octokit.repos.getReleaseByTag({ - owner: github.context.repo.owner, - repo: github.context.repo.repo, - tag: lastSuccessfulDeploy.head_branch, - })).data.prerelease === isProductionDeploy || - !(await GithubUtils_1.default.octokit.actions.listJobsForWorkflowRun({ + let invalidReleaseBranch = false; + let sameAsInputTag = false; + let wrongEnvironment = false; + let unsuccessfulDeploy = false; + while ((invalidReleaseBranch = !!lastSuccessfulDeploy?.head_branch) && + ((sameAsInputTag = lastSuccessfulDeploy?.head_branch === inputTag) || + (wrongEnvironment = + (await GithubUtils_1.default.octokit.repos.getReleaseByTag({ + owner: github.context.repo.owner, + repo: github.context.repo.repo, + tag: lastSuccessfulDeploy.head_branch, + })).data.prerelease === isProductionDeploy) || + (unsuccessfulDeploy = !(await GithubUtils_1.default.octokit.actions.listJobsForWorkflowRun({ owner: github.context.repo.owner, repo: github.context.repo.repo, // eslint-disable-next-line @typescript-eslint/naming-convention run_id: lastSuccessfulDeploy.id, filter: 'latest', - })).data.jobs.some((job) => job.name.startsWith('Build and deploy') && job.conclusion === 'success'))) { - console.log(`Deploy was not a success: ${lastSuccessfulDeploy.html_url}, looking at the next one`); + })).data.jobs.some((job) => job.name.startsWith('Build and deploy') && job.conclusion === 'success')))) { + let reason; + if (invalidReleaseBranch) { + reason = 'Invalid release branch'; + } + else if (sameAsInputTag) { + reason = `Same as input tag ${inputTag}`; + } + else if (wrongEnvironment) { + reason = `Was a ${isProductionDeploy ? 'staging' : 'production'} deploy, we only want to compare with ${isProductionDeploy ? 'production' : 'staging'} deploys`; + } + else if (unsuccessfulDeploy) { + reason = 'Was an unsuccessful deploy'; + } + else { + reason = 'WTF?!'; + } + console.log(`Deploy of tag ${lastSuccessfulDeploy?.head_branch} was not valid as a base for comparison, looking at the next one. Reason: ${reason}`, lastSuccessfulDeploy.html_url); lastSuccessfulDeploy = completedDeploys.shift(); } if (!lastSuccessfulDeploy) { From 0028718596ec5e25b1f5bd41aba1f3bc1d0bedde Mon Sep 17 00:00:00 2001 From: rory Date: Thu, 15 Aug 2024 15:46:15 -0700 Subject: [PATCH 02/12] Add code comment --- .../getDeployPullRequestList/getDeployPullRequestList.ts | 3 +++ .github/actions/javascript/getDeployPullRequestList/index.js | 2 ++ 2 files changed, 5 insertions(+) diff --git a/.github/actions/javascript/getDeployPullRequestList/getDeployPullRequestList.ts b/.github/actions/javascript/getDeployPullRequestList/getDeployPullRequestList.ts index 9b2f90aef01d..178ce1dfae25 100644 --- a/.github/actions/javascript/getDeployPullRequestList/getDeployPullRequestList.ts +++ b/.github/actions/javascript/getDeployPullRequestList/getDeployPullRequestList.ts @@ -34,6 +34,9 @@ async function run() { let sameAsInputTag = false; let wrongEnvironment = false; let unsuccessfulDeploy = false; + + // note: this while statement looks a bit weird because uses assignment as a condition: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/while#using_an_assignment_as_a_condition + // while ugly, it's beneficial in this case because it prevents extra network requests from happening unnecessarily (i.e: we only check wrongEnvironment if sameAsInputTag is false, etc...) while ( (invalidReleaseBranch = !!lastSuccessfulDeploy?.head_branch) && ((sameAsInputTag = lastSuccessfulDeploy?.head_branch === inputTag) || diff --git a/.github/actions/javascript/getDeployPullRequestList/index.js b/.github/actions/javascript/getDeployPullRequestList/index.js index 3e24c8e85c8c..bfd625670b87 100644 --- a/.github/actions/javascript/getDeployPullRequestList/index.js +++ b/.github/actions/javascript/getDeployPullRequestList/index.js @@ -11526,6 +11526,8 @@ async function run() { let sameAsInputTag = false; let wrongEnvironment = false; let unsuccessfulDeploy = false; + // note: this while statement looks a bit weird because uses assignment as a condition: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/while#using_an_assignment_as_a_condition + // while ugly, it's beneficial in this case because it prevents extra network requests from happening unnecessarily (i.e: we only check wrongEnvironment if sameAsInputTag is false, etc...) while ((invalidReleaseBranch = !!lastSuccessfulDeploy?.head_branch) && ((sameAsInputTag = lastSuccessfulDeploy?.head_branch === inputTag) || (wrongEnvironment = From b805d9349b169328cda83b69ac82edf0a6b54169 Mon Sep 17 00:00:00 2001 From: rory Date: Thu, 15 Aug 2024 15:59:30 -0700 Subject: [PATCH 03/12] Further improve comments --- .../getDeployPullRequestList/getDeployPullRequestList.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/actions/javascript/getDeployPullRequestList/getDeployPullRequestList.ts b/.github/actions/javascript/getDeployPullRequestList/getDeployPullRequestList.ts index 178ce1dfae25..cf76ac1c8ec1 100644 --- a/.github/actions/javascript/getDeployPullRequestList/getDeployPullRequestList.ts +++ b/.github/actions/javascript/getDeployPullRequestList/getDeployPullRequestList.ts @@ -25,9 +25,6 @@ async function run() { // because if a build fails on even one platform, then it will have the status 'failure' .filter((workflowRun) => workflowRun.conclusion !== 'cancelled'); - // 9.0.20-6 -> data.prerelease is false and isProductionDeploy is true - // 9.0.20-5 -> data.prerelease is false and isProductionDeploy is false - // Find the most recent deploy workflow targeting the correct environment, for which at least one of the build jobs finished successfully let lastSuccessfulDeploy = completedDeploys.shift(); let invalidReleaseBranch = false; @@ -39,6 +36,8 @@ async function run() { // while ugly, it's beneficial in this case because it prevents extra network requests from happening unnecessarily (i.e: we only check wrongEnvironment if sameAsInputTag is false, etc...) while ( (invalidReleaseBranch = !!lastSuccessfulDeploy?.head_branch) && + // we never want to compare a tag with itself. This check is necessary because prod deploys almost always have the same version as the last staging deploy. + // In this case, the check for wrongEnvironment fails because the release that triggered that staging deploy is now finalized, so it looks like a prod deploy. ((sameAsInputTag = lastSuccessfulDeploy?.head_branch === inputTag) || (wrongEnvironment = ( From 241d085b135018c471b1bef45bff1dac75574e2e Mon Sep 17 00:00:00 2001 From: rory Date: Thu, 15 Aug 2024 16:14:02 -0700 Subject: [PATCH 04/12] Extract isReleaseValidBaseForEnvironment --- .../getDeployPullRequestList.ts | 35 ++++++++++++++----- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/.github/actions/javascript/getDeployPullRequestList/getDeployPullRequestList.ts b/.github/actions/javascript/getDeployPullRequestList/getDeployPullRequestList.ts index cf76ac1c8ec1..1287ad9fc69c 100644 --- a/.github/actions/javascript/getDeployPullRequestList/getDeployPullRequestList.ts +++ b/.github/actions/javascript/getDeployPullRequestList/getDeployPullRequestList.ts @@ -4,10 +4,34 @@ import {getJSONInput} from '@github/libs/ActionUtils'; import GithubUtils from '@github/libs/GithubUtils'; import GitUtils from '@github/libs/GitUtils'; +/** + * This function checks if a given release is a valid base to get the PR list with `git log startTag...endTag`. + * The rules are: + * - production deploys can only be compared with other production deploys + * - staging deploys can be compared with other staging deploys or production deploys. + * The reason this is necessary is that the final staging release in each deploy cycle will BECOME a production release. + * For example, imagine a checklist is closed with version 9.0.20-6. That's the most recent staging deploy, but the release for 9.0.20-6 is now finalized. + * So the most recent prerelease will be 9.0.20-5. + * When 9.0.21-0 finishes deploying, we want to list PRs between 9.0.20-6...9.0.21-0, NOT 9.0.20-5...9.0.21-0 (so that the PR CP'd in 9.0.20-6 is not included in the next checklist) + */ +async function isReleaseValidBaseForEnvironment(releaseTag: string, isProductionDeploy: boolean) { + if (!isProductionDeploy) { + return true; + } + const isPrerelease = ( + await GithubUtils.octokit.repos.getReleaseByTag({ + owner: github.context.repo.owner, + repo: github.context.repo.repo, + tag: releaseTag, + }) + ).data.prerelease; + return !isPrerelease; +} + async function run() { try { const inputTag = core.getInput('TAG', {required: true}); - const isProductionDeploy = getJSONInput('IS_PRODUCTION_DEPLOY', {required: false}, false); + const isProductionDeploy = !!getJSONInput('IS_PRODUCTION_DEPLOY', {required: false}, false); const deployEnv = isProductionDeploy ? 'production' : 'staging'; console.log(`Looking for PRs deployed to ${deployEnv} in ${inputTag}...`); @@ -39,14 +63,7 @@ async function run() { // we never want to compare a tag with itself. This check is necessary because prod deploys almost always have the same version as the last staging deploy. // In this case, the check for wrongEnvironment fails because the release that triggered that staging deploy is now finalized, so it looks like a prod deploy. ((sameAsInputTag = lastSuccessfulDeploy?.head_branch === inputTag) || - (wrongEnvironment = - ( - await GithubUtils.octokit.repos.getReleaseByTag({ - owner: github.context.repo.owner, - repo: github.context.repo.repo, - tag: lastSuccessfulDeploy.head_branch, - }) - ).data.prerelease === isProductionDeploy) || + (wrongEnvironment = await isReleaseValidBaseForEnvironment(lastSuccessfulDeploy?.head_branch, isProductionDeploy)) || (unsuccessfulDeploy = !( await GithubUtils.octokit.actions.listJobsForWorkflowRun({ owner: github.context.repo.owner, From 8a70d251dd416b5b29b000f18ba5652d62ca9c39 Mon Sep 17 00:00:00 2001 From: rory Date: Thu, 15 Aug 2024 16:24:46 -0700 Subject: [PATCH 05/12] Extract wasDeploySuccessful to a separate function --- .../getDeployPullRequestList.ts | 41 +++++++++++-------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/.github/actions/javascript/getDeployPullRequestList/getDeployPullRequestList.ts b/.github/actions/javascript/getDeployPullRequestList/getDeployPullRequestList.ts index 1287ad9fc69c..310b93cef60a 100644 --- a/.github/actions/javascript/getDeployPullRequestList/getDeployPullRequestList.ts +++ b/.github/actions/javascript/getDeployPullRequestList/getDeployPullRequestList.ts @@ -5,14 +5,15 @@ import GithubUtils from '@github/libs/GithubUtils'; import GitUtils from '@github/libs/GitUtils'; /** - * This function checks if a given release is a valid base to get the PR list with `git log startTag...endTag`. + * This function checks if a given release is a valid baseTag to get the PR list with `git log baseTag...endTag`. + * * The rules are: * - production deploys can only be compared with other production deploys * - staging deploys can be compared with other staging deploys or production deploys. - * The reason this is necessary is that the final staging release in each deploy cycle will BECOME a production release. - * For example, imagine a checklist is closed with version 9.0.20-6. That's the most recent staging deploy, but the release for 9.0.20-6 is now finalized. - * So the most recent prerelease will be 9.0.20-5. - * When 9.0.21-0 finishes deploying, we want to list PRs between 9.0.20-6...9.0.21-0, NOT 9.0.20-5...9.0.21-0 (so that the PR CP'd in 9.0.20-6 is not included in the next checklist) + * The reason is that the final staging release in each deploy cycle will BECOME a production release. + * For example, imagine a checklist is closed with version 9.0.20-6; that's the most recent staging deploy, but the release for 9.0.20-6 is now finalized, so it looks like a prod deploy. + * When 9.0.21-0 finishes deploying to staging, the most recent prerelease is 9.0.20-5. However, we want 9.0.20-6...9.0.21-0, + * NOT 9.0.20-5...9.0.21-0 (so that the PR CP'd in 9.0.20-6 is not included in the next checklist) */ async function isReleaseValidBaseForEnvironment(releaseTag: string, isProductionDeploy: boolean) { if (!isProductionDeploy) { @@ -28,6 +29,22 @@ async function isReleaseValidBaseForEnvironment(releaseTag: string, isProduction return !isPrerelease; } +/** + * Was a given platformDeploy workflow run successful on at least one platform? + */ +async function wasDeploySuccessful(runID: number) { + const jobsForWorkflowRun = ( + await GithubUtils.octokit.actions.listJobsForWorkflowRun({ + owner: github.context.repo.owner, + repo: github.context.repo.repo, + // eslint-disable-next-line @typescript-eslint/naming-convention + run_id: runID, + filter: 'latest', + }) + ).data.jobs; + return jobsForWorkflowRun.some((job) => job.name.startsWith('Build and deploy') && job.conclusion === 'success'); +} + async function run() { try { const inputTag = core.getInput('TAG', {required: true}); @@ -56,23 +73,15 @@ async function run() { let wrongEnvironment = false; let unsuccessfulDeploy = false; - // note: this while statement looks a bit weird because uses assignment as a condition: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/while#using_an_assignment_as_a_condition - // while ugly, it's beneficial in this case because it prevents extra network requests from happening unnecessarily (i.e: we only check wrongEnvironment if sameAsInputTag is false, etc...) + // note: this while statement looks a bit weird because uses assignments as conditions: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/while#using_an_assignment_as_a_condition + // it's beneficial in this case because it prevents extra network requests from happening unnecessarily (i.e: we only check wrongEnvironment if sameAsInputTag is false, etc...) while ( (invalidReleaseBranch = !!lastSuccessfulDeploy?.head_branch) && // we never want to compare a tag with itself. This check is necessary because prod deploys almost always have the same version as the last staging deploy. // In this case, the check for wrongEnvironment fails because the release that triggered that staging deploy is now finalized, so it looks like a prod deploy. ((sameAsInputTag = lastSuccessfulDeploy?.head_branch === inputTag) || (wrongEnvironment = await isReleaseValidBaseForEnvironment(lastSuccessfulDeploy?.head_branch, isProductionDeploy)) || - (unsuccessfulDeploy = !( - await GithubUtils.octokit.actions.listJobsForWorkflowRun({ - owner: github.context.repo.owner, - repo: github.context.repo.repo, - // eslint-disable-next-line @typescript-eslint/naming-convention - run_id: lastSuccessfulDeploy.id, - filter: 'latest', - }) - ).data.jobs.some((job) => job.name.startsWith('Build and deploy') && job.conclusion === 'success'))) + (unsuccessfulDeploy = !(await wasDeploySuccessful(lastSuccessfulDeploy.id)))) ) { let reason; if (invalidReleaseBranch) { From 7526f66c4c9c64f95a0ec8d03662ee097c6f244f Mon Sep 17 00:00:00 2001 From: rory Date: Thu, 15 Aug 2024 16:27:58 -0700 Subject: [PATCH 06/12] Rebuild gh actions --- .../getDeployPullRequestList/index.js | 60 +++++++++++++------ 1 file changed, 42 insertions(+), 18 deletions(-) diff --git a/.github/actions/javascript/getDeployPullRequestList/index.js b/.github/actions/javascript/getDeployPullRequestList/index.js index bfd625670b87..1fbce98ed3f4 100644 --- a/.github/actions/javascript/getDeployPullRequestList/index.js +++ b/.github/actions/javascript/getDeployPullRequestList/index.js @@ -11502,10 +11502,45 @@ const github = __importStar(__nccwpck_require__(5438)); const ActionUtils_1 = __nccwpck_require__(6981); const GithubUtils_1 = __importDefault(__nccwpck_require__(9296)); const GitUtils_1 = __importDefault(__nccwpck_require__(1547)); +/** + * This function checks if a given release is a valid baseTag to get the PR list with `git log baseTag...endTag`. + * + * The rules are: + * - production deploys can only be compared with other production deploys + * - staging deploys can be compared with other staging deploys or production deploys. + * The reason is that the final staging release in each deploy cycle will BECOME a production release. + * For example, imagine a checklist is closed with version 9.0.20-6; that's the most recent staging deploy, but the release for 9.0.20-6 is now finalized, so it looks like a prod deploy. + * When 9.0.21-0 finishes deploying to staging, the most recent prerelease is 9.0.20-5. However, we want 9.0.20-6...9.0.21-0, + * NOT 9.0.20-5...9.0.21-0 (so that the PR CP'd in 9.0.20-6 is not included in the next checklist) + */ +async function isReleaseValidBaseForEnvironment(releaseTag, isProductionDeploy) { + if (!isProductionDeploy) { + return true; + } + const isPrerelease = (await GithubUtils_1.default.octokit.repos.getReleaseByTag({ + owner: github.context.repo.owner, + repo: github.context.repo.repo, + tag: releaseTag, + })).data.prerelease; + return !isPrerelease; +} +/** + * Was a given platformDeploy workflow run successful on at least one platform? + */ +async function wasDeploySuccessful(runID) { + const jobsForWorkflowRun = (await GithubUtils_1.default.octokit.actions.listJobsForWorkflowRun({ + owner: github.context.repo.owner, + repo: github.context.repo.repo, + // eslint-disable-next-line @typescript-eslint/naming-convention + run_id: runID, + filter: 'latest', + })).data.jobs; + return jobsForWorkflowRun.some((job) => job.name.startsWith('Build and deploy') && job.conclusion === 'success'); +} async function run() { try { const inputTag = core.getInput('TAG', { required: true }); - const isProductionDeploy = (0, ActionUtils_1.getJSONInput)('IS_PRODUCTION_DEPLOY', { required: false }, false); + const isProductionDeploy = !!(0, ActionUtils_1.getJSONInput)('IS_PRODUCTION_DEPLOY', { required: false }, false); const deployEnv = isProductionDeploy ? 'production' : 'staging'; console.log(`Looking for PRs deployed to ${deployEnv} in ${inputTag}...`); const completedDeploys = (await GithubUtils_1.default.octokit.actions.listWorkflowRuns({ @@ -11518,31 +11553,20 @@ async function run() { // Note: we filter out cancelled runs instead of looking only for success runs // because if a build fails on even one platform, then it will have the status 'failure' .filter((workflowRun) => workflowRun.conclusion !== 'cancelled'); - // 9.0.20-6 -> data.prerelease is false and isProductionDeploy is true - // 9.0.20-5 -> data.prerelease is false and isProductionDeploy is false // Find the most recent deploy workflow targeting the correct environment, for which at least one of the build jobs finished successfully let lastSuccessfulDeploy = completedDeploys.shift(); let invalidReleaseBranch = false; let sameAsInputTag = false; let wrongEnvironment = false; let unsuccessfulDeploy = false; - // note: this while statement looks a bit weird because uses assignment as a condition: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/while#using_an_assignment_as_a_condition - // while ugly, it's beneficial in this case because it prevents extra network requests from happening unnecessarily (i.e: we only check wrongEnvironment if sameAsInputTag is false, etc...) + // note: this while statement looks a bit weird because uses assignments as conditions: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/while#using_an_assignment_as_a_condition + // it's beneficial in this case because it prevents extra network requests from happening unnecessarily (i.e: we only check wrongEnvironment if sameAsInputTag is false, etc...) while ((invalidReleaseBranch = !!lastSuccessfulDeploy?.head_branch) && + // we never want to compare a tag with itself. This check is necessary because prod deploys almost always have the same version as the last staging deploy. + // In this case, the check for wrongEnvironment fails because the release that triggered that staging deploy is now finalized, so it looks like a prod deploy. ((sameAsInputTag = lastSuccessfulDeploy?.head_branch === inputTag) || - (wrongEnvironment = - (await GithubUtils_1.default.octokit.repos.getReleaseByTag({ - owner: github.context.repo.owner, - repo: github.context.repo.repo, - tag: lastSuccessfulDeploy.head_branch, - })).data.prerelease === isProductionDeploy) || - (unsuccessfulDeploy = !(await GithubUtils_1.default.octokit.actions.listJobsForWorkflowRun({ - owner: github.context.repo.owner, - repo: github.context.repo.repo, - // eslint-disable-next-line @typescript-eslint/naming-convention - run_id: lastSuccessfulDeploy.id, - filter: 'latest', - })).data.jobs.some((job) => job.name.startsWith('Build and deploy') && job.conclusion === 'success')))) { + (wrongEnvironment = await isReleaseValidBaseForEnvironment(lastSuccessfulDeploy?.head_branch, isProductionDeploy)) || + (unsuccessfulDeploy = !(await wasDeploySuccessful(lastSuccessfulDeploy.id))))) { let reason; if (invalidReleaseBranch) { reason = 'Invalid release branch'; From a7aba2eaa9f882ef6b21bbf77643a511a9e0b298 Mon Sep 17 00:00:00 2001 From: rory Date: Thu, 15 Aug 2024 17:09:16 -0700 Subject: [PATCH 07/12] Allow no-cond-assign in this case --- .../getDeployPullRequestList/getDeployPullRequestList.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/actions/javascript/getDeployPullRequestList/getDeployPullRequestList.ts b/.github/actions/javascript/getDeployPullRequestList/getDeployPullRequestList.ts index 310b93cef60a..20ce687c243e 100644 --- a/.github/actions/javascript/getDeployPullRequestList/getDeployPullRequestList.ts +++ b/.github/actions/javascript/getDeployPullRequestList/getDeployPullRequestList.ts @@ -76,11 +76,15 @@ async function run() { // note: this while statement looks a bit weird because uses assignments as conditions: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/while#using_an_assignment_as_a_condition // it's beneficial in this case because it prevents extra network requests from happening unnecessarily (i.e: we only check wrongEnvironment if sameAsInputTag is false, etc...) while ( + // eslint-disable-next-line no-cond-assign (invalidReleaseBranch = !!lastSuccessfulDeploy?.head_branch) && // we never want to compare a tag with itself. This check is necessary because prod deploys almost always have the same version as the last staging deploy. // In this case, the check for wrongEnvironment fails because the release that triggered that staging deploy is now finalized, so it looks like a prod deploy. + // eslint-disable-next-line no-cond-assign ((sameAsInputTag = lastSuccessfulDeploy?.head_branch === inputTag) || + // eslint-disable-next-line no-cond-assign (wrongEnvironment = await isReleaseValidBaseForEnvironment(lastSuccessfulDeploy?.head_branch, isProductionDeploy)) || + // eslint-disable-next-line no-cond-assign (unsuccessfulDeploy = !(await wasDeploySuccessful(lastSuccessfulDeploy.id)))) ) { let reason; From 9be58cde34246675493482439d0727b0ed988402 Mon Sep 17 00:00:00 2001 From: rory Date: Thu, 15 Aug 2024 17:11:46 -0700 Subject: [PATCH 08/12] Improve comments again --- .../getDeployPullRequestList.ts | 4 +++- .../javascript/getDeployPullRequestList/index.js | 11 +++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/.github/actions/javascript/getDeployPullRequestList/getDeployPullRequestList.ts b/.github/actions/javascript/getDeployPullRequestList/getDeployPullRequestList.ts index 20ce687c243e..ddb71ccc6fad 100644 --- a/.github/actions/javascript/getDeployPullRequestList/getDeployPullRequestList.ts +++ b/.github/actions/javascript/getDeployPullRequestList/getDeployPullRequestList.ts @@ -74,7 +74,9 @@ async function run() { let unsuccessfulDeploy = false; // note: this while statement looks a bit weird because uses assignments as conditions: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/while#using_an_assignment_as_a_condition - // it's beneficial in this case because it prevents extra network requests from happening unnecessarily (i.e: we only check wrongEnvironment if sameAsInputTag is false, etc...) + // it's beneficial in this case because: + // - keeping the async calls in the while loop conditional prevents extra network requests from happening unnecessarily (i.e: we only check wrongEnvironment if sameAsInputTag is false, etc...) + // - using conditional assignment, we can keep track of why a release is being skipped over for the sake of logs + debugging while ( // eslint-disable-next-line no-cond-assign (invalidReleaseBranch = !!lastSuccessfulDeploy?.head_branch) && diff --git a/.github/actions/javascript/getDeployPullRequestList/index.js b/.github/actions/javascript/getDeployPullRequestList/index.js index 1fbce98ed3f4..ece7077167a3 100644 --- a/.github/actions/javascript/getDeployPullRequestList/index.js +++ b/.github/actions/javascript/getDeployPullRequestList/index.js @@ -11560,12 +11560,19 @@ async function run() { let wrongEnvironment = false; let unsuccessfulDeploy = false; // note: this while statement looks a bit weird because uses assignments as conditions: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/while#using_an_assignment_as_a_condition - // it's beneficial in this case because it prevents extra network requests from happening unnecessarily (i.e: we only check wrongEnvironment if sameAsInputTag is false, etc...) - while ((invalidReleaseBranch = !!lastSuccessfulDeploy?.head_branch) && + // it's beneficial in this case because: + // - keeping the async calls in the while loop conditional prevents extra network requests from happening unnecessarily (i.e: we only check wrongEnvironment if sameAsInputTag is false, etc...) + // - using conditional assignment, we can keep track of why a release is being skipped over for the sake of logs + debugging + while ( + // eslint-disable-next-line no-cond-assign + (invalidReleaseBranch = !!lastSuccessfulDeploy?.head_branch) && // we never want to compare a tag with itself. This check is necessary because prod deploys almost always have the same version as the last staging deploy. // In this case, the check for wrongEnvironment fails because the release that triggered that staging deploy is now finalized, so it looks like a prod deploy. + // eslint-disable-next-line no-cond-assign ((sameAsInputTag = lastSuccessfulDeploy?.head_branch === inputTag) || + // eslint-disable-next-line no-cond-assign (wrongEnvironment = await isReleaseValidBaseForEnvironment(lastSuccessfulDeploy?.head_branch, isProductionDeploy)) || + // eslint-disable-next-line no-cond-assign (unsuccessfulDeploy = !(await wasDeploySuccessful(lastSuccessfulDeploy.id))))) { let reason; if (invalidReleaseBranch) { From 995e116579b549e07d42f14f358d3e3d3ec85b5c Mon Sep 17 00:00:00 2001 From: rory Date: Thu, 15 Aug 2024 17:37:46 -0700 Subject: [PATCH 09/12] clean up while loop --- .../getDeployPullRequestList.ts | 63 +++++++++---------- .../getDeployPullRequestList/index.js | 58 +++++++---------- 2 files changed, 54 insertions(+), 67 deletions(-) diff --git a/.github/actions/javascript/getDeployPullRequestList/getDeployPullRequestList.ts b/.github/actions/javascript/getDeployPullRequestList/getDeployPullRequestList.ts index ddb71ccc6fad..2c295785d6a8 100644 --- a/.github/actions/javascript/getDeployPullRequestList/getDeployPullRequestList.ts +++ b/.github/actions/javascript/getDeployPullRequestList/getDeployPullRequestList.ts @@ -1,9 +1,12 @@ import * as core from '@actions/core'; import * as github from '@actions/github'; +import type {RestEndpointMethodTypes} from '@octokit/plugin-rest-endpoint-methods/dist-types/generated/parameters-and-response-types'; import {getJSONInput} from '@github/libs/ActionUtils'; import GithubUtils from '@github/libs/GithubUtils'; import GitUtils from '@github/libs/GitUtils'; +type WorkflowRun = RestEndpointMethodTypes['actions']['listWorkflowRuns']['response']['data']['workflow_runs'][number]; + /** * This function checks if a given release is a valid baseTag to get the PR list with `git log baseTag...endTag`. * @@ -45,6 +48,30 @@ async function wasDeploySuccessful(runID: number) { return jobsForWorkflowRun.some((job) => job.name.startsWith('Build and deploy') && job.conclusion === 'success'); } +/** + * This function checks if a given deploy workflow is a valid basis for comparison when listing PRs merged between two versions. + * It returns the reason a version should be skipped, or an empty string if the version should not be skipped. + */ +async function shouldSkipVersion(lastSuccessfulDeploy: WorkflowRun, inputTag: string, isProductionDeploy: boolean): Promise { + if (!lastSuccessfulDeploy?.head_branch) { + // This should never happen. Just doing this to appease TS. + return ''; + } + + // we never want to compare a tag with itself. This check is necessary because prod deploys almost always have the same version as the last staging deploy. + // In this case, the next for wrong environment fails because the release that triggered that staging deploy is now finalized, so it looks like a prod deploy. + if (lastSuccessfulDeploy?.head_branch === inputTag) { + return `Same as input tag ${inputTag}`; + } + if (!(await isReleaseValidBaseForEnvironment(lastSuccessfulDeploy?.head_branch, isProductionDeploy))) { + return 'Was a staging deploy, we only want to compare with other production deploys'; + } + if (!(await wasDeploySuccessful(lastSuccessfulDeploy.id))) { + return 'Was an unsuccessful deploy, nothing was deployed in that version'; + } + return ''; +} + async function run() { try { const inputTag = core.getInput('TAG', {required: true}); @@ -68,39 +95,9 @@ async function run() { // Find the most recent deploy workflow targeting the correct environment, for which at least one of the build jobs finished successfully let lastSuccessfulDeploy = completedDeploys.shift(); - let invalidReleaseBranch = false; - let sameAsInputTag = false; - let wrongEnvironment = false; - let unsuccessfulDeploy = false; - - // note: this while statement looks a bit weird because uses assignments as conditions: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/while#using_an_assignment_as_a_condition - // it's beneficial in this case because: - // - keeping the async calls in the while loop conditional prevents extra network requests from happening unnecessarily (i.e: we only check wrongEnvironment if sameAsInputTag is false, etc...) - // - using conditional assignment, we can keep track of why a release is being skipped over for the sake of logs + debugging - while ( - // eslint-disable-next-line no-cond-assign - (invalidReleaseBranch = !!lastSuccessfulDeploy?.head_branch) && - // we never want to compare a tag with itself. This check is necessary because prod deploys almost always have the same version as the last staging deploy. - // In this case, the check for wrongEnvironment fails because the release that triggered that staging deploy is now finalized, so it looks like a prod deploy. - // eslint-disable-next-line no-cond-assign - ((sameAsInputTag = lastSuccessfulDeploy?.head_branch === inputTag) || - // eslint-disable-next-line no-cond-assign - (wrongEnvironment = await isReleaseValidBaseForEnvironment(lastSuccessfulDeploy?.head_branch, isProductionDeploy)) || - // eslint-disable-next-line no-cond-assign - (unsuccessfulDeploy = !(await wasDeploySuccessful(lastSuccessfulDeploy.id)))) - ) { - let reason; - if (invalidReleaseBranch) { - reason = 'Invalid release branch'; - } else if (sameAsInputTag) { - reason = `Same as input tag ${inputTag}`; - } else if (wrongEnvironment) { - reason = `Was a ${isProductionDeploy ? 'staging' : 'production'} deploy, we only want to compare with ${isProductionDeploy ? 'production' : 'staging'} deploys`; - } else if (unsuccessfulDeploy) { - reason = 'Was an unsuccessful deploy'; - } else { - reason = 'WTF?!'; - } + let reason = ''; + // eslint-disable-next-line no-cond-assign + while (lastSuccessfulDeploy?.head_branch && (reason = await shouldSkipVersion(lastSuccessfulDeploy, inputTag, isProductionDeploy))) { console.log( `Deploy of tag ${lastSuccessfulDeploy?.head_branch} was not valid as a base for comparison, looking at the next one. Reason: ${reason}`, lastSuccessfulDeploy.html_url, diff --git a/.github/actions/javascript/getDeployPullRequestList/index.js b/.github/actions/javascript/getDeployPullRequestList/index.js index ece7077167a3..8a986d4b3c64 100644 --- a/.github/actions/javascript/getDeployPullRequestList/index.js +++ b/.github/actions/javascript/getDeployPullRequestList/index.js @@ -11537,6 +11537,28 @@ async function wasDeploySuccessful(runID) { })).data.jobs; return jobsForWorkflowRun.some((job) => job.name.startsWith('Build and deploy') && job.conclusion === 'success'); } +/** + * This function checks if a given deploy workflow is a valid basis for comparison when listing PRs merged between two versions. + * It returns the reason a version should be skipped, or an empty string if the version should not be skipped. + */ +async function shouldSkipVersion(lastSuccessfulDeploy, inputTag, isProductionDeploy) { + if (!lastSuccessfulDeploy?.head_branch) { + // This should never happen. Just doing this to appease TS. + return ''; + } + // we never want to compare a tag with itself. This check is necessary because prod deploys almost always have the same version as the last staging deploy. + // In this case, the next for wrong environment fails because the release that triggered that staging deploy is now finalized, so it looks like a prod deploy. + if (lastSuccessfulDeploy?.head_branch === inputTag) { + return `Same as input tag ${inputTag}`; + } + if (!(await isReleaseValidBaseForEnvironment(lastSuccessfulDeploy?.head_branch, isProductionDeploy))) { + return 'Was a staging deploy, we only want to compare with other production deploys'; + } + if (!(await wasDeploySuccessful(lastSuccessfulDeploy.id))) { + return 'Was an unsuccessful deploy, nothing was deployed in that version'; + } + return ''; +} async function run() { try { const inputTag = core.getInput('TAG', { required: true }); @@ -11555,41 +11577,9 @@ async function run() { .filter((workflowRun) => workflowRun.conclusion !== 'cancelled'); // Find the most recent deploy workflow targeting the correct environment, for which at least one of the build jobs finished successfully let lastSuccessfulDeploy = completedDeploys.shift(); - let invalidReleaseBranch = false; - let sameAsInputTag = false; - let wrongEnvironment = false; - let unsuccessfulDeploy = false; - // note: this while statement looks a bit weird because uses assignments as conditions: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/while#using_an_assignment_as_a_condition - // it's beneficial in this case because: - // - keeping the async calls in the while loop conditional prevents extra network requests from happening unnecessarily (i.e: we only check wrongEnvironment if sameAsInputTag is false, etc...) - // - using conditional assignment, we can keep track of why a release is being skipped over for the sake of logs + debugging - while ( + let reason = ''; // eslint-disable-next-line no-cond-assign - (invalidReleaseBranch = !!lastSuccessfulDeploy?.head_branch) && - // we never want to compare a tag with itself. This check is necessary because prod deploys almost always have the same version as the last staging deploy. - // In this case, the check for wrongEnvironment fails because the release that triggered that staging deploy is now finalized, so it looks like a prod deploy. - // eslint-disable-next-line no-cond-assign - ((sameAsInputTag = lastSuccessfulDeploy?.head_branch === inputTag) || - // eslint-disable-next-line no-cond-assign - (wrongEnvironment = await isReleaseValidBaseForEnvironment(lastSuccessfulDeploy?.head_branch, isProductionDeploy)) || - // eslint-disable-next-line no-cond-assign - (unsuccessfulDeploy = !(await wasDeploySuccessful(lastSuccessfulDeploy.id))))) { - let reason; - if (invalidReleaseBranch) { - reason = 'Invalid release branch'; - } - else if (sameAsInputTag) { - reason = `Same as input tag ${inputTag}`; - } - else if (wrongEnvironment) { - reason = `Was a ${isProductionDeploy ? 'staging' : 'production'} deploy, we only want to compare with ${isProductionDeploy ? 'production' : 'staging'} deploys`; - } - else if (unsuccessfulDeploy) { - reason = 'Was an unsuccessful deploy'; - } - else { - reason = 'WTF?!'; - } + while (lastSuccessfulDeploy?.head_branch && (reason = await shouldSkipVersion(lastSuccessfulDeploy, inputTag, isProductionDeploy))) { console.log(`Deploy of tag ${lastSuccessfulDeploy?.head_branch} was not valid as a base for comparison, looking at the next one. Reason: ${reason}`, lastSuccessfulDeploy.html_url); lastSuccessfulDeploy = completedDeploys.shift(); } From 8f66ccea15b1138bea7e53da25a2607f9b1d5f17 Mon Sep 17 00:00:00 2001 From: rory Date: Thu, 15 Aug 2024 17:42:08 -0700 Subject: [PATCH 10/12] Further clean up while loop --- .../getDeployPullRequestList.ts | 18 ++++++++++++------ .../getDeployPullRequestList/index.js | 15 +++++++++------ 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/.github/actions/javascript/getDeployPullRequestList/getDeployPullRequestList.ts b/.github/actions/javascript/getDeployPullRequestList/getDeployPullRequestList.ts index 2c295785d6a8..1f9dacfca834 100644 --- a/.github/actions/javascript/getDeployPullRequestList/getDeployPullRequestList.ts +++ b/.github/actions/javascript/getDeployPullRequestList/getDeployPullRequestList.ts @@ -95,18 +95,24 @@ async function run() { // Find the most recent deploy workflow targeting the correct environment, for which at least one of the build jobs finished successfully let lastSuccessfulDeploy = completedDeploys.shift(); - let reason = ''; - // eslint-disable-next-line no-cond-assign - while (lastSuccessfulDeploy?.head_branch && (reason = await shouldSkipVersion(lastSuccessfulDeploy, inputTag, isProductionDeploy))) { + + if (!lastSuccessfulDeploy) { + throw new Error('Could not find a prior successful deploy'); + } + + let reason = await shouldSkipVersion(lastSuccessfulDeploy, inputTag, isProductionDeploy); + while (lastSuccessfulDeploy && reason) { console.log( `Deploy of tag ${lastSuccessfulDeploy?.head_branch} was not valid as a base for comparison, looking at the next one. Reason: ${reason}`, lastSuccessfulDeploy.html_url, ); lastSuccessfulDeploy = completedDeploys.shift(); - } - if (!lastSuccessfulDeploy) { - throw new Error('Could not find a prior successful deploy'); + if (!lastSuccessfulDeploy) { + throw new Error('Could not find a prior successful deploy'); + } + + reason = await shouldSkipVersion(lastSuccessfulDeploy, inputTag, isProductionDeploy); } const priorTag = lastSuccessfulDeploy.head_branch; diff --git a/.github/actions/javascript/getDeployPullRequestList/index.js b/.github/actions/javascript/getDeployPullRequestList/index.js index 8a986d4b3c64..b36d3d54e36b 100644 --- a/.github/actions/javascript/getDeployPullRequestList/index.js +++ b/.github/actions/javascript/getDeployPullRequestList/index.js @@ -11577,15 +11577,18 @@ async function run() { .filter((workflowRun) => workflowRun.conclusion !== 'cancelled'); // Find the most recent deploy workflow targeting the correct environment, for which at least one of the build jobs finished successfully let lastSuccessfulDeploy = completedDeploys.shift(); - let reason = ''; - // eslint-disable-next-line no-cond-assign - while (lastSuccessfulDeploy?.head_branch && (reason = await shouldSkipVersion(lastSuccessfulDeploy, inputTag, isProductionDeploy))) { - console.log(`Deploy of tag ${lastSuccessfulDeploy?.head_branch} was not valid as a base for comparison, looking at the next one. Reason: ${reason}`, lastSuccessfulDeploy.html_url); - lastSuccessfulDeploy = completedDeploys.shift(); - } if (!lastSuccessfulDeploy) { throw new Error('Could not find a prior successful deploy'); } + let reason = await shouldSkipVersion(lastSuccessfulDeploy, inputTag, isProductionDeploy); + while (lastSuccessfulDeploy && reason) { + console.log(`Deploy of tag ${lastSuccessfulDeploy?.head_branch} was not valid as a base for comparison, looking at the next one. Reason: ${reason}`, lastSuccessfulDeploy.html_url); + lastSuccessfulDeploy = completedDeploys.shift(); + if (!lastSuccessfulDeploy) { + throw new Error('Could not find a prior successful deploy'); + } + reason = await shouldSkipVersion(lastSuccessfulDeploy, inputTag, isProductionDeploy); + } const priorTag = lastSuccessfulDeploy.head_branch; console.log(`Looking for PRs deployed to ${deployEnv} between ${priorTag} and ${inputTag}`); const prList = await GitUtils_1.default.getPullRequestsMergedBetween(priorTag ?? '', inputTag); From 5a7f15f6402469d9537825f764b1869353ff0f2d Mon Sep 17 00:00:00 2001 From: rory Date: Thu, 15 Aug 2024 17:44:39 -0700 Subject: [PATCH 11/12] Remove unnecessary optional chaining --- .../getDeployPullRequestList/getDeployPullRequestList.ts | 2 +- .github/actions/javascript/getDeployPullRequestList/index.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/actions/javascript/getDeployPullRequestList/getDeployPullRequestList.ts b/.github/actions/javascript/getDeployPullRequestList/getDeployPullRequestList.ts index 1f9dacfca834..c1004c765a94 100644 --- a/.github/actions/javascript/getDeployPullRequestList/getDeployPullRequestList.ts +++ b/.github/actions/javascript/getDeployPullRequestList/getDeployPullRequestList.ts @@ -103,7 +103,7 @@ async function run() { let reason = await shouldSkipVersion(lastSuccessfulDeploy, inputTag, isProductionDeploy); while (lastSuccessfulDeploy && reason) { console.log( - `Deploy of tag ${lastSuccessfulDeploy?.head_branch} was not valid as a base for comparison, looking at the next one. Reason: ${reason}`, + `Deploy of tag ${lastSuccessfulDeploy.head_branch} was not valid as a base for comparison, looking at the next one. Reason: ${reason}`, lastSuccessfulDeploy.html_url, ); lastSuccessfulDeploy = completedDeploys.shift(); diff --git a/.github/actions/javascript/getDeployPullRequestList/index.js b/.github/actions/javascript/getDeployPullRequestList/index.js index b36d3d54e36b..d9c3b1828e03 100644 --- a/.github/actions/javascript/getDeployPullRequestList/index.js +++ b/.github/actions/javascript/getDeployPullRequestList/index.js @@ -11582,7 +11582,7 @@ async function run() { } let reason = await shouldSkipVersion(lastSuccessfulDeploy, inputTag, isProductionDeploy); while (lastSuccessfulDeploy && reason) { - console.log(`Deploy of tag ${lastSuccessfulDeploy?.head_branch} was not valid as a base for comparison, looking at the next one. Reason: ${reason}`, lastSuccessfulDeploy.html_url); + console.log(`Deploy of tag ${lastSuccessfulDeploy.head_branch} was not valid as a base for comparison, looking at the next one. Reason: ${reason}`, lastSuccessfulDeploy.html_url); lastSuccessfulDeploy = completedDeploys.shift(); if (!lastSuccessfulDeploy) { throw new Error('Could not find a prior successful deploy'); From 0183ca514d292cacc1ea98c790b70c51143510c9 Mon Sep 17 00:00:00 2001 From: rory Date: Fri, 16 Aug 2024 13:15:23 -0700 Subject: [PATCH 12/12] Add constant and warning comment in workflow --- .../getDeployPullRequestList/getDeployPullRequestList.ts | 4 +++- .github/actions/javascript/getDeployPullRequestList/index.js | 3 ++- .github/workflows/platformDeploy.yml | 4 ++++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/actions/javascript/getDeployPullRequestList/getDeployPullRequestList.ts b/.github/actions/javascript/getDeployPullRequestList/getDeployPullRequestList.ts index c1004c765a94..da946b78a056 100644 --- a/.github/actions/javascript/getDeployPullRequestList/getDeployPullRequestList.ts +++ b/.github/actions/javascript/getDeployPullRequestList/getDeployPullRequestList.ts @@ -7,6 +7,8 @@ import GitUtils from '@github/libs/GitUtils'; type WorkflowRun = RestEndpointMethodTypes['actions']['listWorkflowRuns']['response']['data']['workflow_runs'][number]; +const BUILD_AND_DEPLOY_JOB_NAME_PREFIX = 'Build and deploy'; + /** * This function checks if a given release is a valid baseTag to get the PR list with `git log baseTag...endTag`. * @@ -45,7 +47,7 @@ async function wasDeploySuccessful(runID: number) { filter: 'latest', }) ).data.jobs; - return jobsForWorkflowRun.some((job) => job.name.startsWith('Build and deploy') && job.conclusion === 'success'); + return jobsForWorkflowRun.some((job) => job.name.startsWith(BUILD_AND_DEPLOY_JOB_NAME_PREFIX) && job.conclusion === 'success'); } /** diff --git a/.github/actions/javascript/getDeployPullRequestList/index.js b/.github/actions/javascript/getDeployPullRequestList/index.js index d9c3b1828e03..e8bd7057d40e 100644 --- a/.github/actions/javascript/getDeployPullRequestList/index.js +++ b/.github/actions/javascript/getDeployPullRequestList/index.js @@ -11502,6 +11502,7 @@ const github = __importStar(__nccwpck_require__(5438)); const ActionUtils_1 = __nccwpck_require__(6981); const GithubUtils_1 = __importDefault(__nccwpck_require__(9296)); const GitUtils_1 = __importDefault(__nccwpck_require__(1547)); +const BUILD_AND_DEPLOY_JOB_NAME_PREFIX = 'Build and deploy'; /** * This function checks if a given release is a valid baseTag to get the PR list with `git log baseTag...endTag`. * @@ -11535,7 +11536,7 @@ async function wasDeploySuccessful(runID) { run_id: runID, filter: 'latest', })).data.jobs; - return jobsForWorkflowRun.some((job) => job.name.startsWith('Build and deploy') && job.conclusion === 'success'); + return jobsForWorkflowRun.some((job) => job.name.startsWith(BUILD_AND_DEPLOY_JOB_NAME_PREFIX) && job.conclusion === 'success'); } /** * This function checks if a given deploy workflow is a valid basis for comparison when listing PRs merged between two versions. diff --git a/.github/workflows/platformDeploy.yml b/.github/workflows/platformDeploy.yml index 0004b2d3eaf8..9f81222898ad 100644 --- a/.github/workflows/platformDeploy.yml +++ b/.github/workflows/platformDeploy.yml @@ -38,6 +38,7 @@ jobs: secrets: inherit android: + # WARNING: getDeployPullRequestList depends on this job name. do not change job name without adjusting that action accordingly name: Build and deploy Android needs: validateActor if: ${{ fromJSON(needs.validateActor.outputs.IS_DEPLOYER) }} @@ -122,6 +123,7 @@ jobs: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} desktop: + # WARNING: getDeployPullRequestList depends on this job name. do not change job name without adjusting that action accordingly name: Build and deploy Desktop needs: validateActor if: ${{ fromJSON(needs.validateActor.outputs.IS_DEPLOYER) }} @@ -165,6 +167,7 @@ jobs: GITHUB_TOKEN: ${{ github.token }} iOS: + # WARNING: getDeployPullRequestList depends on this job name. do not change job name without adjusting that action accordingly name: Build and deploy iOS needs: validateActor if: ${{ fromJSON(needs.validateActor.outputs.IS_DEPLOYER) }} @@ -276,6 +279,7 @@ jobs: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} web: + # WARNING: getDeployPullRequestList depends on this job name. do not change job name without adjusting that action accordingly name: Build and deploy Web needs: validateActor if: ${{ fromJSON(needs.validateActor.outputs.IS_DEPLOYER) }}