From 1d58aeeb51c5a8d2bc611addb17e9d7019a970eb Mon Sep 17 00:00:00 2001 From: Andrew Gable Date: Tue, 14 May 2024 13:04:14 -0600 Subject: [PATCH 01/10] Add HybridApp deploy when we deploy staging --- .github/workflows/platformDeploy.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/platformDeploy.yml b/.github/workflows/platformDeploy.yml index 353a898a941f..8ad1da26fc47 100644 --- a/.github/workflows/platformDeploy.yml +++ b/.github/workflows/platformDeploy.yml @@ -352,6 +352,11 @@ jobs: env: CF_API_KEY: ${{ secrets.CLOUDFLARE_TOKEN }} + # Build a version of iOS and Android HybridApp if we are deploying to staging + hybridApp: + if: ${{ !fromJSON(env.SHOULD_DEPLOY_PRODUCTION) }} + uses: Expensify/Mobile-Deploy/.github/workflows/deploy.yml@main + postSlackMessageOnFailure: name: Post a Slack message when any platform fails to build or deploy runs-on: ubuntu-latest From a78fbcfa85e1a302a2f918760ed6a156bf8efd11 Mon Sep 17 00:00:00 2001 From: Andrew Gable Date: Tue, 14 May 2024 13:15:53 -0600 Subject: [PATCH 02/10] Tweak to github env variable --- .github/workflows/platformDeploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/platformDeploy.yml b/.github/workflows/platformDeploy.yml index 8ad1da26fc47..1a7c862b6d4f 100644 --- a/.github/workflows/platformDeploy.yml +++ b/.github/workflows/platformDeploy.yml @@ -354,7 +354,7 @@ jobs: # Build a version of iOS and Android HybridApp if we are deploying to staging hybridApp: - if: ${{ !fromJSON(env.SHOULD_DEPLOY_PRODUCTION) }} + if: ${{ github.event_name == 'release' }} uses: Expensify/Mobile-Deploy/.github/workflows/deploy.yml@main postSlackMessageOnFailure: From 03ad341995b7ffc1276de4221af0aa30cd5c1c17 Mon Sep 17 00:00:00 2001 From: Andrew Gable Date: Thu, 23 May 2024 16:40:42 -0600 Subject: [PATCH 03/10] Update .github/workflows/platformDeploy.yml Co-authored-by: Rory Abraham <47436092+roryabraham@users.noreply.github.com> --- .github/workflows/platformDeploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/platformDeploy.yml b/.github/workflows/platformDeploy.yml index 1a7c862b6d4f..af63b6b65c55 100644 --- a/.github/workflows/platformDeploy.yml +++ b/.github/workflows/platformDeploy.yml @@ -354,7 +354,7 @@ jobs: # Build a version of iOS and Android HybridApp if we are deploying to staging hybridApp: - if: ${{ github.event_name == 'release' }} + if: ${{ github.event_name == 'push' }} uses: Expensify/Mobile-Deploy/.github/workflows/deploy.yml@main postSlackMessageOnFailure: From 367b36948cd5b2a397b641d9b73672b2dc56e5a3 Mon Sep 17 00:00:00 2001 From: Andrew Gable Date: Fri, 31 May 2024 10:33:13 -0600 Subject: [PATCH 04/10] Start fixing tests --- .github/workflows/platformDeploy.yml | 1 + workflow_tests/mocks/platformDeployMocks.ts | 4 ++++ workflow_tests/platformDeploy.test.ts | 3 +++ 3 files changed, 8 insertions(+) diff --git a/.github/workflows/platformDeploy.yml b/.github/workflows/platformDeploy.yml index af63b6b65c55..680aedf182eb 100644 --- a/.github/workflows/platformDeploy.yml +++ b/.github/workflows/platformDeploy.yml @@ -354,6 +354,7 @@ jobs: # Build a version of iOS and Android HybridApp if we are deploying to staging hybridApp: + name: 'Deploy HybridApp' if: ${{ github.event_name == 'push' }} uses: Expensify/Mobile-Deploy/.github/workflows/deploy.yml@main diff --git a/workflow_tests/mocks/platformDeployMocks.ts b/workflow_tests/mocks/platformDeployMocks.ts index 9d5727bbf5f5..46da36b93a11 100644 --- a/workflow_tests/mocks/platformDeployMocks.ts +++ b/workflow_tests/mocks/platformDeployMocks.ts @@ -199,6 +199,9 @@ const PLATFORM_DEPLOY__WEB__STEP_MOCKS = [ PLATFORM_DEPLOY__WEB__PURGE_STAGING_CACHE__STEP_MOCK, ]; +// deploy hybridAoo +const PLATFORM_DEPLOY__HYBRID_APP__STEP_MOCKS = [createMockStep('hybridApp', 'Deploy HybridApp', 'DEPLOY_CHECKLIST')]; + // post slack message on failure const PLATFORM_DEPLOY__POST_SLACK_FAIL__POST_SLACK__STEP_MOCK = createMockStep('Post Slack message on failure', 'Posting Slack message on platform deploy failure', 'POST_SLACK_FAIL', [ 'SLACK_WEBHOOK', @@ -274,6 +277,7 @@ export default { PLATFORM_DEPLOY__DESKTOP__STEP_MOCKS, PLATFORM_DEPLOY__IOS__STEP_MOCKS, PLATFORM_DEPLOY__WEB__STEP_MOCKS, + PLATFORM_DEPLOY__HYBRID_APP__STEP_MOCKS, PLATFORM_DEPLOY__POST_SLACK_FAIL__STEP_MOCKS, PLATFORM_DEPLOY__POST_SLACK_SUCCESS__STEP_MOCKS, PLATFORM_DEPLOY__POST_GITHUB_COMMENT__STEP_MOCKS, diff --git a/workflow_tests/platformDeploy.test.ts b/workflow_tests/platformDeploy.test.ts index 0ac68eb6d55b..c60c31ea54df 100644 --- a/workflow_tests/platformDeploy.test.ts +++ b/workflow_tests/platformDeploy.test.ts @@ -101,6 +101,7 @@ describe('test workflow platformDeploy', () => { desktop: mocks.PLATFORM_DEPLOY__DESKTOP__STEP_MOCKS, iOS: mocks.PLATFORM_DEPLOY__IOS__STEP_MOCKS, web: mocks.PLATFORM_DEPLOY__WEB__STEP_MOCKS, + hybridApp: mocks.PLATFORM_DEPLOY__HYBRID_APP__STEP_MOCKS, postSlackMessageOnFailure: mocks.PLATFORM_DEPLOY__POST_SLACK_FAIL__STEP_MOCKS, postSlackMessageOnSuccess: mocks.PLATFORM_DEPLOY__POST_SLACK_SUCCESS__STEP_MOCKS, postGithubComment: mocks.PLATFORM_DEPLOY__POST_GITHUB_COMMENT__STEP_MOCKS, @@ -185,6 +186,7 @@ describe('test workflow platformDeploy', () => { desktop: mocks.PLATFORM_DEPLOY__DESKTOP__STEP_MOCKS, iOS: mocks.PLATFORM_DEPLOY__IOS__STEP_MOCKS, web: mocks.PLATFORM_DEPLOY__WEB__STEP_MOCKS, + hybridApp: mocks.PLATFORM_DEPLOY__HYBRID_APP__STEP_MOCKS, postSlackMessageOnFailure: mocks.PLATFORM_DEPLOY__POST_SLACK_FAIL__STEP_MOCKS, postSlackMessageOnSuccess: mocks.PLATFORM_DEPLOY__POST_SLACK_SUCCESS__STEP_MOCKS, postGithubComment: mocks.PLATFORM_DEPLOY__POST_GITHUB_COMMENT__STEP_MOCKS, @@ -269,6 +271,7 @@ describe('test workflow platformDeploy', () => { desktop: mocks.PLATFORM_DEPLOY__DESKTOP__STEP_MOCKS, iOS: mocks.PLATFORM_DEPLOY__IOS__STEP_MOCKS, web: mocks.PLATFORM_DEPLOY__WEB__STEP_MOCKS, + hybridApp: mocks.PLATFORM_DEPLOY__HYBRID_APP__STEP_MOCKS, postSlackMessageOnFailure: mocks.PLATFORM_DEPLOY__POST_SLACK_FAIL__STEP_MOCKS, postSlackMessageOnSuccess: mocks.PLATFORM_DEPLOY__POST_SLACK_SUCCESS__STEP_MOCKS, postGithubComment: mocks.PLATFORM_DEPLOY__POST_GITHUB_COMMENT__STEP_MOCKS, From 0d10695cc72cfd79c11920c605eeb7cc22d9d1fe Mon Sep 17 00:00:00 2001 From: Andrew Gable Date: Fri, 31 May 2024 10:42:04 -0600 Subject: [PATCH 05/10] Fix ID --- workflow_tests/mocks/platformDeployMocks.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/workflow_tests/mocks/platformDeployMocks.ts b/workflow_tests/mocks/platformDeployMocks.ts index 46da36b93a11..fd5986b2d7b2 100644 --- a/workflow_tests/mocks/platformDeployMocks.ts +++ b/workflow_tests/mocks/platformDeployMocks.ts @@ -199,8 +199,9 @@ const PLATFORM_DEPLOY__WEB__STEP_MOCKS = [ PLATFORM_DEPLOY__WEB__PURGE_STAGING_CACHE__STEP_MOCK, ]; -// deploy hybridAoo -const PLATFORM_DEPLOY__HYBRID_APP__STEP_MOCKS = [createMockStep('hybridApp', 'Deploy HybridApp', 'DEPLOY_CHECKLIST')]; +// deploy hybridApp +const PLATFORM_DEPLOY__HYBRID_APP__STEP_MOCK = createMockStep('hybridApp', 'Deploy HybridApp', 'HYBRID_APP_DEPLOY'); +const PLATFORM_DEPLOY__HYBRID_APP__STEP_MOCKS = [PLATFORM_DEPLOY__HYBRID_APP__STEP_MOCK]; // post slack message on failure const PLATFORM_DEPLOY__POST_SLACK_FAIL__POST_SLACK__STEP_MOCK = createMockStep('Post Slack message on failure', 'Posting Slack message on platform deploy failure', 'POST_SLACK_FAIL', [ From 697e9abe626082597eebe10933c7436f574f4f1b Mon Sep 17 00:00:00 2001 From: Andrew Gable Date: Fri, 31 May 2024 11:19:31 -0600 Subject: [PATCH 06/10] Try mocking hybridApp --- .github/workflows/platformDeploy.yml | 8 +++++--- .../assertions/platformDeployAssertions.ts | 13 +++++++++++++ workflow_tests/mocks/platformDeployMocks.ts | 2 +- workflow_tests/platformDeploy.test.ts | 3 +++ 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/.github/workflows/platformDeploy.yml b/.github/workflows/platformDeploy.yml index 680aedf182eb..3b3c1c12739f 100644 --- a/.github/workflows/platformDeploy.yml +++ b/.github/workflows/platformDeploy.yml @@ -354,9 +354,11 @@ jobs: # Build a version of iOS and Android HybridApp if we are deploying to staging hybridApp: - name: 'Deploy HybridApp' - if: ${{ github.event_name == 'push' }} - uses: Expensify/Mobile-Deploy/.github/workflows/deploy.yml@main + runs-on: ubuntu-latest + steps: + - name: 'Deploy HybridApp' + if: ${{ github.event_name == 'push' }} + uses: Expensify/Mobile-Deploy/.github/workflows/deploy.yml@main postSlackMessageOnFailure: name: Post a Slack message when any platform fails to build or deploy diff --git a/workflow_tests/assertions/platformDeployAssertions.ts b/workflow_tests/assertions/platformDeployAssertions.ts index 24bb91f001f6..03ecfcafa94a 100644 --- a/workflow_tests/assertions/platformDeployAssertions.ts +++ b/workflow_tests/assertions/platformDeployAssertions.ts @@ -376,6 +376,18 @@ function assertPostGithubCommentJobExecuted(workflowResult: Step[], didExecute = }); } +function assertHybridAppJobExecuted(workflowResult: Step[], didExecute = true, isProduction = true, didDeploy = true) { + const steps = [] as const; + + steps.forEach((expectedStep) => { + if (didExecute) { + expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); + } else { + expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); + } + }); +} + export default { assertVerifyActorJobExecuted, assertDeployChecklistJobExecuted, @@ -383,6 +395,7 @@ export default { assertDesktopJobExecuted, assertIOSJobExecuted, assertWebJobExecuted, + assertHybridAppJobExecuted, assertPostSlackOnFailureJobExecuted, assertPostSlackOnSuccessJobExecuted, assertPostGithubCommentJobExecuted, diff --git a/workflow_tests/mocks/platformDeployMocks.ts b/workflow_tests/mocks/platformDeployMocks.ts index fd5986b2d7b2..ca6e05b57f8e 100644 --- a/workflow_tests/mocks/platformDeployMocks.ts +++ b/workflow_tests/mocks/platformDeployMocks.ts @@ -200,7 +200,7 @@ const PLATFORM_DEPLOY__WEB__STEP_MOCKS = [ ]; // deploy hybridApp -const PLATFORM_DEPLOY__HYBRID_APP__STEP_MOCK = createMockStep('hybridApp', 'Deploy HybridApp', 'HYBRID_APP_DEPLOY'); +const PLATFORM_DEPLOY__HYBRID_APP__STEP_MOCK = createMockStep('Deploy HybridApp', 'Deploy HybridApp', 'HYBRID_APP'); const PLATFORM_DEPLOY__HYBRID_APP__STEP_MOCKS = [PLATFORM_DEPLOY__HYBRID_APP__STEP_MOCK]; // post slack message on failure diff --git a/workflow_tests/platformDeploy.test.ts b/workflow_tests/platformDeploy.test.ts index c60c31ea54df..791e130479b8 100644 --- a/workflow_tests/platformDeploy.test.ts +++ b/workflow_tests/platformDeploy.test.ts @@ -126,6 +126,7 @@ describe('test workflow platformDeploy', () => { assertions.assertDesktopJobExecuted(result, true, false); assertions.assertIOSJobExecuted(result, true, false, true); assertions.assertWebJobExecuted(result, true, false); + assertions.assertHybridAppJobExecuted(result, true, false); assertions.assertPostSlackOnFailureJobExecuted(result, false); assertions.assertPostSlackOnSuccessJobExecuted(result, true, false); assertions.assertPostGithubCommentJobExecuted(result, true, false); @@ -211,6 +212,7 @@ describe('test workflow platformDeploy', () => { assertions.assertDesktopJobExecuted(result, true, false); assertions.assertIOSJobExecuted(result, true, false, true); assertions.assertWebJobExecuted(result, true, false); + assertions.assertHybridAppJobExecuted(result, true, false); assertions.assertPostSlackOnFailureJobExecuted(result, false); assertions.assertPostSlackOnSuccessJobExecuted(result, true, false); assertions.assertPostGithubCommentJobExecuted(result, true, false); @@ -296,6 +298,7 @@ describe('test workflow platformDeploy', () => { assertions.assertDesktopJobExecuted(result, false); assertions.assertIOSJobExecuted(result, false); assertions.assertWebJobExecuted(result, false); + assertions.assertHybridAppJobExecuted(result, false); assertions.assertPostSlackOnFailureJobExecuted(result, false); assertions.assertPostSlackOnSuccessJobExecuted(result, false); assertions.assertPostGithubCommentJobExecuted(result, true, false, false); From d2d455f2abcb02417022ace5a6ff48b3f8abdb52 Mon Sep 17 00:00:00 2001 From: Andrew Gable Date: Fri, 31 May 2024 13:17:49 -0600 Subject: [PATCH 07/10] Add assertion --- workflow_tests/assertions/platformDeployAssertions.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/workflow_tests/assertions/platformDeployAssertions.ts b/workflow_tests/assertions/platformDeployAssertions.ts index 03ecfcafa94a..2920cc2bff27 100644 --- a/workflow_tests/assertions/platformDeployAssertions.ts +++ b/workflow_tests/assertions/platformDeployAssertions.ts @@ -377,7 +377,7 @@ function assertPostGithubCommentJobExecuted(workflowResult: Step[], didExecute = } function assertHybridAppJobExecuted(workflowResult: Step[], didExecute = true, isProduction = true, didDeploy = true) { - const steps = [] as const; + const steps = [createStepAssertion('Deploy HybridApp', true, null, 'HYBRID_APP')] as const; steps.forEach((expectedStep) => { if (didExecute) { From e24d160d5383690e686c13c1392468ac1fffb4f3 Mon Sep 17 00:00:00 2001 From: Andrew Gable Date: Fri, 31 May 2024 17:46:11 -0600 Subject: [PATCH 08/10] Fix test --- .github/workflows/platformDeploy.yml | 4 +++- workflow_tests/assertions/platformDeployAssertions.ts | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/platformDeploy.yml b/.github/workflows/platformDeploy.yml index 3b3c1c12739f..bb24a1be5e5c 100644 --- a/.github/workflows/platformDeploy.yml +++ b/.github/workflows/platformDeploy.yml @@ -355,9 +355,11 @@ jobs: # Build a version of iOS and Android HybridApp if we are deploying to staging hybridApp: runs-on: ubuntu-latest + needs: validateActor + if: ${{ fromJSON(needs.validateActor.outputs.IS_DEPLOYER) }} steps: - name: 'Deploy HybridApp' - if: ${{ github.event_name == 'push' }} + if: ${{ !fromJSON(env.SHOULD_DEPLOY_PRODUCTION) }} uses: Expensify/Mobile-Deploy/.github/workflows/deploy.yml@main postSlackMessageOnFailure: diff --git a/workflow_tests/assertions/platformDeployAssertions.ts b/workflow_tests/assertions/platformDeployAssertions.ts index 2920cc2bff27..4cede6156be0 100644 --- a/workflow_tests/assertions/platformDeployAssertions.ts +++ b/workflow_tests/assertions/platformDeployAssertions.ts @@ -377,7 +377,7 @@ function assertPostGithubCommentJobExecuted(workflowResult: Step[], didExecute = } function assertHybridAppJobExecuted(workflowResult: Step[], didExecute = true, isProduction = true, didDeploy = true) { - const steps = [createStepAssertion('Deploy HybridApp', true, null, 'HYBRID_APP')] as const; + const steps = [createStepAssertion('Deploy HybridApp', true, null, 'HYBRID_APP', 'Deploy HybridApp')] as const; steps.forEach((expectedStep) => { if (didExecute) { From 50dd4e39c27f46f73cead50d8b3e22fb983def69 Mon Sep 17 00:00:00 2001 From: Andrew Gable Date: Fri, 31 May 2024 17:53:23 -0600 Subject: [PATCH 09/10] Fix lint --- workflow_tests/assertions/platformDeployAssertions.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/workflow_tests/assertions/platformDeployAssertions.ts b/workflow_tests/assertions/platformDeployAssertions.ts index 4cede6156be0..c92d3dda97d0 100644 --- a/workflow_tests/assertions/platformDeployAssertions.ts +++ b/workflow_tests/assertions/platformDeployAssertions.ts @@ -376,7 +376,7 @@ function assertPostGithubCommentJobExecuted(workflowResult: Step[], didExecute = }); } -function assertHybridAppJobExecuted(workflowResult: Step[], didExecute = true, isProduction = true, didDeploy = true) { +function assertHybridAppJobExecuted(workflowResult: Step[], didExecute = true) { const steps = [createStepAssertion('Deploy HybridApp', true, null, 'HYBRID_APP', 'Deploy HybridApp')] as const; steps.forEach((expectedStep) => { From 03a564dc52204640ee7947411ae839da2b4ba4e5 Mon Sep 17 00:00:00 2001 From: Andrew Gable Date: Fri, 31 May 2024 17:56:42 -0600 Subject: [PATCH 10/10] Fix ts --- workflow_tests/platformDeploy.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/workflow_tests/platformDeploy.test.ts b/workflow_tests/platformDeploy.test.ts index 791e130479b8..98fd9b933df4 100644 --- a/workflow_tests/platformDeploy.test.ts +++ b/workflow_tests/platformDeploy.test.ts @@ -126,7 +126,7 @@ describe('test workflow platformDeploy', () => { assertions.assertDesktopJobExecuted(result, true, false); assertions.assertIOSJobExecuted(result, true, false, true); assertions.assertWebJobExecuted(result, true, false); - assertions.assertHybridAppJobExecuted(result, true, false); + assertions.assertHybridAppJobExecuted(result, true); assertions.assertPostSlackOnFailureJobExecuted(result, false); assertions.assertPostSlackOnSuccessJobExecuted(result, true, false); assertions.assertPostGithubCommentJobExecuted(result, true, false); @@ -212,7 +212,7 @@ describe('test workflow platformDeploy', () => { assertions.assertDesktopJobExecuted(result, true, false); assertions.assertIOSJobExecuted(result, true, false, true); assertions.assertWebJobExecuted(result, true, false); - assertions.assertHybridAppJobExecuted(result, true, false); + assertions.assertHybridAppJobExecuted(result, true); assertions.assertPostSlackOnFailureJobExecuted(result, false); assertions.assertPostSlackOnSuccessJobExecuted(result, true, false); assertions.assertPostGithubCommentJobExecuted(result, true, false);