Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/workflows/platformDeploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,16 @@ jobs:
env:
CF_API_KEY: ${{ secrets.CLOUDFLARE_TOKEN }}

# 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: ${{ !fromJSON(env.SHOULD_DEPLOY_PRODUCTION) }}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you move this if to a step level instead of the job level?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to move the entire job to a step for the tests to pass: #42166 (comment)

I just copied the existing step level if from all the other steps, but happy to adjust if there is something better

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kind of lame that the limitations in the tests are driving the workflow design, but in this case I guess it doesn't matter too much. This looks like it should work.

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
Expand Down
13 changes: 13 additions & 0 deletions workflow_tests/assertions/platformDeployAssertions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -376,13 +376,26 @@ function assertPostGithubCommentJobExecuted(workflowResult: Step[], didExecute =
});
}

function assertHybridAppJobExecuted(workflowResult: Step[], didExecute = true) {
const steps = [createStepAssertion('Deploy HybridApp', true, null, 'HYBRID_APP', 'Deploy HybridApp')] 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,
assertAndroidJobExecuted,
assertDesktopJobExecuted,
assertIOSJobExecuted,
assertWebJobExecuted,
assertHybridAppJobExecuted,
assertPostSlackOnFailureJobExecuted,
assertPostSlackOnSuccessJobExecuted,
assertPostGithubCommentJobExecuted,
Expand Down
5 changes: 5 additions & 0 deletions workflow_tests/mocks/platformDeployMocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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('Deploy 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',
Expand Down Expand Up @@ -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,
Expand Down
6 changes: 6 additions & 0 deletions workflow_tests/platformDeploy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -125,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);
assertions.assertPostSlackOnFailureJobExecuted(result, false);
assertions.assertPostSlackOnSuccessJobExecuted(result, true, false);
assertions.assertPostGithubCommentJobExecuted(result, true, false);
Expand Down Expand Up @@ -185,6 +187,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,
Expand All @@ -209,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);
assertions.assertPostSlackOnFailureJobExecuted(result, false);
assertions.assertPostSlackOnSuccessJobExecuted(result, true, false);
assertions.assertPostGithubCommentJobExecuted(result, true, false);
Expand Down Expand Up @@ -269,6 +273,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,
Expand All @@ -293,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);
Expand Down