From 4269bc6e8ca47c5a426c84e7054d4167f0555925 Mon Sep 17 00:00:00 2001 From: Andrew Gable Date: Tue, 4 Jun 2024 10:46:45 -0600 Subject: [PATCH 1/5] Add HybridApp deploy to platform deploy --- .github/workflows/platformDeploy.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/platformDeploy.yml b/.github/workflows/platformDeploy.yml index 353a898a941f..af63b6b65c55 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: ${{ 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 runs-on: ubuntu-latest From 04afde47f362c4572353278e9af6a3ad16938e03 Mon Sep 17 00:00:00 2001 From: Andrew Gable Date: Tue, 4 Jun 2024 13:16:38 -0600 Subject: [PATCH 2/5] Check the user can deploy --- .github/workflows/platformDeploy.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/platformDeploy.yml b/.github/workflows/platformDeploy.yml index af63b6b65c55..1d917262ace0 100644 --- a/.github/workflows/platformDeploy.yml +++ b/.github/workflows/platformDeploy.yml @@ -354,7 +354,8 @@ jobs: # Build a version of iOS and Android HybridApp if we are deploying to staging hybridApp: - if: ${{ github.event_name == 'push' }} + needs: validateActor + if: ${{ fromJSON(needs.validateActor.outputs.IS_DEPLOYER) && github.event_name == 'push' }} uses: Expensify/Mobile-Deploy/.github/workflows/deploy.yml@main postSlackMessageOnFailure: From 070618ff361ceb7cac1a8cb2dfbe6c243ec34af5 Mon Sep 17 00:00:00 2001 From: Github Date: Tue, 4 Jun 2024 14:48:12 -0600 Subject: [PATCH 3/5] Try different mock --- .github/workflows/platformDeploy.yml | 1 + .../assertions/platformDeployAssertions.ts | 13 +++++++++++++ workflow_tests/mocks/platformDeployMocks.ts | 5 +++++ workflow_tests/platformDeploy.test.ts | 15 +++++++++++++++ 4 files changed, 34 insertions(+) diff --git a/.github/workflows/platformDeploy.yml b/.github/workflows/platformDeploy.yml index 1d917262ace0..dacf1c9f42fa 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 needs: validateActor if: ${{ fromJSON(needs.validateActor.outputs.IS_DEPLOYER) && github.event_name == 'push' }} uses: Expensify/Mobile-Deploy/.github/workflows/deploy.yml@main diff --git a/workflow_tests/assertions/platformDeployAssertions.ts b/workflow_tests/assertions/platformDeployAssertions.ts index 24bb91f001f6..9b6f0208a58f 100644 --- a/workflow_tests/assertions/platformDeployAssertions.ts +++ b/workflow_tests/assertions/platformDeployAssertions.ts @@ -25,6 +25,18 @@ function assertDeployChecklistJobExecuted(workflowResult: Step[], didExecute = t }); } +function assertHybridAppJobExecuted(workflowResult: Step[], didExecute = true) { + const steps = [createStepAssertion('hybridApp', true, null, 'HYBRID_APP', 'Run hybridApp')] as const; + + steps.forEach((expectedStep) => { + if (didExecute) { + expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); + } else { + expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); + } + }); +} + function assertAndroidJobExecuted(workflowResult: Step[], didExecute = true, isProduction = true, isSuccessful = true) { const steps = [ createStepAssertion('Checkout', true, null, 'ANDROID', 'Checking out'), @@ -379,6 +391,7 @@ function assertPostGithubCommentJobExecuted(workflowResult: Step[], didExecute = export default { assertVerifyActorJobExecuted, assertDeployChecklistJobExecuted, + assertHybridAppJobExecuted, assertAndroidJobExecuted, assertDesktopJobExecuted, assertIOSJobExecuted, diff --git a/workflow_tests/mocks/platformDeployMocks.ts b/workflow_tests/mocks/platformDeployMocks.ts index 9d5727bbf5f5..6f2647329683 100644 --- a/workflow_tests/mocks/platformDeployMocks.ts +++ b/workflow_tests/mocks/platformDeployMocks.ts @@ -199,6 +199,10 @@ const PLATFORM_DEPLOY__WEB__STEP_MOCKS = [ PLATFORM_DEPLOY__WEB__PURGE_STAGING_CACHE__STEP_MOCK, ]; +// deploy hybridApp +const PLATFORM_DEPLOY__HYBRID_APP__STEP_MOCK = createMockStep('hybridApp', 'Deploy HybridApp', 'HYBRID_APP'); +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', [ 'SLACK_WEBHOOK', @@ -274,6 +278,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..ff256b5868dc 100644 --- a/workflow_tests/platformDeploy.test.ts +++ b/workflow_tests/platformDeploy.test.ts @@ -110,6 +110,10 @@ describe('test workflow platformDeploy', () => { steps: mocks.PLATFORM_DEPLOY__DEPLOY_CHECKLIST__STEP_MOCKS, runsOn: 'ubuntu-latest', }, + hybridApp: { + steps: mocks.PLATFORM_DEPLOY__HYBRID_APP__STEP_MOCKS, + runsOn: 'ubuntu-latest', + }, }; const result = await act.runEvent('push', { workflowFile: path.join(repoPath, '.github', 'workflows', 'platformDeploy.yml'), @@ -121,6 +125,7 @@ describe('test workflow platformDeploy', () => { assertions.assertVerifyActorJobExecuted(result); assertions.assertDeployChecklistJobExecuted(result, true); + assertions.assertHybridAppJobExecuted(result, true); assertions.assertAndroidJobExecuted(result, true, false, true); assertions.assertDesktopJobExecuted(result, true, false); assertions.assertIOSJobExecuted(result, true, false, true); @@ -194,6 +199,10 @@ describe('test workflow platformDeploy', () => { steps: mocks.PLATFORM_DEPLOY__DEPLOY_CHECKLIST__STEP_MOCKS, runsOn: 'ubuntu-latest', }, + hybridApp: { + steps: mocks.PLATFORM_DEPLOY__HYBRID_APP__STEP_MOCKS, + runsOn: 'ubuntu-latest', + }, }; const result = await act.runEvent('push', { workflowFile: path.join(repoPath, '.github', 'workflows', 'platformDeploy.yml'), @@ -205,6 +214,7 @@ describe('test workflow platformDeploy', () => { assertions.assertVerifyActorJobExecuted(result); assertions.assertDeployChecklistJobExecuted(result, true); + assertions.assertHybridAppJobExecuted(result, true); assertions.assertAndroidJobExecuted(result, true, false, true); assertions.assertDesktopJobExecuted(result, true, false); assertions.assertIOSJobExecuted(result, true, false, true); @@ -278,6 +288,10 @@ describe('test workflow platformDeploy', () => { steps: mocks.PLATFORM_DEPLOY__DEPLOY_CHECKLIST__STEP_MOCKS, runsOn: 'ubuntu-latest', }, + hybridApp: { + steps: mocks.PLATFORM_DEPLOY__HYBRID_APP__STEP_MOCKS, + runsOn: 'ubuntu-latest', + }, }; const result = await act.runEvent('push', { workflowFile: path.join(repoPath, '.github', 'workflows', 'platformDeploy.yml'), @@ -289,6 +303,7 @@ describe('test workflow platformDeploy', () => { assertions.assertVerifyActorJobExecuted(result); assertions.assertDeployChecklistJobExecuted(result, true); + assertions.assertHybridAppJobExecuted(result, true); assertions.assertAndroidJobExecuted(result, false); assertions.assertDesktopJobExecuted(result, false); assertions.assertIOSJobExecuted(result, false); From 8f44790aed133bd5d913e58b65b97996d242887c Mon Sep 17 00:00:00 2001 From: Github Date: Tue, 4 Jun 2024 14:55:22 -0600 Subject: [PATCH 4/5] Remove assertions --- workflow_tests/platformDeploy.test.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/workflow_tests/platformDeploy.test.ts b/workflow_tests/platformDeploy.test.ts index ff256b5868dc..cb8f0000212a 100644 --- a/workflow_tests/platformDeploy.test.ts +++ b/workflow_tests/platformDeploy.test.ts @@ -125,7 +125,6 @@ describe('test workflow platformDeploy', () => { assertions.assertVerifyActorJobExecuted(result); assertions.assertDeployChecklistJobExecuted(result, true); - assertions.assertHybridAppJobExecuted(result, true); assertions.assertAndroidJobExecuted(result, true, false, true); assertions.assertDesktopJobExecuted(result, true, false); assertions.assertIOSJobExecuted(result, true, false, true); @@ -214,7 +213,6 @@ describe('test workflow platformDeploy', () => { assertions.assertVerifyActorJobExecuted(result); assertions.assertDeployChecklistJobExecuted(result, true); - assertions.assertHybridAppJobExecuted(result, true); assertions.assertAndroidJobExecuted(result, true, false, true); assertions.assertDesktopJobExecuted(result, true, false); assertions.assertIOSJobExecuted(result, true, false, true); @@ -303,7 +301,6 @@ describe('test workflow platformDeploy', () => { assertions.assertVerifyActorJobExecuted(result); assertions.assertDeployChecklistJobExecuted(result, true); - assertions.assertHybridAppJobExecuted(result, true); assertions.assertAndroidJobExecuted(result, false); assertions.assertDesktopJobExecuted(result, false); assertions.assertIOSJobExecuted(result, false); From 732a375e21bd8611b46f0e0878665aabc7dd40b4 Mon Sep 17 00:00:00 2001 From: Github Date: Tue, 4 Jun 2024 15:07:08 -0600 Subject: [PATCH 5/5] Fix tests --- workflow_tests/assertions/platformDeployAssertions.ts | 2 +- workflow_tests/platformDeploy.test.ts | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/workflow_tests/assertions/platformDeployAssertions.ts b/workflow_tests/assertions/platformDeployAssertions.ts index 9b6f0208a58f..fa61d4ef01ff 100644 --- a/workflow_tests/assertions/platformDeployAssertions.ts +++ b/workflow_tests/assertions/platformDeployAssertions.ts @@ -26,7 +26,7 @@ function assertDeployChecklistJobExecuted(workflowResult: Step[], didExecute = t } function assertHybridAppJobExecuted(workflowResult: Step[], didExecute = true) { - const steps = [createStepAssertion('hybridApp', true, null, 'HYBRID_APP', 'Run hybridApp')] as const; + const steps = [createStepAssertion('hybridApp', true, null, 'HYBRID_APP', 'Deploy HybridApp')] as const; steps.forEach((expectedStep) => { if (didExecute) { diff --git a/workflow_tests/platformDeploy.test.ts b/workflow_tests/platformDeploy.test.ts index cb8f0000212a..5199d6bd08be 100644 --- a/workflow_tests/platformDeploy.test.ts +++ b/workflow_tests/platformDeploy.test.ts @@ -125,6 +125,7 @@ describe('test workflow platformDeploy', () => { assertions.assertVerifyActorJobExecuted(result); assertions.assertDeployChecklistJobExecuted(result, true); + assertions.assertHybridAppJobExecuted(result, true); assertions.assertAndroidJobExecuted(result, true, false, true); assertions.assertDesktopJobExecuted(result, true, false); assertions.assertIOSJobExecuted(result, true, false, true); @@ -213,6 +214,7 @@ describe('test workflow platformDeploy', () => { assertions.assertVerifyActorJobExecuted(result); assertions.assertDeployChecklistJobExecuted(result, true); + assertions.assertHybridAppJobExecuted(result, true); assertions.assertAndroidJobExecuted(result, true, false, true); assertions.assertDesktopJobExecuted(result, true, false); assertions.assertIOSJobExecuted(result, true, false, true); @@ -301,6 +303,7 @@ describe('test workflow platformDeploy', () => { assertions.assertVerifyActorJobExecuted(result); assertions.assertDeployChecklistJobExecuted(result, true); + assertions.assertHybridAppJobExecuted(result, false); assertions.assertAndroidJobExecuted(result, false); assertions.assertDesktopJobExecuted(result, false); assertions.assertIOSJobExecuted(result, false);