From 96a51bbe02aea2e7bb68f56a0cc4a27345cc994c Mon Sep 17 00:00:00 2001 From: rory Date: Mon, 15 Jul 2024 12:40:30 -0700 Subject: [PATCH] Fix more mocks and assertions --- .../assertions/platformDeployAssertions.ts | 112 ++++++------------ workflow_tests/mocks/platformDeployMocks.ts | 6 +- workflow_tests/platformDeploy.test.ts | 1 + 3 files changed, 40 insertions(+), 79 deletions(-) diff --git a/workflow_tests/assertions/platformDeployAssertions.ts b/workflow_tests/assertions/platformDeployAssertions.ts index 0df3e46d9b81..364dabede6ea 100644 --- a/workflow_tests/assertions/platformDeployAssertions.ts +++ b/workflow_tests/assertions/platformDeployAssertions.ts @@ -49,32 +49,26 @@ function assertAndroidJobExecuted(workflowResult: Step[], didExecute = true, isP createStepAssertion('Decrypt keystore', true, null, 'ANDROID', 'Decrypting keystore', null, [{key: 'LARGE_SECRET_PASSPHRASE', value: '***'}]), createStepAssertion('Decrypt json key', true, null, 'ANDROID', 'Decrypting JSON key', null, [{key: 'LARGE_SECRET_PASSPHRASE', value: '***'}]), createStepAssertion('Set version in ENV', true, null, 'ANDROID', 'Setting version in ENV'), - ]; - - if (!isProduction) { - steps.push( - createStepAssertion('Run Fastlane beta', true, null, 'ANDROID', 'Running Fastlane beta', null, [ - {key: 'MYAPP_UPLOAD_STORE_PASSWORD', value: '***'}, - {key: 'MYAPP_UPLOAD_KEY_PASSWORD', value: '***'}, - ]), - ); - } else { - steps.push(createStepAssertion('Run Fastlane production', true, null, 'ANDROID', 'Running Fastlane production', null, [{key: 'VERSION', value: '1.2.3'}])); - } - steps.push( + createStepAssertion('Run Fastlane', true, null, 'ANDROID', 'Running Fastlane', null, [ + {key: 'RUBYOPT', value: '-rostruct'}, + {key: 'MYAPP_UPLOAD_STORE_PASSWORD', value: '***'}, + {key: 'MYAPP_UPLOAD_KEY_PASSWORD', value: '***'}, + {key: 'VERSION', value: '1.2.3'}, + ]), createStepAssertion('Archive Android sourcemaps', true, null, 'ANDROID', 'Archiving Android sourcemaps', [ // Note 1.2.3 comes from the ref name that we are on, which is the version we are deploying {key: 'name', value: 'android-sourcemap-1.2.3'}, {key: 'path', value: 'android/app/build/generated/sourcemaps/react/productionRelease/index.android.bundle.map'}, ]), - ); + ]; + if (!isProduction) { steps.push( - createStepAssertion('Upload Android version to GitHub artifacts', true, null, 'ANDROID', 'Upload Android version to GitHub artifacts', [ + createStepAssertion('Upload Android build to GitHub artifacts', true, null, 'ANDROID', 'Uploading Android build to GitHub artifacts', [ {key: 'name', value: 'app-production-release.aab'}, {key: 'path', value: 'android/app/build/outputs/bundle/productionRelease/app-production-release.aab'}, ]), - createStepAssertion('Upload Android version to Browser Stack', true, null, 'ANDROID', 'Uploading Android version to Browser Stack', null, [{key: 'BROWSERSTACK', value: '***'}]), + createStepAssertion('Upload Android build to Browser Stack', true, null, 'ANDROID', 'Uploading Android build to Browser Stack', null, [{key: 'BROWSERSTACK', value: '***'}]), ); } @@ -115,32 +109,16 @@ function assertDesktopJobExecuted(workflowResult: Step[], didExecute = true, isP createStepAssertion('Checkout', true, null, 'DESKTOP', 'Checking out'), createStepAssertion('Setup Node', true, null, 'DESKTOP', 'Setting up Node'), createStepAssertion('Decrypt Developer ID Certificate', true, null, 'DESKTOP', 'Decrypting developer id certificate', null, [{key: 'DEVELOPER_ID_SECRET_PASSPHRASE', value: '***'}]), + createStepAssertion('Build desktop app', true, null, 'DESKTOP', 'Building desktop app', null, [ + {key: 'CSC_LINK', value: '***'}, + {key: 'CSC_KEY_PASSWORD', value: '***'}, + {key: 'APPLE_ID', value: '***'}, + {key: 'APPLE_APP_SPECIFIC_PASSWORD', value: '***'}, + {key: 'AWS_ACCESS_KEY_ID', value: '***'}, + {key: 'AWS_SECRET_ACCESS_KEY', value: '***'}, + ]), ]; - if (isProduction) { - steps.push( - createStepAssertion('Build production desktop app', true, null, 'DESKTOP', 'Building production desktop app', null, [ - {key: 'CSC_LINK', value: '***'}, - {key: 'CSC_KEY_PASSWORD', value: '***'}, - {key: 'APPLE_ID', value: '***'}, - {key: 'APPLE_APP_SPECIFIC_PASSWORD', value: '***'}, - {key: 'AWS_ACCESS_KEY_ID', value: '***'}, - {key: 'AWS_SECRET_ACCESS_KEY', value: '***'}, - ]), - ); - } else { - steps.push( - createStepAssertion('Build staging desktop app', true, null, 'DESKTOP', 'Building staging desktop app', null, [ - {key: 'CSC_LINK', value: '***'}, - {key: 'CSC_KEY_PASSWORD', value: '***'}, - {key: 'APPLE_ID', value: '***'}, - {key: 'APPLE_APP_SPECIFIC_PASSWORD', value: '***'}, - {key: 'AWS_ACCESS_KEY_ID', value: '***'}, - {key: 'AWS_SECRET_ACCESS_KEY', value: '***'}, - ]), - ); - } - steps.forEach((expectedStep) => { if (didExecute) { expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); @@ -174,37 +152,28 @@ function assertIOSJobExecuted(workflowResult: Step[], didExecute = true, isProdu createStepAssertion('Decrypt AppStore Notification Service profile', true, null, 'IOS', 'Decrypting profile', null, [{key: 'LARGE_SECRET_PASSPHRASE', value: '***'}]), createStepAssertion('Decrypt certificate', true, null, 'IOS', 'Decrypting certificate', null, [{key: 'LARGE_SECRET_PASSPHRASE', value: '***'}]), createStepAssertion('Decrypt App Store Connect API key', true, null, 'IOS', 'Decrypting App Store API key', null, [{key: 'LARGE_SECRET_PASSPHRASE', value: '***'}]), - ]; - - if (!isProduction) { - steps.push( - createStepAssertion('Run Fastlane', true, null, 'IOS', 'Running Fastlane', null, [ - {key: 'APPLE_CONTACT_EMAIL', value: '***'}, - {key: 'APPLE_CONTACT_PHONE', value: '***'}, - {key: 'APPLE_DEMO_EMAIL', value: '***'}, - {key: 'APPLE_DEMO_PASSWORD', value: '***'}, - ]), - ); - } - steps.push( + createStepAssertion('Set iOS version in ENV', true, null, 'IOS', 'Setting iOS version'), + createStepAssertion('Run Fastlane', true, null, 'IOS', 'Running Fastlane', null, [ + {key: 'APPLE_CONTACT_EMAIL', value: '***'}, + {key: 'APPLE_CONTACT_PHONE', value: '***'}, + {key: 'APPLE_DEMO_EMAIL', value: '***'}, + {key: 'APPLE_DEMO_PASSWORD', value: '***'}, + {key: 'VERSION', value: '1.2.3'}, + ]), createStepAssertion('Archive iOS sourcemaps', true, null, 'IOS', 'Archiving sourcemaps', [ // Note 1.2.3 comes from the ref name that we are on, which is the version we are deploying {key: 'name', value: 'ios-sourcemap-1.2.3'}, {key: 'path', value: 'main.jsbundle.map'}, ]), - ); + ]; + if (!isProduction) { steps.push( - createStepAssertion('Upload iOS version to GitHub artifacts', true, null, 'IOS', 'Upload iOS version to GitHub artifacts', [ + createStepAssertion('Upload iOS build to GitHub artifacts', true, null, 'IOS', 'Uploading iOS build to GitHub artifacts', [ {key: 'name', value: 'New Expensify.ipa'}, {key: 'path', value: '/Users/runner/work/App/App/New Expensify.ipa'}, ]), - createStepAssertion('Upload iOS version to Browser Stack', true, null, 'IOS', 'Uploading version to Browser Stack', null, [{key: 'BROWSERSTACK', value: '***'}]), - ); - } else { - steps.push( - createStepAssertion('Set iOS version in ENV', true, null, 'IOS', 'Setting iOS version'), - createStepAssertion('Run Fastlane for App Store release', true, null, 'IOS', 'Running Fastlane for release', null, [{key: 'VERSION', value: '1.2.3'}]), + createStepAssertion('Upload iOS build to Browser Stack', true, null, 'IOS', 'Uploading build to Browser Stack', null, [{key: 'BROWSERSTACK', value: '***'}]), ); } @@ -252,21 +221,12 @@ function assertWebJobExecuted(workflowResult: Step[], didExecute = true, isProdu ]), ]; - if (isProduction) { - steps.push( - createStepAssertion('Build web for production', true, null, 'WEB', 'Building web for production'), - createStepAssertion('Build storybook docs for production', true, null, 'WEB', 'Build storybook docs for production'), - createStepAssertion('Deploy production to S3', true, null, 'WEB', 'Deploying production to S3'), - createStepAssertion('Purge production Cloudflare cache', true, null, 'WEB', 'Purging production Cloudflare cache', null, [{key: 'CF_API_KEY', value: '***'}]), - ); - } else { - steps.push( - createStepAssertion('Build web for staging', true, null, 'WEB', 'Building web for staging'), - createStepAssertion('Build storybook docs for staging', true, null, 'WEB', 'Build storybook docs for staging'), - createStepAssertion('Deploy staging to S3', true, null, 'WEB', 'Deploying staging to S3'), - createStepAssertion('Purge staging Cloudflare cache', true, null, 'WEB', 'Purging staging Cloudflare cache', null, [{key: 'CF_API_KEY', value: '***'}]), - ); - } + steps.push( + createStepAssertion('Build web', true, null, 'WEB', 'Building web'), + createStepAssertion('Build storybook docs', true, null, 'WEB', 'Build storybook docs'), + createStepAssertion('Deploy to S3', true, null, 'WEB', 'Deploying to S3'), + createStepAssertion('Purge Cloudflare cache', true, null, 'WEB', 'Purging Cloudflare cache', null, [{key: 'CF_API_KEY', value: '***'}]), + ); steps.forEach((expectedStep) => { if (didExecute) { diff --git a/workflow_tests/mocks/platformDeployMocks.ts b/workflow_tests/mocks/platformDeployMocks.ts index f46fdbfa21cc..946545e32b03 100644 --- a/workflow_tests/mocks/platformDeployMocks.ts +++ b/workflow_tests/mocks/platformDeployMocks.ts @@ -36,12 +36,12 @@ const PLATFORM_DEPLOY__ANDROID__DECRYPT_JSON_KEY__STEP_MOCK = createMockStep('De const PLATFORM_DEPLOY__ANDROID__SET_VERSION__STEP_MOCK = createMockStep('Set version in ENV', 'Setting version in ENV', 'ANDROID', null, null, null, {VERSION_CODE: '1.2.3'}); const PLATFORM_DEPLOY__ANDROID__FASTLANE__STEP_MOCK = createMockStep('Run Fastlane', 'Running Fastlane', 'ANDROID', null, [ 'RUBYOPT', - 'VERSION', 'MYAPP_UPLOAD_STORE_PASSWORD', 'MYAPP_UPLOAD_KEY_PASSWORD', + 'VERSION', ]); const PLATFORM_DEPLOY__ANDROID__ARCHIVE_SOURCEMAPS__STEP_MOCK = createMockStep('Archive Android sourcemaps', 'Archiving Android sourcemaps', 'ANDROID', ['name', 'path']); -const PLATFORM_DEPLOY__ANDROID__UPLOAD_TO_GITHUB_ARTIFACTS__STEP_MOCK = createMockStep('Upload Android build to GitHub artifacts', 'Uploading android build to GitHub artifacts', 'ANDROID', [ +const PLATFORM_DEPLOY__ANDROID__UPLOAD_TO_GITHUB_ARTIFACTS__STEP_MOCK = createMockStep('Upload Android build to GitHub artifacts', 'Uploading Android build to GitHub artifacts', 'ANDROID', [ 'name', 'path', ]); @@ -124,7 +124,7 @@ const PLATFORM_DEPLOY__IOS__UPLOAD_TO_GITHUB_ARTIFACTS__STEP_MOCK = createMockSt 'name', 'path', ]); -const PLATFORM_DEPLOY__IOS__UPLOAD_BROWSERSTACK__STEP_MOCK = createMockStep('Upload iOS build to Browser Stack', 'Uploading version to Browser Stack', 'IOS', null, ['BROWSERSTACK']); +const PLATFORM_DEPLOY__IOS__UPLOAD_BROWSERSTACK__STEP_MOCK = createMockStep('Upload iOS build to Browser Stack', 'Uploading build to Browser Stack', 'IOS', null, ['BROWSERSTACK']); const PLATFORM_DEPLOY__IOS__SET_VERSION__STEP_MOCK = createMockStep('Set iOS version in ENV', 'Setting iOS version', 'IOS', null, null, null, {IOS_VERSION: '1.2.3'}); const PLATFORM_DEPLOY__IOS__WARN_FAIL__STEP_MOCK = createMockStep( 'Warn deployers if iOS production deploy failed', diff --git a/workflow_tests/platformDeploy.test.ts b/workflow_tests/platformDeploy.test.ts index f3247acd0d14..112bcd0d5e5e 100644 --- a/workflow_tests/platformDeploy.test.ts +++ b/workflow_tests/platformDeploy.test.ts @@ -44,6 +44,7 @@ describe('test workflow platformDeploy', () => { afterEach(async () => { await mockGithub.teardown(); }); + describe('push', () => { describe('tag', () => { it('as team member - platform deploy executes on staging', async () => {