Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
Fixed `preDeploy` tests that broke after merging in the source repos main branch

See: #13604
  • Loading branch information
radoslawkrzemien committed Jun 30, 2023
1 parent 23d0f78 commit 917d3d3
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 410 deletions.
11 changes: 7 additions & 4 deletions .github/workflows/preDeploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,10 @@ jobs:
e2ePerformanceTests:
needs: [chooseDeployActions]
if: ${{ needs.chooseDeployActions.outputs.SHOULD_DEPLOY }}
uses: Expensify/App/.github/workflows/e2ePerformanceTests.yml@main
secrets: inherit
with:
PR_NUMBER: ${{ needs.chooseDeployActions.outputs.MERGED_PR }}
steps:
steps:
- name: Perform E2E tests
uses: Expensify/App/.github/workflows/e2ePerformanceTests.yml@main
secrets: inherit
with:
PR_NUMBER: ${{ needs.chooseDeployActions.outputs.MERGED_PR }}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"symbolicate:android": "npx metro-symbolicate android/app/build/generated/sourcemaps/react/release/index.android.bundle.map",
"symbolicate:ios": "npx metro-symbolicate main.jsbundle.map",
"test:e2e": "node tests/e2e/testRunner.js --development",
"workflow-test": "npm test -- --config=workflow_tests/jest.config.js",
"workflow-test": "npm test -- --config=workflow_tests/jest.config.js --runInBand",
"workflow-test:generate": "node workflow_tests/utils/preGenerateTest.js"
},
"dependencies": {
Expand Down
182 changes: 0 additions & 182 deletions workflow_tests/assertions/preDeployAssertions.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,187 +118,6 @@ const assertNewContributorWelcomeMessageJobExecuted = (workflowResult, didExecut
}
};

const assertE2ETestsJobExecuted = (workflowResult, didExecute = true) => {
const steps = [
utils.getStepAssertion(
'Checkout',
true,
null,
'E2E_TESTS',
'Checking out',
),
utils.getStepAssertion(
'Setup node',
true,
null,
'E2E_TESTS',
'Setting up node',
),
utils.getStepAssertion(
'Setup ruby',
true,
null,
'E2E_TESTS',
'Setting up ruby',
),
utils.getStepAssertion(
'Gradle cache',
true,
null,
'E2E_TESTS',
'Building with gradle',
),
utils.getStepAssertion(
'Make zip directory for everything to send to AWS Device Farm',
true,
null,
'E2E_TESTS',
'Creating zip directory',
),
utils.getStepAssertion(
'Checkout "Compare" commit',
true,
null,
'E2E_TESTS',
'Checking out compare commit',
),
utils.getStepAssertion(
'Install node packages',
true,
null,
'E2E_TESTS',
'Installing node packages',
),
utils.getStepAssertion(
'Build "Compare" APK',
true,
null,
'E2E_TESTS',
'Building compare apk',
),
utils.getStepAssertion(
'Copy "Compare" APK',
true,
null,
'E2E_TESTS',
'Copying compare apk',
),
utils.getStepAssertion(
'Checkout "Baseline" commit (last release)',
true,
null,
'E2E_TESTS',
'Checking out baseline commit',
),
utils.getStepAssertion(
'Install node packages',
true,
null,
'E2E_TESTS',
'Installing node packages',
),
utils.getStepAssertion(
'Build "Baseline" APK',
true,
null,
'E2E_TESTS',
'Building baseline apk',
),
utils.getStepAssertion(
'Copy "Baseline" APK',
true,
null,
'E2E_TESTS',
'Copying baseline apk',
),
utils.getStepAssertion(
'Checkout previous branch for source code to run on AWS Device farm',
true,
null,
'E2E_TESTS',
'Checking out previous branch',
),
utils.getStepAssertion(
'Copy e2e code into zip folder',
true,
null,
'E2E_TESTS',
'Copying e2e tests',
),
utils.getStepAssertion(
'Zip everything in the zip directory up',
true,
null,
'E2E_TESTS',
'Zipping everything',
),
utils.getStepAssertion(
'Configure AWS Credentials',
true,
null,
'E2E_TESTS',
'Configuring AWS credentials',
),
utils.getStepAssertion(
'Schedule AWS Device Farm test run',
true,
null,
'E2E_TESTS',
'Scheduling AWS test run',
),
utils.getStepAssertion(
'Unzip AWS Device Farm results',
true,
null,
'E2E_TESTS',
'Unzipping test results',
),
utils.getStepAssertion(
'Print AWS Device Farm run results',
true,
null,
'E2E_TESTS',
'Printing test results',
),
utils.getStepAssertion(
'Set output of AWS Device Farm into GitHub ENV',
true,
null,
'E2E_TESTS',
'Setting AWS output',
),
utils.getStepAssertion(
'Get merged pull request',
true,
null,
'E2E_TESTS',
'Getting merged pull request',
),
utils.getStepAssertion(
'Leave output of AWS Device Farm as a PR comment',
true,
null,
'E2E_TESTS',
'Leaving comment with test results',
),
utils.getStepAssertion(
'Check if test failed, if so leave a deploy blocker label',
true,
null,
'E2E_TESTS',
'Checking if tests failed',
),
];

for (const expectedStep of steps) {
if (didExecute) {
expect(workflowResult).toEqual(expect.arrayContaining([expectedStep]));
} else {
expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep]));
}
}
};

const assertChooseDeployActionsJobExecuted = (workflowResult, didExecute = true) => {
const steps = [
utils.getStepAssertion(
Expand Down Expand Up @@ -518,7 +337,6 @@ module.exports = {
assertTestJobExecuted,
assertIsExpensifyEmployeeJobExecuted,
assertNewContributorWelcomeMessageJobExecuted,
assertE2ETestsJobExecuted,
assertChooseDeployActionsJobExecuted,
assertSkipDeployJobExecuted,
assertCreateNewVersionJobExecuted,
Expand Down
149 changes: 7 additions & 142 deletions workflow_tests/mocks/preDeployMocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,148 +310,13 @@ const NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__OSBOTIFY = [
COMMENT_ON_FIRST_PULL_REQUEST_MOCK_STEP,
];

// e2e_tests
// these steps are not getting executed anyway, since Act does not support the selected runner
const CHECKOUT_MOCK_STEP__E2E_TESTS = utils.getMockStep(
'Checkout',
'Checking out',
'E2E_TESTS',
);
const SETUP_NODE_MOCK_STEP = utils.getMockStep(
'Setup node',
'Setting up node',
'E2E_TESTS',
);
const SETUP_RUBY_MOCK_STEP = utils.getMockStep(
'Setup ruby',
'Setting up ruby',
'E2E_TESTS',
);
const GRADLE_CACHE_MOCK_STEP = utils.getMockStep(
'Gradle cache',
'Building with gradle',
'E2E_TESTS',
);
const MAKE_ZIP_MOCK_STEP = utils.getMockStep(
'Make zip directory for everything to send to AWS Device Farm',
'Creating zip directory',
'E2E_TESTS',
);
const CHECKOUT_COMPARE_MOCK_STEP = utils.getMockStep(
'Checkout "Compare" commit',
'Checking out compare commit',
'E2E_TESTS',
);
const INSTALL_NODE_PACKAGES_MOCK_STEP = utils.getMockStep(
'Install node packages',
'Installing node packages',
'E2E_TESTS',
);
const BUILD_COMPARE_APK_MOCK_STEP = utils.getMockStep(
'Build "Compare" APK',
'Building compare apk',
'E2E_TESTS',
);
const COPY_COMPARE_APK_MOCK_STEP = utils.getMockStep(
'Copy "Compare" APK',
'Copying compare apk',
'E2E_TESTS',
);
const CHECKOUT_BASELINE_COMMIT_MOCK_STEP = utils.getMockStep(
'Checkout "Baseline" commit (last release)',
'Checking out baseline commit',
'E2E_TESTS',
);
const BUILD_BASELINE_APK_MOCK_STEP = utils.getMockStep(
'Build "Baseline" APK',
'Building baseline apk',
'E2E_TESTS',
);
const COPY_BASELINE_APK_MOCK_STEP = utils.getMockStep(
'Copy "Baseline" APK',
'Copying baseline apk',
'E2E_TESTS',
);
const CHECKOUT_PREVIOUS_BRANCH_MOCK_STEP = utils.getMockStep(
'Checkout previous branch for source code to run on AWS Device farm',
'Checking out previous branch',
'E2E_TESTS',
);
const COPY_E2E_CODE_MOCK_STEP = utils.getMockStep(
'Copy e2e code into zip folder',
'Copying e2e tests',
'E2E_TESTS',
);
const ZIP_EVERYTHING_MOCK_STEP = utils.getMockStep(
'Zip everything in the zip directory up',
'Zipping everything',
'E2E_TESTS',
);
const CONFIGURE_AWS_CREDENTIALS_MOCK_STEP = utils.getMockStep(
'Configure AWS Credentials',
'Configuring AWS credentials',
'E2E_TESTS',
);
const SCHEDULE_AWS_DEVICE_FARM_MOCK_STEP = utils.getMockStep(
'Schedule AWS Device Farm test run',
'Scheduling AWS test run',
'E2E_TESTS',
);
const UNZIP_AWS_DEVICE_FARM_RESULTS_MOCK_STEP = utils.getMockStep(
'Unzip AWS Device Farm results',
'Unzipping test results',
'E2E_TESTS',
);
const PRINT_AWS_DEVICE_FARM_RESULTS_MOCK_STEP = utils.getMockStep(
'Print AWS Device Farm run results',
'Printing test results',
'E2E_TESTS',
);
const SET_OUTPUT_OF_AWS_DEVICE_FARM_MOCK_STEP = utils.getMockStep(
'Set output of AWS Device Farm into GitHub ENV',
'Setting AWS output',
'E2E_TESTS',
);
const GET_MERGED_PULL_REQUEST_MOCK_STEP__E2E_TESTS = utils.getMockStep(
'Get merged pull request',
'Getting merged pull request',
'E2E_TESTS',
);
const LEAVE_COMMENT_WITH_AWS_DEVICE_FARM_OUTPUT_MOCK_STEP = utils.getMockStep(
'Leave output of AWS Device Farm as a PR comment',
'Leaving comment with test results',
'E2E_TESTS',
);
const CHECK_IF_TESTS_FAILED_MOCK_STEP = utils.getMockStep(
'Check if test failed, if so leave a deploy blocker label',
'Checking if tests failed',
'E2E_TESTS',
const PREDEPLOY__E2EPERFORMANCETESTS__PERFORM_E2E_TESTS__MOCK_STEP = utils.getMockStep(
'Perform E2E tests',
'Perform E2E tests',
'E2EPERFORMANCETESTS',
);
const E2E_TESTS_JOB_MOCK_STEPS = [
CHECKOUT_MOCK_STEP__E2E_TESTS,
SETUP_NODE_MOCK_STEP,
SETUP_RUBY_MOCK_STEP,
GRADLE_CACHE_MOCK_STEP,
MAKE_ZIP_MOCK_STEP,
CHECKOUT_COMPARE_MOCK_STEP,
INSTALL_NODE_PACKAGES_MOCK_STEP,
BUILD_COMPARE_APK_MOCK_STEP,
COPY_COMPARE_APK_MOCK_STEP,
CHECKOUT_BASELINE_COMMIT_MOCK_STEP,
INSTALL_NODE_PACKAGES_MOCK_STEP,
BUILD_BASELINE_APK_MOCK_STEP,
COPY_BASELINE_APK_MOCK_STEP,
CHECKOUT_PREVIOUS_BRANCH_MOCK_STEP,
COPY_E2E_CODE_MOCK_STEP,
ZIP_EVERYTHING_MOCK_STEP,
CONFIGURE_AWS_CREDENTIALS_MOCK_STEP,
SCHEDULE_AWS_DEVICE_FARM_MOCK_STEP,
UNZIP_AWS_DEVICE_FARM_RESULTS_MOCK_STEP,
PRINT_AWS_DEVICE_FARM_RESULTS_MOCK_STEP,
SET_OUTPUT_OF_AWS_DEVICE_FARM_MOCK_STEP,
GET_MERGED_PULL_REQUEST_MOCK_STEP__E2E_TESTS,
LEAVE_COMMENT_WITH_AWS_DEVICE_FARM_OUTPUT_MOCK_STEP,
CHECK_IF_TESTS_FAILED_MOCK_STEP,
const PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS = [
PREDEPLOY__E2EPERFORMANCETESTS__PERFORM_E2E_TESTS__MOCK_STEP,
];

module.exports = {
Expand All @@ -470,5 +335,5 @@ module.exports = {
NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS,
NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__ONE_PR,
NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__OSBOTIFY,
E2E_TESTS_JOB_MOCK_STEPS,
PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS,
};
Loading

0 comments on commit 917d3d3

Please sign in to comment.