Skip to content

Commit

Permalink
Fix more mocks and assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
roryabraham committed Jul 15, 2024
1 parent ee40985 commit 96a51bb
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 79 deletions.
112 changes: 36 additions & 76 deletions workflow_tests/assertions/platformDeployAssertions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: '***'}]),
);
}

Expand Down Expand Up @@ -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]));
Expand Down Expand Up @@ -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: '***'}]),
);
}

Expand Down Expand Up @@ -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) {
Expand Down
6 changes: 3 additions & 3 deletions workflow_tests/mocks/platformDeployMocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
]);
Expand Down Expand Up @@ -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',
Expand Down
1 change: 1 addition & 0 deletions workflow_tests/platformDeploy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down

0 comments on commit 96a51bb

Please sign in to comment.