From 5277afe4fb9914841c4ede96de95ea85069dbe2b Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Tue, 21 Feb 2023 12:21:14 +0100 Subject: [PATCH 001/504] Add repo to gitignore Add repo to gitignore See: https://github.com/Expensify/App/issues/13604 --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 94c646a04246..cc7ab513ccd8 100644 --- a/.gitignore +++ b/.gitignore @@ -95,3 +95,6 @@ storybook-static # E2E test reports tests/e2e/results/ .reassure + +# Mock-github +/repo/ From 2e253549fabcb6770006a0f3be3630d9e006ee6b Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Tue, 21 Feb 2023 12:28:53 +0100 Subject: [PATCH 002/504] Add new dependencies Added new packages, most importantly `Mock-github` for creating a local repository for testing (to have better control over which files are accessed by the locally run workflows) and `Act-js` for programatically triggering the workflows with Act (with features added on top of it, like mocking API calls, mocking steps, etc.) See: https://github.com/Expensify/App/issues/13604 --- package.json | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index a7b899d37204..e00d92c9bb83 100644 --- a/package.json +++ b/package.json @@ -53,6 +53,8 @@ "@formatjs/intl-numberformat": "^8.5.0", "@formatjs/intl-pluralrules": "^5.2.2", "@gorhom/portal": "^1.0.14", + "@kie/act-js": "^2.0.1", + "@kie/mock-github": "^1.0.0", "@oguzhnatly/react-native-image-manipulator": "github:Expensify/react-native-image-manipulator#5cdae3d4455b03a04c57f50be3863e2fe6c92c52", "@onfido/react-native-sdk": "7.4.0", "@react-native-async-storage/async-storage": "^1.17.10", @@ -72,6 +74,9 @@ "@react-ng/bounds-observer": "^0.2.1", "@ua/react-native-airship": "^15.2.6", "awesome-phonenumber": "^5.4.0", + "@react-navigation/drawer": "github:Expensify/react-navigation#react-navigation-drawer-v6.5.0-alpha1-gitpkg", + "@types/jest": "^29.4.0", + "@types/node": "^18.14.0", "babel-plugin-transform-remove-console": "^6.9.4", "babel-polyfill": "^6.26.0", "dom-serializer": "^0.2.2", @@ -135,7 +140,12 @@ "save": "^2.4.0", "semver": "^7.3.8", "shim-keyboard-event-key": "^1.0.3", - "underscore": "^1.13.1" + "ts-jest": "^29.0.5", + "ts-node": "^10.9.1", + "tsc": "^2.0.4", + "typescript": "^4.9.5", + "underscore": "^1.13.1", + "urbanairship-react-native": "^14.6.1" }, "devDependencies": { "@actions/core": "1.10.0", From 5816c30ddf094c052c5309cfec6c4eebab85c476 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Tue, 21 Feb 2023 12:31:11 +0100 Subject: [PATCH 003/504] Add configs Added `jest` and `ts` config files in a new folder `workflow_tests` for the testing of GitHub Actions workflows See: https://github.com/Expensify/App/issues/13604 --- workflow_tests/jest.config.ts | 13 +++++ workflow_tests/tsconfig.json | 103 ++++++++++++++++++++++++++++++++++ 2 files changed, 116 insertions(+) create mode 100644 workflow_tests/jest.config.ts create mode 100644 workflow_tests/tsconfig.json diff --git a/workflow_tests/jest.config.ts b/workflow_tests/jest.config.ts new file mode 100644 index 000000000000..28e88dfce53d --- /dev/null +++ b/workflow_tests/jest.config.ts @@ -0,0 +1,13 @@ +import type {Config} from '@jest/types'; + +// Sync object +const jestConfig: Config.InitialOptions = { + verbose: true, + transform: { + '^.+\\.tsx?$': 'ts-jest', + }, + clearMocks: true, + resetMocks: true, +}; + +export default jestConfig; diff --git a/workflow_tests/tsconfig.json b/workflow_tests/tsconfig.json new file mode 100644 index 000000000000..90b8ec162846 --- /dev/null +++ b/workflow_tests/tsconfig.json @@ -0,0 +1,103 @@ +{ + "compilerOptions": { + /* Visit https://aka.ms/tsconfig to read more about this file */ + + /* Projects */ + // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */ + // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */ + // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */ + // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */ + // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */ + // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ + + /* Language and Environment */ + "target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */ + // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ + // "jsx": "preserve", /* Specify what JSX code is generated. */ + // "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */ + // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */ + // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */ + // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */ + // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */ + // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */ + // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */ + // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */ + // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */ + + /* Modules */ + "module": "commonjs", /* Specify what module code is generated. */ + // "rootDir": "./", /* Specify the root folder within your source files. */ + // "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */ + // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ + // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ + // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ + // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */ + // "types": [], /* Specify type package names to be included without being referenced in a source file. */ + // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ + // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ + // "resolveJsonModule": true, /* Enable importing .json files. */ + // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ + + /* JavaScript Support */ + // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */ + // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */ + // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */ + + /* Emit */ + // "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */ + // "declarationMap": true, /* Create sourcemaps for d.ts files. */ + // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ + // "sourceMap": true, /* Create source map files for emitted JavaScript files. */ + // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */ + // "outDir": "./", /* Specify an output folder for all emitted files. */ + // "removeComments": true, /* Disable emitting comments. */ + // "noEmit": true, /* Disable emitting files from a compilation. */ + // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */ + // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */ + // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */ + // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */ + // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ + // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ + // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */ + // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */ + // "newLine": "crlf", /* Set the newline character for emitting files. */ + // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */ + // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */ + // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */ + // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */ + // "declarationDir": "./", /* Specify the output directory for generated declaration files. */ + // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */ + + /* Interop Constraints */ + // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */ + // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */ + "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */ + // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */ + "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */ + + /* Type Checking */ + "strict": true, /* Enable all strict type-checking options. */ + // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */ + // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */ + // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ + // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */ + // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ + // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */ + // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */ + // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ + // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */ + // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */ + // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ + // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ + // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ + // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */ + // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */ + // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */ + // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */ + // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */ + + /* Completeness */ + // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ + "skipLibCheck": true /* Skip type checking all .d.ts files. */ + } +} \ No newline at end of file From 126d210927c1b690d4f689a2cb0bc27827aaee57 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Tue, 21 Feb 2023 12:46:09 +0100 Subject: [PATCH 004/504] Add first proper test stub [WiP] Added the stub of the first proper test, with the more-or-less defined structure, but yet without proper step mocks and result assertions See: https://github.com/Expensify/App/issues/13604 --- workflow_tests/preDeploy.test.ts | 292 +++++++++++++++++++++++++++++++ 1 file changed, 292 insertions(+) create mode 100644 workflow_tests/preDeploy.test.ts diff --git a/workflow_tests/preDeploy.test.ts b/workflow_tests/preDeploy.test.ts new file mode 100644 index 000000000000..ff5701576e97 --- /dev/null +++ b/workflow_tests/preDeploy.test.ts @@ -0,0 +1,292 @@ +import {MockGithub} from '@kie/mock-github'; +import {Act} from '@kie/act-js'; +import path from 'path'; + +let mockGithub: MockGithub; + +beforeEach(async () => { + // create a local repository and copy required files + mockGithub = new MockGithub({ + repo: { + testWorkflowsRepo: { + files: [ + { + src: path.resolve(__dirname, '..', '.github', 'actions'), + dest: '.github/actions', + }, + { + src: path.resolve(__dirname, '..', '.github', 'libs'), + dest: '.github/libs', + }, + { + src: path.resolve(__dirname, '..', '.github', 'scripts'), + dest: '.github/scripts', + }, + { + src: path.resolve(__dirname, '..', '.github', 'workflows', 'preDeploy.yml'), + dest: '.github/workflows/preDeploy.yml', + }, + { + src: path.resolve(__dirname, '..', '.github', '.eslintrc.js'), + dest: '.github/.eslintrc.js', + }, + { + src: path.resolve(__dirname, '..', '.github', 'actionlint.yaml'), + dest: '.github/actionlint.yaml', + }, + ], + }, + }, + }); + + await mockGithub.setup(); +}); + +afterEach(async () => { + await mockGithub.teardown(); +}); + +const WIP_MOCK_STEPS = { + lint: [ + { + uses: 'Expensify/App/.github/workflows/lint.yml@main', + mockWith: 'echo [MOCK] Running lint workflow', + }, + ], + test: [ + { + uses: 'Expensify/App/.github/workflows/test.yml@main', + mockWith: 'echo [MOCK] Running test workflow', + }, + ], + confirmPassingBuild: [ + { + uses: 'Expensify/App/.github/actions/composite/announceFailedWorkflowInSlack@main', + mockWith: 'echo [MOCK] Announcing failed workflow in slack', + }, + { + run: 'exit 1', + mockWith: 'echo [MOCK] Exiting with failed status', + }, + ], + chooseDeployActions: [ + { + uses: 'actions-ecosystem/action-get-merged-pull-request@59afe90821bb0b555082ce8ff1e36b03f91553d9', + mockWith: 'echo [MOCK] Getting merged pull request', + }, + { + uses: 'Expensify/App/.github/actions/javascript/isStagingDeployLocked@main', + mockWith: 'echo [MOCK] Checking StagingDeployCash', + }, + { + run: 'echo "IS_AUTOMATED_PR=${{ github.actor == \'OSBotify\' }}" >> "$GITHUB_OUTPUT"', + mockWith: 'echo [MOCK] Checking for automated PR', + }, + { + run: 'echo "HAS_CP_LABEL=${{ contains(steps.getMergedPullRequest.outputs.labels, \'CP Staging\') }}" >> "$GITHUB_OUTPUT"', + mockWith: 'echo [MOCK] Checking CP Staging', + }, + { + run: 'echo "SHOULD_DEPLOY=${{ fromJSON(steps.hasCherryPickLabel.outputs.HAS_CP_LABEL) || (!fromJSON(steps.isStagingDeployLocked.outputs.IS_LOCKED) && !fromJSON(steps.isAutomatedPullRequest.outputs.IS_AUTOMATED_PR)) }}" >> "$GITHUB_OUTPUT"', + mockWith: 'echo [MOCK] Checking deploy trigger', + }, + ], + skipDeploy: [ + { + uses: 'actions-ecosystem/action-create-comment@cd098164398331c50e7dfdd0dfa1b564a1873fac', + mockWith: 'echo [MOCK] Skipping deploy', + }, + ], + createNewVersion: [ + { + uses: 'Expensify/App/.github/workflows/createNewVersion.yml@main', + mockWith: 'echo [MOCK] Creating new version', + }, + ], + updateStaging: [ + { + uses: 'softprops/turnstyle@ca99add00ff0c9cbc697d22631d2992f377e5bd5', + mockWith: 'echo [MOCK] Running turnstyle', + }, + { + uses: 'Expensify/App/.github/actions/composite/updateProtectedBranch@main', + mockWith: 'echo [MOCK] Updating staging branch', + }, + { + uses: 'Expensify/App/.github/actions/javascript/triggerWorkflowAndWait@main', + mockWith: 'echo [MOCK] Cherry picking', + }, + { + uses: 'actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8', + mockWith: 'echo [MOCK] Checking out staging', + }, + { + run: 'git tag ${{ needs.createNewVersion.outputs.NEW_VERSION }}', + mockWith: 'echo [MOCK] Tagging staging', + }, + { + uses: 'Expensify/App/.github/actions/javascript/createOrUpdateStagingDeploy@main', + mockWith: 'echo [MOCK] Updating StagingDeployCash', + }, + { + run: 'echo "STAGING_DEPLOY_CASH=$(gh issue list --label StagingDeployCash --json number --jq \'.[0].number\')" >> "$GITHUB_OUTPUT"', + mockWith: 'echo [MOCK] Finding open StagingDeployCash', + }, + { + name: 'Wait for staging deploys to finish', + mockWith: 'echo [MOCK] Waiting for staging deploy to finish', + }, + { + name: 'Comment in StagingDeployCash to alert Applause that a new pull request has been cherry-picked', + mockWith: 'echo [MOCK] Commenting in StagingDeployCash', + }, + { + name: 'Comment in StagingDeployCash to alert Applause that cherry-picked pull request has been deployed.', + mockWith: 'echo [MOCK] Commenting in StagingDeployCash', + }, + { + uses: 'Expensify/App/.github/actions/composite/announceFailedWorkflowInSlack@main', + mockWith: 'echo [MOCK] Announcing failed workflow in slack', + }, + ], + isExpensifyEmployee: [ + { + name: 'Get merged pull request', + mockWith: 'echo [MOCK] Getting merged pull request', + }, + { + name: 'Check whether the actor is member of Expensify/expensify team', + mockWith: 'echo [MOCK] Checking actor\'s Expensify membership', + }, + ], + newContributorWelcomeMessage: [ + { + uses: 'actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8', + mockWith: 'echo [MOCK] Checking out', + }, + { + name: 'Get merged pull request', + mockWith: 'echo [MOCK] Getting merged pull request', + }, + { + name: 'Get PR count for ${{ steps.getMergedPullRequest.outputs.author }}', + mockWith: 'echo [MOCK] Getting PR count', + }, + { + uses: 'actions-ecosystem/action-create-comment@cd098164398331c50e7dfdd0dfa1b564a1873fac', + mockWith: 'echo [MOCK] Creating comment', + }, + ], + 'e2e-tests': [ + { + uses: 'actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8', + mockWith: 'echo [MOCK] Checking out', + }, + { + uses: 'Expensify/App/.github/actions/composite/setupNode@main', + mockWith: 'echo [MOCK] Setting up node', + }, + { + name: 'Gradle cache', + mockWith: 'echo [MOCK] Building with gradle', + }, + { + name: 'Make zip directory for everything to send to AWS Device Farm', + mockWith: 'echo [MOCK] Creating zip directory', + }, + { + name: 'Checkout "Compare" commit', + mockWith: 'echo [MOCK] Checking out compare commit', + }, + { + name: 'Install node packages', + mockWith: 'echo [MOCK] Installing node packages', + }, + { + name: 'Build "Compare" APK', + mockWith: 'echo [MOCK] Building compare apk', + }, + { + name: 'Copy "Compare" APK', + mockWith: 'echo [MOCK] Copying compare apk', + }, + { + name: 'Checkout "Baseline" commit (last release)', + mockWith: 'echo [MOCK] Checking out baseline commit', + }, + { + name: 'Build "Baseline" APK', + mockWith: 'echo [MOCK] Building baseline apk', + }, + { + name: 'Copy "Baseline" APK', + mockWith: 'echo [MOCK] Copying baseline apk', + }, + { + name: 'Checkout previous branch for source code to run on AWS Device farm', + mockWith: 'echo [MOCK] Checking out previous branch', + }, + { + name: 'Copy e2e code into zip folder', + mockWith: 'echo [MOCK] Copying e2e tests', + }, + { + name: 'Zip everything in the zip directory up', + mockWith: 'echo [MOCK] Zipping everything', + }, + { + name: 'Configure AWS Credentials', + mockWith: 'echo [MOCK] Configuring AWS credentials', + }, + { + name: 'Schedule AWS Device Farm test run', + mockWith: 'echo [MOCK] Scheduling AWS test run', + }, + { + name: 'Unzip AWS Device Farm results', + mockWith: 'echo [MOCK] Unzipping test results', + }, + { + name: 'Print AWS Device Farm run results', + mockWith: 'echo [MOCK] Printing test results', + }, + { + name: 'Set output of AWS Device Farm into GitHub ENV', + mockWith: 'echo [MOCK] Setting AWS output', + }, + { + name: 'Get merged pull request', + mockWith: 'echo [MOCK] Getting merged pull request', + }, + { + name: 'Leave output of AWS Device Farm as a PR comment', + mockWith: 'echo [MOCK] Leaving comment with test results', + }, + { + name: 'Check if test failed, if so leave a deploy blocker label', + mockWith: 'echo [MOCK] Checking if tests failed', + }, + ], +}; + +test('test preDeploy push to main', async () => { + // get path to the local test repo + const repoPath = mockGithub.repo.getPath('testWorkflowsRepo') || ''; + + // get path to the workflow file under test + const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); + + // instantiate Act in the context of the test repo and given workflow file + const act = new Act(repoPath, workflowPath); + + // run an event and get the result + const result = await act.runEvent('push', { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: WIP_MOCK_STEPS, + }); + + console.debug(`RunEvent result: ${JSON.stringify(result, null, '\t')}`); + + // assert results + // expect(result)...; +}); From a61eaeadafda1dbeefbf63ea68b047d18cb85ed0 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Tue, 21 Feb 2023 14:46:02 +0100 Subject: [PATCH 005/504] Refactor test configuration [WiP] Updated the mocks/test repo files configuration to be more readable/maintainable. Also added `name` properties to `preDeploy` workflow steps, since using `name` is the easiest and most stable way of referencing the steps for mocking See: https://github.com/Expensify/App/issues/13604 --- .github/workflows/preDeploy.yml | 21 +- workflow_tests/preDeploy.test.ts | 523 ++++++++++++++++--------------- 2 files changed, 291 insertions(+), 253 deletions(-) diff --git a/.github/workflows/preDeploy.yml b/.github/workflows/preDeploy.yml index 0e77dbe4704f..27412f07d253 100644 --- a/.github/workflows/preDeploy.yml +++ b/.github/workflows/preDeploy.yml @@ -6,9 +6,11 @@ on: jobs: lint: + name: Run lint workflow uses: Expensify/App/.github/workflows/lint.yml@main test: + name: Run test workflow uses: Expensify/App/.github/workflows/test.yml@main confirmPassingBuild: @@ -17,12 +19,14 @@ jobs: if: ${{ always() }} steps: - - if: ${{ needs.lint.result == 'failure' || needs.test.result == 'failure' }} + - name: Announce failed workflow in Slack + if: ${{ needs.lint.result == 'failure' || needs.test.result == 'failure' }} uses: Expensify/App/.github/actions/composite/announceFailedWorkflowInSlack@main with: SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} - - if: ${{ needs.lint.result == 'failure' || needs.test.result == 'failure' }} + - name: Exit failed workflow + if: ${{ needs.lint.result == 'failure' || needs.test.result == 'failure' }} run: exit 1 chooseDeployActions: @@ -75,6 +79,7 @@ jobs: createNewVersion: needs: chooseDeployActions if: ${{ fromJSON(needs.chooseDeployActions.outputs.SHOULD_DEPLOY) }} + name: Create new version uses: Expensify/App/.github/workflows/createNewVersion.yml@main secrets: inherit @@ -82,7 +87,8 @@ jobs: needs: [chooseDeployActions, createNewVersion] runs-on: ubuntu-latest steps: - - uses: softprops/turnstyle@ca99add00ff0c9cbc697d22631d2992f377e5bd5 + - name: Run turnstyle + uses: softprops/turnstyle@ca99add00ff0c9cbc697d22631d2992f377e5bd5 with: poll-interval-seconds: 10 env: @@ -105,7 +111,8 @@ jobs: INPUTS: '{ "PULL_REQUEST_NUMBER": "${{ needs.chooseDeployActions.outputs.MERGED_PR }}", "NEW_VERSION": "${{ needs.createNewVersion.outputs.NEW_VERSION }}" }' # Version: 3.0.2 - - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 + - name: Checkout staging + uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 with: ref: staging fetch-depth: 0 @@ -156,7 +163,8 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.OS_BOTIFY_TOKEN }} - - if: ${{ failure() }} + - name: Announce failed workflow in Slack + if: ${{ failure() }} uses: Expensify/App/.github/actions/composite/announceFailedWorkflowInSlack@main with: SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} @@ -189,7 +197,8 @@ jobs: if: ${{ github.actor != 'OSBotify' && !fromJSON(needs.isExpensifyEmployee.outputs.IS_EXPENSIFY_EMPLOYEE) }} steps: # Version: 2.3.4 - - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 + - name: Checkout + uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 with: token: ${{ secrets.OS_BOTIFY_TOKEN }} diff --git a/workflow_tests/preDeploy.test.ts b/workflow_tests/preDeploy.test.ts index ff5701576e97..250fc05f51b6 100644 --- a/workflow_tests/preDeploy.test.ts +++ b/workflow_tests/preDeploy.test.ts @@ -3,38 +3,39 @@ import {Act} from '@kie/act-js'; import path from 'path'; let mockGithub: MockGithub; +const FILES_TO_COPY_INTO_TEST_REPO = [ + { + src: path.resolve(__dirname, '..', '.github', 'actions'), + dest: '.github/actions', + }, + { + src: path.resolve(__dirname, '..', '.github', 'libs'), + dest: '.github/libs', + }, + { + src: path.resolve(__dirname, '..', '.github', 'scripts'), + dest: '.github/scripts', + }, + { + src: path.resolve(__dirname, '..', '.github', 'workflows', 'preDeploy.yml'), + dest: '.github/workflows/preDeploy.yml', + }, + { + src: path.resolve(__dirname, '..', '.github', '.eslintrc.js'), + dest: '.github/.eslintrc.js', + }, + { + src: path.resolve(__dirname, '..', '.github', 'actionlint.yaml'), + dest: '.github/actionlint.yaml', + }, +]; beforeEach(async () => { // create a local repository and copy required files mockGithub = new MockGithub({ repo: { testWorkflowsRepo: { - files: [ - { - src: path.resolve(__dirname, '..', '.github', 'actions'), - dest: '.github/actions', - }, - { - src: path.resolve(__dirname, '..', '.github', 'libs'), - dest: '.github/libs', - }, - { - src: path.resolve(__dirname, '..', '.github', 'scripts'), - dest: '.github/scripts', - }, - { - src: path.resolve(__dirname, '..', '.github', 'workflows', 'preDeploy.yml'), - dest: '.github/workflows/preDeploy.yml', - }, - { - src: path.resolve(__dirname, '..', '.github', '.eslintrc.js'), - dest: '.github/.eslintrc.js', - }, - { - src: path.resolve(__dirname, '..', '.github', 'actionlint.yaml'), - dest: '.github/actionlint.yaml', - }, - ], + files: FILES_TO_COPY_INTO_TEST_REPO, }, }, }); @@ -46,230 +47,258 @@ afterEach(async () => { await mockGithub.teardown(); }); +const LINT_JOB_MOCK_STEPS = [ + { + name: 'Run lint workflow', + mockWith: 'echo [MOCK] Running lint workflow', + }, +]; + +const TEST_JOB_MOCK_STEPS = [ + { + name: 'Run test workflow', + mockWith: 'echo [MOCK] Running test workflow', + }, +]; + +const CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS = [ + { + name: 'Announce failed workflow in Slack', + mockWith: 'echo [MOCK] Announcing failed workflow in slack', + }, + { + name: 'Exit failed workflow', + mockWith: 'echo [MOCK] Exiting with failed status', + }, +]; + +const CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS = [ + { + name: 'Get merged pull request', + mockWith: 'echo [MOCK] Getting merged pull request', + }, + { + name: 'Check if StagingDeployCash is locked', + mockWith: 'echo [MOCK] Checking StagingDeployCash', + }, + { + name: 'Check if merged pull request was an automated PR', + mockWith: 'echo [MOCK] Checking for automated PR', + }, + { + name: 'Check if merged pull request has `CP Staging` label', + mockWith: 'echo [MOCK] Checking CP Staging', + }, + { + name: 'Check if merged pull request should trigger a deploy', + mockWith: 'echo [MOCK] Checking deploy trigger', + }, +]; + +const SKIP_DEPLOY_MOCK_STEPS = [ + { + name: 'Comment on deferred PR', + mockWith: 'echo [MOCK] Skipping deploy', + }, +]; + +const CREATE_NEW_VERSION_JOB_MOCK_STEPS = [ + { + name: 'Create new version', + mockWith: 'echo [MOCK] Creating new version', + }, +]; + +const UPDATE_STAGING_JOB_MOCK_STEPS = [ + { + name: 'Run turnstyle', + mockWith: 'echo [MOCK] Running turnstyle', + }, + { + name: 'Update staging branch from main', + mockWith: 'echo [MOCK] Updating staging branch', + }, + { + name: 'Cherry-pick PR to staging', + mockWith: 'echo [MOCK] Cherry picking', + }, + { + name: 'Checkout staging', + mockWith: 'echo [MOCK] Checking out staging', + }, + { + name: 'Tag staging', + mockWith: 'echo [MOCK] Tagging staging', + }, + { + name: 'Update StagingDeployCash', + mockWith: 'echo [MOCK] Updating StagingDeployCash', + }, + { + name: 'Find open StagingDeployCash', + mockWith: 'echo [MOCK] Finding open StagingDeployCash', + }, + { + name: 'Comment in StagingDeployCash to alert Applause that a new pull request has been cherry-picked', + mockWith: 'echo [MOCK] Commenting in StagingDeployCash', + }, + { + name: 'Wait for staging deploys to finish', + mockWith: 'echo [MOCK] Waiting for staging deploy to finish', + }, + { + name: 'Comment in StagingDeployCash to alert Applause that cherry-picked pull request has been deployed.', + mockWith: 'echo [MOCK] Commenting in StagingDeployCash', + }, + { + name: 'Announce failed workflow in Slack', + mockWith: 'echo [MOCK] Announcing failed workflow in slack', + }, +]; + +const IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS = [ + { + name: 'Get merged pull request', + mockWith: 'echo [MOCK] Getting merged pull request', + }, + { + name: 'Check whether the actor is member of Expensify/expensify team', + mockWith: 'echo [MOCK] Checking actor\'s Expensify membership', + }, +]; + +const NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS = [ + { + name: 'Checkout', + mockWith: 'echo [MOCK] Checking out', + }, + { + name: 'Get merged pull request', + mockWith: 'echo [MOCK] Getting merged pull request', + }, + { + name: 'Get PR count for ${{ steps.getMergedPullRequest.outputs.author }}', + mockWith: 'echo [MOCK] Getting PR count', + }, + { + name: 'Comment on ${{ steps.getMergedPullRequest.outputs.author }}\'s first pull request!', + mockWith: 'echo [MOCK] Creating comment', + }, +]; + +const E2E_TESTS_JOB_MOCK_STEPS = [ + { + name: 'Checkout', + mockWith: 'echo [MOCK] Checking out', + }, + { + name: 'Setup node', + mockWith: 'echo [MOCK] Setting up node', + }, + { + name: 'Setup ruby', + mockWith: 'echo [MOCK] Setting up ruby', + }, + { + name: 'Gradle cache', + mockWith: 'echo [MOCK] Building with gradle', + }, + { + name: 'Make zip directory for everything to send to AWS Device Farm', + mockWith: 'echo [MOCK] Creating zip directory', + }, + { + name: 'Checkout "Compare" commit', + mockWith: 'echo [MOCK] Checking out compare commit', + }, + { + name: 'Install node packages', + mockWith: 'echo [MOCK] Installing node packages', + }, + { + name: 'Build "Compare" APK', + mockWith: 'echo [MOCK] Building compare apk', + }, + { + name: 'Copy "Compare" APK', + mockWith: 'echo [MOCK] Copying compare apk', + }, + { + name: 'Checkout "Baseline" commit (last release)', + mockWith: 'echo [MOCK] Checking out baseline commit', + }, + { + name: 'Install node packages', + mockWith: 'echo [MOCK] Installing node packages', + }, + { + name: 'Build "Baseline" APK', + mockWith: 'echo [MOCK] Building baseline apk', + }, + { + name: 'Copy "Baseline" APK', + mockWith: 'echo [MOCK] Copying baseline apk', + }, + { + name: 'Checkout previous branch for source code to run on AWS Device farm', + mockWith: 'echo [MOCK] Checking out previous branch', + }, + { + name: 'Copy e2e code into zip folder', + mockWith: 'echo [MOCK] Copying e2e tests', + }, + { + name: 'Zip everything in the zip directory up', + mockWith: 'echo [MOCK] Zipping everything', + }, + { + name: 'Configure AWS Credentials', + mockWith: 'echo [MOCK] Configuring AWS credentials', + }, + { + name: 'Schedule AWS Device Farm test run', + mockWith: 'echo [MOCK] Scheduling AWS test run', + }, + { + name: 'Unzip AWS Device Farm results', + mockWith: 'echo [MOCK] Unzipping test results', + }, + { + name: 'Print AWS Device Farm run results', + mockWith: 'echo [MOCK] Printing test results', + }, + { + name: 'Set output of AWS Device Farm into GitHub ENV', + mockWith: 'echo [MOCK] Setting AWS output', + }, + { + name: 'Get merged pull request', + mockWith: 'echo [MOCK] Getting merged pull request', + }, + { + name: 'Leave output of AWS Device Farm as a PR comment', + mockWith: 'echo [MOCK] Leaving comment with test results', + }, + { + name: 'Check if test failed, if so leave a deploy blocker label', + mockWith: 'echo [MOCK] Checking if tests failed', + }, +]; + const WIP_MOCK_STEPS = { - lint: [ - { - uses: 'Expensify/App/.github/workflows/lint.yml@main', - mockWith: 'echo [MOCK] Running lint workflow', - }, - ], - test: [ - { - uses: 'Expensify/App/.github/workflows/test.yml@main', - mockWith: 'echo [MOCK] Running test workflow', - }, - ], - confirmPassingBuild: [ - { - uses: 'Expensify/App/.github/actions/composite/announceFailedWorkflowInSlack@main', - mockWith: 'echo [MOCK] Announcing failed workflow in slack', - }, - { - run: 'exit 1', - mockWith: 'echo [MOCK] Exiting with failed status', - }, - ], - chooseDeployActions: [ - { - uses: 'actions-ecosystem/action-get-merged-pull-request@59afe90821bb0b555082ce8ff1e36b03f91553d9', - mockWith: 'echo [MOCK] Getting merged pull request', - }, - { - uses: 'Expensify/App/.github/actions/javascript/isStagingDeployLocked@main', - mockWith: 'echo [MOCK] Checking StagingDeployCash', - }, - { - run: 'echo "IS_AUTOMATED_PR=${{ github.actor == \'OSBotify\' }}" >> "$GITHUB_OUTPUT"', - mockWith: 'echo [MOCK] Checking for automated PR', - }, - { - run: 'echo "HAS_CP_LABEL=${{ contains(steps.getMergedPullRequest.outputs.labels, \'CP Staging\') }}" >> "$GITHUB_OUTPUT"', - mockWith: 'echo [MOCK] Checking CP Staging', - }, - { - run: 'echo "SHOULD_DEPLOY=${{ fromJSON(steps.hasCherryPickLabel.outputs.HAS_CP_LABEL) || (!fromJSON(steps.isStagingDeployLocked.outputs.IS_LOCKED) && !fromJSON(steps.isAutomatedPullRequest.outputs.IS_AUTOMATED_PR)) }}" >> "$GITHUB_OUTPUT"', - mockWith: 'echo [MOCK] Checking deploy trigger', - }, - ], - skipDeploy: [ - { - uses: 'actions-ecosystem/action-create-comment@cd098164398331c50e7dfdd0dfa1b564a1873fac', - mockWith: 'echo [MOCK] Skipping deploy', - }, - ], - createNewVersion: [ - { - uses: 'Expensify/App/.github/workflows/createNewVersion.yml@main', - mockWith: 'echo [MOCK] Creating new version', - }, - ], - updateStaging: [ - { - uses: 'softprops/turnstyle@ca99add00ff0c9cbc697d22631d2992f377e5bd5', - mockWith: 'echo [MOCK] Running turnstyle', - }, - { - uses: 'Expensify/App/.github/actions/composite/updateProtectedBranch@main', - mockWith: 'echo [MOCK] Updating staging branch', - }, - { - uses: 'Expensify/App/.github/actions/javascript/triggerWorkflowAndWait@main', - mockWith: 'echo [MOCK] Cherry picking', - }, - { - uses: 'actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8', - mockWith: 'echo [MOCK] Checking out staging', - }, - { - run: 'git tag ${{ needs.createNewVersion.outputs.NEW_VERSION }}', - mockWith: 'echo [MOCK] Tagging staging', - }, - { - uses: 'Expensify/App/.github/actions/javascript/createOrUpdateStagingDeploy@main', - mockWith: 'echo [MOCK] Updating StagingDeployCash', - }, - { - run: 'echo "STAGING_DEPLOY_CASH=$(gh issue list --label StagingDeployCash --json number --jq \'.[0].number\')" >> "$GITHUB_OUTPUT"', - mockWith: 'echo [MOCK] Finding open StagingDeployCash', - }, - { - name: 'Wait for staging deploys to finish', - mockWith: 'echo [MOCK] Waiting for staging deploy to finish', - }, - { - name: 'Comment in StagingDeployCash to alert Applause that a new pull request has been cherry-picked', - mockWith: 'echo [MOCK] Commenting in StagingDeployCash', - }, - { - name: 'Comment in StagingDeployCash to alert Applause that cherry-picked pull request has been deployed.', - mockWith: 'echo [MOCK] Commenting in StagingDeployCash', - }, - { - uses: 'Expensify/App/.github/actions/composite/announceFailedWorkflowInSlack@main', - mockWith: 'echo [MOCK] Announcing failed workflow in slack', - }, - ], - isExpensifyEmployee: [ - { - name: 'Get merged pull request', - mockWith: 'echo [MOCK] Getting merged pull request', - }, - { - name: 'Check whether the actor is member of Expensify/expensify team', - mockWith: 'echo [MOCK] Checking actor\'s Expensify membership', - }, - ], - newContributorWelcomeMessage: [ - { - uses: 'actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8', - mockWith: 'echo [MOCK] Checking out', - }, - { - name: 'Get merged pull request', - mockWith: 'echo [MOCK] Getting merged pull request', - }, - { - name: 'Get PR count for ${{ steps.getMergedPullRequest.outputs.author }}', - mockWith: 'echo [MOCK] Getting PR count', - }, - { - uses: 'actions-ecosystem/action-create-comment@cd098164398331c50e7dfdd0dfa1b564a1873fac', - mockWith: 'echo [MOCK] Creating comment', - }, - ], - 'e2e-tests': [ - { - uses: 'actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8', - mockWith: 'echo [MOCK] Checking out', - }, - { - uses: 'Expensify/App/.github/actions/composite/setupNode@main', - mockWith: 'echo [MOCK] Setting up node', - }, - { - name: 'Gradle cache', - mockWith: 'echo [MOCK] Building with gradle', - }, - { - name: 'Make zip directory for everything to send to AWS Device Farm', - mockWith: 'echo [MOCK] Creating zip directory', - }, - { - name: 'Checkout "Compare" commit', - mockWith: 'echo [MOCK] Checking out compare commit', - }, - { - name: 'Install node packages', - mockWith: 'echo [MOCK] Installing node packages', - }, - { - name: 'Build "Compare" APK', - mockWith: 'echo [MOCK] Building compare apk', - }, - { - name: 'Copy "Compare" APK', - mockWith: 'echo [MOCK] Copying compare apk', - }, - { - name: 'Checkout "Baseline" commit (last release)', - mockWith: 'echo [MOCK] Checking out baseline commit', - }, - { - name: 'Build "Baseline" APK', - mockWith: 'echo [MOCK] Building baseline apk', - }, - { - name: 'Copy "Baseline" APK', - mockWith: 'echo [MOCK] Copying baseline apk', - }, - { - name: 'Checkout previous branch for source code to run on AWS Device farm', - mockWith: 'echo [MOCK] Checking out previous branch', - }, - { - name: 'Copy e2e code into zip folder', - mockWith: 'echo [MOCK] Copying e2e tests', - }, - { - name: 'Zip everything in the zip directory up', - mockWith: 'echo [MOCK] Zipping everything', - }, - { - name: 'Configure AWS Credentials', - mockWith: 'echo [MOCK] Configuring AWS credentials', - }, - { - name: 'Schedule AWS Device Farm test run', - mockWith: 'echo [MOCK] Scheduling AWS test run', - }, - { - name: 'Unzip AWS Device Farm results', - mockWith: 'echo [MOCK] Unzipping test results', - }, - { - name: 'Print AWS Device Farm run results', - mockWith: 'echo [MOCK] Printing test results', - }, - { - name: 'Set output of AWS Device Farm into GitHub ENV', - mockWith: 'echo [MOCK] Setting AWS output', - }, - { - name: 'Get merged pull request', - mockWith: 'echo [MOCK] Getting merged pull request', - }, - { - name: 'Leave output of AWS Device Farm as a PR comment', - mockWith: 'echo [MOCK] Leaving comment with test results', - }, - { - name: 'Check if test failed, if so leave a deploy blocker label', - mockWith: 'echo [MOCK] Checking if tests failed', - }, - ], + lint: LINT_JOB_MOCK_STEPS, + test: TEST_JOB_MOCK_STEPS, + confirmPassingBuild: CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, + chooseDeployActions: CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS, + skipDeploy: SKIP_DEPLOY_MOCK_STEPS, + createNewVersion: CREATE_NEW_VERSION_JOB_MOCK_STEPS, + updateStaging: UPDATE_STAGING_JOB_MOCK_STEPS, + isExpensifyEmployee: IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS, + newContributorWelcomeMessage: NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS, + 'e2e-tests': E2E_TESTS_JOB_MOCK_STEPS, }; -test('test preDeploy push to main', async () => { +test('test workflow preDeploy push to main', async () => { // get path to the local test repo const repoPath = mockGithub.repo.getPath('testWorkflowsRepo') || ''; From abd6d5678686a36799643b72da5a2cd8ab59a33c Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Tue, 21 Feb 2023 16:39:40 +0100 Subject: [PATCH 006/504] Fix steps mocks [WiP] Updated the step mocks to allow for producing outputs that steer the further workflow execution. Also added run params to the act call See: https://github.com/Expensify/App/issues/13604 --- .github/workflows/preDeploy.yml | 18 ++-- workflow_tests/preDeploy.test.ts | 143 ++++++++++++++++++------------- 2 files changed, 94 insertions(+), 67 deletions(-) diff --git a/.github/workflows/preDeploy.yml b/.github/workflows/preDeploy.yml index 27412f07d253..619ef7b3d43b 100644 --- a/.github/workflows/preDeploy.yml +++ b/.github/workflows/preDeploy.yml @@ -6,12 +6,16 @@ on: jobs: lint: - name: Run lint workflow - uses: Expensify/App/.github/workflows/lint.yml@main + runs-on: ubuntu-latest + steps: + - name: Run lint workflow + uses: Expensify/App/.github/workflows/lint.yml@main test: - name: Run test workflow - uses: Expensify/App/.github/workflows/test.yml@main + runs-on: ubuntu-latest + steps: + - name: Run test workflow + uses: Expensify/App/.github/workflows/test.yml@main confirmPassingBuild: runs-on: ubuntu-latest @@ -77,11 +81,13 @@ jobs: :hand: This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. createNewVersion: + runs-on: ubuntu-latest needs: chooseDeployActions if: ${{ fromJSON(needs.chooseDeployActions.outputs.SHOULD_DEPLOY) }} - name: Create new version - uses: Expensify/App/.github/workflows/createNewVersion.yml@main secrets: inherit + steps: + - name: Create new version + uses: Expensify/App/.github/workflows/createNewVersion.yml@main updateStaging: needs: [chooseDeployActions, createNewVersion] diff --git a/workflow_tests/preDeploy.test.ts b/workflow_tests/preDeploy.test.ts index 250fc05f51b6..d8ffc7c0f5b2 100644 --- a/workflow_tests/preDeploy.test.ts +++ b/workflow_tests/preDeploy.test.ts @@ -50,238 +50,246 @@ afterEach(async () => { const LINT_JOB_MOCK_STEPS = [ { name: 'Run lint workflow', - mockWith: 'echo [MOCK] Running lint workflow', + mockWith: 'echo [MOCK] [LINT] Running lint workflow', }, ]; const TEST_JOB_MOCK_STEPS = [ { name: 'Run test workflow', - mockWith: 'echo [MOCK] Running test workflow', + mockWith: 'echo [MOCK] [TEST] Running test workflow', }, ]; const CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS = [ { name: 'Announce failed workflow in Slack', - mockWith: 'echo [MOCK] Announcing failed workflow in slack', + mockWith: 'echo [MOCK] [CONFIRM_PASSING_BUILD] Announcing failed workflow in slack', }, { name: 'Exit failed workflow', - mockWith: 'echo [MOCK] Exiting with failed status', + mockWith: 'echo [MOCK] [CONFIRM_PASSING_BUILD] Exiting with failed status', }, ]; const CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS = [ { name: 'Get merged pull request', - mockWith: 'echo [MOCK] Getting merged pull request', + mockWith: 'echo [MOCK] [CHOOSE_DEPLOY_ACTIONS] Getting merged pull request\n' + + 'echo "number=1" >> "$GITHUB_OUTPUT"', }, { name: 'Check if StagingDeployCash is locked', - mockWith: 'echo [MOCK] Checking StagingDeployCash', + mockWith: 'echo [MOCK] [CHOOSE_DEPLOY_ACTIONS] Checking StagingDeployCash\n' + + 'echo "IS_LOCKED=false" >> "$GITHUB_OUTPUT"', }, { name: 'Check if merged pull request was an automated PR', - mockWith: 'echo [MOCK] Checking for automated PR', + mockWith: 'echo [MOCK] [CHOOSE_DEPLOY_ACTIONS] Checking for automated PR\n' + + 'echo "IS_AUTOMATED_PR=false" >> "$GITHUB_OUTPUT"', }, { name: 'Check if merged pull request has `CP Staging` label', - mockWith: 'echo [MOCK] Checking CP Staging', + mockWith: 'echo [MOCK] [CHOOSE_DEPLOY_ACTIONS] Checking CP Staging\n' + + 'echo "HAS_CP_LABEL=false" >> "$GITHUB_OUTPUT"', }, { name: 'Check if merged pull request should trigger a deploy', - mockWith: 'echo [MOCK] Checking deploy trigger', + mockWith: 'echo [MOCK] [CHOOSE_DEPLOY_ACTIONS] Checking deploy trigger\n' + + 'echo "SHOULD_DEPLOY=true" >> "$GITHUB_OUTPUT"', }, ]; -const SKIP_DEPLOY_MOCK_STEPS = [ +const SKIP_DEPLOY_JOB_MOCK_STEPS = [ { name: 'Comment on deferred PR', - mockWith: 'echo [MOCK] Skipping deploy', + mockWith: 'echo [MOCK] [SKIP_DEPLOY] Skipping deploy', }, ]; const CREATE_NEW_VERSION_JOB_MOCK_STEPS = [ { name: 'Create new version', - mockWith: 'echo [MOCK] Creating new version', + mockWith: 'echo [MOCK] [CREATE_NEW_VERSION] Creating new version', }, ]; const UPDATE_STAGING_JOB_MOCK_STEPS = [ { name: 'Run turnstyle', - mockWith: 'echo [MOCK] Running turnstyle', + mockWith: 'echo [MOCK] [UPDATE_STAGING] Running turnstyle', }, { name: 'Update staging branch from main', - mockWith: 'echo [MOCK] Updating staging branch', + mockWith: 'echo [MOCK] [UPDATE_STAGING] Updating staging branch', }, { name: 'Cherry-pick PR to staging', - mockWith: 'echo [MOCK] Cherry picking', + mockWith: 'echo [MOCK] [UPDATE_STAGING] Cherry picking', }, { name: 'Checkout staging', - mockWith: 'echo [MOCK] Checking out staging', + mockWith: 'echo [MOCK] [UPDATE_STAGING] Checking out staging', }, { name: 'Tag staging', - mockWith: 'echo [MOCK] Tagging staging', + mockWith: 'echo [MOCK] [UPDATE_STAGING] Tagging staging', }, { name: 'Update StagingDeployCash', - mockWith: 'echo [MOCK] Updating StagingDeployCash', + mockWith: 'echo [MOCK] [UPDATE_STAGING] Updating StagingDeployCash', }, { name: 'Find open StagingDeployCash', - mockWith: 'echo [MOCK] Finding open StagingDeployCash', + mockWith: 'echo [MOCK] [UPDATE_STAGING] Finding open StagingDeployCash\n' + + 'echo "STAGING_DEPLOY_CASH=1234" >> "$GITHUB_OUTPUT"', }, { name: 'Comment in StagingDeployCash to alert Applause that a new pull request has been cherry-picked', - mockWith: 'echo [MOCK] Commenting in StagingDeployCash', + mockWith: 'echo [MOCK] [UPDATE_STAGING] Commenting in StagingDeployCash', }, { name: 'Wait for staging deploys to finish', - mockWith: 'echo [MOCK] Waiting for staging deploy to finish', + mockWith: 'echo [MOCK] [UPDATE_STAGING] Waiting for staging deploy to finish', }, { name: 'Comment in StagingDeployCash to alert Applause that cherry-picked pull request has been deployed.', - mockWith: 'echo [MOCK] Commenting in StagingDeployCash', + mockWith: 'echo [MOCK] [UPDATE_STAGING] Commenting in StagingDeployCash', }, { name: 'Announce failed workflow in Slack', - mockWith: 'echo [MOCK] Announcing failed workflow in slack', + mockWith: 'echo [MOCK] [UPDATE_STAGING] Announcing failed workflow in slack', }, ]; const IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS = [ { name: 'Get merged pull request', - mockWith: 'echo [MOCK] Getting merged pull request', + mockWith: 'echo [MOCK] [IS_EXPENSIFY_EMPLOYEE] Getting merged pull request\n' + + 'echo "author=Dummy Author" >> "$GITHUB_OUTPUT"', }, { name: 'Check whether the actor is member of Expensify/expensify team', - mockWith: 'echo [MOCK] Checking actor\'s Expensify membership', + mockWith: 'echo [MOCK] [IS_EXPENSIFY_EMPLOYEE] Checking actors Expensify membership\n' + + 'echo "isTeamMember=true" >> "$GITHUB_OUTPUT"', }, ]; const NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS = [ { name: 'Checkout', - mockWith: 'echo [MOCK] Checking out', + mockWith: 'echo [MOCK] [NEW_CONTRIBUTOR_WELCOME_MESSAGE] Checking out', }, { name: 'Get merged pull request', - mockWith: 'echo [MOCK] Getting merged pull request', + mockWith: 'echo [MOCK] [NEW_CONTRIBUTOR_WELCOME_MESSAGE] Getting merged pull request', }, { name: 'Get PR count for ${{ steps.getMergedPullRequest.outputs.author }}', - mockWith: 'echo [MOCK] Getting PR count', + mockWith: 'echo [MOCK] [NEW_CONTRIBUTOR_WELCOME_MESSAGE] Getting PR count', }, { - name: 'Comment on ${{ steps.getMergedPullRequest.outputs.author }}\'s first pull request!', - mockWith: 'echo [MOCK] Creating comment', + name: 'Comment on ${{ steps.getMergedPullRequest.outputs.author }}\\\'s first pull request!', + mockWith: 'echo [MOCK] [NEW_CONTRIBUTOR_WELCOME_MESSAGE] Creating comment', }, ]; const E2E_TESTS_JOB_MOCK_STEPS = [ { name: 'Checkout', - mockWith: 'echo [MOCK] Checking out', + mockWith: 'echo [MOCK] [E2E_TESTS] Checking out', }, { name: 'Setup node', - mockWith: 'echo [MOCK] Setting up node', + mockWith: 'echo [MOCK] [E2E_TESTS] Setting up node', }, { name: 'Setup ruby', - mockWith: 'echo [MOCK] Setting up ruby', + mockWith: 'echo [MOCK] [E2E_TESTS] Setting up ruby', }, { name: 'Gradle cache', - mockWith: 'echo [MOCK] Building with gradle', + mockWith: 'echo [MOCK] [E2E_TESTS] Building with gradle', }, { name: 'Make zip directory for everything to send to AWS Device Farm', - mockWith: 'echo [MOCK] Creating zip directory', + mockWith: 'echo [MOCK] [E2E_TESTS] Creating zip directory', }, { name: 'Checkout "Compare" commit', - mockWith: 'echo [MOCK] Checking out compare commit', + mockWith: 'echo [MOCK] [E2E_TESTS] Checking out compare commit', }, { name: 'Install node packages', - mockWith: 'echo [MOCK] Installing node packages', + mockWith: 'echo [MOCK] [E2E_TESTS] Installing node packages', }, { name: 'Build "Compare" APK', - mockWith: 'echo [MOCK] Building compare apk', + mockWith: 'echo [MOCK] [E2E_TESTS] Building compare apk', }, { name: 'Copy "Compare" APK', - mockWith: 'echo [MOCK] Copying compare apk', + mockWith: 'echo [MOCK] [E2E_TESTS] Copying compare apk', }, { name: 'Checkout "Baseline" commit (last release)', - mockWith: 'echo [MOCK] Checking out baseline commit', + mockWith: 'echo [MOCK] [E2E_TESTS] Checking out baseline commit', }, { name: 'Install node packages', - mockWith: 'echo [MOCK] Installing node packages', + mockWith: 'echo [MOCK] [E2E_TESTS] Installing node packages', }, { name: 'Build "Baseline" APK', - mockWith: 'echo [MOCK] Building baseline apk', + mockWith: 'echo [MOCK] [E2E_TESTS] Building baseline apk', }, { name: 'Copy "Baseline" APK', - mockWith: 'echo [MOCK] Copying baseline apk', + mockWith: 'echo [MOCK] [E2E_TESTS] Copying baseline apk', }, { name: 'Checkout previous branch for source code to run on AWS Device farm', - mockWith: 'echo [MOCK] Checking out previous branch', + mockWith: 'echo [MOCK] [E2E_TESTS] Checking out previous branch', }, { name: 'Copy e2e code into zip folder', - mockWith: 'echo [MOCK] Copying e2e tests', + mockWith: 'echo [MOCK] [E2E_TESTS] Copying e2e tests', }, { name: 'Zip everything in the zip directory up', - mockWith: 'echo [MOCK] Zipping everything', + mockWith: 'echo [MOCK] [E2E_TESTS] Zipping everything', }, { name: 'Configure AWS Credentials', - mockWith: 'echo [MOCK] Configuring AWS credentials', + mockWith: 'echo [MOCK] [E2E_TESTS] Configuring AWS credentials', }, { name: 'Schedule AWS Device Farm test run', - mockWith: 'echo [MOCK] Scheduling AWS test run', + mockWith: 'echo [MOCK] [E2E_TESTS] Scheduling AWS test run', }, { name: 'Unzip AWS Device Farm results', - mockWith: 'echo [MOCK] Unzipping test results', + mockWith: 'echo [MOCK] [E2E_TESTS] Unzipping test results', }, { name: 'Print AWS Device Farm run results', - mockWith: 'echo [MOCK] Printing test results', + mockWith: 'echo [MOCK] [E2E_TESTS] Printing test results', }, { name: 'Set output of AWS Device Farm into GitHub ENV', - mockWith: 'echo [MOCK] Setting AWS output', + mockWith: 'echo [MOCK] [E2E_TESTS] Setting AWS output', }, { name: 'Get merged pull request', - mockWith: 'echo [MOCK] Getting merged pull request', + mockWith: 'echo [MOCK] [E2E_TESTS] Getting merged pull request', }, { name: 'Leave output of AWS Device Farm as a PR comment', - mockWith: 'echo [MOCK] Leaving comment with test results', + mockWith: 'echo [MOCK] [E2E_TESTS] Leaving comment with test results', }, { name: 'Check if test failed, if so leave a deploy blocker label', - mockWith: 'echo [MOCK] Checking if tests failed', + mockWith: 'echo [MOCK] [E2E_TESTS] Checking if tests failed', }, ]; @@ -290,7 +298,7 @@ const WIP_MOCK_STEPS = { test: TEST_JOB_MOCK_STEPS, confirmPassingBuild: CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, chooseDeployActions: CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS, - skipDeploy: SKIP_DEPLOY_MOCK_STEPS, + skipDeploy: SKIP_DEPLOY_JOB_MOCK_STEPS, createNewVersion: CREATE_NEW_VERSION_JOB_MOCK_STEPS, updateStaging: UPDATE_STAGING_JOB_MOCK_STEPS, isExpensifyEmployee: IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS, @@ -306,16 +314,29 @@ test('test workflow preDeploy push to main', async () => { const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); // instantiate Act in the context of the test repo and given workflow file - const act = new Act(repoPath, workflowPath); + let act = new Act(repoPath, workflowPath); + + // set run parameters + act = act + .setEvent({ + pull_request: { + head: { + ref: 'main', + }, + }, + }) + .setSecret('OS_BOTIFY_TOKEN', 'dummy_token') + .setGithubToken('dummy_github_token'); // run an event and get the result - const result = await act.runEvent('push', { - workflowFile: path.join(repoPath, '.github', 'workflows'), - mockSteps: WIP_MOCK_STEPS, - }); + const result = await act + .runEvent('push', { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: WIP_MOCK_STEPS, + }); console.debug(`RunEvent result: ${JSON.stringify(result, null, '\t')}`); // assert results // expect(result)...; -}); +}, 300000); From 09a7610cf99c20199a904db8336d417230e42e68 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Wed, 22 Feb 2023 12:34:37 +0100 Subject: [PATCH 007/504] Add output assertions [WiP] Added the option to assert the output of workflow run and compare it to a set of expected values See: https://github.com/Expensify/App/issues/13604 --- workflow_tests/preDeploy.test.ts | 364 ++++++++++++++++++++++++++++--- 1 file changed, 334 insertions(+), 30 deletions(-) diff --git a/workflow_tests/preDeploy.test.ts b/workflow_tests/preDeploy.test.ts index d8ffc7c0f5b2..6d90acb483fb 100644 --- a/workflow_tests/preDeploy.test.ts +++ b/workflow_tests/preDeploy.test.ts @@ -81,7 +81,7 @@ const CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS = [ { name: 'Check if StagingDeployCash is locked', mockWith: 'echo [MOCK] [CHOOSE_DEPLOY_ACTIONS] Checking StagingDeployCash\n' - + 'echo "IS_LOCKED=false" >> "$GITHUB_OUTPUT"', + + 'echo "IS_LOCKED=true" >> "$GITHUB_OUTPUT"', }, { name: 'Check if merged pull request was an automated PR', @@ -91,7 +91,7 @@ const CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS = [ { name: 'Check if merged pull request has `CP Staging` label', mockWith: 'echo [MOCK] [CHOOSE_DEPLOY_ACTIONS] Checking CP Staging\n' - + 'echo "HAS_CP_LABEL=false" >> "$GITHUB_OUTPUT"', + + 'echo "HAS_CP_LABEL=true" >> "$GITHUB_OUTPUT"', }, { name: 'Check if merged pull request should trigger a deploy', @@ -293,7 +293,7 @@ const E2E_TESTS_JOB_MOCK_STEPS = [ }, ]; -const WIP_MOCK_STEPS = { +const MOCK_STEPS = { lint: LINT_JOB_MOCK_STEPS, test: TEST_JOB_MOCK_STEPS, confirmPassingBuild: CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, @@ -306,37 +306,341 @@ const WIP_MOCK_STEPS = { 'e2e-tests': E2E_TESTS_JOB_MOCK_STEPS, }; -test('test workflow preDeploy push to main', async () => { - // get path to the local test repo - const repoPath = mockGithub.repo.getPath('testWorkflowsRepo') || ''; +const assertLintJobExecuted = (workflowResult: Array, didExecute: Boolean = true) => { + const steps = [{ + name: 'Main Run lint workflow', + status: 0, + output: '[MOCK] [LINT] Running lint workflow', + }]; + if (didExecute) { + expect(workflowResult).toEqual(expect.arrayContaining(steps)); + } else { + expect(workflowResult).not.toEqual(steps); + } +}; + +const assertTestJobExecuted = (workflowResult: Array, didExecute: Boolean = true) => { + const steps = [{ + name: 'Main Run test workflow', + status: 0, + output: '[MOCK] [TEST] Running test workflow', + }]; + if (didExecute) { + expect(workflowResult).toEqual(expect.arrayContaining(steps)); + } else { + expect(workflowResult).not.toEqual(steps); + } +}; + +const assertIsExpensifyEmployeeJobExecuted = (workflowResult: Array, didExecute: Boolean = true) => { + const steps = [{ + name: 'Main Get merged pull request', + status: 0, + output: '[MOCK] [IS_EXPENSIFY_EMPLOYEE] Getting merged pull request', + }, + { + name: 'Main Check whether the actor is member of Expensify/expensify team', + status: 0, + output: '[MOCK] [IS_EXPENSIFY_EMPLOYEE] Checking actors Expensify membership', + }]; + if (didExecute) { + expect(workflowResult).toEqual(expect.arrayContaining(steps)); + } else { + expect(workflowResult).not.toEqual(steps); + } +}; + +const assertE2ETestsJobExecuted = (workflowResult: Array, didExecute: Boolean = true) => { + const steps = [ + { + name: 'Main Checkout', + status: 0, + output: '[MOCK] [E2E_TESTS] Checking out', + }, + { + name: 'Main Setup node', + status: 0, + output: '[MOCK] [E2E_TESTS] Setting up node', + }, + { + name: 'Main Setup ruby', + status: 0, + output: '[MOCK] [E2E_TESTS] Setting up ruby', + }, + { + name: 'Main Gradle cache', + status: 0, + output: '[MOCK] [E2E_TESTS] Building with gradle', + }, + { + name: 'Make zip directory for everything to send to AWS Device Farm', + status: 0, + output: '[MOCK] [E2E_TESTS] Creating zip directory', + }, + { + name: 'Checkout "Compare" commit', + status: 0, + output: '[MOCK] [E2E_TESTS] Checking out compare commit', + }, + { + name: 'Install node packages', + status: 0, + output: '[MOCK] [E2E_TESTS] Installing node packages', + }, + { + name: 'Build "Compare" APK', + status: 0, + output: '[MOCK] [E2E_TESTS] Building compare apk', + }, + { + name: 'Copy "Compare" APK', + status: 0, + output: '[MOCK] [E2E_TESTS] Copying compare apk', + }, + { + name: 'Checkout "Baseline" commit (last release)', + status: 0, + output: '[MOCK] [E2E_TESTS] Checking out baseline commit', + }, + { + name: 'Install node packages', + status: 0, + output: '[MOCK] [E2E_TESTS] Installing node packages', + }, + { + name: 'Build "Baseline" APK', + status: 0, + output: '[MOCK] [E2E_TESTS] Building baseline apk', + }, + { + name: 'Copy "Baseline" APK', + status: 0, + output: '[MOCK] [E2E_TESTS] Copying baseline apk', + }, + { + name: 'Checkout previous branch for source code to run on AWS Device farm', + status: 0, + output: '[MOCK] [E2E_TESTS] Checking out previous branch', + }, + { + name: 'Copy e2e code into zip folder', + status: 0, + output: '[MOCK] [E2E_TESTS] Copying e2e tests', + }, + { + name: 'Zip everything in the zip directory up', + status: 0, + output: '[MOCK] [E2E_TESTS] Zipping everything', + }, + { + name: 'Configure AWS Credentials', + status: 0, + output: '[MOCK] [E2E_TESTS] Configuring AWS credentials', + }, + { + name: 'Schedule AWS Device Farm test run', + status: 0, + output: '[MOCK] [E2E_TESTS] Scheduling AWS test run', + }, + { + name: 'Unzip AWS Device Farm results', + status: 0, + output: '[MOCK] [E2E_TESTS] Unzipping test results', + }, + { + name: 'Print AWS Device Farm run results', + status: 0, + output: '[MOCK] [E2E_TESTS] Printing test results', + }, + { + name: 'Set output of AWS Device Farm into GitHub ENV', + status: 0, + output: '[MOCK] [E2E_TESTS] Setting AWS output', + }, + { + name: 'Get merged pull request', + status: 0, + output: '[MOCK] [E2E_TESTS] Getting merged pull request', + }, + { + name: 'Leave output of AWS Device Farm as a PR comment', + status: 0, + output: '[MOCK] [E2E_TESTS] Leaving comment with test results', + }, + { + name: 'Check if test failed, if so leave a deploy blocker label', + status: 0, + output: '[MOCK] [E2E_TESTS] Checking if tests failed', + }, + ]; + if (didExecute) { + expect(workflowResult).toEqual(expect.arrayContaining(steps)); + } else { + expect(workflowResult).not.toEqual(steps); + } +}; - // get path to the workflow file under test - const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); +const assertChooseDeployActionsJobExecuted = (workflowResult: Array, didExecute: Boolean = true) => { + const steps = [ + { + name: 'Main Get merged pull request', + status: 0, + output: '[MOCK] [CHOOSE_DEPLOY_ACTIONS] Getting merged pull request', + }, + { + name: 'Main Check if StagingDeployCash is locked', + status: 0, + output: '[MOCK] [CHOOSE_DEPLOY_ACTIONS] Checking StagingDeployCash', + }, + { + name: 'Main Check if merged pull request was an automated PR', + status: 0, + output: '[MOCK] [CHOOSE_DEPLOY_ACTIONS] Checking for automated PR', + }, + { + name: 'Main Check if merged pull request has `CP Staging` label', + status: 0, + output: '[MOCK] [CHOOSE_DEPLOY_ACTIONS] Checking CP Staging', + }, + { + name: 'Main Check if merged pull request should trigger a deploy', + status: 0, + output: '[MOCK] [CHOOSE_DEPLOY_ACTIONS] Checking deploy trigger', + }, + ]; + if (didExecute) { + expect(workflowResult).toEqual(expect.arrayContaining(steps)); + } else { + expect(workflowResult).not.toEqual(steps); + } +}; - // instantiate Act in the context of the test repo and given workflow file - let act = new Act(repoPath, workflowPath); +const assertSkipDeployJobExecuted = (workflowResult: Array, didExecute: Boolean = true) => { + const steps = [ + { + name: 'Main Comment on deferred PR', + status: 0, + output: '[MOCK] [SKIP_DEPLOY] Skipping deploy', + }, + ]; + if (didExecute) { + expect(workflowResult).toEqual(expect.arrayContaining(steps)); + } else { + expect(workflowResult).not.toEqual(steps); + } +}; - // set run parameters - act = act - .setEvent({ - pull_request: { - head: { - ref: 'main', +const assertCreateNewVersionJobExecuted = (workflowResult: Array, didExecute: Boolean = true) => { + const steps = [ + { + name: 'Main Create new version', + status: 0, + output: '[MOCK] [CREATE_NEW_VERSION] Creating new version', + }, + ]; + if (didExecute) { + expect(workflowResult).toEqual(expect.arrayContaining(steps)); + } else { + expect(workflowResult).not.toEqual(steps); + } +}; + +const assertUpdateStagingJobExecuted = (workflowResult: Array, didExecute: Boolean = true) => { + const steps = [ + { + name: 'Main Run turnstyle', + status: 0, + output: '[MOCK] [UPDATE_STAGING] Running turnstyle', + }, + { + name: 'Main Cherry-pick PR to staging', + status: 0, + output: '[MOCK] [UPDATE_STAGING] Cherry picking', + }, + { + name: 'Main Checkout staging', + status: 0, + output: '[MOCK] [UPDATE_STAGING] Checking out staging', + }, + { + name: 'Main Tag staging', + status: 0, + output: '[MOCK] [UPDATE_STAGING] Tagging staging', + }, + { + name: 'Main Update StagingDeployCash', + status: 0, + output: '[MOCK] [UPDATE_STAGING] Updating StagingDeployCash', + }, + { + name: 'Main Find open StagingDeployCash', + status: 0, + output: '[MOCK] [UPDATE_STAGING] Finding open StagingDeployCash', + }, + { + name: 'Main Comment in StagingDeployCash to alert Applause that a new pull request has been cherry-picked', + status: 0, + output: '[MOCK] [UPDATE_STAGING] Commenting in StagingDeployCash', + }, + { + name: 'Main Wait for staging deploys to finish', + status: 0, + output: '[MOCK] [UPDATE_STAGING] Waiting for staging deploy to finish', + }, + { + name: 'Main Comment in StagingDeployCash to alert Applause that cherry-picked pull request has been deployed.', + status: 0, + output: '[MOCK] [UPDATE_STAGING] Commenting in StagingDeployCash', + }, + ]; + if (didExecute) { + expect(workflowResult).toEqual(expect.arrayContaining(steps)); + } else { + expect(workflowResult).not.toEqual(steps); + } +}; + +describe('test workflow preDeploy', () => { + test('push to main', async () => { + // get path to the local test repo + const repoPath = mockGithub.repo.getPath('testWorkflowsRepo') || ''; + + // get path to the workflow file under test + const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); + + // instantiate Act in the context of the test repo and given workflow file + let act = new Act(repoPath, workflowPath); + + // set run parameters + act = act + .setEvent({ + pull_request: { + head: { + ref: 'main', + }, }, - }, - }) - .setSecret('OS_BOTIFY_TOKEN', 'dummy_token') - .setGithubToken('dummy_github_token'); + }) + .setSecret('OS_BOTIFY_TOKEN', 'dummy_token') + .setGithubToken('dummy_github_token'); - // run an event and get the result - const result = await act - .runEvent('push', { - workflowFile: path.join(repoPath, '.github', 'workflows'), - mockSteps: WIP_MOCK_STEPS, - }); + // run an event and get the result + const result = await act + .runEvent('push', { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: MOCK_STEPS, + }); - console.debug(`RunEvent result: ${JSON.stringify(result, null, '\t')}`); + console.debug(`RunEvent result: ${JSON.stringify(result, null, '\t')}`); - // assert results - // expect(result)...; -}, 300000); + // assert results (some steps can run in parallel to each other so the order is not assured + // therefore we can check which steps have been executed, but not the set job order + assertLintJobExecuted(result); + assertTestJobExecuted(result); + assertIsExpensifyEmployeeJobExecuted(result); + assertE2ETestsJobExecuted(result, false); // Act does not support ubuntu-20.04-64core runner and omits the job + assertChooseDeployActionsJobExecuted(result); + assertSkipDeployJobExecuted(result, false); + assertCreateNewVersionJobExecuted(result); + assertUpdateStagingJobExecuted(result); + }, 300000); +}); From a4f31c67044b711b40b01b488a615109f57382bb Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Wed, 22 Feb 2023 13:54:22 +0100 Subject: [PATCH 008/504] Add tests for failing lint/test jobs [WiP] Added the tests to check what happens when either of `lint` or `test` jobs fails, namely if `confirmPassingBuild` job gets executed and all jobs depending on `lint` and `test` being successful do not See: https://github.com/Expensify/App/issues/13604 --- workflow_tests/preDeploy.test.ts | 190 ++++++++++++++++++++++++++++--- 1 file changed, 172 insertions(+), 18 deletions(-) diff --git a/workflow_tests/preDeploy.test.ts b/workflow_tests/preDeploy.test.ts index 6d90acb483fb..4d36e010e8f2 100644 --- a/workflow_tests/preDeploy.test.ts +++ b/workflow_tests/preDeploy.test.ts @@ -1,6 +1,7 @@ import {MockGithub} from '@kie/mock-github'; import {Act} from '@kie/act-js'; import path from 'path'; +import {string} from 'prop-types'; let mockGithub: MockGithub; const FILES_TO_COPY_INTO_TEST_REPO = [ @@ -66,10 +67,11 @@ const CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS = [ name: 'Announce failed workflow in Slack', mockWith: 'echo [MOCK] [CONFIRM_PASSING_BUILD] Announcing failed workflow in slack', }, - { - name: 'Exit failed workflow', - mockWith: 'echo [MOCK] [CONFIRM_PASSING_BUILD] Exiting with failed status', - }, + + // { + // name: 'Exit failed workflow', + // mockWith: 'echo [MOCK] [CONFIRM_PASSING_BUILD] Exiting with failed status', + // }, ]; const CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS = [ @@ -600,6 +602,28 @@ const assertUpdateStagingJobExecuted = (workflowResult: Array, didExecut } }; +const setUpActParams = (act: Act, event?: string, event_options?: any, secrets?: Array, github_token?: string) => { + let updated_act = act; + + if (event && event_options) { + updated_act = updated_act.setEvent({ + event: event_options, + }); + } + + if (secrets) { + for (const [key, value] of Object.entries(secrets)) { + updated_act = updated_act.setSecret(key, String(value)); + } + } + + if (github_token) { + updated_act = updated_act.setGithubToken(github_token); + } + + return updated_act; +}; + describe('test workflow preDeploy', () => { test('push to main', async () => { // get path to the local test repo @@ -612,26 +636,24 @@ describe('test workflow preDeploy', () => { let act = new Act(repoPath, workflowPath); // set run parameters - act = act - .setEvent({ - pull_request: { - head: { - ref: 'main', - }, - }, - }) - .setSecret('OS_BOTIFY_TOKEN', 'dummy_token') - .setGithubToken('dummy_github_token'); + act = setUpActParams( + act, + 'pull_request', + {head: {ref: 'main'}}, + [{OS_BOTIFY_TOKEN: 'dummy_token'}], + 'dummy_github_token', + ); + + // set up mocks + const mocks = MOCK_STEPS; // run an event and get the result const result = await act .runEvent('push', { workflowFile: path.join(repoPath, '.github', 'workflows'), - mockSteps: MOCK_STEPS, + mockSteps: mocks, }); - console.debug(`RunEvent result: ${JSON.stringify(result, null, '\t')}`); - // assert results (some steps can run in parallel to each other so the order is not assured // therefore we can check which steps have been executed, but not the set job order assertLintJobExecuted(result); @@ -642,5 +664,137 @@ describe('test workflow preDeploy', () => { assertSkipDeployJobExecuted(result, false); assertCreateNewVersionJobExecuted(result); assertUpdateStagingJobExecuted(result); - }, 300000); + }, 60000); + + test('lint job failed', async () => { + const repoPath = mockGithub.repo.getPath('testWorkflowsRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); + let act = new Act(repoPath, workflowPath); + act = setUpActParams( + act, + 'pull_request', + {head: {ref: 'main'}}, + [{OS_BOTIFY_TOKEN: 'dummy_token'}], + 'dummy_github_token', + ); + const mocks = { + lint: [ + { + name: 'Run lint workflow', + mockWith: 'echo [MOCK] [LINT] Running lint workflow\n' + + 'echo [MOCK] [LINT] Lint workflow failed\n' + + 'exit 1', + }, + ], + test: TEST_JOB_MOCK_STEPS, + confirmPassingBuild: CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, + chooseDeployActions: CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS, + skipDeploy: SKIP_DEPLOY_JOB_MOCK_STEPS, + createNewVersion: CREATE_NEW_VERSION_JOB_MOCK_STEPS, + updateStaging: UPDATE_STAGING_JOB_MOCK_STEPS, + isExpensifyEmployee: IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS, + newContributorWelcomeMessage: NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS, + 'e2e-tests': E2E_TESTS_JOB_MOCK_STEPS, + }; + const result = await act + .runEvent('push', { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: mocks, + }); + expect(result).toEqual(expect.arrayContaining( + [{ + name: 'Main Run lint workflow', + status: 1, + output: '[MOCK] [LINT] Running lint workflow\n' + + '[MOCK] [LINT] Lint workflow failed', + }], + )); + assertTestJobExecuted(result); + assertIsExpensifyEmployeeJobExecuted(result); + expect(result).toEqual(expect.arrayContaining( + [ + { + name: 'Main Announce failed workflow in Slack', + status: 0, + output: '[MOCK] [CONFIRM_PASSING_BUILD] Announcing failed workflow in slack', + }, + { + name: 'Main Exit failed workflow', + status: 1, + output: '', + }, + ], + )); + assertE2ETestsJobExecuted(result, false); // Act does not support ubuntu-20.04-64core runner and omits the job + assertChooseDeployActionsJobExecuted(result, false); + assertSkipDeployJobExecuted(result, false); + assertCreateNewVersionJobExecuted(result, false); + assertUpdateStagingJobExecuted(result, false); + }, 60000); + + test('test job failed', async () => { + const repoPath = mockGithub.repo.getPath('testWorkflowsRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); + let act = new Act(repoPath, workflowPath); + act = setUpActParams( + act, + 'pull_request', + {head: {ref: 'main'}}, + [{OS_BOTIFY_TOKEN: 'dummy_token'}], + 'dummy_github_token', + ); + const mocks = { + lint: LINT_JOB_MOCK_STEPS, + test: [ + { + name: 'Run test workflow', + mockWith: 'echo [MOCK] [TEST] Running test workflow\n' + + 'echo [MOCK] [TEST] Test workflow failed\n' + + 'exit 1', + }, + ], + confirmPassingBuild: CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, + chooseDeployActions: CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS, + skipDeploy: SKIP_DEPLOY_JOB_MOCK_STEPS, + createNewVersion: CREATE_NEW_VERSION_JOB_MOCK_STEPS, + updateStaging: UPDATE_STAGING_JOB_MOCK_STEPS, + isExpensifyEmployee: IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS, + newContributorWelcomeMessage: NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS, + 'e2e-tests': E2E_TESTS_JOB_MOCK_STEPS, + }; + const result = await act + .runEvent('push', { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: mocks, + }); + assertLintJobExecuted(result); + expect(result).toEqual(expect.arrayContaining( + [{ + name: 'Main Run test workflow', + status: 1, + output: '[MOCK] [TEST] Running test workflow\n' + + '[MOCK] [TEST] Test workflow failed', + }], + )); + assertIsExpensifyEmployeeJobExecuted(result); + expect(result).toEqual(expect.arrayContaining( + [ + { + name: 'Main Announce failed workflow in Slack', + status: 0, + output: '[MOCK] [CONFIRM_PASSING_BUILD] Announcing failed workflow in slack', + }, + { + name: 'Main Exit failed workflow', + status: 1, + output: '', + }, + ], + )); + assertE2ETestsJobExecuted(result, false); // Act does not support ubuntu-20.04-64core runner and omits the job + assertChooseDeployActionsJobExecuted(result, false); + assertSkipDeployJobExecuted(result, false); + assertCreateNewVersionJobExecuted(result, false); + assertUpdateStagingJobExecuted(result, false); + }, 60000); }); From d48add5b09e07d36ad13180966a5ee0bdb2675f0 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Wed, 22 Feb 2023 14:59:02 +0100 Subject: [PATCH 009/504] Refactor test structure [WiP] The test file is getting way too big, I will have to split it into several files, but for now did some refactoring for maintainability See: https://github.com/Expensify/App/issues/13604 --- workflow_tests/preDeploy.test.ts | 500 ++++++++++++++++--------------- 1 file changed, 265 insertions(+), 235 deletions(-) diff --git a/workflow_tests/preDeploy.test.ts b/workflow_tests/preDeploy.test.ts index 4d36e010e8f2..f34a59fadf44 100644 --- a/workflow_tests/preDeploy.test.ts +++ b/workflow_tests/preDeploy.test.ts @@ -48,253 +48,289 @@ afterEach(async () => { await mockGithub.teardown(); }); +// lint +const LINT_WORKFLOW_MOCK_STEP = { + name: 'Run lint workflow', + mockWith: 'echo [MOCK] [LINT] Running lint workflow', +}; const LINT_JOB_MOCK_STEPS = [ - { - name: 'Run lint workflow', - mockWith: 'echo [MOCK] [LINT] Running lint workflow', - }, + LINT_WORKFLOW_MOCK_STEP, ]; +// test +const TEST_WORKFLOW_MOCK_STEP = { + name: 'Run test workflow', + mockWith: 'echo [MOCK] [TEST] Running test workflow', +}; const TEST_JOB_MOCK_STEPS = [ - { - name: 'Run test workflow', - mockWith: 'echo [MOCK] [TEST] Running test workflow', - }, + TEST_WORKFLOW_MOCK_STEP, ]; +// confirm_passing_build +const ANNOUNCE_IN_SLACK_MOCK_STEP = { + name: 'Announce failed workflow in Slack', + mockWith: 'echo [MOCK] [CONFIRM_PASSING_BUILD] Announcing failed workflow in slack, SLACK_WEBHOOK=${{ secrets.SLACK_WEBHOOK }}', +}; const CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS = [ - { - name: 'Announce failed workflow in Slack', - mockWith: 'echo [MOCK] [CONFIRM_PASSING_BUILD] Announcing failed workflow in slack', - }, - - // { - // name: 'Exit failed workflow', - // mockWith: 'echo [MOCK] [CONFIRM_PASSING_BUILD] Exiting with failed status', - // }, + ANNOUNCE_IN_SLACK_MOCK_STEP, ]; +// choose_deploy_actions +const GET_MERGED_PULL_REQUEST_MOCK_STEP__CHOOSE_DEPLOY = { + name: 'Get merged pull request', + mockWith: 'echo [MOCK] [CHOOSE_DEPLOY_ACTIONS] Getting merged pull request, GITHUB_TOKEN=${{ github.token }}\n' + + 'echo "number=123" >> "$GITHUB_OUTPUT"\n' + + 'echo "labels=[\'CP Staging\']" >> "$GITHUB_OUTPUT"\n', +}; +const CHECK_IF_STAGINGDEPLOYCASH_IS_LOCKED_MOCK_STEP = { + name: 'Check if StagingDeployCash is locked', + mockWith: 'echo [MOCK] [CHOOSE_DEPLOY_ACTIONS] Checking StagingDeployCash, GITHUB_TOKEN=${{ github.token }}\n' + + 'echo "IS_LOCKED=true" >> "$GITHUB_OUTPUT"', +}; const CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS = [ - { - name: 'Get merged pull request', - mockWith: 'echo [MOCK] [CHOOSE_DEPLOY_ACTIONS] Getting merged pull request\n' - + 'echo "number=1" >> "$GITHUB_OUTPUT"', - }, - { - name: 'Check if StagingDeployCash is locked', - mockWith: 'echo [MOCK] [CHOOSE_DEPLOY_ACTIONS] Checking StagingDeployCash\n' - + 'echo "IS_LOCKED=true" >> "$GITHUB_OUTPUT"', - }, - { - name: 'Check if merged pull request was an automated PR', - mockWith: 'echo [MOCK] [CHOOSE_DEPLOY_ACTIONS] Checking for automated PR\n' - + 'echo "IS_AUTOMATED_PR=false" >> "$GITHUB_OUTPUT"', - }, - { - name: 'Check if merged pull request has `CP Staging` label', - mockWith: 'echo [MOCK] [CHOOSE_DEPLOY_ACTIONS] Checking CP Staging\n' - + 'echo "HAS_CP_LABEL=true" >> "$GITHUB_OUTPUT"', - }, - { - name: 'Check if merged pull request should trigger a deploy', - mockWith: 'echo [MOCK] [CHOOSE_DEPLOY_ACTIONS] Checking deploy trigger\n' - + 'echo "SHOULD_DEPLOY=true" >> "$GITHUB_OUTPUT"', - }, + GET_MERGED_PULL_REQUEST_MOCK_STEP__CHOOSE_DEPLOY, + CHECK_IF_STAGINGDEPLOYCASH_IS_LOCKED_MOCK_STEP, ]; +// skip_deploy +const COMMENT_ON_DEFERRED_PR_MOCK_STEP = { + name: 'Comment on deferred PR', + mockWith: 'echo [MOCK] [SKIP_DEPLOY] Skipping deploy, GITHUB_TOKEN=${{ secrets.OS_BOTIFY_TOKEN }}, NUMBER=${{ needs.chooseDeployActions.outputs.MERGED_PR }}, BODY=:hand: This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.', +}; const SKIP_DEPLOY_JOB_MOCK_STEPS = [ - { - name: 'Comment on deferred PR', - mockWith: 'echo [MOCK] [SKIP_DEPLOY] Skipping deploy', - }, + COMMENT_ON_DEFERRED_PR_MOCK_STEP, ]; +// create_new_version +const CREATE_NEW_VERSION_MOCK_STEP = { + name: 'Create new version', + mockWith: 'echo [MOCK] [CREATE_NEW_VERSION] Creating new version', +}; const CREATE_NEW_VERSION_JOB_MOCK_STEPS = [ - { - name: 'Create new version', - mockWith: 'echo [MOCK] [CREATE_NEW_VERSION] Creating new version', - }, + CREATE_NEW_VERSION_MOCK_STEP, ]; +// update_staging +const RUN_TURNSTYLE_MOCK_STEP = { + name: 'Run turnstyle', + mockWith: 'echo [MOCK] [UPDATE_STAGING] Running turnstyle', +}; +const UPDATE_STAGING_BRANCH_MOCK_STEP = { + name: 'Update staging branch from main', + mockWith: 'echo [MOCK] [UPDATE_STAGING] Updating staging branch', +}; +const CHERRYPICK_PR_MOCK_STEP = { + name: 'Cherry-pick PR to staging', + mockWith: 'echo [MOCK] [UPDATE_STAGING] Cherry picking', +}; +const CHECKOUT_STAGING_MOCK_STEP = { + name: 'Checkout staging', + mockWith: 'echo [MOCK] [UPDATE_STAGING] Checking out staging', +}; +const TAG_STAGING_MOCK_STEP = { + name: 'Tag staging', + mockWith: 'echo [MOCK] [UPDATE_STAGING] Tagging staging', +}; +const UPDATE_STAGINGDEPLOYCASH_MOCK_STEP = { + name: 'Update StagingDeployCash', + mockWith: 'echo [MOCK] [UPDATE_STAGING] Updating StagingDeployCash', +}; +const FIND_OPEN_STAGINGDEPLOYCASH_MOCK_STEP = { + name: 'Find open StagingDeployCash', + mockWith: 'echo [MOCK] [UPDATE_STAGING] Finding open StagingDeployCash\n' + + 'echo "STAGING_DEPLOY_CASH=1234" >> "$GITHUB_OUTPUT"', +}; +const COMMENT_TO_ALERT_APPLAUSE_CHERRYPICK_MOCK_STEP = { + name: 'Comment in StagingDeployCash to alert Applause that a new pull request has been cherry-picked', + mockWith: 'echo [MOCK] [UPDATE_STAGING] Commenting in StagingDeployCash', +}; +const WAIT_FOR_STAGING_DEPLOYS_MOCK_STEP = { + name: 'Wait for staging deploys to finish', + mockWith: 'echo [MOCK] [UPDATE_STAGING] Waiting for staging deploy to finish', +}; +const COMMENT_TO_ALERT_APPLAUSE_DEPLOY_MOCK_STEP = { + name: 'Comment in StagingDeployCash to alert Applause that cherry-picked pull request has been deployed.', + mockWith: 'echo [MOCK] [UPDATE_STAGING] Commenting in StagingDeployCash', +}; +const ANNOUNCE_FAILED_WORKFLOW_IN_SLACK_MOCK_STEP = { + name: 'Announce failed workflow in Slack', + mockWith: 'echo [MOCK] [UPDATE_STAGING] Announcing failed workflow in slack', +}; const UPDATE_STAGING_JOB_MOCK_STEPS = [ - { - name: 'Run turnstyle', - mockWith: 'echo [MOCK] [UPDATE_STAGING] Running turnstyle', - }, - { - name: 'Update staging branch from main', - mockWith: 'echo [MOCK] [UPDATE_STAGING] Updating staging branch', - }, - { - name: 'Cherry-pick PR to staging', - mockWith: 'echo [MOCK] [UPDATE_STAGING] Cherry picking', - }, - { - name: 'Checkout staging', - mockWith: 'echo [MOCK] [UPDATE_STAGING] Checking out staging', - }, - { - name: 'Tag staging', - mockWith: 'echo [MOCK] [UPDATE_STAGING] Tagging staging', - }, - { - name: 'Update StagingDeployCash', - mockWith: 'echo [MOCK] [UPDATE_STAGING] Updating StagingDeployCash', - }, - { - name: 'Find open StagingDeployCash', - mockWith: 'echo [MOCK] [UPDATE_STAGING] Finding open StagingDeployCash\n' - + 'echo "STAGING_DEPLOY_CASH=1234" >> "$GITHUB_OUTPUT"', - }, - { - name: 'Comment in StagingDeployCash to alert Applause that a new pull request has been cherry-picked', - mockWith: 'echo [MOCK] [UPDATE_STAGING] Commenting in StagingDeployCash', - }, - { - name: 'Wait for staging deploys to finish', - mockWith: 'echo [MOCK] [UPDATE_STAGING] Waiting for staging deploy to finish', - }, - { - name: 'Comment in StagingDeployCash to alert Applause that cherry-picked pull request has been deployed.', - mockWith: 'echo [MOCK] [UPDATE_STAGING] Commenting in StagingDeployCash', - }, - { - name: 'Announce failed workflow in Slack', - mockWith: 'echo [MOCK] [UPDATE_STAGING] Announcing failed workflow in slack', - }, + RUN_TURNSTYLE_MOCK_STEP, + UPDATE_STAGING_BRANCH_MOCK_STEP, + CHERRYPICK_PR_MOCK_STEP, + CHECKOUT_STAGING_MOCK_STEP, + TAG_STAGING_MOCK_STEP, + UPDATE_STAGINGDEPLOYCASH_MOCK_STEP, + FIND_OPEN_STAGINGDEPLOYCASH_MOCK_STEP, + COMMENT_TO_ALERT_APPLAUSE_CHERRYPICK_MOCK_STEP, + WAIT_FOR_STAGING_DEPLOYS_MOCK_STEP, + COMMENT_TO_ALERT_APPLAUSE_DEPLOY_MOCK_STEP, + ANNOUNCE_FAILED_WORKFLOW_IN_SLACK_MOCK_STEP, ]; +// is_expensify_employee +const GET_MERGED_PULL_REQUEST_MOCK_STEP__IS_EXPENSIFY_EMPLOYEE = { + name: 'Get merged pull request', + mockWith: 'echo [MOCK] [IS_EXPENSIFY_EMPLOYEE] Getting merged pull request\n' + + 'echo "author=Dummy Author" >> "$GITHUB_OUTPUT"', +}; +const CHECK_TEAM_MEMBERSHIP_MOCK_STEP = { + name: 'Check whether the actor is member of Expensify/expensify team', + mockWith: 'echo [MOCK] [IS_EXPENSIFY_EMPLOYEE] Checking actors Expensify membership\n' + + 'echo "isTeamMember=true" >> "$GITHUB_OUTPUT"', +}; const IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS = [ - { - name: 'Get merged pull request', - mockWith: 'echo [MOCK] [IS_EXPENSIFY_EMPLOYEE] Getting merged pull request\n' - + 'echo "author=Dummy Author" >> "$GITHUB_OUTPUT"', - }, - { - name: 'Check whether the actor is member of Expensify/expensify team', - mockWith: 'echo [MOCK] [IS_EXPENSIFY_EMPLOYEE] Checking actors Expensify membership\n' - + 'echo "isTeamMember=true" >> "$GITHUB_OUTPUT"', - }, + GET_MERGED_PULL_REQUEST_MOCK_STEP__IS_EXPENSIFY_EMPLOYEE, + CHECK_TEAM_MEMBERSHIP_MOCK_STEP, ]; +// new_contributor_welcome_message +const CHECKOUT_MOCK_STEP = { + name: 'Checkout', + mockWith: 'echo [MOCK] [NEW_CONTRIBUTOR_WELCOME_MESSAGE] Checking out', +}; +const GET_MERGED_PULL_REQUEST_MOCK_STEP__WELCOME_MESSAGE = { + name: 'Get merged pull request', + mockWith: 'echo [MOCK] [NEW_CONTRIBUTOR_WELCOME_MESSAGE] Getting merged pull request', +}; +const GET_PR_COUNT_MOCK_STEP = { + name: 'Get PR count for ${{ steps.getMergedPullRequest.outputs.author }}', + mockWith: 'echo [MOCK] [NEW_CONTRIBUTOR_WELCOME_MESSAGE] Getting PR count', +}; +const COMMENT_ON_FIRST_PULL_REQUEST_MOCK_STEP = { + name: 'Comment on ${{ steps.getMergedPullRequest.outputs.author }}\\\'s first pull request!', + mockWith: 'echo [MOCK] [NEW_CONTRIBUTOR_WELCOME_MESSAGE] Creating comment', +}; const NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS = [ - { - name: 'Checkout', - mockWith: 'echo [MOCK] [NEW_CONTRIBUTOR_WELCOME_MESSAGE] Checking out', - }, - { - name: 'Get merged pull request', - mockWith: 'echo [MOCK] [NEW_CONTRIBUTOR_WELCOME_MESSAGE] Getting merged pull request', - }, - { - name: 'Get PR count for ${{ steps.getMergedPullRequest.outputs.author }}', - mockWith: 'echo [MOCK] [NEW_CONTRIBUTOR_WELCOME_MESSAGE] Getting PR count', - }, - { - name: 'Comment on ${{ steps.getMergedPullRequest.outputs.author }}\\\'s first pull request!', - mockWith: 'echo [MOCK] [NEW_CONTRIBUTOR_WELCOME_MESSAGE] Creating comment', - }, + CHECKOUT_MOCK_STEP, + GET_MERGED_PULL_REQUEST_MOCK_STEP__WELCOME_MESSAGE, + GET_PR_COUNT_MOCK_STEP, + COMMENT_ON_FIRST_PULL_REQUEST_MOCK_STEP, ]; +// e2e_tests +const CHECKOUT_MOCK_STEP__E2E_TESTS = { + name: 'Checkout', + mockWith: 'echo [MOCK] [E2E_TESTS] Checking out', +}; +const SETUP_NODE_MOCK_STEP = { + name: 'Setup node', + mockWith: 'echo [MOCK] [E2E_TESTS] Setting up node', +}; +const SETUP_RUBY_MOCK_STEP = { + name: 'Setup ruby', + mockWith: 'echo [MOCK] [E2E_TESTS] Setting up ruby', +}; +const GRADLE_CACHE_MOCK_STEP = { + name: 'Gradle cache', + mockWith: 'echo [MOCK] [E2E_TESTS] Building with gradle', +}; +const MAKE_ZIP_MOCK_STEP = { + name: 'Make zip directory for everything to send to AWS Device Farm', + mockWith: 'echo [MOCK] [E2E_TESTS] Creating zip directory', +}; +const CHECKOUT_COMPARE_MOCK_STEP = { + name: 'Checkout "Compare" commit', + mockWith: 'echo [MOCK] [E2E_TESTS] Checking out compare commit', +}; +const INSTALL_NODE_PACKAGES_MOCK_STEP = { + name: 'Install node packages', + mockWith: 'echo [MOCK] [E2E_TESTS] Installing node packages', +}; +const BUILD_COMPARE_APK_MOCK_STEP = { + name: 'Build "Compare" APK', + mockWith: 'echo [MOCK] [E2E_TESTS] Building compare apk', +}; +const COPY_COMPARE_APK_MOCK_STEP = { + name: 'Copy "Compare" APK', + mockWith: 'echo [MOCK] [E2E_TESTS] Copying compare apk', +}; +const CHECKOUT_BASELINE_COMMIT_MOCK_STEP = { + name: 'Checkout "Baseline" commit (last release)', + mockWith: 'echo [MOCK] [E2E_TESTS] Checking out baseline commit', +}; +const BUILD_BASELINE_APK_MOCK_STEP = { + name: 'Build "Baseline" APK', + mockWith: 'echo [MOCK] [E2E_TESTS] Building baseline apk', +}; +const COPY_BASELINE_APK_MOCK_STEP = { + name: 'Copy "Baseline" APK', + mockWith: 'echo [MOCK] [E2E_TESTS] Copying baseline apk', +}; +const CHECKOUT_PREVIOUS_BRANCH_MOCK_STEP = { + name: 'Checkout previous branch for source code to run on AWS Device farm', + mockWith: 'echo [MOCK] [E2E_TESTS] Checking out previous branch', +}; +const COPY_E2E_CODE_MOCK_STEP = { + name: 'Copy e2e code into zip folder', + mockWith: 'echo [MOCK] [E2E_TESTS] Copying e2e tests', +}; +const ZIP_EVERYTHING_MOCK_STEP = { + name: 'Zip everything in the zip directory up', + mockWith: 'echo [MOCK] [E2E_TESTS] Zipping everything', +}; +const CONFIGURE_AWS_CREDENTIALS_MOCK_STEP = { + name: 'Configure AWS Credentials', + mockWith: 'echo [MOCK] [E2E_TESTS] Configuring AWS credentials', +}; +const SCHEDULE_AWS_DEVICE_FARM_MOCK_STEP = { + name: 'Schedule AWS Device Farm test run', + mockWith: 'echo [MOCK] [E2E_TESTS] Scheduling AWS test run', +}; +const UNZIP_AWS_DEVICE_FARM_RESULTS_MOCK_STEP = { + name: 'Unzip AWS Device Farm results', + mockWith: 'echo [MOCK] [E2E_TESTS] Unzipping test results', +}; +const PRINT_AWS_DEVICE_FARM_RESULTS_MOCK_STEP = { + name: 'Print AWS Device Farm run results', + mockWith: 'echo [MOCK] [E2E_TESTS] Printing test results', +}; +const SET_OUTPUT_OF_AWS_DEVICE_FARM_MOCK_STEP = { + name: 'Set output of AWS Device Farm into GitHub ENV', + mockWith: 'echo [MOCK] [E2E_TESTS] Setting AWS output', +}; +const GET_MERGED_PULL_REQUEST_MOCK_STEP__E2E_TESTS = { + name: 'Get merged pull request', + mockWith: 'echo [MOCK] [E2E_TESTS] Getting merged pull request', +}; +const LEAVE_COMMENT_WITH_AWS_DEVICE_FARM_OUTPUT_MOCK_STEP = { + name: 'Leave output of AWS Device Farm as a PR comment', + mockWith: 'echo [MOCK] [E2E_TESTS] Leaving comment with test results', +}; +const CHECK_IF_TESTS_FAILED_MOCK_STEP = { + name: 'Check if test failed, if so leave a deploy blocker label', + mockWith: 'echo [MOCK] [E2E_TESTS] Checking if tests failed', +}; const E2E_TESTS_JOB_MOCK_STEPS = [ - { - name: 'Checkout', - mockWith: 'echo [MOCK] [E2E_TESTS] Checking out', - }, - { - name: 'Setup node', - mockWith: 'echo [MOCK] [E2E_TESTS] Setting up node', - }, - { - name: 'Setup ruby', - mockWith: 'echo [MOCK] [E2E_TESTS] Setting up ruby', - }, - { - name: 'Gradle cache', - mockWith: 'echo [MOCK] [E2E_TESTS] Building with gradle', - }, - { - name: 'Make zip directory for everything to send to AWS Device Farm', - mockWith: 'echo [MOCK] [E2E_TESTS] Creating zip directory', - }, - { - name: 'Checkout "Compare" commit', - mockWith: 'echo [MOCK] [E2E_TESTS] Checking out compare commit', - }, - { - name: 'Install node packages', - mockWith: 'echo [MOCK] [E2E_TESTS] Installing node packages', - }, - { - name: 'Build "Compare" APK', - mockWith: 'echo [MOCK] [E2E_TESTS] Building compare apk', - }, - { - name: 'Copy "Compare" APK', - mockWith: 'echo [MOCK] [E2E_TESTS] Copying compare apk', - }, - { - name: 'Checkout "Baseline" commit (last release)', - mockWith: 'echo [MOCK] [E2E_TESTS] Checking out baseline commit', - }, - { - name: 'Install node packages', - mockWith: 'echo [MOCK] [E2E_TESTS] Installing node packages', - }, - { - name: 'Build "Baseline" APK', - mockWith: 'echo [MOCK] [E2E_TESTS] Building baseline apk', - }, - { - name: 'Copy "Baseline" APK', - mockWith: 'echo [MOCK] [E2E_TESTS] Copying baseline apk', - }, - { - name: 'Checkout previous branch for source code to run on AWS Device farm', - mockWith: 'echo [MOCK] [E2E_TESTS] Checking out previous branch', - }, - { - name: 'Copy e2e code into zip folder', - mockWith: 'echo [MOCK] [E2E_TESTS] Copying e2e tests', - }, - { - name: 'Zip everything in the zip directory up', - mockWith: 'echo [MOCK] [E2E_TESTS] Zipping everything', - }, - { - name: 'Configure AWS Credentials', - mockWith: 'echo [MOCK] [E2E_TESTS] Configuring AWS credentials', - }, - { - name: 'Schedule AWS Device Farm test run', - mockWith: 'echo [MOCK] [E2E_TESTS] Scheduling AWS test run', - }, - { - name: 'Unzip AWS Device Farm results', - mockWith: 'echo [MOCK] [E2E_TESTS] Unzipping test results', - }, - { - name: 'Print AWS Device Farm run results', - mockWith: 'echo [MOCK] [E2E_TESTS] Printing test results', - }, - { - name: 'Set output of AWS Device Farm into GitHub ENV', - mockWith: 'echo [MOCK] [E2E_TESTS] Setting AWS output', - }, - { - name: 'Get merged pull request', - mockWith: 'echo [MOCK] [E2E_TESTS] Getting merged pull request', - }, - { - name: 'Leave output of AWS Device Farm as a PR comment', - mockWith: 'echo [MOCK] [E2E_TESTS] Leaving comment with test results', - }, - { - name: 'Check if test failed, if so leave a deploy blocker label', - mockWith: 'echo [MOCK] [E2E_TESTS] Checking if tests failed', - }, + 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, ]; +// all together const MOCK_STEPS = { lint: LINT_JOB_MOCK_STEPS, test: TEST_JOB_MOCK_STEPS, @@ -308,6 +344,7 @@ const MOCK_STEPS = { 'e2e-tests': E2E_TESTS_JOB_MOCK_STEPS, }; +// assertion helper methods const assertLintJobExecuted = (workflowResult: Array, didExecute: Boolean = true) => { const steps = [{ name: 'Main Run lint workflow', @@ -320,7 +357,6 @@ const assertLintJobExecuted = (workflowResult: Array, didExecute: Boolea expect(workflowResult).not.toEqual(steps); } }; - const assertTestJobExecuted = (workflowResult: Array, didExecute: Boolean = true) => { const steps = [{ name: 'Main Run test workflow', @@ -333,7 +369,6 @@ const assertTestJobExecuted = (workflowResult: Array, didExecute: Boolea expect(workflowResult).not.toEqual(steps); } }; - const assertIsExpensifyEmployeeJobExecuted = (workflowResult: Array, didExecute: Boolean = true) => { const steps = [{ name: 'Main Get merged pull request', @@ -351,7 +386,6 @@ const assertIsExpensifyEmployeeJobExecuted = (workflowResult: Array, did expect(workflowResult).not.toEqual(steps); } }; - const assertE2ETestsJobExecuted = (workflowResult: Array, didExecute: Boolean = true) => { const steps = [ { @@ -481,33 +515,32 @@ const assertE2ETestsJobExecuted = (workflowResult: Array, didExecute: Bo expect(workflowResult).not.toEqual(steps); } }; - const assertChooseDeployActionsJobExecuted = (workflowResult: Array, didExecute: Boolean = true) => { const steps = [ { name: 'Main Get merged pull request', status: 0, - output: '[MOCK] [CHOOSE_DEPLOY_ACTIONS] Getting merged pull request', + output: '[MOCK] [CHOOSE_DEPLOY_ACTIONS] Getting merged pull request, GITHUB_TOKEN=***', // no access to secrets }, { name: 'Main Check if StagingDeployCash is locked', status: 0, - output: '[MOCK] [CHOOSE_DEPLOY_ACTIONS] Checking StagingDeployCash', + output: '[MOCK] [CHOOSE_DEPLOY_ACTIONS] Checking StagingDeployCash, GITHUB_TOKEN=***', // no access to secrets }, { name: 'Main Check if merged pull request was an automated PR', status: 0, - output: '[MOCK] [CHOOSE_DEPLOY_ACTIONS] Checking for automated PR', + output: '', }, { name: 'Main Check if merged pull request has `CP Staging` label', status: 0, - output: '[MOCK] [CHOOSE_DEPLOY_ACTIONS] Checking CP Staging', + output: '', }, { name: 'Main Check if merged pull request should trigger a deploy', status: 0, - output: '[MOCK] [CHOOSE_DEPLOY_ACTIONS] Checking deploy trigger', + output: '', }, ]; if (didExecute) { @@ -516,13 +549,12 @@ const assertChooseDeployActionsJobExecuted = (workflowResult: Array, did expect(workflowResult).not.toEqual(steps); } }; - const assertSkipDeployJobExecuted = (workflowResult: Array, didExecute: Boolean = true) => { const steps = [ { name: 'Main Comment on deferred PR', status: 0, - output: '[MOCK] [SKIP_DEPLOY] Skipping deploy', + output: '[MOCK] [SKIP_DEPLOY] Skipping deploy, GITHUB_TOKEN=, NUMBER=123, BODY=:hand: This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.', }, ]; if (didExecute) { @@ -531,7 +563,6 @@ const assertSkipDeployJobExecuted = (workflowResult: Array, didExecute: expect(workflowResult).not.toEqual(steps); } }; - const assertCreateNewVersionJobExecuted = (workflowResult: Array, didExecute: Boolean = true) => { const steps = [ { @@ -546,7 +577,6 @@ const assertCreateNewVersionJobExecuted = (workflowResult: Array, didExe expect(workflowResult).not.toEqual(steps); } }; - const assertUpdateStagingJobExecuted = (workflowResult: Array, didExecute: Boolean = true) => { const steps = [ { @@ -640,7 +670,7 @@ describe('test workflow preDeploy', () => { act, 'pull_request', {head: {ref: 'main'}}, - [{OS_BOTIFY_TOKEN: 'dummy_token'}], + [{OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook'}], 'dummy_github_token', ); @@ -674,7 +704,7 @@ describe('test workflow preDeploy', () => { act, 'pull_request', {head: {ref: 'main'}}, - [{OS_BOTIFY_TOKEN: 'dummy_token'}], + [{OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook'}], 'dummy_github_token', ); const mocks = { @@ -716,7 +746,7 @@ describe('test workflow preDeploy', () => { { name: 'Main Announce failed workflow in Slack', status: 0, - output: '[MOCK] [CONFIRM_PASSING_BUILD] Announcing failed workflow in slack', + output: '[MOCK] [CONFIRM_PASSING_BUILD] Announcing failed workflow in slack, SLACK_WEBHOOK=', // no access to secrets }, { name: 'Main Exit failed workflow', @@ -740,7 +770,7 @@ describe('test workflow preDeploy', () => { act, 'pull_request', {head: {ref: 'main'}}, - [{OS_BOTIFY_TOKEN: 'dummy_token'}], + [{OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook'}], 'dummy_github_token', ); const mocks = { @@ -782,7 +812,7 @@ describe('test workflow preDeploy', () => { { name: 'Main Announce failed workflow in Slack', status: 0, - output: '[MOCK] [CONFIRM_PASSING_BUILD] Announcing failed workflow in slack', + output: '[MOCK] [CONFIRM_PASSING_BUILD] Announcing failed workflow in slack, SLACK_WEBHOOK=', // no access to secrets }, { name: 'Main Exit failed workflow', From c7b3b219a5917a6dad931abc7ca9913461712d00 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Thu, 23 Feb 2023 12:27:14 +0100 Subject: [PATCH 010/504] Clean up test file [WiP] Extracted step mocks, assertion helper methods and utils methods to their separate files to clean up the already cluttered test file See: https://github.com/Expensify/App/issues/13604 --- .../assertions/preDeployAssertions.ts | 294 +++++++ workflow_tests/mocks/preDeployMocks.ts | 286 +++++++ workflow_tests/preDeploy.test.ts | 725 ++---------------- workflow_tests/utils.ts | 23 + 4 files changed, 670 insertions(+), 658 deletions(-) create mode 100644 workflow_tests/assertions/preDeployAssertions.ts create mode 100644 workflow_tests/mocks/preDeployMocks.ts create mode 100644 workflow_tests/utils.ts diff --git a/workflow_tests/assertions/preDeployAssertions.ts b/workflow_tests/assertions/preDeployAssertions.ts new file mode 100644 index 000000000000..0f02f1373d54 --- /dev/null +++ b/workflow_tests/assertions/preDeployAssertions.ts @@ -0,0 +1,294 @@ +export const assertLintJobExecuted = (workflowResult: Array, didExecute: Boolean = true) => { + const steps = [{ + name: 'Main Run lint workflow', + status: 0, + output: '[MOCK] [LINT] Running lint workflow', + }]; + if (didExecute) { + expect(workflowResult).toEqual(expect.arrayContaining(steps)); + } else { + expect(workflowResult).not.toEqual(steps); + } +}; + +export const assertTestJobExecuted = (workflowResult: Array, didExecute: Boolean = true) => { + const steps = [{ + name: 'Main Run test workflow', + status: 0, + output: '[MOCK] [TEST] Running test workflow', + }]; + if (didExecute) { + expect(workflowResult).toEqual(expect.arrayContaining(steps)); + } else { + expect(workflowResult).not.toEqual(steps); + } +}; + +export const assertIsExpensifyEmployeeJobExecuted = (workflowResult: Array, didExecute: Boolean = true) => { + const steps = [{ + name: 'Main Get merged pull request', + status: 0, + output: '[MOCK] [IS_EXPENSIFY_EMPLOYEE] Getting merged pull request, GITHUB_TOKEN=***', + }, + { + name: 'Main Check whether the actor is member of Expensify/expensify team', + status: 0, + output: '[MOCK] [IS_EXPENSIFY_EMPLOYEE] Checking actors Expensify membership, GITHUB_TOKEN=***, USERNAME=Dummy Author, TEAM=Expensify/expensify', + }]; + if (didExecute) { + expect(workflowResult).toEqual(expect.arrayContaining(steps)); + } else { + expect(workflowResult).not.toEqual(steps); + } +}; + +export const assertE2ETestsJobExecuted = (workflowResult: Array, didExecute: Boolean = true) => { + const steps = [ + { + name: 'Main Checkout', + status: 0, + output: '[MOCK] [E2E_TESTS] Checking out', + }, + { + name: 'Main Setup node', + status: 0, + output: '[MOCK] [E2E_TESTS] Setting up node', + }, + { + name: 'Main Setup ruby', + status: 0, + output: '[MOCK] [E2E_TESTS] Setting up ruby', + }, + { + name: 'Main Gradle cache', + status: 0, + output: '[MOCK] [E2E_TESTS] Building with gradle', + }, + { + name: 'Make zip directory for everything to send to AWS Device Farm', + status: 0, + output: '[MOCK] [E2E_TESTS] Creating zip directory', + }, + { + name: 'Checkout "Compare" commit', + status: 0, + output: '[MOCK] [E2E_TESTS] Checking out compare commit', + }, + { + name: 'Install node packages', + status: 0, + output: '[MOCK] [E2E_TESTS] Installing node packages', + }, + { + name: 'Build "Compare" APK', + status: 0, + output: '[MOCK] [E2E_TESTS] Building compare apk', + }, + { + name: 'Copy "Compare" APK', + status: 0, + output: '[MOCK] [E2E_TESTS] Copying compare apk', + }, + { + name: 'Checkout "Baseline" commit (last release)', + status: 0, + output: '[MOCK] [E2E_TESTS] Checking out baseline commit', + }, + { + name: 'Install node packages', + status: 0, + output: '[MOCK] [E2E_TESTS] Installing node packages', + }, + { + name: 'Build "Baseline" APK', + status: 0, + output: '[MOCK] [E2E_TESTS] Building baseline apk', + }, + { + name: 'Copy "Baseline" APK', + status: 0, + output: '[MOCK] [E2E_TESTS] Copying baseline apk', + }, + { + name: 'Checkout previous branch for source code to run on AWS Device farm', + status: 0, + output: '[MOCK] [E2E_TESTS] Checking out previous branch', + }, + { + name: 'Copy e2e code into zip folder', + status: 0, + output: '[MOCK] [E2E_TESTS] Copying e2e tests', + }, + { + name: 'Zip everything in the zip directory up', + status: 0, + output: '[MOCK] [E2E_TESTS] Zipping everything', + }, + { + name: 'Configure AWS Credentials', + status: 0, + output: '[MOCK] [E2E_TESTS] Configuring AWS credentials', + }, + { + name: 'Schedule AWS Device Farm test run', + status: 0, + output: '[MOCK] [E2E_TESTS] Scheduling AWS test run', + }, + { + name: 'Unzip AWS Device Farm results', + status: 0, + output: '[MOCK] [E2E_TESTS] Unzipping test results', + }, + { + name: 'Print AWS Device Farm run results', + status: 0, + output: '[MOCK] [E2E_TESTS] Printing test results', + }, + { + name: 'Set output of AWS Device Farm into GitHub ENV', + status: 0, + output: '[MOCK] [E2E_TESTS] Setting AWS output', + }, + { + name: 'Get merged pull request', + status: 0, + output: '[MOCK] [E2E_TESTS] Getting merged pull request', + }, + { + name: 'Leave output of AWS Device Farm as a PR comment', + status: 0, + output: '[MOCK] [E2E_TESTS] Leaving comment with test results', + }, + { + name: 'Check if test failed, if so leave a deploy blocker label', + status: 0, + output: '[MOCK] [E2E_TESTS] Checking if tests failed', + }, + ]; + if (didExecute) { + expect(workflowResult).toEqual(expect.arrayContaining(steps)); + } else { + expect(workflowResult).not.toEqual(steps); + } +}; + +export const assertChooseDeployActionsJobExecuted = (workflowResult: Array, didExecute: Boolean = true) => { + const steps = [ + { + name: 'Main Get merged pull request', + status: 0, + output: '[MOCK] [CHOOSE_DEPLOY_ACTIONS] Getting merged pull request, GITHUB_TOKEN=***', // no access to secrets + }, + { + name: 'Main Check if StagingDeployCash is locked', + status: 0, + + output: '[MOCK] [CHOOSE_DEPLOY_ACTIONS] Checking StagingDeployCash, GITHUB_TOKEN=***', // no access to secrets + }, + { + name: 'Main Check if merged pull request was an automated PR', + status: 0, + output: '', + }, + { + name: 'Main Check if merged pull request has `CP Staging` label', + status: 0, + output: '', + }, + { + name: 'Main Check if merged pull request should trigger a deploy', + status: 0, + output: '', + }, + ]; + if (didExecute) { + expect(workflowResult).toEqual(expect.arrayContaining(steps)); + } else { + expect(workflowResult).not.toEqual(steps); + } +}; + +export const assertSkipDeployJobExecuted = (workflowResult: Array, didExecute: Boolean = true) => { + const steps = [ + { + name: 'Main Comment on deferred PR', + status: 0, + output: '[MOCK] [SKIP_DEPLOY] Skipping deploy, GITHUB_TOKEN=***, NUMBER=123, BODY=:hand: This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.', + }, + ]; + if (didExecute) { + expect(workflowResult).toEqual(expect.arrayContaining(steps)); + } else { + expect(workflowResult).not.toEqual(steps); + } +}; + +export const assertCreateNewVersionJobExecuted = (workflowResult: Array, didExecute: Boolean = true) => { + const steps = [ + { + name: 'Main Create new version', + status: 0, + output: '[MOCK] [CREATE_NEW_VERSION] Creating new version', + }, + ]; + if (didExecute) { + expect(workflowResult).toEqual(expect.arrayContaining(steps)); + } else { + expect(workflowResult).not.toEqual(steps); + } +}; + +export const assertUpdateStagingJobExecuted = (workflowResult: Array, didExecute: Boolean = true) => { + const steps = [ + { + name: 'Main Run turnstyle', + status: 0, + output: '[MOCK] [UPDATE_STAGING] Running turnstyle, POLL_INTERVAL_SECONDS=10, GITHUB_TOKEN=***', + }, + { + name: 'Main Cherry-pick PR to staging', + status: 0, + output: '[MOCK] [UPDATE_STAGING] Cherry picking', + }, + { + name: 'Main Checkout staging', + status: 0, + output: '[MOCK] [UPDATE_STAGING] Checking out staging', + }, + { + name: 'Main Tag staging', + status: 0, + output: '[MOCK] [UPDATE_STAGING] Tagging staging', + }, + { + name: 'Main Update StagingDeployCash', + status: 0, + output: '[MOCK] [UPDATE_STAGING] Updating StagingDeployCash', + }, + { + name: 'Main Find open StagingDeployCash', + status: 0, + output: '[MOCK] [UPDATE_STAGING] Finding open StagingDeployCash', + }, + { + name: 'Main Comment in StagingDeployCash to alert Applause that a new pull request has been cherry-picked', + status: 0, + output: '[MOCK] [UPDATE_STAGING] Commenting in StagingDeployCash', + }, + { + name: 'Main Wait for staging deploys to finish', + status: 0, + output: '[MOCK] [UPDATE_STAGING] Waiting for staging deploy to finish', + }, + { + name: 'Main Comment in StagingDeployCash to alert Applause that cherry-picked pull request has been deployed.', + status: 0, + output: '[MOCK] [UPDATE_STAGING] Commenting in StagingDeployCash', + }, + ]; + if (didExecute) { + expect(workflowResult).toEqual(expect.arrayContaining(steps)); + } else { + expect(workflowResult).not.toEqual(steps); + } +}; diff --git a/workflow_tests/mocks/preDeployMocks.ts b/workflow_tests/mocks/preDeployMocks.ts new file mode 100644 index 000000000000..3d133e26c730 --- /dev/null +++ b/workflow_tests/mocks/preDeployMocks.ts @@ -0,0 +1,286 @@ +// lint +const LINT_WORKFLOW_MOCK_STEP = { + name: 'Run lint workflow', + mockWith: 'echo [MOCK] [LINT] Running lint workflow', +}; +export const LINT_JOB_MOCK_STEPS = [ + LINT_WORKFLOW_MOCK_STEP, +]; + +// test +const TEST_WORKFLOW_MOCK_STEP = { + name: 'Run test workflow', + mockWith: 'echo [MOCK] [TEST] Running test workflow', +}; +export const TEST_JOB_MOCK_STEPS = [ + TEST_WORKFLOW_MOCK_STEP, +]; + +// confirm_passing_build +const ANNOUNCE_IN_SLACK_MOCK_STEP = { + name: 'Announce failed workflow in Slack', + mockWith: 'echo [MOCK] [CONFIRM_PASSING_BUILD] Announcing failed workflow in slack, SLACK_WEBHOOK=${{ inputs.SLACK_WEBHOOK }}', +}; +export const CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS = [ + ANNOUNCE_IN_SLACK_MOCK_STEP, + + // 2nd step runs normally +]; + +// choose_deploy_actions +const GET_MERGED_PULL_REQUEST_MOCK_STEP__CHOOSE_DEPLOY = { + name: 'Get merged pull request', + mockWith: 'echo [MOCK] [CHOOSE_DEPLOY_ACTIONS] Getting merged pull request, GITHUB_TOKEN=${{ inputs.github_token }}\n' + + 'echo "number=123" >> "$GITHUB_OUTPUT"\n' + + 'echo "labels=[\'CP Staging\']" >> "$GITHUB_OUTPUT"\n', +}; + +const CHECK_IF_STAGINGDEPLOYCASH_IS_LOCKED_MOCK_STEP = { + name: 'Check if StagingDeployCash is locked', + mockWith: 'echo [MOCK] [CHOOSE_DEPLOY_ACTIONS] Checking StagingDeployCash, GITHUB_TOKEN=${{ inputs.GITHUB_TOKEN }}\n' + + 'echo "IS_LOCKED=true" >> "$GITHUB_OUTPUT"', +}; +export const CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS = [ + GET_MERGED_PULL_REQUEST_MOCK_STEP__CHOOSE_DEPLOY, + CHECK_IF_STAGINGDEPLOYCASH_IS_LOCKED_MOCK_STEP, + + // steps 3-5 run normally +]; + +// skip_deploy +const COMMENT_ON_DEFERRED_PR_MOCK_STEP = { + name: 'Comment on deferred PR', + mockWith: 'echo [MOCK] [SKIP_DEPLOY] Skipping deploy, GITHUB_TOKEN=${{ inputs.github_token }}, NUMBER=${{ inputs.number }}, BODY=${{ inputs.body }}', +}; +export const SKIP_DEPLOY_JOB_MOCK_STEPS = [ + COMMENT_ON_DEFERRED_PR_MOCK_STEP, +]; + +// create_new_version +const CREATE_NEW_VERSION_MOCK_STEP = { + name: 'Create new version', + mockWith: 'echo [MOCK] [CREATE_NEW_VERSION] Creating new version', +}; +export const CREATE_NEW_VERSION_JOB_MOCK_STEPS = [ + CREATE_NEW_VERSION_MOCK_STEP, +]; + +// update_staging +const RUN_TURNSTYLE_MOCK_STEP = { + name: 'Run turnstyle', + mockWith: 'echo [MOCK] [UPDATE_STAGING] Running turnstyle, POLL_INTERVAL_SECONDS=${{ inputs.poll-interval-seconds }}, GITHUB_TOKEN=${{ env.GITHUB_TOKEN }}', +}; +const UPDATE_STAGING_BRANCH_MOCK_STEP = { + name: 'Update staging branch from main', + mockWith: 'echo [MOCK] [UPDATE_STAGING] Updating staging branch', +}; +const CHERRYPICK_PR_MOCK_STEP = { + name: 'Cherry-pick PR to staging', + mockWith: 'echo [MOCK] [UPDATE_STAGING] Cherry picking', +}; +const CHECKOUT_STAGING_MOCK_STEP = { + name: 'Checkout staging', + mockWith: 'echo [MOCK] [UPDATE_STAGING] Checking out staging', +}; +const TAG_STAGING_MOCK_STEP = { + name: 'Tag staging', + mockWith: 'echo [MOCK] [UPDATE_STAGING] Tagging staging', +}; +const UPDATE_STAGINGDEPLOYCASH_MOCK_STEP = { + name: 'Update StagingDeployCash', + mockWith: 'echo [MOCK] [UPDATE_STAGING] Updating StagingDeployCash', +}; +const FIND_OPEN_STAGINGDEPLOYCASH_MOCK_STEP = { + name: 'Find open StagingDeployCash', + mockWith: 'echo [MOCK] [UPDATE_STAGING] Finding open StagingDeployCash\n' + + 'echo "STAGING_DEPLOY_CASH=1234" >> "$GITHUB_OUTPUT"', +}; +const COMMENT_TO_ALERT_APPLAUSE_CHERRYPICK_MOCK_STEP = { + name: 'Comment in StagingDeployCash to alert Applause that a new pull request has been cherry-picked', + mockWith: 'echo [MOCK] [UPDATE_STAGING] Commenting in StagingDeployCash', +}; +const WAIT_FOR_STAGING_DEPLOYS_MOCK_STEP = { + name: 'Wait for staging deploys to finish', + mockWith: 'echo [MOCK] [UPDATE_STAGING] Waiting for staging deploy to finish', +}; +const COMMENT_TO_ALERT_APPLAUSE_DEPLOY_MOCK_STEP = { + name: 'Comment in StagingDeployCash to alert Applause that cherry-picked pull request has been deployed.', + mockWith: 'echo [MOCK] [UPDATE_STAGING] Commenting in StagingDeployCash', +}; +const ANNOUNCE_FAILED_WORKFLOW_IN_SLACK_MOCK_STEP = { + name: 'Announce failed workflow in Slack', + mockWith: 'echo [MOCK] [UPDATE_STAGING] Announcing failed workflow in slack', +}; +export const UPDATE_STAGING_JOB_MOCK_STEPS = [ + RUN_TURNSTYLE_MOCK_STEP, + UPDATE_STAGING_BRANCH_MOCK_STEP, + CHERRYPICK_PR_MOCK_STEP, + CHECKOUT_STAGING_MOCK_STEP, + TAG_STAGING_MOCK_STEP, + UPDATE_STAGINGDEPLOYCASH_MOCK_STEP, + FIND_OPEN_STAGINGDEPLOYCASH_MOCK_STEP, + COMMENT_TO_ALERT_APPLAUSE_CHERRYPICK_MOCK_STEP, + WAIT_FOR_STAGING_DEPLOYS_MOCK_STEP, + COMMENT_TO_ALERT_APPLAUSE_DEPLOY_MOCK_STEP, + ANNOUNCE_FAILED_WORKFLOW_IN_SLACK_MOCK_STEP, +]; + +// is_expensify_employee +const GET_MERGED_PULL_REQUEST_MOCK_STEP__IS_EXPENSIFY_EMPLOYEE = { + name: 'Get merged pull request', + mockWith: 'echo [MOCK] [IS_EXPENSIFY_EMPLOYEE] Getting merged pull request, GITHUB_TOKEN=${{ inputs.github_token }}\n' + + 'echo "author=Dummy Author" >> "$GITHUB_OUTPUT"', +}; +const CHECK_TEAM_MEMBERSHIP_MOCK_STEP = { + name: 'Check whether the actor is member of Expensify/expensify team', + mockWith: 'echo [MOCK] [IS_EXPENSIFY_EMPLOYEE] Checking actors Expensify membership, GITHUB_TOKEN=${{ inputs.GITHUB_TOKEN }}, USERNAME=${{ inputs.username }}, TEAM=${{ inputs.team }}\n' + + 'echo "isTeamMember=true" >> "$GITHUB_OUTPUT"', +}; +export const IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS = [ + GET_MERGED_PULL_REQUEST_MOCK_STEP__IS_EXPENSIFY_EMPLOYEE, + CHECK_TEAM_MEMBERSHIP_MOCK_STEP, +]; + +// new_contributor_welcome_message +const CHECKOUT_MOCK_STEP = { + name: 'Checkout', + mockWith: 'echo [MOCK] [NEW_CONTRIBUTOR_WELCOME_MESSAGE] Checking out, TOKEN=${{ inputs.token }}', +}; +const GET_MERGED_PULL_REQUEST_MOCK_STEP__WELCOME_MESSAGE = { + name: 'Get merged pull request', + mockWith: 'echo [MOCK] [NEW_CONTRIBUTOR_WELCOME_MESSAGE] Getting merged pull request, GITHUB_TOKEN=${{ inputs.github_token }}', +}; +const GET_PR_COUNT_MOCK_STEP = { + name: 'Get PR count for ${{ steps.getMergedPullRequest.outputs.author }}', + mockWith: 'echo [MOCK] [NEW_CONTRIBUTOR_WELCOME_MESSAGE] Getting PR count, GITHUB_TOKEN=${{ env.GITHUB_TOKEN }}', +}; +const COMMENT_ON_FIRST_PULL_REQUEST_MOCK_STEP = { + name: 'Comment on ${{ steps.getMergedPullRequest.outputs.author }}\\\'s first pull request!', + mockWith: 'echo [MOCK] [NEW_CONTRIBUTOR_WELCOME_MESSAGE] Creating comment, GITHUB_TOKEN=${{ inputs.github_token }}, NUMBER=${{ inputs.number }}, BODY=${{ inputs.body }}', +}; +export const NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS = [ + CHECKOUT_MOCK_STEP, + GET_MERGED_PULL_REQUEST_MOCK_STEP__WELCOME_MESSAGE, + GET_PR_COUNT_MOCK_STEP, + COMMENT_ON_FIRST_PULL_REQUEST_MOCK_STEP, +]; + +// e2e_tests +const CHECKOUT_MOCK_STEP__E2E_TESTS = { + name: 'Checkout', + mockWith: 'echo [MOCK] [E2E_TESTS] Checking out', +}; +const SETUP_NODE_MOCK_STEP = { + name: 'Setup node', + mockWith: 'echo [MOCK] [E2E_TESTS] Setting up node', +}; +const SETUP_RUBY_MOCK_STEP = { + name: 'Setup ruby', + mockWith: 'echo [MOCK] [E2E_TESTS] Setting up ruby', +}; +const GRADLE_CACHE_MOCK_STEP = { + name: 'Gradle cache', + mockWith: 'echo [MOCK] [E2E_TESTS] Building with gradle', +}; +const MAKE_ZIP_MOCK_STEP = { + name: 'Make zip directory for everything to send to AWS Device Farm', + mockWith: 'echo [MOCK] [E2E_TESTS] Creating zip directory', +}; +const CHECKOUT_COMPARE_MOCK_STEP = { + name: 'Checkout "Compare" commit', + mockWith: 'echo [MOCK] [E2E_TESTS] Checking out compare commit', +}; +const INSTALL_NODE_PACKAGES_MOCK_STEP = { + name: 'Install node packages', + mockWith: 'echo [MOCK] [E2E_TESTS] Installing node packages', +}; +const BUILD_COMPARE_APK_MOCK_STEP = { + name: 'Build "Compare" APK', + mockWith: 'echo [MOCK] [E2E_TESTS] Building compare apk', +}; +const COPY_COMPARE_APK_MOCK_STEP = { + name: 'Copy "Compare" APK', + mockWith: 'echo [MOCK] [E2E_TESTS] Copying compare apk', +}; +const CHECKOUT_BASELINE_COMMIT_MOCK_STEP = { + name: 'Checkout "Baseline" commit (last release)', + mockWith: 'echo [MOCK] [E2E_TESTS] Checking out baseline commit', +}; +const BUILD_BASELINE_APK_MOCK_STEP = { + name: 'Build "Baseline" APK', + mockWith: 'echo [MOCK] [E2E_TESTS] Building baseline apk', +}; +const COPY_BASELINE_APK_MOCK_STEP = { + name: 'Copy "Baseline" APK', + mockWith: 'echo [MOCK] [E2E_TESTS] Copying baseline apk', +}; +const CHECKOUT_PREVIOUS_BRANCH_MOCK_STEP = { + name: 'Checkout previous branch for source code to run on AWS Device farm', + mockWith: 'echo [MOCK] [E2E_TESTS] Checking out previous branch', +}; +const COPY_E2E_CODE_MOCK_STEP = { + name: 'Copy e2e code into zip folder', + mockWith: 'echo [MOCK] [E2E_TESTS] Copying e2e tests', +}; +const ZIP_EVERYTHING_MOCK_STEP = { + name: 'Zip everything in the zip directory up', + mockWith: 'echo [MOCK] [E2E_TESTS] Zipping everything', +}; +const CONFIGURE_AWS_CREDENTIALS_MOCK_STEP = { + name: 'Configure AWS Credentials', + mockWith: 'echo [MOCK] [E2E_TESTS] Configuring AWS credentials', +}; +const SCHEDULE_AWS_DEVICE_FARM_MOCK_STEP = { + name: 'Schedule AWS Device Farm test run', + mockWith: 'echo [MOCK] [E2E_TESTS] Scheduling AWS test run', +}; +const UNZIP_AWS_DEVICE_FARM_RESULTS_MOCK_STEP = { + name: 'Unzip AWS Device Farm results', + mockWith: 'echo [MOCK] [E2E_TESTS] Unzipping test results', +}; +const PRINT_AWS_DEVICE_FARM_RESULTS_MOCK_STEP = { + name: 'Print AWS Device Farm run results', + mockWith: 'echo [MOCK] [E2E_TESTS] Printing test results', +}; +const SET_OUTPUT_OF_AWS_DEVICE_FARM_MOCK_STEP = { + name: 'Set output of AWS Device Farm into GitHub ENV', + mockWith: 'echo [MOCK] [E2E_TESTS] Setting AWS output', +}; +const GET_MERGED_PULL_REQUEST_MOCK_STEP__E2E_TESTS = { + name: 'Get merged pull request', + mockWith: 'echo [MOCK] [E2E_TESTS] Getting merged pull request', +}; +const LEAVE_COMMENT_WITH_AWS_DEVICE_FARM_OUTPUT_MOCK_STEP = { + name: 'Leave output of AWS Device Farm as a PR comment', + mockWith: 'echo [MOCK] [E2E_TESTS] Leaving comment with test results', +}; +const CHECK_IF_TESTS_FAILED_MOCK_STEP = { + name: 'Check if test failed, if so leave a deploy blocker label', + mockWith: 'echo [MOCK] [E2E_TESTS] Checking if tests failed', +}; +export 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, +]; diff --git a/workflow_tests/preDeploy.test.ts b/workflow_tests/preDeploy.test.ts index f34a59fadf44..1e1b10454a8a 100644 --- a/workflow_tests/preDeploy.test.ts +++ b/workflow_tests/preDeploy.test.ts @@ -1,7 +1,9 @@ import {MockGithub} from '@kie/mock-github'; import {Act} from '@kie/act-js'; import path from 'path'; -import {string} from 'prop-types'; +import * as mocks from './mocks/preDeployMocks'; +import * as assertions from './assertions/preDeployAssertions'; +import * as utils from './utils'; let mockGithub: MockGithub; const FILES_TO_COPY_INTO_TEST_REPO = [ @@ -48,610 +50,17 @@ afterEach(async () => { await mockGithub.teardown(); }); -// lint -const LINT_WORKFLOW_MOCK_STEP = { - name: 'Run lint workflow', - mockWith: 'echo [MOCK] [LINT] Running lint workflow', -}; -const LINT_JOB_MOCK_STEPS = [ - LINT_WORKFLOW_MOCK_STEP, -]; - -// test -const TEST_WORKFLOW_MOCK_STEP = { - name: 'Run test workflow', - mockWith: 'echo [MOCK] [TEST] Running test workflow', -}; -const TEST_JOB_MOCK_STEPS = [ - TEST_WORKFLOW_MOCK_STEP, -]; - -// confirm_passing_build -const ANNOUNCE_IN_SLACK_MOCK_STEP = { - name: 'Announce failed workflow in Slack', - mockWith: 'echo [MOCK] [CONFIRM_PASSING_BUILD] Announcing failed workflow in slack, SLACK_WEBHOOK=${{ secrets.SLACK_WEBHOOK }}', -}; -const CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS = [ - ANNOUNCE_IN_SLACK_MOCK_STEP, -]; - -// choose_deploy_actions -const GET_MERGED_PULL_REQUEST_MOCK_STEP__CHOOSE_DEPLOY = { - name: 'Get merged pull request', - mockWith: 'echo [MOCK] [CHOOSE_DEPLOY_ACTIONS] Getting merged pull request, GITHUB_TOKEN=${{ github.token }}\n' - + 'echo "number=123" >> "$GITHUB_OUTPUT"\n' - + 'echo "labels=[\'CP Staging\']" >> "$GITHUB_OUTPUT"\n', -}; -const CHECK_IF_STAGINGDEPLOYCASH_IS_LOCKED_MOCK_STEP = { - name: 'Check if StagingDeployCash is locked', - mockWith: 'echo [MOCK] [CHOOSE_DEPLOY_ACTIONS] Checking StagingDeployCash, GITHUB_TOKEN=${{ github.token }}\n' - + 'echo "IS_LOCKED=true" >> "$GITHUB_OUTPUT"', -}; -const CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS = [ - GET_MERGED_PULL_REQUEST_MOCK_STEP__CHOOSE_DEPLOY, - CHECK_IF_STAGINGDEPLOYCASH_IS_LOCKED_MOCK_STEP, -]; - -// skip_deploy -const COMMENT_ON_DEFERRED_PR_MOCK_STEP = { - name: 'Comment on deferred PR', - mockWith: 'echo [MOCK] [SKIP_DEPLOY] Skipping deploy, GITHUB_TOKEN=${{ secrets.OS_BOTIFY_TOKEN }}, NUMBER=${{ needs.chooseDeployActions.outputs.MERGED_PR }}, BODY=:hand: This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.', -}; -const SKIP_DEPLOY_JOB_MOCK_STEPS = [ - COMMENT_ON_DEFERRED_PR_MOCK_STEP, -]; - -// create_new_version -const CREATE_NEW_VERSION_MOCK_STEP = { - name: 'Create new version', - mockWith: 'echo [MOCK] [CREATE_NEW_VERSION] Creating new version', -}; -const CREATE_NEW_VERSION_JOB_MOCK_STEPS = [ - CREATE_NEW_VERSION_MOCK_STEP, -]; - -// update_staging -const RUN_TURNSTYLE_MOCK_STEP = { - name: 'Run turnstyle', - mockWith: 'echo [MOCK] [UPDATE_STAGING] Running turnstyle', -}; -const UPDATE_STAGING_BRANCH_MOCK_STEP = { - name: 'Update staging branch from main', - mockWith: 'echo [MOCK] [UPDATE_STAGING] Updating staging branch', -}; -const CHERRYPICK_PR_MOCK_STEP = { - name: 'Cherry-pick PR to staging', - mockWith: 'echo [MOCK] [UPDATE_STAGING] Cherry picking', -}; -const CHECKOUT_STAGING_MOCK_STEP = { - name: 'Checkout staging', - mockWith: 'echo [MOCK] [UPDATE_STAGING] Checking out staging', -}; -const TAG_STAGING_MOCK_STEP = { - name: 'Tag staging', - mockWith: 'echo [MOCK] [UPDATE_STAGING] Tagging staging', -}; -const UPDATE_STAGINGDEPLOYCASH_MOCK_STEP = { - name: 'Update StagingDeployCash', - mockWith: 'echo [MOCK] [UPDATE_STAGING] Updating StagingDeployCash', -}; -const FIND_OPEN_STAGINGDEPLOYCASH_MOCK_STEP = { - name: 'Find open StagingDeployCash', - mockWith: 'echo [MOCK] [UPDATE_STAGING] Finding open StagingDeployCash\n' - + 'echo "STAGING_DEPLOY_CASH=1234" >> "$GITHUB_OUTPUT"', -}; -const COMMENT_TO_ALERT_APPLAUSE_CHERRYPICK_MOCK_STEP = { - name: 'Comment in StagingDeployCash to alert Applause that a new pull request has been cherry-picked', - mockWith: 'echo [MOCK] [UPDATE_STAGING] Commenting in StagingDeployCash', -}; -const WAIT_FOR_STAGING_DEPLOYS_MOCK_STEP = { - name: 'Wait for staging deploys to finish', - mockWith: 'echo [MOCK] [UPDATE_STAGING] Waiting for staging deploy to finish', -}; -const COMMENT_TO_ALERT_APPLAUSE_DEPLOY_MOCK_STEP = { - name: 'Comment in StagingDeployCash to alert Applause that cherry-picked pull request has been deployed.', - mockWith: 'echo [MOCK] [UPDATE_STAGING] Commenting in StagingDeployCash', -}; -const ANNOUNCE_FAILED_WORKFLOW_IN_SLACK_MOCK_STEP = { - name: 'Announce failed workflow in Slack', - mockWith: 'echo [MOCK] [UPDATE_STAGING] Announcing failed workflow in slack', -}; -const UPDATE_STAGING_JOB_MOCK_STEPS = [ - RUN_TURNSTYLE_MOCK_STEP, - UPDATE_STAGING_BRANCH_MOCK_STEP, - CHERRYPICK_PR_MOCK_STEP, - CHECKOUT_STAGING_MOCK_STEP, - TAG_STAGING_MOCK_STEP, - UPDATE_STAGINGDEPLOYCASH_MOCK_STEP, - FIND_OPEN_STAGINGDEPLOYCASH_MOCK_STEP, - COMMENT_TO_ALERT_APPLAUSE_CHERRYPICK_MOCK_STEP, - WAIT_FOR_STAGING_DEPLOYS_MOCK_STEP, - COMMENT_TO_ALERT_APPLAUSE_DEPLOY_MOCK_STEP, - ANNOUNCE_FAILED_WORKFLOW_IN_SLACK_MOCK_STEP, -]; - -// is_expensify_employee -const GET_MERGED_PULL_REQUEST_MOCK_STEP__IS_EXPENSIFY_EMPLOYEE = { - name: 'Get merged pull request', - mockWith: 'echo [MOCK] [IS_EXPENSIFY_EMPLOYEE] Getting merged pull request\n' - + 'echo "author=Dummy Author" >> "$GITHUB_OUTPUT"', -}; -const CHECK_TEAM_MEMBERSHIP_MOCK_STEP = { - name: 'Check whether the actor is member of Expensify/expensify team', - mockWith: 'echo [MOCK] [IS_EXPENSIFY_EMPLOYEE] Checking actors Expensify membership\n' - + 'echo "isTeamMember=true" >> "$GITHUB_OUTPUT"', -}; -const IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS = [ - GET_MERGED_PULL_REQUEST_MOCK_STEP__IS_EXPENSIFY_EMPLOYEE, - CHECK_TEAM_MEMBERSHIP_MOCK_STEP, -]; - -// new_contributor_welcome_message -const CHECKOUT_MOCK_STEP = { - name: 'Checkout', - mockWith: 'echo [MOCK] [NEW_CONTRIBUTOR_WELCOME_MESSAGE] Checking out', -}; -const GET_MERGED_PULL_REQUEST_MOCK_STEP__WELCOME_MESSAGE = { - name: 'Get merged pull request', - mockWith: 'echo [MOCK] [NEW_CONTRIBUTOR_WELCOME_MESSAGE] Getting merged pull request', -}; -const GET_PR_COUNT_MOCK_STEP = { - name: 'Get PR count for ${{ steps.getMergedPullRequest.outputs.author }}', - mockWith: 'echo [MOCK] [NEW_CONTRIBUTOR_WELCOME_MESSAGE] Getting PR count', -}; -const COMMENT_ON_FIRST_PULL_REQUEST_MOCK_STEP = { - name: 'Comment on ${{ steps.getMergedPullRequest.outputs.author }}\\\'s first pull request!', - mockWith: 'echo [MOCK] [NEW_CONTRIBUTOR_WELCOME_MESSAGE] Creating comment', -}; -const NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS = [ - CHECKOUT_MOCK_STEP, - GET_MERGED_PULL_REQUEST_MOCK_STEP__WELCOME_MESSAGE, - GET_PR_COUNT_MOCK_STEP, - COMMENT_ON_FIRST_PULL_REQUEST_MOCK_STEP, -]; - -// e2e_tests -const CHECKOUT_MOCK_STEP__E2E_TESTS = { - name: 'Checkout', - mockWith: 'echo [MOCK] [E2E_TESTS] Checking out', -}; -const SETUP_NODE_MOCK_STEP = { - name: 'Setup node', - mockWith: 'echo [MOCK] [E2E_TESTS] Setting up node', -}; -const SETUP_RUBY_MOCK_STEP = { - name: 'Setup ruby', - mockWith: 'echo [MOCK] [E2E_TESTS] Setting up ruby', -}; -const GRADLE_CACHE_MOCK_STEP = { - name: 'Gradle cache', - mockWith: 'echo [MOCK] [E2E_TESTS] Building with gradle', -}; -const MAKE_ZIP_MOCK_STEP = { - name: 'Make zip directory for everything to send to AWS Device Farm', - mockWith: 'echo [MOCK] [E2E_TESTS] Creating zip directory', -}; -const CHECKOUT_COMPARE_MOCK_STEP = { - name: 'Checkout "Compare" commit', - mockWith: 'echo [MOCK] [E2E_TESTS] Checking out compare commit', -}; -const INSTALL_NODE_PACKAGES_MOCK_STEP = { - name: 'Install node packages', - mockWith: 'echo [MOCK] [E2E_TESTS] Installing node packages', -}; -const BUILD_COMPARE_APK_MOCK_STEP = { - name: 'Build "Compare" APK', - mockWith: 'echo [MOCK] [E2E_TESTS] Building compare apk', -}; -const COPY_COMPARE_APK_MOCK_STEP = { - name: 'Copy "Compare" APK', - mockWith: 'echo [MOCK] [E2E_TESTS] Copying compare apk', -}; -const CHECKOUT_BASELINE_COMMIT_MOCK_STEP = { - name: 'Checkout "Baseline" commit (last release)', - mockWith: 'echo [MOCK] [E2E_TESTS] Checking out baseline commit', -}; -const BUILD_BASELINE_APK_MOCK_STEP = { - name: 'Build "Baseline" APK', - mockWith: 'echo [MOCK] [E2E_TESTS] Building baseline apk', -}; -const COPY_BASELINE_APK_MOCK_STEP = { - name: 'Copy "Baseline" APK', - mockWith: 'echo [MOCK] [E2E_TESTS] Copying baseline apk', -}; -const CHECKOUT_PREVIOUS_BRANCH_MOCK_STEP = { - name: 'Checkout previous branch for source code to run on AWS Device farm', - mockWith: 'echo [MOCK] [E2E_TESTS] Checking out previous branch', -}; -const COPY_E2E_CODE_MOCK_STEP = { - name: 'Copy e2e code into zip folder', - mockWith: 'echo [MOCK] [E2E_TESTS] Copying e2e tests', -}; -const ZIP_EVERYTHING_MOCK_STEP = { - name: 'Zip everything in the zip directory up', - mockWith: 'echo [MOCK] [E2E_TESTS] Zipping everything', -}; -const CONFIGURE_AWS_CREDENTIALS_MOCK_STEP = { - name: 'Configure AWS Credentials', - mockWith: 'echo [MOCK] [E2E_TESTS] Configuring AWS credentials', -}; -const SCHEDULE_AWS_DEVICE_FARM_MOCK_STEP = { - name: 'Schedule AWS Device Farm test run', - mockWith: 'echo [MOCK] [E2E_TESTS] Scheduling AWS test run', -}; -const UNZIP_AWS_DEVICE_FARM_RESULTS_MOCK_STEP = { - name: 'Unzip AWS Device Farm results', - mockWith: 'echo [MOCK] [E2E_TESTS] Unzipping test results', -}; -const PRINT_AWS_DEVICE_FARM_RESULTS_MOCK_STEP = { - name: 'Print AWS Device Farm run results', - mockWith: 'echo [MOCK] [E2E_TESTS] Printing test results', -}; -const SET_OUTPUT_OF_AWS_DEVICE_FARM_MOCK_STEP = { - name: 'Set output of AWS Device Farm into GitHub ENV', - mockWith: 'echo [MOCK] [E2E_TESTS] Setting AWS output', -}; -const GET_MERGED_PULL_REQUEST_MOCK_STEP__E2E_TESTS = { - name: 'Get merged pull request', - mockWith: 'echo [MOCK] [E2E_TESTS] Getting merged pull request', -}; -const LEAVE_COMMENT_WITH_AWS_DEVICE_FARM_OUTPUT_MOCK_STEP = { - name: 'Leave output of AWS Device Farm as a PR comment', - mockWith: 'echo [MOCK] [E2E_TESTS] Leaving comment with test results', -}; -const CHECK_IF_TESTS_FAILED_MOCK_STEP = { - name: 'Check if test failed, if so leave a deploy blocker label', - mockWith: 'echo [MOCK] [E2E_TESTS] Checking if tests failed', -}; -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, -]; - -// all together const MOCK_STEPS = { - lint: LINT_JOB_MOCK_STEPS, - test: TEST_JOB_MOCK_STEPS, - confirmPassingBuild: CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, - chooseDeployActions: CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS, - skipDeploy: SKIP_DEPLOY_JOB_MOCK_STEPS, - createNewVersion: CREATE_NEW_VERSION_JOB_MOCK_STEPS, - updateStaging: UPDATE_STAGING_JOB_MOCK_STEPS, - isExpensifyEmployee: IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS, - newContributorWelcomeMessage: NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS, - 'e2e-tests': E2E_TESTS_JOB_MOCK_STEPS, -}; - -// assertion helper methods -const assertLintJobExecuted = (workflowResult: Array, didExecute: Boolean = true) => { - const steps = [{ - name: 'Main Run lint workflow', - status: 0, - output: '[MOCK] [LINT] Running lint workflow', - }]; - if (didExecute) { - expect(workflowResult).toEqual(expect.arrayContaining(steps)); - } else { - expect(workflowResult).not.toEqual(steps); - } -}; -const assertTestJobExecuted = (workflowResult: Array, didExecute: Boolean = true) => { - const steps = [{ - name: 'Main Run test workflow', - status: 0, - output: '[MOCK] [TEST] Running test workflow', - }]; - if (didExecute) { - expect(workflowResult).toEqual(expect.arrayContaining(steps)); - } else { - expect(workflowResult).not.toEqual(steps); - } -}; -const assertIsExpensifyEmployeeJobExecuted = (workflowResult: Array, didExecute: Boolean = true) => { - const steps = [{ - name: 'Main Get merged pull request', - status: 0, - output: '[MOCK] [IS_EXPENSIFY_EMPLOYEE] Getting merged pull request', - }, - { - name: 'Main Check whether the actor is member of Expensify/expensify team', - status: 0, - output: '[MOCK] [IS_EXPENSIFY_EMPLOYEE] Checking actors Expensify membership', - }]; - if (didExecute) { - expect(workflowResult).toEqual(expect.arrayContaining(steps)); - } else { - expect(workflowResult).not.toEqual(steps); - } -}; -const assertE2ETestsJobExecuted = (workflowResult: Array, didExecute: Boolean = true) => { - const steps = [ - { - name: 'Main Checkout', - status: 0, - output: '[MOCK] [E2E_TESTS] Checking out', - }, - { - name: 'Main Setup node', - status: 0, - output: '[MOCK] [E2E_TESTS] Setting up node', - }, - { - name: 'Main Setup ruby', - status: 0, - output: '[MOCK] [E2E_TESTS] Setting up ruby', - }, - { - name: 'Main Gradle cache', - status: 0, - output: '[MOCK] [E2E_TESTS] Building with gradle', - }, - { - name: 'Make zip directory for everything to send to AWS Device Farm', - status: 0, - output: '[MOCK] [E2E_TESTS] Creating zip directory', - }, - { - name: 'Checkout "Compare" commit', - status: 0, - output: '[MOCK] [E2E_TESTS] Checking out compare commit', - }, - { - name: 'Install node packages', - status: 0, - output: '[MOCK] [E2E_TESTS] Installing node packages', - }, - { - name: 'Build "Compare" APK', - status: 0, - output: '[MOCK] [E2E_TESTS] Building compare apk', - }, - { - name: 'Copy "Compare" APK', - status: 0, - output: '[MOCK] [E2E_TESTS] Copying compare apk', - }, - { - name: 'Checkout "Baseline" commit (last release)', - status: 0, - output: '[MOCK] [E2E_TESTS] Checking out baseline commit', - }, - { - name: 'Install node packages', - status: 0, - output: '[MOCK] [E2E_TESTS] Installing node packages', - }, - { - name: 'Build "Baseline" APK', - status: 0, - output: '[MOCK] [E2E_TESTS] Building baseline apk', - }, - { - name: 'Copy "Baseline" APK', - status: 0, - output: '[MOCK] [E2E_TESTS] Copying baseline apk', - }, - { - name: 'Checkout previous branch for source code to run on AWS Device farm', - status: 0, - output: '[MOCK] [E2E_TESTS] Checking out previous branch', - }, - { - name: 'Copy e2e code into zip folder', - status: 0, - output: '[MOCK] [E2E_TESTS] Copying e2e tests', - }, - { - name: 'Zip everything in the zip directory up', - status: 0, - output: '[MOCK] [E2E_TESTS] Zipping everything', - }, - { - name: 'Configure AWS Credentials', - status: 0, - output: '[MOCK] [E2E_TESTS] Configuring AWS credentials', - }, - { - name: 'Schedule AWS Device Farm test run', - status: 0, - output: '[MOCK] [E2E_TESTS] Scheduling AWS test run', - }, - { - name: 'Unzip AWS Device Farm results', - status: 0, - output: '[MOCK] [E2E_TESTS] Unzipping test results', - }, - { - name: 'Print AWS Device Farm run results', - status: 0, - output: '[MOCK] [E2E_TESTS] Printing test results', - }, - { - name: 'Set output of AWS Device Farm into GitHub ENV', - status: 0, - output: '[MOCK] [E2E_TESTS] Setting AWS output', - }, - { - name: 'Get merged pull request', - status: 0, - output: '[MOCK] [E2E_TESTS] Getting merged pull request', - }, - { - name: 'Leave output of AWS Device Farm as a PR comment', - status: 0, - output: '[MOCK] [E2E_TESTS] Leaving comment with test results', - }, - { - name: 'Check if test failed, if so leave a deploy blocker label', - status: 0, - output: '[MOCK] [E2E_TESTS] Checking if tests failed', - }, - ]; - if (didExecute) { - expect(workflowResult).toEqual(expect.arrayContaining(steps)); - } else { - expect(workflowResult).not.toEqual(steps); - } -}; -const assertChooseDeployActionsJobExecuted = (workflowResult: Array, didExecute: Boolean = true) => { - const steps = [ - { - name: 'Main Get merged pull request', - status: 0, - output: '[MOCK] [CHOOSE_DEPLOY_ACTIONS] Getting merged pull request, GITHUB_TOKEN=***', // no access to secrets - }, - { - name: 'Main Check if StagingDeployCash is locked', - status: 0, - output: '[MOCK] [CHOOSE_DEPLOY_ACTIONS] Checking StagingDeployCash, GITHUB_TOKEN=***', // no access to secrets - }, - { - name: 'Main Check if merged pull request was an automated PR', - status: 0, - output: '', - }, - { - name: 'Main Check if merged pull request has `CP Staging` label', - status: 0, - output: '', - }, - { - name: 'Main Check if merged pull request should trigger a deploy', - status: 0, - output: '', - }, - ]; - if (didExecute) { - expect(workflowResult).toEqual(expect.arrayContaining(steps)); - } else { - expect(workflowResult).not.toEqual(steps); - } -}; -const assertSkipDeployJobExecuted = (workflowResult: Array, didExecute: Boolean = true) => { - const steps = [ - { - name: 'Main Comment on deferred PR', - status: 0, - output: '[MOCK] [SKIP_DEPLOY] Skipping deploy, GITHUB_TOKEN=, NUMBER=123, BODY=:hand: This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.', - }, - ]; - if (didExecute) { - expect(workflowResult).toEqual(expect.arrayContaining(steps)); - } else { - expect(workflowResult).not.toEqual(steps); - } -}; -const assertCreateNewVersionJobExecuted = (workflowResult: Array, didExecute: Boolean = true) => { - const steps = [ - { - name: 'Main Create new version', - status: 0, - output: '[MOCK] [CREATE_NEW_VERSION] Creating new version', - }, - ]; - if (didExecute) { - expect(workflowResult).toEqual(expect.arrayContaining(steps)); - } else { - expect(workflowResult).not.toEqual(steps); - } -}; -const assertUpdateStagingJobExecuted = (workflowResult: Array, didExecute: Boolean = true) => { - const steps = [ - { - name: 'Main Run turnstyle', - status: 0, - output: '[MOCK] [UPDATE_STAGING] Running turnstyle', - }, - { - name: 'Main Cherry-pick PR to staging', - status: 0, - output: '[MOCK] [UPDATE_STAGING] Cherry picking', - }, - { - name: 'Main Checkout staging', - status: 0, - output: '[MOCK] [UPDATE_STAGING] Checking out staging', - }, - { - name: 'Main Tag staging', - status: 0, - output: '[MOCK] [UPDATE_STAGING] Tagging staging', - }, - { - name: 'Main Update StagingDeployCash', - status: 0, - output: '[MOCK] [UPDATE_STAGING] Updating StagingDeployCash', - }, - { - name: 'Main Find open StagingDeployCash', - status: 0, - output: '[MOCK] [UPDATE_STAGING] Finding open StagingDeployCash', - }, - { - name: 'Main Comment in StagingDeployCash to alert Applause that a new pull request has been cherry-picked', - status: 0, - output: '[MOCK] [UPDATE_STAGING] Commenting in StagingDeployCash', - }, - { - name: 'Main Wait for staging deploys to finish', - status: 0, - output: '[MOCK] [UPDATE_STAGING] Waiting for staging deploy to finish', - }, - { - name: 'Main Comment in StagingDeployCash to alert Applause that cherry-picked pull request has been deployed.', - status: 0, - output: '[MOCK] [UPDATE_STAGING] Commenting in StagingDeployCash', - }, - ]; - if (didExecute) { - expect(workflowResult).toEqual(expect.arrayContaining(steps)); - } else { - expect(workflowResult).not.toEqual(steps); - } -}; - -const setUpActParams = (act: Act, event?: string, event_options?: any, secrets?: Array, github_token?: string) => { - let updated_act = act; - - if (event && event_options) { - updated_act = updated_act.setEvent({ - event: event_options, - }); - } - - if (secrets) { - for (const [key, value] of Object.entries(secrets)) { - updated_act = updated_act.setSecret(key, String(value)); - } - } - - if (github_token) { - updated_act = updated_act.setGithubToken(github_token); - } - - return updated_act; + lint: mocks.LINT_JOB_MOCK_STEPS, + test: mocks.TEST_JOB_MOCK_STEPS, + confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, + chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS, + skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, + createNewVersion: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, + updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, + isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS, + newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS, + 'e2e-tests': mocks.E2E_TESTS_JOB_MOCK_STEPS, }; describe('test workflow preDeploy', () => { @@ -666,48 +75,48 @@ describe('test workflow preDeploy', () => { let act = new Act(repoPath, workflowPath); // set run parameters - act = setUpActParams( + act = utils.setUpActParams( act, 'pull_request', {head: {ref: 'main'}}, - [{OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook'}], + {OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook'}, 'dummy_github_token', ); // set up mocks - const mocks = MOCK_STEPS; + const testMockSteps = MOCK_STEPS; // run an event and get the result const result = await act .runEvent('push', { workflowFile: path.join(repoPath, '.github', 'workflows'), - mockSteps: mocks, + mockSteps: testMockSteps, }); // assert results (some steps can run in parallel to each other so the order is not assured // therefore we can check which steps have been executed, but not the set job order - assertLintJobExecuted(result); - assertTestJobExecuted(result); - assertIsExpensifyEmployeeJobExecuted(result); - assertE2ETestsJobExecuted(result, false); // Act does not support ubuntu-20.04-64core runner and omits the job - assertChooseDeployActionsJobExecuted(result); - assertSkipDeployJobExecuted(result, false); - assertCreateNewVersionJobExecuted(result); - assertUpdateStagingJobExecuted(result); + assertions.assertLintJobExecuted(result); + assertions.assertTestJobExecuted(result); + assertions.assertIsExpensifyEmployeeJobExecuted(result); + assertions.assertE2ETestsJobExecuted(result, false); // Act does not support ubuntu-20.04-64core runner and omits the job + assertions.assertChooseDeployActionsJobExecuted(result); + assertions.assertSkipDeployJobExecuted(result, false); + assertions.assertCreateNewVersionJobExecuted(result); + assertions.assertUpdateStagingJobExecuted(result); }, 60000); test('lint job failed', async () => { const repoPath = mockGithub.repo.getPath('testWorkflowsRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); let act = new Act(repoPath, workflowPath); - act = setUpActParams( + act = utils.setUpActParams( act, 'pull_request', {head: {ref: 'main'}}, - [{OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook'}], + {OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook'}, 'dummy_github_token', ); - const mocks = { + const testMockSteps = { lint: [ { name: 'Run lint workflow', @@ -716,20 +125,20 @@ describe('test workflow preDeploy', () => { + 'exit 1', }, ], - test: TEST_JOB_MOCK_STEPS, - confirmPassingBuild: CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, - chooseDeployActions: CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS, - skipDeploy: SKIP_DEPLOY_JOB_MOCK_STEPS, - createNewVersion: CREATE_NEW_VERSION_JOB_MOCK_STEPS, - updateStaging: UPDATE_STAGING_JOB_MOCK_STEPS, - isExpensifyEmployee: IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS, - newContributorWelcomeMessage: NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS, - 'e2e-tests': E2E_TESTS_JOB_MOCK_STEPS, + test: mocks.TEST_JOB_MOCK_STEPS, + confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, + chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS, + skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, + createNewVersion: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, + updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, + isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS, + newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS, + 'e2e-tests': mocks.E2E_TESTS_JOB_MOCK_STEPS, }; const result = await act .runEvent('push', { workflowFile: path.join(repoPath, '.github', 'workflows'), - mockSteps: mocks, + mockSteps: testMockSteps, }); expect(result).toEqual(expect.arrayContaining( [{ @@ -739,14 +148,14 @@ describe('test workflow preDeploy', () => { + '[MOCK] [LINT] Lint workflow failed', }], )); - assertTestJobExecuted(result); - assertIsExpensifyEmployeeJobExecuted(result); + assertions.assertTestJobExecuted(result); + assertions.assertIsExpensifyEmployeeJobExecuted(result); expect(result).toEqual(expect.arrayContaining( [ { name: 'Main Announce failed workflow in Slack', status: 0, - output: '[MOCK] [CONFIRM_PASSING_BUILD] Announcing failed workflow in slack, SLACK_WEBHOOK=', // no access to secrets + output: '[MOCK] [CONFIRM_PASSING_BUILD] Announcing failed workflow in slack, SLACK_WEBHOOK=***', // no access to secrets }, { name: 'Main Exit failed workflow', @@ -755,26 +164,26 @@ describe('test workflow preDeploy', () => { }, ], )); - assertE2ETestsJobExecuted(result, false); // Act does not support ubuntu-20.04-64core runner and omits the job - assertChooseDeployActionsJobExecuted(result, false); - assertSkipDeployJobExecuted(result, false); - assertCreateNewVersionJobExecuted(result, false); - assertUpdateStagingJobExecuted(result, false); + assertions.assertE2ETestsJobExecuted(result, false); // Act does not support ubuntu-20.04-64core runner and omits the job + assertions.assertChooseDeployActionsJobExecuted(result, false); + assertions.assertSkipDeployJobExecuted(result, false); + assertions.assertCreateNewVersionJobExecuted(result, false); + assertions.assertUpdateStagingJobExecuted(result, false); }, 60000); test('test job failed', async () => { const repoPath = mockGithub.repo.getPath('testWorkflowsRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); let act = new Act(repoPath, workflowPath); - act = setUpActParams( + act = utils.setUpActParams( act, 'pull_request', {head: {ref: 'main'}}, - [{OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook'}], + {OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook'}, 'dummy_github_token', ); - const mocks = { - lint: LINT_JOB_MOCK_STEPS, + const testMockSteps = { + lint: mocks.LINT_JOB_MOCK_STEPS, test: [ { name: 'Run test workflow', @@ -783,21 +192,21 @@ describe('test workflow preDeploy', () => { + 'exit 1', }, ], - confirmPassingBuild: CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, - chooseDeployActions: CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS, - skipDeploy: SKIP_DEPLOY_JOB_MOCK_STEPS, - createNewVersion: CREATE_NEW_VERSION_JOB_MOCK_STEPS, - updateStaging: UPDATE_STAGING_JOB_MOCK_STEPS, - isExpensifyEmployee: IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS, - newContributorWelcomeMessage: NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS, - 'e2e-tests': E2E_TESTS_JOB_MOCK_STEPS, + confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, + chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS, + skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, + createNewVersion: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, + updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, + isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS, + newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS, + 'e2e-tests': mocks.E2E_TESTS_JOB_MOCK_STEPS, }; const result = await act .runEvent('push', { workflowFile: path.join(repoPath, '.github', 'workflows'), - mockSteps: mocks, + mockSteps: testMockSteps, }); - assertLintJobExecuted(result); + assertions.assertLintJobExecuted(result); expect(result).toEqual(expect.arrayContaining( [{ name: 'Main Run test workflow', @@ -806,13 +215,13 @@ describe('test workflow preDeploy', () => { + '[MOCK] [TEST] Test workflow failed', }], )); - assertIsExpensifyEmployeeJobExecuted(result); + assertions.assertIsExpensifyEmployeeJobExecuted(result); expect(result).toEqual(expect.arrayContaining( [ { name: 'Main Announce failed workflow in Slack', status: 0, - output: '[MOCK] [CONFIRM_PASSING_BUILD] Announcing failed workflow in slack, SLACK_WEBHOOK=', // no access to secrets + output: '[MOCK] [CONFIRM_PASSING_BUILD] Announcing failed workflow in slack, SLACK_WEBHOOK=***', // no access to secrets }, { name: 'Main Exit failed workflow', @@ -821,10 +230,10 @@ describe('test workflow preDeploy', () => { }, ], )); - assertE2ETestsJobExecuted(result, false); // Act does not support ubuntu-20.04-64core runner and omits the job - assertChooseDeployActionsJobExecuted(result, false); - assertSkipDeployJobExecuted(result, false); - assertCreateNewVersionJobExecuted(result, false); - assertUpdateStagingJobExecuted(result, false); + assertions.assertE2ETestsJobExecuted(result, false); // Act does not support ubuntu-20.04-64core runner and omits the job + assertions.assertChooseDeployActionsJobExecuted(result, false); + assertions.assertSkipDeployJobExecuted(result, false); + assertions.assertCreateNewVersionJobExecuted(result, false); + assertions.assertUpdateStagingJobExecuted(result, false); }, 60000); }); diff --git a/workflow_tests/utils.ts b/workflow_tests/utils.ts new file mode 100644 index 000000000000..a76ce55a63d8 --- /dev/null +++ b/workflow_tests/utils.ts @@ -0,0 +1,23 @@ +import {Act} from '@kie/act-js'; + +export const setUpActParams = (act: Act, event?: string, event_options?: any, secrets?: Object, github_token?: string) => { + let updated_act = act; + + if (event && event_options) { + updated_act = updated_act.setEvent({ + event: event_options, + }); + } + + if (secrets) { + for (const [key, value] of Object.entries(secrets)) { + updated_act = updated_act.setSecret(key, value); + } + } + + if (github_token) { + updated_act = updated_act.setGithubToken(github_token); + } + + return updated_act; +}; From b427262eed0caf6dc7644e3faeedb27aa4b515bb Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Thu, 23 Feb 2023 16:16:55 +0100 Subject: [PATCH 011/504] Add new tests [WiP] Added tests for new contributor message job See: https://github.com/Expensify/App/issues/13604 --- .../assertions/preDeployAssertions.ts | 34 ++ workflow_tests/mocks/preDeployMocks.ts | 62 ++- workflow_tests/preDeploy.test.ts | 468 ++++++++++++------ 3 files changed, 412 insertions(+), 152 deletions(-) diff --git a/workflow_tests/assertions/preDeployAssertions.ts b/workflow_tests/assertions/preDeployAssertions.ts index 0f02f1373d54..0dc493f3d0f6 100644 --- a/workflow_tests/assertions/preDeployAssertions.ts +++ b/workflow_tests/assertions/preDeployAssertions.ts @@ -42,6 +42,40 @@ export const assertIsExpensifyEmployeeJobExecuted = (workflowResult: Array, didExecute: Boolean = true, isOsBotify: Boolean = false, isFirstPr: Boolean = false) => { + const steps = [ + { + name: 'Main Checkout', + status: 0, + output: '[MOCK] [NEW_CONTRIBUTOR_WELCOME_MESSAGE] Checking out, TOKEN=***', + }, + { + name: 'Main Get merged pull request', + status: 0, + output: '[MOCK] [NEW_CONTRIBUTOR_WELCOME_MESSAGE] Getting merged pull request, GITHUB_TOKEN=***', + }, + { + name: isOsBotify ? 'Main Get PR count for OSBotify' : 'Main Get PR count for Dummy Author', + status: 0, + output: '[MOCK] [NEW_CONTRIBUTOR_WELCOME_MESSAGE] Getting PR count, GITHUB_TOKEN=***', + }, + ]; + if (isFirstPr) { + steps.push( + { + name: isOsBotify ? 'Main Comment on OSBotify\\\'s first pull request!' : 'Main Comment on Dummy Author\\\'s first pull request!', + status: 0, + output: isOsBotify ? '[MOCK] [NEW_CONTRIBUTOR_WELCOME_MESSAGE] Creating comment, GITHUB_TOKEN=***, NUMBER=12345, BODY=@OSBotify, Great job getting your first Expensify/App pull request over the finish line! :tada:\n\nI know there\'s a lot of information in our [contributing guidelines](https://github.com/Expensify/App/blob/main/contributingGuides/CONTRIBUTING.md), so here are some points to take note of :memo::\n\n1. Now that your first PR has been merged, you can be hired for another issue. Once you\'ve completed a few issues, you may be eligible to work on more than one job at a time.\n2. Once your PR is deployed to our staging servers, it will undergo quality assurance (QA) testing. If we find that it doesn\'t work as expected or causes a regression, you\'ll be responsible for fixing it. Typically, we would revert this PR and give you another chance to create a similar PR without causing a regression.\n3. Once your PR is deployed to _production_, we start a 7-day timer :alarm_clock:. After it has been on production for 7 days without causing any regressions, then we pay out the Upwork job. :moneybag:\n\nSo it might take a while before you\'re paid for your work, but we typically post multiple new jobs every day, so there\'s plenty of opportunity. I hope you\'ve had a positive experience contributing to this repo! :blush:' : '[MOCK] [NEW_CONTRIBUTOR_WELCOME_MESSAGE] Creating comment, GITHUB_TOKEN=***, NUMBER=12345, BODY=@Dummy Author, Great job getting your first Expensify/App pull request over the finish line! :tada:\n\nI know there\'s a lot of information in our [contributing guidelines](https://github.com/Expensify/App/blob/main/contributingGuides/CONTRIBUTING.md), so here are some points to take note of :memo::\n\n1. Now that your first PR has been merged, you can be hired for another issue. Once you\'ve completed a few issues, you may be eligible to work on more than one job at a time.\n2. Once your PR is deployed to our staging servers, it will undergo quality assurance (QA) testing. If we find that it doesn\'t work as expected or causes a regression, you\'ll be responsible for fixing it. Typically, we would revert this PR and give you another chance to create a similar PR without causing a regression.\n3. Once your PR is deployed to _production_, we start a 7-day timer :alarm_clock:. After it has been on production for 7 days without causing any regressions, then we pay out the Upwork job. :moneybag:\n\nSo it might take a while before you\'re paid for your work, but we typically post multiple new jobs every day, so there\'s plenty of opportunity. I hope you\'ve had a positive experience contributing to this repo! :blush:', + }, + ); + } + if (didExecute) { + expect(workflowResult).toEqual(expect.arrayContaining(steps)); + } else { + expect(workflowResult).not.toEqual(steps); + } +}; + export const assertE2ETestsJobExecuted = (workflowResult: Array, didExecute: Boolean = true) => { const steps = [ { diff --git a/workflow_tests/mocks/preDeployMocks.ts b/workflow_tests/mocks/preDeployMocks.ts index 3d133e26c730..045409627f3f 100644 --- a/workflow_tests/mocks/preDeployMocks.ts +++ b/workflow_tests/mocks/preDeployMocks.ts @@ -131,41 +131,83 @@ const GET_MERGED_PULL_REQUEST_MOCK_STEP__IS_EXPENSIFY_EMPLOYEE = { mockWith: 'echo [MOCK] [IS_EXPENSIFY_EMPLOYEE] Getting merged pull request, GITHUB_TOKEN=${{ inputs.github_token }}\n' + 'echo "author=Dummy Author" >> "$GITHUB_OUTPUT"', }; -const CHECK_TEAM_MEMBERSHIP_MOCK_STEP = { +const CHECK_TEAM_MEMBERSHIP_MOCK_STEP__TRUE = { name: 'Check whether the actor is member of Expensify/expensify team', mockWith: 'echo [MOCK] [IS_EXPENSIFY_EMPLOYEE] Checking actors Expensify membership, GITHUB_TOKEN=${{ inputs.GITHUB_TOKEN }}, USERNAME=${{ inputs.username }}, TEAM=${{ inputs.team }}\n' + 'echo "isTeamMember=true" >> "$GITHUB_OUTPUT"', }; -export const IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS = [ +export const IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE = [ GET_MERGED_PULL_REQUEST_MOCK_STEP__IS_EXPENSIFY_EMPLOYEE, - CHECK_TEAM_MEMBERSHIP_MOCK_STEP, + CHECK_TEAM_MEMBERSHIP_MOCK_STEP__TRUE, +]; +const CHECK_TEAM_MEMBERSHIP_MOCK_STEP__FALSE = { + name: 'Check whether the actor is member of Expensify/expensify team', + mockWith: 'echo [MOCK] [IS_EXPENSIFY_EMPLOYEE] Checking actors Expensify membership, GITHUB_TOKEN=${{ inputs.GITHUB_TOKEN }}, USERNAME=${{ inputs.username }}, TEAM=${{ inputs.team }}\n' + + 'echo "isTeamMember=false" >> "$GITHUB_OUTPUT"', +}; +export const IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__FALSE = [ + GET_MERGED_PULL_REQUEST_MOCK_STEP__IS_EXPENSIFY_EMPLOYEE, + CHECK_TEAM_MEMBERSHIP_MOCK_STEP__FALSE, ]; // new_contributor_welcome_message const CHECKOUT_MOCK_STEP = { name: 'Checkout', - mockWith: 'echo [MOCK] [NEW_CONTRIBUTOR_WELCOME_MESSAGE] Checking out, TOKEN=${{ inputs.token }}', + mockWith: 'echo [MOCK] [NEW_CONTRIBUTOR_WELCOME_MESSAGE] Checking out, TOKEN=${{ inputs.token }}\n' + + 'echo "author=Dummy Author" >> "$GITHUB_OUTPUT"', +}; +const CHECKOUT_MOCK_STEP__OSBOTIFY = { + name: 'Checkout', + mockWith: 'echo [MOCK] [NEW_CONTRIBUTOR_WELCOME_MESSAGE] Checking out, TOKEN=${{ inputs.token }}\n' + + 'echo "author=OSBotify" >> "$GITHUB_OUTPUT"', }; const GET_MERGED_PULL_REQUEST_MOCK_STEP__WELCOME_MESSAGE = { name: 'Get merged pull request', - mockWith: 'echo [MOCK] [NEW_CONTRIBUTOR_WELCOME_MESSAGE] Getting merged pull request, GITHUB_TOKEN=${{ inputs.github_token }}', + mockWith: 'echo [MOCK] [NEW_CONTRIBUTOR_WELCOME_MESSAGE] Getting merged pull request, GITHUB_TOKEN=${{ inputs.github_token }}\n' + + 'echo "number=12345" >> "$GITHUB_OUTPUT"\n' + + 'echo "author=Dummy Author" >> "$GITHUB_OUTPUT"', }; -const GET_PR_COUNT_MOCK_STEP = { +const GET_MERGED_PULL_REQUEST_MOCK_STEP__WELCOME_MESSAGE__OSBOTIFY = { + name: 'Get merged pull request', + mockWith: 'echo [MOCK] [NEW_CONTRIBUTOR_WELCOME_MESSAGE] Getting merged pull request, GITHUB_TOKEN=${{ inputs.github_token }}\n' + + 'echo "number=12345" >> "$GITHUB_OUTPUT"\n' + + 'echo "author=OSBotify" >> "$GITHUB_OUTPUT"', +}; +const GET_PR_COUNT_MOCK_STEP__1 = { + name: 'Get PR count for ${{ steps.getMergedPullRequest.outputs.author }}', + mockWith: 'echo [MOCK] [NEW_CONTRIBUTOR_WELCOME_MESSAGE] Getting PR count, GITHUB_TOKEN=${{ env.GITHUB_TOKEN }}\n' + + 'echo "PR_COUNT=1" >> "$GITHUB_ENV"', +}; +const GET_PR_COUNT_MOCK_STEP__10 = { name: 'Get PR count for ${{ steps.getMergedPullRequest.outputs.author }}', - mockWith: 'echo [MOCK] [NEW_CONTRIBUTOR_WELCOME_MESSAGE] Getting PR count, GITHUB_TOKEN=${{ env.GITHUB_TOKEN }}', + mockWith: 'echo [MOCK] [NEW_CONTRIBUTOR_WELCOME_MESSAGE] Getting PR count, GITHUB_TOKEN=${{ env.GITHUB_TOKEN }}\n' + + 'echo "PR_COUNT=10" >> "$GITHUB_ENV"', }; const COMMENT_ON_FIRST_PULL_REQUEST_MOCK_STEP = { name: 'Comment on ${{ steps.getMergedPullRequest.outputs.author }}\\\'s first pull request!', - mockWith: 'echo [MOCK] [NEW_CONTRIBUTOR_WELCOME_MESSAGE] Creating comment, GITHUB_TOKEN=${{ inputs.github_token }}, NUMBER=${{ inputs.number }}, BODY=${{ inputs.body }}', + mockWith: 'echo [MOCK] [NEW_CONTRIBUTOR_WELCOME_MESSAGE] Creating comment, GITHUB_TOKEN=${{ inputs.github_token }}, NUMBER=${{ inputs.number }}, BODY="${{ inputs.body }}"', }; -export const NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS = [ +export const NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS = [ CHECKOUT_MOCK_STEP, GET_MERGED_PULL_REQUEST_MOCK_STEP__WELCOME_MESSAGE, - GET_PR_COUNT_MOCK_STEP, + GET_PR_COUNT_MOCK_STEP__10, + COMMENT_ON_FIRST_PULL_REQUEST_MOCK_STEP, +]; +export const NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__ONE_PR = [ + CHECKOUT_MOCK_STEP, + GET_MERGED_PULL_REQUEST_MOCK_STEP__WELCOME_MESSAGE, + GET_PR_COUNT_MOCK_STEP__1, + COMMENT_ON_FIRST_PULL_REQUEST_MOCK_STEP, +]; +export const NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__OSBOTIFY = [ + CHECKOUT_MOCK_STEP__OSBOTIFY, + GET_MERGED_PULL_REQUEST_MOCK_STEP__WELCOME_MESSAGE__OSBOTIFY, + GET_PR_COUNT_MOCK_STEP__10, 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 = { name: 'Checkout', mockWith: 'echo [MOCK] [E2E_TESTS] Checking out', diff --git a/workflow_tests/preDeploy.test.ts b/workflow_tests/preDeploy.test.ts index 1e1b10454a8a..3f01c3e30e86 100644 --- a/workflow_tests/preDeploy.test.ts +++ b/workflow_tests/preDeploy.test.ts @@ -50,19 +50,6 @@ afterEach(async () => { await mockGithub.teardown(); }); -const MOCK_STEPS = { - lint: mocks.LINT_JOB_MOCK_STEPS, - test: mocks.TEST_JOB_MOCK_STEPS, - confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, - chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS, - skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, - createNewVersion: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, - updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, - isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS, - newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS, - 'e2e-tests': mocks.E2E_TESTS_JOB_MOCK_STEPS, -}; - describe('test workflow preDeploy', () => { test('push to main', async () => { // get path to the local test repo @@ -84,7 +71,18 @@ describe('test workflow preDeploy', () => { ); // set up mocks - const testMockSteps = MOCK_STEPS; + const testMockSteps = { + lint: mocks.LINT_JOB_MOCK_STEPS, + test: mocks.TEST_JOB_MOCK_STEPS, + confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, + chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS, + skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, + createNewVersion: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, + updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, + isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, + newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, + 'e2e-tests': mocks.E2E_TESTS_JOB_MOCK_STEPS, + }; // run an event and get the result const result = await act @@ -105,135 +103,321 @@ describe('test workflow preDeploy', () => { assertions.assertUpdateStagingJobExecuted(result); }, 60000); - test('lint job failed', async () => { - const repoPath = mockGithub.repo.getPath('testWorkflowsRepo') || ''; - const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); - let act = new Act(repoPath, workflowPath); - act = utils.setUpActParams( - act, - 'pull_request', - {head: {ref: 'main'}}, - {OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook'}, - 'dummy_github_token', - ); - const testMockSteps = { - lint: [ - { - name: 'Run lint workflow', - mockWith: 'echo [MOCK] [LINT] Running lint workflow\n' - + 'echo [MOCK] [LINT] Lint workflow failed\n' - + 'exit 1', - }, - ], - test: mocks.TEST_JOB_MOCK_STEPS, - confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, - chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS, - skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, - createNewVersion: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, - updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, - isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS, - newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS, - 'e2e-tests': mocks.E2E_TESTS_JOB_MOCK_STEPS, - }; - const result = await act - .runEvent('push', { - workflowFile: path.join(repoPath, '.github', 'workflows'), - mockSteps: testMockSteps, - }); - expect(result).toEqual(expect.arrayContaining( - [{ - name: 'Main Run lint workflow', - status: 1, - output: '[MOCK] [LINT] Running lint workflow\n' - + '[MOCK] [LINT] Lint workflow failed', - }], - )); - assertions.assertTestJobExecuted(result); - assertions.assertIsExpensifyEmployeeJobExecuted(result); - expect(result).toEqual(expect.arrayContaining( - [ - { - name: 'Main Announce failed workflow in Slack', - status: 0, - output: '[MOCK] [CONFIRM_PASSING_BUILD] Announcing failed workflow in slack, SLACK_WEBHOOK=***', // no access to secrets - }, - { - name: 'Main Exit failed workflow', + describe('confirm passing build', () => { + test('lint job failed - workflow exits', async () => { + const repoPath = mockGithub.repo.getPath('testWorkflowsRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); + let act = new Act(repoPath, workflowPath); + act = utils.setUpActParams( + act, + 'pull_request', + {head: {ref: 'main'}}, + {OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook'}, + 'dummy_github_token', + ); + const testMockSteps = { + lint: [ + { + name: 'Run lint workflow', + mockWith: 'echo [MOCK] [LINT] Running lint workflow\n' + + 'echo [MOCK] [LINT] Lint workflow failed\n' + + 'exit 1', + }, + ], + test: mocks.TEST_JOB_MOCK_STEPS, + confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, + chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS, + skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, + createNewVersion: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, + updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, + isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, + newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, + 'e2e-tests': mocks.E2E_TESTS_JOB_MOCK_STEPS, + }; + const result = await act + .runEvent('push', { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + }); + expect(result).toEqual(expect.arrayContaining( + [{ + name: 'Main Run lint workflow', status: 1, - output: '', - }, - ], - )); - assertions.assertE2ETestsJobExecuted(result, false); // Act does not support ubuntu-20.04-64core runner and omits the job - assertions.assertChooseDeployActionsJobExecuted(result, false); - assertions.assertSkipDeployJobExecuted(result, false); - assertions.assertCreateNewVersionJobExecuted(result, false); - assertions.assertUpdateStagingJobExecuted(result, false); - }, 60000); + output: '[MOCK] [LINT] Running lint workflow\n' + + '[MOCK] [LINT] Lint workflow failed', + }], + )); + assertions.assertTestJobExecuted(result); + assertions.assertIsExpensifyEmployeeJobExecuted(result); + expect(result).toEqual(expect.arrayContaining( + [ + { + name: 'Main Announce failed workflow in Slack', + status: 0, + output: '[MOCK] [CONFIRM_PASSING_BUILD] Announcing failed workflow in slack, SLACK_WEBHOOK=***', // no access to secrets + }, + { + name: 'Main Exit failed workflow', + status: 1, + output: '', + }, + ], + )); + assertions.assertE2ETestsJobExecuted(result, false); // Act does not support ubuntu-20.04-64core runner and omits the job + assertions.assertChooseDeployActionsJobExecuted(result, false); + assertions.assertSkipDeployJobExecuted(result, false); + assertions.assertCreateNewVersionJobExecuted(result, false); + assertions.assertUpdateStagingJobExecuted(result, false); + }, 60000); - test('test job failed', async () => { - const repoPath = mockGithub.repo.getPath('testWorkflowsRepo') || ''; - const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); - let act = new Act(repoPath, workflowPath); - act = utils.setUpActParams( - act, - 'pull_request', - {head: {ref: 'main'}}, - {OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook'}, - 'dummy_github_token', - ); - const testMockSteps = { - lint: mocks.LINT_JOB_MOCK_STEPS, - test: [ - { - name: 'Run test workflow', - mockWith: 'echo [MOCK] [TEST] Running test workflow\n' - + 'echo [MOCK] [TEST] Test workflow failed\n' - + 'exit 1', - }, - ], - confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, - chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS, - skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, - createNewVersion: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, - updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, - isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS, - newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS, - 'e2e-tests': mocks.E2E_TESTS_JOB_MOCK_STEPS, - }; - const result = await act - .runEvent('push', { - workflowFile: path.join(repoPath, '.github', 'workflows'), - mockSteps: testMockSteps, - }); - assertions.assertLintJobExecuted(result); - expect(result).toEqual(expect.arrayContaining( - [{ - name: 'Main Run test workflow', - status: 1, - output: '[MOCK] [TEST] Running test workflow\n' - + '[MOCK] [TEST] Test workflow failed', - }], - )); - assertions.assertIsExpensifyEmployeeJobExecuted(result); - expect(result).toEqual(expect.arrayContaining( - [ - { - name: 'Main Announce failed workflow in Slack', - status: 0, - output: '[MOCK] [CONFIRM_PASSING_BUILD] Announcing failed workflow in slack, SLACK_WEBHOOK=***', // no access to secrets - }, - { - name: 'Main Exit failed workflow', + test('test job failed - workflow exits', async () => { + const repoPath = mockGithub.repo.getPath('testWorkflowsRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); + let act = new Act(repoPath, workflowPath); + act = utils.setUpActParams( + act, + 'pull_request', + {head: {ref: 'main'}}, + {OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook'}, + 'dummy_github_token', + ); + const testMockSteps = { + lint: mocks.LINT_JOB_MOCK_STEPS, + test: [ + { + name: 'Run test workflow', + mockWith: 'echo [MOCK] [TEST] Running test workflow\n' + + 'echo [MOCK] [TEST] Test workflow failed\n' + + 'exit 1', + }, + ], + confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, + chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS, + skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, + createNewVersion: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, + updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, + isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, + newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, + 'e2e-tests': mocks.E2E_TESTS_JOB_MOCK_STEPS, + }; + const result = await act + .runEvent('push', { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + }); + assertions.assertLintJobExecuted(result); + expect(result).toEqual(expect.arrayContaining( + [{ + name: 'Main Run test workflow', status: 1, - output: '', - }, - ], - )); - assertions.assertE2ETestsJobExecuted(result, false); // Act does not support ubuntu-20.04-64core runner and omits the job - assertions.assertChooseDeployActionsJobExecuted(result, false); - assertions.assertSkipDeployJobExecuted(result, false); - assertions.assertCreateNewVersionJobExecuted(result, false); - assertions.assertUpdateStagingJobExecuted(result, false); - }, 60000); + output: '[MOCK] [TEST] Running test workflow\n' + + '[MOCK] [TEST] Test workflow failed', + }], + )); + assertions.assertIsExpensifyEmployeeJobExecuted(result); + expect(result).toEqual(expect.arrayContaining( + [ + { + name: 'Main Announce failed workflow in Slack', + status: 0, + output: '[MOCK] [CONFIRM_PASSING_BUILD] Announcing failed workflow in slack, SLACK_WEBHOOK=***', // no access to secrets + }, + { + name: 'Main Exit failed workflow', + status: 1, + output: '', + }, + ], + )); + assertions.assertE2ETestsJobExecuted(result, false); // Act does not support ubuntu-20.04-64core runner and omits the job + assertions.assertChooseDeployActionsJobExecuted(result, false); + assertions.assertSkipDeployJobExecuted(result, false); + assertions.assertCreateNewVersionJobExecuted(result, false); + assertions.assertUpdateStagingJobExecuted(result, false); + }, 60000); + + test('lint and test job succeed - workflow continues', async () => { + const repoPath = mockGithub.repo.getPath('testWorkflowsRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); + let act = new Act(repoPath, workflowPath); + act = utils.setUpActParams( + act, + 'pull_request', + {head: {ref: 'main'}}, + {OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook'}, + 'dummy_github_token', + ); + const testMockSteps = { + lint: mocks.LINT_JOB_MOCK_STEPS, + test: mocks.TEST_JOB_MOCK_STEPS, + confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, + chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS, + skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, + createNewVersion: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, + updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, + isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, + newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, + 'e2e-tests': mocks.E2E_TESTS_JOB_MOCK_STEPS, + }; + const result = await act + .runEvent('push', { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + }); + assertions.assertLintJobExecuted(result); + assertions.assertTestJobExecuted(result); + assertions.assertIsExpensifyEmployeeJobExecuted(result); + assertions.assertE2ETestsJobExecuted(result, false); // Act does not support ubuntu-20.04-64core runner and omits the job + assertions.assertChooseDeployActionsJobExecuted(result, false); + assertions.assertSkipDeployJobExecuted(result, false); + assertions.assertCreateNewVersionJobExecuted(result, false); + assertions.assertUpdateStagingJobExecuted(result, false); + }, 60000); + }); + + describe('new contributor welcome message', () => { + test('actor is OSBotify - no comment left', async () => { + const repoPath = mockGithub.repo.getPath('testWorkflowsRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); + let act = new Act(repoPath, workflowPath); + act = utils.setUpActParams( + act, + 'pull_request', + {head: {ref: 'main'}}, + {OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'OSBotify', SLACK_WEBHOOK: 'dummy_slack_webhook'}, + 'dummy_github_token', + ); + const testMockSteps = { + lint: mocks.LINT_JOB_MOCK_STEPS, + test: mocks.TEST_JOB_MOCK_STEPS, + confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, + chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS, + skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, + createNewVersion: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, + updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, + isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__FALSE, + newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__OSBOTIFY, + 'e2e-tests': mocks.E2E_TESTS_JOB_MOCK_STEPS, + }; + const result = await act + .runEvent('push', { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + }); + assertions.assertLintJobExecuted(result); + assertions.assertTestJobExecuted(result); + assertions.assertIsExpensifyEmployeeJobExecuted(result); + assertions.assertE2ETestsJobExecuted(result, false); // Act does not support ubuntu-20.04-64core runner and omits the job + assertions.assertChooseDeployActionsJobExecuted(result); + assertions.assertNewContributorWelcomeMessageJobExecuted(result, false); + }, 60000); + + test('actor is Expensify employee - no comment left', async () => { + const repoPath = mockGithub.repo.getPath('testWorkflowsRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); + let act = new Act(repoPath, workflowPath); + act = utils.setUpActParams( + act, + 'pull_request', + {head: {ref: 'main'}}, + {OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook'}, + 'dummy_github_token', + ); + const testMockSteps = { + lint: mocks.LINT_JOB_MOCK_STEPS, + test: mocks.TEST_JOB_MOCK_STEPS, + confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, + chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS, + skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, + createNewVersion: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, + updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, + isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, + newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, + 'e2e-tests': mocks.E2E_TESTS_JOB_MOCK_STEPS, + }; + const result = await act + .runEvent('push', { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + }); + assertions.assertLintJobExecuted(result); + assertions.assertTestJobExecuted(result); + assertions.assertIsExpensifyEmployeeJobExecuted(result); + assertions.assertE2ETestsJobExecuted(result, false); // Act does not support ubuntu-20.04-64core runner and omits the job + assertions.assertChooseDeployActionsJobExecuted(result); + assertions.assertNewContributorWelcomeMessageJobExecuted(result, false); + }, 60000); + + test('actor is not Expensify employee, its not their first PR - job triggers, but no comment left', async () => { + const repoPath = mockGithub.repo.getPath('testWorkflowsRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); + let act = new Act(repoPath, workflowPath); + act = utils.setUpActParams( + act, + 'pull_request', + {head: {ref: 'main'}}, + {OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook'}, + 'dummy_github_token', + ); + const testMockSteps = { + lint: mocks.LINT_JOB_MOCK_STEPS, + test: mocks.TEST_JOB_MOCK_STEPS, + confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, + chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS, + skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, + createNewVersion: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, + updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, + isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__FALSE, + newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, + 'e2e-tests': mocks.E2E_TESTS_JOB_MOCK_STEPS, + }; + const result = await act + .runEvent('push', { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + }); + assertions.assertLintJobExecuted(result); + assertions.assertTestJobExecuted(result); + assertions.assertIsExpensifyEmployeeJobExecuted(result); + assertions.assertE2ETestsJobExecuted(result, false); // Act does not support ubuntu-20.04-64core runner and omits the job + assertions.assertChooseDeployActionsJobExecuted(result); + assertions.assertNewContributorWelcomeMessageJobExecuted(result, true, false, false); + }, 60000); + + test('actor is not Expensify employee, and its their first PR - job triggers and comment left', async () => { + const repoPath = mockGithub.repo.getPath('testWorkflowsRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); + let act = new Act(repoPath, workflowPath); + act = utils.setUpActParams( + act, + 'pull_request', + {head: {ref: 'main'}}, + {OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook'}, + 'dummy_github_token', + ); + const testMockSteps = { + lint: mocks.LINT_JOB_MOCK_STEPS, + test: mocks.TEST_JOB_MOCK_STEPS, + confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, + chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS, + skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, + createNewVersion: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, + updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, + isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__FALSE, + newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__ONE_PR, + 'e2e-tests': mocks.E2E_TESTS_JOB_MOCK_STEPS, + }; + const result = await act + .runEvent('push', { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + }); + assertions.assertLintJobExecuted(result); + assertions.assertTestJobExecuted(result); + assertions.assertIsExpensifyEmployeeJobExecuted(result); + assertions.assertE2ETestsJobExecuted(result, false); // Act does not support ubuntu-20.04-64core runner and omits the job + assertions.assertChooseDeployActionsJobExecuted(result); + assertions.assertNewContributorWelcomeMessageJobExecuted(result, true, false, true); + }, 60000); + }); }); From 11854201a2adebc63609ac75245de3779b5486f1 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Fri, 24 Feb 2023 12:03:21 +0100 Subject: [PATCH 012/504] Migrate from .ts to .js [WiP] Changed all typescript code into javascript code and removed ts-related dependencies See: https://github.com/Expensify/App/issues/13604 --- package.json | 4 -- ...oyAssertions.ts => preDeployAssertions.js} | 30 +++++++++---- workflow_tests/jest.config.js | 8 ++++ workflow_tests/jest.config.ts | 13 ------ .../{preDeployMocks.ts => preDeployMocks.js} | 42 +++++++++++++------ .../{preDeploy.test.ts => preDeploy.test.js} | 32 +++++++------- workflow_tests/{utils.ts => utils.js} | 7 ++-- 7 files changed, 78 insertions(+), 58 deletions(-) rename workflow_tests/assertions/{preDeployAssertions.ts => preDeployAssertions.js} (92%) create mode 100644 workflow_tests/jest.config.js delete mode 100644 workflow_tests/jest.config.ts rename workflow_tests/mocks/{preDeployMocks.ts => preDeployMocks.js} (91%) rename workflow_tests/{preDeploy.test.ts => preDeploy.test.js} (96%) rename workflow_tests/{utils.ts => utils.js} (73%) diff --git a/package.json b/package.json index e00d92c9bb83..79311ea03989 100644 --- a/package.json +++ b/package.json @@ -140,10 +140,6 @@ "save": "^2.4.0", "semver": "^7.3.8", "shim-keyboard-event-key": "^1.0.3", - "ts-jest": "^29.0.5", - "ts-node": "^10.9.1", - "tsc": "^2.0.4", - "typescript": "^4.9.5", "underscore": "^1.13.1", "urbanairship-react-native": "^14.6.1" }, diff --git a/workflow_tests/assertions/preDeployAssertions.ts b/workflow_tests/assertions/preDeployAssertions.js similarity index 92% rename from workflow_tests/assertions/preDeployAssertions.ts rename to workflow_tests/assertions/preDeployAssertions.js index 0dc493f3d0f6..cbbe56c6d0af 100644 --- a/workflow_tests/assertions/preDeployAssertions.ts +++ b/workflow_tests/assertions/preDeployAssertions.js @@ -1,4 +1,4 @@ -export const assertLintJobExecuted = (workflowResult: Array, didExecute: Boolean = true) => { +const assertLintJobExecuted = (workflowResult, didExecute = true) => { const steps = [{ name: 'Main Run lint workflow', status: 0, @@ -11,7 +11,7 @@ export const assertLintJobExecuted = (workflowResult: Array, didExecute: } }; -export const assertTestJobExecuted = (workflowResult: Array, didExecute: Boolean = true) => { +const assertTestJobExecuted = (workflowResult, didExecute = true) => { const steps = [{ name: 'Main Run test workflow', status: 0, @@ -24,7 +24,7 @@ export const assertTestJobExecuted = (workflowResult: Array, didExecute: } }; -export const assertIsExpensifyEmployeeJobExecuted = (workflowResult: Array, didExecute: Boolean = true) => { +const assertIsExpensifyEmployeeJobExecuted = (workflowResult, didExecute = true) => { const steps = [{ name: 'Main Get merged pull request', status: 0, @@ -42,7 +42,7 @@ export const assertIsExpensifyEmployeeJobExecuted = (workflowResult: Array, didExecute: Boolean = true, isOsBotify: Boolean = false, isFirstPr: Boolean = false) => { +const assertNewContributorWelcomeMessageJobExecuted = (workflowResult, didExecute = true, isOsBotify = false, isFirstPr = false) => { const steps = [ { name: 'Main Checkout', @@ -76,7 +76,7 @@ export const assertNewContributorWelcomeMessageJobExecuted = (workflowResult: Ar } }; -export const assertE2ETestsJobExecuted = (workflowResult: Array, didExecute: Boolean = true) => { +const assertE2ETestsJobExecuted = (workflowResult, didExecute = true) => { const steps = [ { name: 'Main Checkout', @@ -206,7 +206,7 @@ export const assertE2ETestsJobExecuted = (workflowResult: Array, didExec } }; -export const assertChooseDeployActionsJobExecuted = (workflowResult: Array, didExecute: Boolean = true) => { +const assertChooseDeployActionsJobExecuted = (workflowResult, didExecute = true) => { const steps = [ { name: 'Main Get merged pull request', @@ -242,7 +242,7 @@ export const assertChooseDeployActionsJobExecuted = (workflowResult: Array, didExecute: Boolean = true) => { +const assertSkipDeployJobExecuted = (workflowResult, didExecute = true) => { const steps = [ { name: 'Main Comment on deferred PR', @@ -257,7 +257,7 @@ export const assertSkipDeployJobExecuted = (workflowResult: Array, didEx } }; -export const assertCreateNewVersionJobExecuted = (workflowResult: Array, didExecute: Boolean = true) => { +const assertCreateNewVersionJobExecuted = (workflowResult, didExecute = true) => { const steps = [ { name: 'Main Create new version', @@ -272,7 +272,7 @@ export const assertCreateNewVersionJobExecuted = (workflowResult: Array, } }; -export const assertUpdateStagingJobExecuted = (workflowResult: Array, didExecute: Boolean = true) => { +const assertUpdateStagingJobExecuted = (workflowResult, didExecute = true) => { const steps = [ { name: 'Main Run turnstyle', @@ -326,3 +326,15 @@ export const assertUpdateStagingJobExecuted = (workflowResult: Array, di expect(workflowResult).not.toEqual(steps); } }; + +module.exports = { + assertLintJobExecuted, + assertTestJobExecuted, + assertIsExpensifyEmployeeJobExecuted, + assertNewContributorWelcomeMessageJobExecuted, + assertE2ETestsJobExecuted, + assertChooseDeployActionsJobExecuted, + assertSkipDeployJobExecuted, + assertCreateNewVersionJobExecuted, + assertUpdateStagingJobExecuted, +}; diff --git a/workflow_tests/jest.config.js b/workflow_tests/jest.config.js new file mode 100644 index 000000000000..c8a4534764e3 --- /dev/null +++ b/workflow_tests/jest.config.js @@ -0,0 +1,8 @@ +module.exports = { + verbose: true, + transform: { + '^.+\\.jsx?$': 'babel-jest', + }, + clearMocks: true, + resetMocks: true, +}; diff --git a/workflow_tests/jest.config.ts b/workflow_tests/jest.config.ts deleted file mode 100644 index 28e88dfce53d..000000000000 --- a/workflow_tests/jest.config.ts +++ /dev/null @@ -1,13 +0,0 @@ -import type {Config} from '@jest/types'; - -// Sync object -const jestConfig: Config.InitialOptions = { - verbose: true, - transform: { - '^.+\\.tsx?$': 'ts-jest', - }, - clearMocks: true, - resetMocks: true, -}; - -export default jestConfig; diff --git a/workflow_tests/mocks/preDeployMocks.ts b/workflow_tests/mocks/preDeployMocks.js similarity index 91% rename from workflow_tests/mocks/preDeployMocks.ts rename to workflow_tests/mocks/preDeployMocks.js index 045409627f3f..e63a6d60c5b1 100644 --- a/workflow_tests/mocks/preDeployMocks.ts +++ b/workflow_tests/mocks/preDeployMocks.js @@ -3,7 +3,7 @@ const LINT_WORKFLOW_MOCK_STEP = { name: 'Run lint workflow', mockWith: 'echo [MOCK] [LINT] Running lint workflow', }; -export const LINT_JOB_MOCK_STEPS = [ +const LINT_JOB_MOCK_STEPS = [ LINT_WORKFLOW_MOCK_STEP, ]; @@ -12,7 +12,7 @@ const TEST_WORKFLOW_MOCK_STEP = { name: 'Run test workflow', mockWith: 'echo [MOCK] [TEST] Running test workflow', }; -export const TEST_JOB_MOCK_STEPS = [ +const TEST_JOB_MOCK_STEPS = [ TEST_WORKFLOW_MOCK_STEP, ]; @@ -21,7 +21,7 @@ const ANNOUNCE_IN_SLACK_MOCK_STEP = { name: 'Announce failed workflow in Slack', mockWith: 'echo [MOCK] [CONFIRM_PASSING_BUILD] Announcing failed workflow in slack, SLACK_WEBHOOK=${{ inputs.SLACK_WEBHOOK }}', }; -export const CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS = [ +const CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS = [ ANNOUNCE_IN_SLACK_MOCK_STEP, // 2nd step runs normally @@ -40,7 +40,7 @@ const CHECK_IF_STAGINGDEPLOYCASH_IS_LOCKED_MOCK_STEP = { mockWith: 'echo [MOCK] [CHOOSE_DEPLOY_ACTIONS] Checking StagingDeployCash, GITHUB_TOKEN=${{ inputs.GITHUB_TOKEN }}\n' + 'echo "IS_LOCKED=true" >> "$GITHUB_OUTPUT"', }; -export const CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS = [ +const CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS = [ GET_MERGED_PULL_REQUEST_MOCK_STEP__CHOOSE_DEPLOY, CHECK_IF_STAGINGDEPLOYCASH_IS_LOCKED_MOCK_STEP, @@ -52,7 +52,7 @@ const COMMENT_ON_DEFERRED_PR_MOCK_STEP = { name: 'Comment on deferred PR', mockWith: 'echo [MOCK] [SKIP_DEPLOY] Skipping deploy, GITHUB_TOKEN=${{ inputs.github_token }}, NUMBER=${{ inputs.number }}, BODY=${{ inputs.body }}', }; -export const SKIP_DEPLOY_JOB_MOCK_STEPS = [ +const SKIP_DEPLOY_JOB_MOCK_STEPS = [ COMMENT_ON_DEFERRED_PR_MOCK_STEP, ]; @@ -61,7 +61,7 @@ const CREATE_NEW_VERSION_MOCK_STEP = { name: 'Create new version', mockWith: 'echo [MOCK] [CREATE_NEW_VERSION] Creating new version', }; -export const CREATE_NEW_VERSION_JOB_MOCK_STEPS = [ +const CREATE_NEW_VERSION_JOB_MOCK_STEPS = [ CREATE_NEW_VERSION_MOCK_STEP, ]; @@ -111,7 +111,7 @@ const ANNOUNCE_FAILED_WORKFLOW_IN_SLACK_MOCK_STEP = { name: 'Announce failed workflow in Slack', mockWith: 'echo [MOCK] [UPDATE_STAGING] Announcing failed workflow in slack', }; -export const UPDATE_STAGING_JOB_MOCK_STEPS = [ +const UPDATE_STAGING_JOB_MOCK_STEPS = [ RUN_TURNSTYLE_MOCK_STEP, UPDATE_STAGING_BRANCH_MOCK_STEP, CHERRYPICK_PR_MOCK_STEP, @@ -136,7 +136,7 @@ const CHECK_TEAM_MEMBERSHIP_MOCK_STEP__TRUE = { mockWith: 'echo [MOCK] [IS_EXPENSIFY_EMPLOYEE] Checking actors Expensify membership, GITHUB_TOKEN=${{ inputs.GITHUB_TOKEN }}, USERNAME=${{ inputs.username }}, TEAM=${{ inputs.team }}\n' + 'echo "isTeamMember=true" >> "$GITHUB_OUTPUT"', }; -export const IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE = [ +const IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE = [ GET_MERGED_PULL_REQUEST_MOCK_STEP__IS_EXPENSIFY_EMPLOYEE, CHECK_TEAM_MEMBERSHIP_MOCK_STEP__TRUE, ]; @@ -145,7 +145,7 @@ const CHECK_TEAM_MEMBERSHIP_MOCK_STEP__FALSE = { mockWith: 'echo [MOCK] [IS_EXPENSIFY_EMPLOYEE] Checking actors Expensify membership, GITHUB_TOKEN=${{ inputs.GITHUB_TOKEN }}, USERNAME=${{ inputs.username }}, TEAM=${{ inputs.team }}\n' + 'echo "isTeamMember=false" >> "$GITHUB_OUTPUT"', }; -export const IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__FALSE = [ +const IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__FALSE = [ GET_MERGED_PULL_REQUEST_MOCK_STEP__IS_EXPENSIFY_EMPLOYEE, CHECK_TEAM_MEMBERSHIP_MOCK_STEP__FALSE, ]; @@ -187,19 +187,19 @@ const COMMENT_ON_FIRST_PULL_REQUEST_MOCK_STEP = { name: 'Comment on ${{ steps.getMergedPullRequest.outputs.author }}\\\'s first pull request!', mockWith: 'echo [MOCK] [NEW_CONTRIBUTOR_WELCOME_MESSAGE] Creating comment, GITHUB_TOKEN=${{ inputs.github_token }}, NUMBER=${{ inputs.number }}, BODY="${{ inputs.body }}"', }; -export const NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS = [ +const NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS = [ CHECKOUT_MOCK_STEP, GET_MERGED_PULL_REQUEST_MOCK_STEP__WELCOME_MESSAGE, GET_PR_COUNT_MOCK_STEP__10, COMMENT_ON_FIRST_PULL_REQUEST_MOCK_STEP, ]; -export const NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__ONE_PR = [ +const NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__ONE_PR = [ CHECKOUT_MOCK_STEP, GET_MERGED_PULL_REQUEST_MOCK_STEP__WELCOME_MESSAGE, GET_PR_COUNT_MOCK_STEP__1, COMMENT_ON_FIRST_PULL_REQUEST_MOCK_STEP, ]; -export const NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__OSBOTIFY = [ +const NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__OSBOTIFY = [ CHECKOUT_MOCK_STEP__OSBOTIFY, GET_MERGED_PULL_REQUEST_MOCK_STEP__WELCOME_MESSAGE__OSBOTIFY, GET_PR_COUNT_MOCK_STEP__10, @@ -300,7 +300,7 @@ const CHECK_IF_TESTS_FAILED_MOCK_STEP = { name: 'Check if test failed, if so leave a deploy blocker label', mockWith: 'echo [MOCK] [E2E_TESTS] Checking if tests failed', }; -export const E2E_TESTS_JOB_MOCK_STEPS = [ +const E2E_TESTS_JOB_MOCK_STEPS = [ CHECKOUT_MOCK_STEP__E2E_TESTS, SETUP_NODE_MOCK_STEP, SETUP_RUBY_MOCK_STEP, @@ -326,3 +326,19 @@ export const E2E_TESTS_JOB_MOCK_STEPS = [ LEAVE_COMMENT_WITH_AWS_DEVICE_FARM_OUTPUT_MOCK_STEP, CHECK_IF_TESTS_FAILED_MOCK_STEP, ]; + +module.exports = { + LINT_JOB_MOCK_STEPS, + TEST_JOB_MOCK_STEPS, + CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, + CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS, + SKIP_DEPLOY_JOB_MOCK_STEPS, + CREATE_NEW_VERSION_JOB_MOCK_STEPS, + UPDATE_STAGING_JOB_MOCK_STEPS, + IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, + IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__FALSE, + 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, +}; diff --git a/workflow_tests/preDeploy.test.ts b/workflow_tests/preDeploy.test.js similarity index 96% rename from workflow_tests/preDeploy.test.ts rename to workflow_tests/preDeploy.test.js index 3f01c3e30e86..97bb31004804 100644 --- a/workflow_tests/preDeploy.test.ts +++ b/workflow_tests/preDeploy.test.js @@ -1,11 +1,11 @@ -import {MockGithub} from '@kie/mock-github'; -import {Act} from '@kie/act-js'; -import path from 'path'; -import * as mocks from './mocks/preDeployMocks'; -import * as assertions from './assertions/preDeployAssertions'; -import * as utils from './utils'; +const path = require('path'); +const kieActJs = require('@kie/act-js'); +const kieMockGithub = require('@kie/mock-github'); +const utils = require('./utils'); +const assertions = require('./assertions/preDeployAssertions'); +const mocks = require('./mocks/preDeployMocks'); -let mockGithub: MockGithub; +let mockGithub; const FILES_TO_COPY_INTO_TEST_REPO = [ { src: path.resolve(__dirname, '..', '.github', 'actions'), @@ -35,7 +35,7 @@ const FILES_TO_COPY_INTO_TEST_REPO = [ beforeEach(async () => { // create a local repository and copy required files - mockGithub = new MockGithub({ + mockGithub = new kieMockGithub.MockGithub({ repo: { testWorkflowsRepo: { files: FILES_TO_COPY_INTO_TEST_REPO, @@ -59,7 +59,7 @@ describe('test workflow preDeploy', () => { const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); // instantiate Act in the context of the test repo and given workflow file - let act = new Act(repoPath, workflowPath); + let act = new kieActJs.Act(repoPath, workflowPath); // set run parameters act = utils.setUpActParams( @@ -107,7 +107,7 @@ describe('test workflow preDeploy', () => { test('lint job failed - workflow exits', async () => { const repoPath = mockGithub.repo.getPath('testWorkflowsRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); - let act = new Act(repoPath, workflowPath); + let act = new kieActJs.Act(repoPath, workflowPath); act = utils.setUpActParams( act, 'pull_request', @@ -173,7 +173,7 @@ describe('test workflow preDeploy', () => { test('test job failed - workflow exits', async () => { const repoPath = mockGithub.repo.getPath('testWorkflowsRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); - let act = new Act(repoPath, workflowPath); + let act = new kieActJs.Act(repoPath, workflowPath); act = utils.setUpActParams( act, 'pull_request', @@ -239,7 +239,7 @@ describe('test workflow preDeploy', () => { test('lint and test job succeed - workflow continues', async () => { const repoPath = mockGithub.repo.getPath('testWorkflowsRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); - let act = new Act(repoPath, workflowPath); + let act = new kieActJs.Act(repoPath, workflowPath); act = utils.setUpActParams( act, 'pull_request', @@ -279,7 +279,7 @@ describe('test workflow preDeploy', () => { test('actor is OSBotify - no comment left', async () => { const repoPath = mockGithub.repo.getPath('testWorkflowsRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); - let act = new Act(repoPath, workflowPath); + let act = new kieActJs.Act(repoPath, workflowPath); act = utils.setUpActParams( act, 'pull_request', @@ -315,7 +315,7 @@ describe('test workflow preDeploy', () => { test('actor is Expensify employee - no comment left', async () => { const repoPath = mockGithub.repo.getPath('testWorkflowsRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); - let act = new Act(repoPath, workflowPath); + let act = new kieActJs.Act(repoPath, workflowPath); act = utils.setUpActParams( act, 'pull_request', @@ -351,7 +351,7 @@ describe('test workflow preDeploy', () => { test('actor is not Expensify employee, its not their first PR - job triggers, but no comment left', async () => { const repoPath = mockGithub.repo.getPath('testWorkflowsRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); - let act = new Act(repoPath, workflowPath); + let act = new kieActJs.Act(repoPath, workflowPath); act = utils.setUpActParams( act, 'pull_request', @@ -387,7 +387,7 @@ describe('test workflow preDeploy', () => { test('actor is not Expensify employee, and its their first PR - job triggers and comment left', async () => { const repoPath = mockGithub.repo.getPath('testWorkflowsRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); - let act = new Act(repoPath, workflowPath); + let act = new kieActJs.Act(repoPath, workflowPath); act = utils.setUpActParams( act, 'pull_request', diff --git a/workflow_tests/utils.ts b/workflow_tests/utils.js similarity index 73% rename from workflow_tests/utils.ts rename to workflow_tests/utils.js index a76ce55a63d8..e0c33dc7ad13 100644 --- a/workflow_tests/utils.ts +++ b/workflow_tests/utils.js @@ -1,6 +1,6 @@ -import {Act} from '@kie/act-js'; - -export const setUpActParams = (act: Act, event?: string, event_options?: any, secrets?: Object, github_token?: string) => { +module.exports = { + setUpActParams: +(act, event = null, event_options = null, secrets = null, github_token = null) => { let updated_act = act; if (event && event_options) { @@ -20,4 +20,5 @@ export const setUpActParams = (act: Act, event?: string, event_options?: any, se } return updated_act; +}, }; From 65353d7cada2d4b898c6236adde8ea8899237229 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Fri, 24 Feb 2023 13:24:13 +0100 Subject: [PATCH 013/504] Add method for getting mock steps [WiP] Added a helper method to utils, that helps with creating step mocks - easier than mocking them by hand, allows reusability and reduces the chance of a typo sneaking in See: https://github.com/Expensify/App/issues/13604 --- .../assertions/preDeployAssertions.js | 16 +- workflow_tests/mocks/preDeployMocks.js | 520 ++++++++++-------- workflow_tests/utils.js | 43 +- 3 files changed, 347 insertions(+), 232 deletions(-) diff --git a/workflow_tests/assertions/preDeployAssertions.js b/workflow_tests/assertions/preDeployAssertions.js index cbbe56c6d0af..1ada8e1a5eca 100644 --- a/workflow_tests/assertions/preDeployAssertions.js +++ b/workflow_tests/assertions/preDeployAssertions.js @@ -28,12 +28,12 @@ const assertIsExpensifyEmployeeJobExecuted = (workflowResult, didExecute = true) const steps = [{ name: 'Main Get merged pull request', status: 0, - output: '[MOCK] [IS_EXPENSIFY_EMPLOYEE] Getting merged pull request, GITHUB_TOKEN=***', + output: '[MOCK] [IS_EXPENSIFY_EMPLOYEE] Getting merged pull request, github_token=***', }, { name: 'Main Check whether the actor is member of Expensify/expensify team', status: 0, - output: '[MOCK] [IS_EXPENSIFY_EMPLOYEE] Checking actors Expensify membership, GITHUB_TOKEN=***, USERNAME=Dummy Author, TEAM=Expensify/expensify', + output: '[MOCK] [IS_EXPENSIFY_EMPLOYEE] Checking actors Expensify membership, GITHUB_TOKEN=***, username=Dummy Author, team=Expensify/expensify', }]; if (didExecute) { expect(workflowResult).toEqual(expect.arrayContaining(steps)); @@ -47,12 +47,12 @@ const assertNewContributorWelcomeMessageJobExecuted = (workflowResult, didExecut { name: 'Main Checkout', status: 0, - output: '[MOCK] [NEW_CONTRIBUTOR_WELCOME_MESSAGE] Checking out, TOKEN=***', + output: '[MOCK] [NEW_CONTRIBUTOR_WELCOME_MESSAGE] Checking out, token=***', }, { name: 'Main Get merged pull request', status: 0, - output: '[MOCK] [NEW_CONTRIBUTOR_WELCOME_MESSAGE] Getting merged pull request, GITHUB_TOKEN=***', + output: '[MOCK] [NEW_CONTRIBUTOR_WELCOME_MESSAGE] Getting merged pull request, github_token=***', }, { name: isOsBotify ? 'Main Get PR count for OSBotify' : 'Main Get PR count for Dummy Author', @@ -65,7 +65,7 @@ const assertNewContributorWelcomeMessageJobExecuted = (workflowResult, didExecut { name: isOsBotify ? 'Main Comment on OSBotify\\\'s first pull request!' : 'Main Comment on Dummy Author\\\'s first pull request!', status: 0, - output: isOsBotify ? '[MOCK] [NEW_CONTRIBUTOR_WELCOME_MESSAGE] Creating comment, GITHUB_TOKEN=***, NUMBER=12345, BODY=@OSBotify, Great job getting your first Expensify/App pull request over the finish line! :tada:\n\nI know there\'s a lot of information in our [contributing guidelines](https://github.com/Expensify/App/blob/main/contributingGuides/CONTRIBUTING.md), so here are some points to take note of :memo::\n\n1. Now that your first PR has been merged, you can be hired for another issue. Once you\'ve completed a few issues, you may be eligible to work on more than one job at a time.\n2. Once your PR is deployed to our staging servers, it will undergo quality assurance (QA) testing. If we find that it doesn\'t work as expected or causes a regression, you\'ll be responsible for fixing it. Typically, we would revert this PR and give you another chance to create a similar PR without causing a regression.\n3. Once your PR is deployed to _production_, we start a 7-day timer :alarm_clock:. After it has been on production for 7 days without causing any regressions, then we pay out the Upwork job. :moneybag:\n\nSo it might take a while before you\'re paid for your work, but we typically post multiple new jobs every day, so there\'s plenty of opportunity. I hope you\'ve had a positive experience contributing to this repo! :blush:' : '[MOCK] [NEW_CONTRIBUTOR_WELCOME_MESSAGE] Creating comment, GITHUB_TOKEN=***, NUMBER=12345, BODY=@Dummy Author, Great job getting your first Expensify/App pull request over the finish line! :tada:\n\nI know there\'s a lot of information in our [contributing guidelines](https://github.com/Expensify/App/blob/main/contributingGuides/CONTRIBUTING.md), so here are some points to take note of :memo::\n\n1. Now that your first PR has been merged, you can be hired for another issue. Once you\'ve completed a few issues, you may be eligible to work on more than one job at a time.\n2. Once your PR is deployed to our staging servers, it will undergo quality assurance (QA) testing. If we find that it doesn\'t work as expected or causes a regression, you\'ll be responsible for fixing it. Typically, we would revert this PR and give you another chance to create a similar PR without causing a regression.\n3. Once your PR is deployed to _production_, we start a 7-day timer :alarm_clock:. After it has been on production for 7 days without causing any regressions, then we pay out the Upwork job. :moneybag:\n\nSo it might take a while before you\'re paid for your work, but we typically post multiple new jobs every day, so there\'s plenty of opportunity. I hope you\'ve had a positive experience contributing to this repo! :blush:', + output: isOsBotify ? '[MOCK] [NEW_CONTRIBUTOR_WELCOME_MESSAGE] Creating comment, github_token=***, number=12345, body=@OSBotify, Great job getting your first Expensify/App pull request over the finish line! :tada:\n\nI know there\'s a lot of information in our [contributing guidelines](https://github.com/Expensify/App/blob/main/contributingGuides/CONTRIBUTING.md), so here are some points to take note of :memo::\n\n1. Now that your first PR has been merged, you can be hired for another issue. Once you\'ve completed a few issues, you may be eligible to work on more than one job at a time.\n2. Once your PR is deployed to our staging servers, it will undergo quality assurance (QA) testing. If we find that it doesn\'t work as expected or causes a regression, you\'ll be responsible for fixing it. Typically, we would revert this PR and give you another chance to create a similar PR without causing a regression.\n3. Once your PR is deployed to _production_, we start a 7-day timer :alarm_clock:. After it has been on production for 7 days without causing any regressions, then we pay out the Upwork job. :moneybag:\n\nSo it might take a while before you\'re paid for your work, but we typically post multiple new jobs every day, so there\'s plenty of opportunity. I hope you\'ve had a positive experience contributing to this repo! :blush:' : '[MOCK] [NEW_CONTRIBUTOR_WELCOME_MESSAGE] Creating comment, github_token=***, number=12345, body=@Dummy Author, Great job getting your first Expensify/App pull request over the finish line! :tada:\n\nI know there\'s a lot of information in our [contributing guidelines](https://github.com/Expensify/App/blob/main/contributingGuides/CONTRIBUTING.md), so here are some points to take note of :memo::\n\n1. Now that your first PR has been merged, you can be hired for another issue. Once you\'ve completed a few issues, you may be eligible to work on more than one job at a time.\n2. Once your PR is deployed to our staging servers, it will undergo quality assurance (QA) testing. If we find that it doesn\'t work as expected or causes a regression, you\'ll be responsible for fixing it. Typically, we would revert this PR and give you another chance to create a similar PR without causing a regression.\n3. Once your PR is deployed to _production_, we start a 7-day timer :alarm_clock:. After it has been on production for 7 days without causing any regressions, then we pay out the Upwork job. :moneybag:\n\nSo it might take a while before you\'re paid for your work, but we typically post multiple new jobs every day, so there\'s plenty of opportunity. I hope you\'ve had a positive experience contributing to this repo! :blush:', }, ); } @@ -211,7 +211,7 @@ const assertChooseDeployActionsJobExecuted = (workflowResult, didExecute = true) { name: 'Main Get merged pull request', status: 0, - output: '[MOCK] [CHOOSE_DEPLOY_ACTIONS] Getting merged pull request, GITHUB_TOKEN=***', // no access to secrets + output: '[MOCK] [CHOOSE_DEPLOY_ACTIONS] Getting merged pull request, github_token=***', // no access to secrets }, { name: 'Main Check if StagingDeployCash is locked', @@ -247,7 +247,7 @@ const assertSkipDeployJobExecuted = (workflowResult, didExecute = true) => { { name: 'Main Comment on deferred PR', status: 0, - output: '[MOCK] [SKIP_DEPLOY] Skipping deploy, GITHUB_TOKEN=***, NUMBER=123, BODY=:hand: This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.', + output: '[MOCK] [SKIP_DEPLOY] Skipping deploy, github_token=***, number=123, body=:hand: This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.', }, ]; if (didExecute) { @@ -277,7 +277,7 @@ const assertUpdateStagingJobExecuted = (workflowResult, didExecute = true) => { { name: 'Main Run turnstyle', status: 0, - output: '[MOCK] [UPDATE_STAGING] Running turnstyle, POLL_INTERVAL_SECONDS=10, GITHUB_TOKEN=***', + output: '[MOCK] [UPDATE_STAGING] Running turnstyle, poll-interval-seconds=10, GITHUB_TOKEN=***', }, { name: 'Main Cherry-pick PR to staging', diff --git a/workflow_tests/mocks/preDeployMocks.js b/workflow_tests/mocks/preDeployMocks.js index e63a6d60c5b1..f96f190fd42f 100644 --- a/workflow_tests/mocks/preDeployMocks.js +++ b/workflow_tests/mocks/preDeployMocks.js @@ -1,26 +1,32 @@ +const utils = require('../utils'); + // lint -const LINT_WORKFLOW_MOCK_STEP = { - name: 'Run lint workflow', - mockWith: 'echo [MOCK] [LINT] Running lint workflow', -}; +const LINT_WORKFLOW_MOCK_STEP = utils.getMockStep( + 'Run lint workflow', + 'Running lint workflow', + 'LINT', +); const LINT_JOB_MOCK_STEPS = [ LINT_WORKFLOW_MOCK_STEP, ]; // test -const TEST_WORKFLOW_MOCK_STEP = { - name: 'Run test workflow', - mockWith: 'echo [MOCK] [TEST] Running test workflow', -}; +const TEST_WORKFLOW_MOCK_STEP = utils.getMockStep( + 'Run test workflow', + 'Running test workflow', + 'TEST', +); const TEST_JOB_MOCK_STEPS = [ TEST_WORKFLOW_MOCK_STEP, ]; // confirm_passing_build -const ANNOUNCE_IN_SLACK_MOCK_STEP = { - name: 'Announce failed workflow in Slack', - mockWith: 'echo [MOCK] [CONFIRM_PASSING_BUILD] Announcing failed workflow in slack, SLACK_WEBHOOK=${{ inputs.SLACK_WEBHOOK }}', -}; +const ANNOUNCE_IN_SLACK_MOCK_STEP = utils.getMockStep( + 'Announce failed workflow in Slack', + 'Announcing failed workflow in slack', + 'CONFIRM_PASSING_BUILD', + ['SLACK_WEBHOOK'], +); const CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS = [ ANNOUNCE_IN_SLACK_MOCK_STEP, @@ -28,18 +34,22 @@ const CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS = [ ]; // choose_deploy_actions -const GET_MERGED_PULL_REQUEST_MOCK_STEP__CHOOSE_DEPLOY = { - name: 'Get merged pull request', - mockWith: 'echo [MOCK] [CHOOSE_DEPLOY_ACTIONS] Getting merged pull request, GITHUB_TOKEN=${{ inputs.github_token }}\n' - + 'echo "number=123" >> "$GITHUB_OUTPUT"\n' - + 'echo "labels=[\'CP Staging\']" >> "$GITHUB_OUTPUT"\n', -}; - -const CHECK_IF_STAGINGDEPLOYCASH_IS_LOCKED_MOCK_STEP = { - name: 'Check if StagingDeployCash is locked', - mockWith: 'echo [MOCK] [CHOOSE_DEPLOY_ACTIONS] Checking StagingDeployCash, GITHUB_TOKEN=${{ inputs.GITHUB_TOKEN }}\n' - + 'echo "IS_LOCKED=true" >> "$GITHUB_OUTPUT"', -}; +const GET_MERGED_PULL_REQUEST_MOCK_STEP__CHOOSE_DEPLOY = utils.getMockStep( + 'Get merged pull request', + 'Getting merged pull request', + 'CHOOSE_DEPLOY_ACTIONS', + ['github_token'], + null, + {number: '123', labels: '[\'CP Staging\']'}, +); +const CHECK_IF_STAGINGDEPLOYCASH_IS_LOCKED_MOCK_STEP = utils.getMockStep( + 'Check if StagingDeployCash is locked', + 'Checking StagingDeployCash', + 'CHOOSE_DEPLOY_ACTIONS', + ['GITHUB_TOKEN'], + null, + {IS_LOCKED: 'true'}, +); const CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS = [ GET_MERGED_PULL_REQUEST_MOCK_STEP__CHOOSE_DEPLOY, CHECK_IF_STAGINGDEPLOYCASH_IS_LOCKED_MOCK_STEP, @@ -48,69 +58,87 @@ const CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS = [ ]; // skip_deploy -const COMMENT_ON_DEFERRED_PR_MOCK_STEP = { - name: 'Comment on deferred PR', - mockWith: 'echo [MOCK] [SKIP_DEPLOY] Skipping deploy, GITHUB_TOKEN=${{ inputs.github_token }}, NUMBER=${{ inputs.number }}, BODY=${{ inputs.body }}', -}; +const COMMENT_ON_DEFERRED_PR_MOCK_STEP = utils.getMockStep( + 'Comment on deferred PR', + 'Skipping deploy', + 'SKIP_DEPLOY', + ['github_token', 'number', 'body'], +); const SKIP_DEPLOY_JOB_MOCK_STEPS = [ COMMENT_ON_DEFERRED_PR_MOCK_STEP, ]; // create_new_version -const CREATE_NEW_VERSION_MOCK_STEP = { - name: 'Create new version', - mockWith: 'echo [MOCK] [CREATE_NEW_VERSION] Creating new version', -}; +const CREATE_NEW_VERSION_MOCK_STEP = utils.getMockStep( + 'Create new version', + 'Creating new version', + 'CREATE_NEW_VERSION', +); const CREATE_NEW_VERSION_JOB_MOCK_STEPS = [ CREATE_NEW_VERSION_MOCK_STEP, ]; // update_staging -const RUN_TURNSTYLE_MOCK_STEP = { - name: 'Run turnstyle', - mockWith: 'echo [MOCK] [UPDATE_STAGING] Running turnstyle, POLL_INTERVAL_SECONDS=${{ inputs.poll-interval-seconds }}, GITHUB_TOKEN=${{ env.GITHUB_TOKEN }}', -}; -const UPDATE_STAGING_BRANCH_MOCK_STEP = { - name: 'Update staging branch from main', - mockWith: 'echo [MOCK] [UPDATE_STAGING] Updating staging branch', -}; -const CHERRYPICK_PR_MOCK_STEP = { - name: 'Cherry-pick PR to staging', - mockWith: 'echo [MOCK] [UPDATE_STAGING] Cherry picking', -}; -const CHECKOUT_STAGING_MOCK_STEP = { - name: 'Checkout staging', - mockWith: 'echo [MOCK] [UPDATE_STAGING] Checking out staging', -}; -const TAG_STAGING_MOCK_STEP = { - name: 'Tag staging', - mockWith: 'echo [MOCK] [UPDATE_STAGING] Tagging staging', -}; -const UPDATE_STAGINGDEPLOYCASH_MOCK_STEP = { - name: 'Update StagingDeployCash', - mockWith: 'echo [MOCK] [UPDATE_STAGING] Updating StagingDeployCash', -}; -const FIND_OPEN_STAGINGDEPLOYCASH_MOCK_STEP = { - name: 'Find open StagingDeployCash', - mockWith: 'echo [MOCK] [UPDATE_STAGING] Finding open StagingDeployCash\n' - + 'echo "STAGING_DEPLOY_CASH=1234" >> "$GITHUB_OUTPUT"', -}; -const COMMENT_TO_ALERT_APPLAUSE_CHERRYPICK_MOCK_STEP = { - name: 'Comment in StagingDeployCash to alert Applause that a new pull request has been cherry-picked', - mockWith: 'echo [MOCK] [UPDATE_STAGING] Commenting in StagingDeployCash', -}; -const WAIT_FOR_STAGING_DEPLOYS_MOCK_STEP = { - name: 'Wait for staging deploys to finish', - mockWith: 'echo [MOCK] [UPDATE_STAGING] Waiting for staging deploy to finish', -}; -const COMMENT_TO_ALERT_APPLAUSE_DEPLOY_MOCK_STEP = { - name: 'Comment in StagingDeployCash to alert Applause that cherry-picked pull request has been deployed.', - mockWith: 'echo [MOCK] [UPDATE_STAGING] Commenting in StagingDeployCash', -}; -const ANNOUNCE_FAILED_WORKFLOW_IN_SLACK_MOCK_STEP = { - name: 'Announce failed workflow in Slack', - mockWith: 'echo [MOCK] [UPDATE_STAGING] Announcing failed workflow in slack', -}; +const RUN_TURNSTYLE_MOCK_STEP = utils.getMockStep( + 'Run turnstyle', + 'Running turnstyle', + 'UPDATE_STAGING', + ['poll-interval-seconds'], + ['GITHUB_TOKEN'], +); +const UPDATE_STAGING_BRANCH_MOCK_STEP = utils.getMockStep( + 'Update staging branch from main', + 'Updating staging branch', + 'UPDATE_STAGING', +); +const CHERRYPICK_PR_MOCK_STEP = utils.getMockStep( + 'Cherry-pick PR to staging', + 'Cherry picking', + 'UPDATE_STAGING', +); +const CHECKOUT_STAGING_MOCK_STEP = utils.getMockStep( + 'Checkout staging', + 'Checking out staging', + 'UPDATE_STAGING', +); +const TAG_STAGING_MOCK_STEP = utils.getMockStep( + 'Tag staging', + 'Tagging staging', + 'UPDATE_STAGING', +); +const UPDATE_STAGINGDEPLOYCASH_MOCK_STEP = utils.getMockStep( + 'Update StagingDeployCash', + 'Updating StagingDeployCash', + 'UPDATE_STAGING', +); +const FIND_OPEN_STAGINGDEPLOYCASH_MOCK_STEP = utils.getMockStep( + 'Find open StagingDeployCash', + 'Finding open StagingDeployCash', + 'UPDATE_STAGING', + null, + null, + {STAGING_DEPLOY_CASH: '1234'}, +); +const COMMENT_TO_ALERT_APPLAUSE_CHERRYPICK_MOCK_STEP = utils.getMockStep( + 'Comment in StagingDeployCash to alert Applause that a new pull request has been cherry-picked', + 'Commenting in StagingDeployCash', + 'UPDATE_STAGING', +); +const WAIT_FOR_STAGING_DEPLOYS_MOCK_STEP = utils.getMockStep( + 'Wait for staging deploys to finish', + 'Waiting for staging deploy to finish', + 'UPDATE_STAGING', +); +const COMMENT_TO_ALERT_APPLAUSE_DEPLOY_MOCK_STEP = utils.getMockStep( + 'Comment in StagingDeployCash to alert Applause that cherry-picked pull request has been deployed.', + 'Commenting in StagingDeployCash', + 'UPDATE_STAGING', +); +const ANNOUNCE_FAILED_WORKFLOW_IN_SLACK_MOCK_STEP = utils.getMockStep( + 'Announce failed workflow in Slack', + 'Announcing failed workflow in slack', + 'UPDATE_STAGING', +); const UPDATE_STAGING_JOB_MOCK_STEPS = [ RUN_TURNSTYLE_MOCK_STEP, UPDATE_STAGING_BRANCH_MOCK_STEP, @@ -126,67 +154,96 @@ const UPDATE_STAGING_JOB_MOCK_STEPS = [ ]; // is_expensify_employee -const GET_MERGED_PULL_REQUEST_MOCK_STEP__IS_EXPENSIFY_EMPLOYEE = { - name: 'Get merged pull request', - mockWith: 'echo [MOCK] [IS_EXPENSIFY_EMPLOYEE] Getting merged pull request, GITHUB_TOKEN=${{ inputs.github_token }}\n' - + 'echo "author=Dummy Author" >> "$GITHUB_OUTPUT"', -}; -const CHECK_TEAM_MEMBERSHIP_MOCK_STEP__TRUE = { - name: 'Check whether the actor is member of Expensify/expensify team', - mockWith: 'echo [MOCK] [IS_EXPENSIFY_EMPLOYEE] Checking actors Expensify membership, GITHUB_TOKEN=${{ inputs.GITHUB_TOKEN }}, USERNAME=${{ inputs.username }}, TEAM=${{ inputs.team }}\n' - + 'echo "isTeamMember=true" >> "$GITHUB_OUTPUT"', -}; +const GET_MERGED_PULL_REQUEST_MOCK_STEP__IS_EXPENSIFY_EMPLOYEE = utils.getMockStep( + 'Get merged pull request', + 'Getting merged pull request', + 'IS_EXPENSIFY_EMPLOYEE', + ['github_token'], + null, + {author: 'Dummy Author'}, +); +const CHECK_TEAM_MEMBERSHIP_MOCK_STEP__TRUE = utils.getMockStep( + 'Check whether the actor is member of Expensify/expensify team', + 'Checking actors Expensify membership', + 'IS_EXPENSIFY_EMPLOYEE', + ['GITHUB_TOKEN', 'username', 'team'], + null, + {isTeamMember: 'true'}, +); const IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE = [ GET_MERGED_PULL_REQUEST_MOCK_STEP__IS_EXPENSIFY_EMPLOYEE, CHECK_TEAM_MEMBERSHIP_MOCK_STEP__TRUE, ]; -const CHECK_TEAM_MEMBERSHIP_MOCK_STEP__FALSE = { - name: 'Check whether the actor is member of Expensify/expensify team', - mockWith: 'echo [MOCK] [IS_EXPENSIFY_EMPLOYEE] Checking actors Expensify membership, GITHUB_TOKEN=${{ inputs.GITHUB_TOKEN }}, USERNAME=${{ inputs.username }}, TEAM=${{ inputs.team }}\n' - + 'echo "isTeamMember=false" >> "$GITHUB_OUTPUT"', -}; +const CHECK_TEAM_MEMBERSHIP_MOCK_STEP__FALSE = utils.getMockStep( + 'Check whether the actor is member of Expensify/expensify team', + 'Checking actors Expensify membership', + 'IS_EXPENSIFY_EMPLOYEE', + ['GITHUB_TOKEN', 'username', 'team'], + null, + {isTeamMember: 'false'}, +); const IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__FALSE = [ GET_MERGED_PULL_REQUEST_MOCK_STEP__IS_EXPENSIFY_EMPLOYEE, CHECK_TEAM_MEMBERSHIP_MOCK_STEP__FALSE, ]; // new_contributor_welcome_message -const CHECKOUT_MOCK_STEP = { - name: 'Checkout', - mockWith: 'echo [MOCK] [NEW_CONTRIBUTOR_WELCOME_MESSAGE] Checking out, TOKEN=${{ inputs.token }}\n' - + 'echo "author=Dummy Author" >> "$GITHUB_OUTPUT"', -}; -const CHECKOUT_MOCK_STEP__OSBOTIFY = { - name: 'Checkout', - mockWith: 'echo [MOCK] [NEW_CONTRIBUTOR_WELCOME_MESSAGE] Checking out, TOKEN=${{ inputs.token }}\n' - + 'echo "author=OSBotify" >> "$GITHUB_OUTPUT"', -}; -const GET_MERGED_PULL_REQUEST_MOCK_STEP__WELCOME_MESSAGE = { - name: 'Get merged pull request', - mockWith: 'echo [MOCK] [NEW_CONTRIBUTOR_WELCOME_MESSAGE] Getting merged pull request, GITHUB_TOKEN=${{ inputs.github_token }}\n' - + 'echo "number=12345" >> "$GITHUB_OUTPUT"\n' - + 'echo "author=Dummy Author" >> "$GITHUB_OUTPUT"', -}; -const GET_MERGED_PULL_REQUEST_MOCK_STEP__WELCOME_MESSAGE__OSBOTIFY = { - name: 'Get merged pull request', - mockWith: 'echo [MOCK] [NEW_CONTRIBUTOR_WELCOME_MESSAGE] Getting merged pull request, GITHUB_TOKEN=${{ inputs.github_token }}\n' - + 'echo "number=12345" >> "$GITHUB_OUTPUT"\n' - + 'echo "author=OSBotify" >> "$GITHUB_OUTPUT"', -}; -const GET_PR_COUNT_MOCK_STEP__1 = { - name: 'Get PR count for ${{ steps.getMergedPullRequest.outputs.author }}', - mockWith: 'echo [MOCK] [NEW_CONTRIBUTOR_WELCOME_MESSAGE] Getting PR count, GITHUB_TOKEN=${{ env.GITHUB_TOKEN }}\n' - + 'echo "PR_COUNT=1" >> "$GITHUB_ENV"', -}; -const GET_PR_COUNT_MOCK_STEP__10 = { - name: 'Get PR count for ${{ steps.getMergedPullRequest.outputs.author }}', - mockWith: 'echo [MOCK] [NEW_CONTRIBUTOR_WELCOME_MESSAGE] Getting PR count, GITHUB_TOKEN=${{ env.GITHUB_TOKEN }}\n' - + 'echo "PR_COUNT=10" >> "$GITHUB_ENV"', -}; -const COMMENT_ON_FIRST_PULL_REQUEST_MOCK_STEP = { - name: 'Comment on ${{ steps.getMergedPullRequest.outputs.author }}\\\'s first pull request!', - mockWith: 'echo [MOCK] [NEW_CONTRIBUTOR_WELCOME_MESSAGE] Creating comment, GITHUB_TOKEN=${{ inputs.github_token }}, NUMBER=${{ inputs.number }}, BODY="${{ inputs.body }}"', -}; +const CHECKOUT_MOCK_STEP = utils.getMockStep( + 'Checkout', + 'Checking out', + 'NEW_CONTRIBUTOR_WELCOME_MESSAGE', + ['token'], + null, + {author: 'Dummy Author'}, +); +const CHECKOUT_MOCK_STEP__OSBOTIFY = utils.getMockStep( + 'Checkout', + 'Checking out', + 'NEW_CONTRIBUTOR_WELCOME_MESSAGE', + ['token'], + null, + {author: 'OSBotify'}, +); +const GET_MERGED_PULL_REQUEST_MOCK_STEP__WELCOME_MESSAGE = utils.getMockStep( + 'Get merged pull request', + 'Getting merged pull request', + 'NEW_CONTRIBUTOR_WELCOME_MESSAGE', + ['github_token'], + null, + {number: '12345', author: 'Dummy Author'}, +); +const GET_MERGED_PULL_REQUEST_MOCK_STEP__WELCOME_MESSAGE__OSBOTIFY = utils.getMockStep( + 'Get merged pull request', + 'Getting merged pull request', + 'NEW_CONTRIBUTOR_WELCOME_MESSAGE', + ['github_token'], + null, + {number: '12345', author: 'OSBotify'}, +); +const GET_PR_COUNT_MOCK_STEP__1 = utils.getMockStep( + 'Get PR count for ${{ steps.getMergedPullRequest.outputs.author }}', + 'Getting PR count', + 'NEW_CONTRIBUTOR_WELCOME_MESSAGE', + null, + ['GITHUB_TOKEN'], + null, + {PR_COUNT: '1'}, +); +const GET_PR_COUNT_MOCK_STEP__10 = utils.getMockStep( + 'Get PR count for ${{ steps.getMergedPullRequest.outputs.author }}', + 'Getting PR count', + 'NEW_CONTRIBUTOR_WELCOME_MESSAGE', + null, + ['GITHUB_TOKEN'], + null, + {PR_COUNT: '10'}, +); +const COMMENT_ON_FIRST_PULL_REQUEST_MOCK_STEP = utils.getMockStep( + 'Comment on ${{ steps.getMergedPullRequest.outputs.author }}\\\'s first pull request!', + 'Creating comment', + 'NEW_CONTRIBUTOR_WELCOME_MESSAGE', + ['github_token', 'number', 'body'], +); const NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS = [ CHECKOUT_MOCK_STEP, GET_MERGED_PULL_REQUEST_MOCK_STEP__WELCOME_MESSAGE, @@ -208,98 +265,121 @@ const NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__OSBOTIFY = [ // e2e_tests // these steps are not getting executed anyway, since Act does not support the selected runner -const CHECKOUT_MOCK_STEP__E2E_TESTS = { - name: 'Checkout', - mockWith: 'echo [MOCK] [E2E_TESTS] Checking out', -}; -const SETUP_NODE_MOCK_STEP = { - name: 'Setup node', - mockWith: 'echo [MOCK] [E2E_TESTS] Setting up node', -}; -const SETUP_RUBY_MOCK_STEP = { - name: 'Setup ruby', - mockWith: 'echo [MOCK] [E2E_TESTS] Setting up ruby', -}; -const GRADLE_CACHE_MOCK_STEP = { - name: 'Gradle cache', - mockWith: 'echo [MOCK] [E2E_TESTS] Building with gradle', -}; -const MAKE_ZIP_MOCK_STEP = { - name: 'Make zip directory for everything to send to AWS Device Farm', - mockWith: 'echo [MOCK] [E2E_TESTS] Creating zip directory', -}; -const CHECKOUT_COMPARE_MOCK_STEP = { - name: 'Checkout "Compare" commit', - mockWith: 'echo [MOCK] [E2E_TESTS] Checking out compare commit', -}; -const INSTALL_NODE_PACKAGES_MOCK_STEP = { - name: 'Install node packages', - mockWith: 'echo [MOCK] [E2E_TESTS] Installing node packages', -}; -const BUILD_COMPARE_APK_MOCK_STEP = { - name: 'Build "Compare" APK', - mockWith: 'echo [MOCK] [E2E_TESTS] Building compare apk', -}; -const COPY_COMPARE_APK_MOCK_STEP = { - name: 'Copy "Compare" APK', - mockWith: 'echo [MOCK] [E2E_TESTS] Copying compare apk', -}; -const CHECKOUT_BASELINE_COMMIT_MOCK_STEP = { - name: 'Checkout "Baseline" commit (last release)', - mockWith: 'echo [MOCK] [E2E_TESTS] Checking out baseline commit', -}; -const BUILD_BASELINE_APK_MOCK_STEP = { - name: 'Build "Baseline" APK', - mockWith: 'echo [MOCK] [E2E_TESTS] Building baseline apk', -}; -const COPY_BASELINE_APK_MOCK_STEP = { - name: 'Copy "Baseline" APK', - mockWith: 'echo [MOCK] [E2E_TESTS] Copying baseline apk', -}; -const CHECKOUT_PREVIOUS_BRANCH_MOCK_STEP = { - name: 'Checkout previous branch for source code to run on AWS Device farm', - mockWith: 'echo [MOCK] [E2E_TESTS] Checking out previous branch', -}; -const COPY_E2E_CODE_MOCK_STEP = { - name: 'Copy e2e code into zip folder', - mockWith: 'echo [MOCK] [E2E_TESTS] Copying e2e tests', -}; -const ZIP_EVERYTHING_MOCK_STEP = { - name: 'Zip everything in the zip directory up', - mockWith: 'echo [MOCK] [E2E_TESTS] Zipping everything', -}; -const CONFIGURE_AWS_CREDENTIALS_MOCK_STEP = { - name: 'Configure AWS Credentials', - mockWith: 'echo [MOCK] [E2E_TESTS] Configuring AWS credentials', -}; -const SCHEDULE_AWS_DEVICE_FARM_MOCK_STEP = { - name: 'Schedule AWS Device Farm test run', - mockWith: 'echo [MOCK] [E2E_TESTS] Scheduling AWS test run', -}; -const UNZIP_AWS_DEVICE_FARM_RESULTS_MOCK_STEP = { - name: 'Unzip AWS Device Farm results', - mockWith: 'echo [MOCK] [E2E_TESTS] Unzipping test results', -}; -const PRINT_AWS_DEVICE_FARM_RESULTS_MOCK_STEP = { - name: 'Print AWS Device Farm run results', - mockWith: 'echo [MOCK] [E2E_TESTS] Printing test results', -}; -const SET_OUTPUT_OF_AWS_DEVICE_FARM_MOCK_STEP = { - name: 'Set output of AWS Device Farm into GitHub ENV', - mockWith: 'echo [MOCK] [E2E_TESTS] Setting AWS output', -}; -const GET_MERGED_PULL_REQUEST_MOCK_STEP__E2E_TESTS = { - name: 'Get merged pull request', - mockWith: 'echo [MOCK] [E2E_TESTS] Getting merged pull request', -}; -const LEAVE_COMMENT_WITH_AWS_DEVICE_FARM_OUTPUT_MOCK_STEP = { - name: 'Leave output of AWS Device Farm as a PR comment', - mockWith: 'echo [MOCK] [E2E_TESTS] Leaving comment with test results', -}; -const CHECK_IF_TESTS_FAILED_MOCK_STEP = { - name: 'Check if test failed, if so leave a deploy blocker label', - mockWith: 'echo [MOCK] [E2E_TESTS] Checking if tests failed', -}; +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 E2E_TESTS_JOB_MOCK_STEPS = [ CHECKOUT_MOCK_STEP__E2E_TESTS, SETUP_NODE_MOCK_STEP, diff --git a/workflow_tests/utils.js b/workflow_tests/utils.js index e0c33dc7ad13..97d138ffa8c5 100644 --- a/workflow_tests/utils.js +++ b/workflow_tests/utils.js @@ -1,6 +1,4 @@ -module.exports = { - setUpActParams: -(act, event = null, event_options = null, secrets = null, github_token = null) => { +const setUpActParams = (act, event = null, event_options = null, secrets = null, github_token = null) => { let updated_act = act; if (event && event_options) { @@ -20,5 +18,42 @@ module.exports = { } return updated_act; -}, +}; + +const getMockStep = (name, message, job_id = null, inputs = null, in_envs = null, outputs = null, out_envs = null) => { + const mockStepName = name; + let mockWithCommand = 'echo [MOCK]'; + if (job_id) { + mockWithCommand += ` [${job_id}]`; + } + mockWithCommand += ` ${message}`; + if (inputs) { + for (const input of inputs) { + mockWithCommand += `, ${input}="\${{ inputs.${input} }}"`; + } + } + if (in_envs) { + for (const env of in_envs) { + mockWithCommand += `, ${env}="\${{ env.${env} }}"`; + } + } + if (outputs) { + for (const [key, value] of Object.entries(outputs)) { + mockWithCommand += `\necho "${key}=${value}" >> "$GITHUB_OUTPUT"`; + } + } + if (out_envs) { + for (const [key, value] of Object.entries(out_envs)) { + mockWithCommand += `\necho "${key}=${value}" >> "$GITHUB_ENV"`; + } + } + return { + name: mockStepName, + mockWith: mockWithCommand, + }; +}; + +module.exports = { + setUpActParams, + getMockStep, }; From d89c80cf8cc20de4c839d7d5ad917131d68215a8 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Fri, 24 Feb 2023 14:44:15 +0100 Subject: [PATCH 014/504] Add method for getting step assertions [WiP] Added a helper method to utils, that helps with creating mock step assertions - easier than typing them by hand, allows reusability and reduces the chance of a typo sneaking in See: https://github.com/Expensify/App/issues/13604 --- .../assertions/preDeployAssertions.js | 589 +++++++++++------- workflow_tests/preDeploy.test.js | 108 ++-- workflow_tests/utils.js | 38 +- 3 files changed, 449 insertions(+), 286 deletions(-) diff --git a/workflow_tests/assertions/preDeployAssertions.js b/workflow_tests/assertions/preDeployAssertions.js index 1ada8e1a5eca..2de86d0dcb5b 100644 --- a/workflow_tests/assertions/preDeployAssertions.js +++ b/workflow_tests/assertions/preDeployAssertions.js @@ -1,9 +1,15 @@ +const utils = require('../utils'); + const assertLintJobExecuted = (workflowResult, didExecute = true) => { - const steps = [{ - name: 'Main Run lint workflow', - status: 0, - output: '[MOCK] [LINT] Running lint workflow', - }]; + const steps = [ + utils.getStepAssertion( + 'Run lint workflow', + true, + null, + 'LINT', + 'Running lint workflow', + ), + ]; if (didExecute) { expect(workflowResult).toEqual(expect.arrayContaining(steps)); } else { @@ -12,11 +18,15 @@ const assertLintJobExecuted = (workflowResult, didExecute = true) => { }; const assertTestJobExecuted = (workflowResult, didExecute = true) => { - const steps = [{ - name: 'Main Run test workflow', - status: 0, - output: '[MOCK] [TEST] Running test workflow', - }]; + const steps = [ + utils.getStepAssertion( + 'Run test workflow', + true, + null, + 'TEST', + 'Running test workflow', + ), + ]; if (didExecute) { expect(workflowResult).toEqual(expect.arrayContaining(steps)); } else { @@ -25,16 +35,24 @@ const assertTestJobExecuted = (workflowResult, didExecute = true) => { }; const assertIsExpensifyEmployeeJobExecuted = (workflowResult, didExecute = true) => { - const steps = [{ - name: 'Main Get merged pull request', - status: 0, - output: '[MOCK] [IS_EXPENSIFY_EMPLOYEE] Getting merged pull request, github_token=***', - }, - { - name: 'Main Check whether the actor is member of Expensify/expensify team', - status: 0, - output: '[MOCK] [IS_EXPENSIFY_EMPLOYEE] Checking actors Expensify membership, GITHUB_TOKEN=***, username=Dummy Author, team=Expensify/expensify', - }]; + const steps = [ + utils.getStepAssertion( + 'Get merged pull request', + true, + null, + 'IS_EXPENSIFY_EMPLOYEE', + 'Getting merged pull request', + [{key: 'github_token', value: '***'}], + ), + utils.getStepAssertion( + 'Check whether the actor is member of Expensify/expensify team', + true, + null, + 'IS_EXPENSIFY_EMPLOYEE', + 'Checking actors Expensify membership', + [{key: 'GITHUB_TOKEN', value: '***'}, {key: 'username', value: 'Dummy Author'}, {key: 'team', value: 'Expensify/expensify'}], + ), + ]; if (didExecute) { expect(workflowResult).toEqual(expect.arrayContaining(steps)); } else { @@ -44,29 +62,41 @@ const assertIsExpensifyEmployeeJobExecuted = (workflowResult, didExecute = true) const assertNewContributorWelcomeMessageJobExecuted = (workflowResult, didExecute = true, isOsBotify = false, isFirstPr = false) => { const steps = [ - { - name: 'Main Checkout', - status: 0, - output: '[MOCK] [NEW_CONTRIBUTOR_WELCOME_MESSAGE] Checking out, token=***', - }, - { - name: 'Main Get merged pull request', - status: 0, - output: '[MOCK] [NEW_CONTRIBUTOR_WELCOME_MESSAGE] Getting merged pull request, github_token=***', - }, - { - name: isOsBotify ? 'Main Get PR count for OSBotify' : 'Main Get PR count for Dummy Author', - status: 0, - output: '[MOCK] [NEW_CONTRIBUTOR_WELCOME_MESSAGE] Getting PR count, GITHUB_TOKEN=***', - }, + utils.getStepAssertion( + 'Checkout', + true, + null, + 'NEW_CONTRIBUTOR_WELCOME_MESSAGE', + 'Checking out', + [{key: 'token', value: '***'}], + ), + utils.getStepAssertion( + 'Get merged pull request', + true, + null, + 'NEW_CONTRIBUTOR_WELCOME_MESSAGE', + 'Getting merged pull request', + [{key: 'github_token', value: '***'}], + ), + utils.getStepAssertion( + isOsBotify ? 'Get PR count for OSBotify' : 'Get PR count for Dummy Author', + true, + null, + 'NEW_CONTRIBUTOR_WELCOME_MESSAGE', + 'Getting PR count', + [{key: 'GITHUB_TOKEN', value: '***'}], + ), ]; if (isFirstPr) { steps.push( - { - name: isOsBotify ? 'Main Comment on OSBotify\\\'s first pull request!' : 'Main Comment on Dummy Author\\\'s first pull request!', - status: 0, - output: isOsBotify ? '[MOCK] [NEW_CONTRIBUTOR_WELCOME_MESSAGE] Creating comment, github_token=***, number=12345, body=@OSBotify, Great job getting your first Expensify/App pull request over the finish line! :tada:\n\nI know there\'s a lot of information in our [contributing guidelines](https://github.com/Expensify/App/blob/main/contributingGuides/CONTRIBUTING.md), so here are some points to take note of :memo::\n\n1. Now that your first PR has been merged, you can be hired for another issue. Once you\'ve completed a few issues, you may be eligible to work on more than one job at a time.\n2. Once your PR is deployed to our staging servers, it will undergo quality assurance (QA) testing. If we find that it doesn\'t work as expected or causes a regression, you\'ll be responsible for fixing it. Typically, we would revert this PR and give you another chance to create a similar PR without causing a regression.\n3. Once your PR is deployed to _production_, we start a 7-day timer :alarm_clock:. After it has been on production for 7 days without causing any regressions, then we pay out the Upwork job. :moneybag:\n\nSo it might take a while before you\'re paid for your work, but we typically post multiple new jobs every day, so there\'s plenty of opportunity. I hope you\'ve had a positive experience contributing to this repo! :blush:' : '[MOCK] [NEW_CONTRIBUTOR_WELCOME_MESSAGE] Creating comment, github_token=***, number=12345, body=@Dummy Author, Great job getting your first Expensify/App pull request over the finish line! :tada:\n\nI know there\'s a lot of information in our [contributing guidelines](https://github.com/Expensify/App/blob/main/contributingGuides/CONTRIBUTING.md), so here are some points to take note of :memo::\n\n1. Now that your first PR has been merged, you can be hired for another issue. Once you\'ve completed a few issues, you may be eligible to work on more than one job at a time.\n2. Once your PR is deployed to our staging servers, it will undergo quality assurance (QA) testing. If we find that it doesn\'t work as expected or causes a regression, you\'ll be responsible for fixing it. Typically, we would revert this PR and give you another chance to create a similar PR without causing a regression.\n3. Once your PR is deployed to _production_, we start a 7-day timer :alarm_clock:. After it has been on production for 7 days without causing any regressions, then we pay out the Upwork job. :moneybag:\n\nSo it might take a while before you\'re paid for your work, but we typically post multiple new jobs every day, so there\'s plenty of opportunity. I hope you\'ve had a positive experience contributing to this repo! :blush:', - }, + utils.getStepAssertion( + isOsBotify ? 'Comment on OSBotify\\\'s first pull request!' : 'Comment on Dummy Author\\\'s first pull request!', + true, + null, + 'NEW_CONTRIBUTOR_WELCOME_MESSAGE', + 'Creating comment', + [{key: 'github_token', value: '***'}, {key: 'number', value: '12345'}, {key: 'body', value: isOsBotify ? '@OSBotify, Great job getting your first Expensify/App pull request over the finish line! :tada:\n\nI know there\'s a lot of information in our [contributing guidelines](https://github.com/Expensify/App/blob/main/contributingGuides/CONTRIBUTING.md), so here are some points to take note of :memo::\n\n1. Now that your first PR has been merged, you can be hired for another issue. Once you\'ve completed a few issues, you may be eligible to work on more than one job at a time.\n2. Once your PR is deployed to our staging servers, it will undergo quality assurance (QA) testing. If we find that it doesn\'t work as expected or causes a regression, you\'ll be responsible for fixing it. Typically, we would revert this PR and give you another chance to create a similar PR without causing a regression.\n3. Once your PR is deployed to _production_, we start a 7-day timer :alarm_clock:. After it has been on production for 7 days without causing any regressions, then we pay out the Upwork job. :moneybag:\n\nSo it might take a while before you\'re paid for your work, but we typically post multiple new jobs every day, so there\'s plenty of opportunity. I hope you\'ve had a positive experience contributing to this repo! :blush:' : '@Dummy Author, Great job getting your first Expensify/App pull request over the finish line! :tada:\n\nI know there\'s a lot of information in our [contributing guidelines](https://github.com/Expensify/App/blob/main/contributingGuides/CONTRIBUTING.md), so here are some points to take note of :memo::\n\n1. Now that your first PR has been merged, you can be hired for another issue. Once you\'ve completed a few issues, you may be eligible to work on more than one job at a time.\n2. Once your PR is deployed to our staging servers, it will undergo quality assurance (QA) testing. If we find that it doesn\'t work as expected or causes a regression, you\'ll be responsible for fixing it. Typically, we would revert this PR and give you another chance to create a similar PR without causing a regression.\n3. Once your PR is deployed to _production_, we start a 7-day timer :alarm_clock:. After it has been on production for 7 days without causing any regressions, then we pay out the Upwork job. :moneybag:\n\nSo it might take a while before you\'re paid for your work, but we typically post multiple new jobs every day, so there\'s plenty of opportunity. I hope you\'ve had a positive experience contributing to this repo! :blush:'}], + ), ); } if (didExecute) { @@ -78,126 +108,174 @@ const assertNewContributorWelcomeMessageJobExecuted = (workflowResult, didExecut const assertE2ETestsJobExecuted = (workflowResult, didExecute = true) => { const steps = [ - { - name: 'Main Checkout', - status: 0, - output: '[MOCK] [E2E_TESTS] Checking out', - }, - { - name: 'Main Setup node', - status: 0, - output: '[MOCK] [E2E_TESTS] Setting up node', - }, - { - name: 'Main Setup ruby', - status: 0, - output: '[MOCK] [E2E_TESTS] Setting up ruby', - }, - { - name: 'Main Gradle cache', - status: 0, - output: '[MOCK] [E2E_TESTS] Building with gradle', - }, - { - name: 'Make zip directory for everything to send to AWS Device Farm', - status: 0, - output: '[MOCK] [E2E_TESTS] Creating zip directory', - }, - { - name: 'Checkout "Compare" commit', - status: 0, - output: '[MOCK] [E2E_TESTS] Checking out compare commit', - }, - { - name: 'Install node packages', - status: 0, - output: '[MOCK] [E2E_TESTS] Installing node packages', - }, - { - name: 'Build "Compare" APK', - status: 0, - output: '[MOCK] [E2E_TESTS] Building compare apk', - }, - { - name: 'Copy "Compare" APK', - status: 0, - output: '[MOCK] [E2E_TESTS] Copying compare apk', - }, - { - name: 'Checkout "Baseline" commit (last release)', - status: 0, - output: '[MOCK] [E2E_TESTS] Checking out baseline commit', - }, - { - name: 'Install node packages', - status: 0, - output: '[MOCK] [E2E_TESTS] Installing node packages', - }, - { - name: 'Build "Baseline" APK', - status: 0, - output: '[MOCK] [E2E_TESTS] Building baseline apk', - }, - { - name: 'Copy "Baseline" APK', - status: 0, - output: '[MOCK] [E2E_TESTS] Copying baseline apk', - }, - { - name: 'Checkout previous branch for source code to run on AWS Device farm', - status: 0, - output: '[MOCK] [E2E_TESTS] Checking out previous branch', - }, - { - name: 'Copy e2e code into zip folder', - status: 0, - output: '[MOCK] [E2E_TESTS] Copying e2e tests', - }, - { - name: 'Zip everything in the zip directory up', - status: 0, - output: '[MOCK] [E2E_TESTS] Zipping everything', - }, - { - name: 'Configure AWS Credentials', - status: 0, - output: '[MOCK] [E2E_TESTS] Configuring AWS credentials', - }, - { - name: 'Schedule AWS Device Farm test run', - status: 0, - output: '[MOCK] [E2E_TESTS] Scheduling AWS test run', - }, - { - name: 'Unzip AWS Device Farm results', - status: 0, - output: '[MOCK] [E2E_TESTS] Unzipping test results', - }, - { - name: 'Print AWS Device Farm run results', - status: 0, - output: '[MOCK] [E2E_TESTS] Printing test results', - }, - { - name: 'Set output of AWS Device Farm into GitHub ENV', - status: 0, - output: '[MOCK] [E2E_TESTS] Setting AWS output', - }, - { - name: 'Get merged pull request', - status: 0, - output: '[MOCK] [E2E_TESTS] Getting merged pull request', - }, - { - name: 'Leave output of AWS Device Farm as a PR comment', - status: 0, - output: '[MOCK] [E2E_TESTS] Leaving comment with test results', - }, - { - name: 'Check if test failed, if so leave a deploy blocker label', - status: 0, - output: '[MOCK] [E2E_TESTS] Checking if tests failed', - }, + 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', + ), ]; if (didExecute) { expect(workflowResult).toEqual(expect.arrayContaining(steps)); @@ -208,32 +286,37 @@ const assertE2ETestsJobExecuted = (workflowResult, didExecute = true) => { const assertChooseDeployActionsJobExecuted = (workflowResult, didExecute = true) => { const steps = [ - { - name: 'Main Get merged pull request', - status: 0, - output: '[MOCK] [CHOOSE_DEPLOY_ACTIONS] Getting merged pull request, github_token=***', // no access to secrets - }, - { - name: 'Main Check if StagingDeployCash is locked', - status: 0, - - output: '[MOCK] [CHOOSE_DEPLOY_ACTIONS] Checking StagingDeployCash, GITHUB_TOKEN=***', // no access to secrets - }, - { - name: 'Main Check if merged pull request was an automated PR', - status: 0, - output: '', - }, - { - name: 'Main Check if merged pull request has `CP Staging` label', - status: 0, - output: '', - }, - { - name: 'Main Check if merged pull request should trigger a deploy', - status: 0, - output: '', - }, + utils.getStepAssertion( + 'Get merged pull request', + true, + null, + 'CHOOSE_DEPLOY_ACTIONS', + 'Getting merged pull request', + [{key: 'github_token', value: '***'}], + ), + utils.getStepAssertion( + 'Check if StagingDeployCash is locked', + true, + null, + 'CHOOSE_DEPLOY_ACTIONS', + 'Checking StagingDeployCash', + [{key: 'GITHUB_TOKEN', value: '***'}], + ), + utils.getStepAssertion( + 'Check if merged pull request was an automated PR', + true, + '', + ), + utils.getStepAssertion( + 'Check if merged pull request has `CP Staging` label', + true, + '', + ), + utils.getStepAssertion( + 'Check if merged pull request should trigger a deploy', + true, + '', + ), ]; if (didExecute) { expect(workflowResult).toEqual(expect.arrayContaining(steps)); @@ -244,11 +327,14 @@ const assertChooseDeployActionsJobExecuted = (workflowResult, didExecute = true) const assertSkipDeployJobExecuted = (workflowResult, didExecute = true) => { const steps = [ - { - name: 'Main Comment on deferred PR', - status: 0, - output: '[MOCK] [SKIP_DEPLOY] Skipping deploy, github_token=***, number=123, body=:hand: This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.', - }, + utils.getStepAssertion( + 'Comment on deferred PR', + true, + null, + 'SKIP_DEPLOY', + 'Skipping deploy', + [{key: 'github_token', value: '***'}, {key: 'number', value: '123'}, {key: 'body', value: ':hand: This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.'}], + ), ]; if (didExecute) { expect(workflowResult).toEqual(expect.arrayContaining(steps)); @@ -259,11 +345,13 @@ const assertSkipDeployJobExecuted = (workflowResult, didExecute = true) => { const assertCreateNewVersionJobExecuted = (workflowResult, didExecute = true) => { const steps = [ - { - name: 'Main Create new version', - status: 0, - output: '[MOCK] [CREATE_NEW_VERSION] Creating new version', - }, + utils.getStepAssertion( + 'Create new version', + true, + null, + 'CREATE_NEW_VERSION', + 'Creating new version', + ), ]; if (didExecute) { expect(workflowResult).toEqual(expect.arrayContaining(steps)); @@ -274,51 +362,70 @@ const assertCreateNewVersionJobExecuted = (workflowResult, didExecute = true) => const assertUpdateStagingJobExecuted = (workflowResult, didExecute = true) => { const steps = [ - { - name: 'Main Run turnstyle', - status: 0, - output: '[MOCK] [UPDATE_STAGING] Running turnstyle, poll-interval-seconds=10, GITHUB_TOKEN=***', - }, - { - name: 'Main Cherry-pick PR to staging', - status: 0, - output: '[MOCK] [UPDATE_STAGING] Cherry picking', - }, - { - name: 'Main Checkout staging', - status: 0, - output: '[MOCK] [UPDATE_STAGING] Checking out staging', - }, - { - name: 'Main Tag staging', - status: 0, - output: '[MOCK] [UPDATE_STAGING] Tagging staging', - }, - { - name: 'Main Update StagingDeployCash', - status: 0, - output: '[MOCK] [UPDATE_STAGING] Updating StagingDeployCash', - }, - { - name: 'Main Find open StagingDeployCash', - status: 0, - output: '[MOCK] [UPDATE_STAGING] Finding open StagingDeployCash', - }, - { - name: 'Main Comment in StagingDeployCash to alert Applause that a new pull request has been cherry-picked', - status: 0, - output: '[MOCK] [UPDATE_STAGING] Commenting in StagingDeployCash', - }, - { - name: 'Main Wait for staging deploys to finish', - status: 0, - output: '[MOCK] [UPDATE_STAGING] Waiting for staging deploy to finish', - }, - { - name: 'Main Comment in StagingDeployCash to alert Applause that cherry-picked pull request has been deployed.', - status: 0, - output: '[MOCK] [UPDATE_STAGING] Commenting in StagingDeployCash', - }, + utils.getStepAssertion( + 'Run turnstyle', + true, + null, + 'UPDATE_STAGING', + 'Running turnstyle', + [{key: 'poll-interval-seconds', value: '10'}, {key: 'GITHUB_TOKEN', value: '***'}], + ), + utils.getStepAssertion( + 'Cherry-pick PR to staging', + true, + null, + 'UPDATE_STAGING', + 'Cherry picking', + ), + utils.getStepAssertion( + 'Checkout staging', + true, + null, + 'UPDATE_STAGING', + 'Checking out staging', + ), + utils.getStepAssertion( + 'Tag staging', + true, + null, + 'UPDATE_STAGING', + 'Tagging staging', + ), + utils.getStepAssertion( + 'Update StagingDeployCash', + true, + null, + 'UPDATE_STAGING', + 'Updating StagingDeployCash', + ), + utils.getStepAssertion( + 'Find open StagingDeployCash', + true, + null, + 'UPDATE_STAGING', + 'Finding open StagingDeployCash', + ), + utils.getStepAssertion( + 'Comment in StagingDeployCash to alert Applause that a new pull request has been cherry-picked', + true, + null, + 'UPDATE_STAGING', + 'Commenting in StagingDeployCash', + ), + utils.getStepAssertion( + 'Wait for staging deploys to finish', + true, + null, + 'UPDATE_STAGING', + 'Waiting for staging deploy to finish', + ), + utils.getStepAssertion( + 'Comment in StagingDeployCash to alert Applause that cherry-picked pull request has been deployed.', + true, + null, + 'UPDATE_STAGING', + 'Commenting in StagingDeployCash', + ), ]; if (didExecute) { expect(workflowResult).toEqual(expect.arrayContaining(steps)); diff --git a/workflow_tests/preDeploy.test.js b/workflow_tests/preDeploy.test.js index 97bb31004804..3f70ffb8428b 100644 --- a/workflow_tests/preDeploy.test.js +++ b/workflow_tests/preDeploy.test.js @@ -117,12 +117,16 @@ describe('test workflow preDeploy', () => { ); const testMockSteps = { lint: [ - { - name: 'Run lint workflow', - mockWith: 'echo [MOCK] [LINT] Running lint workflow\n' - + 'echo [MOCK] [LINT] Lint workflow failed\n' - + 'exit 1', - }, + utils.getMockStep( + 'Run lint workflow', + 'Running lint workflow - Lint workflow failed', + 'LINT', + null, + null, + null, + null, + false, + ), ], test: mocks.TEST_JOB_MOCK_STEPS, confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, @@ -140,27 +144,33 @@ describe('test workflow preDeploy', () => { mockSteps: testMockSteps, }); expect(result).toEqual(expect.arrayContaining( - [{ - name: 'Main Run lint workflow', - status: 1, - output: '[MOCK] [LINT] Running lint workflow\n' - + '[MOCK] [LINT] Lint workflow failed', - }], + [ + utils.getStepAssertion( + 'Run lint workflow', + false, + null, + 'LINT', + 'Running lint workflow - Lint workflow failed', + ), + ], )); assertions.assertTestJobExecuted(result); assertions.assertIsExpensifyEmployeeJobExecuted(result); expect(result).toEqual(expect.arrayContaining( [ - { - name: 'Main Announce failed workflow in Slack', - status: 0, - output: '[MOCK] [CONFIRM_PASSING_BUILD] Announcing failed workflow in slack, SLACK_WEBHOOK=***', // no access to secrets - }, - { - name: 'Main Exit failed workflow', - status: 1, - output: '', - }, + utils.getStepAssertion( + 'Announce failed workflow in Slack', + true, + null, + 'CONFIRM_PASSING_BUILD', + 'Announcing failed workflow in slack', + [{key: 'SLACK_WEBHOOK', value: '***'}], + ), + utils.getStepAssertion( + 'Exit failed workflow', + false, + '', + ), ], )); assertions.assertE2ETestsJobExecuted(result, false); // Act does not support ubuntu-20.04-64core runner and omits the job @@ -184,12 +194,16 @@ describe('test workflow preDeploy', () => { const testMockSteps = { lint: mocks.LINT_JOB_MOCK_STEPS, test: [ - { - name: 'Run test workflow', - mockWith: 'echo [MOCK] [TEST] Running test workflow\n' - + 'echo [MOCK] [TEST] Test workflow failed\n' - + 'exit 1', - }, + utils.getMockStep( + 'Run test workflow', + 'Running test workflow - Test workflow failed', + 'TEST', + null, + null, + null, + null, + false, + ), ], confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS, @@ -207,26 +221,32 @@ describe('test workflow preDeploy', () => { }); assertions.assertLintJobExecuted(result); expect(result).toEqual(expect.arrayContaining( - [{ - name: 'Main Run test workflow', - status: 1, - output: '[MOCK] [TEST] Running test workflow\n' - + '[MOCK] [TEST] Test workflow failed', - }], + [ + utils.getStepAssertion( + 'Run test workflow', + false, + null, + 'TEST', + 'Running test workflow - Test workflow failed', + ), + ], )); assertions.assertIsExpensifyEmployeeJobExecuted(result); expect(result).toEqual(expect.arrayContaining( [ - { - name: 'Main Announce failed workflow in Slack', - status: 0, - output: '[MOCK] [CONFIRM_PASSING_BUILD] Announcing failed workflow in slack, SLACK_WEBHOOK=***', // no access to secrets - }, - { - name: 'Main Exit failed workflow', - status: 1, - output: '', - }, + utils.getStepAssertion( + 'Announce failed workflow in Slack', + true, + null, + 'CONFIRM_PASSING_BUILD', + 'Announcing failed workflow in slack', + [{key: 'SLACK_WEBHOOK', value: '***'}], + ), + utils.getStepAssertion( + 'Exit failed workflow', + false, + '', + ), ], )); assertions.assertE2ETestsJobExecuted(result, false); // Act does not support ubuntu-20.04-64core runner and omits the job diff --git a/workflow_tests/utils.js b/workflow_tests/utils.js index 97d138ffa8c5..c0023e9193f2 100644 --- a/workflow_tests/utils.js +++ b/workflow_tests/utils.js @@ -20,7 +20,7 @@ const setUpActParams = (act, event = null, event_options = null, secrets = null, return updated_act; }; -const getMockStep = (name, message, job_id = null, inputs = null, in_envs = null, outputs = null, out_envs = null) => { +const getMockStep = (name, message, job_id = null, inputs = null, in_envs = null, outputs = null, out_envs = null, isSuccessful = true) => { const mockStepName = name; let mockWithCommand = 'echo [MOCK]'; if (job_id) { @@ -47,13 +47,49 @@ const getMockStep = (name, message, job_id = null, inputs = null, in_envs = null mockWithCommand += `\necho "${key}=${value}" >> "$GITHUB_ENV"`; } } + if (!isSuccessful) { + mockWithCommand += '\nexit 1'; + } return { name: mockStepName, mockWith: mockWithCommand, }; }; +const getStepAssertion = (name, isSuccessful = true, expectedOutput = null, jobId = null, message = null, inputs = null, envs = null) => { + const stepName = `Main ${name}`; + const stepStatus = isSuccessful ? 0 : 1; + let stepOutput; + if (expectedOutput !== undefined && expectedOutput !== null) { + stepOutput = expectedOutput; + } else { + stepOutput = '[MOCK]'; + if (jobId) { + stepOutput += ` [${jobId}]`; + } + if (message) { + stepOutput += ` ${message}`; + } + if (inputs) { + for (const input of inputs) { + stepOutput += `, ${input.key}=${input.value}`; + } + } + if (envs) { + for (const env of envs) { + stepOutput += `, ${env.key}=${env.value}`; + } + } + } + return { + name: stepName, + status: stepStatus, + output: stepOutput, + }; +}; + module.exports = { setUpActParams, getMockStep, + getStepAssertion, }; From 04671129f0b97f9c08850826ccfdfdc126e4a424 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Mon, 27 Feb 2023 12:01:02 +0100 Subject: [PATCH 015/504] Remove tsconfig [WiP] Forgot to previously remove tsconfig.json See: https://github.com/Expensify/App/issues/13604 --- workflow_tests/tsconfig.json | 103 ----------------------------------- 1 file changed, 103 deletions(-) delete mode 100644 workflow_tests/tsconfig.json diff --git a/workflow_tests/tsconfig.json b/workflow_tests/tsconfig.json deleted file mode 100644 index 90b8ec162846..000000000000 --- a/workflow_tests/tsconfig.json +++ /dev/null @@ -1,103 +0,0 @@ -{ - "compilerOptions": { - /* Visit https://aka.ms/tsconfig to read more about this file */ - - /* Projects */ - // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */ - // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */ - // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */ - // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */ - // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */ - // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ - - /* Language and Environment */ - "target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */ - // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ - // "jsx": "preserve", /* Specify what JSX code is generated. */ - // "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */ - // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */ - // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */ - // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */ - // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */ - // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */ - // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */ - // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */ - // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */ - - /* Modules */ - "module": "commonjs", /* Specify what module code is generated. */ - // "rootDir": "./", /* Specify the root folder within your source files. */ - // "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */ - // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ - // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ - // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ - // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */ - // "types": [], /* Specify type package names to be included without being referenced in a source file. */ - // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ - // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ - // "resolveJsonModule": true, /* Enable importing .json files. */ - // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ - - /* JavaScript Support */ - // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */ - // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */ - // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */ - - /* Emit */ - // "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */ - // "declarationMap": true, /* Create sourcemaps for d.ts files. */ - // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ - // "sourceMap": true, /* Create source map files for emitted JavaScript files. */ - // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */ - // "outDir": "./", /* Specify an output folder for all emitted files. */ - // "removeComments": true, /* Disable emitting comments. */ - // "noEmit": true, /* Disable emitting files from a compilation. */ - // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */ - // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */ - // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */ - // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */ - // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ - // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ - // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */ - // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */ - // "newLine": "crlf", /* Set the newline character for emitting files. */ - // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */ - // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */ - // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */ - // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */ - // "declarationDir": "./", /* Specify the output directory for generated declaration files. */ - // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */ - - /* Interop Constraints */ - // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */ - // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */ - "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */ - // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */ - "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */ - - /* Type Checking */ - "strict": true, /* Enable all strict type-checking options. */ - // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */ - // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */ - // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ - // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */ - // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ - // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */ - // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */ - // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ - // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */ - // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */ - // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ - // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ - // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ - // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */ - // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */ - // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */ - // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */ - // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */ - - /* Completeness */ - // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ - "skipLibCheck": true /* Skip type checking all .d.ts files. */ - } -} \ No newline at end of file From 50818e6849b276f84af68d9cf203e8a8edfbe73b Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Mon, 27 Feb 2023 12:08:06 +0100 Subject: [PATCH 016/504] Add tests for chooseDeployActions/skipDeploy/createNewVersion/updateStaging [WiP] Added the tests checking for which steps get executed based on given set of conditions See: https://github.com/Expensify/App/issues/13604 --- .github/workflows/preDeploy.yml | 9 +- .../assertions/preDeployAssertions.js | 89 +++-- workflow_tests/mocks/preDeployMocks.js | 67 +++- workflow_tests/preDeploy.test.js | 364 +++++++++++++++++- 4 files changed, 472 insertions(+), 57 deletions(-) diff --git a/.github/workflows/preDeploy.yml b/.github/workflows/preDeploy.yml index 619ef7b3d43b..5c1257b85f41 100644 --- a/.github/workflows/preDeploy.yml +++ b/.github/workflows/preDeploy.yml @@ -38,9 +38,9 @@ jobs: needs: confirmPassingBuild outputs: MERGED_PR: ${{ steps.getMergedPullRequest.outputs.number }} - IS_AUTOMATED_PR: ${{ steps.isAutomatedPullRequest.outputs.IS_AUTOMATED_PR }} - SHOULD_DEPLOY: ${{ steps.shouldDeploy.outputs.SHOULD_DEPLOY }} - SHOULD_CP: ${{ steps.isStagingDeployLocked.outputs.IS_LOCKED && steps.hasCherryPickLabel.outputs.HAS_CP_LABEL }} + IS_AUTOMATED_PR: ${{ fromJSON(steps.isAutomatedPullRequest.outputs.IS_AUTOMATED_PR) }} + SHOULD_DEPLOY: ${{ fromJSON(steps.shouldDeploy.outputs.SHOULD_DEPLOY) }} + SHOULD_CP: ${{ fromJSON(steps.isStagingDeployLocked.outputs.IS_LOCKED) && fromJSON(steps.hasCherryPickLabel.outputs.HAS_CP_LABEL) }} steps: - name: Get merged pull request @@ -85,8 +85,11 @@ jobs: needs: chooseDeployActions if: ${{ fromJSON(needs.chooseDeployActions.outputs.SHOULD_DEPLOY) }} secrets: inherit + outputs: + NEW_VERSION: ${{ steps.createNewVersion.outputs.NEW_VERSION }} steps: - name: Create new version + id: createNewVersion uses: Expensify/App/.github/workflows/createNewVersion.yml@main updateStaging: diff --git a/workflow_tests/assertions/preDeployAssertions.js b/workflow_tests/assertions/preDeployAssertions.js index 2de86d0dcb5b..4ba684d0982c 100644 --- a/workflow_tests/assertions/preDeployAssertions.js +++ b/workflow_tests/assertions/preDeployAssertions.js @@ -360,7 +360,7 @@ const assertCreateNewVersionJobExecuted = (workflowResult, didExecute = true) => } }; -const assertUpdateStagingJobExecuted = (workflowResult, didExecute = true) => { +const assertUpdateStagingJobExecuted = (workflowResult, didExecute = true, shouldCp = false) => { const steps = [ utils.getStepAssertion( 'Run turnstyle', @@ -370,19 +370,38 @@ const assertUpdateStagingJobExecuted = (workflowResult, didExecute = true) => { 'Running turnstyle', [{key: 'poll-interval-seconds', value: '10'}, {key: 'GITHUB_TOKEN', value: '***'}], ), - utils.getStepAssertion( - 'Cherry-pick PR to staging', - true, - null, - 'UPDATE_STAGING', - 'Cherry picking', - ), + ]; + if (shouldCp) { + steps.push( + utils.getStepAssertion( + 'Cherry-pick PR to staging', + true, + null, + 'UPDATE_STAGING', + 'Cherry picking', + [{key: 'GITHUB_TOKEN', value: '***'}, {key: 'WORKFLOW', value: 'cherryPick.yml'}, {key: 'INPUTS', value: '{ PULL_REQUEST_NUMBER: 123, NEW_VERSION: 1.2.3 }'}], + ), + ); + } else { + steps.push( + utils.getStepAssertion( + 'Update staging branch from main', + true, + null, + 'UPDATE_STAGING', + 'Updating staging branch', + [{key: 'TARGET_BRANCH', value: 'staging'}, {key: 'OS_BOTIFY_TOKEN', value: '***'}, {key: 'GPG_PASSPHRASE', value: '***'}], + ), + ); + } + steps.push( utils.getStepAssertion( 'Checkout staging', true, null, 'UPDATE_STAGING', 'Checking out staging', + [{key: 'ref', value: 'staging'}, {key: 'fetch-depth', value: '0'}], ), utils.getStepAssertion( 'Tag staging', @@ -397,6 +416,7 @@ const assertUpdateStagingJobExecuted = (workflowResult, didExecute = true) => { null, 'UPDATE_STAGING', 'Updating StagingDeployCash', + [{key: 'GITHUB_TOKEN', value: '***'}, {key: 'NPM_VERSION', value: '1.2.3'}], ), utils.getStepAssertion( 'Find open StagingDeployCash', @@ -404,29 +424,40 @@ const assertUpdateStagingJobExecuted = (workflowResult, didExecute = true) => { null, 'UPDATE_STAGING', 'Finding open StagingDeployCash', - ), - utils.getStepAssertion( - 'Comment in StagingDeployCash to alert Applause that a new pull request has been cherry-picked', - true, null, - 'UPDATE_STAGING', - 'Commenting in StagingDeployCash', - ), - utils.getStepAssertion( - 'Wait for staging deploys to finish', - true, - null, - 'UPDATE_STAGING', - 'Waiting for staging deploy to finish', - ), - utils.getStepAssertion( - 'Comment in StagingDeployCash to alert Applause that cherry-picked pull request has been deployed.', - true, - null, - 'UPDATE_STAGING', - 'Commenting in StagingDeployCash', + [{key: 'GITHUB_TOKEN', value: '***'}], ), - ]; + ); + if (shouldCp) { + steps.push( + utils.getStepAssertion( + 'Comment in StagingDeployCash to alert Applause that a new pull request has been cherry-picked', + true, + null, + 'UPDATE_STAGING', + 'Commenting in StagingDeployCash', + null, + [{key: 'GITHUB_TOKEN', value: '***'}], + ), + utils.getStepAssertion( + 'Wait for staging deploys to finish', + true, + null, + 'UPDATE_STAGING', + 'Waiting for staging deploy to finish', + [{key: 'GITHUB_TOKEN', value: '***'}, {key: 'TAG', value: '1.2.3'}], + ), + utils.getStepAssertion( + 'Comment in StagingDeployCash to alert Applause that cherry-picked pull request has been deployed.', + true, + null, + 'UPDATE_STAGING', + 'Commenting in StagingDeployCash', + null, + [{key: 'GITHUB_TOKEN', value: '***'}], + ), + ); + } if (didExecute) { expect(workflowResult).toEqual(expect.arrayContaining(steps)); } else { diff --git a/workflow_tests/mocks/preDeployMocks.js b/workflow_tests/mocks/preDeployMocks.js index f96f190fd42f..1c42607523cf 100644 --- a/workflow_tests/mocks/preDeployMocks.js +++ b/workflow_tests/mocks/preDeployMocks.js @@ -34,7 +34,7 @@ const CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS = [ ]; // choose_deploy_actions -const GET_MERGED_PULL_REQUEST_MOCK_STEP__CHOOSE_DEPLOY = utils.getMockStep( +const GET_MERGED_PULL_REQUEST_MOCK_STEP__CHOOSE_DEPLOY__CP_LABEL = utils.getMockStep( 'Get merged pull request', 'Getting merged pull request', 'CHOOSE_DEPLOY_ACTIONS', @@ -42,17 +42,51 @@ const GET_MERGED_PULL_REQUEST_MOCK_STEP__CHOOSE_DEPLOY = utils.getMockStep( null, {number: '123', labels: '[\'CP Staging\']'}, ); -const CHECK_IF_STAGINGDEPLOYCASH_IS_LOCKED_MOCK_STEP = utils.getMockStep( +const GET_MERGED_PULL_REQUEST_MOCK_STEP__CHOOSE_DEPLOY = utils.getMockStep( + 'Get merged pull request', + 'Getting merged pull request', + 'CHOOSE_DEPLOY_ACTIONS', + ['github_token'], + null, + {number: '123', labels: '[]'}, +); +const CHECK_IF_STAGINGDEPLOYCASH_IS_LOCKED_MOCK_STEP__LOCKED = utils.getMockStep( 'Check if StagingDeployCash is locked', 'Checking StagingDeployCash', 'CHOOSE_DEPLOY_ACTIONS', ['GITHUB_TOKEN'], null, - {IS_LOCKED: 'true'}, + {IS_LOCKED: true}, ); -const CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS = [ +const CHECK_IF_STAGINGDEPLOYCASH_IS_LOCKED_MOCK_STEP__UNLOCKED = utils.getMockStep( + 'Check if StagingDeployCash is locked', + 'Checking StagingDeployCash', + 'CHOOSE_DEPLOY_ACTIONS', + ['GITHUB_TOKEN'], + null, + {IS_LOCKED: false}, +); +const CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__STAGING_LOCKED = [ + GET_MERGED_PULL_REQUEST_MOCK_STEP__CHOOSE_DEPLOY, + CHECK_IF_STAGINGDEPLOYCASH_IS_LOCKED_MOCK_STEP__LOCKED, + + // steps 3-5 run normally +]; +const CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__CP_LABEL__STAGING_LOCKED = [ + GET_MERGED_PULL_REQUEST_MOCK_STEP__CHOOSE_DEPLOY__CP_LABEL, + CHECK_IF_STAGINGDEPLOYCASH_IS_LOCKED_MOCK_STEP__LOCKED, + + // steps 3-5 run normally +]; +const CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__STAGING_UNLOCKED = [ GET_MERGED_PULL_REQUEST_MOCK_STEP__CHOOSE_DEPLOY, - CHECK_IF_STAGINGDEPLOYCASH_IS_LOCKED_MOCK_STEP, + CHECK_IF_STAGINGDEPLOYCASH_IS_LOCKED_MOCK_STEP__UNLOCKED, + + // steps 3-5 run normally +]; +const CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__CP_LABEL__STAGING_UNLOCKED = [ + GET_MERGED_PULL_REQUEST_MOCK_STEP__CHOOSE_DEPLOY__CP_LABEL, + CHECK_IF_STAGINGDEPLOYCASH_IS_LOCKED_MOCK_STEP__UNLOCKED, // steps 3-5 run normally ]; @@ -73,6 +107,9 @@ const CREATE_NEW_VERSION_MOCK_STEP = utils.getMockStep( 'Create new version', 'Creating new version', 'CREATE_NEW_VERSION', + null, + null, + {NEW_VERSION: '1.2.3'}, ); const CREATE_NEW_VERSION_JOB_MOCK_STEPS = [ CREATE_NEW_VERSION_MOCK_STEP, @@ -90,16 +127,19 @@ const UPDATE_STAGING_BRANCH_MOCK_STEP = utils.getMockStep( 'Update staging branch from main', 'Updating staging branch', 'UPDATE_STAGING', + ['TARGET_BRANCH', 'OS_BOTIFY_TOKEN', 'GPG_PASSPHRASE'], ); const CHERRYPICK_PR_MOCK_STEP = utils.getMockStep( 'Cherry-pick PR to staging', 'Cherry picking', 'UPDATE_STAGING', + ['GITHUB_TOKEN', 'WORKFLOW', 'INPUTS'], ); const CHECKOUT_STAGING_MOCK_STEP = utils.getMockStep( 'Checkout staging', 'Checking out staging', 'UPDATE_STAGING', + ['ref', 'fetch-depth'], ); const TAG_STAGING_MOCK_STEP = utils.getMockStep( 'Tag staging', @@ -110,29 +150,35 @@ const UPDATE_STAGINGDEPLOYCASH_MOCK_STEP = utils.getMockStep( 'Update StagingDeployCash', 'Updating StagingDeployCash', 'UPDATE_STAGING', + ['GITHUB_TOKEN', 'NPM_VERSION'], ); const FIND_OPEN_STAGINGDEPLOYCASH_MOCK_STEP = utils.getMockStep( 'Find open StagingDeployCash', 'Finding open StagingDeployCash', 'UPDATE_STAGING', null, - null, + ['GITHUB_TOKEN'], {STAGING_DEPLOY_CASH: '1234'}, ); const COMMENT_TO_ALERT_APPLAUSE_CHERRYPICK_MOCK_STEP = utils.getMockStep( 'Comment in StagingDeployCash to alert Applause that a new pull request has been cherry-picked', 'Commenting in StagingDeployCash', 'UPDATE_STAGING', + null, + ['GITHUB_TOKEN'], ); const WAIT_FOR_STAGING_DEPLOYS_MOCK_STEP = utils.getMockStep( 'Wait for staging deploys to finish', 'Waiting for staging deploy to finish', 'UPDATE_STAGING', + ['GITHUB_TOKEN', 'TAG'], ); const COMMENT_TO_ALERT_APPLAUSE_DEPLOY_MOCK_STEP = utils.getMockStep( 'Comment in StagingDeployCash to alert Applause that cherry-picked pull request has been deployed.', 'Commenting in StagingDeployCash', 'UPDATE_STAGING', + null, + ['GITHUB_TOKEN'], ); const ANNOUNCE_FAILED_WORKFLOW_IN_SLACK_MOCK_STEP = utils.getMockStep( 'Announce failed workflow in Slack', @@ -168,7 +214,7 @@ const CHECK_TEAM_MEMBERSHIP_MOCK_STEP__TRUE = utils.getMockStep( 'IS_EXPENSIFY_EMPLOYEE', ['GITHUB_TOKEN', 'username', 'team'], null, - {isTeamMember: 'true'}, + {isTeamMember: true}, ); const IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE = [ GET_MERGED_PULL_REQUEST_MOCK_STEP__IS_EXPENSIFY_EMPLOYEE, @@ -180,7 +226,7 @@ const CHECK_TEAM_MEMBERSHIP_MOCK_STEP__FALSE = utils.getMockStep( 'IS_EXPENSIFY_EMPLOYEE', ['GITHUB_TOKEN', 'username', 'team'], null, - {isTeamMember: 'false'}, + {isTeamMember: false}, ); const IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__FALSE = [ GET_MERGED_PULL_REQUEST_MOCK_STEP__IS_EXPENSIFY_EMPLOYEE, @@ -411,7 +457,10 @@ module.exports = { LINT_JOB_MOCK_STEPS, TEST_JOB_MOCK_STEPS, CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, - CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS, + CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__STAGING_LOCKED, + CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__CP_LABEL__STAGING_LOCKED, + CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__STAGING_UNLOCKED, + CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__CP_LABEL__STAGING_UNLOCKED, SKIP_DEPLOY_JOB_MOCK_STEPS, CREATE_NEW_VERSION_JOB_MOCK_STEPS, UPDATE_STAGING_JOB_MOCK_STEPS, diff --git a/workflow_tests/preDeploy.test.js b/workflow_tests/preDeploy.test.js index 3f70ffb8428b..f491832a82b2 100644 --- a/workflow_tests/preDeploy.test.js +++ b/workflow_tests/preDeploy.test.js @@ -66,7 +66,9 @@ describe('test workflow preDeploy', () => { act, 'pull_request', {head: {ref: 'main'}}, - {OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook'}, + { + OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_s3cr3t_p455word', + }, 'dummy_github_token', ); @@ -75,7 +77,7 @@ describe('test workflow preDeploy', () => { lint: mocks.LINT_JOB_MOCK_STEPS, test: mocks.TEST_JOB_MOCK_STEPS, confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, - chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS, + chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__CP_LABEL__STAGING_UNLOCKED, skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, createNewVersion: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, @@ -112,7 +114,9 @@ describe('test workflow preDeploy', () => { act, 'pull_request', {head: {ref: 'main'}}, - {OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook'}, + { + OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_s3cr3t_p455word', + }, 'dummy_github_token', ); const testMockSteps = { @@ -130,7 +134,7 @@ describe('test workflow preDeploy', () => { ], test: mocks.TEST_JOB_MOCK_STEPS, confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, - chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS, + chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__CP_LABEL__STAGING_UNLOCKED, skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, createNewVersion: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, @@ -188,7 +192,9 @@ describe('test workflow preDeploy', () => { act, 'pull_request', {head: {ref: 'main'}}, - {OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook'}, + { + OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_s3cr3t_p455word', + }, 'dummy_github_token', ); const testMockSteps = { @@ -206,7 +212,7 @@ describe('test workflow preDeploy', () => { ), ], confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, - chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS, + chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__CP_LABEL__STAGING_UNLOCKED, skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, createNewVersion: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, @@ -264,14 +270,16 @@ describe('test workflow preDeploy', () => { act, 'pull_request', {head: {ref: 'main'}}, - {OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook'}, + { + OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_s3cr3t_p455word', + }, 'dummy_github_token', ); const testMockSteps = { lint: mocks.LINT_JOB_MOCK_STEPS, test: mocks.TEST_JOB_MOCK_STEPS, confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, - chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS, + chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__CP_LABEL__STAGING_UNLOCKED, skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, createNewVersion: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, @@ -304,14 +312,16 @@ describe('test workflow preDeploy', () => { act, 'pull_request', {head: {ref: 'main'}}, - {OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'OSBotify', SLACK_WEBHOOK: 'dummy_slack_webhook'}, + { + OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'OSBotify', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_s3cr3t_p455word', + }, 'dummy_github_token', ); const testMockSteps = { lint: mocks.LINT_JOB_MOCK_STEPS, test: mocks.TEST_JOB_MOCK_STEPS, confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, - chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS, + chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__CP_LABEL__STAGING_UNLOCKED, skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, createNewVersion: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, @@ -340,14 +350,16 @@ describe('test workflow preDeploy', () => { act, 'pull_request', {head: {ref: 'main'}}, - {OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook'}, + { + OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_s3cr3t_p455word', + }, 'dummy_github_token', ); const testMockSteps = { lint: mocks.LINT_JOB_MOCK_STEPS, test: mocks.TEST_JOB_MOCK_STEPS, confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, - chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS, + chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__CP_LABEL__STAGING_UNLOCKED, skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, createNewVersion: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, @@ -376,14 +388,16 @@ describe('test workflow preDeploy', () => { act, 'pull_request', {head: {ref: 'main'}}, - {OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook'}, + { + OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_s3cr3t_p455word', + }, 'dummy_github_token', ); const testMockSteps = { lint: mocks.LINT_JOB_MOCK_STEPS, test: mocks.TEST_JOB_MOCK_STEPS, confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, - chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS, + chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__CP_LABEL__STAGING_UNLOCKED, skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, createNewVersion: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, @@ -412,14 +426,16 @@ describe('test workflow preDeploy', () => { act, 'pull_request', {head: {ref: 'main'}}, - {OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook'}, + { + OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_s3cr3t_p455word', + }, 'dummy_github_token', ); const testMockSteps = { lint: mocks.LINT_JOB_MOCK_STEPS, test: mocks.TEST_JOB_MOCK_STEPS, confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, - chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS, + chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__CP_LABEL__STAGING_UNLOCKED, skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, createNewVersion: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, @@ -440,4 +456,320 @@ describe('test workflow preDeploy', () => { assertions.assertNewContributorWelcomeMessageJobExecuted(result, true, false, true); }, 60000); }); + + describe('skip deploy', () => { + test('no CP label, staging locked, not automated PR - deploy skipped and comment left', async () => { + const repoPath = mockGithub.repo.getPath('testWorkflowsRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); + let act = new kieActJs.Act(repoPath, workflowPath); + act = utils.setUpActParams( + act, + 'pull_request', + {head: {ref: 'main'}}, + {OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook'}, + 'dummy_github_token', + ); + const testMockSteps = { + lint: mocks.LINT_JOB_MOCK_STEPS, + test: mocks.TEST_JOB_MOCK_STEPS, + confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, + chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__STAGING_LOCKED, + skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, + createNewVersion: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, + updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, + isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, + newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, + 'e2e-tests': mocks.E2E_TESTS_JOB_MOCK_STEPS, + }; + const result = await act + .runEvent('push', { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + }); + assertions.assertLintJobExecuted(result); + assertions.assertTestJobExecuted(result); + assertions.assertIsExpensifyEmployeeJobExecuted(result); + assertions.assertE2ETestsJobExecuted(result, false); // Act does not support ubuntu-20.04-64core runner and omits the job + assertions.assertChooseDeployActionsJobExecuted(result); + assertions.assertSkipDeployJobExecuted(result); + assertions.assertCreateNewVersionJobExecuted(result, false); + assertions.assertUpdateStagingJobExecuted(result, false, false); + }, 60000); + + test('no CP label, staging locked, automated PR - deploy skipped, but no comment left', async () => { + const repoPath = mockGithub.repo.getPath('testWorkflowsRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); + let act = new kieActJs.Act(repoPath, workflowPath); + act = utils.setUpActParams( + act, + 'pull_request', + {head: {ref: 'main'}}, + {OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'OSBotify', SLACK_WEBHOOK: 'dummy_slack_webhook'}, + 'dummy_github_token', + ); + const testMockSteps = { + lint: mocks.LINT_JOB_MOCK_STEPS, + test: mocks.TEST_JOB_MOCK_STEPS, + confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, + chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__STAGING_LOCKED, + skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, + createNewVersion: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, + updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, + isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, + newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, + 'e2e-tests': mocks.E2E_TESTS_JOB_MOCK_STEPS, + }; + const result = await act + .runEvent('push', { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + }); + assertions.assertLintJobExecuted(result); + assertions.assertTestJobExecuted(result); + assertions.assertIsExpensifyEmployeeJobExecuted(result); + assertions.assertE2ETestsJobExecuted(result, false); // Act does not support ubuntu-20.04-64core runner and omits the job + assertions.assertChooseDeployActionsJobExecuted(result); + assertions.assertSkipDeployJobExecuted(result, false); + assertions.assertCreateNewVersionJobExecuted(result, false); + assertions.assertUpdateStagingJobExecuted(result, false, false); + }, 60000); + + test('no CP label, staging not locked, not automated PR - proceed with deploy', async () => { + const repoPath = mockGithub.repo.getPath('testWorkflowsRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); + let act = new kieActJs.Act(repoPath, workflowPath); + act = utils.setUpActParams( + act, + 'pull_request', + {head: {ref: 'main'}}, + { + OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_s3cr3t_p455word', + }, + 'dummy_github_token', + ); + const testMockSteps = { + lint: mocks.LINT_JOB_MOCK_STEPS, + test: mocks.TEST_JOB_MOCK_STEPS, + confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, + chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__STAGING_UNLOCKED, + skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, + createNewVersion: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, + updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, + isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, + newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, + 'e2e-tests': mocks.E2E_TESTS_JOB_MOCK_STEPS, + }; + const result = await act + .runEvent('push', { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + }); + assertions.assertLintJobExecuted(result); + assertions.assertTestJobExecuted(result); + assertions.assertIsExpensifyEmployeeJobExecuted(result); + assertions.assertE2ETestsJobExecuted(result, false); // Act does not support ubuntu-20.04-64core runner and omits the job + assertions.assertChooseDeployActionsJobExecuted(result); + assertions.assertSkipDeployJobExecuted(result, false); + assertions.assertCreateNewVersionJobExecuted(result); + assertions.assertUpdateStagingJobExecuted(result, true, false); + }, 60000); + + test('no CP label, staging not locked, automated PR - deploy skipped, but no comment left', async () => { + const repoPath = mockGithub.repo.getPath('testWorkflowsRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); + let act = new kieActJs.Act(repoPath, workflowPath); + act = utils.setUpActParams( + act, + 'pull_request', + {head: {ref: 'main'}}, + {OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'OSBotify', SLACK_WEBHOOK: 'dummy_slack_webhook'}, + 'dummy_github_token', + ); + const testMockSteps = { + lint: mocks.LINT_JOB_MOCK_STEPS, + test: mocks.TEST_JOB_MOCK_STEPS, + confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, + chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__STAGING_UNLOCKED, + skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, + createNewVersion: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, + updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, + isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, + newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, + 'e2e-tests': mocks.E2E_TESTS_JOB_MOCK_STEPS, + }; + const result = await act + .runEvent('push', { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + }); + assertions.assertLintJobExecuted(result); + assertions.assertTestJobExecuted(result); + assertions.assertIsExpensifyEmployeeJobExecuted(result); + assertions.assertE2ETestsJobExecuted(result, false); // Act does not support ubuntu-20.04-64core runner and omits the job + assertions.assertChooseDeployActionsJobExecuted(result); + assertions.assertSkipDeployJobExecuted(result, false); + assertions.assertCreateNewVersionJobExecuted(result, false); + assertions.assertUpdateStagingJobExecuted(result, false, false); + }, 60000); + + test('CP label, staging locked, not automated PR - proceed with deploy', async () => { + const repoPath = mockGithub.repo.getPath('testWorkflowsRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); + let act = new kieActJs.Act(repoPath, workflowPath); + act = utils.setUpActParams( + act, + 'pull_request', + {head: {ref: 'main'}}, + { + OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_s3cr3t_p455word', + }, + 'dummy_github_token', + ); + const testMockSteps = { + lint: mocks.LINT_JOB_MOCK_STEPS, + test: mocks.TEST_JOB_MOCK_STEPS, + confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, + chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__CP_LABEL__STAGING_LOCKED, + skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, + createNewVersion: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, + updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, + isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, + newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, + 'e2e-tests': mocks.E2E_TESTS_JOB_MOCK_STEPS, + }; + const result = await act + .runEvent('push', { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + }); + assertions.assertLintJobExecuted(result); + assertions.assertTestJobExecuted(result); + assertions.assertIsExpensifyEmployeeJobExecuted(result); + assertions.assertE2ETestsJobExecuted(result, false); // Act does not support ubuntu-20.04-64core runner and omits the job + assertions.assertChooseDeployActionsJobExecuted(result); + assertions.assertSkipDeployJobExecuted(result, false); + assertions.assertCreateNewVersionJobExecuted(result); + assertions.assertUpdateStagingJobExecuted(result, true, true); + }, 60000); + + test('CP label, staging locked, automated PR - proceed with deploy', async () => { + const repoPath = mockGithub.repo.getPath('testWorkflowsRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); + let act = new kieActJs.Act(repoPath, workflowPath); + act = utils.setUpActParams( + act, + 'pull_request', + {head: {ref: 'main'}}, + { + OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'OSBotify', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_s3cr3t_p455word', + }, + 'dummy_github_token', + ); + const testMockSteps = { + lint: mocks.LINT_JOB_MOCK_STEPS, + test: mocks.TEST_JOB_MOCK_STEPS, + confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, + chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__CP_LABEL__STAGING_LOCKED, + skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, + createNewVersion: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, + updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, + isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, + newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, + 'e2e-tests': mocks.E2E_TESTS_JOB_MOCK_STEPS, + }; + const result = await act + .runEvent('push', { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + }); + assertions.assertLintJobExecuted(result); + assertions.assertTestJobExecuted(result); + assertions.assertIsExpensifyEmployeeJobExecuted(result); + assertions.assertE2ETestsJobExecuted(result, false); // Act does not support ubuntu-20.04-64core runner and omits the job + assertions.assertChooseDeployActionsJobExecuted(result); + assertions.assertSkipDeployJobExecuted(result, false); + assertions.assertCreateNewVersionJobExecuted(result); + assertions.assertUpdateStagingJobExecuted(result, true, true); + }, 60000); + + test('CP label, staging not locked, not automated PR - proceed with deploy', async () => { + const repoPath = mockGithub.repo.getPath('testWorkflowsRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); + let act = new kieActJs.Act(repoPath, workflowPath); + act = utils.setUpActParams( + act, + 'pull_request', + {head: {ref: 'main'}}, + { + OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_s3cr3t_p455word', + }, + 'dummy_github_token', + ); + const testMockSteps = { + lint: mocks.LINT_JOB_MOCK_STEPS, + test: mocks.TEST_JOB_MOCK_STEPS, + confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, + chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__CP_LABEL__STAGING_UNLOCKED, + skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, + createNewVersion: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, + updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, + isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, + newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, + 'e2e-tests': mocks.E2E_TESTS_JOB_MOCK_STEPS, + }; + const result = await act + .runEvent('push', { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + }); + assertions.assertLintJobExecuted(result); + assertions.assertTestJobExecuted(result); + assertions.assertIsExpensifyEmployeeJobExecuted(result); + assertions.assertE2ETestsJobExecuted(result, false); // Act does not support ubuntu-20.04-64core runner and omits the job + assertions.assertChooseDeployActionsJobExecuted(result); + assertions.assertSkipDeployJobExecuted(result, false); + assertions.assertCreateNewVersionJobExecuted(result); + assertions.assertUpdateStagingJobExecuted(result, true, false); + }, 60000); + + test('CP label, staging not locked, automated PR - proceed with deploy', async () => { + const repoPath = mockGithub.repo.getPath('testWorkflowsRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); + let act = new kieActJs.Act(repoPath, workflowPath); + act = utils.setUpActParams( + act, + 'pull_request', + {head: {ref: 'main'}}, + { + OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'OSBotify', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_s3cr3t_p455word', + }, + 'dummy_github_token', + ); + const testMockSteps = { + lint: mocks.LINT_JOB_MOCK_STEPS, + test: mocks.TEST_JOB_MOCK_STEPS, + confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, + chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__CP_LABEL__STAGING_UNLOCKED, + skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, + createNewVersion: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, + updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, + isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, + newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, + 'e2e-tests': mocks.E2E_TESTS_JOB_MOCK_STEPS, + }; + const result = await act + .runEvent('push', { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + }); + assertions.assertLintJobExecuted(result); + assertions.assertTestJobExecuted(result); + assertions.assertIsExpensifyEmployeeJobExecuted(result); + assertions.assertE2ETestsJobExecuted(result, false); // Act does not support ubuntu-20.04-64core runner and omits the job + assertions.assertChooseDeployActionsJobExecuted(result); + assertions.assertSkipDeployJobExecuted(result, false); + assertions.assertCreateNewVersionJobExecuted(result); + assertions.assertUpdateStagingJobExecuted(result, true, false); + }, 60000); + }); }); From 79c8f64d25f2f25d40ceb49c1cb5edfd49bb0360 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Mon, 27 Feb 2023 12:15:27 +0100 Subject: [PATCH 017/504] Add tests for push to a different branch [WiP] Added the test checking if the workflow does not get executed if the code is pushed to a different branch than main See: https://github.com/Expensify/App/issues/13604 --- workflow_tests/preDeploy.test.js | 44 ++++++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/workflow_tests/preDeploy.test.js b/workflow_tests/preDeploy.test.js index f491832a82b2..bdac3c60fa1d 100644 --- a/workflow_tests/preDeploy.test.js +++ b/workflow_tests/preDeploy.test.js @@ -51,7 +51,7 @@ afterEach(async () => { }); describe('test workflow preDeploy', () => { - test('push to main', async () => { + test('push to main - workflow executes', async () => { // get path to the local test repo const repoPath = mockGithub.repo.getPath('testWorkflowsRepo') || ''; @@ -105,6 +105,46 @@ describe('test workflow preDeploy', () => { assertions.assertUpdateStagingJobExecuted(result); }, 60000); + test('push to different branch - workflow does not execute', async () => { + const repoPath = mockGithub.repo.getPath('testWorkflowsRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); + let act = new kieActJs.Act(repoPath, workflowPath); + act = utils.setUpActParams( + act, + 'pull_request', + {head: {ref: 'not_main'}}, + { + OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_s3cr3t_p455word', + }, + 'dummy_github_token', + ); + const testMockSteps = { + lint: mocks.LINT_JOB_MOCK_STEPS, + test: mocks.TEST_JOB_MOCK_STEPS, + confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, + chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__CP_LABEL__STAGING_UNLOCKED, + skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, + createNewVersion: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, + updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, + isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, + newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, + 'e2e-tests': mocks.E2E_TESTS_JOB_MOCK_STEPS, + }; + const result = await act + .runEvent('push', { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + }); + assertions.assertLintJobExecuted(result, false); + assertions.assertTestJobExecuted(result, false); + assertions.assertIsExpensifyEmployeeJobExecuted(result, false); + assertions.assertE2ETestsJobExecuted(result, false); // Act does not support ubuntu-20.04-64core runner and omits the job + assertions.assertChooseDeployActionsJobExecuted(result, false); + assertions.assertSkipDeployJobExecuted(result, false); + assertions.assertCreateNewVersionJobExecuted(result, false); + assertions.assertUpdateStagingJobExecuted(result, false); + }, 60000); + describe('confirm passing build', () => { test('lint job failed - workflow exits', async () => { const repoPath = mockGithub.repo.getPath('testWorkflowsRepo') || ''; @@ -457,7 +497,7 @@ describe('test workflow preDeploy', () => { }, 60000); }); - describe('skip deploy', () => { + describe('choose deploy actions', () => { test('no CP label, staging locked, not automated PR - deploy skipped and comment left', async () => { const repoPath = mockGithub.repo.getPath('testWorkflowsRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); From 3922e7cedfae55219d531297a495f55a1d736782 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Mon, 27 Feb 2023 12:35:35 +0100 Subject: [PATCH 018/504] Add test for events different from push [WiP] Added the test checking if the workflow does not get executed if the triggering event is different from `push` See: https://github.com/Expensify/App/issues/13604 --- workflow_tests/preDeploy.test.js | 99 ++++++++++++++++++++++++++------ 1 file changed, 82 insertions(+), 17 deletions(-) diff --git a/workflow_tests/preDeploy.test.js b/workflow_tests/preDeploy.test.js index bdac3c60fa1d..ff11b4420a28 100644 --- a/workflow_tests/preDeploy.test.js +++ b/workflow_tests/preDeploy.test.js @@ -64,7 +64,7 @@ describe('test workflow preDeploy', () => { // set run parameters act = utils.setUpActParams( act, - 'pull_request', + 'push', {head: {ref: 'main'}}, { OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_s3cr3t_p455word', @@ -111,7 +111,7 @@ describe('test workflow preDeploy', () => { let act = new kieActJs.Act(repoPath, workflowPath); act = utils.setUpActParams( act, - 'pull_request', + 'push', {head: {ref: 'not_main'}}, { OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_s3cr3t_p455word', @@ -145,6 +145,71 @@ describe('test workflow preDeploy', () => { assertions.assertUpdateStagingJobExecuted(result, false); }, 60000); + test('different event than push - workflow does not execute', async () => { + const repoPath = mockGithub.repo.getPath('testWorkflowsRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); + let act = new kieActJs.Act(repoPath, workflowPath); + const testMockSteps = { + lint: mocks.LINT_JOB_MOCK_STEPS, + test: mocks.TEST_JOB_MOCK_STEPS, + confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, + chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__CP_LABEL__STAGING_UNLOCKED, + skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, + createNewVersion: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, + updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, + isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, + newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, + 'e2e-tests': mocks.E2E_TESTS_JOB_MOCK_STEPS, + }; + + // pull_request + act = utils.setUpActParams( + act, + 'pull_request', + {head: {ref: 'main'}}, + { + OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_s3cr3t_p455word', + }, + 'dummy_github_token', + ); + let result = await act + .runEvent('pull_request', { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + }); + assertions.assertLintJobExecuted(result, false); + assertions.assertTestJobExecuted(result, false); + assertions.assertIsExpensifyEmployeeJobExecuted(result, false); + assertions.assertE2ETestsJobExecuted(result, false); // Act does not support ubuntu-20.04-64core runner and omits the job + assertions.assertChooseDeployActionsJobExecuted(result, false); + assertions.assertSkipDeployJobExecuted(result, false); + assertions.assertCreateNewVersionJobExecuted(result, false); + assertions.assertUpdateStagingJobExecuted(result, false); + + // workflow_dispatch + act = utils.setUpActParams( + act, + 'workflow_dispatch', + { + OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_s3cr3t_p455word', + }, + 'dummy_github_token', + ); + result = await act + .runEvent('workflow_dispatch', { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + }); + assertions.assertLintJobExecuted(result, false); + assertions.assertTestJobExecuted(result, false); + assertions.assertIsExpensifyEmployeeJobExecuted(result, false); + assertions.assertE2ETestsJobExecuted(result, false); // Act does not support ubuntu-20.04-64core runner and omits the job + assertions.assertChooseDeployActionsJobExecuted(result, false); + assertions.assertSkipDeployJobExecuted(result, false); + assertions.assertCreateNewVersionJobExecuted(result, false); + assertions.assertUpdateStagingJobExecuted(result, false); + }, 60000); + describe('confirm passing build', () => { test('lint job failed - workflow exits', async () => { const repoPath = mockGithub.repo.getPath('testWorkflowsRepo') || ''; @@ -152,7 +217,7 @@ describe('test workflow preDeploy', () => { let act = new kieActJs.Act(repoPath, workflowPath); act = utils.setUpActParams( act, - 'pull_request', + 'push', {head: {ref: 'main'}}, { OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_s3cr3t_p455word', @@ -230,7 +295,7 @@ describe('test workflow preDeploy', () => { let act = new kieActJs.Act(repoPath, workflowPath); act = utils.setUpActParams( act, - 'pull_request', + 'push', {head: {ref: 'main'}}, { OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_s3cr3t_p455word', @@ -308,7 +373,7 @@ describe('test workflow preDeploy', () => { let act = new kieActJs.Act(repoPath, workflowPath); act = utils.setUpActParams( act, - 'pull_request', + 'push', {head: {ref: 'main'}}, { OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_s3cr3t_p455word', @@ -350,7 +415,7 @@ describe('test workflow preDeploy', () => { let act = new kieActJs.Act(repoPath, workflowPath); act = utils.setUpActParams( act, - 'pull_request', + 'push', {head: {ref: 'main'}}, { OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'OSBotify', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_s3cr3t_p455word', @@ -388,7 +453,7 @@ describe('test workflow preDeploy', () => { let act = new kieActJs.Act(repoPath, workflowPath); act = utils.setUpActParams( act, - 'pull_request', + 'push', {head: {ref: 'main'}}, { OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_s3cr3t_p455word', @@ -426,7 +491,7 @@ describe('test workflow preDeploy', () => { let act = new kieActJs.Act(repoPath, workflowPath); act = utils.setUpActParams( act, - 'pull_request', + 'push', {head: {ref: 'main'}}, { OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_s3cr3t_p455word', @@ -464,7 +529,7 @@ describe('test workflow preDeploy', () => { let act = new kieActJs.Act(repoPath, workflowPath); act = utils.setUpActParams( act, - 'pull_request', + 'push', {head: {ref: 'main'}}, { OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_s3cr3t_p455word', @@ -504,7 +569,7 @@ describe('test workflow preDeploy', () => { let act = new kieActJs.Act(repoPath, workflowPath); act = utils.setUpActParams( act, - 'pull_request', + 'push', {head: {ref: 'main'}}, {OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook'}, 'dummy_github_token', @@ -542,7 +607,7 @@ describe('test workflow preDeploy', () => { let act = new kieActJs.Act(repoPath, workflowPath); act = utils.setUpActParams( act, - 'pull_request', + 'push', {head: {ref: 'main'}}, {OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'OSBotify', SLACK_WEBHOOK: 'dummy_slack_webhook'}, 'dummy_github_token', @@ -580,7 +645,7 @@ describe('test workflow preDeploy', () => { let act = new kieActJs.Act(repoPath, workflowPath); act = utils.setUpActParams( act, - 'pull_request', + 'push', {head: {ref: 'main'}}, { OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_s3cr3t_p455word', @@ -620,7 +685,7 @@ describe('test workflow preDeploy', () => { let act = new kieActJs.Act(repoPath, workflowPath); act = utils.setUpActParams( act, - 'pull_request', + 'push', {head: {ref: 'main'}}, {OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'OSBotify', SLACK_WEBHOOK: 'dummy_slack_webhook'}, 'dummy_github_token', @@ -658,7 +723,7 @@ describe('test workflow preDeploy', () => { let act = new kieActJs.Act(repoPath, workflowPath); act = utils.setUpActParams( act, - 'pull_request', + 'push', {head: {ref: 'main'}}, { OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_s3cr3t_p455word', @@ -698,7 +763,7 @@ describe('test workflow preDeploy', () => { let act = new kieActJs.Act(repoPath, workflowPath); act = utils.setUpActParams( act, - 'pull_request', + 'push', {head: {ref: 'main'}}, { OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'OSBotify', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_s3cr3t_p455word', @@ -738,7 +803,7 @@ describe('test workflow preDeploy', () => { let act = new kieActJs.Act(repoPath, workflowPath); act = utils.setUpActParams( act, - 'pull_request', + 'push', {head: {ref: 'main'}}, { OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_s3cr3t_p455word', @@ -778,7 +843,7 @@ describe('test workflow preDeploy', () => { let act = new kieActJs.Act(repoPath, workflowPath); act = utils.setUpActParams( act, - 'pull_request', + 'push', {head: {ref: 'main'}}, { OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'OSBotify', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_s3cr3t_p455word', From 1e578c8dd6a8440678587abdeb4833c56d42256e Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Mon, 27 Feb 2023 12:40:51 +0100 Subject: [PATCH 019/504] Add documentation skeleton [WiP] Started working on the tests documentation See: https://github.com/Expensify/App/issues/13604 --- workflow_tests/README.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 workflow_tests/README.md diff --git a/workflow_tests/README.md b/workflow_tests/README.md new file mode 100644 index 000000000000..71dbc5f7d27e --- /dev/null +++ b/workflow_tests/README.md @@ -0,0 +1,17 @@ +# Testing GitHub Actions workflows locally + +## Components + +The workflow testing framework consists mainly of 3 components: + +- [Jest](https://jestjs.io/) - testing framework, also used for [application tests](https://github.com/Expensify/App/tree/main/tests) +- [Mock-github](https://github.com/kiegroup/mock-github) - package allowing for creation of local repositories, which can be used to make sure that the workflow tests have access only to these files that they should and that they won't modify the actual repository +- [Act-js](https://github.com/kiegroup/act-js) - JS wrapper around [Act](https://github.com/nektos/act). Act is a tool that allows to run GitHub Actions workflows locally, and Act-js allows to configure and run Act from JS code, like Jest tests. It also provides additional tools like mocking workflow steps and retrieving the workflow output a JSON, which allows for comparison of the actual output with expected values + +## Limitations + +Not all workflows can always be tested this way, for example: + +- Act and Act-js do not support all the runner types available in GitHub Actions, like `macOS` runners or some specific version of `Ubuntu` runners like `ubuntu-20.04-64core`. In these cases the job will be omitted entirely and cannot be tested +- Testing more complex workflows in their entirety can be extremely time-consuming and cumbersome. It is often optimal to mock most of the steps with expressions printing the input and output conditions +- Due to the way `Act` and `Act-js` handle workflow output, not much can be checked in the test. What is available, namely whether the job/step executed or not, whether it was successful or not and what its printed output was, should be enough in most scenarios From 8dbd8f86ebb6dae06fabd2a4c717119ab33db0bb Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Mon, 27 Feb 2023 13:08:51 +0100 Subject: [PATCH 020/504] Add file structure to documentation [WiP] Added a new section to documentation with structure of the workflow testing framework See: https://github.com/Expensify/App/issues/13604 --- workflow_tests/README.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/workflow_tests/README.md b/workflow_tests/README.md index 71dbc5f7d27e..94177affd971 100644 --- a/workflow_tests/README.md +++ b/workflow_tests/README.md @@ -15,3 +15,27 @@ Not all workflows can always be tested this way, for example: - Act and Act-js do not support all the runner types available in GitHub Actions, like `macOS` runners or some specific version of `Ubuntu` runners like `ubuntu-20.04-64core`. In these cases the job will be omitted entirely and cannot be tested - Testing more complex workflows in their entirety can be extremely time-consuming and cumbersome. It is often optimal to mock most of the steps with expressions printing the input and output conditions - Due to the way `Act` and `Act-js` handle workflow output, not much can be checked in the test. What is available, namely whether the job/step executed or not, whether it was successful or not and what its printed output was, should be enough in most scenarios + +## File structure + +The testing framework file structure within the repository is as follows: + +- `App/` - main application folder + - `.github/` - GitHub Actions folder + - `workflows/` - workflows folder + - `.yml` - workflow file + - `...` - other workflow files + - `...` - other GitHub Actions files + - `...` - other application files + - `workflow_tests/` - workflow testing folder + - `jest.config.ts` - `Jest` configuration file + - `README.md` - this readme file + - `utils.js` - various utility functions used in multiple tests + - `.test.js` - test suite file for a GitHub Actions workflow named `` + - `...` - other test suites + - `mocks/` - folder with step mock definitions + - `Mocks.js` - file with step mock definitions for the `../.test.js` suite, or for the `` workflow + - `...` - other step mock definition files + - `assertions/` - folder with output assertions + - `Assertions.js` - file with output assertions for the `../.test.js` suite, or for the `` workflow + - `...` - other output assertion files From 29e12e22d32361a39f881216c69f604d0a70d573 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Mon, 27 Feb 2023 14:37:27 +0100 Subject: [PATCH 021/504] Add utils description [WiP] Added a new section to documentation with the description and example usage of utils helper methods See: https://github.com/Expensify/App/issues/13604 --- workflow_tests/README.md | 124 +++++++++++++++++++++++++++++-- workflow_tests/preDeploy.test.js | 1 + 2 files changed, 117 insertions(+), 8 deletions(-) diff --git a/workflow_tests/README.md b/workflow_tests/README.md index 94177affd971..2d4e18aa6bb5 100644 --- a/workflow_tests/README.md +++ b/workflow_tests/README.md @@ -1,41 +1,149 @@ # Testing GitHub Actions workflows locally ## Components - The workflow testing framework consists mainly of 3 components: - - [Jest](https://jestjs.io/) - testing framework, also used for [application tests](https://github.com/Expensify/App/tree/main/tests) - [Mock-github](https://github.com/kiegroup/mock-github) - package allowing for creation of local repositories, which can be used to make sure that the workflow tests have access only to these files that they should and that they won't modify the actual repository - [Act-js](https://github.com/kiegroup/act-js) - JS wrapper around [Act](https://github.com/nektos/act). Act is a tool that allows to run GitHub Actions workflows locally, and Act-js allows to configure and run Act from JS code, like Jest tests. It also provides additional tools like mocking workflow steps and retrieving the workflow output a JSON, which allows for comparison of the actual output with expected values ## Limitations - Not all workflows can always be tested this way, for example: - - Act and Act-js do not support all the runner types available in GitHub Actions, like `macOS` runners or some specific version of `Ubuntu` runners like `ubuntu-20.04-64core`. In these cases the job will be omitted entirely and cannot be tested - Testing more complex workflows in their entirety can be extremely time-consuming and cumbersome. It is often optimal to mock most of the steps with expressions printing the input and output conditions - Due to the way `Act` and `Act-js` handle workflow output, not much can be checked in the test. What is available, namely whether the job/step executed or not, whether it was successful or not and what its printed output was, should be enough in most scenarios ## File structure - The testing framework file structure within the repository is as follows: - - `App/` - main application folder - `.github/` - GitHub Actions folder - `workflows/` - workflows folder - `.yml` - workflow file - `...` - other workflow files - `...` - other GitHub Actions files - - `...` - other application files - `workflow_tests/` - workflow testing folder - `jest.config.ts` - `Jest` configuration file - `README.md` - this readme file - `utils.js` - various utility functions used in multiple tests - `.test.js` - test suite file for a GitHub Actions workflow named `` - - `...` - other test suites - `mocks/` - folder with step mock definitions - `Mocks.js` - file with step mock definitions for the `../.test.js` suite, or for the `` workflow - `...` - other step mock definition files - `assertions/` - folder with output assertions - `Assertions.js` - file with output assertions for the `../.test.js` suite, or for the `` workflow - `...` - other output assertion files + - `...` - other test suites + - `...` - other application files + +## Utility helpers +`utils.js` file provides several helper methods to speed up the tests development and maintenance + +### `setUpActParams` +`setUpActParams` allows for initiating the context in which Act will execute the workflow + +Parameters: +- `act` - instance of previously created `Act` object that will be updated with new params +- `event` - the name of the event, this can be any event name used by GitHub Actions, like `pull_request`, `push`, `workflow_dispatch`, etc. +- `event_options` - object with options of the event, allowing for customising it for different scenarios, for example `push` event can be customised for pushing to different branches with options `{head: {ref: ''}}` +- `secrets` - object with secret values provided, like `{: , ...}` +- `github_token` - value of the GitHub token, analogous to providing `GITHUB_TOKEN` secret + +Returns an updated `Act` object instance + +Example: +```javascript +let act = new kieActJs.Act(repoPath, workflowPath); +act = utils.setUpActParams( + act, + 'push', + {head: {ref: 'main'}}, + {OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_s3cr3t_p455word'}, + 'dummy_github_token', +); +``` + +### `getMockStep` +`getMockStep` allows for creating uniform mock step definitions compatible with `Act-js` and reduces time required, as well as possibility of errors/typos slipping in while developing tests. More complex behaviours have to be mocked manually + +Parameters: +- `name` - name of the step that **must correspond to the `name` in the `.yml` file**, otherwise the step cannot be found +- `message` - the message to be printed to default output when mock gets executed +- `job_id` - an optional id of the job that will be printed in `[]` square brackets along the `message`, useful when assessing the output with many steps from many jobs +- `inputs` - a list of input parameters to be printed, useful when checking if the step had been executed with expected inputs +- `in_envs` - a list of input environment variables, to be printed, useful when checking if the step had been executed in expected environment +- `outputs` - an object with values which should be printed by the mock to `$GITHUB_OUTPUT`, useful for setting the step output +- `out_envs` - an objects with values of environment variables set by the step in `$GITHUB_ENV`, useful for modifying the environment by the mock +- `isSuccessful` - a boolean value indicating whether the step succeeds or not, exits with status `0` (if successful) or `1` (if not) + +Returns an object with step mock definition, ready to be provided to the `Act` object instance + +Example: +```javascript +let mockStep = utils.getMockStep( + 'Name of the step from .yml', + 'Message to be printed', + 'TEST_JOB', + ['INPUT_1', 'INPUT_2'], + ['ENV_1', 'ENV_2'], + {output_1: true, output_2: 'Some Result'}, + {OUT_ENV: 'ENV_VALUE'}, + false, +); +``` +results in +```javascript +{ + name: 'Name of the step from .yml', + mockWith: 'echo [MOCK]' + + ' [TEST_JOB]' + + ' Message to be printed' + + ', INPUT_1="{{ inputs.INPUT_1 }}' + + ', INPUT_2="{{ inputs.INPUT_2 }}' + + ', ENV_1="{{ env.ENV_1 }}' + + ', ENV_1="{{ env.ENV_1 }}' + + '\necho "output_1=true" >> "$GITHUB_OUTPUT"', + + '\necho "output_2=Some Result" >> "$GITHUB_OUTPUT"', + + '\necho "OUT_ENV=ENV_VALUE" >> "$GITHUB_ENV"', + + '\nexit 1', +} +``` + +### `getStepAssertion` +`getStepAssertion` allows for creating uniform assertions for output from executed step, compatible with step mocks provided by `getMockStep` + +Parameters: +- `name` - name of the step, **has to correspond to the name from `.yml` file**, and the name in the step mock if applicable +- `isSuccessful` - boolean value for checking if the step should have exited successfully +- `expectedOutput` - an output that is expected from the step, compared directly - if provided the subsequent parameters are ignored +- `jobId` - an optional expected job identifier +- `message` - expected message printed by the step +- `inputs` - expected input values provided to the step +- `envs` - expected input environment variables for the step + +Returns an object with step expected output definition ready to be provided to `expect()` matcher + +Example: +```javascript +utils.getStepAssertion( + 'Name of the step from .yml', + false, + null, + 'TEST_JOB', + 'Message to be printed', + [{key: 'INPUT_1', value: true}, {key: 'INPUT_2', value: 'Some value'}], + [{key: 'PLAIN_ENV_VAR', value: 'Value'}, {key: 'SECRET_ENV_VAR', value: '***'}], +) +``` +results in +```javascript +{ + name: 'Name of the step from .yml', + status: 1, + output: '[MOCK]' + + ' [TEST_JOB]' + + ' Message to be printed' + + ', INPUT_1=true' + + ', INPUT_2=Some value' + + ', PLAIN_ENV_VAR=Value' + + ', SECRET_ENV_VAR=***', +} +``` diff --git a/workflow_tests/preDeploy.test.js b/workflow_tests/preDeploy.test.js index ff11b4420a28..4a3329cde51d 100644 --- a/workflow_tests/preDeploy.test.js +++ b/workflow_tests/preDeploy.test.js @@ -190,6 +190,7 @@ describe('test workflow preDeploy', () => { act = utils.setUpActParams( act, 'workflow_dispatch', + {}, { OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_s3cr3t_p455word', }, From 489e90296f0d7575232087557a2f94e18dc7dccc Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Mon, 27 Feb 2023 15:40:47 +0100 Subject: [PATCH 022/504] Add breakdown of the test file structure [WiP] Added a new section to documentation with the detail breakdown of the structure of typical test file See: https://github.com/Expensify/App/issues/13604 --- workflow_tests/README.md | 196 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 196 insertions(+) diff --git a/workflow_tests/README.md b/workflow_tests/README.md index 2d4e18aa6bb5..c773099f8500 100644 --- a/workflow_tests/README.md +++ b/workflow_tests/README.md @@ -147,3 +147,199 @@ results in + ', SECRET_ENV_VAR=***', } ``` + +## Typical test file +The following is the typical test file content, which will be followed by a detailed breakdown +```javascript +const path = require('path'); +const kieActJs = require('@kie/act-js'); +const kieMockGithub = require('@kie/mock-github'); +const utils = require('./utils'); +const assertions = require('./assertions/Assertions'); +const mocks = require('./mocks/Mocks'); + +let mockGithub; +const FILES_TO_COPY_INTO_TEST_REPO = [ + { + src: path.resolve(__dirname, '..', '.github', 'actions'), + dest: '.github/actions', + }, + { + src: path.resolve(__dirname, '..', '.github', 'libs'), + dest: '.github/libs', + }, + { + src: path.resolve(__dirname, '..', '.github', 'scripts'), + dest: '.github/scripts', + }, + { + src: path.resolve(__dirname, '..', '.github', 'workflows', '.yml'), + dest: '.github/workflows/.yml', + }, +]; + +beforeEach(async () => { + mockGithub = new kieMockGithub.MockGithub({ + repo: { + testWorkflowsRepo: { + files: FILES_TO_COPY_INTO_TEST_REPO, + }, + }, + }); + + await mockGithub.setup(); +}); + +afterEach(async () => { + await mockGithub.teardown(); +}); + +describe('test some general behaviour', () => { + test('something happens - test if expected happened next', async () => { + // get path to the local test repo + const repoPath = mockGithub.repo.getPath('testWorkflowsRepo') || ''; + + // get path to the workflow file under test + const workflowPath = path.join(repoPath, '.github', 'workflows', '.yml'); + + // instantiate Act in the context of the test repo and given workflow file + let act = new kieActJs.Act(repoPath, workflowPath); + + // set run parameters + act = utils.setUpActParams( + act, + '', + {head: {ref: ''}}, + {'': '', + ); + + // set up mocks + const testMockSteps = { + '': [ + { + name: '', + mockWith: '', + }, + { + name: '', + mockWith: '', + }, + ], + '': [ + utils.getMockStep('', ''), + utils.getMockStep('', ''), + ], + }; + + // run an event and get the result + const result = await act + .runEvent('', { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + }); + + // assert results (some steps can run in parallel to each other so the order is not assured + // therefore we can check which steps have been executed, but not the set job order + assertions.assertSomethingHappend(result); + assertions.assertSomethingDidNotHappen(result, false); + }, timeout); +); +``` + +### Breakdown +Define which files should be copied into the test repo. In this case we copy `actions`, `libs`, `scripts` folders in their entirety and just the one workflow file we want to test +```javascript +const FILES_TO_COPY_INTO_TEST_REPO = [ + { + src: path.resolve(__dirname, '..', '.github', 'actions'), + dest: '.github/actions', + }, + { + src: path.resolve(__dirname, '..', '.github', 'libs'), + dest: '.github/libs', + }, + { + src: path.resolve(__dirname, '..', '.github', 'scripts'), + dest: '.github/scripts', + }, + { + src: path.resolve(__dirname, '..', '.github', 'workflows', '.yml'), + dest: '.github/workflows/.yml', + }, +]; +``` +`beforeEach` gets executed before each test. Here we create the local test repository with the files defined in the `FILES_TO_COPY_INTO_TEST_REPO` variable. `testWorkflowRepo` is the name of the test repo and can be changed to whichever name you choose, just remember to use it later when accessing this repo. _Note that we can't use `beforeAll()` method, because while mocking steps `Act-js` modifies the workflow file copied into the test repo and thus mocking could persist between tests_ +```javascript +beforeEach(async () => { + mockGithub = new kieMockGithub.MockGithub({ + repo: { + testWorkflowsRepo: { + files: FILES_TO_COPY_INTO_TEST_REPO, + }, + }, + }); + + await mockGithub.setup(); +}); +``` +Similarly, `afterEach` gets executed after each test. In this case we remove the test repo after the test finishes +```javascript +afterEach(async () => { + await mockGithub.teardown(); +}); +``` +Get path to the local test repo, useful to have it in a variable +```javascript +const repoPath = mockGithub.repo.getPath('testWorkflowsRepo') || ''; +``` +Get path to the workflow under test. Note that it's the path **in the test repo** +```javascript +const workflowPath = path.join(repoPath, '.github', 'workflows', '.yml'); +``` +Instantiate `Act` object instance. Here we provide the constructor with the path to the test repo (so that `Act` can execute in its context) and the path the workflow file under test (so just the workflow we want to test would be executed) +```javascript +let act = new kieActJs.Act(repoPath, workflowPath); +``` +Set up initial parameters for `Act`. This is where we can set secrets, GitHub token and options for the events (like the name of the branch to which the push has been made, etc.) +```javascript +act = utils.setUpActParams( + act, + '', + {head: {ref: ''}}, + {'': '', +); +``` +Set up step mocks. Here we configure which steps in the workflow should be mocked, and with what behaviour. This takes form of an object with keys corresponding to the names of the jobs in the workflow, and values being mock definitions for specific steps. The steps can be identified either by `id`, `name`, `uses` or `run`. Step mock can be defined either by hand (``) or with the helper method `utils.getMockStep()` (``). Not mocked steps will be executed normally - **make sure this will not have unexpected consequences** +```javascript +const testMockSteps = { + '': [ + { + name: '', + mockWith: '', + }, + { + name: '', + mockWith: '', + }, + ], + '': [ + utils.getMockStep('', ''), + utils.getMockStep('', ''), + ], +}; +``` +Most important part - actually running the event with `Act`. This executes the specified `` in the context of the local test repo created before and with the workflow under test set up. `result` stores the output of `Act` execution, which can then be compared to what was expected. Note that the `workflowFile` is actually path to _workflow folder_ and not the file itself - `Act-js` determines the name of the workflow by itself, and tries to find it in the specified `workflowFile` path, so _providing the full path to the file will fail_ +```javascript +const result = await act + .runEvent('', { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + }); +``` +Assert results are as expected. Here it's usually done with the helper assertion methods defined in the assertions file. Step assertions can be created manually or with `getStepAssertion()` helper method +```javascript +assertions.assertSomethingHappend(result); +assertions.assertSomethingDidNotHappen(result, false); +``` From 949f420cf188c4cce5112ffbb8750b832cd1eae6 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Mon, 27 Feb 2023 15:50:41 +0100 Subject: [PATCH 023/504] Add minor tweaks [WiP] Self-explanatory See: https://github.com/Expensify/App/issues/13604 --- workflow_tests/README.md | 2 +- workflow_tests/preDeploy.test.js | 32 ++++++++++++++++---------------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/workflow_tests/README.md b/workflow_tests/README.md index c773099f8500..30b6f3d6a90d 100644 --- a/workflow_tests/README.md +++ b/workflow_tests/README.md @@ -338,7 +338,7 @@ const result = await act mockSteps: testMockSteps, }); ``` -Assert results are as expected. Here it's usually done with the helper assertion methods defined in the assertions file. Step assertions can be created manually or with `getStepAssertion()` helper method +Assert results are as expected. This can, for example, include using `expect()` to check if the steps that should be executed have indeed been executed, steps that shouldn't run have not been executed, compare statuses (which steps succeeded, which failed) and step outputs. Outputs can include additional information, like input values, environmental variables, secrets (although these are usually not accessible and represented by `***`, this can still be useful to check if the value exists or not). Here it's usually done with the helper assertion methods defined in the assertions file. Step assertions can be created manually or with `getStepAssertion()` helper method ```javascript assertions.assertSomethingHappend(result); assertions.assertSomethingDidNotHappen(result, false); diff --git a/workflow_tests/preDeploy.test.js b/workflow_tests/preDeploy.test.js index 4a3329cde51d..760e738bc1e3 100644 --- a/workflow_tests/preDeploy.test.js +++ b/workflow_tests/preDeploy.test.js @@ -67,7 +67,7 @@ describe('test workflow preDeploy', () => { 'push', {head: {ref: 'main'}}, { - OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_s3cr3t_p455word', + OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', }, 'dummy_github_token', ); @@ -114,7 +114,7 @@ describe('test workflow preDeploy', () => { 'push', {head: {ref: 'not_main'}}, { - OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_s3cr3t_p455word', + OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', }, 'dummy_github_token', ); @@ -168,7 +168,7 @@ describe('test workflow preDeploy', () => { 'pull_request', {head: {ref: 'main'}}, { - OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_s3cr3t_p455word', + OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', }, 'dummy_github_token', ); @@ -192,7 +192,7 @@ describe('test workflow preDeploy', () => { 'workflow_dispatch', {}, { - OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_s3cr3t_p455word', + OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', }, 'dummy_github_token', ); @@ -221,7 +221,7 @@ describe('test workflow preDeploy', () => { 'push', {head: {ref: 'main'}}, { - OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_s3cr3t_p455word', + OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', }, 'dummy_github_token', ); @@ -299,7 +299,7 @@ describe('test workflow preDeploy', () => { 'push', {head: {ref: 'main'}}, { - OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_s3cr3t_p455word', + OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', }, 'dummy_github_token', ); @@ -377,7 +377,7 @@ describe('test workflow preDeploy', () => { 'push', {head: {ref: 'main'}}, { - OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_s3cr3t_p455word', + OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', }, 'dummy_github_token', ); @@ -419,7 +419,7 @@ describe('test workflow preDeploy', () => { 'push', {head: {ref: 'main'}}, { - OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'OSBotify', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_s3cr3t_p455word', + OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'OSBotify', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', }, 'dummy_github_token', ); @@ -457,7 +457,7 @@ describe('test workflow preDeploy', () => { 'push', {head: {ref: 'main'}}, { - OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_s3cr3t_p455word', + OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', }, 'dummy_github_token', ); @@ -495,7 +495,7 @@ describe('test workflow preDeploy', () => { 'push', {head: {ref: 'main'}}, { - OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_s3cr3t_p455word', + OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', }, 'dummy_github_token', ); @@ -533,7 +533,7 @@ describe('test workflow preDeploy', () => { 'push', {head: {ref: 'main'}}, { - OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_s3cr3t_p455word', + OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', }, 'dummy_github_token', ); @@ -649,7 +649,7 @@ describe('test workflow preDeploy', () => { 'push', {head: {ref: 'main'}}, { - OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_s3cr3t_p455word', + OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', }, 'dummy_github_token', ); @@ -727,7 +727,7 @@ describe('test workflow preDeploy', () => { 'push', {head: {ref: 'main'}}, { - OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_s3cr3t_p455word', + OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', }, 'dummy_github_token', ); @@ -767,7 +767,7 @@ describe('test workflow preDeploy', () => { 'push', {head: {ref: 'main'}}, { - OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'OSBotify', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_s3cr3t_p455word', + OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'OSBotify', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', }, 'dummy_github_token', ); @@ -807,7 +807,7 @@ describe('test workflow preDeploy', () => { 'push', {head: {ref: 'main'}}, { - OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_s3cr3t_p455word', + OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', }, 'dummy_github_token', ); @@ -847,7 +847,7 @@ describe('test workflow preDeploy', () => { 'push', {head: {ref: 'main'}}, { - OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'OSBotify', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_s3cr3t_p455word', + OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'OSBotify', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', }, 'dummy_github_token', ); From d51407dd953b17214c313311d42cf92474264ed1 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Tue, 28 Feb 2023 13:39:30 +0100 Subject: [PATCH 024/504] Add test for Slack announcement [WiP] Added the test checking if the failed workflow gets announced on Slack See: https://github.com/Expensify/App/issues/13604 --- .github/workflows/preDeploy.yml | 2 +- .../assertions/preDeployAssertions.js | 19 + workflow_tests/mocks/preDeployMocks.js | 3 +- workflow_tests/preDeploy.test.js | 618 ++++++++++-------- 4 files changed, 371 insertions(+), 271 deletions(-) diff --git a/.github/workflows/preDeploy.yml b/.github/workflows/preDeploy.yml index 5c1257b85f41..78df8370a3ef 100644 --- a/.github/workflows/preDeploy.yml +++ b/.github/workflows/preDeploy.yml @@ -173,7 +173,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.OS_BOTIFY_TOKEN }} - name: Announce failed workflow in Slack - if: ${{ failure() }} + if: failure() uses: Expensify/App/.github/actions/composite/announceFailedWorkflowInSlack@main with: SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} diff --git a/workflow_tests/assertions/preDeployAssertions.js b/workflow_tests/assertions/preDeployAssertions.js index 4ba684d0982c..a37e9cebc397 100644 --- a/workflow_tests/assertions/preDeployAssertions.js +++ b/workflow_tests/assertions/preDeployAssertions.js @@ -465,6 +465,24 @@ const assertUpdateStagingJobExecuted = (workflowResult, didExecute = true, shoul } }; +const assertUpdateStagingJobFailed = (workflowResult, didFail = false) => { + const steps = [ + utils.getStepAssertion( + 'Announce failed workflow in Slack', + true, + null, + 'UPDATE_STAGING', + 'Announcing failed workflow in Slack', + [{key: 'SLACK_WEBHOOK', value: '***'}], + ), + ]; + if (didFail) { + expect(workflowResult).toEqual(expect.arrayContaining(steps)); + } else { + expect(workflowResult).not.toEqual(steps); + } +}; + module.exports = { assertLintJobExecuted, assertTestJobExecuted, @@ -475,4 +493,5 @@ module.exports = { assertSkipDeployJobExecuted, assertCreateNewVersionJobExecuted, assertUpdateStagingJobExecuted, + assertUpdateStagingJobFailed, }; diff --git a/workflow_tests/mocks/preDeployMocks.js b/workflow_tests/mocks/preDeployMocks.js index 1c42607523cf..ed8691defc2f 100644 --- a/workflow_tests/mocks/preDeployMocks.js +++ b/workflow_tests/mocks/preDeployMocks.js @@ -182,8 +182,9 @@ const COMMENT_TO_ALERT_APPLAUSE_DEPLOY_MOCK_STEP = utils.getMockStep( ); const ANNOUNCE_FAILED_WORKFLOW_IN_SLACK_MOCK_STEP = utils.getMockStep( 'Announce failed workflow in Slack', - 'Announcing failed workflow in slack', + 'Announcing failed workflow in Slack', 'UPDATE_STAGING', + ['SLACK_WEBHOOK'], ); const UPDATE_STAGING_JOB_MOCK_STEPS = [ RUN_TURNSTYLE_MOCK_STEP, diff --git a/workflow_tests/preDeploy.test.js b/workflow_tests/preDeploy.test.js index 760e738bc1e3..b9f7dd0c0117 100644 --- a/workflow_tests/preDeploy.test.js +++ b/workflow_tests/preDeploy.test.js @@ -564,281 +564,360 @@ describe('test workflow preDeploy', () => { }); describe('choose deploy actions', () => { - test('no CP label, staging locked, not automated PR - deploy skipped and comment left', async () => { - const repoPath = mockGithub.repo.getPath('testWorkflowsRepo') || ''; - const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); - let act = new kieActJs.Act(repoPath, workflowPath); - act = utils.setUpActParams( - act, - 'push', - {head: {ref: 'main'}}, - {OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook'}, - 'dummy_github_token', - ); - const testMockSteps = { - lint: mocks.LINT_JOB_MOCK_STEPS, - test: mocks.TEST_JOB_MOCK_STEPS, - confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, - chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__STAGING_LOCKED, - skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, - createNewVersion: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, - updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, - isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, - newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, - 'e2e-tests': mocks.E2E_TESTS_JOB_MOCK_STEPS, - }; - const result = await act - .runEvent('push', { - workflowFile: path.join(repoPath, '.github', 'workflows'), - mockSteps: testMockSteps, - }); - assertions.assertLintJobExecuted(result); - assertions.assertTestJobExecuted(result); - assertions.assertIsExpensifyEmployeeJobExecuted(result); - assertions.assertE2ETestsJobExecuted(result, false); // Act does not support ubuntu-20.04-64core runner and omits the job - assertions.assertChooseDeployActionsJobExecuted(result); - assertions.assertSkipDeployJobExecuted(result); - assertions.assertCreateNewVersionJobExecuted(result, false); - assertions.assertUpdateStagingJobExecuted(result, false, false); - }, 60000); + describe('no CP label', () => { + describe('staging locked', () => { + test('not automated PR - deploy skipped and comment left', async () => { + const repoPath = mockGithub.repo.getPath('testWorkflowsRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); + let act = new kieActJs.Act(repoPath, workflowPath); + act = utils.setUpActParams( + act, + 'push', + {head: {ref: 'main'}}, + {OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook'}, + 'dummy_github_token', + ); + const testMockSteps = { + lint: mocks.LINT_JOB_MOCK_STEPS, + test: mocks.TEST_JOB_MOCK_STEPS, + confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, + chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__STAGING_LOCKED, + skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, + createNewVersion: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, + updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, + isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, + newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, + 'e2e-tests': mocks.E2E_TESTS_JOB_MOCK_STEPS, + }; + const result = await act + .runEvent('push', { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + }); + assertions.assertLintJobExecuted(result); + assertions.assertTestJobExecuted(result); + assertions.assertIsExpensifyEmployeeJobExecuted(result); + assertions.assertE2ETestsJobExecuted(result, false); // Act does not support ubuntu-20.04-64core runner and omits the job + assertions.assertChooseDeployActionsJobExecuted(result); + assertions.assertSkipDeployJobExecuted(result); + assertions.assertCreateNewVersionJobExecuted(result, false); + assertions.assertUpdateStagingJobExecuted(result, false, false); + assertions.assertUpdateStagingJobFailed(result, false); + }, 60000); - test('no CP label, staging locked, automated PR - deploy skipped, but no comment left', async () => { - const repoPath = mockGithub.repo.getPath('testWorkflowsRepo') || ''; - const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); - let act = new kieActJs.Act(repoPath, workflowPath); - act = utils.setUpActParams( - act, - 'push', - {head: {ref: 'main'}}, - {OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'OSBotify', SLACK_WEBHOOK: 'dummy_slack_webhook'}, - 'dummy_github_token', - ); - const testMockSteps = { - lint: mocks.LINT_JOB_MOCK_STEPS, - test: mocks.TEST_JOB_MOCK_STEPS, - confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, - chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__STAGING_LOCKED, - skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, - createNewVersion: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, - updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, - isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, - newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, - 'e2e-tests': mocks.E2E_TESTS_JOB_MOCK_STEPS, - }; - const result = await act - .runEvent('push', { - workflowFile: path.join(repoPath, '.github', 'workflows'), - mockSteps: testMockSteps, - }); - assertions.assertLintJobExecuted(result); - assertions.assertTestJobExecuted(result); - assertions.assertIsExpensifyEmployeeJobExecuted(result); - assertions.assertE2ETestsJobExecuted(result, false); // Act does not support ubuntu-20.04-64core runner and omits the job - assertions.assertChooseDeployActionsJobExecuted(result); - assertions.assertSkipDeployJobExecuted(result, false); - assertions.assertCreateNewVersionJobExecuted(result, false); - assertions.assertUpdateStagingJobExecuted(result, false, false); - }, 60000); + test('automated PR - deploy skipped, but no comment left', async () => { + const repoPath = mockGithub.repo.getPath('testWorkflowsRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); + let act = new kieActJs.Act(repoPath, workflowPath); + act = utils.setUpActParams( + act, + 'push', + {head: {ref: 'main'}}, + {OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'OSBotify', SLACK_WEBHOOK: 'dummy_slack_webhook'}, + 'dummy_github_token', + ); + const testMockSteps = { + lint: mocks.LINT_JOB_MOCK_STEPS, + test: mocks.TEST_JOB_MOCK_STEPS, + confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, + chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__STAGING_LOCKED, + skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, + createNewVersion: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, + updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, + isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, + newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, + 'e2e-tests': mocks.E2E_TESTS_JOB_MOCK_STEPS, + }; + const result = await act + .runEvent('push', { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + }); + assertions.assertLintJobExecuted(result); + assertions.assertTestJobExecuted(result); + assertions.assertIsExpensifyEmployeeJobExecuted(result); + assertions.assertE2ETestsJobExecuted(result, false); // Act does not support ubuntu-20.04-64core runner and omits the job + assertions.assertChooseDeployActionsJobExecuted(result); + assertions.assertSkipDeployJobExecuted(result, false); + assertions.assertCreateNewVersionJobExecuted(result, false); + assertions.assertUpdateStagingJobExecuted(result, false, false); + assertions.assertUpdateStagingJobFailed(result, false); + }, 60000); + }); - test('no CP label, staging not locked, not automated PR - proceed with deploy', async () => { - const repoPath = mockGithub.repo.getPath('testWorkflowsRepo') || ''; - const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); - let act = new kieActJs.Act(repoPath, workflowPath); - act = utils.setUpActParams( - act, - 'push', - {head: {ref: 'main'}}, - { - OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', - }, - 'dummy_github_token', - ); - const testMockSteps = { - lint: mocks.LINT_JOB_MOCK_STEPS, - test: mocks.TEST_JOB_MOCK_STEPS, - confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, - chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__STAGING_UNLOCKED, - skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, - createNewVersion: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, - updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, - isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, - newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, - 'e2e-tests': mocks.E2E_TESTS_JOB_MOCK_STEPS, - }; - const result = await act - .runEvent('push', { - workflowFile: path.join(repoPath, '.github', 'workflows'), - mockSteps: testMockSteps, - }); - assertions.assertLintJobExecuted(result); - assertions.assertTestJobExecuted(result); - assertions.assertIsExpensifyEmployeeJobExecuted(result); - assertions.assertE2ETestsJobExecuted(result, false); // Act does not support ubuntu-20.04-64core runner and omits the job - assertions.assertChooseDeployActionsJobExecuted(result); - assertions.assertSkipDeployJobExecuted(result, false); - assertions.assertCreateNewVersionJobExecuted(result); - assertions.assertUpdateStagingJobExecuted(result, true, false); - }, 60000); + describe('staging not locked', () => { + test('not automated PR - proceed with deploy', async () => { + const repoPath = mockGithub.repo.getPath('testWorkflowsRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); + let act = new kieActJs.Act(repoPath, workflowPath); + act = utils.setUpActParams( + act, + 'push', + {head: {ref: 'main'}}, + { + OS_BOTIFY_TOKEN: 'dummy_token', + GITHUB_ACTOR: 'Dummy Tester', + SLACK_WEBHOOK: 'dummy_slack_webhook', + LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', + }, + 'dummy_github_token', + ); + const testMockSteps = { + lint: mocks.LINT_JOB_MOCK_STEPS, + test: mocks.TEST_JOB_MOCK_STEPS, + confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, + chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__STAGING_UNLOCKED, + skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, + createNewVersion: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, + updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, + isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, + newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, + 'e2e-tests': mocks.E2E_TESTS_JOB_MOCK_STEPS, + }; + const result = await act + .runEvent('push', { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + }); + assertions.assertLintJobExecuted(result); + assertions.assertTestJobExecuted(result); + assertions.assertIsExpensifyEmployeeJobExecuted(result); + assertions.assertE2ETestsJobExecuted(result, false); // Act does not support ubuntu-20.04-64core runner and omits the job + assertions.assertChooseDeployActionsJobExecuted(result); + assertions.assertSkipDeployJobExecuted(result, false); + assertions.assertCreateNewVersionJobExecuted(result); + assertions.assertUpdateStagingJobExecuted(result, true, false); + assertions.assertUpdateStagingJobFailed(result, false); + }, 60000); - test('no CP label, staging not locked, automated PR - deploy skipped, but no comment left', async () => { - const repoPath = mockGithub.repo.getPath('testWorkflowsRepo') || ''; - const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); - let act = new kieActJs.Act(repoPath, workflowPath); - act = utils.setUpActParams( - act, - 'push', - {head: {ref: 'main'}}, - {OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'OSBotify', SLACK_WEBHOOK: 'dummy_slack_webhook'}, - 'dummy_github_token', - ); - const testMockSteps = { - lint: mocks.LINT_JOB_MOCK_STEPS, - test: mocks.TEST_JOB_MOCK_STEPS, - confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, - chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__STAGING_UNLOCKED, - skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, - createNewVersion: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, - updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, - isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, - newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, - 'e2e-tests': mocks.E2E_TESTS_JOB_MOCK_STEPS, - }; - const result = await act - .runEvent('push', { - workflowFile: path.join(repoPath, '.github', 'workflows'), - mockSteps: testMockSteps, - }); - assertions.assertLintJobExecuted(result); - assertions.assertTestJobExecuted(result); - assertions.assertIsExpensifyEmployeeJobExecuted(result); - assertions.assertE2ETestsJobExecuted(result, false); // Act does not support ubuntu-20.04-64core runner and omits the job - assertions.assertChooseDeployActionsJobExecuted(result); - assertions.assertSkipDeployJobExecuted(result, false); - assertions.assertCreateNewVersionJobExecuted(result, false); - assertions.assertUpdateStagingJobExecuted(result, false, false); - }, 60000); + test('automated PR - deploy skipped, but no comment left', async () => { + const repoPath = mockGithub.repo.getPath('testWorkflowsRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); + let act = new kieActJs.Act(repoPath, workflowPath); + act = utils.setUpActParams( + act, + 'push', + {head: {ref: 'main'}}, + { + OS_BOTIFY_TOKEN: 'dummy_token', + GITHUB_ACTOR: 'OSBotify', + SLACK_WEBHOOK: 'dummy_slack_webhook', + }, + 'dummy_github_token', + ); + const testMockSteps = { + lint: mocks.LINT_JOB_MOCK_STEPS, + test: mocks.TEST_JOB_MOCK_STEPS, + confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, + chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__STAGING_UNLOCKED, + skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, + createNewVersion: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, + updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, + isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, + newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, + 'e2e-tests': mocks.E2E_TESTS_JOB_MOCK_STEPS, + }; + const result = await act + .runEvent('push', { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + }); + assertions.assertLintJobExecuted(result); + assertions.assertTestJobExecuted(result); + assertions.assertIsExpensifyEmployeeJobExecuted(result); + assertions.assertE2ETestsJobExecuted(result, false); // Act does not support ubuntu-20.04-64core runner and omits the job + assertions.assertChooseDeployActionsJobExecuted(result); + assertions.assertSkipDeployJobExecuted(result, false); + assertions.assertCreateNewVersionJobExecuted(result, false); + assertions.assertUpdateStagingJobExecuted(result, false, false); + assertions.assertUpdateStagingJobFailed(result, false); + }, 60000); + }); + }); - test('CP label, staging locked, not automated PR - proceed with deploy', async () => { - const repoPath = mockGithub.repo.getPath('testWorkflowsRepo') || ''; - const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); - let act = new kieActJs.Act(repoPath, workflowPath); - act = utils.setUpActParams( - act, - 'push', - {head: {ref: 'main'}}, - { - OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', - }, - 'dummy_github_token', - ); - const testMockSteps = { - lint: mocks.LINT_JOB_MOCK_STEPS, - test: mocks.TEST_JOB_MOCK_STEPS, - confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, - chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__CP_LABEL__STAGING_LOCKED, - skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, - createNewVersion: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, - updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, - isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, - newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, - 'e2e-tests': mocks.E2E_TESTS_JOB_MOCK_STEPS, - }; - const result = await act - .runEvent('push', { - workflowFile: path.join(repoPath, '.github', 'workflows'), - mockSteps: testMockSteps, - }); - assertions.assertLintJobExecuted(result); - assertions.assertTestJobExecuted(result); - assertions.assertIsExpensifyEmployeeJobExecuted(result); - assertions.assertE2ETestsJobExecuted(result, false); // Act does not support ubuntu-20.04-64core runner and omits the job - assertions.assertChooseDeployActionsJobExecuted(result); - assertions.assertSkipDeployJobExecuted(result, false); - assertions.assertCreateNewVersionJobExecuted(result); - assertions.assertUpdateStagingJobExecuted(result, true, true); - }, 60000); + describe('CP label', () => { + describe('staging locked', () => { + test('not automated PR - proceed with deploy', async () => { + const repoPath = mockGithub.repo.getPath('testWorkflowsRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); + let act = new kieActJs.Act(repoPath, workflowPath); + act = utils.setUpActParams( + act, + 'push', + {head: {ref: 'main'}}, + { + OS_BOTIFY_TOKEN: 'dummy_token', + GITHUB_ACTOR: 'Dummy Tester', + SLACK_WEBHOOK: 'dummy_slack_webhook', + LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', + }, + 'dummy_github_token', + ); + const testMockSteps = { + lint: mocks.LINT_JOB_MOCK_STEPS, + test: mocks.TEST_JOB_MOCK_STEPS, + confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, + chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__CP_LABEL__STAGING_LOCKED, + skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, + createNewVersion: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, + updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, + isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, + newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, + 'e2e-tests': mocks.E2E_TESTS_JOB_MOCK_STEPS, + }; + const result = await act + .runEvent('push', { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + }); + assertions.assertLintJobExecuted(result); + assertions.assertTestJobExecuted(result); + assertions.assertIsExpensifyEmployeeJobExecuted(result); + assertions.assertE2ETestsJobExecuted(result, false); // Act does not support ubuntu-20.04-64core runner and omits the job + assertions.assertChooseDeployActionsJobExecuted(result); + assertions.assertSkipDeployJobExecuted(result, false); + assertions.assertCreateNewVersionJobExecuted(result); + assertions.assertUpdateStagingJobExecuted(result, true, true); + assertions.assertUpdateStagingJobFailed(result, false); + }, 60000); - test('CP label, staging locked, automated PR - proceed with deploy', async () => { - const repoPath = mockGithub.repo.getPath('testWorkflowsRepo') || ''; - const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); - let act = new kieActJs.Act(repoPath, workflowPath); - act = utils.setUpActParams( - act, - 'push', - {head: {ref: 'main'}}, - { - OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'OSBotify', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', - }, - 'dummy_github_token', - ); - const testMockSteps = { - lint: mocks.LINT_JOB_MOCK_STEPS, - test: mocks.TEST_JOB_MOCK_STEPS, - confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, - chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__CP_LABEL__STAGING_LOCKED, - skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, - createNewVersion: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, - updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, - isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, - newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, - 'e2e-tests': mocks.E2E_TESTS_JOB_MOCK_STEPS, - }; - const result = await act - .runEvent('push', { - workflowFile: path.join(repoPath, '.github', 'workflows'), - mockSteps: testMockSteps, - }); - assertions.assertLintJobExecuted(result); - assertions.assertTestJobExecuted(result); - assertions.assertIsExpensifyEmployeeJobExecuted(result); - assertions.assertE2ETestsJobExecuted(result, false); // Act does not support ubuntu-20.04-64core runner and omits the job - assertions.assertChooseDeployActionsJobExecuted(result); - assertions.assertSkipDeployJobExecuted(result, false); - assertions.assertCreateNewVersionJobExecuted(result); - assertions.assertUpdateStagingJobExecuted(result, true, true); - }, 60000); + test('automated PR - proceed with deploy', async () => { + const repoPath = mockGithub.repo.getPath('testWorkflowsRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); + let act = new kieActJs.Act(repoPath, workflowPath); + act = utils.setUpActParams( + act, + 'push', + {head: {ref: 'main'}}, + { + OS_BOTIFY_TOKEN: 'dummy_token', + GITHUB_ACTOR: 'OSBotify', + SLACK_WEBHOOK: 'dummy_slack_webhook', + LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', + }, + 'dummy_github_token', + ); + const testMockSteps = { + lint: mocks.LINT_JOB_MOCK_STEPS, + test: mocks.TEST_JOB_MOCK_STEPS, + confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, + chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__CP_LABEL__STAGING_LOCKED, + skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, + createNewVersion: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, + updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, + isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, + newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, + 'e2e-tests': mocks.E2E_TESTS_JOB_MOCK_STEPS, + }; + const result = await act + .runEvent('push', { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + }); + assertions.assertLintJobExecuted(result); + assertions.assertTestJobExecuted(result); + assertions.assertIsExpensifyEmployeeJobExecuted(result); + assertions.assertE2ETestsJobExecuted(result, false); // Act does not support ubuntu-20.04-64core runner and omits the job + assertions.assertChooseDeployActionsJobExecuted(result); + assertions.assertSkipDeployJobExecuted(result, false); + assertions.assertCreateNewVersionJobExecuted(result); + assertions.assertUpdateStagingJobExecuted(result, true, true); + assertions.assertUpdateStagingJobFailed(result, false); + }, 60000); + }); - test('CP label, staging not locked, not automated PR - proceed with deploy', async () => { - const repoPath = mockGithub.repo.getPath('testWorkflowsRepo') || ''; - const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); - let act = new kieActJs.Act(repoPath, workflowPath); - act = utils.setUpActParams( - act, - 'push', - {head: {ref: 'main'}}, - { - OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', - }, - 'dummy_github_token', - ); - const testMockSteps = { - lint: mocks.LINT_JOB_MOCK_STEPS, - test: mocks.TEST_JOB_MOCK_STEPS, - confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, - chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__CP_LABEL__STAGING_UNLOCKED, - skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, - createNewVersion: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, - updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, - isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, - newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, - 'e2e-tests': mocks.E2E_TESTS_JOB_MOCK_STEPS, - }; - const result = await act - .runEvent('push', { - workflowFile: path.join(repoPath, '.github', 'workflows'), - mockSteps: testMockSteps, - }); - assertions.assertLintJobExecuted(result); - assertions.assertTestJobExecuted(result); - assertions.assertIsExpensifyEmployeeJobExecuted(result); - assertions.assertE2ETestsJobExecuted(result, false); // Act does not support ubuntu-20.04-64core runner and omits the job - assertions.assertChooseDeployActionsJobExecuted(result); - assertions.assertSkipDeployJobExecuted(result, false); - assertions.assertCreateNewVersionJobExecuted(result); - assertions.assertUpdateStagingJobExecuted(result, true, false); - }, 60000); + describe('staging not locked', () => { + test('not automated PR - proceed with deploy', async () => { + const repoPath = mockGithub.repo.getPath('testWorkflowsRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); + let act = new kieActJs.Act(repoPath, workflowPath); + act = utils.setUpActParams( + act, + 'push', + {head: {ref: 'main'}}, + { + OS_BOTIFY_TOKEN: 'dummy_token', + GITHUB_ACTOR: 'Dummy Tester', + SLACK_WEBHOOK: 'dummy_slack_webhook', + LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', + }, + 'dummy_github_token', + ); + const testMockSteps = { + lint: mocks.LINT_JOB_MOCK_STEPS, + test: mocks.TEST_JOB_MOCK_STEPS, + confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, + chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__CP_LABEL__STAGING_UNLOCKED, + skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, + createNewVersion: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, + updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, + isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, + newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, + 'e2e-tests': mocks.E2E_TESTS_JOB_MOCK_STEPS, + }; + const result = await act + .runEvent('push', { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + }); + assertions.assertLintJobExecuted(result); + assertions.assertTestJobExecuted(result); + assertions.assertIsExpensifyEmployeeJobExecuted(result); + assertions.assertE2ETestsJobExecuted(result, false); // Act does not support ubuntu-20.04-64core runner and omits the job + assertions.assertChooseDeployActionsJobExecuted(result); + assertions.assertSkipDeployJobExecuted(result, false); + assertions.assertCreateNewVersionJobExecuted(result); + assertions.assertUpdateStagingJobExecuted(result, true, false); + assertions.assertUpdateStagingJobFailed(result, false); + }, 60000); + + test('automated PR - proceed with deploy', async () => { + const repoPath = mockGithub.repo.getPath('testWorkflowsRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); + let act = new kieActJs.Act(repoPath, workflowPath); + act = utils.setUpActParams( + act, + 'push', + {head: {ref: 'main'}}, + { + OS_BOTIFY_TOKEN: 'dummy_token', + GITHUB_ACTOR: 'OSBotify', + SLACK_WEBHOOK: 'dummy_slack_webhook', + LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', + }, + 'dummy_github_token', + ); + const testMockSteps = { + lint: mocks.LINT_JOB_MOCK_STEPS, + test: mocks.TEST_JOB_MOCK_STEPS, + confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, + chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__CP_LABEL__STAGING_UNLOCKED, + skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, + createNewVersion: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, + updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, + isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, + newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, + 'e2e-tests': mocks.E2E_TESTS_JOB_MOCK_STEPS, + }; + const result = await act + .runEvent('push', { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + }); + assertions.assertLintJobExecuted(result); + assertions.assertTestJobExecuted(result); + assertions.assertIsExpensifyEmployeeJobExecuted(result); + assertions.assertE2ETestsJobExecuted(result, false); // Act does not support ubuntu-20.04-64core runner and omits the job + assertions.assertChooseDeployActionsJobExecuted(result); + assertions.assertSkipDeployJobExecuted(result, false); + assertions.assertCreateNewVersionJobExecuted(result); + assertions.assertUpdateStagingJobExecuted(result, true, false); + assertions.assertUpdateStagingJobFailed(result, false); + }, 60000); + }); + }); - test('CP label, staging not locked, automated PR - proceed with deploy', async () => { + test('one of updateStaging steps failed - failure announced in Slack', async () => { const repoPath = mockGithub.repo.getPath('testWorkflowsRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); let act = new kieActJs.Act(repoPath, workflowPath); @@ -863,6 +942,7 @@ describe('test workflow preDeploy', () => { newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, 'e2e-tests': mocks.E2E_TESTS_JOB_MOCK_STEPS, }; + testMockSteps.updateStaging[3].mockWith = 'exit 1'; const result = await act .runEvent('push', { workflowFile: path.join(repoPath, '.github', 'workflows'), @@ -875,7 +955,7 @@ describe('test workflow preDeploy', () => { assertions.assertChooseDeployActionsJobExecuted(result); assertions.assertSkipDeployJobExecuted(result, false); assertions.assertCreateNewVersionJobExecuted(result); - assertions.assertUpdateStagingJobExecuted(result, true, false); + assertions.assertUpdateStagingJobFailed(result, true); }, 60000); }); }); From 665dbf98c9195d57520ab0dcdca6b09f12384b6e Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Tue, 28 Feb 2023 13:40:03 +0100 Subject: [PATCH 025/504] Add setup section [WiP] Added new section to readme, about setting up the environment for running tests See: https://github.com/Expensify/App/issues/13604 --- workflow_tests/README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/workflow_tests/README.md b/workflow_tests/README.md index 30b6f3d6a90d..b78ebf92838a 100644 --- a/workflow_tests/README.md +++ b/workflow_tests/README.md @@ -12,6 +12,12 @@ Not all workflows can always be tested this way, for example: - Testing more complex workflows in their entirety can be extremely time-consuming and cumbersome. It is often optimal to mock most of the steps with expressions printing the input and output conditions - Due to the way `Act` and `Act-js` handle workflow output, not much can be checked in the test. What is available, namely whether the job/step executed or not, whether it was successful or not and what its printed output was, should be enough in most scenarios +## Setup +- Install dependencies from `package.json` file with `npm install` +- Install `Act` with `brew install act` and follow the documentation on [first Act run](https://github.com/nektos/act#first-act-run) +- Set the environment variable `ACT_BINARY` to the path to your `Act` executable (`which act` if you're not sure what the path is) +- You should be ready to run the tests now with `npm test -- --config=workflow_tests/jest.config.js` + ## File structure The testing framework file structure within the repository is as follows: - `App/` - main application folder From 31c1cf0ffa33bb331e6a3a8db10ce63d69dd111e Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Tue, 28 Feb 2023 16:27:45 +0100 Subject: [PATCH 026/504] Add deploy tests [WiP] Added tests for the deploy.yml workflow and fixed the setActParams method See: https://github.com/Expensify/App/issues/13604 --- .github/workflows/deploy.yml | 13 +- workflow_tests/assertions/deployAssertions.js | 135 ++++++++++ workflow_tests/deploy.test.js | 241 ++++++++++++++++++ workflow_tests/mocks/deployMocks.js | 124 +++++++++ workflow_tests/utils.js | 2 +- 5 files changed, 509 insertions(+), 6 deletions(-) create mode 100644 workflow_tests/assertions/deployAssertions.js create mode 100644 workflow_tests/deploy.test.js create mode 100644 workflow_tests/mocks/deployMocks.js diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 606393ca5c12..9b7916358fd6 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -25,7 +25,7 @@ jobs: deployStaging: runs-on: ubuntu-latest needs: validate - if: ${{ fromJSON(needs.validate.outputs.isAutomatedPullRequest) && github.ref == 'refs/heads/staging' }} + if: ${{ fromJSON(needs.validate.outputs.isAutomatedPullRequest) && github.event.push.ref == 'refs/heads/staging' }} steps: - name: Checkout staging branch @@ -34,7 +34,8 @@ jobs: ref: staging token: ${{ secrets.OS_BOTIFY_TOKEN }} - - uses: Expensify/App/.github/actions/composite/setupGitForOSBotify@main + - name: Setup git for OSBotify + uses: Expensify/App/.github/actions/composite/setupGitForOSBotify@main with: GPG_PASSPHRASE: ${{ secrets.LARGE_SECRET_PASSPHRASE }} @@ -47,15 +48,17 @@ jobs: deployProduction: runs-on: ubuntu-latest needs: validate - if: ${{ fromJSON(needs.validate.outputs.isAutomatedPullRequest) && github.ref == 'refs/heads/production' }} + if: ${{ fromJSON(needs.validate.outputs.isAutomatedPullRequest) && github.event.push.ref == 'refs/heads/production' }} steps: - - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 + - name: Checkout + uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 with: fetch-depth: 0 token: ${{ secrets.OS_BOTIFY_TOKEN }} - - uses: Expensify/App/.github/actions/composite/setupGitForOSBotify@main + - name: Setup git for OSBotify + uses: Expensify/App/.github/actions/composite/setupGitForOSBotify@main with: GPG_PASSPHRASE: ${{ secrets.LARGE_SECRET_PASSPHRASE }} diff --git a/workflow_tests/assertions/deployAssertions.js b/workflow_tests/assertions/deployAssertions.js new file mode 100644 index 000000000000..8471cb6bfdaa --- /dev/null +++ b/workflow_tests/assertions/deployAssertions.js @@ -0,0 +1,135 @@ +const utils = require('../utils'); + +const assertValidateJobExecuted = (workflowResult, didExecute = true) => { + const steps = [ + utils.getStepAssertion( + 'Get merged pull request', + true, + null, + 'VALIDATE', + 'Getting merged PR', + [{key: 'github_token', value: '***'}], + ), + { + name: 'Main Check if merged pull request was an automatic version bump PR', + status: 0, + output: '', + }, + ]; + if (didExecute) { + expect(workflowResult).toEqual(expect.arrayContaining(steps)); + } else { + expect(workflowResult).not.toEqual(expect.arrayContaining(steps)); + } +}; + +const assertDeployStagingJobExecuted = (workflowResult, didExecute = true) => { + const steps = [ + utils.getStepAssertion( + 'Checkout staging branch', + true, + null, + 'DEPLOY_STAGING', + 'Checking out staging branch', + [{key: 'ref', value: 'staging'}, {key: 'token', value: '***'}], + ), + utils.getStepAssertion( + 'Setup git for ***', + true, + null, + 'DEPLOY_STAGING', + 'Setting up git for ***', + [{key: 'GPG_PASSPHRASE', value: '***'}], + ), + utils.getStepAssertion( + 'Tag version', + true, + null, + 'DEPLOY_STAGING', + 'Tagging new version', + ), + utils.getStepAssertion( + '🚀 Push tags to trigger staging deploy 🚀', + true, + null, + 'DEPLOY_STAGING', + 'Pushing tag to trigger staging deploy', + ), + ]; + if (didExecute) { + expect(workflowResult).toEqual(expect.arrayContaining(steps)); + } else { + expect(workflowResult).not.toEqual(expect.arrayContaining(steps)); + } +}; + +const assertDeployProductionJobExecuted = (workflowResult, didExecute = true) => { + const steps = [ + utils.getStepAssertion( + 'Checkout', + true, + null, + 'DEPLOY_PRODUCTION', + 'Checking out', + [{key: 'fetch-depth', value: '0'}, {key: 'token', value: '***'}], + ), + utils.getStepAssertion( + 'Setup git for ***', + true, + null, + 'DEPLOY_PRODUCTION', + 'Setting up git for ***', + [{key: 'GPG_PASSPHRASE', value: '***'}], + ), + utils.getStepAssertion( + 'Checkout production branch', + true, + null, + 'DEPLOY_PRODUCTION', + 'Checking out production branch', + ), + utils.getStepAssertion( + 'Get current app version', + true, + null, + 'DEPLOY_PRODUCTION', + 'Getting current app version', + ), + utils.getStepAssertion( + 'Get Release Pull Request List', + true, + null, + 'DEPLOY_PRODUCTION', + 'Getting release PR list', + [{key: 'TAG', value: '1.2.3'}, {key: 'GITHUB_TOKEN', value: '***'}, {key: 'IS_PRODUCTION_DEPLOY', value: 'true'}], + ), + utils.getStepAssertion( + 'Generate Release Body', + true, + null, + 'DEPLOY_PRODUCTION', + 'Generating release body', + [{key: 'PR_LIST', value: '[1.2.1, 1.2.2]'}], + ), + utils.getStepAssertion( + '🚀 Create release to trigger production deploy 🚀', + true, + null, + 'DEPLOY_PRODUCTION', + 'Creating release to trigger production deploy', + [{key: 'tag_name', value: '1.2.3'}, {key: 'body', value: 'Release body'}], + [{key: 'GITHUB_TOKEN', value: '***'}], + ), + ]; + if (didExecute) { + expect(workflowResult).toEqual(expect.arrayContaining(steps)); + } else { + expect(workflowResult).not.toEqual(expect.arrayContaining(steps)); + } +}; + +module.exports = { + assertValidateJobExecuted, + assertDeployStagingJobExecuted, + assertDeployProductionJobExecuted, +}; diff --git a/workflow_tests/deploy.test.js b/workflow_tests/deploy.test.js new file mode 100644 index 000000000000..d8fe903beb4b --- /dev/null +++ b/workflow_tests/deploy.test.js @@ -0,0 +1,241 @@ +const path = require('path'); +const kieActJs = require('@kie/act-js'); +const kieMockGithub = require('@kie/mock-github'); +const utils = require('./utils'); +const assertions = require('./assertions/deployAssertions'); +const mocks = require('./mocks/deployMocks'); + +let mockGithub; +const FILES_TO_COPY_INTO_TEST_REPO = [ + { + src: path.resolve(__dirname, '..', '.github', 'actions'), + dest: '.github/actions', + }, + { + src: path.resolve(__dirname, '..', '.github', 'libs'), + dest: '.github/libs', + }, + { + src: path.resolve(__dirname, '..', '.github', 'scripts'), + dest: '.github/scripts', + }, + { + src: path.resolve(__dirname, '..', '.github', 'workflows', 'deploy.yml'), + dest: '.github/workflows/deploy.yml', + }, +]; + +beforeEach(async () => { + // create a local repository and copy required files + mockGithub = new kieMockGithub.MockGithub({ + repo: { + testDeployWorkflowRepo: { + files: FILES_TO_COPY_INTO_TEST_REPO, + pushedBranches: ['staging', 'production'], + }, + }, + }); + + await mockGithub.setup(); +}); + +afterEach(async () => { + await mockGithub.teardown(); +}); + +describe('test workflow deploy', () => { + describe('push as OSBotify', () => { + test('to main - nothing triggered', async () => { + const repoPath = mockGithub.repo.getPath('testDeployWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'deploy.yml'); + let act = new kieActJs.Act(repoPath, workflowPath); + act = utils.setUpActParams( + act, + 'push', + { + ref: 'refs/heads/main', + }, + { + GITHUB_ACTOR: 'OSBotify', + OS_BOTIFY_TOKEN: 'dummy_token', + LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', + }, + 'dummy_github_token', + ); + const testMockSteps = { + validate: mocks.VALIDATE__OSBOTIFY__STEP_MOCKS, + deployStaging: mocks.DEPLOY_STAGING_STEP_MOCKS, + deployProduction: mocks.DEPLOY_PRODUCTION_STEP_MOCKS, + }; + const result = await act + .runEvent('push', { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + }); + assertions.assertValidateJobExecuted(result); + assertions.assertDeployStagingJobExecuted(result, false); + assertions.assertDeployProductionJobExecuted(result, false); + }, 60000); + + test('to staging - deployStaging triggered', async () => { + const repoPath = mockGithub.repo.getPath('testDeployWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'deploy.yml'); + let act = new kieActJs.Act(repoPath, workflowPath); + act = utils.setUpActParams( + act, + 'push', + { + ref: 'refs/heads/staging', + }, + { + GITHUB_ACTOR: 'OSBotify', + OS_BOTIFY_TOKEN: 'dummy_token', + LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', + }, + 'dummy_github_token', + ); + const testMockSteps = { + validate: mocks.VALIDATE__OSBOTIFY__STEP_MOCKS, + deployStaging: mocks.DEPLOY_STAGING_STEP_MOCKS, + deployProduction: mocks.DEPLOY_PRODUCTION_STEP_MOCKS, + }; + const result = await act + .runEvent('push', { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + }); + assertions.assertValidateJobExecuted(result); + assertions.assertDeployStagingJobExecuted(result); + assertions.assertDeployProductionJobExecuted(result, false); + }, 60000); + + test('to production - deployProduction triggered', async () => { + const repoPath = mockGithub.repo.getPath('testDeployWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'deploy.yml'); + let act = new kieActJs.Act(repoPath, workflowPath); + act = utils.setUpActParams( + act, + 'push', + { + ref: 'refs/heads/production', + }, + { + GITHUB_ACTOR: 'OSBotify', + OS_BOTIFY_TOKEN: 'dummy_token', + LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', + }, + 'dummy_github_token', + ); + const testMockSteps = { + validate: mocks.VALIDATE__OSBOTIFY__STEP_MOCKS, + deployStaging: mocks.DEPLOY_STAGING_STEP_MOCKS, + deployProduction: mocks.DEPLOY_PRODUCTION_STEP_MOCKS, + }; + const result = await act + .runEvent('push', { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + }); + assertions.assertValidateJobExecuted(result); + assertions.assertDeployStagingJobExecuted(result, false); + assertions.assertDeployProductionJobExecuted(result); + }, 60000); + }); + describe('push as user', () => { + test('to main - nothing triggered', async () => { + const repoPath = mockGithub.repo.getPath('testDeployWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'deploy.yml'); + let act = new kieActJs.Act(repoPath, workflowPath); + act = utils.setUpActParams( + act, + 'push', + { + ref: 'refs/heads/main', + }, + { + GITHUB_ACTOR: 'Dummy Author', + OS_BOTIFY_TOKEN: 'dummy_token', + LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', + }, + 'dummy_github_token', + ); + const testMockSteps = { + validate: mocks.VALIDATE__OSBOTIFY__STEP_MOCKS, + deployStaging: mocks.DEPLOY_STAGING_STEP_MOCKS, + deployProduction: mocks.DEPLOY_PRODUCTION_STEP_MOCKS, + }; + const result = await act + .runEvent('push', { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + }); + assertions.assertValidateJobExecuted(result); + assertions.assertDeployStagingJobExecuted(result, false); + assertions.assertDeployProductionJobExecuted(result, false); + }, 60000); + + test('to staging - nothing triggered', async () => { + const repoPath = mockGithub.repo.getPath('testDeployWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'deploy.yml'); + let act = new kieActJs.Act(repoPath, workflowPath); + act = utils.setUpActParams( + act, + 'push', + { + ref: 'refs/heads/staging', + }, + { + GITHUB_ACTOR: 'Dummy Author', + OS_BOTIFY_TOKEN: 'dummy_token', + LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', + }, + 'dummy_github_token', + ); + const testMockSteps = { + validate: mocks.VALIDATE__OSBOTIFY__STEP_MOCKS, + deployStaging: mocks.DEPLOY_STAGING_STEP_MOCKS, + deployProduction: mocks.DEPLOY_PRODUCTION_STEP_MOCKS, + }; + const result = await act + .runEvent('push', { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + }); + assertions.assertValidateJobExecuted(result); + assertions.assertDeployStagingJobExecuted(result, false); + assertions.assertDeployProductionJobExecuted(result, false); + }, 60000); + + test('to production - nothing triggered', async () => { + const repoPath = mockGithub.repo.getPath('testDeployWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'deploy.yml'); + let act = new kieActJs.Act(repoPath, workflowPath); + act = utils.setUpActParams( + act, + 'push', + { + ref: 'refs/heads/production', + }, + { + GITHUB_ACTOR: 'Dummy Author', + OS_BOTIFY_TOKEN: 'dummy_token', + LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', + }, + 'dummy_github_token', + ); + const testMockSteps = { + validate: mocks.VALIDATE__OSBOTIFY__STEP_MOCKS, + deployStaging: mocks.DEPLOY_STAGING_STEP_MOCKS, + deployProduction: mocks.DEPLOY_PRODUCTION_STEP_MOCKS, + }; + const result = await act + .runEvent('push', { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + }); + assertions.assertValidateJobExecuted(result); + assertions.assertDeployStagingJobExecuted(result, false); + assertions.assertDeployProductionJobExecuted(result, false); + }, 60000); + }); +}); diff --git a/workflow_tests/mocks/deployMocks.js b/workflow_tests/mocks/deployMocks.js new file mode 100644 index 000000000000..0f4164ffa07f --- /dev/null +++ b/workflow_tests/mocks/deployMocks.js @@ -0,0 +1,124 @@ +const utils = require('../utils'); + +const VALIDATE__GET_MERGED_PR__STEP_MOCK = utils.getMockStep( + 'Get merged pull request', + 'Getting merged PR', + 'VALIDATE', + ['github_token'], + [], + {author: 'Dummy Author'}, +); +const VALIDATE__GET_MERGED_PR__OSBOTIFY__STEP_MOCK = utils.getMockStep( + 'Get merged pull request', + 'Getting merged PR', + 'VALIDATE', + ['github_token'], + [], + {author: 'OSBotify'}, +); + +const VALIDATE_STEP_MOCKS = [ + VALIDATE__GET_MERGED_PR__STEP_MOCK, + + // 2nd step normal +]; +const VALIDATE__OSBOTIFY__STEP_MOCKS = [ + VALIDATE__GET_MERGED_PR__OSBOTIFY__STEP_MOCK, + + // 2nd step normal +]; + +const DEPLOY_STAGING__CHECKOUT__STEP_MOCK = utils.getMockStep( + 'Checkout staging branch', + 'Checking out staging branch', + 'DEPLOY_STAGING', + ['ref', 'token'], +); +const DEPLOY_STAGING__SETUP_GIT__STEP_MOCK = utils.getMockStep( + 'Setup git for OSBotify', + 'Setting up git for OSBotify', + 'DEPLOY_STAGING', + ['GPG_PASSPHRASE'], +); +const DEPLOY_STAGING__TAG_VERSION__STEP_MOCK = utils.getMockStep( + 'Tag version', + 'Tagging new version', + 'DEPLOY_STAGING', +); +const DEPLOY_STAGING__PUSH_TAG__STEP_MOCK = utils.getMockStep( + '🚀 Push tags to trigger staging deploy 🚀', + 'Pushing tag to trigger staging deploy', + 'DEPLOY_STAGING', +); +const DEPLOY_STAGING_STEP_MOCKS = [ + DEPLOY_STAGING__CHECKOUT__STEP_MOCK, + DEPLOY_STAGING__SETUP_GIT__STEP_MOCK, + DEPLOY_STAGING__TAG_VERSION__STEP_MOCK, + DEPLOY_STAGING__PUSH_TAG__STEP_MOCK, +]; + +const DEPLOY_PRODUCTION__CHECKOUT__STEP_MOCK = utils.getMockStep( + 'Checkout', + 'Checking out', + 'DEPLOY_PRODUCTION', + ['fetch-depth', 'token'], +); +const DEPLOY_PRODUCTION__SETUP_GIT__STEP_MOCK = utils.getMockStep( + 'Setup git for OSBotify', + 'Setting up git for OSBotify', + 'DEPLOY_PRODUCTION', + ['GPG_PASSPHRASE'], +); +const DEPLOY_PRODUCTION__CHECKOUT_PRODUCTION__STEP_MOCK = utils.getMockStep( + 'Checkout production branch', + 'Checking out production branch', + 'DEPLOY_PRODUCTION', +); +const DEPLOY_PRODUCTION__CURRENT_APP_VERSION__STEP_MOCK = utils.getMockStep( + 'Get current app version', + 'Getting current app version', + 'DEPLOY_PRODUCTION', + null, + null, + null, + {PRODUCTION_VERSION: '1.2.3'}, +); +const DEPLOY_PRODUCTION__RELEASE_PR_LIST__STEP_MOCK = utils.getMockStep( + 'Get Release Pull Request List', + 'Getting release PR list', + 'DEPLOY_PRODUCTION', + ['TAG', 'GITHUB_TOKEN', 'IS_PRODUCTION_DEPLOY'], + null, + {PR_LIST: '["1.2.1", "1.2.2"]'}, +); +const DEPLOY_PRODUCTION__GENERATE_RELEASE_BODY__STEP_MOCK = utils.getMockStep( + 'Generate Release Body', + 'Generating release body', + 'DEPLOY_PRODUCTION', + ['PR_LIST'], + null, + {RELEASE_BODY: 'Release body'}, +); +const DEPLOY_PRODUCTION__CREATE_RELEASE__STEP_MOCK = utils.getMockStep( + '🚀 Create release to trigger production deploy 🚀', + 'Creating release to trigger production deploy', + 'DEPLOY_PRODUCTION', + ['tag_name', 'body'], + ['GITHUB_TOKEN'], +); +const DEPLOY_PRODUCTION_STEP_MOCKS = [ + DEPLOY_PRODUCTION__CHECKOUT__STEP_MOCK, + DEPLOY_PRODUCTION__SETUP_GIT__STEP_MOCK, + DEPLOY_PRODUCTION__CHECKOUT_PRODUCTION__STEP_MOCK, + DEPLOY_PRODUCTION__CURRENT_APP_VERSION__STEP_MOCK, + DEPLOY_PRODUCTION__RELEASE_PR_LIST__STEP_MOCK, + DEPLOY_PRODUCTION__GENERATE_RELEASE_BODY__STEP_MOCK, + DEPLOY_PRODUCTION__CREATE_RELEASE__STEP_MOCK, +]; + +module.exports = { + VALIDATE_STEP_MOCKS, + VALIDATE__OSBOTIFY__STEP_MOCKS, + DEPLOY_STAGING_STEP_MOCKS, + DEPLOY_PRODUCTION_STEP_MOCKS, +}; diff --git a/workflow_tests/utils.js b/workflow_tests/utils.js index c0023e9193f2..290d3ed292bd 100644 --- a/workflow_tests/utils.js +++ b/workflow_tests/utils.js @@ -3,7 +3,7 @@ const setUpActParams = (act, event = null, event_options = null, secrets = null, if (event && event_options) { updated_act = updated_act.setEvent({ - event: event_options, + [event]: event_options, }); } From 58d0a66afca36ee8c04c845c5dc91a0b91eeab5a Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Tue, 28 Feb 2023 16:28:51 +0100 Subject: [PATCH 027/504] Clean up preDeploy.test.js [WiP] Self-explanatory See: https://github.com/Expensify/App/issues/13604 --- workflow_tests/preDeploy.test.js | 48 +++++++++++++------------------- 1 file changed, 20 insertions(+), 28 deletions(-) diff --git a/workflow_tests/preDeploy.test.js b/workflow_tests/preDeploy.test.js index b9f7dd0c0117..afe9c673761b 100644 --- a/workflow_tests/preDeploy.test.js +++ b/workflow_tests/preDeploy.test.js @@ -23,21 +23,13 @@ const FILES_TO_COPY_INTO_TEST_REPO = [ src: path.resolve(__dirname, '..', '.github', 'workflows', 'preDeploy.yml'), dest: '.github/workflows/preDeploy.yml', }, - { - src: path.resolve(__dirname, '..', '.github', '.eslintrc.js'), - dest: '.github/.eslintrc.js', - }, - { - src: path.resolve(__dirname, '..', '.github', 'actionlint.yaml'), - dest: '.github/actionlint.yaml', - }, ]; beforeEach(async () => { // create a local repository and copy required files mockGithub = new kieMockGithub.MockGithub({ repo: { - testWorkflowsRepo: { + testPreDeployWorkflowRepo: { files: FILES_TO_COPY_INTO_TEST_REPO, }, }, @@ -53,7 +45,7 @@ afterEach(async () => { describe('test workflow preDeploy', () => { test('push to main - workflow executes', async () => { // get path to the local test repo - const repoPath = mockGithub.repo.getPath('testWorkflowsRepo') || ''; + const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; // get path to the workflow file under test const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); @@ -106,7 +98,7 @@ describe('test workflow preDeploy', () => { }, 60000); test('push to different branch - workflow does not execute', async () => { - const repoPath = mockGithub.repo.getPath('testWorkflowsRepo') || ''; + const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); let act = new kieActJs.Act(repoPath, workflowPath); act = utils.setUpActParams( @@ -146,7 +138,7 @@ describe('test workflow preDeploy', () => { }, 60000); test('different event than push - workflow does not execute', async () => { - const repoPath = mockGithub.repo.getPath('testWorkflowsRepo') || ''; + const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); let act = new kieActJs.Act(repoPath, workflowPath); const testMockSteps = { @@ -213,7 +205,7 @@ describe('test workflow preDeploy', () => { describe('confirm passing build', () => { test('lint job failed - workflow exits', async () => { - const repoPath = mockGithub.repo.getPath('testWorkflowsRepo') || ''; + const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); let act = new kieActJs.Act(repoPath, workflowPath); act = utils.setUpActParams( @@ -291,7 +283,7 @@ describe('test workflow preDeploy', () => { }, 60000); test('test job failed - workflow exits', async () => { - const repoPath = mockGithub.repo.getPath('testWorkflowsRepo') || ''; + const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); let act = new kieActJs.Act(repoPath, workflowPath); act = utils.setUpActParams( @@ -369,7 +361,7 @@ describe('test workflow preDeploy', () => { }, 60000); test('lint and test job succeed - workflow continues', async () => { - const repoPath = mockGithub.repo.getPath('testWorkflowsRepo') || ''; + const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); let act = new kieActJs.Act(repoPath, workflowPath); act = utils.setUpActParams( @@ -411,7 +403,7 @@ describe('test workflow preDeploy', () => { describe('new contributor welcome message', () => { test('actor is OSBotify - no comment left', async () => { - const repoPath = mockGithub.repo.getPath('testWorkflowsRepo') || ''; + const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); let act = new kieActJs.Act(repoPath, workflowPath); act = utils.setUpActParams( @@ -449,7 +441,7 @@ describe('test workflow preDeploy', () => { }, 60000); test('actor is Expensify employee - no comment left', async () => { - const repoPath = mockGithub.repo.getPath('testWorkflowsRepo') || ''; + const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); let act = new kieActJs.Act(repoPath, workflowPath); act = utils.setUpActParams( @@ -487,7 +479,7 @@ describe('test workflow preDeploy', () => { }, 60000); test('actor is not Expensify employee, its not their first PR - job triggers, but no comment left', async () => { - const repoPath = mockGithub.repo.getPath('testWorkflowsRepo') || ''; + const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); let act = new kieActJs.Act(repoPath, workflowPath); act = utils.setUpActParams( @@ -525,7 +517,7 @@ describe('test workflow preDeploy', () => { }, 60000); test('actor is not Expensify employee, and its their first PR - job triggers and comment left', async () => { - const repoPath = mockGithub.repo.getPath('testWorkflowsRepo') || ''; + const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); let act = new kieActJs.Act(repoPath, workflowPath); act = utils.setUpActParams( @@ -567,7 +559,7 @@ describe('test workflow preDeploy', () => { describe('no CP label', () => { describe('staging locked', () => { test('not automated PR - deploy skipped and comment left', async () => { - const repoPath = mockGithub.repo.getPath('testWorkflowsRepo') || ''; + const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); let act = new kieActJs.Act(repoPath, workflowPath); act = utils.setUpActParams( @@ -606,7 +598,7 @@ describe('test workflow preDeploy', () => { }, 60000); test('automated PR - deploy skipped, but no comment left', async () => { - const repoPath = mockGithub.repo.getPath('testWorkflowsRepo') || ''; + const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); let act = new kieActJs.Act(repoPath, workflowPath); act = utils.setUpActParams( @@ -647,7 +639,7 @@ describe('test workflow preDeploy', () => { describe('staging not locked', () => { test('not automated PR - proceed with deploy', async () => { - const repoPath = mockGithub.repo.getPath('testWorkflowsRepo') || ''; + const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); let act = new kieActJs.Act(repoPath, workflowPath); act = utils.setUpActParams( @@ -691,7 +683,7 @@ describe('test workflow preDeploy', () => { }, 60000); test('automated PR - deploy skipped, but no comment left', async () => { - const repoPath = mockGithub.repo.getPath('testWorkflowsRepo') || ''; + const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); let act = new kieActJs.Act(repoPath, workflowPath); act = utils.setUpActParams( @@ -738,7 +730,7 @@ describe('test workflow preDeploy', () => { describe('CP label', () => { describe('staging locked', () => { test('not automated PR - proceed with deploy', async () => { - const repoPath = mockGithub.repo.getPath('testWorkflowsRepo') || ''; + const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); let act = new kieActJs.Act(repoPath, workflowPath); act = utils.setUpActParams( @@ -782,7 +774,7 @@ describe('test workflow preDeploy', () => { }, 60000); test('automated PR - proceed with deploy', async () => { - const repoPath = mockGithub.repo.getPath('testWorkflowsRepo') || ''; + const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); let act = new kieActJs.Act(repoPath, workflowPath); act = utils.setUpActParams( @@ -828,7 +820,7 @@ describe('test workflow preDeploy', () => { describe('staging not locked', () => { test('not automated PR - proceed with deploy', async () => { - const repoPath = mockGithub.repo.getPath('testWorkflowsRepo') || ''; + const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); let act = new kieActJs.Act(repoPath, workflowPath); act = utils.setUpActParams( @@ -872,7 +864,7 @@ describe('test workflow preDeploy', () => { }, 60000); test('automated PR - proceed with deploy', async () => { - const repoPath = mockGithub.repo.getPath('testWorkflowsRepo') || ''; + const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); let act = new kieActJs.Act(repoPath, workflowPath); act = utils.setUpActParams( @@ -918,7 +910,7 @@ describe('test workflow preDeploy', () => { }); test('one of updateStaging steps failed - failure announced in Slack', async () => { - const repoPath = mockGithub.repo.getPath('testWorkflowsRepo') || ''; + const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); let act = new kieActJs.Act(repoPath, workflowPath); act = utils.setUpActParams( From d9842c060c1dd8b9542af41289a48300e27de186 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Wed, 1 Mar 2023 16:00:36 +0100 Subject: [PATCH 028/504] Tweak preDeploy config[WiP] Updated event options and local repo pushed branches See: https://github.com/Expensify/App/issues/13604 --- workflow_tests/preDeploy.test.js | 37 ++++++++++++++++---------------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/workflow_tests/preDeploy.test.js b/workflow_tests/preDeploy.test.js index afe9c673761b..4d33251e3534 100644 --- a/workflow_tests/preDeploy.test.js +++ b/workflow_tests/preDeploy.test.js @@ -31,6 +31,7 @@ beforeEach(async () => { repo: { testPreDeployWorkflowRepo: { files: FILES_TO_COPY_INTO_TEST_REPO, + pushedBranches: ['not_main'], }, }, }); @@ -57,7 +58,7 @@ describe('test workflow preDeploy', () => { act = utils.setUpActParams( act, 'push', - {head: {ref: 'main'}}, + {ref: 'refs/heads/main'}, { OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', }, @@ -104,7 +105,7 @@ describe('test workflow preDeploy', () => { act = utils.setUpActParams( act, 'push', - {head: {ref: 'not_main'}}, + {ref: 'refs/heads/not_main'}, { OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', }, @@ -211,7 +212,7 @@ describe('test workflow preDeploy', () => { act = utils.setUpActParams( act, 'push', - {head: {ref: 'main'}}, + {ref: 'refs/heads/main'}, { OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', }, @@ -289,7 +290,7 @@ describe('test workflow preDeploy', () => { act = utils.setUpActParams( act, 'push', - {head: {ref: 'main'}}, + {ref: 'refs/heads/main'}, { OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', }, @@ -367,7 +368,7 @@ describe('test workflow preDeploy', () => { act = utils.setUpActParams( act, 'push', - {head: {ref: 'main'}}, + {ref: 'refs/heads/main'}, { OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', }, @@ -409,7 +410,7 @@ describe('test workflow preDeploy', () => { act = utils.setUpActParams( act, 'push', - {head: {ref: 'main'}}, + {ref: 'refs/heads/main'}, { OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'OSBotify', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', }, @@ -447,7 +448,7 @@ describe('test workflow preDeploy', () => { act = utils.setUpActParams( act, 'push', - {head: {ref: 'main'}}, + {ref: 'refs/heads/main'}, { OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', }, @@ -485,7 +486,7 @@ describe('test workflow preDeploy', () => { act = utils.setUpActParams( act, 'push', - {head: {ref: 'main'}}, + {ref: 'refs/heads/main'}, { OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', }, @@ -523,7 +524,7 @@ describe('test workflow preDeploy', () => { act = utils.setUpActParams( act, 'push', - {head: {ref: 'main'}}, + {ref: 'refs/heads/main'}, { OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', }, @@ -565,7 +566,7 @@ describe('test workflow preDeploy', () => { act = utils.setUpActParams( act, 'push', - {head: {ref: 'main'}}, + {ref: 'refs/heads/main'}, {OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook'}, 'dummy_github_token', ); @@ -604,7 +605,7 @@ describe('test workflow preDeploy', () => { act = utils.setUpActParams( act, 'push', - {head: {ref: 'main'}}, + {ref: 'refs/heads/main'}, {OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'OSBotify', SLACK_WEBHOOK: 'dummy_slack_webhook'}, 'dummy_github_token', ); @@ -645,7 +646,7 @@ describe('test workflow preDeploy', () => { act = utils.setUpActParams( act, 'push', - {head: {ref: 'main'}}, + {ref: 'refs/heads/main'}, { OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', @@ -689,7 +690,7 @@ describe('test workflow preDeploy', () => { act = utils.setUpActParams( act, 'push', - {head: {ref: 'main'}}, + {ref: 'refs/heads/main'}, { OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'OSBotify', @@ -736,7 +737,7 @@ describe('test workflow preDeploy', () => { act = utils.setUpActParams( act, 'push', - {head: {ref: 'main'}}, + {ref: 'refs/heads/main'}, { OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', @@ -780,7 +781,7 @@ describe('test workflow preDeploy', () => { act = utils.setUpActParams( act, 'push', - {head: {ref: 'main'}}, + {ref: 'refs/heads/main'}, { OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'OSBotify', @@ -826,7 +827,7 @@ describe('test workflow preDeploy', () => { act = utils.setUpActParams( act, 'push', - {head: {ref: 'main'}}, + {ref: 'refs/heads/main'}, { OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', @@ -870,7 +871,7 @@ describe('test workflow preDeploy', () => { act = utils.setUpActParams( act, 'push', - {head: {ref: 'main'}}, + {ref: 'refs/heads/main'}, { OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'OSBotify', @@ -916,7 +917,7 @@ describe('test workflow preDeploy', () => { act = utils.setUpActParams( act, 'push', - {head: {ref: 'main'}}, + {ref: 'refs/heads/main'}, { OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'OSBotify', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', }, From 0371c3cf4e2b5e595d04b435329c298132d1f902 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Wed, 1 Mar 2023 16:03:43 +0100 Subject: [PATCH 029/504] Add test for different event Added test checking if deploy workflow does not execute on a different event than push See: https://github.com/Expensify/App/issues/13604 --- workflow_tests/deploy.test.js | 53 +++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/workflow_tests/deploy.test.js b/workflow_tests/deploy.test.js index d8fe903beb4b..02f2accdf98d 100644 --- a/workflow_tests/deploy.test.js +++ b/workflow_tests/deploy.test.js @@ -238,4 +238,57 @@ describe('test workflow deploy', () => { assertions.assertDeployProductionJobExecuted(result, false); }, 60000); }); + + test('different event than push - workflow does not execute', async () => { + const repoPath = mockGithub.repo.getPath('testdeployWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'deploy.yml'); + let act = new kieActJs.Act(repoPath, workflowPath); + const testMockSteps = { + validate: mocks.VALIDATE__OSBOTIFY__STEP_MOCKS, + deployStaging: mocks.DEPLOY_STAGING_STEP_MOCKS, + deployProduction: mocks.DEPLOY_PRODUCTION_STEP_MOCKS, + }; + + // pull_request + act = utils.setUpActParams( + act, + 'pull_request', + {head: {ref: 'main'}}, + { + GITHUB_ACTOR: 'Dummy Author', + OS_BOTIFY_TOKEN: 'dummy_token', + LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', + }, + 'dummy_github_token', + ); + let result = await act + .runEvent('pull_request', { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + }); + assertions.assertValidateJobExecuted(result, false); + assertions.assertDeployStagingJobExecuted(result, false); + assertions.assertDeployProductionJobExecuted(result, false); + + // workflow_dispatch + act = utils.setUpActParams( + act, + 'workflow_dispatch', + {}, + { + GITHUB_ACTOR: 'Dummy Author', + OS_BOTIFY_TOKEN: 'dummy_token', + LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', + }, + 'dummy_github_token', + ); + result = await act + .runEvent('workflow_dispatch', { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + }); + assertions.assertValidateJobExecuted(result, false); + assertions.assertDeployStagingJobExecuted(result, false); + assertions.assertDeployProductionJobExecuted(result, false); + }, 60000); }); From 67b9540e4c425312a650a07e8f37238ad4af75eb Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Thu, 2 Mar 2023 15:57:16 +0100 Subject: [PATCH 030/504] Add first platformDeploy test Added test first working test for platformDeploy workflow, along with all the mocks and assertions See: https://github.com/Expensify/App/issues/13604 --- .github/workflows/platformDeploy.yml | 45 +- .../assertions/platformDeployAssertions.js | 590 ++++++++++++++++++ workflow_tests/mocks/platformDeployMocks.js | 445 +++++++++++++ workflow_tests/platformDeploy.test.js | 108 ++++ workflow_tests/utils.js | 8 +- 5 files changed, 1180 insertions(+), 16 deletions(-) create mode 100644 workflow_tests/assertions/platformDeployAssertions.js create mode 100644 workflow_tests/mocks/platformDeployMocks.js create mode 100644 workflow_tests/platformDeploy.test.js diff --git a/.github/workflows/platformDeploy.yml b/.github/workflows/platformDeploy.yml index 3884f88e4ff2..ba9c89a60ded 100644 --- a/.github/workflows/platformDeploy.yml +++ b/.github/workflows/platformDeploy.yml @@ -18,7 +18,8 @@ jobs: outputs: IS_DEPLOYER: ${{ fromJSON(steps.isUserDeployer.outputs.isTeamMember) || github.actor == 'OSBotify' }} steps: - - id: isUserDeployer + - name: Check if user is deployer + id: isUserDeployer uses: tspascoal/get-user-teams-membership@baf2e6adf4c3b897bd65a7e3184305c165aec872 with: GITHUB_TOKEN: ${{ secrets.OS_BOTIFY_TOKEN }} @@ -32,13 +33,16 @@ jobs: runs-on: ubuntu-latest steps: # This action checks-out the repository, so the workflow can access it. - - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 + - name: Checkout + uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 with: fetch-depth: 0 - - uses: Expensify/App/.github/actions/composite/setupNode@main + - name: Setup Node + uses: Expensify/App/.github/actions/composite/setupNode@main - - uses: ruby/setup-ruby@eae47962baca661befdfd24e4d6c34ade04858f7 + - name: Setup Ruby + uses: ruby/setup-ruby@eae47962baca661befdfd24e4d6c34ade04858f7 with: ruby-version: '2.7' bundler-cache: true @@ -106,11 +110,13 @@ jobs: runs-on: macos-12 steps: # This action checks-out the repository, so the workflow can access it. - - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 + - name: Checkout + uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 with: fetch-depth: 0 - - uses: Expensify/App/.github/actions/composite/setupNode@main + - name: Setup Node + uses: Expensify/App/.github/actions/composite/setupNode@main - name: Decrypt Developer ID Certificate run: cd desktop && gpg --quiet --batch --yes --decrypt --passphrase="$DEVELOPER_ID_SECRET_PASSPHRASE" --output developer_id.p12 developer_id.p12.gpg @@ -146,13 +152,16 @@ jobs: runs-on: macos-12-xl steps: # This action checks-out the repository, so the workflow can access it. - - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 + - name: Checkout + uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 with: fetch-depth: 0 - - uses: Expensify/App/.github/actions/composite/setupNode@main + - name: Setup Node + uses: Expensify/App/.github/actions/composite/setupNode@main - - uses: ruby/setup-ruby@eae47962baca661befdfd24e4d6c34ade04858f7 + - name: Setup Ruby + uses: ruby/setup-ruby@eae47962baca661befdfd24e4d6c34ade04858f7 with: ruby-version: '2.7' bundler-cache: true @@ -235,11 +244,13 @@ jobs: runs-on: ubuntu-latest steps: # This action checks-out the repository, so the workflow can access it. - - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 + - name: Checkout + uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 with: fetch-depth: 0 - - uses: Expensify/App/.github/actions/composite/setupNode@main + - name: Setup Node + uses: Expensify/App/.github/actions/composite/setupNode@main - name: Setup Cloudflare CLI run: pip3 install cloudflare @@ -288,7 +299,8 @@ jobs: if: ${{ failure() }} needs: [android, desktop, iOS, web] steps: - - uses: Expensify/App/.github/actions/composite/announceFailedWorkflowInSlack@main + - name: Post Slack message on failure + uses: Expensify/App/.github/actions/composite/announceFailedWorkflowInSlack@main with: SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} @@ -298,7 +310,8 @@ jobs: if: ${{ success() }} needs: [android, desktop, iOS, web] steps: - - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 + - name: Checkout + uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 - name: Set version run: echo "VERSION=$(npm run print-version --silent)" >> "$GITHUB_ENV" @@ -359,11 +372,13 @@ jobs: needs: [android, desktop, iOS, web] steps: # This action checks-out the repository, so the workflow can access it. - - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 + - name: Checkout + uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 with: fetch-depth: 0 - - uses: Expensify/App/.github/actions/composite/setupNode@main + - name: Setup Node + uses: Expensify/App/.github/actions/composite/setupNode@main - name: Set version run: echo "VERSION=$(npm run print-version --silent)" >> "$GITHUB_ENV" diff --git a/workflow_tests/assertions/platformDeployAssertions.js b/workflow_tests/assertions/platformDeployAssertions.js new file mode 100644 index 000000000000..7f39f280dd36 --- /dev/null +++ b/workflow_tests/assertions/platformDeployAssertions.js @@ -0,0 +1,590 @@ +const utils = require('../utils'); + +const assertVerifyActorJobExecuted = (workflowResult, didExecute = true) => { + const steps = [ + utils.getStepAssertion( + 'Check if user is deployer', + true, + null, + 'VALIDATE_ACTOR', + 'Checking if the user is a deployer', + [{key: 'GITHUB_TOKEN', value: '***'}, {key: 'team', value: 'mobile-deployers'}], + ), + ]; + if (didExecute) { + expect(workflowResult).toEqual(expect.arrayContaining(steps)); + } else { + expect(workflowResult).not.toEqual(expect.arrayContaining(steps)); + } +}; + +const assertAndroidJobExecuted = (workflowResult, didExecute = true, isProduction = true, isSuccessful = true) => { + const steps = [ + utils.getStepAssertion( + 'Checkout', + true, + null, + 'ANDROID', + 'Checking out', + [{key: 'fetch-depth', value: '0'}], + ), + utils.getStepAssertion( + 'Setup Node', + true, + null, + 'ANDROID', + 'Setting up Node', + ), + utils.getStepAssertion( + 'Setup Ruby', + true, + null, + 'ANDROID', + 'Setting up Ruby', + [{key: 'ruby-version', value: '2.7'}, {key: 'bundler-cache', value: 'true'}], + ), + utils.getStepAssertion( + 'Decrypt keystore', + true, + null, + 'ANDROID', + 'Decrypting keystore', + null, + [{key: 'LARGE_SECRET_PASSPHRASE', value: '***'}], + ), + utils.getStepAssertion( + 'Decrypt json key', + true, + null, + 'ANDROID', + 'Decrypting JSON key', + null, + [{key: 'LARGE_SECRET_PASSPHRASE', value: '***'}], + ), + utils.getStepAssertion( + 'Set version in ENV', + true, + null, + 'ANDROID', + 'Setting version in ENV', + ), + ]; + if (!isProduction) { + steps.push( + utils.getStepAssertion( + '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( + utils.getStepAssertion( + 'Run Fastlane production', + true, + null, + 'ANDROID', + 'Running Fastlane production', + null, + [{key: 'VERSION', value: '1.2.3'}], + ), + ); + } + steps.push( + utils.getStepAssertion( + 'Archive Android sourcemaps', + true, + null, + 'ANDROID', + 'Archiving Android sourcemaps', + [{key: 'name', value: 'android-sourcemap'}, {key: 'path', value: 'android/app/build/generated/sourcemaps/react/release/*.map'}], + ), + ); + if (!isProduction) { + steps.push( + utils.getStepAssertion( + 'Upload Android version to Browser Stack', + true, + null, + 'ANDROID', + 'Uploading Android version to Browser Stack', + null, + [{key: 'BROWSERSTACK', value: '***'}], + ), + ); + } + if (didExecute) { + expect(workflowResult).toEqual(expect.arrayContaining(steps)); + } else { + expect(workflowResult).not.toEqual(expect.arrayContaining(steps)); + } + + const failProdSteps = [ + utils.getStepAssertion( + 'Warn deployers if Android production deploy failed', + true, + null, + 'ANDROID', + 'Warning deployers of failed production deploy', + [{key: 'status', value: 'custom'}, {key: 'custom_payload', value: '{\n channel: \'#deployer\',\n attachments: [{\n color: "#DB4545",\n pretext: ``,\n text: `💥 Android production deploy failed. Please manually submit 1.2.3 in the . 💥`,\n }]\n}'}], + [{key: 'GITHUB_TOKEN', value: '***'}, {key: 'SLACK_WEBHOOK_URL', value: '***'}], + ), + ]; + if (didExecute && isProduction && !isSuccessful) { + expect(workflowResult).toEqual(expect.arrayContaining(failProdSteps)); + } else { + expect(workflowResult).not.toEqual(expect.arrayContaining(failProdSteps)); + } +}; + +const assertDesktopJobExecuted = (workflowResult, didExecute = true, isProduction = true) => { + const steps = [ + utils.getStepAssertion( + 'Checkout', + true, + null, + 'DESKTOP', + 'Checking out', + [{key: 'fetch-depth', value: '0'}], + ), + utils.getStepAssertion( + 'Setup Node', + true, + null, + 'DESKTOP', + 'Setting up Node', + ), + utils.getStepAssertion( + 'Decrypt Developer ID Certificate', + true, + null, + 'DESKTOP', + 'Decrypting developer id certificate', + null, + [{key: 'DEVELOPER_ID_SECRET_PASSPHRASE', value: '***'}], + ), + ]; + if (isProduction) { + steps.push( + utils.getStepAssertion( + '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_ID_PASSWORD', value: '***'}, {key: 'AWS_ACCESS_KEY_ID', value: '***'}, {key: 'AWS_SECRET_ACCESS_KEY', value: '***'}], + ), + ); + } else { + steps.push( + utils.getStepAssertion( + '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_ID_PASSWORD', value: '***'}, {key: 'AWS_ACCESS_KEY_ID', value: '***'}, {key: 'AWS_SECRET_ACCESS_KEY', value: '***'}], + ), + ); + } + + if (didExecute) { + expect(workflowResult).toEqual(expect.arrayContaining(steps)); + } else { + expect(workflowResult).not.toEqual(expect.arrayContaining(steps)); + } +}; + +const assertIOSJobExecuted = (workflowResult, didExecute = true, isProduction = true, isSuccessful = true) => { + const steps = [ + utils.getStepAssertion( + 'Checkout', + true, + null, + 'IOS', + 'Checking out', + [{key: 'fetch-depth', value: '0'}], + ), + utils.getStepAssertion( + 'Setup Node', + true, + null, + 'IOS', + 'Setting up Node', + ), + utils.getStepAssertion( + 'Setup Ruby', + true, + null, + 'IOS', + 'Setting up Ruby', + [{key: 'ruby-version', value: '2.7'}, {key: 'bundler-cache', value: 'true'}], + ), + utils.getStepAssertion( + 'Install cocoapods', + true, + null, + 'IOS', + 'Installing cocoapods', + [{key: 'timeout_minutes', value: '10'}, {key: 'max_attempts', value: '5'}, {key: 'command', value: 'cd ios && pod install'}], + ), + utils.getStepAssertion( + 'Decrypt profile', + true, + null, + 'IOS', + 'Decrypting profile', + null, + [{key: 'LARGE_SECRET_PASSPHRASE', value: '***'}], + ), + utils.getStepAssertion( + 'Decrypt certificate', + true, + null, + 'IOS', + 'Decrypting certificate', + null, + [{key: 'LARGE_SECRET_PASSPHRASE', value: '***'}], + ), + utils.getStepAssertion( + 'Decrypt App Store Connect API key', + true, + null, + 'IOS', + 'Decrypting App Store API key', + null, + [{key: 'LARGE_SECRET_PASSPHRASE', value: '***'}], + ), + ]; + if (!isProduction) { + steps.push( + utils.getStepAssertion( + '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( + utils.getStepAssertion( + 'Archive iOS sourcemaps', + true, + null, + 'IOS', + 'Archiving sourcemaps', + [{key: 'name', value: 'ios-sourcemap'}, {key: 'path', value: 'main.jsbundle.map'}], + ), + ); + if (!isProduction) { + steps.push( + utils.getStepAssertion( + 'Upload iOS version to Browser Stack', + true, + null, + 'IOS', + 'Uploading version to Browser Stack', + null, + [{key: 'BROWSERSTACK', value: '***'}], + ), + ); + } else { + steps.push( + utils.getStepAssertion( + 'Set iOS version in ENV', + true, + null, + 'IOS', + 'Setting iOS version', + ), + utils.getStepAssertion( + 'Run Fastlane for App Store release', + true, + null, + 'IOS', + 'Running Fastlane for release', + null, + [{key: 'VERSION', value: '1.2.3'}], + ), + ); + } + if (didExecute) { + expect(workflowResult).toEqual(expect.arrayContaining(steps)); + } else { + expect(workflowResult).not.toEqual(expect.arrayContaining(steps)); + } + + const failProdSteps = [ + utils.getStepAssertion( + 'Warn deployers if iOS production deploy failed', + true, + null, + 'IOS', + 'Warning developers of failed deploy', + [{key: 'status', value: 'custom'}, {key: 'custom_payload', value: '{\n channel: \'#deployer\',\n attachments: [{\n color: "#DB4545",\n pretext: ``,\n text: `💥 iOS production deploy failed. Please manually submit 1.2.3 in the . 💥`,\n }]\n}'}], + [{key: 'GITHUB_TOKEN', value: '***'}, {key: 'SLACK_WEBHOOK_URL', value: '***'}], + ), + ]; + if (didExecute && isProduction && !isSuccessful) { + expect(workflowResult).toEqual(expect.arrayContaining(failProdSteps)); + } else { + expect(workflowResult).not.toEqual(expect.arrayContaining(failProdSteps)); + } +}; + +const assertWebJobExecuted = (workflowResult, didExecute = true, isProduction = true) => { + const steps = [ + utils.getStepAssertion( + 'Checkout', + true, + null, + 'WEB', + 'Checking out', + [{key: 'fetch-depth', value: '0'}], + ), + utils.getStepAssertion( + 'Setup Node', + true, + null, + 'WEB', + 'Setting up Node', + ), + utils.getStepAssertion( + 'Setup Cloudflare CLI', + true, + null, + 'WEB', + 'Setting up Cloudflare CLI', + ), + utils.getStepAssertion( + 'Configure AWS Credentials', + true, + null, + 'WEB', + 'Configuring AWS credentials', + [{key: 'AWS_ACCESS_KEY_ID', value: '***'}, {key: 'AWS_SECRET_ACCESS_KEY', value: '***'}], + ), + ]; + if (isProduction) { + steps.push( + utils.getStepAssertion( + 'Build web for production', + true, + null, + 'WEB', + 'Building web for production', + ), + ); + } else { + steps.push( + utils.getStepAssertion( + 'Build web for staging', + true, + null, + 'WEB', + 'Building web for staging', + ), + ); + } + steps.push( + utils.getStepAssertion( + 'Build docs', + true, + null, + 'WEB', + 'Building docs', + ), + ); + if (isProduction) { + steps.push( + utils.getStepAssertion( + 'Deploy production to S3', + true, + null, + 'WEB', + 'Deploying production to S3', + ), + utils.getStepAssertion( + 'Purge production Cloudflare cache', + true, + null, + 'WEB', + 'Purging production Cloudflare cache', + null, + [{key: 'CF_API_KEY', value: '***'}], + ), + ); + } else { + steps.push( + utils.getStepAssertion( + 'Deploy staging to S3', + true, + null, + 'WEB', + 'Deploying staging to S3', + ), + utils.getStepAssertion( + 'Purge staging Cloudflare cache', + true, + null, + 'WEB', + 'Purging staging Cloudflare cache', + null, + [{key: 'CF_API_KEY', value: '***'}], + ), + ); + } + + if (didExecute) { + expect(workflowResult).toEqual(expect.arrayContaining(steps)); + } else { + expect(workflowResult).not.toEqual(expect.arrayContaining(steps)); + } +}; + +const assertPostSlackOnFailureJobExecuted = (workflowResult, didExecute = true) => { + const steps = [ + utils.getStepAssertion( + 'Post Slack message on failure', + true, + null, + 'POST_SLACK_FAIL', + 'Posting Slack message on platform deploy failure', + [{key: 'SLACK_WEBHOOK', value: '***'}], + ), + ]; + + if (didExecute) { + expect(workflowResult).toEqual(expect.arrayContaining(steps)); + } else { + expect(workflowResult).not.toEqual(expect.arrayContaining(steps)); + } +}; + +const assertPostSlackOnSuccessJobExecuted = (workflowResult, didExecute = true, isProduction = true) => { + const steps = [ + utils.getStepAssertion( + 'Checkout', + true, + null, + 'POST_SLACK_SUCCESS', + 'Checking out', + ), + utils.getStepAssertion( + 'Set version', + true, + null, + 'POST_SLACK_SUCCESS', + 'Setting version', + ), + utils.getStepAssertion( + 'Announces the deploy in the #announce Slack room', + true, + null, + 'POST_SLACK_SUCCESS', + 'Posting message to #announce channel', + [{key: 'status', value: 'custom'}, {key: 'custom_payload', value: isProduction ? '{\n channel: \'#announce\',\n attachments: [{\n color: \'good\',\n text: `🎉️ Successfully deployed App to production 🎉️`,\n }]\n}' : '{\n channel: \'#announce\',\n attachments: [{\n color: \'good\',\n text: `🎉️ Successfully deployed App to staging 🎉️`,\n }]\n}'}], + [{key: 'GITHUB_TOKEN', value: '***'}, {key: 'SLACK_WEBHOOK_URL', value: '***'}], + ), + utils.getStepAssertion( + 'Announces the deploy in the #deployer Slack room', + true, + null, + 'POST_SLACK_SUCCESS', + 'Posting message to #deployer channel', + [{key: 'status', value: 'custom'}, {key: 'custom_payload', value: isProduction ? '{\n channel: \'#announce\',\n attachments: [{\n color: \'good\',\n text: `🎉️ Successfully deployed App to production 🎉️`,\n }]\n}' : '{\n channel: \'#announce\',\n attachments: [{\n color: \'good\',\n text: `🎉️ Successfully deployed App to staging 🎉️`,\n }]\n}'}], + [{key: 'GITHUB_TOKEN', value: '***'}, {key: 'SLACK_WEBHOOK_URL', value: '***'}], + ), + ]; + if (isProduction) { + steps.push( + utils.getStepAssertion( + 'Announces the deploy in the #expensify-open-source Slack room', + true, + null, + 'POST_SLACK_SUCCESS', + 'Posting message to #expensify-open-source channel', + [{key: 'status', value: 'custom'}, { + key: 'custom_payload', + value: '{\n channel: \'#announce\',\n attachments: [{\n color: \'good\',\n text: `🎉️ Successfully deployed App to production 🎉️`,\n }]\n}', + }], + [{key: 'GITHUB_TOKEN', value: '***'}, {key: 'SLACK_WEBHOOK_URL', value: '***'}], + ), + ); + } + + if (didExecute) { + expect(workflowResult).toEqual(expect.arrayContaining(steps)); + } else { + expect(workflowResult).not.toEqual(expect.arrayContaining(steps)); + } +}; + +const assertPostGithubCommentJobExecuted = (workflowResult, didExecute = true, isProduction = true) => { + const steps = [ + utils.getStepAssertion( + 'Checkout', + true, + null, + 'POST_GITHUB_COMMENT', + 'Checking out', + [{key: 'fetch-depth', value: '0'}], + ), + utils.getStepAssertion( + 'Setup Node', + true, + null, + 'POST_GITHUB_COMMENT', + 'Setting up Node', + ), + utils.getStepAssertion( + 'Set version', + true, + null, + 'POST_GITHUB_COMMENT', + 'Setting version', + ), + utils.getStepAssertion( + 'Get Release Pull Request List', + true, + null, + 'POST_GITHUB_COMMENT', + 'Getting release pull request list', + [{key: 'TAG', value: '1.2.3'}, {key: 'GITHUB_TOKEN', value: '***'}, {key: 'IS_PRODUCTION_DEPLOY', value: isProduction ? 'true' : 'false'}], + ), + utils.getStepAssertion( + 'Comment on issues', + true, + null, + 'POST_GITHUB_COMMENT', + 'Commenting on issues', + [{key: 'PR_LIST', value: '[1.2.1, 1.2.2]'}, {key: 'IS_PRODUCTION_DEPLOY', value: isProduction ? 'true' : 'false'}, {key: 'DEPLOY_VERSION', value: '1.2.3'}, {key: 'GITHUB_TOKEN', value: '***'}, {key: 'ANDROID', value: 'success'}, {key: 'DESKTOP', value: ''}, {key: 'IOS', value: ''}, {key: 'WEB', value: 'success'}], // unsupported runners for desktop and ios + ), + ]; + + if (didExecute) { + expect(workflowResult).toEqual(expect.arrayContaining(steps)); + } else { + expect(workflowResult).not.toEqual(expect.arrayContaining(steps)); + } +}; + +module.exports = { + assertVerifyActorJobExecuted, + assertAndroidJobExecuted, + assertDesktopJobExecuted, + assertIOSJobExecuted, + assertWebJobExecuted, + assertPostSlackOnFailureJobExecuted, + assertPostSlackOnSuccessJobExecuted, + assertPostGithubCommentJobExecuted, +}; diff --git a/workflow_tests/mocks/platformDeployMocks.js b/workflow_tests/mocks/platformDeployMocks.js new file mode 100644 index 000000000000..4253a76640da --- /dev/null +++ b/workflow_tests/mocks/platformDeployMocks.js @@ -0,0 +1,445 @@ +const utils = require('../utils'); + +// validateActor +const PLATFORM_DEPLOY__VALIDATE_ACTOR__CHECK_USER_DEPLOYER__TEAM_MEMBER__STEP_MOCK = utils.getMockStep( + 'Check if user is deployer', + 'Checking if the user is a deployer', + 'VALIDATE_ACTOR', + ['GITHUB_TOKEN', 'team'], + null, + {isTeamMember: true}, +); +const PLATFORM_DEPLOY__VALIDATE_ACTOR__CHECK_USER_DEPLOYER__OUTSIDER__STEP_MOCK = utils.getMockStep( + 'Check if user is deployer', + 'Checking if the user is a deployer', + 'VALIDATE_ACTOR', + ['GITHUB_TOKEN', 'username', 'team'], + null, + {isTeamMember: false}, +); +const PLATFORM_DEPLOY__VALIDATE_ACTOR__TEAM_MEMBER__STEP_MOCKS = [ + PLATFORM_DEPLOY__VALIDATE_ACTOR__CHECK_USER_DEPLOYER__TEAM_MEMBER__STEP_MOCK, +]; +const PLATFORM_DEPLOY__VALIDATE_ACTOR__OUTSIDER__STEP_MOCKS = [ + PLATFORM_DEPLOY__VALIDATE_ACTOR__CHECK_USER_DEPLOYER__OUTSIDER__STEP_MOCK, +]; + +// android +const PLATFORM_DEPLOY__ANDROID__CHECKOUT__STEP_MOCK = utils.getMockStep( + 'Checkout', + 'Checking out', + 'ANDROID', + ['fetch-depth'], +); +const PLATFORM_DEPLOY__ANDROID__SETUP_NODE__STEP_MOCK = utils.getMockStep( + 'Setup Node', + 'Setting up Node', + 'ANDROID', +); +const PLATFORM_DEPLOY__ANDROID__SETUP_RUBY__STEP_MOCK = utils.getMockStep( + 'Setup Ruby', + 'Setting up Ruby', + 'ANDROID', + ['ruby-version', 'bundler-cache'], +); +const PLATFORM_DEPLOY__ANDROID__DECRYPT_KEYSTORE__STEP_MOCK = utils.getMockStep( + 'Decrypt keystore', + 'Decrypting keystore', + 'ANDROID', + null, + ['LARGE_SECRET_PASSPHRASE'], +); +const PLATFORM_DEPLOY__ANDROID__DECRYPT_JSON_KEY__STEP_MOCK = utils.getMockStep( + 'Decrypt json key', + 'Decrypting JSON key', + 'ANDROID', + null, + ['LARGE_SECRET_PASSPHRASE'], +); +const PLATFORM_DEPLOY__ANDROID__SET_VERSION__STEP_MOCK = utils.getMockStep( + 'Set version in ENV', + 'Setting version in ENV', + 'ANDROID', + null, + null, + null, + {VERSION_CODE: '1.2.3'}, +); +const PLATFORM_DEPLOY__ANDROID__FASTLANE_BETA__STEP_MOCK = utils.getMockStep( + 'Run Fastlane beta', + 'Running Fastlane beta', + 'ANDROID', + null, + ['MYAPP_UPLOAD_STORE_PASSWORD', 'MYAPP_UPLOAD_KEY_PASSWORD'], +); +const PLATFORM_DEPLOY__ANDROID__FASTLANE_PRODUCTION__STEP_MOCK = utils.getMockStep( + 'Run Fastlane production', + 'Running Fastlane production', + 'ANDROID', + null, + ['VERSION'], +); +const PLATFORM_DEPLOY__ANDROID__ARCHIVE_SOURCEMAPS__STEP_MOCK = utils.getMockStep( + 'Archive Android sourcemaps', + 'Archiving Android sourcemaps', + 'ANDROID', + ['name', 'path'], +); +const PLATFORM_DEPLOY__ANDROID__UPLOAD_TO_BROWSER_STACK__STEP_MOCK = utils.getMockStep( + 'Upload Android version to Browser Stack', + 'Uploading Android version to Browser Stack', + 'ANDROID', + null, + ['BROWSERSTACK'], +); +const PLATFORM_DEPLOY__ANDROID__WARN_DEPLOYERS__STEP_MOCK = utils.getMockStep( + 'Warn deployers if Android production deploy failed', + 'Warning deployers of failed production deploy', + 'ANDROID', + ['status', 'custom_payload'], + ['GITHUB_TOKEN', 'SLACK_WEBHOOK_URL'], +); +const PLATFORM_DEPLOY__ANDROID__STEP_MOCKS = [ + PLATFORM_DEPLOY__ANDROID__CHECKOUT__STEP_MOCK, + PLATFORM_DEPLOY__ANDROID__SETUP_NODE__STEP_MOCK, + PLATFORM_DEPLOY__ANDROID__SETUP_RUBY__STEP_MOCK, + PLATFORM_DEPLOY__ANDROID__DECRYPT_KEYSTORE__STEP_MOCK, + PLATFORM_DEPLOY__ANDROID__DECRYPT_JSON_KEY__STEP_MOCK, + PLATFORM_DEPLOY__ANDROID__SET_VERSION__STEP_MOCK, + PLATFORM_DEPLOY__ANDROID__FASTLANE_BETA__STEP_MOCK, + PLATFORM_DEPLOY__ANDROID__FASTLANE_PRODUCTION__STEP_MOCK, + PLATFORM_DEPLOY__ANDROID__ARCHIVE_SOURCEMAPS__STEP_MOCK, + PLATFORM_DEPLOY__ANDROID__UPLOAD_TO_BROWSER_STACK__STEP_MOCK, + PLATFORM_DEPLOY__ANDROID__WARN_DEPLOYERS__STEP_MOCK, +]; + +// desktop +const PLATFORM_DEPLOY__DESKTOP__CHECKOUT__STEP_MOCK = utils.getMockStep( + 'Checkout', + 'Checking out', + 'DESKTOP', + ['fetch-depth'], +); +const PLATFORM_DEPLOY__DESKTOP__SETUP_NODE__STEP_MOCK = utils.getMockStep( + 'Setup Node', + 'Setting up Node', + 'DESKTOP', +); +const PLATFORM_DEPLOY__DESKTOP__DECRYPT_ID__STEP_MOCK = utils.getMockStep( + 'Decrypt Developer ID Certificate', + 'Decrypting developer id certificate', + 'DESKTOP', + null, + ['DEVELOPER_ID_SECRET_PASSPHRASE'], +); +const PLATFORM_DEPLOY__DESKTOP__BUILD_PRODUCTION__STEP_MOCK = utils.getMockStep( + 'Build production desktop app', + 'Building production desktop app', + 'DESKTOP', + null, + ['CSC_LINK', 'CSC_KEY_PASSWORD', 'APPLE_ID', 'APPLE_ID_PASSWORD', 'AWS_ACCESS_KEY_ID', 'AWS_SECRET_ACCESS_KEY'], +); +const PLATFORM_DEPLOY__DESKTOP__BUILD_STAGING__STEP_MOCK = utils.getMockStep( + 'Build staging desktop app', + 'Building staging desktop app', + 'DESKTOP', + null, + ['CSC_LINK', 'CSC_KEY_PASSWORD', 'APPLE_ID', 'APPLE_ID_PASSWORD', 'AWS_ACCESS_KEY_ID', 'AWS_SECRET_ACCESS_KEY'], +); +const PLATFORM_DEPLOY__DESKTOP__STEP_MOCKS = [ + PLATFORM_DEPLOY__DESKTOP__CHECKOUT__STEP_MOCK, + PLATFORM_DEPLOY__DESKTOP__SETUP_NODE__STEP_MOCK, + PLATFORM_DEPLOY__DESKTOP__DECRYPT_ID__STEP_MOCK, + PLATFORM_DEPLOY__DESKTOP__BUILD_PRODUCTION__STEP_MOCK, + PLATFORM_DEPLOY__DESKTOP__BUILD_STAGING__STEP_MOCK, +]; + +// ios +const PLATFORM_DEPLOY__IOS__CHECKOUT__STEP_MOCK = utils.getMockStep( + 'Checkout', + 'Checking out', + 'IOS', + ['fetch-depth'], +); +const PLATFORM_DEPLOY__IOS__SETUP_NODE__STEP_MOCK = utils.getMockStep( + 'Setup Node', + 'Setting up Node', + 'IOS', +); +const PLATFORM_DEPLOY__IOS__SETUP_RUBY__STEP_MOCK = utils.getMockStep( + 'Setup Ruby', + 'Setting up Ruby', + 'IOS', + ['ruby-version', 'bundler-cache'], +); +const PLATFORM_DEPLOY__IOS__COCOAPODS__STEP_MOCK = utils.getMockStep( + 'Install cocoapods', + 'Installing cocoapods', + 'IOS', + ['timeout_minutes', 'max_attempts', 'command'], +); +const PLATFORM_DEPLOY__IOS__DECRYPT_PROFILE__STEP_MOCK = utils.getMockStep( + 'Decrypt profile', + 'Decrypting profile', + 'IOS', + null, + ['LARGE_SECRET_PASSPHRASE'], +); +const PLATFORM_DEPLOY__IOS__DECRYPT_CERTIFICATE__STEP_MOCK = utils.getMockStep( + 'Decrypt certificate', + 'Decrypting certificate', + 'IOS', + null, + ['LARGE_SECRET_PASSPHRASE'], +); +const PLATFORM_DEPLOY__IOS__DECRYPT_APP_STORE_API_KEY__STEP_MOCK = utils.getMockStep( + 'Decrypt App Store Connect API key', + 'Decrypting App Store API key', + 'IOS', + null, + ['LARGE_SECRET_PASSPHRASE'], +); +const PLATFORM_DEPLOY__IOS__FASTLANE__STEP_MOCK = utils.getMockStep( + 'Run Fastlane', + 'Running Fastlane', + 'IOS', + null, + ['APPLE_CONTACT_EMAIL', 'APPLE_CONTACT_PHONE', 'APPLE_DEMO_EMAIL', 'APPLE_DEMO_PASSWORD'], +); +const PLATFORM_DEPLOY__IOS__ARCHIVE_SOURCEMAPS__STEP_MOCK = utils.getMockStep( + 'Archive iOS sourcemaps', + 'Archiving sourcemaps', + 'IOS', + ['name', 'path'], +); +const PLATFORM_DEPLOY__IOS__UPLOAD_BROWSERSTACK__STEP_MOCK = utils.getMockStep( + 'Upload iOS version to Browser Stack', + 'Uploading version to Browser Stack', + 'IOS', + null, + ['BROWSERSTACK'], +); +const PLATFORM_DEPLOY__IOS__SET_VERSION__STEP_MOCK = utils.getMockStep( + 'Set iOS version in ENV', + 'Setting iOS version', + 'IOS', + null, + null, + null, + {IOS_VERSION: '1.2.3'}, +); +const PLATFORM_DEPLOY__IOS__RELEASE_FASTLANE__STEP_MOCK = utils.getMockStep( + 'Run Fastlane for App Store release', + 'Running Fastlane for release', + 'IOS', + null, + ['VERSION'], +); +const PLATFORM_DEPLOY__IOS__WARN_FAIL__STEP_MOCK = utils.getMockStep( + 'Warn deployers if iOS production deploy failed', + 'Warning developers of failed deploy', + 'IOS', + ['status', 'custom_payload'], + ['GITHUB_TOKEN', 'SLACK_WEBHOOK_URL'], +); +const PLATFORM_DEPLOY__IOS__STEP_MOCKS = [ + PLATFORM_DEPLOY__IOS__CHECKOUT__STEP_MOCK, + PLATFORM_DEPLOY__IOS__SETUP_NODE__STEP_MOCK, + PLATFORM_DEPLOY__IOS__SETUP_RUBY__STEP_MOCK, + PLATFORM_DEPLOY__IOS__COCOAPODS__STEP_MOCK, + PLATFORM_DEPLOY__IOS__DECRYPT_PROFILE__STEP_MOCK, + PLATFORM_DEPLOY__IOS__DECRYPT_CERTIFICATE__STEP_MOCK, + PLATFORM_DEPLOY__IOS__DECRYPT_APP_STORE_API_KEY__STEP_MOCK, + PLATFORM_DEPLOY__IOS__FASTLANE__STEP_MOCK, + PLATFORM_DEPLOY__IOS__ARCHIVE_SOURCEMAPS__STEP_MOCK, + PLATFORM_DEPLOY__IOS__UPLOAD_BROWSERSTACK__STEP_MOCK, + PLATFORM_DEPLOY__IOS__SET_VERSION__STEP_MOCK, + PLATFORM_DEPLOY__IOS__RELEASE_FASTLANE__STEP_MOCK, + PLATFORM_DEPLOY__IOS__WARN_FAIL__STEP_MOCK, +]; + +// web +const PLATFORM_DEPLOY__WEB__CHECKOUT__STEP_MOCK = utils.getMockStep( + 'Checkout', + 'Checking out', + 'WEB', + ['fetch-depth'], +); +const PLATFORM_DEPLOY__WEB__SETUP_NODE__STEP_MOCK = utils.getMockStep( + 'Setup Node', + 'Setting up Node', + 'WEB', +); +const PLATFORM_DEPLOY__WEB__CLOUDFLARE__STEP_MOCK = utils.getMockStep( + 'Setup Cloudflare CLI', + 'Setting up Cloudflare CLI', + 'WEB', +); +const PLATFORM_DEPLOY__WEB__AWS_CREDENTIALS__STEP_MOCK = utils.getMockStep( + 'Configure AWS Credentials', + 'Configuring AWS credentials', + 'WEB', + ['AWS_ACCESS_KEY_ID', 'AWS_SECRET_ACCESS_KEY'], +); +const PLATFORM_DEPLOY__WEB__BUILD_PRODUCTION__STEP_MOCK = utils.getMockStep( + 'Build web for production', + 'Building web for production', + 'WEB', +); +const PLATFORM_DEPLOY__WEB__BUILD_STAGING__STEP_MOCK = utils.getMockStep( + 'Build web for staging', + 'Building web for staging', + 'WEB', +); +const PLATFORM_DEPLOY__WEB__BUILD_DOCS__STEP_MOCK = utils.getMockStep( + 'Build docs', + 'Building docs', + 'WEB', +); +const PLATFORM_DEPLOY__WEB__DEPLOY_PRODUCTION_S3__STEP_MOCK = utils.getMockStep( + 'Deploy production to S3', + 'Deploying production to S3', + 'WEB', +); +const PLATFORM_DEPLOY__WEB__DEPLOY_STAGING_S3__STEP_MOCK = utils.getMockStep( + 'Deploy staging to S3', + 'Deploying staging to S3', + 'WEB', +); +const PLATFORM_DEPLOY__WEB__PURGE_PRODUCTION_CACHE__STEP_MOCK = utils.getMockStep( + 'Purge production Cloudflare cache', + 'Purging production Cloudflare cache', + 'WEB', + null, + ['CF_API_KEY'], +); +const PLATFORM_DEPLOY__WEB__PURGE_STAGING_CACHE__STEP_MOCK = utils.getMockStep( + 'Purge staging Cloudflare cache', + 'Purging staging Cloudflare cache', + 'WEB', + null, + ['CF_API_KEY'], +); +const PLATFORM_DEPLOY__WEB__STEP_MOCKS = [ + PLATFORM_DEPLOY__WEB__CHECKOUT__STEP_MOCK, + PLATFORM_DEPLOY__WEB__SETUP_NODE__STEP_MOCK, + PLATFORM_DEPLOY__WEB__CLOUDFLARE__STEP_MOCK, + PLATFORM_DEPLOY__WEB__AWS_CREDENTIALS__STEP_MOCK, + PLATFORM_DEPLOY__WEB__BUILD_PRODUCTION__STEP_MOCK, + PLATFORM_DEPLOY__WEB__BUILD_STAGING__STEP_MOCK, + PLATFORM_DEPLOY__WEB__BUILD_DOCS__STEP_MOCK, + PLATFORM_DEPLOY__WEB__DEPLOY_PRODUCTION_S3__STEP_MOCK, + PLATFORM_DEPLOY__WEB__DEPLOY_STAGING_S3__STEP_MOCK, + PLATFORM_DEPLOY__WEB__PURGE_PRODUCTION_CACHE__STEP_MOCK, + PLATFORM_DEPLOY__WEB__PURGE_STAGING_CACHE__STEP_MOCK, +]; + +// post slack message on failure +const PLATFORM_DEPLOY__POST_SLACK_FAIL__POST_SLACK__STEP_MOCK = utils.getMockStep( + 'Post Slack message on failure', + 'Posting Slack message on platform deploy failure', + 'POST_SLACK_FAIL', + ['SLACK_WEBHOOK'], +); +const PLATFORM_DEPLOY__POST_SLACK_FAIL__STEP_MOCKS = [ + PLATFORM_DEPLOY__POST_SLACK_FAIL__POST_SLACK__STEP_MOCK, +]; + +// post slack message on success +const PLATFORM_DEPLOY__POST_SLACK_SUCCESS__CHECKOUT__STEP_MOCK = utils.getMockStep( + 'Checkout', + 'Checking out', + 'POST_SLACK_SUCCESS', +); +const PLATFORM_DEPLOY__POST_SLACK_SUCCESS__SET_VERSION__STEP_MOCK = utils.getMockStep( + 'Set version', + 'Setting version', + 'POST_SLACK_SUCCESS', + null, + null, + null, + {VERSION: '1.2.3'}, +); +const PLATFORM_DEPLOY__POST_SLACK_SUCCESS__ANNOUNCE_CHANNEL__STEP_MOCK = utils.getMockStep( + 'Announces the deploy in the #announce Slack room', + 'Posting message to #announce channel', + 'POST_SLACK_SUCCESS', + ['status', 'custom_payload'], + ['GITHUB_TOKEN', 'SLACK_WEBHOOK_URL'], +); +const PLATFORM_DEPLOY__POST_SLACK_SUCCESS__DEPLOYER_CHANNEL__STEP_MOCK = utils.getMockStep( + 'Announces the deploy in the #deployer Slack room', + 'Posting message to #deployer channel', + 'POST_SLACK_SUCCESS', + ['status', 'custom_payload'], + ['GITHUB_TOKEN', 'SLACK_WEBHOOK_URL'], +); +const PLATFORM_DEPLOY__POST_SLACK_SUCCESS__EXPENSIFY_CHANNEL__STEP_MOCK = utils.getMockStep( + 'Announces a production deploy in the #expensify-open-source Slack room', + 'Posting message to #expensify-open-source channel', + 'POST_SLACK_SUCCESS', + ['status', 'custom_payload'], + ['GITHUB_TOKEN', 'SLACK_WEBHOOK_URL'], +); +const PLATFORM_DEPLOY__POST_SLACK_SUCCESS__STEP_MOCKS = [ + PLATFORM_DEPLOY__POST_SLACK_SUCCESS__CHECKOUT__STEP_MOCK, + PLATFORM_DEPLOY__POST_SLACK_SUCCESS__SET_VERSION__STEP_MOCK, + PLATFORM_DEPLOY__POST_SLACK_SUCCESS__ANNOUNCE_CHANNEL__STEP_MOCK, + PLATFORM_DEPLOY__POST_SLACK_SUCCESS__DEPLOYER_CHANNEL__STEP_MOCK, + PLATFORM_DEPLOY__POST_SLACK_SUCCESS__EXPENSIFY_CHANNEL__STEP_MOCK, +]; + +// post github comment +const PLATFORM_DEPLOY__POST_GIHUB_COMMENT__CHECKOUT__STEP_MOCK = utils.getMockStep( + 'Checkout', + 'Checking out', + 'POST_GITHUB_COMMENT', + ['fetch-depth'], +); +const PLATFORM_DEPLOY__POST_GIHUB_COMMENT__SETUP_NODE__STEP_MOCK = utils.getMockStep( + 'Setup Node', + 'Setting up Node', + 'POST_GITHUB_COMMENT', +); +const PLATFORM_DEPLOY__POST_GIHUB_COMMENT__SET_VERSION__STEP_MOCK = utils.getMockStep( + 'Set version', + 'Setting version', + 'POST_GITHUB_COMMENT', + null, + null, + null, + {VERSION: '1.2.3'}, +); +const PLATFORM_DEPLOY__POST_GIHUB_COMMENT__GET_PR_LIST__STEP_MOCK = utils.getMockStep( + 'Get Release Pull Request List', + 'Getting release pull request list', + 'POST_GITHUB_COMMENT', + ['TAG', 'GITHUB_TOKEN', 'IS_PRODUCTION_DEPLOY'], + null, + {PR_LIST: '[1.2.1, 1.2.2]'}, +); +const PLATFORM_DEPLOY__POST_GIHUB_COMMENT__COMMENT__STEP_MOCK = utils.getMockStep( + 'Comment on issues', + 'Commenting on issues', + 'POST_GITHUB_COMMENT', + ['PR_LIST', 'IS_PRODUCTION_DEPLOY', 'DEPLOY_VERSION', 'GITHUB_TOKEN', 'ANDROID', 'DESKTOP', 'IOS', 'WEB'], +); +const PLATFORM_DEPLOY__POST_GITHUB_COMMENT__STEP_MOCKS = [ + PLATFORM_DEPLOY__POST_GIHUB_COMMENT__CHECKOUT__STEP_MOCK, + PLATFORM_DEPLOY__POST_GIHUB_COMMENT__SETUP_NODE__STEP_MOCK, + PLATFORM_DEPLOY__POST_GIHUB_COMMENT__SET_VERSION__STEP_MOCK, + PLATFORM_DEPLOY__POST_GIHUB_COMMENT__GET_PR_LIST__STEP_MOCK, + PLATFORM_DEPLOY__POST_GIHUB_COMMENT__COMMENT__STEP_MOCK, +]; + +module.exports = { + PLATFORM_DEPLOY__VALIDATE_ACTOR__TEAM_MEMBER__STEP_MOCKS, + PLATFORM_DEPLOY__VALIDATE_ACTOR__OUTSIDER__STEP_MOCKS, + PLATFORM_DEPLOY__ANDROID__STEP_MOCKS, + PLATFORM_DEPLOY__DESKTOP__STEP_MOCKS, + PLATFORM_DEPLOY__IOS__STEP_MOCKS, + PLATFORM_DEPLOY__WEB__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.js b/workflow_tests/platformDeploy.test.js new file mode 100644 index 000000000000..4b876d3cb2ed --- /dev/null +++ b/workflow_tests/platformDeploy.test.js @@ -0,0 +1,108 @@ +const path = require('path'); +const kieActJs = require('@kie/act-js'); +const kieMockGithub = require('@kie/mock-github'); +const utils = require('./utils'); +const assertions = require('./assertions/platformDeployAssertions'); +const mocks = require('./mocks/platformDeployMocks'); + +let mockGithub; +const FILES_TO_COPY_INTO_TEST_REPO = [ + { + src: path.resolve(__dirname, '..', '.github', 'actions'), + dest: '.github/actions', + }, + { + src: path.resolve(__dirname, '..', '.github', 'libs'), + dest: '.github/libs', + }, + { + src: path.resolve(__dirname, '..', '.github', 'scripts'), + dest: '.github/scripts', + }, + { + src: path.resolve(__dirname, '..', '.github', 'workflows', 'platformDeploy.yml'), + dest: '.github/workflows/platformDeploy.yml', + }, +]; + +beforeEach(async () => { + // create a local repository and copy required files + mockGithub = new kieMockGithub.MockGithub({ + repo: { + testPlatformDeployWorkflowRepo: { + files: FILES_TO_COPY_INTO_TEST_REPO, + pushedBranches: [], + }, + }, + }); + + await mockGithub.setup(); +}); + +afterEach(async () => { + await mockGithub.teardown(); +}); + +describe('test workflow platformDeploy', () => { + test('test', async () => { + const repoPath = mockGithub.repo.getPath('testPlatformDeployWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'platformDeploy.yml'); + let act = new kieActJs.Act(repoPath, workflowPath); + act = utils.setUpActParams( + act, + 'push', + { + ref: 'refs/tags/1.2.3', + }, + { + OS_BOTIFY_TOKEN: 'dummy_token', + GITHUB_ACTOR: 'Dummy Author', + LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', + MYAPP_UPLOAD_STORE_PASSWORD: 'dummy_store_password', + MYAPP_UPLOAD_KEY_PASSWORD: 'dummy_key_password', + BROWSERSTACK: 'dummy_browserstack', + SLACK_WEBHOOK: 'dummy_slack_webhook', + DEVELOPER_ID_SECRET_PASSPHRASE: 'dummy_secret_passphrase', + CSC_LINK: 'dummy_csc_link', + CSC_KEY_PASSWORD: 'dummy_csc_key_pass', + APPLE_ID: 'dummy_apple_id', + APPLE_ID_PASSWORD: 'dummy_apple_id_pass', + AWS_ACCESS_KEY_ID: 'dummy_aws_access_key_id', + AWS_SECRET_ACCESS_KEY: 'dummy_aws_secret_access_key', + APPLE_CONTACT_EMAIL: 'dummy@email.com', + APPLE_CONTACT_PHONE: '123456789', + APPLE_DEMO_EMAIL: 'dummy.demo@email.com', + APPLE_DEMO_PASSWORD: 'dummy_password', + CLOUDFLARE_TOKEN: 'dummy_cloudflare_token', + }, + 'dummy_github_token', + { + AS_REPO: 'App', + }, + ); + const testMockSteps = { + validateActor: mocks.PLATFORM_DEPLOY__VALIDATE_ACTOR__TEAM_MEMBER__STEP_MOCKS, + android: mocks.PLATFORM_DEPLOY__ANDROID__STEP_MOCKS, + desktop: mocks.PLATFORM_DEPLOY__DESKTOP__STEP_MOCKS, + iOS: mocks.PLATFORM_DEPLOY__IOS__STEP_MOCKS, + web: mocks.PLATFORM_DEPLOY__WEB__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, + }; + const result = await act + .runEvent('push', { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + }); + + assertions.assertVerifyActorJobExecuted(result); + assertions.assertAndroidJobExecuted(result, true, false, true); + assertions.assertDesktopJobExecuted(result, false); // act does not support macos-12 runner + assertions.assertIOSJobExecuted(result, false); // act does not support macos-12 runner + assertions.assertWebJobExecuted(result, true, false); + assertions.assertPostSlackOnFailureJobExecuted(result, false); + assertions.assertPostSlackOnSuccessJobExecuted(result, false); // since desktop and iOS don't run - this one doesn't either + assertions.assertPostGithubCommentJobExecuted(result, true, false); + }, 120000); +}); diff --git a/workflow_tests/utils.js b/workflow_tests/utils.js index 290d3ed292bd..1bd9b528d41b 100644 --- a/workflow_tests/utils.js +++ b/workflow_tests/utils.js @@ -1,4 +1,4 @@ -const setUpActParams = (act, event = null, event_options = null, secrets = null, github_token = null) => { +const setUpActParams = (act, event = null, event_options = null, secrets = null, github_token = null, env_vars = null) => { let updated_act = act; if (event && event_options) { @@ -17,6 +17,12 @@ const setUpActParams = (act, event = null, event_options = null, secrets = null, updated_act = updated_act.setGithubToken(github_token); } + if (env_vars) { + for (const [key, value] of Object.entries(env_vars)) { + updated_act = updated_act.setEnv(key, value); + } + } + return updated_act; }; From 0c1027795f74154e233665204f8458894180a45b Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Fri, 3 Mar 2023 12:59:07 +0100 Subject: [PATCH 031/504] Add method to overwrite the runner type Some runner types are not supported by act. To run the jobs using them, even with mock steps to check the execution flow and outputs, I've added a helper method to overwrite the runner type See: https://github.com/Expensify/App/issues/13604 --- workflow_tests/utils.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/workflow_tests/utils.js b/workflow_tests/utils.js index 1bd9b528d41b..c8186da06153 100644 --- a/workflow_tests/utils.js +++ b/workflow_tests/utils.js @@ -1,3 +1,6 @@ +const yaml = require('yaml'); +const fs = require('fs'); + const setUpActParams = (act, event = null, event_options = null, secrets = null, github_token = null, env_vars = null) => { let updated_act = act; @@ -94,8 +97,23 @@ const getStepAssertion = (name, isSuccessful = true, expectedOutput = null, jobI }; }; +const setJobRunners = (act, jobs, workflowPath) => { + if (!act || !jobs || !workflowPath) { + return act; + } + + const workflow = yaml.parse(fs.readFileSync(workflowPath, 'utf8')); + for (const [jobId, runner] of Object.entries(jobs)) { + const job = workflow.jobs[jobId]; + job['runs-on'] = runner; + } + fs.writeFileSync(workflowPath, yaml.stringify(workflow), 'utf8'); + return act; +}; + module.exports = { setUpActParams, getMockStep, getStepAssertion, + setJobRunners, }; From 6ebb7c8e755ee6437739ec6ab7b6fa85ead4d13d Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Fri, 3 Mar 2023 13:07:58 +0100 Subject: [PATCH 032/504] Update readme Added a description and examples regarding the new method for overwriting the runner types See: https://github.com/Expensify/App/issues/13604 --- workflow_tests/README.md | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/workflow_tests/README.md b/workflow_tests/README.md index b78ebf92838a..651adcbedfeb 100644 --- a/workflow_tests/README.md +++ b/workflow_tests/README.md @@ -154,6 +154,45 @@ results in } ``` +### `setJobRunners` +`setJobRunners` overwrites the runner types for given jobs, helpful when the runner type in the workflow is not supported by `Act` + +Parameters: +- `act` - instance of previously created `Act` object +- `jobs` - object with keys being the IDs of the workflow jobs to be modified and values being the names of runners that should be used for them in the test +- `workflowPath` - path to the workflow file to be updated, **NOTE**: this will modify the file, use the one from the local test repo, not from `App/.github/workflows`! + +Returns an `Act` object instance + +Let's say you have a workflow with a job using `macos-12` runner, which is unsupported by `Act` - in this case that job will simply be skipped altogether, not allowing you to test it in any way. +```yaml +iOS: + name: Build and deploy iOS + needs: validateActor + if: ${{ fromJSON(needs.validateActor.outputs.IS_DEPLOYER) }} + runs-on: macos-12 + steps: +``` +You can use this method to change the runner to something that is supported, like +```javascript +act = utils.setJobRunners( + act, + { + iOS: 'ubuntu-latest', + }, + workflowPath, +); +``` +Now the test workflow will look as follows, which will allow you to run the job and do at least limited testing +```yaml +iOS: + name: Build and deploy iOS + needs: validateActor + if: ${{ fromJSON(needs.validateActor.outputs.IS_DEPLOYER) }} + runs-on: ubuntu-latest + steps: +``` + ## Typical test file The following is the typical test file content, which will be followed by a detailed breakdown ```javascript From a8adb248d1c039aba17c13753b0fe41eba63744a Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Fri, 3 Mar 2023 13:09:41 +0100 Subject: [PATCH 033/504] Update test Utilised the new method to run all jobs within the `platformDeploy` workflow See: https://github.com/Expensify/App/issues/13604 --- .../assertions/platformDeployAssertions.js | 15 ++++++--------- workflow_tests/mocks/platformDeployMocks.js | 16 ++++++++-------- workflow_tests/platformDeploy.test.js | 16 ++++++++++++---- 3 files changed, 26 insertions(+), 21 deletions(-) diff --git a/workflow_tests/assertions/platformDeployAssertions.js b/workflow_tests/assertions/platformDeployAssertions.js index 7f39f280dd36..64b3ef3f875d 100644 --- a/workflow_tests/assertions/platformDeployAssertions.js +++ b/workflow_tests/assertions/platformDeployAssertions.js @@ -130,7 +130,7 @@ const assertAndroidJobExecuted = (workflowResult, didExecute = true, isProductio null, 'ANDROID', 'Warning deployers of failed production deploy', - [{key: 'status', value: 'custom'}, {key: 'custom_payload', value: '{\n channel: \'#deployer\',\n attachments: [{\n color: "#DB4545",\n pretext: ``,\n text: `💥 Android production deploy failed. Please manually submit 1.2.3 in the . 💥`,\n }]\n}'}], + [{key: 'status', value: 'custom'}], [{key: 'GITHUB_TOKEN', value: '***'}, {key: 'SLACK_WEBHOOK_URL', value: '***'}], ), ]; @@ -330,7 +330,7 @@ const assertIOSJobExecuted = (workflowResult, didExecute = true, isProduction = null, 'IOS', 'Warning developers of failed deploy', - [{key: 'status', value: 'custom'}, {key: 'custom_payload', value: '{\n channel: \'#deployer\',\n attachments: [{\n color: "#DB4545",\n pretext: ``,\n text: `💥 iOS production deploy failed. Please manually submit 1.2.3 in the . 💥`,\n }]\n}'}], + [{key: 'status', value: 'custom'}], [{key: 'GITHUB_TOKEN', value: '***'}, {key: 'SLACK_WEBHOOK_URL', value: '***'}], ), ]; @@ -492,7 +492,7 @@ const assertPostSlackOnSuccessJobExecuted = (workflowResult, didExecute = true, null, 'POST_SLACK_SUCCESS', 'Posting message to #announce channel', - [{key: 'status', value: 'custom'}, {key: 'custom_payload', value: isProduction ? '{\n channel: \'#announce\',\n attachments: [{\n color: \'good\',\n text: `🎉️ Successfully deployed App to production 🎉️`,\n }]\n}' : '{\n channel: \'#announce\',\n attachments: [{\n color: \'good\',\n text: `🎉️ Successfully deployed App to staging 🎉️`,\n }]\n}'}], + [{key: 'status', value: 'custom'}], [{key: 'GITHUB_TOKEN', value: '***'}, {key: 'SLACK_WEBHOOK_URL', value: '***'}], ), utils.getStepAssertion( @@ -501,7 +501,7 @@ const assertPostSlackOnSuccessJobExecuted = (workflowResult, didExecute = true, null, 'POST_SLACK_SUCCESS', 'Posting message to #deployer channel', - [{key: 'status', value: 'custom'}, {key: 'custom_payload', value: isProduction ? '{\n channel: \'#announce\',\n attachments: [{\n color: \'good\',\n text: `🎉️ Successfully deployed App to production 🎉️`,\n }]\n}' : '{\n channel: \'#announce\',\n attachments: [{\n color: \'good\',\n text: `🎉️ Successfully deployed App to staging 🎉️`,\n }]\n}'}], + [{key: 'status', value: 'custom'}], [{key: 'GITHUB_TOKEN', value: '***'}, {key: 'SLACK_WEBHOOK_URL', value: '***'}], ), ]; @@ -513,10 +513,7 @@ const assertPostSlackOnSuccessJobExecuted = (workflowResult, didExecute = true, null, 'POST_SLACK_SUCCESS', 'Posting message to #expensify-open-source channel', - [{key: 'status', value: 'custom'}, { - key: 'custom_payload', - value: '{\n channel: \'#announce\',\n attachments: [{\n color: \'good\',\n text: `🎉️ Successfully deployed App to production 🎉️`,\n }]\n}', - }], + [{key: 'status', value: 'custom'}], [{key: 'GITHUB_TOKEN', value: '***'}, {key: 'SLACK_WEBHOOK_URL', value: '***'}], ), ); @@ -567,7 +564,7 @@ const assertPostGithubCommentJobExecuted = (workflowResult, didExecute = true, i null, 'POST_GITHUB_COMMENT', 'Commenting on issues', - [{key: 'PR_LIST', value: '[1.2.1, 1.2.2]'}, {key: 'IS_PRODUCTION_DEPLOY', value: isProduction ? 'true' : 'false'}, {key: 'DEPLOY_VERSION', value: '1.2.3'}, {key: 'GITHUB_TOKEN', value: '***'}, {key: 'ANDROID', value: 'success'}, {key: 'DESKTOP', value: ''}, {key: 'IOS', value: ''}, {key: 'WEB', value: 'success'}], // unsupported runners for desktop and ios + [{key: 'PR_LIST', value: '[1.2.1, 1.2.2]'}, {key: 'IS_PRODUCTION_DEPLOY', value: isProduction ? 'true' : 'false'}, {key: 'DEPLOY_VERSION', value: '1.2.3'}, {key: 'GITHUB_TOKEN', value: '***'}, {key: 'ANDROID', value: 'success'}, {key: 'DESKTOP', value: 'success'}, {key: 'IOS', value: 'success'}, {key: 'WEB', value: 'success'}], ), ]; diff --git a/workflow_tests/mocks/platformDeployMocks.js b/workflow_tests/mocks/platformDeployMocks.js index 4253a76640da..42e790236b64 100644 --- a/workflow_tests/mocks/platformDeployMocks.js +++ b/workflow_tests/mocks/platformDeployMocks.js @@ -96,7 +96,7 @@ const PLATFORM_DEPLOY__ANDROID__WARN_DEPLOYERS__STEP_MOCK = utils.getMockStep( 'Warn deployers if Android production deploy failed', 'Warning deployers of failed production deploy', 'ANDROID', - ['status', 'custom_payload'], + ['status'], ['GITHUB_TOKEN', 'SLACK_WEBHOOK_URL'], ); const PLATFORM_DEPLOY__ANDROID__STEP_MOCKS = [ @@ -239,7 +239,7 @@ const PLATFORM_DEPLOY__IOS__WARN_FAIL__STEP_MOCK = utils.getMockStep( 'Warn deployers if iOS production deploy failed', 'Warning developers of failed deploy', 'IOS', - ['status', 'custom_payload'], + ['status'], ['GITHUB_TOKEN', 'SLACK_WEBHOOK_URL'], ); const PLATFORM_DEPLOY__IOS__STEP_MOCKS = [ @@ -362,23 +362,23 @@ const PLATFORM_DEPLOY__POST_SLACK_SUCCESS__SET_VERSION__STEP_MOCK = utils.getMoc ); const PLATFORM_DEPLOY__POST_SLACK_SUCCESS__ANNOUNCE_CHANNEL__STEP_MOCK = utils.getMockStep( 'Announces the deploy in the #announce Slack room', - 'Posting message to #announce channel', + 'Posting message to \\#announce channel', 'POST_SLACK_SUCCESS', - ['status', 'custom_payload'], + ['status'], ['GITHUB_TOKEN', 'SLACK_WEBHOOK_URL'], ); const PLATFORM_DEPLOY__POST_SLACK_SUCCESS__DEPLOYER_CHANNEL__STEP_MOCK = utils.getMockStep( 'Announces the deploy in the #deployer Slack room', - 'Posting message to #deployer channel', + 'Posting message to \\#deployer channel', 'POST_SLACK_SUCCESS', - ['status', 'custom_payload'], + ['status'], ['GITHUB_TOKEN', 'SLACK_WEBHOOK_URL'], ); const PLATFORM_DEPLOY__POST_SLACK_SUCCESS__EXPENSIFY_CHANNEL__STEP_MOCK = utils.getMockStep( 'Announces a production deploy in the #expensify-open-source Slack room', - 'Posting message to #expensify-open-source channel', + 'Posting message to \\#expensify-open-source channel', 'POST_SLACK_SUCCESS', - ['status', 'custom_payload'], + ['status'], ['GITHUB_TOKEN', 'SLACK_WEBHOOK_URL'], ); const PLATFORM_DEPLOY__POST_SLACK_SUCCESS__STEP_MOCKS = [ diff --git a/workflow_tests/platformDeploy.test.js b/workflow_tests/platformDeploy.test.js index 4b876d3cb2ed..d721b3554e63 100644 --- a/workflow_tests/platformDeploy.test.js +++ b/workflow_tests/platformDeploy.test.js @@ -66,7 +66,7 @@ describe('test workflow platformDeploy', () => { CSC_LINK: 'dummy_csc_link', CSC_KEY_PASSWORD: 'dummy_csc_key_pass', APPLE_ID: 'dummy_apple_id', - APPLE_ID_PASSWORD: 'dummy_apple_id_pass', + APPLE_ID_PASSWORD: 'dummy_apple_pass', AWS_ACCESS_KEY_ID: 'dummy_aws_access_key_id', AWS_SECRET_ACCESS_KEY: 'dummy_aws_secret_access_key', APPLE_CONTACT_EMAIL: 'dummy@email.com', @@ -80,6 +80,14 @@ describe('test workflow platformDeploy', () => { AS_REPO: 'App', }, ); + act = utils.setJobRunners( + act, + { + desktop: 'ubuntu-latest', + iOS: 'ubuntu-latest', + }, + workflowPath, + ); const testMockSteps = { validateActor: mocks.PLATFORM_DEPLOY__VALIDATE_ACTOR__TEAM_MEMBER__STEP_MOCKS, android: mocks.PLATFORM_DEPLOY__ANDROID__STEP_MOCKS, @@ -98,11 +106,11 @@ describe('test workflow platformDeploy', () => { assertions.assertVerifyActorJobExecuted(result); assertions.assertAndroidJobExecuted(result, true, false, true); - assertions.assertDesktopJobExecuted(result, false); // act does not support macos-12 runner - assertions.assertIOSJobExecuted(result, false); // act does not support macos-12 runner + assertions.assertDesktopJobExecuted(result, true, false); + assertions.assertIOSJobExecuted(result, true, false, true); assertions.assertWebJobExecuted(result, true, false); assertions.assertPostSlackOnFailureJobExecuted(result, false); - assertions.assertPostSlackOnSuccessJobExecuted(result, false); // since desktop and iOS don't run - this one doesn't either + assertions.assertPostSlackOnSuccessJobExecuted(result, true, false); assertions.assertPostGithubCommentJobExecuted(result, true, false); }, 120000); }); From ebe4cf00a16e2cafca26628503a86067a6726aab Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Fri, 3 Mar 2023 13:15:19 +0100 Subject: [PATCH 034/504] Add dependency Added yaml to the dependencies, even though it's still required by act-js See: https://github.com/Expensify/App/issues/13604 --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 79311ea03989..22db87aa8bac 100644 --- a/package.json +++ b/package.json @@ -141,7 +141,8 @@ "semver": "^7.3.8", "shim-keyboard-event-key": "^1.0.3", "underscore": "^1.13.1", - "urbanairship-react-native": "^14.6.1" + "urbanairship-react-native": "^14.6.1", + "yaml": "^2.2.1" }, "devDependencies": { "@actions/core": "1.10.0", From 951fae772ace62cf63783bc22860e41527b18de9 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Fri, 3 Mar 2023 16:17:06 +0100 Subject: [PATCH 035/504] Extend Act class Had to extend the `Act` class from `Act-js` because there was no apparent way to change the `github.actor` property on which many workflows depend See: https://github.com/Expensify/App/issues/13604 --- workflow_tests/utils.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/workflow_tests/utils.js b/workflow_tests/utils.js index c8186da06153..850c6c03d2c4 100644 --- a/workflow_tests/utils.js +++ b/workflow_tests/utils.js @@ -1,5 +1,16 @@ const yaml = require('yaml'); const fs = require('fs'); +const kieActJs = require('@kie/act-js'); + +class ExtendedAct extends kieActJs.Act { + async parseRunOpts(opts) { + const {cwd, actArguments, proxy} = await super.parseRunOpts(opts); + if (opts?.actor) { + actArguments.push('--actor', opts?.actor); + } + return {cwd, actArguments, proxy}; + } +} const setUpActParams = (act, event = null, event_options = null, secrets = null, github_token = null, env_vars = null) => { let updated_act = act; @@ -116,4 +127,5 @@ module.exports = { getMockStep, getStepAssertion, setJobRunners, + ExtendedAct, }; From 9f793d9869c8b25341ee91875a0db651e6e1e7b6 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Fri, 3 Mar 2023 17:29:25 +0100 Subject: [PATCH 036/504] Update tests Updated the tests with extended Act class and assertions with single step checks See: https://github.com/Expensify/App/issues/13604 --- .github/workflows/preDeploy.yml | 3 +- workflow_tests/assertions/deployAssertions.js | 41 ++++--- .../assertions/platformDeployAssertions.js | 105 ++++++++++------- .../assertions/preDeployAssertions.js | 110 +++++++++++------- workflow_tests/deploy.test.js | 37 +++--- workflow_tests/platformDeploy.test.js | 7 +- workflow_tests/preDeploy.test.js | 109 +++++++++-------- 7 files changed, 245 insertions(+), 167 deletions(-) diff --git a/.github/workflows/preDeploy.yml b/.github/workflows/preDeploy.yml index 78df8370a3ef..7beea5a3361a 100644 --- a/.github/workflows/preDeploy.yml +++ b/.github/workflows/preDeploy.yml @@ -2,7 +2,8 @@ name: Process new code merged to main on: push: - branches: [main] + branches: + - main jobs: lint: diff --git a/workflow_tests/assertions/deployAssertions.js b/workflow_tests/assertions/deployAssertions.js index 8471cb6bfdaa..4c12d778cc05 100644 --- a/workflow_tests/assertions/deployAssertions.js +++ b/workflow_tests/assertions/deployAssertions.js @@ -16,10 +16,13 @@ const assertValidateJobExecuted = (workflowResult, didExecute = true) => { output: '', }, ]; - if (didExecute) { - expect(workflowResult).toEqual(expect.arrayContaining(steps)); - } else { - expect(workflowResult).not.toEqual(expect.arrayContaining(steps)); + + for (const expectedStep of steps) { + if (didExecute) { + expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); + } else { + expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); + } } }; @@ -34,11 +37,11 @@ const assertDeployStagingJobExecuted = (workflowResult, didExecute = true) => { [{key: 'ref', value: 'staging'}, {key: 'token', value: '***'}], ), utils.getStepAssertion( - 'Setup git for ***', + 'Setup git for OSBotify', true, null, 'DEPLOY_STAGING', - 'Setting up git for ***', + 'Setting up git for OSBotify', [{key: 'GPG_PASSPHRASE', value: '***'}], ), utils.getStepAssertion( @@ -56,10 +59,13 @@ const assertDeployStagingJobExecuted = (workflowResult, didExecute = true) => { 'Pushing tag to trigger staging deploy', ), ]; - if (didExecute) { - expect(workflowResult).toEqual(expect.arrayContaining(steps)); - } else { - expect(workflowResult).not.toEqual(expect.arrayContaining(steps)); + + for (const expectedStep of steps) { + if (didExecute) { + expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); + } else { + expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); + } } }; @@ -74,11 +80,11 @@ const assertDeployProductionJobExecuted = (workflowResult, didExecute = true) => [{key: 'fetch-depth', value: '0'}, {key: 'token', value: '***'}], ), utils.getStepAssertion( - 'Setup git for ***', + 'Setup git for OSBotify', true, null, 'DEPLOY_PRODUCTION', - 'Setting up git for ***', + 'Setting up git for OSBotify', [{key: 'GPG_PASSPHRASE', value: '***'}], ), utils.getStepAssertion( @@ -121,10 +127,13 @@ const assertDeployProductionJobExecuted = (workflowResult, didExecute = true) => [{key: 'GITHUB_TOKEN', value: '***'}], ), ]; - if (didExecute) { - expect(workflowResult).toEqual(expect.arrayContaining(steps)); - } else { - expect(workflowResult).not.toEqual(expect.arrayContaining(steps)); + + for (const expectedStep of steps) { + if (didExecute) { + expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); + } else { + expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); + } } }; diff --git a/workflow_tests/assertions/platformDeployAssertions.js b/workflow_tests/assertions/platformDeployAssertions.js index 64b3ef3f875d..6b25263bd59d 100644 --- a/workflow_tests/assertions/platformDeployAssertions.js +++ b/workflow_tests/assertions/platformDeployAssertions.js @@ -11,10 +11,13 @@ const assertVerifyActorJobExecuted = (workflowResult, didExecute = true) => { [{key: 'GITHUB_TOKEN', value: '***'}, {key: 'team', value: 'mobile-deployers'}], ), ]; - if (didExecute) { - expect(workflowResult).toEqual(expect.arrayContaining(steps)); - } else { - expect(workflowResult).not.toEqual(expect.arrayContaining(steps)); + + for (const expectedStep of steps) { + if (didExecute) { + expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); + } else { + expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); + } } }; @@ -117,10 +120,13 @@ const assertAndroidJobExecuted = (workflowResult, didExecute = true, isProductio ), ); } - if (didExecute) { - expect(workflowResult).toEqual(expect.arrayContaining(steps)); - } else { - expect(workflowResult).not.toEqual(expect.arrayContaining(steps)); + + for (const expectedStep of steps) { + if (didExecute) { + expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); + } else { + expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); + } } const failProdSteps = [ @@ -134,10 +140,13 @@ const assertAndroidJobExecuted = (workflowResult, didExecute = true, isProductio [{key: 'GITHUB_TOKEN', value: '***'}, {key: 'SLACK_WEBHOOK_URL', value: '***'}], ), ]; - if (didExecute && isProduction && !isSuccessful) { - expect(workflowResult).toEqual(expect.arrayContaining(failProdSteps)); - } else { - expect(workflowResult).not.toEqual(expect.arrayContaining(failProdSteps)); + + for (const expectedStep of failProdSteps) { + if (didExecute && isProduction && !isSuccessful) { + expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); + } else { + expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); + } } }; @@ -194,10 +203,12 @@ const assertDesktopJobExecuted = (workflowResult, didExecute = true, isProductio ); } - if (didExecute) { - expect(workflowResult).toEqual(expect.arrayContaining(steps)); - } else { - expect(workflowResult).not.toEqual(expect.arrayContaining(steps)); + for (const expectedStep of steps) { + if (didExecute) { + expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); + } else { + expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); + } } }; @@ -317,10 +328,13 @@ const assertIOSJobExecuted = (workflowResult, didExecute = true, isProduction = ), ); } - if (didExecute) { - expect(workflowResult).toEqual(expect.arrayContaining(steps)); - } else { - expect(workflowResult).not.toEqual(expect.arrayContaining(steps)); + + for (const expectedStep of steps) { + if (didExecute) { + expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); + } else { + expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); + } } const failProdSteps = [ @@ -334,10 +348,13 @@ const assertIOSJobExecuted = (workflowResult, didExecute = true, isProduction = [{key: 'GITHUB_TOKEN', value: '***'}, {key: 'SLACK_WEBHOOK_URL', value: '***'}], ), ]; - if (didExecute && isProduction && !isSuccessful) { - expect(workflowResult).toEqual(expect.arrayContaining(failProdSteps)); - } else { - expect(workflowResult).not.toEqual(expect.arrayContaining(failProdSteps)); + + for (const expectedStep of failProdSteps) { + if (didExecute && isProduction && !isSuccessful) { + expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); + } else { + expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); + } } }; @@ -444,10 +461,12 @@ const assertWebJobExecuted = (workflowResult, didExecute = true, isProduction = ); } - if (didExecute) { - expect(workflowResult).toEqual(expect.arrayContaining(steps)); - } else { - expect(workflowResult).not.toEqual(expect.arrayContaining(steps)); + for (const expectedStep of steps) { + if (didExecute) { + expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); + } else { + expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); + } } }; @@ -463,10 +482,12 @@ const assertPostSlackOnFailureJobExecuted = (workflowResult, didExecute = true) ), ]; - if (didExecute) { - expect(workflowResult).toEqual(expect.arrayContaining(steps)); - } else { - expect(workflowResult).not.toEqual(expect.arrayContaining(steps)); + for (const expectedStep of steps) { + if (didExecute) { + expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); + } else { + expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); + } } }; @@ -519,10 +540,12 @@ const assertPostSlackOnSuccessJobExecuted = (workflowResult, didExecute = true, ); } - if (didExecute) { - expect(workflowResult).toEqual(expect.arrayContaining(steps)); - } else { - expect(workflowResult).not.toEqual(expect.arrayContaining(steps)); + for (const expectedStep of steps) { + if (didExecute) { + expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); + } else { + expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); + } } }; @@ -568,10 +591,12 @@ const assertPostGithubCommentJobExecuted = (workflowResult, didExecute = true, i ), ]; - if (didExecute) { - expect(workflowResult).toEqual(expect.arrayContaining(steps)); - } else { - expect(workflowResult).not.toEqual(expect.arrayContaining(steps)); + for (const expectedStep of steps) { + if (didExecute) { + expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); + } else { + expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); + } } }; diff --git a/workflow_tests/assertions/preDeployAssertions.js b/workflow_tests/assertions/preDeployAssertions.js index a37e9cebc397..c074f4a1f68f 100644 --- a/workflow_tests/assertions/preDeployAssertions.js +++ b/workflow_tests/assertions/preDeployAssertions.js @@ -10,10 +10,13 @@ const assertLintJobExecuted = (workflowResult, didExecute = true) => { 'Running lint workflow', ), ]; - if (didExecute) { - expect(workflowResult).toEqual(expect.arrayContaining(steps)); - } else { - expect(workflowResult).not.toEqual(steps); + + for (const expectedStep of steps) { + if (didExecute) { + expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); + } else { + expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); + } } }; @@ -27,10 +30,13 @@ const assertTestJobExecuted = (workflowResult, didExecute = true) => { 'Running test workflow', ), ]; - if (didExecute) { - expect(workflowResult).toEqual(expect.arrayContaining(steps)); - } else { - expect(workflowResult).not.toEqual(steps); + + for (const expectedStep of steps) { + if (didExecute) { + expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); + } else { + expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); + } } }; @@ -53,10 +59,13 @@ const assertIsExpensifyEmployeeJobExecuted = (workflowResult, didExecute = true) [{key: 'GITHUB_TOKEN', value: '***'}, {key: 'username', value: 'Dummy Author'}, {key: 'team', value: 'Expensify/expensify'}], ), ]; - if (didExecute) { - expect(workflowResult).toEqual(expect.arrayContaining(steps)); - } else { - expect(workflowResult).not.toEqual(steps); + + for (const expectedStep of steps) { + if (didExecute) { + expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); + } else { + expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); + } } }; @@ -99,10 +108,13 @@ const assertNewContributorWelcomeMessageJobExecuted = (workflowResult, didExecut ), ); } - if (didExecute) { - expect(workflowResult).toEqual(expect.arrayContaining(steps)); - } else { - expect(workflowResult).not.toEqual(steps); + + for (const expectedStep of steps) { + if (didExecute) { + expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); + } else { + expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); + } } }; @@ -277,10 +289,13 @@ const assertE2ETestsJobExecuted = (workflowResult, didExecute = true) => { 'Checking if tests failed', ), ]; - if (didExecute) { - expect(workflowResult).toEqual(expect.arrayContaining(steps)); - } else { - expect(workflowResult).not.toEqual(steps); + + for (const expectedStep of steps) { + if (didExecute) { + expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); + } else { + expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); + } } }; @@ -318,10 +333,13 @@ const assertChooseDeployActionsJobExecuted = (workflowResult, didExecute = true) '', ), ]; - if (didExecute) { - expect(workflowResult).toEqual(expect.arrayContaining(steps)); - } else { - expect(workflowResult).not.toEqual(steps); + + for (const expectedStep of steps) { + if (didExecute) { + expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); + } else { + expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); + } } }; @@ -336,10 +354,13 @@ const assertSkipDeployJobExecuted = (workflowResult, didExecute = true) => { [{key: 'github_token', value: '***'}, {key: 'number', value: '123'}, {key: 'body', value: ':hand: This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.'}], ), ]; - if (didExecute) { - expect(workflowResult).toEqual(expect.arrayContaining(steps)); - } else { - expect(workflowResult).not.toEqual(steps); + + for (const expectedStep of steps) { + if (didExecute) { + expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); + } else { + expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); + } } }; @@ -353,10 +374,13 @@ const assertCreateNewVersionJobExecuted = (workflowResult, didExecute = true) => 'Creating new version', ), ]; - if (didExecute) { - expect(workflowResult).toEqual(expect.arrayContaining(steps)); - } else { - expect(workflowResult).not.toEqual(steps); + + for (const expectedStep of steps) { + if (didExecute) { + expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); + } else { + expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); + } } }; @@ -458,10 +482,13 @@ const assertUpdateStagingJobExecuted = (workflowResult, didExecute = true, shoul ), ); } - if (didExecute) { - expect(workflowResult).toEqual(expect.arrayContaining(steps)); - } else { - expect(workflowResult).not.toEqual(steps); + + for (const expectedStep of steps) { + if (didExecute) { + expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); + } else { + expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); + } } }; @@ -476,10 +503,13 @@ const assertUpdateStagingJobFailed = (workflowResult, didFail = false) => { [{key: 'SLACK_WEBHOOK', value: '***'}], ), ]; - if (didFail) { - expect(workflowResult).toEqual(expect.arrayContaining(steps)); - } else { - expect(workflowResult).not.toEqual(steps); + + for (const expectedStep of steps) { + if (didFail) { + expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); + } else { + expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); + } } }; diff --git a/workflow_tests/deploy.test.js b/workflow_tests/deploy.test.js index 02f2accdf98d..1ad5ff46990f 100644 --- a/workflow_tests/deploy.test.js +++ b/workflow_tests/deploy.test.js @@ -1,5 +1,4 @@ const path = require('path'); -const kieActJs = require('@kie/act-js'); const kieMockGithub = require('@kie/mock-github'); const utils = require('./utils'); const assertions = require('./assertions/deployAssertions'); @@ -48,7 +47,7 @@ describe('test workflow deploy', () => { test('to main - nothing triggered', async () => { const repoPath = mockGithub.repo.getPath('testDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'deploy.yml'); - let act = new kieActJs.Act(repoPath, workflowPath); + let act = new utils.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams( act, 'push', @@ -56,7 +55,6 @@ describe('test workflow deploy', () => { ref: 'refs/heads/main', }, { - GITHUB_ACTOR: 'OSBotify', OS_BOTIFY_TOKEN: 'dummy_token', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', }, @@ -71,6 +69,7 @@ describe('test workflow deploy', () => { .runEvent('push', { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, + actor: 'OSBotify', }); assertions.assertValidateJobExecuted(result); assertions.assertDeployStagingJobExecuted(result, false); @@ -80,7 +79,7 @@ describe('test workflow deploy', () => { test('to staging - deployStaging triggered', async () => { const repoPath = mockGithub.repo.getPath('testDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'deploy.yml'); - let act = new kieActJs.Act(repoPath, workflowPath); + let act = new utils.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams( act, 'push', @@ -88,7 +87,6 @@ describe('test workflow deploy', () => { ref: 'refs/heads/staging', }, { - GITHUB_ACTOR: 'OSBotify', OS_BOTIFY_TOKEN: 'dummy_token', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', }, @@ -103,6 +101,7 @@ describe('test workflow deploy', () => { .runEvent('push', { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, + actor: 'OSBotify', }); assertions.assertValidateJobExecuted(result); assertions.assertDeployStagingJobExecuted(result); @@ -112,7 +111,7 @@ describe('test workflow deploy', () => { test('to production - deployProduction triggered', async () => { const repoPath = mockGithub.repo.getPath('testDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'deploy.yml'); - let act = new kieActJs.Act(repoPath, workflowPath); + let act = new utils.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams( act, 'push', @@ -120,7 +119,6 @@ describe('test workflow deploy', () => { ref: 'refs/heads/production', }, { - GITHUB_ACTOR: 'OSBotify', OS_BOTIFY_TOKEN: 'dummy_token', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', }, @@ -135,6 +133,7 @@ describe('test workflow deploy', () => { .runEvent('push', { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, + actor: 'OSBotify', }); assertions.assertValidateJobExecuted(result); assertions.assertDeployStagingJobExecuted(result, false); @@ -145,7 +144,7 @@ describe('test workflow deploy', () => { test('to main - nothing triggered', async () => { const repoPath = mockGithub.repo.getPath('testDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'deploy.yml'); - let act = new kieActJs.Act(repoPath, workflowPath); + let act = new utils.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams( act, 'push', @@ -153,14 +152,13 @@ describe('test workflow deploy', () => { ref: 'refs/heads/main', }, { - GITHUB_ACTOR: 'Dummy Author', OS_BOTIFY_TOKEN: 'dummy_token', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', }, 'dummy_github_token', ); const testMockSteps = { - validate: mocks.VALIDATE__OSBOTIFY__STEP_MOCKS, + validate: mocks.VALIDATE_STEP_MOCKS, deployStaging: mocks.DEPLOY_STAGING_STEP_MOCKS, deployProduction: mocks.DEPLOY_PRODUCTION_STEP_MOCKS, }; @@ -168,6 +166,7 @@ describe('test workflow deploy', () => { .runEvent('push', { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, + actor: 'Dummy Author', }); assertions.assertValidateJobExecuted(result); assertions.assertDeployStagingJobExecuted(result, false); @@ -177,7 +176,7 @@ describe('test workflow deploy', () => { test('to staging - nothing triggered', async () => { const repoPath = mockGithub.repo.getPath('testDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'deploy.yml'); - let act = new kieActJs.Act(repoPath, workflowPath); + let act = new utils.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams( act, 'push', @@ -185,14 +184,13 @@ describe('test workflow deploy', () => { ref: 'refs/heads/staging', }, { - GITHUB_ACTOR: 'Dummy Author', OS_BOTIFY_TOKEN: 'dummy_token', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', }, 'dummy_github_token', ); const testMockSteps = { - validate: mocks.VALIDATE__OSBOTIFY__STEP_MOCKS, + validate: mocks.VALIDATE_STEP_MOCKS, deployStaging: mocks.DEPLOY_STAGING_STEP_MOCKS, deployProduction: mocks.DEPLOY_PRODUCTION_STEP_MOCKS, }; @@ -200,6 +198,7 @@ describe('test workflow deploy', () => { .runEvent('push', { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, + actor: 'Dummy Author', }); assertions.assertValidateJobExecuted(result); assertions.assertDeployStagingJobExecuted(result, false); @@ -209,7 +208,7 @@ describe('test workflow deploy', () => { test('to production - nothing triggered', async () => { const repoPath = mockGithub.repo.getPath('testDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'deploy.yml'); - let act = new kieActJs.Act(repoPath, workflowPath); + let act = new utils.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams( act, 'push', @@ -217,14 +216,13 @@ describe('test workflow deploy', () => { ref: 'refs/heads/production', }, { - GITHUB_ACTOR: 'Dummy Author', OS_BOTIFY_TOKEN: 'dummy_token', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', }, 'dummy_github_token', ); const testMockSteps = { - validate: mocks.VALIDATE__OSBOTIFY__STEP_MOCKS, + validate: mocks.VALIDATE_STEP_MOCKS, deployStaging: mocks.DEPLOY_STAGING_STEP_MOCKS, deployProduction: mocks.DEPLOY_PRODUCTION_STEP_MOCKS, }; @@ -232,6 +230,7 @@ describe('test workflow deploy', () => { .runEvent('push', { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, + actor: 'Dummy Author', }); assertions.assertValidateJobExecuted(result); assertions.assertDeployStagingJobExecuted(result, false); @@ -242,7 +241,7 @@ describe('test workflow deploy', () => { test('different event than push - workflow does not execute', async () => { const repoPath = mockGithub.repo.getPath('testdeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'deploy.yml'); - let act = new kieActJs.Act(repoPath, workflowPath); + let act = new utils.ExtendedAct(repoPath, workflowPath); const testMockSteps = { validate: mocks.VALIDATE__OSBOTIFY__STEP_MOCKS, deployStaging: mocks.DEPLOY_STAGING_STEP_MOCKS, @@ -255,7 +254,6 @@ describe('test workflow deploy', () => { 'pull_request', {head: {ref: 'main'}}, { - GITHUB_ACTOR: 'Dummy Author', OS_BOTIFY_TOKEN: 'dummy_token', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', }, @@ -265,6 +263,7 @@ describe('test workflow deploy', () => { .runEvent('pull_request', { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, + actor: 'Dummy Author', }); assertions.assertValidateJobExecuted(result, false); assertions.assertDeployStagingJobExecuted(result, false); @@ -276,7 +275,6 @@ describe('test workflow deploy', () => { 'workflow_dispatch', {}, { - GITHUB_ACTOR: 'Dummy Author', OS_BOTIFY_TOKEN: 'dummy_token', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', }, @@ -286,6 +284,7 @@ describe('test workflow deploy', () => { .runEvent('workflow_dispatch', { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, + actor: 'Dummy Author', }); assertions.assertValidateJobExecuted(result, false); assertions.assertDeployStagingJobExecuted(result, false); diff --git a/workflow_tests/platformDeploy.test.js b/workflow_tests/platformDeploy.test.js index d721b3554e63..0233c224ac15 100644 --- a/workflow_tests/platformDeploy.test.js +++ b/workflow_tests/platformDeploy.test.js @@ -1,5 +1,4 @@ const path = require('path'); -const kieActJs = require('@kie/act-js'); const kieMockGithub = require('@kie/mock-github'); const utils = require('./utils'); const assertions = require('./assertions/platformDeployAssertions'); @@ -47,7 +46,7 @@ describe('test workflow platformDeploy', () => { test('test', async () => { const repoPath = mockGithub.repo.getPath('testPlatformDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'platformDeploy.yml'); - let act = new kieActJs.Act(repoPath, workflowPath); + let act = new utils.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams( act, 'push', @@ -56,7 +55,6 @@ describe('test workflow platformDeploy', () => { }, { OS_BOTIFY_TOKEN: 'dummy_token', - GITHUB_ACTOR: 'Dummy Author', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', MYAPP_UPLOAD_STORE_PASSWORD: 'dummy_store_password', MYAPP_UPLOAD_KEY_PASSWORD: 'dummy_key_password', @@ -102,6 +100,7 @@ describe('test workflow platformDeploy', () => { .runEvent('push', { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, + actor: 'Dummy Author', }); assertions.assertVerifyActorJobExecuted(result); @@ -112,5 +111,5 @@ describe('test workflow platformDeploy', () => { assertions.assertPostSlackOnFailureJobExecuted(result, false); assertions.assertPostSlackOnSuccessJobExecuted(result, true, false); assertions.assertPostGithubCommentJobExecuted(result, true, false); - }, 120000); + }, 60000); }); diff --git a/workflow_tests/preDeploy.test.js b/workflow_tests/preDeploy.test.js index 4d33251e3534..8018f6768beb 100644 --- a/workflow_tests/preDeploy.test.js +++ b/workflow_tests/preDeploy.test.js @@ -1,5 +1,4 @@ const path = require('path'); -const kieActJs = require('@kie/act-js'); const kieMockGithub = require('@kie/mock-github'); const utils = require('./utils'); const assertions = require('./assertions/preDeployAssertions'); @@ -31,7 +30,7 @@ beforeEach(async () => { repo: { testPreDeployWorkflowRepo: { files: FILES_TO_COPY_INTO_TEST_REPO, - pushedBranches: ['not_main'], + pushedBranches: ['different_branch'], }, }, }); @@ -52,7 +51,7 @@ describe('test workflow preDeploy', () => { const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); // instantiate Act in the context of the test repo and given workflow file - let act = new kieActJs.Act(repoPath, workflowPath); + let act = new utils.ExtendedAct(repoPath, workflowPath); // set run parameters act = utils.setUpActParams( @@ -60,7 +59,7 @@ describe('test workflow preDeploy', () => { 'push', {ref: 'refs/heads/main'}, { - OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', + OS_BOTIFY_TOKEN: 'dummy_token', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', }, 'dummy_github_token', ); @@ -84,6 +83,7 @@ describe('test workflow preDeploy', () => { .runEvent('push', { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, + actor: 'Dummy Tester', }); // assert results (some steps can run in parallel to each other so the order is not assured @@ -101,13 +101,15 @@ describe('test workflow preDeploy', () => { test('push to different branch - workflow does not execute', async () => { const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); - let act = new kieActJs.Act(repoPath, workflowPath); + let act = new utils.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams( act, 'push', - {ref: 'refs/heads/not_main'}, { - OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', + ref: 'refs/heads/different_branch', + }, + { + OS_BOTIFY_TOKEN: 'dummy_token', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', }, 'dummy_github_token', ); @@ -127,6 +129,7 @@ describe('test workflow preDeploy', () => { .runEvent('push', { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, + actor: 'Dummy Tester', }); assertions.assertLintJobExecuted(result, false); assertions.assertTestJobExecuted(result, false); @@ -141,7 +144,7 @@ describe('test workflow preDeploy', () => { test('different event than push - workflow does not execute', async () => { const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); - let act = new kieActJs.Act(repoPath, workflowPath); + let act = new utils.ExtendedAct(repoPath, workflowPath); const testMockSteps = { lint: mocks.LINT_JOB_MOCK_STEPS, test: mocks.TEST_JOB_MOCK_STEPS, @@ -161,7 +164,7 @@ describe('test workflow preDeploy', () => { 'pull_request', {head: {ref: 'main'}}, { - OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', + OS_BOTIFY_TOKEN: 'dummy_token', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', }, 'dummy_github_token', ); @@ -169,6 +172,7 @@ describe('test workflow preDeploy', () => { .runEvent('pull_request', { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, + actor: 'Dummy Tester', }); assertions.assertLintJobExecuted(result, false); assertions.assertTestJobExecuted(result, false); @@ -185,7 +189,7 @@ describe('test workflow preDeploy', () => { 'workflow_dispatch', {}, { - OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', + OS_BOTIFY_TOKEN: 'dummy_token', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', }, 'dummy_github_token', ); @@ -193,6 +197,7 @@ describe('test workflow preDeploy', () => { .runEvent('workflow_dispatch', { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, + actor: 'Dummy Tester', }); assertions.assertLintJobExecuted(result, false); assertions.assertTestJobExecuted(result, false); @@ -208,13 +213,13 @@ describe('test workflow preDeploy', () => { test('lint job failed - workflow exits', async () => { const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); - let act = new kieActJs.Act(repoPath, workflowPath); + let act = new utils.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams( act, 'push', {ref: 'refs/heads/main'}, { - OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', + OS_BOTIFY_TOKEN: 'dummy_token', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', }, 'dummy_github_token', ); @@ -245,6 +250,7 @@ describe('test workflow preDeploy', () => { .runEvent('push', { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, + actor: 'Dummy Tester', }); expect(result).toEqual(expect.arrayContaining( [ @@ -286,13 +292,13 @@ describe('test workflow preDeploy', () => { test('test job failed - workflow exits', async () => { const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); - let act = new kieActJs.Act(repoPath, workflowPath); + let act = new utils.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams( act, 'push', {ref: 'refs/heads/main'}, { - OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', + OS_BOTIFY_TOKEN: 'dummy_token', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', }, 'dummy_github_token', ); @@ -323,6 +329,7 @@ describe('test workflow preDeploy', () => { .runEvent('push', { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, + actor: 'Dummy Tester', }); assertions.assertLintJobExecuted(result); expect(result).toEqual(expect.arrayContaining( @@ -364,13 +371,13 @@ describe('test workflow preDeploy', () => { test('lint and test job succeed - workflow continues', async () => { const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); - let act = new kieActJs.Act(repoPath, workflowPath); + let act = new utils.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams( act, 'push', {ref: 'refs/heads/main'}, { - OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', + OS_BOTIFY_TOKEN: 'dummy_token', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', }, 'dummy_github_token', ); @@ -390,15 +397,16 @@ describe('test workflow preDeploy', () => { .runEvent('push', { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, + actor: 'Dummy Tester', }); assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); assertions.assertIsExpensifyEmployeeJobExecuted(result); assertions.assertE2ETestsJobExecuted(result, false); // Act does not support ubuntu-20.04-64core runner and omits the job - assertions.assertChooseDeployActionsJobExecuted(result, false); + assertions.assertChooseDeployActionsJobExecuted(result); assertions.assertSkipDeployJobExecuted(result, false); - assertions.assertCreateNewVersionJobExecuted(result, false); - assertions.assertUpdateStagingJobExecuted(result, false); + assertions.assertCreateNewVersionJobExecuted(result); + assertions.assertUpdateStagingJobExecuted(result); }, 60000); }); @@ -406,13 +414,13 @@ describe('test workflow preDeploy', () => { test('actor is OSBotify - no comment left', async () => { const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); - let act = new kieActJs.Act(repoPath, workflowPath); + let act = new utils.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams( act, 'push', {ref: 'refs/heads/main'}, { - OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'OSBotify', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', + OS_BOTIFY_TOKEN: 'dummy_token', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', }, 'dummy_github_token', ); @@ -432,6 +440,7 @@ describe('test workflow preDeploy', () => { .runEvent('push', { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, + actor: 'OSBotify', }); assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); @@ -444,13 +453,13 @@ describe('test workflow preDeploy', () => { test('actor is Expensify employee - no comment left', async () => { const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); - let act = new kieActJs.Act(repoPath, workflowPath); + let act = new utils.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams( act, 'push', {ref: 'refs/heads/main'}, { - OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', + OS_BOTIFY_TOKEN: 'dummy_token', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', }, 'dummy_github_token', ); @@ -470,6 +479,7 @@ describe('test workflow preDeploy', () => { .runEvent('push', { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, + actor: 'Dummy Tester', }); assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); @@ -482,13 +492,13 @@ describe('test workflow preDeploy', () => { test('actor is not Expensify employee, its not their first PR - job triggers, but no comment left', async () => { const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); - let act = new kieActJs.Act(repoPath, workflowPath); + let act = new utils.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams( act, 'push', {ref: 'refs/heads/main'}, { - OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', + OS_BOTIFY_TOKEN: 'dummy_token', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', }, 'dummy_github_token', ); @@ -508,6 +518,7 @@ describe('test workflow preDeploy', () => { .runEvent('push', { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, + actor: 'Dummy Tester', }); assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); @@ -520,13 +531,13 @@ describe('test workflow preDeploy', () => { test('actor is not Expensify employee, and its their first PR - job triggers and comment left', async () => { const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); - let act = new kieActJs.Act(repoPath, workflowPath); + let act = new utils.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams( act, 'push', {ref: 'refs/heads/main'}, { - OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', + OS_BOTIFY_TOKEN: 'dummy_token', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', }, 'dummy_github_token', ); @@ -546,6 +557,7 @@ describe('test workflow preDeploy', () => { .runEvent('push', { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, + actor: 'Dummy Tester', }); assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); @@ -562,12 +574,12 @@ describe('test workflow preDeploy', () => { test('not automated PR - deploy skipped and comment left', async () => { const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); - let act = new kieActJs.Act(repoPath, workflowPath); + let act = new utils.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams( act, 'push', {ref: 'refs/heads/main'}, - {OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook'}, + {OS_BOTIFY_TOKEN: 'dummy_token', SLACK_WEBHOOK: 'dummy_slack_webhook'}, 'dummy_github_token', ); const testMockSteps = { @@ -586,6 +598,7 @@ describe('test workflow preDeploy', () => { .runEvent('push', { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, + actor: 'Dummy Tester', }); assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); @@ -601,12 +614,12 @@ describe('test workflow preDeploy', () => { test('automated PR - deploy skipped, but no comment left', async () => { const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); - let act = new kieActJs.Act(repoPath, workflowPath); + let act = new utils.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams( act, 'push', {ref: 'refs/heads/main'}, - {OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'OSBotify', SLACK_WEBHOOK: 'dummy_slack_webhook'}, + {OS_BOTIFY_TOKEN: 'dummy_token', SLACK_WEBHOOK: 'dummy_slack_webhook'}, 'dummy_github_token', ); const testMockSteps = { @@ -618,13 +631,14 @@ describe('test workflow preDeploy', () => { createNewVersion: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, - newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, + newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__OSBOTIFY, 'e2e-tests': mocks.E2E_TESTS_JOB_MOCK_STEPS, }; const result = await act .runEvent('push', { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, + actor: 'OSBotify', }); assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); @@ -642,14 +656,13 @@ describe('test workflow preDeploy', () => { test('not automated PR - proceed with deploy', async () => { const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); - let act = new kieActJs.Act(repoPath, workflowPath); + let act = new utils.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams( act, 'push', {ref: 'refs/heads/main'}, { OS_BOTIFY_TOKEN: 'dummy_token', - GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', }, @@ -671,6 +684,7 @@ describe('test workflow preDeploy', () => { .runEvent('push', { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, + actor: 'Dummy Tester', }); assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); @@ -686,14 +700,13 @@ describe('test workflow preDeploy', () => { test('automated PR - deploy skipped, but no comment left', async () => { const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); - let act = new kieActJs.Act(repoPath, workflowPath); + let act = new utils.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams( act, 'push', {ref: 'refs/heads/main'}, { OS_BOTIFY_TOKEN: 'dummy_token', - GITHUB_ACTOR: 'OSBotify', SLACK_WEBHOOK: 'dummy_slack_webhook', }, 'dummy_github_token', @@ -707,13 +720,14 @@ describe('test workflow preDeploy', () => { createNewVersion: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, - newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, + newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__OSBOTIFY, 'e2e-tests': mocks.E2E_TESTS_JOB_MOCK_STEPS, }; const result = await act .runEvent('push', { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, + actor: 'OSBotify', }); assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); @@ -733,14 +747,13 @@ describe('test workflow preDeploy', () => { test('not automated PR - proceed with deploy', async () => { const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); - let act = new kieActJs.Act(repoPath, workflowPath); + let act = new utils.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams( act, 'push', {ref: 'refs/heads/main'}, { OS_BOTIFY_TOKEN: 'dummy_token', - GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', }, @@ -762,6 +775,7 @@ describe('test workflow preDeploy', () => { .runEvent('push', { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, + actor: 'Dummy Tester', }); assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); @@ -777,14 +791,13 @@ describe('test workflow preDeploy', () => { test('automated PR - proceed with deploy', async () => { const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); - let act = new kieActJs.Act(repoPath, workflowPath); + let act = new utils.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams( act, 'push', {ref: 'refs/heads/main'}, { OS_BOTIFY_TOKEN: 'dummy_token', - GITHUB_ACTOR: 'OSBotify', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', }, @@ -806,6 +819,7 @@ describe('test workflow preDeploy', () => { .runEvent('push', { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, + actor: 'OSBotify', }); assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); @@ -823,14 +837,13 @@ describe('test workflow preDeploy', () => { test('not automated PR - proceed with deploy', async () => { const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); - let act = new kieActJs.Act(repoPath, workflowPath); + let act = new utils.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams( act, 'push', {ref: 'refs/heads/main'}, { OS_BOTIFY_TOKEN: 'dummy_token', - GITHUB_ACTOR: 'Dummy Tester', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', }, @@ -852,6 +865,7 @@ describe('test workflow preDeploy', () => { .runEvent('push', { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, + actor: 'Dummy Tester', }); assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); @@ -867,14 +881,13 @@ describe('test workflow preDeploy', () => { test('automated PR - proceed with deploy', async () => { const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); - let act = new kieActJs.Act(repoPath, workflowPath); + let act = new utils.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams( act, 'push', {ref: 'refs/heads/main'}, { OS_BOTIFY_TOKEN: 'dummy_token', - GITHUB_ACTOR: 'OSBotify', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', }, @@ -896,6 +909,7 @@ describe('test workflow preDeploy', () => { .runEvent('push', { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, + actor: 'OSBotify', }); assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); @@ -913,13 +927,13 @@ describe('test workflow preDeploy', () => { test('one of updateStaging steps failed - failure announced in Slack', async () => { const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); - let act = new kieActJs.Act(repoPath, workflowPath); + let act = new utils.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams( act, 'push', {ref: 'refs/heads/main'}, { - OS_BOTIFY_TOKEN: 'dummy_token', GITHUB_ACTOR: 'OSBotify', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', + OS_BOTIFY_TOKEN: 'dummy_token', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', }, 'dummy_github_token', ); @@ -940,6 +954,7 @@ describe('test workflow preDeploy', () => { .runEvent('push', { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, + actor: 'OSBotify', }); assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); From f6aa12aaea273d45e06bc92eb55c79caadee2261 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Wed, 8 Mar 2023 14:12:28 +0100 Subject: [PATCH 037/504] Update tests Updated previously failing tests See: https://github.com/Expensify/App/issues/13604 --- .../assertions/platformDeployAssertions.js | 8 +- workflow_tests/deploy.test.js | 14 +- workflow_tests/mocks/platformDeployMocks.js | 2 +- workflow_tests/platformDeploy.test.js | 291 ++++++++++++++---- 4 files changed, 235 insertions(+), 80 deletions(-) diff --git a/workflow_tests/assertions/platformDeployAssertions.js b/workflow_tests/assertions/platformDeployAssertions.js index 6b25263bd59d..e4b2c9bae920 100644 --- a/workflow_tests/assertions/platformDeployAssertions.js +++ b/workflow_tests/assertions/platformDeployAssertions.js @@ -1,6 +1,6 @@ const utils = require('../utils'); -const assertVerifyActorJobExecuted = (workflowResult, didExecute = true) => { +const assertVerifyActorJobExecuted = (workflowResult, username, didExecute = true) => { const steps = [ utils.getStepAssertion( 'Check if user is deployer', @@ -8,7 +8,7 @@ const assertVerifyActorJobExecuted = (workflowResult, didExecute = true) => { null, 'VALIDATE_ACTOR', 'Checking if the user is a deployer', - [{key: 'GITHUB_TOKEN', value: '***'}, {key: 'team', value: 'mobile-deployers'}], + [{key: 'GITHUB_TOKEN', value: '***'}, {key: 'username', value: username}, {key: 'team', value: 'mobile-deployers'}], ), ]; @@ -549,7 +549,7 @@ const assertPostSlackOnSuccessJobExecuted = (workflowResult, didExecute = true, } }; -const assertPostGithubCommentJobExecuted = (workflowResult, didExecute = true, isProduction = true) => { +const assertPostGithubCommentJobExecuted = (workflowResult, didExecute = true, isProduction = true, didDeploy = true) => { const steps = [ utils.getStepAssertion( 'Checkout', @@ -587,7 +587,7 @@ const assertPostGithubCommentJobExecuted = (workflowResult, didExecute = true, i null, 'POST_GITHUB_COMMENT', 'Commenting on issues', - [{key: 'PR_LIST', value: '[1.2.1, 1.2.2]'}, {key: 'IS_PRODUCTION_DEPLOY', value: isProduction ? 'true' : 'false'}, {key: 'DEPLOY_VERSION', value: '1.2.3'}, {key: 'GITHUB_TOKEN', value: '***'}, {key: 'ANDROID', value: 'success'}, {key: 'DESKTOP', value: 'success'}, {key: 'IOS', value: 'success'}, {key: 'WEB', value: 'success'}], + [{key: 'PR_LIST', value: '[1.2.1, 1.2.2]'}, {key: 'IS_PRODUCTION_DEPLOY', value: isProduction ? 'true' : 'false'}, {key: 'DEPLOY_VERSION', value: '1.2.3'}, {key: 'GITHUB_TOKEN', value: '***'}, {key: 'ANDROID', value: didDeploy ? 'success' : ''}, {key: 'DESKTOP', value: didDeploy ? 'success' : ''}, {key: 'IOS', value: didDeploy ? 'success' : ''}, {key: 'WEB', value: didDeploy ? 'success' : ''}], ), ]; diff --git a/workflow_tests/deploy.test.js b/workflow_tests/deploy.test.js index 1ad5ff46990f..49190b8efc9c 100644 --- a/workflow_tests/deploy.test.js +++ b/workflow_tests/deploy.test.js @@ -47,7 +47,7 @@ describe('test workflow deploy', () => { test('to main - nothing triggered', async () => { const repoPath = mockGithub.repo.getPath('testDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'deploy.yml'); - let act = new utils.ExtendedAct(repoPath, workflowPath); + let act = new eAct.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams( act, 'push', @@ -79,7 +79,7 @@ describe('test workflow deploy', () => { test('to staging - deployStaging triggered', async () => { const repoPath = mockGithub.repo.getPath('testDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'deploy.yml'); - let act = new utils.ExtendedAct(repoPath, workflowPath); + let act = new eAct.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams( act, 'push', @@ -111,7 +111,7 @@ describe('test workflow deploy', () => { test('to production - deployProduction triggered', async () => { const repoPath = mockGithub.repo.getPath('testDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'deploy.yml'); - let act = new utils.ExtendedAct(repoPath, workflowPath); + let act = new eAct.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams( act, 'push', @@ -144,7 +144,7 @@ describe('test workflow deploy', () => { test('to main - nothing triggered', async () => { const repoPath = mockGithub.repo.getPath('testDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'deploy.yml'); - let act = new utils.ExtendedAct(repoPath, workflowPath); + let act = new eAct.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams( act, 'push', @@ -176,7 +176,7 @@ describe('test workflow deploy', () => { test('to staging - nothing triggered', async () => { const repoPath = mockGithub.repo.getPath('testDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'deploy.yml'); - let act = new utils.ExtendedAct(repoPath, workflowPath); + let act = new eAct.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams( act, 'push', @@ -208,7 +208,7 @@ describe('test workflow deploy', () => { test('to production - nothing triggered', async () => { const repoPath = mockGithub.repo.getPath('testDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'deploy.yml'); - let act = new utils.ExtendedAct(repoPath, workflowPath); + let act = new eAct.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams( act, 'push', @@ -241,7 +241,7 @@ describe('test workflow deploy', () => { test('different event than push - workflow does not execute', async () => { const repoPath = mockGithub.repo.getPath('testdeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'deploy.yml'); - let act = new utils.ExtendedAct(repoPath, workflowPath); + let act = new eAct.ExtendedAct(repoPath, workflowPath); const testMockSteps = { validate: mocks.VALIDATE__OSBOTIFY__STEP_MOCKS, deployStaging: mocks.DEPLOY_STAGING_STEP_MOCKS, diff --git a/workflow_tests/mocks/platformDeployMocks.js b/workflow_tests/mocks/platformDeployMocks.js index 42e790236b64..31d4716f7a00 100644 --- a/workflow_tests/mocks/platformDeployMocks.js +++ b/workflow_tests/mocks/platformDeployMocks.js @@ -5,7 +5,7 @@ const PLATFORM_DEPLOY__VALIDATE_ACTOR__CHECK_USER_DEPLOYER__TEAM_MEMBER__STEP_MO 'Check if user is deployer', 'Checking if the user is a deployer', 'VALIDATE_ACTOR', - ['GITHUB_TOKEN', 'team'], + ['GITHUB_TOKEN', 'username', 'team'], null, {isTeamMember: true}, ); diff --git a/workflow_tests/platformDeploy.test.js b/workflow_tests/platformDeploy.test.js index 0233c224ac15..f4ff084e2d88 100644 --- a/workflow_tests/platformDeploy.test.js +++ b/workflow_tests/platformDeploy.test.js @@ -43,73 +43,228 @@ afterEach(async () => { }); describe('test workflow platformDeploy', () => { - test('test', async () => { - const repoPath = mockGithub.repo.getPath('testPlatformDeployWorkflowRepo') || ''; - const workflowPath = path.join(repoPath, '.github', 'workflows', 'platformDeploy.yml'); - let act = new utils.ExtendedAct(repoPath, workflowPath); - act = utils.setUpActParams( - act, - 'push', - { - ref: 'refs/tags/1.2.3', - }, - { - OS_BOTIFY_TOKEN: 'dummy_token', - LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', - MYAPP_UPLOAD_STORE_PASSWORD: 'dummy_store_password', - MYAPP_UPLOAD_KEY_PASSWORD: 'dummy_key_password', - BROWSERSTACK: 'dummy_browserstack', - SLACK_WEBHOOK: 'dummy_slack_webhook', - DEVELOPER_ID_SECRET_PASSPHRASE: 'dummy_secret_passphrase', - CSC_LINK: 'dummy_csc_link', - CSC_KEY_PASSWORD: 'dummy_csc_key_pass', - APPLE_ID: 'dummy_apple_id', - APPLE_ID_PASSWORD: 'dummy_apple_pass', - AWS_ACCESS_KEY_ID: 'dummy_aws_access_key_id', - AWS_SECRET_ACCESS_KEY: 'dummy_aws_secret_access_key', - APPLE_CONTACT_EMAIL: 'dummy@email.com', - APPLE_CONTACT_PHONE: '123456789', - APPLE_DEMO_EMAIL: 'dummy.demo@email.com', - APPLE_DEMO_PASSWORD: 'dummy_password', - CLOUDFLARE_TOKEN: 'dummy_cloudflare_token', - }, - 'dummy_github_token', - { - AS_REPO: 'App', - }, - ); - act = utils.setJobRunners( - act, - { - desktop: 'ubuntu-latest', - iOS: 'ubuntu-latest', - }, - workflowPath, - ); - const testMockSteps = { - validateActor: mocks.PLATFORM_DEPLOY__VALIDATE_ACTOR__TEAM_MEMBER__STEP_MOCKS, - android: mocks.PLATFORM_DEPLOY__ANDROID__STEP_MOCKS, - desktop: mocks.PLATFORM_DEPLOY__DESKTOP__STEP_MOCKS, - iOS: mocks.PLATFORM_DEPLOY__IOS__STEP_MOCKS, - web: mocks.PLATFORM_DEPLOY__WEB__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, - }; - const result = await act - .runEvent('push', { - workflowFile: path.join(repoPath, '.github', 'workflows'), - mockSteps: testMockSteps, - actor: 'Dummy Author', - }); + describe('push', () => { + describe('tag', () => { + test('as team member - platform deploy executes on staging', async () => { + const repoPath = mockGithub.repo.getPath('testPlatformDeployWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'platformDeploy.yml'); + let act = new utils.ExtendedAct(repoPath, workflowPath); + act = utils.setUpActParams( + act, + 'push', + { + ref: 'refs/tags/1.2.3', + ref_type: 'tag', + ref_name: '1.2.3', + }, + { + OS_BOTIFY_TOKEN: 'dummy_token', + LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', + MYAPP_UPLOAD_STORE_PASSWORD: 'dummy_store_password', + MYAPP_UPLOAD_KEY_PASSWORD: 'dummy_key_password', + BROWSERSTACK: 'dummy_browserstack', + SLACK_WEBHOOK: 'dummy_slack_webhook', + DEVELOPER_ID_SECRET_PASSPHRASE: 'dummy_secret_passphrase', + CSC_LINK: 'dummy_csc_link', + CSC_KEY_PASSWORD: 'dummy_csc_key_pass', + APPLE_ID: 'dummy_apple_id', + APPLE_ID_PASSWORD: 'dummy_apple_pass', + AWS_ACCESS_KEY_ID: 'dummy_aws_access_key_id', + AWS_SECRET_ACCESS_KEY: 'dummy_aws_secret_access_key', + APPLE_CONTACT_EMAIL: 'dummy@email.com', + APPLE_CONTACT_PHONE: '123456789', + APPLE_DEMO_EMAIL: 'dummy.demo@email.com', + APPLE_DEMO_PASSWORD: 'dummy_password', + CLOUDFLARE_TOKEN: 'dummy_cloudflare_token', + }, + 'dummy_github_token', + { + AS_REPO: 'App', + }, + ); + act = utils.setJobRunners( + act, + { + desktop: 'ubuntu-latest', + iOS: 'ubuntu-latest', + }, + workflowPath, + ); + const testMockSteps = { + validateActor: mocks.PLATFORM_DEPLOY__VALIDATE_ACTOR__TEAM_MEMBER__STEP_MOCKS, + android: mocks.PLATFORM_DEPLOY__ANDROID__STEP_MOCKS, + desktop: mocks.PLATFORM_DEPLOY__DESKTOP__STEP_MOCKS, + iOS: mocks.PLATFORM_DEPLOY__IOS__STEP_MOCKS, + web: mocks.PLATFORM_DEPLOY__WEB__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, + }; + const result = await act + .runEvent('push', { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor: 'Dummy Author', + }); + + assertions.assertVerifyActorJobExecuted(result, 'Dummy Author'); + assertions.assertAndroidJobExecuted(result, true, false, true); + assertions.assertDesktopJobExecuted(result, true, false); + assertions.assertIOSJobExecuted(result, true, false, true); + assertions.assertWebJobExecuted(result, true, false); + assertions.assertPostSlackOnFailureJobExecuted(result, false); + assertions.assertPostSlackOnSuccessJobExecuted(result, true, false); + assertions.assertPostGithubCommentJobExecuted(result, true, false); + }, 60000); + + test('as OSBotify - platform deploy executes on staging', async () => { + const repoPath = mockGithub.repo.getPath('testPlatformDeployWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'platformDeploy.yml'); + let act = new utils.ExtendedAct(repoPath, workflowPath); + act = utils.setUpActParams( + act, + 'push', + { + ref: 'refs/tags/1.2.3', + ref_type: 'tag', + ref_name: '1.2.3', + }, + { + OS_BOTIFY_TOKEN: 'dummy_token', + LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', + MYAPP_UPLOAD_STORE_PASSWORD: 'dummy_store_password', + MYAPP_UPLOAD_KEY_PASSWORD: 'dummy_key_password', + BROWSERSTACK: 'dummy_browserstack', + SLACK_WEBHOOK: 'dummy_slack_webhook', + DEVELOPER_ID_SECRET_PASSPHRASE: 'dummy_secret_passphrase', + CSC_LINK: 'dummy_csc_link', + CSC_KEY_PASSWORD: 'dummy_csc_key_pass', + APPLE_ID: 'dummy_apple_id', + APPLE_ID_PASSWORD: 'dummy_apple_pass', + AWS_ACCESS_KEY_ID: 'dummy_aws_access_key_id', + AWS_SECRET_ACCESS_KEY: 'dummy_aws_secret_access_key', + APPLE_CONTACT_EMAIL: 'dummy@email.com', + APPLE_CONTACT_PHONE: '123456789', + APPLE_DEMO_EMAIL: 'dummy.demo@email.com', + APPLE_DEMO_PASSWORD: 'dummy_password', + CLOUDFLARE_TOKEN: 'dummy_cloudflare_token', + }, + 'dummy_github_token', + { + AS_REPO: 'App', + }, + ); + act = utils.setJobRunners( + act, + { + desktop: 'ubuntu-latest', + iOS: 'ubuntu-latest', + }, + workflowPath, + ); + const testMockSteps = { + validateActor: mocks.PLATFORM_DEPLOY__VALIDATE_ACTOR__OUTSIDER__STEP_MOCKS, + android: mocks.PLATFORM_DEPLOY__ANDROID__STEP_MOCKS, + desktop: mocks.PLATFORM_DEPLOY__DESKTOP__STEP_MOCKS, + iOS: mocks.PLATFORM_DEPLOY__IOS__STEP_MOCKS, + web: mocks.PLATFORM_DEPLOY__WEB__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, + }; + const result = await act + .runEvent('push', { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor: 'OSBotify', + }); - assertions.assertVerifyActorJobExecuted(result); - assertions.assertAndroidJobExecuted(result, true, false, true); - assertions.assertDesktopJobExecuted(result, true, false); - assertions.assertIOSJobExecuted(result, true, false, true); - assertions.assertWebJobExecuted(result, true, false); - assertions.assertPostSlackOnFailureJobExecuted(result, false); - assertions.assertPostSlackOnSuccessJobExecuted(result, true, false); - assertions.assertPostGithubCommentJobExecuted(result, true, false); - }, 60000); + assertions.assertVerifyActorJobExecuted(result, 'OSBotify'); + assertions.assertAndroidJobExecuted(result, true, false, true); + assertions.assertDesktopJobExecuted(result, true, false); + assertions.assertIOSJobExecuted(result, true, false, true); + assertions.assertWebJobExecuted(result, true, false); + assertions.assertPostSlackOnFailureJobExecuted(result, false); + assertions.assertPostSlackOnSuccessJobExecuted(result, true, false); + assertions.assertPostGithubCommentJobExecuted(result, true, false); + }, 60000); + + test('as outsider - platform deploy does not execute', async () => { + const repoPath = mockGithub.repo.getPath('testPlatformDeployWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'platformDeploy.yml'); + let act = new utils.ExtendedAct(repoPath, workflowPath); + act = utils.setUpActParams( + act, + 'push', + { + ref: 'refs/tags/1.2.3', + ref_type: 'tag', + ref_name: '1.2.3', + }, + { + OS_BOTIFY_TOKEN: 'dummy_token', + LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', + MYAPP_UPLOAD_STORE_PASSWORD: 'dummy_store_password', + MYAPP_UPLOAD_KEY_PASSWORD: 'dummy_key_password', + BROWSERSTACK: 'dummy_browserstack', + SLACK_WEBHOOK: 'dummy_slack_webhook', + DEVELOPER_ID_SECRET_PASSPHRASE: 'dummy_secret_passphrase', + CSC_LINK: 'dummy_csc_link', + CSC_KEY_PASSWORD: 'dummy_csc_key_pass', + APPLE_ID: 'dummy_apple_id', + APPLE_ID_PASSWORD: 'dummy_apple_pass', + AWS_ACCESS_KEY_ID: 'dummy_aws_access_key_id', + AWS_SECRET_ACCESS_KEY: 'dummy_aws_secret_access_key', + APPLE_CONTACT_EMAIL: 'dummy@email.com', + APPLE_CONTACT_PHONE: '123456789', + APPLE_DEMO_EMAIL: 'dummy.demo@email.com', + APPLE_DEMO_PASSWORD: 'dummy_password', + CLOUDFLARE_TOKEN: 'dummy_cloudflare_token', + }, + 'dummy_github_token', + { + AS_REPO: 'App', + }, + ); + act = utils.setJobRunners( + act, + { + desktop: 'ubuntu-latest', + iOS: 'ubuntu-latest', + }, + workflowPath, + ); + const testMockSteps = { + validateActor: mocks.PLATFORM_DEPLOY__VALIDATE_ACTOR__OUTSIDER__STEP_MOCKS, + android: mocks.PLATFORM_DEPLOY__ANDROID__STEP_MOCKS, + desktop: mocks.PLATFORM_DEPLOY__DESKTOP__STEP_MOCKS, + iOS: mocks.PLATFORM_DEPLOY__IOS__STEP_MOCKS, + web: mocks.PLATFORM_DEPLOY__WEB__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, + }; + const result = await act + .runEvent('push', { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor: 'Dummy Author', + }); + + assertions.assertVerifyActorJobExecuted(result, 'Dummy Author'); + assertions.assertAndroidJobExecuted(result, false); + assertions.assertDesktopJobExecuted(result, false); + assertions.assertIOSJobExecuted(result, false); + assertions.assertWebJobExecuted(result, false); + assertions.assertPostSlackOnFailureJobExecuted(result, false); + assertions.assertPostSlackOnSuccessJobExecuted(result, false); + assertions.assertPostGithubCommentJobExecuted(result, true, false, false); + }, 60000); + }); + + describe('branch', () => { + // changing ref_type does not seem to work as described in documentation + + }); + }); }); From d4ae0c63e874f0c7acd1cfdc5220784a4fa45d41 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Wed, 8 Mar 2023 14:14:11 +0100 Subject: [PATCH 038/504] Restructure utils Created utils folder, moved ExtendedAct into a separate file See: https://github.com/Expensify/App/issues/13604 --- workflow_tests/assertions/deployAssertions.js | 2 +- .../assertions/platformDeployAssertions.js | 2 +- .../assertions/preDeployAssertions.js | 2 +- workflow_tests/deploy.test.js | 3 +- workflow_tests/mocks/deployMocks.js | 2 +- workflow_tests/mocks/platformDeployMocks.js | 2 +- workflow_tests/mocks/preDeployMocks.js | 2 +- workflow_tests/platformDeploy.test.js | 2 +- workflow_tests/preDeploy.test.js | 87 ++++++++++--------- workflow_tests/utils/ExtendedAct.js | 15 ++++ workflow_tests/{ => utils}/utils.js | 12 --- 11 files changed, 68 insertions(+), 63 deletions(-) create mode 100644 workflow_tests/utils/ExtendedAct.js rename workflow_tests/{ => utils}/utils.js (90%) diff --git a/workflow_tests/assertions/deployAssertions.js b/workflow_tests/assertions/deployAssertions.js index 4c12d778cc05..c8917921df11 100644 --- a/workflow_tests/assertions/deployAssertions.js +++ b/workflow_tests/assertions/deployAssertions.js @@ -1,4 +1,4 @@ -const utils = require('../utils'); +const utils = require('../utils/utils'); const assertValidateJobExecuted = (workflowResult, didExecute = true) => { const steps = [ diff --git a/workflow_tests/assertions/platformDeployAssertions.js b/workflow_tests/assertions/platformDeployAssertions.js index e4b2c9bae920..a41f5d9f2e72 100644 --- a/workflow_tests/assertions/platformDeployAssertions.js +++ b/workflow_tests/assertions/platformDeployAssertions.js @@ -1,4 +1,4 @@ -const utils = require('../utils'); +const utils = require('../utils/utils'); const assertVerifyActorJobExecuted = (workflowResult, username, didExecute = true) => { const steps = [ diff --git a/workflow_tests/assertions/preDeployAssertions.js b/workflow_tests/assertions/preDeployAssertions.js index c074f4a1f68f..1b089b6385c2 100644 --- a/workflow_tests/assertions/preDeployAssertions.js +++ b/workflow_tests/assertions/preDeployAssertions.js @@ -1,4 +1,4 @@ -const utils = require('../utils'); +const utils = require('../utils/utils'); const assertLintJobExecuted = (workflowResult, didExecute = true) => { const steps = [ diff --git a/workflow_tests/deploy.test.js b/workflow_tests/deploy.test.js index 49190b8efc9c..d573630bcf00 100644 --- a/workflow_tests/deploy.test.js +++ b/workflow_tests/deploy.test.js @@ -1,8 +1,9 @@ const path = require('path'); const kieMockGithub = require('@kie/mock-github'); -const utils = require('./utils'); +const utils = require('./utils/utils'); const assertions = require('./assertions/deployAssertions'); const mocks = require('./mocks/deployMocks'); +const eAct = require('./utils/ExtendedAct'); let mockGithub; const FILES_TO_COPY_INTO_TEST_REPO = [ diff --git a/workflow_tests/mocks/deployMocks.js b/workflow_tests/mocks/deployMocks.js index 0f4164ffa07f..2b71fb1f0b0a 100644 --- a/workflow_tests/mocks/deployMocks.js +++ b/workflow_tests/mocks/deployMocks.js @@ -1,4 +1,4 @@ -const utils = require('../utils'); +const utils = require('../utils/utils'); const VALIDATE__GET_MERGED_PR__STEP_MOCK = utils.getMockStep( 'Get merged pull request', diff --git a/workflow_tests/mocks/platformDeployMocks.js b/workflow_tests/mocks/platformDeployMocks.js index 31d4716f7a00..bb7304338665 100644 --- a/workflow_tests/mocks/platformDeployMocks.js +++ b/workflow_tests/mocks/platformDeployMocks.js @@ -1,4 +1,4 @@ -const utils = require('../utils'); +const utils = require('../utils/utils'); // validateActor const PLATFORM_DEPLOY__VALIDATE_ACTOR__CHECK_USER_DEPLOYER__TEAM_MEMBER__STEP_MOCK = utils.getMockStep( diff --git a/workflow_tests/mocks/preDeployMocks.js b/workflow_tests/mocks/preDeployMocks.js index ed8691defc2f..47aeb77fc87c 100644 --- a/workflow_tests/mocks/preDeployMocks.js +++ b/workflow_tests/mocks/preDeployMocks.js @@ -1,4 +1,4 @@ -const utils = require('../utils'); +const utils = require('../utils/utils'); // lint const LINT_WORKFLOW_MOCK_STEP = utils.getMockStep( diff --git a/workflow_tests/platformDeploy.test.js b/workflow_tests/platformDeploy.test.js index f4ff084e2d88..165189b90131 100644 --- a/workflow_tests/platformDeploy.test.js +++ b/workflow_tests/platformDeploy.test.js @@ -1,6 +1,6 @@ const path = require('path'); const kieMockGithub = require('@kie/mock-github'); -const utils = require('./utils'); +const utils = require('./utils/utils'); const assertions = require('./assertions/platformDeployAssertions'); const mocks = require('./mocks/platformDeployMocks'); diff --git a/workflow_tests/preDeploy.test.js b/workflow_tests/preDeploy.test.js index 8018f6768beb..2dfeee8abed9 100644 --- a/workflow_tests/preDeploy.test.js +++ b/workflow_tests/preDeploy.test.js @@ -1,6 +1,6 @@ const path = require('path'); const kieMockGithub = require('@kie/mock-github'); -const utils = require('./utils'); +const utils = require('./utils/utils'); const assertions = require('./assertions/preDeployAssertions'); const mocks = require('./mocks/preDeployMocks'); @@ -98,48 +98,49 @@ describe('test workflow preDeploy', () => { assertions.assertUpdateStagingJobExecuted(result); }, 60000); - test('push to different branch - workflow does not execute', async () => { - const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; - const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); - let act = new utils.ExtendedAct(repoPath, workflowPath); - act = utils.setUpActParams( - act, - 'push', - { - ref: 'refs/heads/different_branch', - }, - { - OS_BOTIFY_TOKEN: 'dummy_token', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', - }, - 'dummy_github_token', - ); - const testMockSteps = { - lint: mocks.LINT_JOB_MOCK_STEPS, - test: mocks.TEST_JOB_MOCK_STEPS, - confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, - chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__CP_LABEL__STAGING_UNLOCKED, - skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, - createNewVersion: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, - updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, - isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, - newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, - 'e2e-tests': mocks.E2E_TESTS_JOB_MOCK_STEPS, - }; - const result = await act - .runEvent('push', { - workflowFile: path.join(repoPath, '.github', 'workflows'), - mockSteps: testMockSteps, - actor: 'Dummy Tester', - }); - assertions.assertLintJobExecuted(result, false); - assertions.assertTestJobExecuted(result, false); - assertions.assertIsExpensifyEmployeeJobExecuted(result, false); - assertions.assertE2ETestsJobExecuted(result, false); // Act does not support ubuntu-20.04-64core runner and omits the job - assertions.assertChooseDeployActionsJobExecuted(result, false); - assertions.assertSkipDeployJobExecuted(result, false); - assertions.assertCreateNewVersionJobExecuted(result, false); - assertions.assertUpdateStagingJobExecuted(result, false); - }, 60000); + // using a different branch does not seem to work as described in documentation + // test('push to different branch - workflow does not execute', async () => { + // const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; + // const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); + // let act = new utils.ExtendedAct(repoPath, workflowPath); + // act = utils.setUpActParams( + // act, + // 'push', + // { + // ref: 'refs/heads/different_branch', + // }, + // { + // OS_BOTIFY_TOKEN: 'dummy_token', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', + // }, + // 'dummy_github_token', + // ); + // const testMockSteps = { + // lint: mocks.LINT_JOB_MOCK_STEPS, + // test: mocks.TEST_JOB_MOCK_STEPS, + // confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, + // chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__CP_LABEL__STAGING_UNLOCKED, + // skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, + // createNewVersion: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, + // updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, + // isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, + // newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, + // 'e2e-tests': mocks.E2E_TESTS_JOB_MOCK_STEPS, + // }; + // const result = await act + // .runEvent('push', { + // workflowFile: path.join(repoPath, '.github', 'workflows'), + // mockSteps: testMockSteps, + // actor: 'Dummy Tester', + // }); + // assertions.assertLintJobExecuted(result, false); + // assertions.assertTestJobExecuted(result, false); + // assertions.assertIsExpensifyEmployeeJobExecuted(result, false); + // assertions.assertE2ETestsJobExecuted(result, false); // Act does not support ubuntu-20.04-64core runner and omits the job + // assertions.assertChooseDeployActionsJobExecuted(result, false); + // assertions.assertSkipDeployJobExecuted(result, false); + // assertions.assertCreateNewVersionJobExecuted(result, false); + // assertions.assertUpdateStagingJobExecuted(result, false); + // }, 60000); test('different event than push - workflow does not execute', async () => { const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; diff --git a/workflow_tests/utils/ExtendedAct.js b/workflow_tests/utils/ExtendedAct.js new file mode 100644 index 000000000000..a9d887e2ab82 --- /dev/null +++ b/workflow_tests/utils/ExtendedAct.js @@ -0,0 +1,15 @@ +const kieActJs = require('@kie/act-js'); + +class ExtendedAct extends kieActJs.Act { + async parseRunOpts(opts) { + const {cwd, actArguments, proxy} = await super.parseRunOpts(opts); + if (opts?.actor) { + actArguments.push('--actor', opts?.actor); + } + return {cwd, actArguments, proxy}; + } +} + +module.exports = { + ExtendedAct, +}; diff --git a/workflow_tests/utils.js b/workflow_tests/utils/utils.js similarity index 90% rename from workflow_tests/utils.js rename to workflow_tests/utils/utils.js index 850c6c03d2c4..c8186da06153 100644 --- a/workflow_tests/utils.js +++ b/workflow_tests/utils/utils.js @@ -1,16 +1,5 @@ const yaml = require('yaml'); const fs = require('fs'); -const kieActJs = require('@kie/act-js'); - -class ExtendedAct extends kieActJs.Act { - async parseRunOpts(opts) { - const {cwd, actArguments, proxy} = await super.parseRunOpts(opts); - if (opts?.actor) { - actArguments.push('--actor', opts?.actor); - } - return {cwd, actArguments, proxy}; - } -} const setUpActParams = (act, event = null, event_options = null, secrets = null, github_token = null, env_vars = null) => { let updated_act = act; @@ -127,5 +116,4 @@ module.exports = { getMockStep, getStepAssertion, setJobRunners, - ExtendedAct, }; From 714d13409fd2c8d1a7e2f470182711b986071033 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Wed, 8 Mar 2023 14:15:02 +0100 Subject: [PATCH 039/504] Pre-generate test Added a script to automatically pre-generate a test file, mocks file, and an assertions file for a given workflow to speed up tests development See: https://github.com/Expensify/App/issues/13604 --- workflow_tests/utils/preGenerateTest.js | 265 ++++++++++++++++++++++++ 1 file changed, 265 insertions(+) create mode 100644 workflow_tests/utils/preGenerateTest.js diff --git a/workflow_tests/utils/preGenerateTest.js b/workflow_tests/utils/preGenerateTest.js new file mode 100644 index 000000000000..03883870c7e7 --- /dev/null +++ b/workflow_tests/utils/preGenerateTest.js @@ -0,0 +1,265 @@ +const path = require('path'); +const {exit} = require("process"); +const fs = require('fs'); +const yaml = require('yaml'); + +const workflowsDirectory = path.resolve(__dirname, '..', '..', '.github', 'workflows'); +const workflowTestsDirectory = path.resolve(__dirname, '..'); +const workflowTestMocksDirectory = path.join(workflowTestsDirectory, 'mocks'); +const workflowTestAssertionsDirectory = path.join(workflowTestsDirectory, 'assertions'); +const workflowFilePattern = '\\w+\\.yml'; +const workflowFileRegex = new RegExp(workflowFilePattern, 'g'); + +const capitalize = s => (s && s.charAt(0).toUpperCase() + s.slice(1)) || ''; +const mockFileTemplate = (mockSteps, exports) => `const utils = require('../utils/utils'); + +${mockSteps} +${exports} +`; +const assertionFileTemplate = (jobAssertions, exports) => `const utils = require('../utils/utils'); +${jobAssertions} +${exports} +`; +const testFileTemplate = (workflowName) => `const path = require('path'); +const kieMockGithub = require('@kie/mock-github'); +const utils = require('./utils/utils'); +const assertions = require('./assertions/${workflowName}Assertions'); +const mocks = require('./mocks/${workflowName}Mocks'); +const eAct = require('./utils/ExtendedAct'); + +let mockGithub; +const FILES_TO_COPY_INTO_TEST_REPO = [ + { + src: path.resolve(__dirname, '..', '.github', 'actions'), + dest: '.github/actions', + }, + { + src: path.resolve(__dirname, '..', '.github', 'libs'), + dest: '.github/libs', + }, + { + src: path.resolve(__dirname, '..', '.github', 'scripts'), + dest: '.github/scripts', + }, + { + src: path.resolve(__dirname, '..', '.github', 'workflows', '${workflowName}.yml'), + dest: '.github/workflows/${workflowName}.yml', + }, +]; + +beforeEach(async () => { + // create a local repository and copy required files + mockGithub = new kieMockGithub.MockGithub({ + repo: { + test${capitalize(workflowName)}WorkflowRepo: { + files: FILES_TO_COPY_INTO_TEST_REPO, + + // if any branches besides main are need add: pushedBranches: ['staging', 'production'], + }, + }, + }); + + await mockGithub.setup(); +}); + +afterEach(async () => { + await mockGithub.teardown(); +}); + +describe('test workflow ${workflowName}', () => { + test('test stub', async () => { + const repoPath = mockGithub.repo.getPath('test${capitalize(workflowName)}WorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', '${workflowName}.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + act = utils.setUpActParams( + act, + + // set up params if needed + ); + const testMockSteps = { + // mock steps with imported mocks + }; + const result = await act + .runEvent('[EVENT]', { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor: 'Dummy Author', + }); + + // assert execution with imported assertions + }, 60000); +}); +`; +const mockStepTemplate = (stepMockName, step, jobId) => ` +const ${stepMockName} = utils.getMockStep( + '${step.name || ''}', + '${step.name || ''}', + ${jobId ? `'${jobId.toUpperCase()}'` : 'null'}, + ${step.inputs ? JSON.stringify(step.inputs).replaceAll('"', "'") : 'null'}, + ${step.envs ? JSON.stringify(step.envs).replaceAll('"', "'") : 'null'}, + // add outputs if needed +);`; +const stepAssertionTemplate = (step_name, job_id, step_message, inputs, envs) => ` + utils.getStepAssertion( + '${step_name}', + true, + null, + '${job_id}', + '${step_message}', + [${inputs.map((input) => `{key: '${input}', value: '[FILL_IN]'}`)}], + [${envs.map((env) => `{key: '${env}', value: '[FILL_IN]'}`)}], + ),`; +const jobMocksTemplate = (jobMocksName, stepMocks) => ` +const ${jobMocksName} = [${stepMocks.map((stepMock) => ` + ${stepMock}`)} +];`; +const jobAssertionTemplate = (jobAssertionName, stepAssertions) => ` +const ${jobAssertionName} = (workflowResult, didExecute = true) => { + const steps = [${stepAssertions} + ]; + + for (const expectedStep of steps) { + if (didExecute) { + expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); + } else { + expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); + } + } +};`; +const mocksExportsTemplate = (jobMocks) => ` +module.exports = { + ${jobMocks.map((jobMock) => `${jobMock},`)} +};`; +const assertionsExportsTemplate = (jobAssertions) => ` +module.exports = { + ${jobAssertions.map((jobAssertion) => `${jobAssertion},`)} +};`; + +const checkArguments = (args) => { + if (args.length === 0 || !args[0]) { + console.warn('Please provide workflow file name'); + exit(1); + } +}; +const checkWorkflowFileName = (fileName) => { + if (!workflowFileRegex.test(fileName)) { + console.warn(`Please provide a valid workflow file name ([workflow].yml) instead of ${fileName}`); + exit(1); + } +}; +const checkWorkflowFilePath = (filePath) => { + if (!fs.existsSync(filePath)) { + console.warn(`Provided workflow file does not exist: ${filePath}`); + exit(1); + } +}; +const checkIfTestFileDoesNotExist = (testsDirectory, testFileName) => { + if (fs.existsSync(path.join(testsDirectory, testFileName))) { + console.warn(`The test file ${testFileName} already exists, exiting`); + exit(1); + } +} +const checkIfMocksFileDoesNotExist = (mocksDirectory, mocksFileName) => { + if (fs.existsSync(path.join(mocksDirectory, mocksFileName))) { + console.warn(`The mocks file ${mocksFileName} already exists, exiting`); + exit(1); + } +} +const checkIfAssertionsFileDoesNotExist = (assertionsDirectory, assertionsFileName) => { + if (fs.existsSync(path.join(assertionsDirectory, assertionsFileName))) { + console.warn(`The assertions file ${assertionsFileName} already exists, exiting`); + exit(1); + } +} +const parseWorkflowFile = (workflow) => { + const workflowJobs = {}; + for (const [jobId, job] of Object.entries(workflow.jobs)) { + workflowJobs[jobId] = { + steps: [], + }; + for (const step of job.steps) { + const workflowStep = { + name: step.name || '', + inputs: Object.keys(step.with || {}) || [], + envs: Object.keys(step.env || {}) || [], + } + workflowJobs[jobId].steps.push(workflowStep); + } + } + return workflowJobs; +}; +const getMockFileContent = (workflowName, jobs) => { + let content = ''; + const jobMocks = []; + for (const [jobId, job] of Object.entries(jobs)) { + let mockStepsContent = `// ${jobId.toLowerCase()}`; + const stepMocks = []; + for (const step of job.steps) { + const stepMockName = `${workflowName.toUpperCase()}__${jobId.toUpperCase()}__${step.name.replaceAll(' ', '_').toUpperCase()}__STEP_MOCK`; + stepMocks.push(stepMockName); + mockStepsContent += mockStepTemplate(stepMockName, step, jobId); + } + const jobMocksName = `${workflowName.toUpperCase()}__${jobId.toUpperCase()}__STEP_MOCKS`; + jobMocks.push(jobMocksName); + mockStepsContent += jobMocksTemplate(jobMocksName, stepMocks); + content += mockStepsContent; + } + return mockFileTemplate(content, mocksExportsTemplate(jobMocks)); +}; +const getAssertionsFileContent = (workflowName, jobs) => { + let content = ''; + const jobAssertions = []; + for (const [jobId, job] of Object.entries(jobs)) { + let stepAssertionsContent = ''; + for (const step of job.steps) { + stepAssertionsContent += stepAssertionTemplate(step.name.replaceAll(' ', ''), jobId.toUpperCase(), step.name, step.inputs, step.envs); + } + const jobAssertionName = `assert${jobId}JobExecuted`; + jobAssertions.push(jobAssertionName); + content += jobAssertionTemplate(jobAssertionName, stepAssertionsContent); + } + return assertionFileTemplate(content, assertionsExportsTemplate(jobAssertions)); +}; +const getTestFileContent = (workflowName) => { + return testFileTemplate(workflowName); +}; + +const arguments = process.argv.slice(2); +checkArguments(arguments); + +const workflowFileName = arguments[0]; +checkWorkflowFileName(workflowFileName); + +const workflowName = workflowFileName.slice(0, -4); +const workflowFilePath = path.join(workflowsDirectory, workflowFileName); +checkWorkflowFilePath(workflowFilePath); + +const workflowTestFileName = `${workflowName}.test.js`; +checkIfTestFileDoesNotExist(workflowTestsDirectory, workflowTestFileName); + +const workflowTestMocksFileName = `${workflowName}Mocks.js`; +checkIfMocksFileDoesNotExist(workflowTestMocksDirectory, workflowTestMocksFileName); + +const workflowTestAssertionsFileName = `${workflowName}Assertions.js`; +checkIfAssertionsFileDoesNotExist(workflowTestAssertionsDirectory, workflowTestAssertionsFileName); + +const workflow = yaml.parse(fs.readFileSync(workflowFilePath, 'utf8')); +const workflowJobs = parseWorkflowFile(workflow); + +const mockFileContent = getMockFileContent(workflowName, workflowJobs); +const mockFilePath = path.join(workflowTestMocksDirectory, workflowTestMocksFileName); +console.log(`Creating mock file ${mockFilePath}`); +fs.writeFileSync(mockFilePath, mockFileContent); +console.log(`Mock file ${mockFilePath} created`); + +const assertionsFileContent = getAssertionsFileContent(workflowName, workflowJobs); +const assertionsFilePath = path.join(workflowTestAssertionsDirectory, workflowTestAssertionsFileName); +console.log(`Creating assertions file ${assertionsFilePath}`); +fs.writeFileSync(assertionsFilePath, assertionsFileContent); +console.log(`Assertions file ${assertionsFilePath} created`); + +const testFileContent = getTestFileContent(workflowName, workflowJobs); +const testFilePath = path.join(workflowTestsDirectory, workflowTestFileName); +console.log(`Creating test file ${testFilePath}`); +fs.writeFileSync(testFilePath, testFileContent); +console.log(`Test file ${testFilePath} created`); From c82ae94f1fb07cf47615e44ef6732c3d80f5f5f5 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Wed, 8 Mar 2023 14:18:20 +0100 Subject: [PATCH 040/504] Add script to package.json Added the new script to package.json under `workflow-test:generate` See: https://github.com/Expensify/App/issues/13604 --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 22db87aa8bac..17c1e4a2d6a6 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,8 @@ "analyze-packages": "ANALYZE_BUNDLE=true webpack --config config/webpack/webpack.common.js --env envFile=.env.production", "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" + "test:e2e": "node tests/e2e/testRunner.js --development", + "workflow-test:generate": "node workflow_tests/utils/preGenerateTest.js" }, "dependencies": { "@expensify/react-native-web": "0.18.15", From 6dfa60b5d3a761e18929358cf5670aebbb38fd7a Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Wed, 8 Mar 2023 14:20:22 +0100 Subject: [PATCH 041/504] Update readme Updated the workflow_tests readme with mention of the new script See: https://github.com/Expensify/App/issues/13604 --- workflow_tests/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/workflow_tests/README.md b/workflow_tests/README.md index 651adcbedfeb..a64edd0cfab7 100644 --- a/workflow_tests/README.md +++ b/workflow_tests/README.md @@ -17,6 +17,7 @@ Not all workflows can always be tested this way, for example: - Install `Act` with `brew install act` and follow the documentation on [first Act run](https://github.com/nektos/act#first-act-run) - Set the environment variable `ACT_BINARY` to the path to your `Act` executable (`which act` if you're not sure what the path is) - You should be ready to run the tests now with `npm test -- --config=workflow_tests/jest.config.js` +- You can pre-generate new mocks/assertions/test files for a given workflow by running `npm run workflow-test:generate ` ## File structure The testing framework file structure within the repository is as follows: From 1ebc0d1f01bfcd536d19b83aa42af7390fd69dba Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Wed, 8 Mar 2023 15:44:49 +0100 Subject: [PATCH 042/504] Fix imports Fixed imports after the refactor of utils See: https://github.com/Expensify/App/issues/13604 --- workflow_tests/platformDeploy.test.js | 7 ++--- workflow_tests/preDeploy.test.js | 39 ++++++++++++++------------- 2 files changed, 24 insertions(+), 22 deletions(-) diff --git a/workflow_tests/platformDeploy.test.js b/workflow_tests/platformDeploy.test.js index 165189b90131..f350758a2fca 100644 --- a/workflow_tests/platformDeploy.test.js +++ b/workflow_tests/platformDeploy.test.js @@ -3,6 +3,7 @@ const kieMockGithub = require('@kie/mock-github'); const utils = require('./utils/utils'); const assertions = require('./assertions/platformDeployAssertions'); const mocks = require('./mocks/platformDeployMocks'); +const eAct = require('./utils/ExtendedAct'); let mockGithub; const FILES_TO_COPY_INTO_TEST_REPO = [ @@ -48,7 +49,7 @@ describe('test workflow platformDeploy', () => { test('as team member - platform deploy executes on staging', async () => { const repoPath = mockGithub.repo.getPath('testPlatformDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'platformDeploy.yml'); - let act = new utils.ExtendedAct(repoPath, workflowPath); + let act = new eAct.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams( act, 'push', @@ -120,7 +121,7 @@ describe('test workflow platformDeploy', () => { test('as OSBotify - platform deploy executes on staging', async () => { const repoPath = mockGithub.repo.getPath('testPlatformDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'platformDeploy.yml'); - let act = new utils.ExtendedAct(repoPath, workflowPath); + let act = new eAct.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams( act, 'push', @@ -192,7 +193,7 @@ describe('test workflow platformDeploy', () => { test('as outsider - platform deploy does not execute', async () => { const repoPath = mockGithub.repo.getPath('testPlatformDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'platformDeploy.yml'); - let act = new utils.ExtendedAct(repoPath, workflowPath); + let act = new eAct.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams( act, 'push', diff --git a/workflow_tests/preDeploy.test.js b/workflow_tests/preDeploy.test.js index 2dfeee8abed9..2339b7390986 100644 --- a/workflow_tests/preDeploy.test.js +++ b/workflow_tests/preDeploy.test.js @@ -3,6 +3,7 @@ const kieMockGithub = require('@kie/mock-github'); const utils = require('./utils/utils'); const assertions = require('./assertions/preDeployAssertions'); const mocks = require('./mocks/preDeployMocks'); +const eAct = require('./utils/ExtendedAct'); let mockGithub; const FILES_TO_COPY_INTO_TEST_REPO = [ @@ -51,7 +52,7 @@ describe('test workflow preDeploy', () => { const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); // instantiate Act in the context of the test repo and given workflow file - let act = new utils.ExtendedAct(repoPath, workflowPath); + let act = new eAct.ExtendedAct(repoPath, workflowPath); // set run parameters act = utils.setUpActParams( @@ -102,7 +103,7 @@ describe('test workflow preDeploy', () => { // test('push to different branch - workflow does not execute', async () => { // const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; // const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); - // let act = new utils.ExtendedAct(repoPath, workflowPath); + // let act = new eAct.ExtendedAct(repoPath, workflowPath); // act = utils.setUpActParams( // act, // 'push', @@ -145,7 +146,7 @@ describe('test workflow preDeploy', () => { test('different event than push - workflow does not execute', async () => { const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); - let act = new utils.ExtendedAct(repoPath, workflowPath); + let act = new eAct.ExtendedAct(repoPath, workflowPath); const testMockSteps = { lint: mocks.LINT_JOB_MOCK_STEPS, test: mocks.TEST_JOB_MOCK_STEPS, @@ -214,7 +215,7 @@ describe('test workflow preDeploy', () => { test('lint job failed - workflow exits', async () => { const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); - let act = new utils.ExtendedAct(repoPath, workflowPath); + let act = new eAct.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams( act, 'push', @@ -293,7 +294,7 @@ describe('test workflow preDeploy', () => { test('test job failed - workflow exits', async () => { const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); - let act = new utils.ExtendedAct(repoPath, workflowPath); + let act = new eAct.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams( act, 'push', @@ -372,7 +373,7 @@ describe('test workflow preDeploy', () => { test('lint and test job succeed - workflow continues', async () => { const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); - let act = new utils.ExtendedAct(repoPath, workflowPath); + let act = new eAct.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams( act, 'push', @@ -415,7 +416,7 @@ describe('test workflow preDeploy', () => { test('actor is OSBotify - no comment left', async () => { const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); - let act = new utils.ExtendedAct(repoPath, workflowPath); + let act = new eAct.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams( act, 'push', @@ -454,7 +455,7 @@ describe('test workflow preDeploy', () => { test('actor is Expensify employee - no comment left', async () => { const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); - let act = new utils.ExtendedAct(repoPath, workflowPath); + let act = new eAct.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams( act, 'push', @@ -493,7 +494,7 @@ describe('test workflow preDeploy', () => { test('actor is not Expensify employee, its not their first PR - job triggers, but no comment left', async () => { const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); - let act = new utils.ExtendedAct(repoPath, workflowPath); + let act = new eAct.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams( act, 'push', @@ -532,7 +533,7 @@ describe('test workflow preDeploy', () => { test('actor is not Expensify employee, and its their first PR - job triggers and comment left', async () => { const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); - let act = new utils.ExtendedAct(repoPath, workflowPath); + let act = new eAct.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams( act, 'push', @@ -575,7 +576,7 @@ describe('test workflow preDeploy', () => { test('not automated PR - deploy skipped and comment left', async () => { const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); - let act = new utils.ExtendedAct(repoPath, workflowPath); + let act = new eAct.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams( act, 'push', @@ -615,7 +616,7 @@ describe('test workflow preDeploy', () => { test('automated PR - deploy skipped, but no comment left', async () => { const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); - let act = new utils.ExtendedAct(repoPath, workflowPath); + let act = new eAct.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams( act, 'push', @@ -657,7 +658,7 @@ describe('test workflow preDeploy', () => { test('not automated PR - proceed with deploy', async () => { const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); - let act = new utils.ExtendedAct(repoPath, workflowPath); + let act = new eAct.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams( act, 'push', @@ -701,7 +702,7 @@ describe('test workflow preDeploy', () => { test('automated PR - deploy skipped, but no comment left', async () => { const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); - let act = new utils.ExtendedAct(repoPath, workflowPath); + let act = new eAct.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams( act, 'push', @@ -748,7 +749,7 @@ describe('test workflow preDeploy', () => { test('not automated PR - proceed with deploy', async () => { const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); - let act = new utils.ExtendedAct(repoPath, workflowPath); + let act = new eAct.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams( act, 'push', @@ -792,7 +793,7 @@ describe('test workflow preDeploy', () => { test('automated PR - proceed with deploy', async () => { const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); - let act = new utils.ExtendedAct(repoPath, workflowPath); + let act = new eAct.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams( act, 'push', @@ -838,7 +839,7 @@ describe('test workflow preDeploy', () => { test('not automated PR - proceed with deploy', async () => { const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); - let act = new utils.ExtendedAct(repoPath, workflowPath); + let act = new eAct.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams( act, 'push', @@ -882,7 +883,7 @@ describe('test workflow preDeploy', () => { test('automated PR - proceed with deploy', async () => { const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); - let act = new utils.ExtendedAct(repoPath, workflowPath); + let act = new eAct.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams( act, 'push', @@ -928,7 +929,7 @@ describe('test workflow preDeploy', () => { test('one of updateStaging steps failed - failure announced in Slack', async () => { const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); - let act = new utils.ExtendedAct(repoPath, workflowPath); + let act = new eAct.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams( act, 'push', From cc59c3b26a14910506a4cbaef6089547eb442c39 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Wed, 15 Mar 2023 14:01:01 +0100 Subject: [PATCH 043/504] Update pre-generation script Removed replacing spaces in generated mock/assertion names See: https://github.com/Expensify/App/issues/13604 --- workflow_tests/utils/preGenerateTest.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/workflow_tests/utils/preGenerateTest.js b/workflow_tests/utils/preGenerateTest.js index 03883870c7e7..fb1680683e80 100644 --- a/workflow_tests/utils/preGenerateTest.js +++ b/workflow_tests/utils/preGenerateTest.js @@ -212,7 +212,7 @@ const getAssertionsFileContent = (workflowName, jobs) => { for (const [jobId, job] of Object.entries(jobs)) { let stepAssertionsContent = ''; for (const step of job.steps) { - stepAssertionsContent += stepAssertionTemplate(step.name.replaceAll(' ', ''), jobId.toUpperCase(), step.name, step.inputs, step.envs); + stepAssertionsContent += stepAssertionTemplate(step.name, jobId.toUpperCase(), step.name, step.inputs, step.envs); } const jobAssertionName = `assert${jobId}JobExecuted`; jobAssertions.push(jobAssertionName); From 61b89062682676181325f8e04b4d06984eabbc93 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Wed, 15 Mar 2023 14:02:40 +0100 Subject: [PATCH 044/504] Update setting event options Updated the way event data is set for `Act` instance, since `Act` seems to not be consistent in how it expects the data to be provided based on the type of event. This change seems to cover all possibilities. Plus renamed some variables to be compliant with JS convention See: https://github.com/Expensify/App/issues/13604 --- workflow_tests/utils/utils.js | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/workflow_tests/utils/utils.js b/workflow_tests/utils/utils.js index c8186da06153..31c7ac0bceb4 100644 --- a/workflow_tests/utils/utils.js +++ b/workflow_tests/utils/utils.js @@ -1,13 +1,18 @@ const yaml = require('yaml'); const fs = require('fs'); -const setUpActParams = (act, event = null, event_options = null, secrets = null, github_token = null, env_vars = null) => { +const setUpActParams = (act, event = null, eventOptions = null, secrets = null, githubToken = null, envVars = null) => { let updated_act = act; - if (event && event_options) { - updated_act = updated_act.setEvent({ - [event]: event_options, - }); + if (event && eventOptions) { + // according to `Act` docs event data should be under the key with the event name (`[event]: eventOptions`), but + // for some event types this does not work (like `issues`), but providing the data on the JSON top level does, + // hence `...eventOptions` - this seems to cover all options + const eventData = { + [event]: eventOptions, + ...eventOptions, + }; + updated_act = updated_act.setEvent(eventData); } if (secrets) { @@ -16,12 +21,12 @@ const setUpActParams = (act, event = null, event_options = null, secrets = null, } } - if (github_token) { - updated_act = updated_act.setGithubToken(github_token); + if (githubToken) { + updated_act = updated_act.setGithubToken(githubToken); } - if (env_vars) { - for (const [key, value] of Object.entries(env_vars)) { + if (envVars) { + for (const [key, value] of Object.entries(envVars)) { updated_act = updated_act.setEnv(key, value); } } From 5e7fe6a362b0f452f9a4ef8a85f62105cd62d118 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Wed, 15 Mar 2023 14:03:18 +0100 Subject: [PATCH 045/504] Add step names Added missing names to steps in the `lockDeploys.yml` workflow for test files pre-generation See: https://github.com/Expensify/App/issues/13604 --- .github/workflows/lockDeploys.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/lockDeploys.yml b/.github/workflows/lockDeploys.yml index 38764561ed59..03948f5cb3fc 100644 --- a/.github/workflows/lockDeploys.yml +++ b/.github/workflows/lockDeploys.yml @@ -10,7 +10,8 @@ jobs: runs-on: macos-12 steps: # Version: 2.3.4 - - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 + - name: Checkout + uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 with: ref: main fetch-depth: 0 @@ -29,7 +30,8 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.OS_BOTIFY_TOKEN }} - - if: ${{ failure() }} + - name: Announce failed workflow + if: ${{ failure() }} uses: Expensify/App/.github/actions/composite/announceFailedWorkflowInSlack@main with: SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} From 99369ec44edc764acbd77ca717696807f6956d2b Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Wed, 15 Mar 2023 14:03:49 +0100 Subject: [PATCH 046/504] Add tests Added tests, mocks, and assertions for `lockDeploys.yml` workflow See: https://github.com/Expensify/App/issues/13604 --- .../assertions/lockDeploysAssertions.js | 102 ++++ workflow_tests/lockDeploys.test.js | 489 ++++++++++++++++++ workflow_tests/mocks/lockDeploysMocks.js | 41 ++ 3 files changed, 632 insertions(+) create mode 100644 workflow_tests/assertions/lockDeploysAssertions.js create mode 100644 workflow_tests/lockDeploys.test.js create mode 100644 workflow_tests/mocks/lockDeploysMocks.js diff --git a/workflow_tests/assertions/lockDeploysAssertions.js b/workflow_tests/assertions/lockDeploysAssertions.js new file mode 100644 index 000000000000..9d6b83ab157a --- /dev/null +++ b/workflow_tests/assertions/lockDeploysAssertions.js @@ -0,0 +1,102 @@ +const utils = require('../utils/utils'); + +const assertlockStagingDeploysJobExecuted = (workflowResult, didExecute = true, isSuccessful = true) => { + const steps = [ + utils.getStepAssertion( + 'Checkout', + true, + null, + 'LOCKSTAGINGDEPLOYS', + 'Checking out', + [{key: 'ref', value: 'main'}, {key: 'fetch-depth', value: '0'}, {key: 'token', value: '***'}], + [], + ), + utils.getStepAssertion( + 'Wait for staging deploys to finish', + true, + null, + 'LOCKSTAGINGDEPLOYS', + 'Waiting for staging deploys to finish', + [{key: 'GITHUB_TOKEN', value: '***'}], + [], + ), + utils.getStepAssertion( + 'Comment in StagingDeployCash to give Applause the 🟢 to begin QA', + true, + null, + 'LOCKSTAGINGDEPLOYS', + 'Commenting in StagingDeployCash', + [], + [{key: 'GITHUB_TOKEN', value: '***'}], + ), + ]; + + for (const expectedStep of steps) { + if (didExecute) { + expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); + } else { + expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); + } + } + + const failProdSteps = [ + utils.getStepAssertion( + 'Announce failed workflow', + true, + null, + 'LOCKSTAGINGDEPLOYS', + 'Announcing failed workflow in Slack', + [{key: 'SLACK_WEBHOOK', value: '***'}], + [], + ), + ]; + + for (const expectedStep of failProdSteps) { + if (didExecute && !isSuccessful) { + expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); + } else { + expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); + } + } +}; + +const assertlockStagingDeploysJobFailedAfterFirstStep = (workflowResult) => { + const steps = [ + utils.getStepAssertion( + 'Checkout', + true, + null, + 'LOCKSTAGINGDEPLOYS', + 'Checking out', + [{key: 'ref', value: 'main'}, {key: 'fetch-depth', value: '0'}, {key: 'token', value: '***'}], + [], + ), + utils.getStepAssertion( + 'Wait for staging deploys to finish', + false, + null, + 'LOCKSTAGINGDEPLOYS', + 'Waiting for staging deploys to finish', + [{key: 'GITHUB_TOKEN', value: '***'}], + [], + ), + utils.getStepAssertion( + 'Announce failed workflow', + true, + null, + 'LOCKSTAGINGDEPLOYS', + 'Announcing failed workflow in Slack', + [{key: 'SLACK_WEBHOOK', value: '***'}], + [], + ), + ]; + + for (const expectedStep of steps) { + expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); + } +}; + +module.exports = { + assertlockStagingDeploysJobExecuted, + assertlockStagingDeploysJobFailedAfterFirstStep, +}; diff --git a/workflow_tests/lockDeploys.test.js b/workflow_tests/lockDeploys.test.js new file mode 100644 index 000000000000..853b6cd6bac4 --- /dev/null +++ b/workflow_tests/lockDeploys.test.js @@ -0,0 +1,489 @@ +const path = require('path'); +const kieMockGithub = require('@kie/mock-github'); +const utils = require('./utils/utils'); +const assertions = require('./assertions/lockDeploysAssertions'); +const mocks = require('./mocks/lockDeploysMocks'); +const eAct = require('./utils/ExtendedAct'); + +let mockGithub; +const FILES_TO_COPY_INTO_TEST_REPO = [ + { + src: path.resolve(__dirname, '..', '.github', 'actions'), + dest: '.github/actions', + }, + { + src: path.resolve(__dirname, '..', '.github', 'libs'), + dest: '.github/libs', + }, + { + src: path.resolve(__dirname, '..', '.github', 'scripts'), + dest: '.github/scripts', + }, + { + src: path.resolve(__dirname, '..', '.github', 'workflows', 'lockDeploys.yml'), + dest: '.github/workflows/lockDeploys.yml', + }, +]; + +beforeEach(async () => { + // create a local repository and copy required files + mockGithub = new kieMockGithub.MockGithub({ + repo: { + testLockDeploysWorkflowRepo: { + files: FILES_TO_COPY_INTO_TEST_REPO, + }, + }, + }); + + await mockGithub.setup(); +}); + +afterEach(async () => { + await mockGithub.teardown(); +}); + +describe('test workflow lockDeploys', () => { + describe('issue labeled', () => { + describe('label is LockCashDeploys', () => { + describe('issue has StagingDeployCash', () => { + describe('actor is not OSBotify', () => { + test('job triggered, comment left in StagingDeployCash', async () => { + const repoPath = mockGithub.repo.getPath('testLockDeploysWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'lockDeploys.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + act = utils.setUpActParams( + act, + 'issues', + { + action: 'labeled', + type: 'labeled', + label: { + name: '🔐 LockCashDeploys 🔐', + }, + issue: { + labels: [ + {name: 'StagingDeployCash'}, + ], + }, + }, + { + OS_BOTIFY_TOKEN: 'dummy_token', + SLACK_WEBHOOK: 'dummy_slack_webhook', + }, + ); + act = utils.setJobRunners( + act, + { + lockStagingDeploys: 'ubuntu-latest', + }, + workflowPath, + ); + const testMockSteps = { + lockStagingDeploys: mocks.LOCKDEPLOYS__LOCKSTAGINGDEPLOYS__STEP_MOCKS, + }; + const result = await act + .runEvent('issues', { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor: 'Dummy Author', + }); + + assertions.assertlockStagingDeploysJobExecuted(result); + }, 60000); + + test('one step fails, comment not left in StagingDeployCash, announced failure in Slack', async () => { + const repoPath = mockGithub.repo.getPath('testLockDeploysWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'lockDeploys.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + act = utils.setUpActParams( + act, + 'issues', + { + action: 'labeled', + type: 'labeled', + label: { + name: '🔐 LockCashDeploys 🔐', + }, + issue: { + labels: [ + {name: 'StagingDeployCash'}, + ], + }, + }, + { + OS_BOTIFY_TOKEN: 'dummy_token', + SLACK_WEBHOOK: 'dummy_slack_webhook', + }, + ); + act = utils.setJobRunners( + act, + { + lockStagingDeploys: 'ubuntu-latest', + }, + workflowPath, + ); + const testMockSteps = { + lockStagingDeploys: mocks.LOCKDEPLOYS__LOCKSTAGINGDEPLOYS__STEP_MOCKS, + }; + testMockSteps.lockStagingDeploys[1] = utils.getMockStep( + 'Wait for staging deploys to finish', + 'Waiting for staging deploys to finish', + 'LOCKSTAGINGDEPLOYS', + ['GITHUB_TOKEN'], + [], + null, + null, + false, + ); + const result = await act + .runEvent('issues', { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor: 'Dummy Author', + }); + + assertions.assertlockStagingDeploysJobFailedAfterFirstStep(result); + }, 60000); + }); + + describe('actor is OSBotify', () => { + test('job not triggered, comment not left in StagingDeployCash', async () => { + const repoPath = mockGithub.repo.getPath('testLockDeploysWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'lockDeploys.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + act = utils.setUpActParams( + act, + 'issues', + { + action: 'labeled', + type: 'labeled', + label: { + name: '🔐 LockCashDeploys 🔐', + }, + issue: { + labels: [ + {name: 'StagingDeployCash'}, + ], + }, + }, + { + OS_BOTIFY_TOKEN: 'dummy_token', + SLACK_WEBHOOK: 'dummy_slack_webhook', + }, + ); + act = utils.setJobRunners( + act, + { + lockStagingDeploys: 'ubuntu-latest', + }, + workflowPath, + ); + const testMockSteps = { + lockStagingDeploys: mocks.LOCKDEPLOYS__LOCKSTAGINGDEPLOYS__STEP_MOCKS, + }; + const result = await act + .runEvent('issues', { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor: 'OSBotify', + }); + + assertions.assertlockStagingDeploysJobExecuted(result, false); + }, 60000); + }); + }); + + describe('issue does not have StagingDeployCash', () => { + describe('actor is not OSBotify', () => { + test('job not triggered, comment not left in StagingDeployCash', async () => { + const repoPath = mockGithub.repo.getPath('testLockDeploysWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'lockDeploys.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + act = utils.setUpActParams( + act, + 'issues', + { + action: 'labeled', + type: 'labeled', + label: { + name: '🔐 LockCashDeploys 🔐', + }, + issue: { + labels: [ + {name: 'Some'}, + {name: 'Other'}, + {name: 'Labels'}, + ], + }, + }, + { + OS_BOTIFY_TOKEN: 'dummy_token', + SLACK_WEBHOOK: 'dummy_slack_webhook', + }, + ); + act = utils.setJobRunners( + act, + { + lockStagingDeploys: 'ubuntu-latest', + }, + workflowPath, + ); + const testMockSteps = { + lockStagingDeploys: mocks.LOCKDEPLOYS__LOCKSTAGINGDEPLOYS__STEP_MOCKS, + }; + const result = await act + .runEvent('issues', { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor: 'Dummy Author', + }); + + assertions.assertlockStagingDeploysJobExecuted(result, false); + }, 60000); + }); + + describe('actor is OSBotify', () => { + test('job not triggered, comment not left in StagingDeployCash', async () => { + const repoPath = mockGithub.repo.getPath('testLockDeploysWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'lockDeploys.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + act = utils.setUpActParams( + act, + 'issues', + { + action: 'labeled', + type: 'labeled', + label: { + name: '🔐 LockCashDeploys 🔐', + }, + issue: { + labels: [ + {name: 'Some'}, + {name: 'Other'}, + {name: 'Labels'}, + ], + }, + }, + { + OS_BOTIFY_TOKEN: 'dummy_token', + SLACK_WEBHOOK: 'dummy_slack_webhook', + }, + ); + act = utils.setJobRunners( + act, + { + lockStagingDeploys: 'ubuntu-latest', + }, + workflowPath, + ); + const testMockSteps = { + lockStagingDeploys: mocks.LOCKDEPLOYS__LOCKSTAGINGDEPLOYS__STEP_MOCKS, + }; + const result = await act + .runEvent('issues', { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor: 'OSBotify', + }); + + assertions.assertlockStagingDeploysJobExecuted(result, false); + }, 60000); + }); + }); + }); + + describe('label is not LockCashDeploys', () => { + describe('issue has StagingDeployCash', () => { + describe('actor is not OSBotify', () => { + test('job not triggered, comment not left in StagingDeployCash', async () => { + const repoPath = mockGithub.repo.getPath('testLockDeploysWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'lockDeploys.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + act = utils.setUpActParams( + act, + 'issues', + { + action: 'labeled', + type: 'labeled', + label: { + name: 'Some different label', + }, + issue: { + labels: [ + {name: 'StagingDeployCash'}, + ], + }, + }, + { + OS_BOTIFY_TOKEN: 'dummy_token', + SLACK_WEBHOOK: 'dummy_slack_webhook', + }, + ); + act = utils.setJobRunners( + act, + { + lockStagingDeploys: 'ubuntu-latest', + }, + workflowPath, + ); + const testMockSteps = { + lockStagingDeploys: mocks.LOCKDEPLOYS__LOCKSTAGINGDEPLOYS__STEP_MOCKS, + }; + const result = await act + .runEvent('issues', { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor: 'Dummy Author', + }); + + assertions.assertlockStagingDeploysJobExecuted(result, false); + }, 60000); + }); + + describe('actor is OSBotify', () => { + test('job not triggered, comment not left in StagingDeployCash', async () => { + const repoPath = mockGithub.repo.getPath('testLockDeploysWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'lockDeploys.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + act = utils.setUpActParams( + act, + 'issues', + { + action: 'labeled', + type: 'labeled', + label: { + name: 'Some different label', + }, + issue: { + labels: [ + {name: 'StagingDeployCash'}, + ], + }, + }, + { + OS_BOTIFY_TOKEN: 'dummy_token', + SLACK_WEBHOOK: 'dummy_slack_webhook', + }, + ); + act = utils.setJobRunners( + act, + { + lockStagingDeploys: 'ubuntu-latest', + }, + workflowPath, + ); + const testMockSteps = { + lockStagingDeploys: mocks.LOCKDEPLOYS__LOCKSTAGINGDEPLOYS__STEP_MOCKS, + }; + const result = await act + .runEvent('issues', { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor: 'OSBotify', + }); + + assertions.assertlockStagingDeploysJobExecuted(result, false); + }, 60000); + }); + }); + + describe('issue does not have StagingDeployCash', () => { + describe('actor is not OSBotify', () => { + test('job not triggered, comment not left in StagingDeployCash', async () => { + const repoPath = mockGithub.repo.getPath('testLockDeploysWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'lockDeploys.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + act = utils.setUpActParams( + act, + 'issues', + { + action: 'labeled', + type: 'labeled', + label: { + name: 'Some other label', + }, + issue: { + labels: [ + {name: 'Some'}, + {name: 'Other'}, + {name: 'Labels'}, + ], + }, + }, + { + OS_BOTIFY_TOKEN: 'dummy_token', + SLACK_WEBHOOK: 'dummy_slack_webhook', + }, + ); + act = utils.setJobRunners( + act, + { + lockStagingDeploys: 'ubuntu-latest', + }, + workflowPath, + ); + const testMockSteps = { + lockStagingDeploys: mocks.LOCKDEPLOYS__LOCKSTAGINGDEPLOYS__STEP_MOCKS, + }; + const result = await act + .runEvent('issues', { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor: 'Dummy Author', + }); + + assertions.assertlockStagingDeploysJobExecuted(result, false); + }, 60000); + }); + + describe('actor is OSBotify', () => { + test('job not triggered, comment not left in StagingDeployCash', async () => { + const repoPath = mockGithub.repo.getPath('testLockDeploysWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'lockDeploys.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + act = utils.setUpActParams( + act, + 'issues', + { + action: 'labeled', + type: 'labeled', + label: { + name: 'Some other label', + }, + issue: { + labels: [ + {name: 'Some'}, + {name: 'Other'}, + {name: 'Labels'}, + ], + }, + }, + { + OS_BOTIFY_TOKEN: 'dummy_token', + SLACK_WEBHOOK: 'dummy_slack_webhook', + }, + ); + act = utils.setJobRunners( + act, + { + lockStagingDeploys: 'ubuntu-latest', + }, + workflowPath, + ); + const testMockSteps = { + lockStagingDeploys: mocks.LOCKDEPLOYS__LOCKSTAGINGDEPLOYS__STEP_MOCKS, + }; + const result = await act + .runEvent('issues', { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor: 'OSBotify', + }); + + assertions.assertlockStagingDeploysJobExecuted(result, false); + }, 60000); + }); + }); + }); + }); +}); diff --git a/workflow_tests/mocks/lockDeploysMocks.js b/workflow_tests/mocks/lockDeploysMocks.js new file mode 100644 index 000000000000..629406695a8e --- /dev/null +++ b/workflow_tests/mocks/lockDeploysMocks.js @@ -0,0 +1,41 @@ +const utils = require('../utils/utils'); + +// lockstagingdeploys +const LOCKDEPLOYS__LOCKSTAGINGDEPLOYS__CHECKOUT__STEP_MOCK = utils.getMockStep( + 'Checkout', + 'Checking out', + 'LOCKSTAGINGDEPLOYS', + ['ref', 'fetch-depth', 'token'], + [], +); +const LOCKDEPLOYS__LOCKSTAGINGDEPLOYS__WAIT_FOR_STAGING_DEPLOYS_TO_FINISH__STEP_MOCK = utils.getMockStep( + 'Wait for staging deploys to finish', + 'Waiting for staging deploys to finish', + 'LOCKSTAGINGDEPLOYS', + ['GITHUB_TOKEN'], + [], +); +const LOCKDEPLOYS__LOCKSTAGINGDEPLOYS__COMMENT_IN_STAGINGDEPLOYCASH_TO_GIVE_APPLAUSE_THE_GREEN_LIGHT_TO_BEGIN_QA__STEP_MOCK = utils.getMockStep( + 'Comment in StagingDeployCash to give Applause the 🟢 to begin QA', + 'Commenting in StagingDeployCash', + 'LOCKSTAGINGDEPLOYS', + [], + ['GITHUB_TOKEN'], +); +const LOCKDEPLOYS__LOCKSTAGINGDEPLOYS__ANNOUNCE_FAILED_WORKFLOW__STEP_MOCK = utils.getMockStep( + 'Announce failed workflow', + 'Announcing failed workflow in Slack', + 'LOCKSTAGINGDEPLOYS', + ['SLACK_WEBHOOK'], + [], +); +const LOCKDEPLOYS__LOCKSTAGINGDEPLOYS__STEP_MOCKS = [ + LOCKDEPLOYS__LOCKSTAGINGDEPLOYS__CHECKOUT__STEP_MOCK, + LOCKDEPLOYS__LOCKSTAGINGDEPLOYS__WAIT_FOR_STAGING_DEPLOYS_TO_FINISH__STEP_MOCK, + LOCKDEPLOYS__LOCKSTAGINGDEPLOYS__COMMENT_IN_STAGINGDEPLOYCASH_TO_GIVE_APPLAUSE_THE_GREEN_LIGHT_TO_BEGIN_QA__STEP_MOCK, + LOCKDEPLOYS__LOCKSTAGINGDEPLOYS__ANNOUNCE_FAILED_WORKFLOW__STEP_MOCK, +]; + +module.exports = { + LOCKDEPLOYS__LOCKSTAGINGDEPLOYS__STEP_MOCKS, +}; From ff9f353f9fd9925f99ba21dac9609bc8557f7658 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Wed, 15 Mar 2023 15:05:58 +0100 Subject: [PATCH 047/504] Update `finishReleaseCycle.yml` Updated workflow file for pre-generation of test files See: https://github.com/Expensify/App/issues/13604 --- .github/workflows/finishReleaseCycle.yml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/finishReleaseCycle.yml b/.github/workflows/finishReleaseCycle.yml index 88187d7a4355..b0376d0837cd 100644 --- a/.github/workflows/finishReleaseCycle.yml +++ b/.github/workflows/finishReleaseCycle.yml @@ -67,10 +67,12 @@ jobs: createNewPatchVersion: needs: validate if: ${{ fromJSON(needs.validate.outputs.isValid) }} - uses: Expensify/App/.github/workflows/createNewVersion.yml@main secrets: inherit - with: - SEMVER_LEVEL: PATCH + steps: + - name: Create new version + uses: Expensify/App/.github/workflows/createNewVersion.yml@main + with: + SEMVER_LEVEL: PATCH # Deploy deferred PRs to staging and create a new StagingDeployCash for the next release cycle. createNewStagingDeployCash: @@ -97,7 +99,8 @@ jobs: GITHUB_TOKEN: ${{ secrets.OS_BOTIFY_TOKEN }} NPM_VERSION: ${{ needs.createNewPatchVersion.outputs.NEW_VERSION }} - - if: ${{ failure() }} + - name: Announce failed workflow in Slack + if: ${{ failure() }} uses: Expensify/App/.github/actions/composite/announceFailedWorkflowInSlack@main with: SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} From 88e4bc170e7e2d35e01a35d52cb90b51c583f5d9 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Wed, 15 Mar 2023 17:27:42 +0100 Subject: [PATCH 048/504] Add more tests Added tests for the `finishReleaseCycle.yml` workflow See: https://github.com/Expensify/App/issues/13604 --- .github/workflows/finishReleaseCycle.yml | 10 +- .../finishReleaseCycleAssertions.js | 217 ++++++++++++++ workflow_tests/finishReleaseCycle.test.js | 274 ++++++++++++++++++ .../mocks/finishReleaseCycleMocks.js | 147 ++++++++++ 4 files changed, 645 insertions(+), 3 deletions(-) create mode 100644 workflow_tests/assertions/finishReleaseCycleAssertions.js create mode 100644 workflow_tests/finishReleaseCycle.test.js create mode 100644 workflow_tests/mocks/finishReleaseCycleMocks.js diff --git a/.github/workflows/finishReleaseCycle.yml b/.github/workflows/finishReleaseCycle.yml index b0376d0837cd..570594334b0f 100644 --- a/.github/workflows/finishReleaseCycle.yml +++ b/.github/workflows/finishReleaseCycle.yml @@ -22,7 +22,7 @@ jobs: username: ${{ github.actor }} team: mobile-deployers - - name: Reopen and comment on issue + - name: Reopen and comment on issue (not a team member) if: ${{ !fromJSON(steps.validateActor.outputs.isTeamMember) }} uses: Expensify/App/.github/actions/javascript/reopenIssueWithComment@main with: @@ -40,7 +40,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.OS_BOTIFY_TOKEN }} ISSUE_NUMBER: ${{ github.event.issue.number }} - - name: Reopen and comment on issue + - name: Reopen and comment on issue (has blockers) if: ${{ fromJSON(steps.validateActor.outputs.isTeamMember) && fromJSON(steps.checkDeployBlockers.outputs.HAS_DEPLOY_BLOCKERS) }} uses: Expensify/App/.github/actions/javascript/reopenIssueWithComment@main with: @@ -65,14 +65,18 @@ jobs: # Create a new patch version to prep for next release cycle createNewPatchVersion: + runs-on: ubuntu-latest needs: validate if: ${{ fromJSON(needs.validate.outputs.isValid) }} - secrets: inherit + outputs: + NEW_VERSION: ${{ steps.createNewVersion.outputs.NEW_VERSION }} steps: - name: Create new version + id: createNewVersion uses: Expensify/App/.github/workflows/createNewVersion.yml@main with: SEMVER_LEVEL: PATCH + secrets: inherit # Deploy deferred PRs to staging and create a new StagingDeployCash for the next release cycle. createNewStagingDeployCash: diff --git a/workflow_tests/assertions/finishReleaseCycleAssertions.js b/workflow_tests/assertions/finishReleaseCycleAssertions.js new file mode 100644 index 000000000000..613366f9d262 --- /dev/null +++ b/workflow_tests/assertions/finishReleaseCycleAssertions.js @@ -0,0 +1,217 @@ +const utils = require('../utils/utils'); + +const assertValidateJobExecuted = (workflowResult, username = 'Dummy Author', issueNumber = '', didExecute = true, isTeamMember = true, hasBlockers = false) => { + const steps = [ + utils.getStepAssertion( + 'Validate actor is deployer', + true, + null, + 'VALIDATE', + 'Validating if actor is deployer', + [ + {key: 'GITHUB_TOKEN', value: '***'}, + {key: 'username', value: username}, + {key: 'team', value: 'mobile-deployers'}, + ], + [], + ), + ]; + if (isTeamMember) { + steps.push( + utils.getStepAssertion( + 'Check for any deploy blockers', + true, + null, + 'VALIDATE', + 'Checking for deploy blockers', + [ + {key: 'GITHUB_TOKEN', value: '***'}, + {key: 'ISSUE_NUMBER', value: issueNumber}, + ], + [], + ), + ); + } + + for (const expectedStep of steps) { + if (didExecute) { + expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); + } else { + expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); + } + } + + // eslint-disable-next-line rulesdir/no-negated-variables + const notTeamMemberSteps = [ + utils.getStepAssertion( + 'Reopen and comment on issue (not a team member)', + true, + null, + 'VALIDATE', + 'Reopening issue - not a team member', + [ + {key: 'GITHUB_TOKEN', value: '***'}, + {key: 'ISSUE_NUMBER', value: issueNumber}, + {key: 'COMMENT', value: 'Sorry, only members of @Expensify/Mobile-Deployers can close deploy checklists.\nReopening!'}, + ], + [], + ), + ]; + + for (const expectedStep of notTeamMemberSteps) { + if (didExecute && !isTeamMember) { + expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); + } else { + expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); + } + } + + const blockerSteps = [ + utils.getStepAssertion( + 'Reopen and comment on issue (has blockers)', + true, + null, + 'VALIDATE', + 'Reopening issue - blockers', + [ + {key: 'GITHUB_TOKEN', value: '***'}, + {key: 'ISSUE_NUMBER', value: issueNumber}, + ], + [], + ), + ]; + + for (const expectedStep of blockerSteps) { + if (didExecute && hasBlockers) { + expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); + } else { + expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); + } + } +}; + +const assertUpdateProductionJobExecuted = (workflowResult, didExecute = true) => { + const steps = [ + utils.getStepAssertion( + 'Update production branch', + true, + null, + 'UPDATEPRODUCTION', + 'Updating production branch', + [ + {key: 'TARGET_BRANCH', value: 'production'}, + {key: 'OS_BOTIFY_TOKEN', value: '***'}, + {key: 'GPG_PASSPHRASE', value: '***'}, + ], + [], + ), + ]; + + for (const expectedStep of steps) { + if (didExecute) { + expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); + } else { + expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); + } + } +}; + +const assertCreateNewPatchVersionJobExecuted = (workflowResult, didExecute = true) => { + const steps = [ + utils.getStepAssertion( + 'Create new version', + true, + null, + 'CREATENEWPATCHVERSION', + 'Creating new version', + [{key: 'SEMVER_LEVEL', value: 'PATCH'}], + [], + ), + ]; + + for (const expectedStep of steps) { + if (didExecute) { + expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); + } else { + expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); + } + } +}; + +const assertCreateNewStagingDeployCashJobExecuted = (workflowResult, newVersion = '', didExecute = true, isSuccessful = true) => { + const steps = [ + utils.getStepAssertion( + 'Update staging branch to trigger staging deploy', + true, + null, + 'CREATENEWSTAGINGDEPLOYCASH', + 'Updating staging branch', + [ + {key: 'TARGET_BRANCH', value: 'staging'}, + {key: 'OS_BOTIFY_TOKEN', value: '***'}, + {key: 'GPG_PASSPHRASE', value: '***'}, + ], + [], + ), + utils.getStepAssertion( + 'Tag version', + true, + null, + 'CREATENEWSTAGINGDEPLOYCASH', + 'Tagging version', + [], + [], + ), + utils.getStepAssertion( + 'Create new StagingDeployCash', + true, + null, + 'CREATENEWSTAGINGDEPLOYCASH', + 'Creating new StagingDeployCash', + [ + {key: 'GITHUB_TOKEN', value: '***'}, + {key: 'NPM_VERSION', value: newVersion}, + ], + [], + ), + ]; + + if (!isSuccessful) { + steps[2].status = 1; + } + + for (const expectedStep of steps) { + if (didExecute) { + expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); + } else { + expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); + } + } + + const failProdSteps = [ + utils.getStepAssertion( + 'Announce failed workflow in Slack', + true, + null, + 'CREATENEWSTAGINGDEPLOYCASH', + 'Announcing failed workflow', + [{key: 'SLACK_WEBHOOK', value: '***'}], + [], + ), + ]; + + for (const expectedStep of failProdSteps) { + if (didExecute && !isSuccessful) { + expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); + } else { + expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); + } + } +}; + +module.exports = { + assertValidateJobExecuted, + assertUpdateProductionJobExecuted, + assertCreateNewPatchVersionJobExecuted, + assertCreateNewStagingDeployCashJobExecuted, +}; diff --git a/workflow_tests/finishReleaseCycle.test.js b/workflow_tests/finishReleaseCycle.test.js new file mode 100644 index 000000000000..cb4263f3dd1a --- /dev/null +++ b/workflow_tests/finishReleaseCycle.test.js @@ -0,0 +1,274 @@ +const path = require('path'); +const kieMockGithub = require('@kie/mock-github'); +const utils = require('./utils/utils'); +const assertions = require('./assertions/finishReleaseCycleAssertions'); +const mocks = require('./mocks/finishReleaseCycleMocks'); +const eAct = require('./utils/ExtendedAct'); + +let mockGithub; +const FILES_TO_COPY_INTO_TEST_REPO = [ + { + src: path.resolve(__dirname, '..', '.github', 'actions'), + dest: '.github/actions', + }, + { + src: path.resolve(__dirname, '..', '.github', 'libs'), + dest: '.github/libs', + }, + { + src: path.resolve(__dirname, '..', '.github', 'scripts'), + dest: '.github/scripts', + }, + { + src: path.resolve(__dirname, '..', '.github', 'workflows', 'finishReleaseCycle.yml'), + dest: '.github/workflows/finishReleaseCycle.yml', + }, +]; + +beforeEach(async () => { + // create a local repository and copy required files + mockGithub = new kieMockGithub.MockGithub({ + repo: { + testFinishReleaseCycleWorkflowRepo: { + files: FILES_TO_COPY_INTO_TEST_REPO, + }, + }, + }); + + await mockGithub.setup(); +}); + +afterEach(async () => { + await mockGithub.teardown(); +}); + +describe('test workflow finishReleaseCycle', () => { + describe('issue closed', () => { + describe('issue has StagingDeployCash', () => { + describe('actor is a team member', () => { + describe('no deploy blockers', () => { + test('production updated, new version created, new StagingDeployCash created', async () => { + const repoPath = mockGithub.repo.getPath('testFinishReleaseCycleWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'finishReleaseCycle.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + act = utils.setUpActParams( + act, + 'issues', + { + action: 'closed', + type: 'closed', + issue: { + labels: [ + {name: 'StagingDeployCash'}, + ], + number: '1234', + }, + }, + { + OS_BOTIFY_TOKEN: 'dummy_token', + LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', + SLACK_WEBHOOK: 'dummy_slack_webhook', + }, + ); + const testMockSteps = { + validate: mocks.FINISHRELEASECYCLE__VALIDATE__TEAM_MEMBER_NO_BLOCKERS__STEP_MOCKS, + updateProduction: mocks.FINISHRELEASECYCLE__UPDATEPRODUCTION__STEP_MOCKS, + createNewPatchVersion: mocks.FINISHRELEASECYCLE__CREATENEWPATCHVERSION__STEP_MOCKS, + createNewStagingDeployCash: mocks.FINISHRELEASECYCLE__CREATENEWSTAGINGDEPLOYCASH__STEP_MOCKS, + }; + const result = await act + .runEvent('issues', { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor: 'Dummy Author', + }); + assertions.assertValidateJobExecuted(result, 'Dummy Author', '1234'); + assertions.assertUpdateProductionJobExecuted(result); + assertions.assertCreateNewPatchVersionJobExecuted(result); + assertions.assertCreateNewStagingDeployCashJobExecuted(result, '1.2.3'); + }, 60000); + describe('createNewStagingDeployCash fails', () => { + test('failure announced on Slack', async () => { + const repoPath = mockGithub.repo.getPath('testFinishReleaseCycleWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'finishReleaseCycle.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + act = utils.setUpActParams( + act, + 'issues', + { + action: 'closed', + type: 'closed', + issue: { + labels: [ + {name: 'StagingDeployCash'}, + ], + number: '1234', + }, + }, + { + OS_BOTIFY_TOKEN: 'dummy_token', + LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', + SLACK_WEBHOOK: 'dummy_slack_webhook', + }, + ); + const testMockSteps = { + validate: mocks.FINISHRELEASECYCLE__VALIDATE__TEAM_MEMBER_NO_BLOCKERS__STEP_MOCKS, + updateProduction: mocks.FINISHRELEASECYCLE__UPDATEPRODUCTION__STEP_MOCKS, + createNewPatchVersion: mocks.FINISHRELEASECYCLE__CREATENEWPATCHVERSION__STEP_MOCKS, + createNewStagingDeployCash: mocks.FINISHRELEASECYCLE__CREATENEWSTAGINGDEPLOYCASH__STEP_MOCKS, + }; + testMockSteps.createNewStagingDeployCash[2] = utils.getMockStep( + 'Create new StagingDeployCash', + 'Creating new StagingDeployCash', + 'CREATENEWSTAGINGDEPLOYCASH', + ['GITHUB_TOKEN', 'NPM_VERSION'], + [], + null, + null, + false, + ); + const result = await act + .runEvent('issues', { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor: 'Dummy Author', + }); + assertions.assertValidateJobExecuted(result, 'Dummy Author', '1234'); + assertions.assertUpdateProductionJobExecuted(result); + assertions.assertCreateNewPatchVersionJobExecuted(result); + assertions.assertCreateNewStagingDeployCashJobExecuted(result, '1.2.3', true, false); + }, 60000); + }); + }); + describe('deploy blockers', () => { + test('production not updated, new version not created, new StagingDeployCash not created, issue reopened', async () => { + const repoPath = mockGithub.repo.getPath('testFinishReleaseCycleWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'finishReleaseCycle.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + act = utils.setUpActParams( + act, + 'issues', + { + action: 'closed', + type: 'closed', + issue: { + labels: [ + {name: 'StagingDeployCash'}, + ], + number: '1234', + }, + }, + { + OS_BOTIFY_TOKEN: 'dummy_token', + LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', + SLACK_WEBHOOK: 'dummy_slack_webhook', + }, + ); + const testMockSteps = { + validate: mocks.FINISHRELEASECYCLE__VALIDATE__TEAM_MEMBER_BLOCKERS__STEP_MOCKS, + updateProduction: mocks.FINISHRELEASECYCLE__UPDATEPRODUCTION__STEP_MOCKS, + createNewPatchVersion: mocks.FINISHRELEASECYCLE__CREATENEWPATCHVERSION__STEP_MOCKS, + createNewStagingDeployCash: mocks.FINISHRELEASECYCLE__CREATENEWSTAGINGDEPLOYCASH__STEP_MOCKS, + }; + const result = await act + .runEvent('issues', { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor: 'Dummy Author', + }); + assertions.assertValidateJobExecuted(result, 'Dummy Author', '1234', true, true, true); + assertions.assertUpdateProductionJobExecuted(result, false); + assertions.assertCreateNewPatchVersionJobExecuted(result, false); + assertions.assertCreateNewStagingDeployCashJobExecuted(result, '1.2.3', false); + }, 60000); + }); + }); + describe('actor is not a team member', () => { + test('production not updated, new version not created, new StagingDeployCash not created, issue reopened', async () => { + const repoPath = mockGithub.repo.getPath('testFinishReleaseCycleWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'finishReleaseCycle.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + act = utils.setUpActParams( + act, + 'issues', + { + action: 'closed', + type: 'closed', + issue: { + labels: [ + {name: 'StagingDeployCash'}, + ], + number: '1234', + }, + }, + { + OS_BOTIFY_TOKEN: 'dummy_token', + LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', + SLACK_WEBHOOK: 'dummy_slack_webhook', + }, + ); + const testMockSteps = { + validate: mocks.FINISHRELEASECYCLE__VALIDATE__NOT_TEAM_MEMBER_NO_BLOCKERS__STEP_MOCKS, + updateProduction: mocks.FINISHRELEASECYCLE__UPDATEPRODUCTION__STEP_MOCKS, + createNewPatchVersion: mocks.FINISHRELEASECYCLE__CREATENEWPATCHVERSION__STEP_MOCKS, + createNewStagingDeployCash: mocks.FINISHRELEASECYCLE__CREATENEWSTAGINGDEPLOYCASH__STEP_MOCKS, + }; + const result = await act + .runEvent('issues', { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor: 'Dummy Author', + }); + assertions.assertValidateJobExecuted(result, 'Dummy Author', '1234', true, false, false); + assertions.assertUpdateProductionJobExecuted(result, false); + assertions.assertCreateNewPatchVersionJobExecuted(result, false); + assertions.assertCreateNewStagingDeployCashJobExecuted(result, '1.2.3', false); + }, 60000); + }); + }); + describe('issue does not have StagingDeployCash', () => { + test('validate job not run', async () => { + const repoPath = mockGithub.repo.getPath('testFinishReleaseCycleWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'finishReleaseCycle.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + act = utils.setUpActParams( + act, + 'issues', + { + action: 'closed', + type: 'closed', + issue: { + labels: [ + {name: 'Some'}, + {name: 'Other'}, + {name: 'Labels'}, + ], + number: '1234', + }, + }, + { + OS_BOTIFY_TOKEN: 'dummy_token', + LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', + SLACK_WEBHOOK: 'dummy_slack_webhook', + }, + ); + const testMockSteps = { + validate: mocks.FINISHRELEASECYCLE__VALIDATE__TEAM_MEMBER_NO_BLOCKERS__STEP_MOCKS, + updateProduction: mocks.FINISHRELEASECYCLE__UPDATEPRODUCTION__STEP_MOCKS, + createNewPatchVersion: mocks.FINISHRELEASECYCLE__CREATENEWPATCHVERSION__STEP_MOCKS, + createNewStagingDeployCash: mocks.FINISHRELEASECYCLE__CREATENEWSTAGINGDEPLOYCASH__STEP_MOCKS, + }; + const result = await act + .runEvent('issues', { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor: 'Dummy Author', + }); + assertions.assertValidateJobExecuted(result, 'Dummy Author', '1234', false); + assertions.assertUpdateProductionJobExecuted(result, false); + assertions.assertCreateNewPatchVersionJobExecuted(result, false); + assertions.assertCreateNewStagingDeployCashJobExecuted(result, '1.2.3', false); + }, 60000); + }); + }); +}); diff --git a/workflow_tests/mocks/finishReleaseCycleMocks.js b/workflow_tests/mocks/finishReleaseCycleMocks.js new file mode 100644 index 000000000000..b14f92a7413f --- /dev/null +++ b/workflow_tests/mocks/finishReleaseCycleMocks.js @@ -0,0 +1,147 @@ +const utils = require('../utils/utils'); + +// validate +const FINISHRELEASECYCLE__VALIDATE__VALIDATE_ACTOR_IS_DEPLOYER_TRUE__STEP_MOCK = utils.getMockStep( + 'Validate actor is deployer', + 'Validating if actor is deployer', + 'VALIDATE', + ['GITHUB_TOKEN', 'username', 'team'], + [], + {isTeamMember: true}, +); +const FINISHRELEASECYCLE__VALIDATE__VALIDATE_ACTOR_IS_DEPLOYER_FALSE__STEP_MOCK = utils.getMockStep( + 'Validate actor is deployer', + 'Validating if actor is deployer', + 'VALIDATE', + ['GITHUB_TOKEN', 'username', 'team'], + [], + {isTeamMember: false}, +); +// eslint-disable-next-line rulesdir/no-negated-variables +const FINISHRELEASECYCLE__VALIDATE__REOPEN_AND_COMMENT_ON_ISSUE_NOT_A_TEAM_MEMBER__STEP_MOCK = utils.getMockStep( + 'Reopen and comment on issue (not a team member)', + 'Reopening issue - not a team member', + 'VALIDATE', + ['GITHUB_TOKEN', 'ISSUE_NUMBER', 'COMMENT'], + [], +); +const FINISHRELEASECYCLE__VALIDATE__CHECK_FOR_ANY_DEPLOY_BLOCKERS_FALSE__STEP_MOCK = utils.getMockStep( + 'Check for any deploy blockers', + 'Checking for deploy blockers', + 'VALIDATE', + ['GITHUB_TOKEN', 'ISSUE_NUMBER'], + [], + {HAS_DEPLOY_BLOCKERS: false}, +); +const FINISHRELEASECYCLE__VALIDATE__CHECK_FOR_ANY_DEPLOY_BLOCKERS_TRUE__STEP_MOCK = utils.getMockStep( + 'Check for any deploy blockers', + 'Checking for deploy blockers', + 'VALIDATE', + ['GITHUB_TOKEN', 'ISSUE_NUMBER'], + [], + {HAS_DEPLOY_BLOCKERS: true}, +); +const FINISHRELEASECYCLE__VALIDATE__REOPEN_AND_COMMENT_ON_ISSUE_HAS_BLOCKERS__STEP_MOCK = utils.getMockStep( + 'Reopen and comment on issue (has blockers)', + 'Reopening issue - blockers', + 'VALIDATE', + ['GITHUB_TOKEN', 'ISSUE_NUMBER'], + [], +); +const FINISHRELEASECYCLE__VALIDATE__TEAM_MEMBER_NO_BLOCKERS__STEP_MOCKS = [ + FINISHRELEASECYCLE__VALIDATE__VALIDATE_ACTOR_IS_DEPLOYER_TRUE__STEP_MOCK, + FINISHRELEASECYCLE__VALIDATE__REOPEN_AND_COMMENT_ON_ISSUE_NOT_A_TEAM_MEMBER__STEP_MOCK, + FINISHRELEASECYCLE__VALIDATE__CHECK_FOR_ANY_DEPLOY_BLOCKERS_FALSE__STEP_MOCK, + FINISHRELEASECYCLE__VALIDATE__REOPEN_AND_COMMENT_ON_ISSUE_HAS_BLOCKERS__STEP_MOCK, +]; +const FINISHRELEASECYCLE__VALIDATE__TEAM_MEMBER_BLOCKERS__STEP_MOCKS = [ + FINISHRELEASECYCLE__VALIDATE__VALIDATE_ACTOR_IS_DEPLOYER_TRUE__STEP_MOCK, + FINISHRELEASECYCLE__VALIDATE__REOPEN_AND_COMMENT_ON_ISSUE_NOT_A_TEAM_MEMBER__STEP_MOCK, + FINISHRELEASECYCLE__VALIDATE__CHECK_FOR_ANY_DEPLOY_BLOCKERS_TRUE__STEP_MOCK, + FINISHRELEASECYCLE__VALIDATE__REOPEN_AND_COMMENT_ON_ISSUE_HAS_BLOCKERS__STEP_MOCK, +]; +// eslint-disable-next-line rulesdir/no-negated-variables +const FINISHRELEASECYCLE__VALIDATE__NOT_TEAM_MEMBER_NO_BLOCKERS__STEP_MOCKS = [ + FINISHRELEASECYCLE__VALIDATE__VALIDATE_ACTOR_IS_DEPLOYER_FALSE__STEP_MOCK, + FINISHRELEASECYCLE__VALIDATE__REOPEN_AND_COMMENT_ON_ISSUE_NOT_A_TEAM_MEMBER__STEP_MOCK, + FINISHRELEASECYCLE__VALIDATE__CHECK_FOR_ANY_DEPLOY_BLOCKERS_FALSE__STEP_MOCK, + FINISHRELEASECYCLE__VALIDATE__REOPEN_AND_COMMENT_ON_ISSUE_HAS_BLOCKERS__STEP_MOCK, +]; +// eslint-disable-next-line rulesdir/no-negated-variables +const FINISHRELEASECYCLE__VALIDATE__NOT_TEAM_MEMBER_BLOCKERS__STEP_MOCKS = [ + FINISHRELEASECYCLE__VALIDATE__VALIDATE_ACTOR_IS_DEPLOYER_FALSE__STEP_MOCK, + FINISHRELEASECYCLE__VALIDATE__REOPEN_AND_COMMENT_ON_ISSUE_NOT_A_TEAM_MEMBER__STEP_MOCK, + FINISHRELEASECYCLE__VALIDATE__CHECK_FOR_ANY_DEPLOY_BLOCKERS_TRUE__STEP_MOCK, + FINISHRELEASECYCLE__VALIDATE__REOPEN_AND_COMMENT_ON_ISSUE_HAS_BLOCKERS__STEP_MOCK, +]; + +// updateproduction +const FINISHRELEASECYCLE__UPDATEPRODUCTION__UPDATE_PRODUCTION_BRANCH__STEP_MOCK = utils.getMockStep( + 'Update production branch', + 'Updating production branch', + 'UPDATEPRODUCTION', + ['TARGET_BRANCH', 'OS_BOTIFY_TOKEN', 'GPG_PASSPHRASE'], + [], +); +const FINISHRELEASECYCLE__UPDATEPRODUCTION__STEP_MOCKS = [ + FINISHRELEASECYCLE__UPDATEPRODUCTION__UPDATE_PRODUCTION_BRANCH__STEP_MOCK, +]; + +// createnewpatchversion +const FINISHRELEASECYCLE__CREATENEWPATCHVERSION__CREATE_NEW_VERSION__STEP_MOCK = utils.getMockStep( + 'Create new version', + 'Creating new version', + 'CREATENEWPATCHVERSION', + ['SEMVER_LEVEL'], + [], + {NEW_VERSION: '1.2.3'}, +); +const FINISHRELEASECYCLE__CREATENEWPATCHVERSION__STEP_MOCKS = [ + FINISHRELEASECYCLE__CREATENEWPATCHVERSION__CREATE_NEW_VERSION__STEP_MOCK, +]; + +// createnewstagingdeploycash +const FINISHRELEASECYCLE__CREATENEWSTAGINGDEPLOYCASH__UPDATE_STAGING_BRANCH_TO_TRIGGER_STAGING_DEPLOY__STEP_MOCK = utils.getMockStep( + 'Update staging branch to trigger staging deploy', + 'Updating staging branch', + 'CREATENEWSTAGINGDEPLOYCASH', + ['TARGET_BRANCH', 'OS_BOTIFY_TOKEN', 'GPG_PASSPHRASE'], + [], +); +const FINISHRELEASECYCLE__CREATENEWSTAGINGDEPLOYCASH__TAG_VERSION__STEP_MOCK = utils.getMockStep( + 'Tag version', + 'Tagging version', + 'CREATENEWSTAGINGDEPLOYCASH', + [], + [], +); +const FINISHRELEASECYCLE__CREATENEWSTAGINGDEPLOYCASH__CREATE_NEW_STAGINGDEPLOYCASH__STEP_MOCK = utils.getMockStep( + 'Create new StagingDeployCash', + 'Creating new StagingDeployCash', + 'CREATENEWSTAGINGDEPLOYCASH', + ['GITHUB_TOKEN', 'NPM_VERSION'], + [], +); +const FINISHRELEASECYCLE__CREATENEWSTAGINGDEPLOYCASH__ANNOUNCE_FAILED_WORKFLOW_IN_SLACK__STEP_MOCK = utils.getMockStep( + 'Announce failed workflow in Slack', + 'Announcing failed workflow', + 'CREATENEWSTAGINGDEPLOYCASH', + ['SLACK_WEBHOOK'], + [], +); +const FINISHRELEASECYCLE__CREATENEWSTAGINGDEPLOYCASH__STEP_MOCKS = [ + FINISHRELEASECYCLE__CREATENEWSTAGINGDEPLOYCASH__UPDATE_STAGING_BRANCH_TO_TRIGGER_STAGING_DEPLOY__STEP_MOCK, + FINISHRELEASECYCLE__CREATENEWSTAGINGDEPLOYCASH__TAG_VERSION__STEP_MOCK, + FINISHRELEASECYCLE__CREATENEWSTAGINGDEPLOYCASH__CREATE_NEW_STAGINGDEPLOYCASH__STEP_MOCK, + FINISHRELEASECYCLE__CREATENEWSTAGINGDEPLOYCASH__ANNOUNCE_FAILED_WORKFLOW_IN_SLACK__STEP_MOCK, +]; + +module.exports = { + FINISHRELEASECYCLE__VALIDATE__TEAM_MEMBER_NO_BLOCKERS__STEP_MOCKS, + FINISHRELEASECYCLE__VALIDATE__TEAM_MEMBER_BLOCKERS__STEP_MOCKS, + FINISHRELEASECYCLE__VALIDATE__NOT_TEAM_MEMBER_NO_BLOCKERS__STEP_MOCKS, + FINISHRELEASECYCLE__VALIDATE__NOT_TEAM_MEMBER_BLOCKERS__STEP_MOCKS, + FINISHRELEASECYCLE__UPDATEPRODUCTION__STEP_MOCKS, + FINISHRELEASECYCLE__CREATENEWPATCHVERSION__STEP_MOCKS, + FINISHRELEASECYCLE__CREATENEWSTAGINGDEPLOYCASH__STEP_MOCKS, +}; From 2659fecb8ada43672d36a134791887df94c144f1 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Wed, 15 Mar 2023 17:32:15 +0100 Subject: [PATCH 049/504] Add npm script Added the `workflow-test` script to `package.json` to simplify triggering the workflow tests See: https://github.com/Expensify/App/issues/13604 --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 17c1e4a2d6a6..76f69f0abee2 100644 --- a/package.json +++ b/package.json @@ -44,6 +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 -t \"test workflow\"", "workflow-test:generate": "node workflow_tests/utils/preGenerateTest.js" }, "dependencies": { From 387f2c63fc201379e322562897816418382af8d1 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Thu, 16 Mar 2023 11:31:19 +0100 Subject: [PATCH 050/504] Add tests Added tests for `authorChecklist` workflow See: https://github.com/Expensify/App/issues/13604 --- .../assertions/authorChecklistAssertions.js | 27 +++ workflow_tests/authorChecklist.test.js | 214 ++++++++++++++++++ workflow_tests/mocks/authorChecklistMocks.js | 17 ++ 3 files changed, 258 insertions(+) create mode 100644 workflow_tests/assertions/authorChecklistAssertions.js create mode 100644 workflow_tests/authorChecklist.test.js create mode 100644 workflow_tests/mocks/authorChecklistMocks.js diff --git a/workflow_tests/assertions/authorChecklistAssertions.js b/workflow_tests/assertions/authorChecklistAssertions.js new file mode 100644 index 000000000000..a1ca5840426b --- /dev/null +++ b/workflow_tests/assertions/authorChecklistAssertions.js @@ -0,0 +1,27 @@ +const utils = require('../utils/utils'); + +const assertChecklistJobExecuted = (workflowResult, didExecute = true) => { + const steps = [ + utils.getStepAssertion( + 'authorChecklist.js', + true, + null, + 'CHECKLIST', + 'Running authorChecklist.js', + [{key: 'GITHUB_TOKEN', value: '***'}], + [], + ), + ]; + + for (const expectedStep of steps) { + if (didExecute) { + expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); + } else { + expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); + } + } +}; + +module.exports = { + assertChecklistJobExecuted, +}; diff --git a/workflow_tests/authorChecklist.test.js b/workflow_tests/authorChecklist.test.js new file mode 100644 index 000000000000..6beb778cea4b --- /dev/null +++ b/workflow_tests/authorChecklist.test.js @@ -0,0 +1,214 @@ +const path = require('path'); +const kieMockGithub = require('@kie/mock-github'); +const utils = require('./utils/utils'); +const assertions = require('./assertions/authorChecklistAssertions'); +const mocks = require('./mocks/authorChecklistMocks'); +const eAct = require('./utils/ExtendedAct'); + +let mockGithub; +const FILES_TO_COPY_INTO_TEST_REPO = [ + { + src: path.resolve(__dirname, '..', '.github', 'actions'), + dest: '.github/actions', + }, + { + src: path.resolve(__dirname, '..', '.github', 'libs'), + dest: '.github/libs', + }, + { + src: path.resolve(__dirname, '..', '.github', 'scripts'), + dest: '.github/scripts', + }, + { + src: path.resolve(__dirname, '..', '.github', 'workflows', 'authorChecklist.yml'), + dest: '.github/workflows/authorChecklist.yml', + }, +]; + +beforeEach(async () => { + // create a local repository and copy required files + mockGithub = new kieMockGithub.MockGithub({ + repo: { + testAuthorChecklistWorkflowRepo: { + files: FILES_TO_COPY_INTO_TEST_REPO, + }, + }, + }); + + await mockGithub.setup(); +}); + +afterEach(async () => { + await mockGithub.teardown(); +}); + +describe('test workflow authorChecklist', () => { + describe('pull request opened', () => { + describe('actor is not OSBotify', () => { + test('workflow executes', async () => { + const repoPath = mockGithub.repo.getPath('testAuthorChecklistWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'authorChecklist.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + act = utils.setUpActParams( + act, + 'pull_request', + { + action: 'opened', + }, + {}, + 'dummy_github_token', + ); + const testMockSteps = { + checklist: mocks.AUTHORCHECKLIST__CHECKLIST__STEP_MOCKS, + }; + const result = await act + .runEvent('pull_request', { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor: 'Dummy Author', + }); + + assertions.assertChecklistJobExecuted(result); + }, 60000); + }); + describe('actor is OSBotify', () => { + test('workflow does not execute', async () => { + const repoPath = mockGithub.repo.getPath('testAuthorChecklistWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'authorChecklist.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + act = utils.setUpActParams( + act, + 'pull_request', + { + action: 'opened', + }, + {}, + 'dummy_github_token', + ); + const testMockSteps = { + checklist: mocks.AUTHORCHECKLIST__CHECKLIST__STEP_MOCKS, + }; + const result = await act + .runEvent('pull_request', { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor: 'OSBotify', + }); + + assertions.assertChecklistJobExecuted(result, false); + }, 60000); + }); + }); + describe('pull request edited', () => { + describe('actor is not OSBotify', () => { + test('workflow executes', async () => { + const repoPath = mockGithub.repo.getPath('testAuthorChecklistWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'authorChecklist.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + act = utils.setUpActParams( + act, + 'pull_request', + { + action: 'edited', + }, + {}, + 'dummy_github_token', + ); + const testMockSteps = { + checklist: mocks.AUTHORCHECKLIST__CHECKLIST__STEP_MOCKS, + }; + const result = await act + .runEvent('pull_request', { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor: 'Dummy Author', + }); + + assertions.assertChecklistJobExecuted(result); + }, 60000); + }); + describe('actor is OSBotify', () => { + test('workflow does not execute', async () => { + const repoPath = mockGithub.repo.getPath('testAuthorChecklistWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'authorChecklist.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + act = utils.setUpActParams( + act, + 'pull_request', + { + action: 'edited', + }, + {}, + 'dummy_github_token', + ); + const testMockSteps = { + checklist: mocks.AUTHORCHECKLIST__CHECKLIST__STEP_MOCKS, + }; + const result = await act + .runEvent('pull_request', { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor: 'OSBotify', + }); + + assertions.assertChecklistJobExecuted(result, false); + }, 60000); + }); + }); + describe('pull request reopened', () => { + describe('actor is not OSBotify', () => { + test('workflow executes', async () => { + const repoPath = mockGithub.repo.getPath('testAuthorChecklistWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'authorChecklist.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + act = utils.setUpActParams( + act, + 'pull_request', + { + action: 'reopened', + }, + {}, + 'dummy_github_token', + ); + const testMockSteps = { + checklist: mocks.AUTHORCHECKLIST__CHECKLIST__STEP_MOCKS, + }; + const result = await act + .runEvent('pull_request', { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor: 'Dummy Author', + }); + + assertions.assertChecklistJobExecuted(result); + }, 60000); + }); + describe('actor is OSBotify', () => { + test('workflow does not execute', async () => { + const repoPath = mockGithub.repo.getPath('testAuthorChecklistWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'authorChecklist.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + act = utils.setUpActParams( + act, + 'pull_request', + { + action: 'reopened', + }, + {}, + 'dummy_github_token', + ); + const testMockSteps = { + checklist: mocks.AUTHORCHECKLIST__CHECKLIST__STEP_MOCKS, + }; + const result = await act + .runEvent('pull_request', { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor: 'OSBotify', + }); + + assertions.assertChecklistJobExecuted(result, false); + }, 60000); + }); + }); +}); diff --git a/workflow_tests/mocks/authorChecklistMocks.js b/workflow_tests/mocks/authorChecklistMocks.js new file mode 100644 index 000000000000..d27330928012 --- /dev/null +++ b/workflow_tests/mocks/authorChecklistMocks.js @@ -0,0 +1,17 @@ +const utils = require('../utils/utils'); + +// checklist +const AUTHORCHECKLIST__CHECKLIST__AUTHORCHECKLIST_JS__STEP_MOCK = utils.getMockStep( + 'authorChecklist.js', + 'Running authorChecklist.js', + 'CHECKLIST', + ['GITHUB_TOKEN'], + [], +); +const AUTHORCHECKLIST__CHECKLIST__STEP_MOCKS = [ + AUTHORCHECKLIST__CHECKLIST__AUTHORCHECKLIST_JS__STEP_MOCK, +]; + +module.exports = { + AUTHORCHECKLIST__CHECKLIST__STEP_MOCKS, +}; From 58906cc5c8d3848ed2ddb0bd4ab79fdfda83e273 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Thu, 16 Mar 2023 11:31:56 +0100 Subject: [PATCH 051/504] Update readme Added a mention about `Act`'s limitation to the workflow tests Readme See: https://github.com/Expensify/App/issues/13604 --- workflow_tests/README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/workflow_tests/README.md b/workflow_tests/README.md index a64edd0cfab7..e6b98f71ab5b 100644 --- a/workflow_tests/README.md +++ b/workflow_tests/README.md @@ -11,6 +11,13 @@ Not all workflows can always be tested this way, for example: - Act and Act-js do not support all the runner types available in GitHub Actions, like `macOS` runners or some specific version of `Ubuntu` runners like `ubuntu-20.04-64core`. In these cases the job will be omitted entirely and cannot be tested - Testing more complex workflows in their entirety can be extremely time-consuming and cumbersome. It is often optimal to mock most of the steps with expressions printing the input and output conditions - Due to the way `Act` and `Act-js` handle workflow output, not much can be checked in the test. What is available, namely whether the job/step executed or not, whether it was successful or not and what its printed output was, should be enough in most scenarios +- `Act` does not seem to support the conditions set on event parameters when determining whether to run the workflow or not, namely for a workflow defined with: +```yaml +on: + pull_request: + types: [opened, edited, reopened] +``` +running `act pull_request -e event_data.json` with `event_data.json` having `{"action": "opened"}` will execute the workflow (as expected), running for example `act push` will not execute it (as expected), but running `act pull_request -e event_data.json` with `event_data.json` having for example `{"action": "assigned"}` **will still execute the workflow** even though it should only be executed with `action` being `opened`, `edited` or `reopened`. This only applies to running the workflow with `Act`, in the GitHub environment it still works as expected ## Setup - Install dependencies from `package.json` file with `npm install` From 5e1a6073e9ffebdfac9a282e98c5eef6c0027d42 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Thu, 16 Mar 2023 11:32:46 +0100 Subject: [PATCH 052/504] Tweak pre-generation script Made the job's name capitalised in the assertion method names See: https://github.com/Expensify/App/issues/13604 --- workflow_tests/utils/preGenerateTest.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/workflow_tests/utils/preGenerateTest.js b/workflow_tests/utils/preGenerateTest.js index fb1680683e80..e011e3a200b0 100644 --- a/workflow_tests/utils/preGenerateTest.js +++ b/workflow_tests/utils/preGenerateTest.js @@ -214,7 +214,7 @@ const getAssertionsFileContent = (workflowName, jobs) => { for (const step of job.steps) { stepAssertionsContent += stepAssertionTemplate(step.name, jobId.toUpperCase(), step.name, step.inputs, step.envs); } - const jobAssertionName = `assert${jobId}JobExecuted`; + const jobAssertionName = `assert${jobId.charAt(0).toUpperCase() + jobId.slice(1)}JobExecuted`; jobAssertions.push(jobAssertionName); content += jobAssertionTemplate(jobAssertionName, stepAssertionsContent); } From 74434b012b0fc5d4d795ebc0d158cdda7e232b8a Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Thu, 16 Mar 2023 17:11:15 +0100 Subject: [PATCH 053/504] Add tests Added test for the `cherryPick.yml` workflow, plus edited the utils to allow for setting the event inputs See: https://github.com/Expensify/App/issues/13604 --- .github/workflows/cherryPick.yml | 16 +- .../assertions/cherryPickAssertions.js | 309 ++++++++ workflow_tests/cherryPick.test.js | 658 ++++++++++++++++++ workflow_tests/mocks/cherryPickMocks.js | 225 ++++++ workflow_tests/utils/preGenerateTest.js | 2 +- workflow_tests/utils/utils.js | 8 +- 6 files changed, 1212 insertions(+), 6 deletions(-) create mode 100644 workflow_tests/assertions/cherryPickAssertions.js create mode 100644 workflow_tests/cherryPick.test.js create mode 100644 workflow_tests/mocks/cherryPickMocks.js diff --git a/.github/workflows/cherryPick.yml b/.github/workflows/cherryPick.yml index 2f8d05e15f8b..6944ad03d44f 100644 --- a/.github/workflows/cherryPick.yml +++ b/.github/workflows/cherryPick.yml @@ -17,7 +17,8 @@ jobs: outputs: IS_DEPLOYER: ${{ fromJSON(steps.isUserDeployer.outputs.isTeamMember) || github.actor == 'OSBotify' }} steps: - - id: isUserDeployer + - name: Check if user is deployer + id: isUserDeployer uses: tspascoal/get-user-teams-membership@baf2e6adf4c3b897bd65a7e3184305c165aec872 with: GITHUB_TOKEN: ${{ secrets.OS_BOTIFY_TOKEN }} @@ -26,9 +27,15 @@ jobs: createNewVersion: needs: validateActor + runs-on: ubuntu-latest if: ${{ fromJSON(needs.validateActor.outputs.IS_DEPLOYER) && github.event.inputs.NEW_VERSION == '' }} - uses: Expensify/App/.github/workflows/createNewVersion.yml@main - secrets: inherit + outputs: + NEW_VERSION: ${{ steps.createNewVersion.outputs.NEW_VERSION }} + steps: + - name: Create new version + id: createNewVersion + uses: Expensify/App/.github/workflows/createNewVersion.yml@main + secrets: inherit cherryPick: needs: [validateActor, createNewVersion] @@ -42,7 +49,8 @@ jobs: ref: staging token: ${{ secrets.OS_BOTIFY_TOKEN }} - - uses: Expensify/App/.github/actions/composite/setupGitForOSBotify@main + - name: Set up git for OSBotify + uses: Expensify/App/.github/actions/composite/setupGitForOSBotify@main with: GPG_PASSPHRASE: ${{ secrets.LARGE_SECRET_PASSPHRASE }} diff --git a/workflow_tests/assertions/cherryPickAssertions.js b/workflow_tests/assertions/cherryPickAssertions.js new file mode 100644 index 000000000000..f86f07f491f5 --- /dev/null +++ b/workflow_tests/assertions/cherryPickAssertions.js @@ -0,0 +1,309 @@ +const utils = require('../utils/utils'); + +const assertValidateActorJobExecuted = (workflowResult, username = 'Dummy Author', didExecute = true) => { + const steps = [ + utils.getStepAssertion( + 'Check if user is deployer', + true, + null, + 'VALIDATEACTOR', + 'Checking if user is a deployer', + [{key: 'GITHUB_TOKEN', value: '***'}, {key: 'username', value: username}, {key: 'team', value: 'mobile-deployers'}], + [], + ), + ]; + + for (const expectedStep of steps) { + if (didExecute) { + expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); + } else { + expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); + } + } +}; + +const assertCreateNewVersionJobExecuted = (workflowResult, didExecute = true) => { + const steps = [ + utils.getStepAssertion( + 'Create new version', + true, + null, + 'CREATENEWVERSION', + 'Creating new version', + [], + [], + ), + ]; + + for (const expectedStep of steps) { + if (didExecute) { + expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); + } else { + expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); + } + } +}; + +const assertCherryPickJobExecuted = ( + workflowResult, + user = 'Dummy Author', + pullRequestNumber = '1234', + newVersion = '1.2.3', + didExecute = true, + mergeConflictsOrVersionMismatch = false, + shouldAutomerge = true, + versionsMatch = true, + prIsMergeable = true, + inputNewVersion = '', + isSuccessful = true, +) => { + const steps = [ + utils.getStepAssertion( + 'Checkout staging branch', + true, + null, + 'CHERRYPICK', + 'Checking out staging branch', + [{key: 'ref', value: 'staging'}, {key: 'token', value: '***'}], + [], + ), + utils.getStepAssertion( + 'Set up git for OSBotify', + true, + null, + 'CHERRYPICK', + 'Setting up git for OSBotify', + [{key: 'GPG_PASSPHRASE', value: '***'}], + [], + ), + utils.getStepAssertion( + 'Create branch for new pull request', + true, + null, + 'CHERRYPICK', + 'Creating branch for new pull request', + [], + [], + ), + utils.getStepAssertion( + 'Get merge commit for CP pull request', + true, + null, + 'CHERRYPICK', + 'Getting merge commit for CP pull request', + [{key: 'GITHUB_TOKEN', value: '***'}, {key: 'USER', value: user}, {key: 'PULL_REQUEST_NUMBER', value: pullRequestNumber}], + [], + ), + utils.getStepAssertion( + 'Save correct NEW_VERSION to env', + true, + inputNewVersion ? `New version is ${inputNewVersion}` : 'New version is', + ), + utils.getStepAssertion( + 'Get merge commit for version-bump pull request', + true, + null, + 'CHERRYPICK', + 'Getting merge commit for version-bump pull request', + [{key: 'GITHUB_TOKEN', value: '***'}, {key: 'USER', value: 'OSBotify'}, {key: 'TITLE_REGEX', value: `Update version to ${newVersion}`}], + [], + ), + utils.getStepAssertion( + 'Cherry-pick the version-bump to new branch', + true, + null, + 'CHERRYPICK', + 'Cherry-picking the version-bump to new branch', + [], + [], + ), + utils.getStepAssertion( + 'Cherry-pick the merge commit of target PR to new branch', + true, + null, + 'CHERRYPICK', + 'Cherry-picking the merge commit of target PR to new branch', + [], + [], + ), + utils.getStepAssertion( + 'Push changes to CP branch', + true, + null, + 'CHERRYPICK', + 'Pushing changes to CP branch', + [], + [], + ), + utils.getStepAssertion( + 'Create Pull Request', + true, + null, + 'CHERRYPICK', + 'Creating Pull Request', + [], + [{key: 'GITHUB_TOKEN', value: '***'}], + ), + utils.getStepAssertion( + 'Check if ShortVersionString is up to date', + true, + null, + 'CHERRYPICK', + 'Checking if ShortVersionString is up to date', + [], + [], + ), + utils.getStepAssertion( + 'Check if pull request is mergeable', + true, + null, + 'CHERRYPICK', + 'Checking if pull request is mergeable', + [{key: 'GITHUB_TOKEN', value: '***'}, {key: 'PULL_REQUEST_NUMBER', value: pullRequestNumber}], + [], + ), + ]; + + for (const expectedStep of steps) { + if (didExecute) { + expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); + } else { + expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); + } + } + + const conflictsSteps = [ + utils.getStepAssertion( + 'Auto-assign PR if there are merge conflicts or if the bundle versions are mismatched', + true, + null, + 'CHERRYPICK', + 'Auto-assigning PR', + [], + [{key: 'GITHUB_TOKEN', value: '***'}], + ), + ]; + + for (const step of conflictsSteps) { + if (didExecute && mergeConflictsOrVersionMismatch) { + expect(workflowResult).toEqual(expect.arrayContaining([step])); + } else { + expect(workflowResult).not.toEqual(expect.arrayContaining([step])); + } + } + + const manualMergeSteps = [ + utils.getStepAssertion( + 'Assign the PR to the deployer', + true, + null, + 'CHERRYPICK', + 'Assigning the PR to the deployer', + [], + [{key: 'GITHUB_TOKEN', value: '***'}], + ), + utils.getStepAssertion( + 'If PR has merge conflicts, comment with instructions for assignee', + true, + null, + 'CHERRYPICK', + 'Commenting with instructions for assignee', + [], + [{key: 'GITHUB_TOKEN', value: '***'}], + ), + ]; + + for (const step of manualMergeSteps) { + if (didExecute && !shouldAutomerge) { + expect(workflowResult).toEqual(expect.arrayContaining([step])); + } else { + expect(workflowResult).not.toEqual(expect.arrayContaining([step])); + } + } + + const autoMergeSteps = [ + utils.getStepAssertion( + 'Auto-approve the PR', + true, + null, + 'CHERRYPICK', + 'Auto-approving the PR', + [], + [{key: 'GITHUB_TOKEN', value: '***'}], + ), + ]; + + for (const step of autoMergeSteps) { + if (didExecute && shouldAutomerge) { + expect(workflowResult).toEqual(expect.arrayContaining([step])); + } else { + expect(workflowResult).not.toEqual(expect.arrayContaining([step])); + } + } + + const versionMismatchSteps = [ + utils.getStepAssertion( + 'If PR has a bundle version mismatch, comment with the instructions for assignee', + true, + null, + 'CHERRYPICK', + 'Commenting with the instructions for assignee', + [], + [{key: 'GITHUB_TOKEN', value: '***'}], + ), + ]; + + for (const step of versionMismatchSteps) { + if (didExecute && !versionsMatch) { + expect(workflowResult).toEqual(expect.arrayContaining([step])); + } else { + expect(workflowResult).not.toEqual(expect.arrayContaining([step])); + } + } + + const failedSteps = [ + utils.getStepAssertion( + 'Announces a CP failure in the #announce Slack room', + true, + null, + 'CHERRYPICK', + 'Announcing a CP failure', + [{key: 'status', value: 'custom'}], + [{key: 'GITHUB_TOKEN', value: '***'}, {key: 'SLACK_WEBHOOK_URL', value: '***'}], + ), + ]; + + for (const step of failedSteps) { + if (didExecute && (!isSuccessful || !prIsMergeable)) { + expect(workflowResult).toEqual(expect.arrayContaining([step])); + } else { + expect(workflowResult).not.toEqual(expect.arrayContaining([step])); + } + } + + const autoMergeableSteps = [ + utils.getStepAssertion( + 'Auto-merge the PR', + true, + null, + 'CHERRYPICK', + 'Auto-merging the PR', + [], + [{key: 'GITHUB_TOKEN', value: '***'}], + ), + ]; + + for (const step of autoMergeableSteps) { + if (didExecute && shouldAutomerge && prIsMergeable) { + expect(workflowResult).toEqual(expect.arrayContaining([step])); + } else { + expect(workflowResult).not.toEqual(expect.arrayContaining([step])); + } + } +}; + +module.exports = { + assertValidateActorJobExecuted, + assertCreateNewVersionJobExecuted, + assertCherryPickJobExecuted, +}; diff --git a/workflow_tests/cherryPick.test.js b/workflow_tests/cherryPick.test.js new file mode 100644 index 000000000000..ea593d1d7a52 --- /dev/null +++ b/workflow_tests/cherryPick.test.js @@ -0,0 +1,658 @@ +const path = require('path'); +const kieMockGithub = require('@kie/mock-github'); +const utils = require('./utils/utils'); +const assertions = require('./assertions/cherryPickAssertions'); +const mocks = require('./mocks/cherryPickMocks'); +const eAct = require('./utils/ExtendedAct'); + +let mockGithub; +const FILES_TO_COPY_INTO_TEST_REPO = [ + { + src: path.resolve(__dirname, '..', '.github', 'actions'), + dest: '.github/actions', + }, + { + src: path.resolve(__dirname, '..', '.github', 'libs'), + dest: '.github/libs', + }, + { + src: path.resolve(__dirname, '..', '.github', 'scripts'), + dest: '.github/scripts', + }, + { + src: path.resolve(__dirname, '..', '.github', 'workflows', 'cherryPick.yml'), + dest: '.github/workflows/cherryPick.yml', + }, +]; + +beforeEach(async () => { + // create a local repository and copy required files + mockGithub = new kieMockGithub.MockGithub({ + repo: { + testCherryPickWorkflowRepo: { + files: FILES_TO_COPY_INTO_TEST_REPO, + }, + }, + }); + + await mockGithub.setup(); +}); + +afterEach(async () => { + await mockGithub.teardown(); +}); + +const runWorkflow = async (act, event, repoPath, testMockSteps, actor) => await act + .runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor, + }); + +const getPathsAndAct = () => { + const repoPath = mockGithub.repo.getPath('testCherryPickWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'); + const act = new eAct.ExtendedAct(repoPath, workflowPath); + return {repoPath, workflowPath, act}; +}; + +const setUpActParams = (act, event, newVersion) => utils.setUpActParams( + act, + event, + null, + { + OS_BOTIFY_TOKEN: 'dummy_token', + LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', + SLACK_WEBHOOK: 'dummy_slack_webhook', + }, + 'dummy_github_token', + null, + { + PULL_REQUEST_NUMBER: '1234', + NEW_VERSION: newVersion, + }, +); + +describe('test workflow cherryPick', () => { + describe('manual workflow dispatch', () => { + const event = 'workflow_dispatch'; + describe('actor is not deployer', () => { + const testMockSteps = { + validateActor: mocks.CHERRYPICK__VALIDATEACTOR__FALSE__STEP_MOCKS, + createNewVersion: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, + cherryPick: mocks.getCherryPickMockSteps(true, true, true), + }; + const actor = 'Dummy Author'; + test('workflow ends after validate job', async () => { + const repoPath = mockGithub.repo.getPath('testCherryPickWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + act = utils.setUpActParams( + act, + event, + null, + { + OS_BOTIFY_TOKEN: 'dummy_token', + LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', + SLACK_WEBHOOK: 'dummy_slack_webhook', + }, + 'dummy_github_token', + null, + { + PULL_REQUEST_NUMBER: '1234', + NEW_VERSION: '', + }, + ); + const result = await act + .runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor, + }); + + assertions.assertValidateActorJobExecuted(result, actor); + assertions.assertCreateNewVersionJobExecuted(result, false); + assertions.assertCherryPickJobExecuted(result, actor, '1234', '1.2.3', false); + }, 60000); + }); + describe('actor is OSBotify', () => { + const testMockSteps = { + validateActor: mocks.CHERRYPICK__VALIDATEACTOR__FALSE__STEP_MOCKS, + createNewVersion: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, + }; + const actor = 'OSBotify'; + const newVersion = ''; + const mergeConflicts = false; + const versionsMatch = true; + const prIsMergeable = true; + test('behaviour is the same as with actor being the deployer', async () => { + const pathsAndAct = getPathsAndAct(); + const repoPath = pathsAndAct.repoPath; + let act = pathsAndAct.act; + testMockSteps.cherryPick = mocks.getCherryPickMockSteps(versionsMatch, prIsMergeable, !mergeConflicts); + act = setUpActParams(act, event, newVersion); + const result = await runWorkflow(act, event, repoPath, testMockSteps, actor); + + assertions.assertValidateActorJobExecuted(result, actor); + assertions.assertCreateNewVersionJobExecuted(result); + assertions.assertCherryPickJobExecuted( + result, + actor, + '1234', + '1.2.3', + true, + mergeConflicts || !versionsMatch, + !mergeConflicts, + versionsMatch, + prIsMergeable, + newVersion, + ); + }, 60000); + }); + describe('actor is a deployer', () => { + const testMockSteps = { + validateActor: mocks.CHERRYPICK__VALIDATEACTOR__TRUE__STEP_MOCKS, + createNewVersion: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, + }; + const actor = 'Dummy Author'; + describe('input version not set', () => { + const newVersion = ''; + describe('no merge conflicts', () => { + const mergeConflicts = false; + describe('version match', () => { + const versionsMatch = true; + describe('PR is mergeable', () => { + const prIsMergeable = true; + test('workflow executes, new version created, PR approved and merged automatically', async () => { + const pathsAndAct = getPathsAndAct(); + const repoPath = pathsAndAct.repoPath; + let act = pathsAndAct.act; + testMockSteps.cherryPick = mocks.getCherryPickMockSteps(versionsMatch, prIsMergeable, !mergeConflicts); + act = setUpActParams(act, event, newVersion); + const result = await runWorkflow(act, event, repoPath, testMockSteps, actor); + + assertions.assertValidateActorJobExecuted(result, actor); + assertions.assertCreateNewVersionJobExecuted(result); + assertions.assertCherryPickJobExecuted( + result, + actor, + '1234', + '1.2.3', + true, + mergeConflicts || !versionsMatch, + !mergeConflicts, + versionsMatch, + prIsMergeable, + newVersion, + ); + }, 60000); + }); + describe('PR is not mergeable', () => { + const prIsMergeable = false; + test('workflow executes, new version created, PR is not merged automatically', async () => { + const pathsAndAct = getPathsAndAct(); + const repoPath = pathsAndAct.repoPath; + let act = pathsAndAct.act; + testMockSteps.cherryPick = mocks.getCherryPickMockSteps(versionsMatch, prIsMergeable, !mergeConflicts); + act = setUpActParams(act, event, newVersion); + const result = await runWorkflow(act, event, repoPath, testMockSteps, actor); + + assertions.assertValidateActorJobExecuted(result, actor); + assertions.assertCreateNewVersionJobExecuted(result); + assertions.assertCherryPickJobExecuted( + result, + actor, + '1234', + '1.2.3', + true, + mergeConflicts || !versionsMatch, + !mergeConflicts, + versionsMatch, + prIsMergeable, + newVersion, + ); + }, 60000); + }); + }); + describe('version do not match', () => { + const versionsMatch = false; + describe('PR is mergeable', () => { + const prIsMergeable = true; + test('workflow executes, new version created, PR auto-assigned and commented, approved and merged automatically', async () => { + const pathsAndAct = getPathsAndAct(); + const repoPath = pathsAndAct.repoPath; + let act = pathsAndAct.act; + testMockSteps.cherryPick = mocks.getCherryPickMockSteps(versionsMatch, prIsMergeable, !mergeConflicts); + act = setUpActParams(act, event, newVersion); + const result = await runWorkflow(act, event, repoPath, testMockSteps, actor); + + assertions.assertValidateActorJobExecuted(result, actor); + assertions.assertCreateNewVersionJobExecuted(result); + assertions.assertCherryPickJobExecuted( + result, + actor, + '1234', + '1.2.3', + true, + mergeConflicts || !versionsMatch, + !mergeConflicts, + versionsMatch, + prIsMergeable, + newVersion, + ); + }, 60000); + }); + describe('PR is not mergeable', () => { + const prIsMergeable = false; + test('workflow executes, new version created, PR auto-assigned and commented, not merged automatically', async () => { + const pathsAndAct = getPathsAndAct(); + const repoPath = pathsAndAct.repoPath; + let act = pathsAndAct.act; + testMockSteps.cherryPick = mocks.getCherryPickMockSteps(versionsMatch, prIsMergeable, !mergeConflicts); + act = setUpActParams(act, event, newVersion); + const result = await runWorkflow(act, event, repoPath, testMockSteps, actor); + + assertions.assertValidateActorJobExecuted(result, actor); + assertions.assertCreateNewVersionJobExecuted(result); + assertions.assertCherryPickJobExecuted( + result, + actor, + '1234', + '1.2.3', + true, + mergeConflicts || !versionsMatch, + !mergeConflicts, + versionsMatch, + prIsMergeable, + newVersion, + ); + }, 60000); + }); + }); + }); + describe('merge conflicts', () => { + const mergeConflicts = true; + describe('version match', () => { + const versionsMatch = true; + describe('PR is mergeable', () => { + const prIsMergeable = true; + test('workflow executes, new version created, PR auto-assigned and commented, not merged automatically', async () => { + const pathsAndAct = getPathsAndAct(); + const repoPath = pathsAndAct.repoPath; + let act = pathsAndAct.act; + testMockSteps.cherryPick = mocks.getCherryPickMockSteps(versionsMatch, prIsMergeable, !mergeConflicts); + act = setUpActParams(act, event, newVersion); + const result = await runWorkflow(act, event, repoPath, testMockSteps, actor); + + assertions.assertValidateActorJobExecuted(result, actor); + assertions.assertCreateNewVersionJobExecuted(result); + assertions.assertCherryPickJobExecuted( + result, + actor, + '1234', + '1.2.3', + true, + mergeConflicts || !versionsMatch, + !mergeConflicts, + versionsMatch, + prIsMergeable, + newVersion, + ); + }, 60000); + }); + describe('PR is not mergeable', () => { + const prIsMergeable = false; + test('workflow executes, new version created, PR auto-assigned and commented, not merged automatically', async () => { + const pathsAndAct = getPathsAndAct(); + const repoPath = pathsAndAct.repoPath; + let act = pathsAndAct.act; + testMockSteps.cherryPick = mocks.getCherryPickMockSteps(versionsMatch, prIsMergeable, !mergeConflicts); + act = setUpActParams(act, event, newVersion); + const result = await runWorkflow(act, event, repoPath, testMockSteps, actor); + + assertions.assertValidateActorJobExecuted(result, actor); + assertions.assertCreateNewVersionJobExecuted(result); + assertions.assertCherryPickJobExecuted( + result, + actor, + '1234', + '1.2.3', + true, + mergeConflicts || !versionsMatch, + !mergeConflicts, + versionsMatch, + prIsMergeable, + newVersion, + ); + }, 60000); + }); + }); + describe('version do not match', () => { + const versionsMatch = false; + describe('PR is mergeable', () => { + const prIsMergeable = true; + test('workflow executes, new version created, PR auto-assigned and commented, not merged automatically', async () => { + const pathsAndAct = getPathsAndAct(); + const repoPath = pathsAndAct.repoPath; + let act = pathsAndAct.act; + testMockSteps.cherryPick = mocks.getCherryPickMockSteps(versionsMatch, prIsMergeable, !mergeConflicts); + act = setUpActParams(act, event, newVersion); + const result = await runWorkflow(act, event, repoPath, testMockSteps, actor); + + assertions.assertValidateActorJobExecuted(result, actor); + assertions.assertCreateNewVersionJobExecuted(result); + assertions.assertCherryPickJobExecuted( + result, + actor, + '1234', + '1.2.3', + true, + mergeConflicts || !versionsMatch, + !mergeConflicts, + versionsMatch, + prIsMergeable, + newVersion, + ); + }, 60000); + }); + describe('PR is not mergeable', () => { + const prIsMergeable = false; + test('workflow executes, new version created, PR auto-assigned and commented, not merged automatically', async () => { + const pathsAndAct = getPathsAndAct(); + const repoPath = pathsAndAct.repoPath; + let act = pathsAndAct.act; + testMockSteps.cherryPick = mocks.getCherryPickMockSteps(versionsMatch, prIsMergeable, !mergeConflicts); + act = setUpActParams(act, event, newVersion); + const result = await runWorkflow(act, event, repoPath, testMockSteps, actor); + + assertions.assertValidateActorJobExecuted(result, actor); + assertions.assertCreateNewVersionJobExecuted(result); + assertions.assertCherryPickJobExecuted( + result, + actor, + '1234', + '1.2.3', + true, + mergeConflicts || !versionsMatch, + !mergeConflicts, + versionsMatch, + prIsMergeable, + newVersion, + ); + }, 60000); + }); + }); + }); + }); + + describe('input version set', () => { + const newVersion = '1.2.3'; + describe('no merge conflicts', () => { + const mergeConflicts = false; + describe('version match', () => { + const versionsMatch = true; + describe('PR is mergeable', () => { + const prIsMergeable = true; + test('workflow executes, PR approved and merged automatically', async () => { + const pathsAndAct = getPathsAndAct(); + const repoPath = pathsAndAct.repoPath; + let act = pathsAndAct.act; + testMockSteps.cherryPick = mocks.getCherryPickMockSteps(versionsMatch, prIsMergeable, !mergeConflicts); + act = setUpActParams(act, event, newVersion); + const result = await runWorkflow(act, event, repoPath, testMockSteps, actor); + + assertions.assertValidateActorJobExecuted(result, actor); + assertions.assertCreateNewVersionJobExecuted(result, false); + assertions.assertCherryPickJobExecuted( + result, + actor, + '1234', + '1.2.3', + true, + mergeConflicts || !versionsMatch, + !mergeConflicts, + versionsMatch, + prIsMergeable, + newVersion, + ); + }, 60000); + }); + describe('PR is not mergeable', () => { + const prIsMergeable = false; + test('workflow executes, PR is not merged automatically', async () => { + const pathsAndAct = getPathsAndAct(); + const repoPath = pathsAndAct.repoPath; + let act = pathsAndAct.act; + testMockSteps.cherryPick = mocks.getCherryPickMockSteps(versionsMatch, prIsMergeable, !mergeConflicts); + act = setUpActParams(act, event, newVersion); + const result = await runWorkflow(act, event, repoPath, testMockSteps, actor); + + assertions.assertValidateActorJobExecuted(result, actor); + assertions.assertCreateNewVersionJobExecuted(result, false); + assertions.assertCherryPickJobExecuted( + result, + actor, + '1234', + '1.2.3', + true, + mergeConflicts || !versionsMatch, + !mergeConflicts, + versionsMatch, + prIsMergeable, + newVersion, + ); + }, 60000); + }); + }); + describe('version do not match', () => { + const versionsMatch = false; + describe('PR is mergeable', () => { + const prIsMergeable = true; + test('workflow executes, PR auto-assigned and commented, approved and merged automatically', async () => { + const pathsAndAct = getPathsAndAct(); + const repoPath = pathsAndAct.repoPath; + let act = pathsAndAct.act; + testMockSteps.cherryPick = mocks.getCherryPickMockSteps(versionsMatch, prIsMergeable, !mergeConflicts); + act = setUpActParams(act, event, newVersion); + const result = await runWorkflow(act, event, repoPath, testMockSteps, actor); + + assertions.assertValidateActorJobExecuted(result, actor); + assertions.assertCreateNewVersionJobExecuted(result, false); + assertions.assertCherryPickJobExecuted( + result, + actor, + '1234', + '1.2.3', + true, + mergeConflicts || !versionsMatch, + !mergeConflicts, + versionsMatch, + prIsMergeable, + newVersion, + ); + }, 60000); + }); + describe('PR is not mergeable', () => { + const prIsMergeable = false; + test('workflow executes, PR auto-assigned and commented, not merged automatically', async () => { + const pathsAndAct = getPathsAndAct(); + const repoPath = pathsAndAct.repoPath; + let act = pathsAndAct.act; + testMockSteps.cherryPick = mocks.getCherryPickMockSteps(versionsMatch, prIsMergeable, !mergeConflicts); + act = setUpActParams(act, event, newVersion); + const result = await runWorkflow(act, event, repoPath, testMockSteps, actor); + + assertions.assertValidateActorJobExecuted(result, actor); + assertions.assertCreateNewVersionJobExecuted(result, false); + assertions.assertCherryPickJobExecuted( + result, + actor, + '1234', + '1.2.3', + true, + mergeConflicts || !versionsMatch, + !mergeConflicts, + versionsMatch, + prIsMergeable, + newVersion, + ); + }, 60000); + }); + }); + }); + describe('merge conflicts', () => { + const mergeConflicts = true; + describe('version match', () => { + const versionsMatch = true; + describe('PR is mergeable', () => { + const prIsMergeable = true; + test('workflow executes, PR auto-assigned and commented, not merged automatically', async () => { + const pathsAndAct = getPathsAndAct(); + const repoPath = pathsAndAct.repoPath; + let act = pathsAndAct.act; + testMockSteps.cherryPick = mocks.getCherryPickMockSteps(versionsMatch, prIsMergeable, !mergeConflicts); + act = setUpActParams(act, event, newVersion); + const result = await runWorkflow(act, event, repoPath, testMockSteps, actor); + + assertions.assertValidateActorJobExecuted(result, actor); + assertions.assertCreateNewVersionJobExecuted(result, false); + assertions.assertCherryPickJobExecuted( + result, + actor, + '1234', + '1.2.3', + true, + mergeConflicts || !versionsMatch, + !mergeConflicts, + versionsMatch, + prIsMergeable, + newVersion, + ); + }, 60000); + }); + describe('PR is not mergeable', () => { + const prIsMergeable = false; + test('workflow executes, PR auto-assigned and commented, not merged automatically', async () => { + const pathsAndAct = getPathsAndAct(); + const repoPath = pathsAndAct.repoPath; + let act = pathsAndAct.act; + testMockSteps.cherryPick = mocks.getCherryPickMockSteps(versionsMatch, prIsMergeable, !mergeConflicts); + act = setUpActParams(act, event, newVersion); + const result = await runWorkflow(act, event, repoPath, testMockSteps, actor); + + assertions.assertValidateActorJobExecuted(result, actor); + assertions.assertCreateNewVersionJobExecuted(result, false); + assertions.assertCherryPickJobExecuted( + result, + actor, + '1234', + '1.2.3', + true, + mergeConflicts || !versionsMatch, + !mergeConflicts, + versionsMatch, + prIsMergeable, + newVersion, + ); + }, 60000); + }); + }); + describe('version do not match', () => { + const versionsMatch = false; + describe('PR is mergeable', () => { + const prIsMergeable = true; + test('workflow executes, PR auto-assigned and commented, not merged automatically', async () => { + const pathsAndAct = getPathsAndAct(); + const repoPath = pathsAndAct.repoPath; + let act = pathsAndAct.act; + testMockSteps.cherryPick = mocks.getCherryPickMockSteps(versionsMatch, prIsMergeable, !mergeConflicts); + act = setUpActParams(act, event, newVersion); + const result = await runWorkflow(act, event, repoPath, testMockSteps, actor); + + assertions.assertValidateActorJobExecuted(result, actor); + assertions.assertCreateNewVersionJobExecuted(result, false); + assertions.assertCherryPickJobExecuted( + result, + actor, + '1234', + '1.2.3', + true, + mergeConflicts || !versionsMatch, + !mergeConflicts, + versionsMatch, + prIsMergeable, + newVersion, + ); + }, 60000); + }); + describe('PR is not mergeable', () => { + const prIsMergeable = false; + test('workflow executes, PR auto-assigned and commented, not merged automatically', async () => { + const pathsAndAct = getPathsAndAct(); + const repoPath = pathsAndAct.repoPath; + let act = pathsAndAct.act; + testMockSteps.cherryPick = mocks.getCherryPickMockSteps(versionsMatch, prIsMergeable, !mergeConflicts); + act = setUpActParams(act, event, newVersion); + const result = await runWorkflow(act, event, repoPath, testMockSteps, actor); + + assertions.assertValidateActorJobExecuted(result, actor); + assertions.assertCreateNewVersionJobExecuted(result, false); + assertions.assertCherryPickJobExecuted( + result, + actor, + '1234', + '1.2.3', + true, + mergeConflicts || !versionsMatch, + !mergeConflicts, + versionsMatch, + prIsMergeable, + newVersion, + ); + }, 60000); + }); + }); + }); + }); + }); + }); + describe('autmatic trigger', () => { + const event = 'pull_request'; + test('workflow does not execute', async () => { + const repoPath = mockGithub.repo.getPath('testCherryPickWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + act = utils.setUpActParams( + act, + event, + null, + { + OS_BOTIFY_TOKEN: 'dummy_token', + LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', + SLACK_WEBHOOK: 'dummy_slack_webhook', + }, + 'dummy_github_token', + null, + { + PULL_REQUEST_NUMBER: '1234', + NEW_VERSION: '', + }, + ); + const testMockSteps = { + validateActor: mocks.CHERRYPICK__VALIDATEACTOR__TRUE__STEP_MOCKS, + createNewVersion: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, + cherryPick: mocks.getCherryPickMockSteps(true, true, true), + }; + const result = await act + .runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor: 'Dummy Author', + }); + + assertions.assertValidateActorJobExecuted(result, 'Dummy Author', false); + assertions.assertCreateNewVersionJobExecuted(result, false); + assertions.assertCherryPickJobExecuted(result, 'Dummy Author', '1234', '1.2.3', false); + }, 60000); + }); +}); diff --git a/workflow_tests/mocks/cherryPickMocks.js b/workflow_tests/mocks/cherryPickMocks.js new file mode 100644 index 000000000000..55f538ba0480 --- /dev/null +++ b/workflow_tests/mocks/cherryPickMocks.js @@ -0,0 +1,225 @@ +const utils = require('../utils/utils'); + +// validateactor +const CHERRYPICK__VALIDATEACTOR__CHECK_IF_USER_IS_DEPLOYER_TRUE__STEP_MOCK = utils.getMockStep( + 'Check if user is deployer', + 'Checking if user is a deployer', + 'VALIDATEACTOR', + ['GITHUB_TOKEN', 'username', 'team'], + [], + {isTeamMember: true}, +); +const CHERRYPICK__VALIDATEACTOR__CHECK_IF_USER_IS_DEPLOYER_FALSE__STEP_MOCK = utils.getMockStep( + 'Check if user is deployer', + 'Checking if user is a deployer', + 'VALIDATEACTOR', + ['GITHUB_TOKEN', 'username', 'team'], + [], + {isTeamMember: false}, +); +const CHERRYPICK__VALIDATEACTOR__TRUE__STEP_MOCKS = [ + CHERRYPICK__VALIDATEACTOR__CHECK_IF_USER_IS_DEPLOYER_TRUE__STEP_MOCK, +]; +const CHERRYPICK__VALIDATEACTOR__FALSE__STEP_MOCKS = [ + CHERRYPICK__VALIDATEACTOR__CHECK_IF_USER_IS_DEPLOYER_FALSE__STEP_MOCK, +]; + +// createnewversion +const CHERRYPICK__CREATENEWVERSION__CREATE_NEW_VERSION__STEP_MOCK = utils.getMockStep( + 'Create new version', + 'Creating new version', + 'CREATENEWVERSION', + [], + [], + {NEW_VERSION: '1.2.3'}, +); +const CHERRYPICK__CREATENEWVERSION__STEP_MOCKS = [ + CHERRYPICK__CREATENEWVERSION__CREATE_NEW_VERSION__STEP_MOCK, +]; + +// cherrypick +const CHERRYPICK__CHERRYPICK__CHECKOUT_STAGING_BRANCH__STEP_MOCK = utils.getMockStep( + 'Checkout staging branch', + 'Checking out staging branch', + 'CHERRYPICK', + ['ref', 'token'], + [], +); +const CHERRYPICK__CHERRYPICK__SET_UP_GIT_FOR_OSBOTIFY__STEP_MOCK = utils.getMockStep( + 'Set up git for OSBotify', + 'Setting up git for OSBotify', + 'CHERRYPICK', + ['GPG_PASSPHRASE'], + [], +); +const CHERRYPICK__CHERRYPICK__CREATE_BRANCH_FOR_NEW_PULL_REQUEST__STEP_MOCK = utils.getMockStep( + 'Create branch for new pull request', + 'Creating branch for new pull request', + 'CHERRYPICK', + [], + [], +); +const CHERRYPICK__CHERRYPICK__GET_MERGE_COMMIT_FOR_CP_PULL_REQUEST__STEP_MOCK = utils.getMockStep( + 'Get merge commit for CP pull request', + 'Getting merge commit for CP pull request', + 'CHERRYPICK', + ['GITHUB_TOKEN', 'USER', 'PULL_REQUEST_NUMBER'], + [], + {MERGE_ACTOR: '@dummyauthor'}, +); +const CHERRYPICK__CHERRYPICK__GET_MERGE_COMMIT_FOR_VERSION_BUMP_PULL_REQUEST__STEP_MOCK = utils.getMockStep( + 'Get merge commit for version-bump pull request', + 'Getting merge commit for version-bump pull request', + 'CHERRYPICK', + ['GITHUB_TOKEN', 'USER', 'TITLE_REGEX'], + [], + {MERGE_COMMIT_SHA: '0123456789abcdef'}, +); +const CHERRYPICK__CHERRYPICK__CHERRY_PICK_THE_VERSION_BUMP_TO_NEW_BRANCH__STEP_MOCK = utils.getMockStep( + 'Cherry-pick the version-bump to new branch', + 'Cherry-picking the version-bump to new branch', + 'CHERRYPICK', + [], + [], +); +const CHERRYPICK__CHERRYPICK__CHERRY_PICK_THE_MERGE_COMMIT_OF_TARGET_PR_TO_NEW_BRANCH__SHOULD_MERGE__STEP_MOCK = utils.getMockStep( + 'Cherry-pick the merge commit of target PR to new branch', + 'Cherry-picking the merge commit of target PR to new branch', + 'CHERRYPICK', + [], + [], + {SHOULD_AUTOMERGE: true}, +); +// eslint-disable-next-line rulesdir/no-negated-variables +const CHERRYPICK__CHERRYPICK__CHERRY_PICK_THE_MERGE_COMMIT_OF_TARGET_PR_TO_NEW_BRANCH__SHOULD_NOT_MERGE__STEP_MOCK = utils.getMockStep( + 'Cherry-pick the merge commit of target PR to new branch', + 'Cherry-picking the merge commit of target PR to new branch', + 'CHERRYPICK', + [], + [], + {SHOULD_AUTOMERGE: false}, +); +const CHERRYPICK__CHERRYPICK__PUSH_CHANGES_TO_CP_BRANCH__STEP_MOCK = utils.getMockStep( + 'Push changes to CP branch', + 'Pushing changes to CP branch', + 'CHERRYPICK', + [], + [], +); +const CHERRYPICK__CHERRYPICK__CREATE_PULL_REQUEST__STEP_MOCK = utils.getMockStep( + 'Create Pull Request', + 'Creating Pull Request', + 'CHERRYPICK', + [], + ['GITHUB_TOKEN'], + {PR_NUMBER: '1234'}, +); +const CHERRYPICK__CHERRYPICK__CHECK_IF_SHORTVERSIONSTRING_IS_UP_TO_DATE_TRUE__STEP_MOCK = utils.getMockStep( + 'Check if ShortVersionString is up to date', + 'Checking if ShortVersionString is up to date', + 'CHERRYPICK', + [], + [], + {BUNDLE_VERSIONS_MATCH: true}, +); +const CHERRYPICK__CHERRYPICK__CHECK_IF_SHORTVERSIONSTRING_IS_UP_TO_DATE_FALSE__STEP_MOCK = utils.getMockStep( + 'Check if ShortVersionString is up to date', + 'Checking if ShortVersionString is up to date', + 'CHERRYPICK', + [], + [], + {BUNDLE_VERSIONS_MATCH: false}, +); +const CHERRYPICK__CHERRYPICK__AUTO_ASSIGN_PR_IF_THERE_ARE_MERGE_CONFLICTS_OR_IF_THE_BUNDLE_VERSIONS_ARE_MISMATCHED__STEP_MOCK = utils.getMockStep( + 'Auto-assign PR if there are merge conflicts or if the bundle versions are mismatched', + 'Auto-assigning PR', + 'CHERRYPICK', + [], + ['GITHUB_TOKEN'], +); +const CHERRYPICK__CHERRYPICK__ASSIGN_THE_PR_TO_THE_DEPLOYER__STEP_MOCK = utils.getMockStep( + 'Assign the PR to the deployer', + 'Assigning the PR to the deployer', + 'CHERRYPICK', + [], + ['GITHUB_TOKEN'], +); +const CHERRYPICK__CHERRYPICK__IF_PR_HAS_MERGE_CONFLICTS_COMMENT_WITH_INSTRUCTIONS_FOR_ASSIGNEE__STEP_MOCK = utils.getMockStep( + 'If PR has merge conflicts, comment with instructions for assignee', + 'Commenting with instructions for assignee', + 'CHERRYPICK', + [], + ['GITHUB_TOKEN'], +); +const CHERRYPICK__CHERRYPICK__IF_PR_HAS_A_BUNDLE_VERSION_MISMATCH_COMMENT_WITH_THE_INSTRUCTIONS_FOR_ASSIGNEE__STEP_MOCK = utils.getMockStep( + 'If PR has a bundle version mismatch, comment with the instructions for assignee', + 'Commenting with the instructions for assignee', + 'CHERRYPICK', + [], + ['GITHUB_TOKEN'], +); +const CHERRYPICK__CHERRYPICK__AUTO_APPROVE_THE_PR__STEP_MOCK = utils.getMockStep( + 'Auto-approve the PR', + 'Auto-approving the PR', + 'CHERRYPICK', + [], + ['GITHUB_TOKEN'], +); +const CHERRYPICK__CHERRYPICK__CHECK_IF_PULL_REQUEST_IS_MERGEABLE_TRUE__STEP_MOCK = utils.getMockStep( + 'Check if pull request is mergeable', + 'Checking if pull request is mergeable', + 'CHERRYPICK', + ['GITHUB_TOKEN', 'PULL_REQUEST_NUMBER'], + [], + {IS_MERGEABLE: true}, +); +const CHERRYPICK__CHERRYPICK__CHECK_IF_PULL_REQUEST_IS_MERGEABLE_FALSE__STEP_MOCK = utils.getMockStep( + 'Check if pull request is mergeable', + 'Checking if pull request is mergeable', + 'CHERRYPICK', + ['GITHUB_TOKEN', 'PULL_REQUEST_NUMBER'], + [], + {IS_MERGEABLE: false}, +); +const CHERRYPICK__CHERRYPICK__AUTO_MERGE_THE_PR__STEP_MOCK = utils.getMockStep( + 'Auto-merge the PR', + 'Auto-merging the PR', + 'CHERRYPICK', + [], + ['GITHUB_TOKEN'], +); +const CHERRYPICK__CHERRYPICK__ANNOUNCES_A_CP_FAILURE_IN_THE_ANNOUNCE_SLACK_ROOM__STEP_MOCK = utils.getMockStep( + 'Announces a CP failure in the #announce Slack room', + 'Announcing a CP failure', + 'CHERRYPICK', + ['status'], + ['GITHUB_TOKEN', 'SLACK_WEBHOOK_URL'], +); + +const getCherryPickMockSteps = (upToDate, isMergeable, shouldMerge) => [ + CHERRYPICK__CHERRYPICK__CHECKOUT_STAGING_BRANCH__STEP_MOCK, + CHERRYPICK__CHERRYPICK__SET_UP_GIT_FOR_OSBOTIFY__STEP_MOCK, + CHERRYPICK__CHERRYPICK__CREATE_BRANCH_FOR_NEW_PULL_REQUEST__STEP_MOCK, + CHERRYPICK__CHERRYPICK__GET_MERGE_COMMIT_FOR_CP_PULL_REQUEST__STEP_MOCK, + CHERRYPICK__CHERRYPICK__GET_MERGE_COMMIT_FOR_VERSION_BUMP_PULL_REQUEST__STEP_MOCK, + CHERRYPICK__CHERRYPICK__CHERRY_PICK_THE_VERSION_BUMP_TO_NEW_BRANCH__STEP_MOCK, + shouldMerge ? CHERRYPICK__CHERRYPICK__CHERRY_PICK_THE_MERGE_COMMIT_OF_TARGET_PR_TO_NEW_BRANCH__SHOULD_MERGE__STEP_MOCK : CHERRYPICK__CHERRYPICK__CHERRY_PICK_THE_MERGE_COMMIT_OF_TARGET_PR_TO_NEW_BRANCH__SHOULD_NOT_MERGE__STEP_MOCK, + CHERRYPICK__CHERRYPICK__PUSH_CHANGES_TO_CP_BRANCH__STEP_MOCK, + CHERRYPICK__CHERRYPICK__CREATE_PULL_REQUEST__STEP_MOCK, + upToDate ? CHERRYPICK__CHERRYPICK__CHECK_IF_SHORTVERSIONSTRING_IS_UP_TO_DATE_TRUE__STEP_MOCK : CHERRYPICK__CHERRYPICK__CHECK_IF_SHORTVERSIONSTRING_IS_UP_TO_DATE_FALSE__STEP_MOCK, + CHERRYPICK__CHERRYPICK__AUTO_ASSIGN_PR_IF_THERE_ARE_MERGE_CONFLICTS_OR_IF_THE_BUNDLE_VERSIONS_ARE_MISMATCHED__STEP_MOCK, + CHERRYPICK__CHERRYPICK__ASSIGN_THE_PR_TO_THE_DEPLOYER__STEP_MOCK, + CHERRYPICK__CHERRYPICK__IF_PR_HAS_MERGE_CONFLICTS_COMMENT_WITH_INSTRUCTIONS_FOR_ASSIGNEE__STEP_MOCK, + CHERRYPICK__CHERRYPICK__IF_PR_HAS_A_BUNDLE_VERSION_MISMATCH_COMMENT_WITH_THE_INSTRUCTIONS_FOR_ASSIGNEE__STEP_MOCK, + CHERRYPICK__CHERRYPICK__AUTO_APPROVE_THE_PR__STEP_MOCK, + isMergeable ? CHERRYPICK__CHERRYPICK__CHECK_IF_PULL_REQUEST_IS_MERGEABLE_TRUE__STEP_MOCK : CHERRYPICK__CHERRYPICK__CHECK_IF_PULL_REQUEST_IS_MERGEABLE_FALSE__STEP_MOCK, + CHERRYPICK__CHERRYPICK__AUTO_MERGE_THE_PR__STEP_MOCK, + CHERRYPICK__CHERRYPICK__ANNOUNCES_A_CP_FAILURE_IN_THE_ANNOUNCE_SLACK_ROOM__STEP_MOCK, +]; + +module.exports = { + CHERRYPICK__VALIDATEACTOR__TRUE__STEP_MOCKS, + CHERRYPICK__VALIDATEACTOR__FALSE__STEP_MOCKS, + CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, + getCherryPickMockSteps, +}; diff --git a/workflow_tests/utils/preGenerateTest.js b/workflow_tests/utils/preGenerateTest.js index e011e3a200b0..1801eab4c4ad 100644 --- a/workflow_tests/utils/preGenerateTest.js +++ b/workflow_tests/utils/preGenerateTest.js @@ -195,7 +195,7 @@ const getMockFileContent = (workflowName, jobs) => { let mockStepsContent = `// ${jobId.toLowerCase()}`; const stepMocks = []; for (const step of job.steps) { - const stepMockName = `${workflowName.toUpperCase()}__${jobId.toUpperCase()}__${step.name.replaceAll(' ', '_').toUpperCase()}__STEP_MOCK`; + const stepMockName = `${workflowName.toUpperCase()}__${jobId.toUpperCase()}__${step.name.replaceAll(' ', '_').replaceAll('-', '_').replaceAll(',', '').replaceAll('#', '').toUpperCase()}__STEP_MOCK`; stepMocks.push(stepMockName); mockStepsContent += mockStepTemplate(stepMockName, step, jobId); } diff --git a/workflow_tests/utils/utils.js b/workflow_tests/utils/utils.js index 31c7ac0bceb4..867527ca566b 100644 --- a/workflow_tests/utils/utils.js +++ b/workflow_tests/utils/utils.js @@ -1,7 +1,7 @@ const yaml = require('yaml'); const fs = require('fs'); -const setUpActParams = (act, event = null, eventOptions = null, secrets = null, githubToken = null, envVars = null) => { +const setUpActParams = (act, event = null, eventOptions = null, secrets = null, githubToken = null, envVars = null, inputs = null) => { let updated_act = act; if (event && eventOptions) { @@ -31,6 +31,12 @@ const setUpActParams = (act, event = null, eventOptions = null, secrets = null, } } + if (inputs) { + for (const [key, value] of Object.entries(inputs)) { + updated_act = updated_act.setInput(key, value); + } + } + return updated_act; }; From 9ec9f8917bc41d419f2e20d492b30f11af3bdbd0 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Fri, 17 Mar 2023 15:22:32 +0100 Subject: [PATCH 054/504] Add tests Added test for the `cla.yml` workflow See: https://github.com/Expensify/App/issues/13604 --- .github/workflows/cla.yml | 8 +- workflow_tests/assertions/claAssertions.js | 64 ++++++ workflow_tests/cla.test.js | 230 +++++++++++++++++++++ workflow_tests/mocks/claMocks.js | 63 ++++++ 4 files changed, 362 insertions(+), 3 deletions(-) create mode 100644 workflow_tests/assertions/claAssertions.js create mode 100644 workflow_tests/cla.test.js create mode 100644 workflow_tests/mocks/claMocks.js diff --git a/.github/workflows/cla.yml b/.github/workflows/cla.yml index 8943669c2ba8..54ae1048b57b 100644 --- a/.github/workflows/cla.yml +++ b/.github/workflows/cla.yml @@ -13,18 +13,20 @@ jobs: # It does not run for pull requests created by OSBotify if: ${{ github.event.issue.pull_request || (github.event_name == 'pull_request_target' && github.event.pull_request.user.login != 'OSBotify') }} steps: - - uses: actions-ecosystem/action-regex-match@9c35fe9ac1840239939c59e5db8839422eed8a73 + - name: CLA comment check + uses: actions-ecosystem/action-regex-match@9c35fe9ac1840239939c59e5db8839422eed8a73 id: sign with: text: ${{ github.event.comment.body }} regex: '\s*I have read the CLA Document and I hereby sign the CLA\s*' - - uses: actions-ecosystem/action-regex-match@9c35fe9ac1840239939c59e5db8839422eed8a73 + - name: CLA comment re-check + uses: actions-ecosystem/action-regex-match@9c35fe9ac1840239939c59e5db8839422eed8a73 id: recheck with: text: ${{ github.event.comment.body }} regex: '\s*recheck\s*' - name: CLA Assistant - if: ${{ steps.recheck.outputs.match != '' || steps.sign.outputs.match != '' }} || github.event_name == 'pull_request_target' + if: ${{ steps.recheck.outputs.match != '' || steps.sign.outputs.match != '' || github.event_name == 'pull_request_target' }} # Version: 2.1.2-beta uses: cla-assistant/github-action@948230deb0d44dd38957592f08c6bd934d96d0cf env: diff --git a/workflow_tests/assertions/claAssertions.js b/workflow_tests/assertions/claAssertions.js new file mode 100644 index 000000000000..1056f0dc5f78 --- /dev/null +++ b/workflow_tests/assertions/claAssertions.js @@ -0,0 +1,64 @@ +const utils = require('../utils/utils'); + +const assertCLAJobExecuted = (workflowResult, commentBody = '', githubRepository = '', didExecute = true, runAssitant = true) => { + const steps = [ + utils.getStepAssertion( + 'CLA comment check', + true, + null, + 'CLA', + 'CLA comment check', + [{key: 'text', value: commentBody}, {key: 'regex', value: '\\s*I have read the CLA Document and I hereby sign the CLA\\s*'}], + [], + ), + utils.getStepAssertion( + 'CLA comment re-check', + true, + null, + 'CLA', + 'CLA comment re-check', + [{key: 'text', value: commentBody}, {key: 'regex', value: '\\s*recheck\\s*'}], + [], + ), + ]; + + for (const expectedStep of steps) { + if (didExecute) { + expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); + } else { + expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); + } + } + + const assistantSteps = [ + utils.getStepAssertion( + 'CLA Assistant', + true, + null, + 'CLA', + 'CLA Assistant', + [ + {key: 'path-to-signatures', value: `${githubRepository}/cla.json`}, + {key: 'path-to-document', value: `https://github.com/${githubRepository}/blob/main/contributingGuides/CLA.md`}, + {key: 'branch', value: 'main'}, + {key: 'remote-organization-name', value: 'Expensify'}, + {key: 'remote-repository-name', value: 'CLA'}, + {key: 'lock-pullrequest-aftermerge', value: false}, + {key: 'allowlist', value: 'OSBotify,snyk-bot'}, + ], + [{key: 'GITHUB_TOKEN', value: '***'}, {key: 'PERSONAL_ACCESS_TOKEN', value: '***'}], + ), + ]; + + for (const step of assistantSteps) { + if (didExecute && runAssitant) { + expect(workflowResult).toEqual(expect.arrayContaining([step])); + } else { + expect(workflowResult).not.toEqual(expect.arrayContaining([step])); + } + } +}; + +module.exports = { + assertCLAJobExecuted, +}; diff --git a/workflow_tests/cla.test.js b/workflow_tests/cla.test.js new file mode 100644 index 000000000000..abc87098e3cb --- /dev/null +++ b/workflow_tests/cla.test.js @@ -0,0 +1,230 @@ +const path = require('path'); +const kieMockGithub = require('@kie/mock-github'); +const utils = require('./utils/utils'); +const assertions = require('./assertions/claAssertions'); +const mocks = require('./mocks/claMocks'); +const eAct = require('./utils/ExtendedAct'); + +let mockGithub; +const FILES_TO_COPY_INTO_TEST_REPO = [ + { + src: path.resolve(__dirname, '..', '.github', 'actions'), + dest: '.github/actions', + }, + { + src: path.resolve(__dirname, '..', '.github', 'libs'), + dest: '.github/libs', + }, + { + src: path.resolve(__dirname, '..', '.github', 'scripts'), + dest: '.github/scripts', + }, + { + src: path.resolve(__dirname, '..', '.github', 'workflows', 'cla.yml'), + dest: '.github/workflows/cla.yml', + }, +]; + +beforeEach(async () => { + // create a local repository and copy required files + mockGithub = new kieMockGithub.MockGithub({ + repo: { + testClaWorkflowRepo: { + files: FILES_TO_COPY_INTO_TEST_REPO, + }, + }, + }); + + await mockGithub.setup(); +}); + +afterEach(async () => { + await mockGithub.teardown(); +}); + +describe('test workflow cla', () => { + const secrets = { + CLA_BOTIFY_TOKEN: 'dummy_cla_botify_token', + }; + const githubToken = 'dummy_github_token'; + const actor = 'Dummy Author'; + describe('event is issue_comment', () => { + const event = 'issue_comment'; + describe('no regex matches', () => { + const commentBody = 'Comment body'; + const eventData = { + action: 'created', + issue: { + pull_request: { + number: 1234, + }, + }, + comment: { + body: commentBody, + }, + }; + test('workflow executes, CLA assistant step not run', async () => { + const repoPath = mockGithub.repo.getPath('testClaWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'cla.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + act = utils.setUpActParams( + act, + event, + eventData, + secrets, + githubToken, + ); + const testMockSteps = { + CLA: mocks.CLA__CLA__NO_MATCHES__STEP_MOCKS, + }; + const result = await act + .runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor, + }); + + assertions.assertCLAJobExecuted(result, commentBody, `${repoPath}/remote/origin`, true, false); + }, 60000); + }); + describe('check regex matches', () => { + const commentBody = 'I have read the CLA Document and I hereby sign the CLA'; + const eventData = { + action: 'created', + issue: { + pull_request: { + number: 1234, + }, + }, + comment: { + body: commentBody, + }, + }; + test('workflow executes, CLA assistant step run', async () => { + const repoPath = mockGithub.repo.getPath('testClaWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'cla.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + act = utils.setUpActParams( + act, + event, + eventData, + secrets, + githubToken, + ); + const testMockSteps = { + CLA: mocks.CLA__CLA__CHECK_MATCH__STEP_MOCKS, + }; + const result = await act + .runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor, + }); + + assertions.assertCLAJobExecuted(result, commentBody, `${repoPath}/remote/origin`, true, true); + }, 60000); + }); + describe('re-check regex matches', () => { + const commentBody = 'recheck'; + const eventData = { + action: 'created', + issue: { + pull_request: { + number: 1234, + }, + }, + comment: { + body: commentBody, + }, + }; + test('workflow executes, CLA assistant step run', async () => { + const repoPath = mockGithub.repo.getPath('testClaWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'cla.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + act = utils.setUpActParams( + act, + event, + eventData, + secrets, + githubToken, + ); + const testMockSteps = { + CLA: mocks.CLA__CLA__RECHECK_MATCH__STEP_MOCKS, + }; + const result = await act + .runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor, + }); + + assertions.assertCLAJobExecuted(result, commentBody, `${repoPath}/remote/origin`, true, true); + }, 60000); + }); + }); + describe('event is pull_request_target', () => { + const event = 'pull_request_target'; + describe('no regex matches - there\'s no comment', () => { + const eventData = { + action: 'opened', + issue: { + pull_request: { + number: 1234, + }, + }, + }; + test('workflow executes, CLA assistant step still run', async () => { + const repoPath = mockGithub.repo.getPath('testClaWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'cla.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + act = utils.setUpActParams( + act, + event, + eventData, + secrets, + githubToken, + ); + const testMockSteps = { + CLA: mocks.CLA__CLA__NO_MATCHES__STEP_MOCKS, + }; + const result = await act + .runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor, + }); + + assertions.assertCLAJobExecuted(result, '', `${repoPath}/remote/origin`, true, true); + }, 60000); + }); + }); + describe('different event', () => { + const event = 'push'; + test('workflow does not execute', async () => { + const eventData = { + ref: 'main', + }; + const repoPath = mockGithub.repo.getPath('testClaWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'cla.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + act = utils.setUpActParams( + act, + event, + eventData, + secrets, + githubToken, + ); + const testMockSteps = { + CLA: mocks.CLA__CLA__NO_MATCHES__STEP_MOCKS, + }; + const result = await act + .runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor, + }); + + assertions.assertCLAJobExecuted(result, '', `${repoPath}/remote/origin`, false); + }, 60000); + }); +}); diff --git a/workflow_tests/mocks/claMocks.js b/workflow_tests/mocks/claMocks.js new file mode 100644 index 000000000000..5fbf6ebe629f --- /dev/null +++ b/workflow_tests/mocks/claMocks.js @@ -0,0 +1,63 @@ +const utils = require('../utils/utils'); + +// cla +const CLA__CLA__CLA_COMMENT_CHECK__NO_MATCH__STEP_MOCK = utils.getMockStep( + 'CLA comment check', + 'CLA comment check', + 'CLA', + ['text', 'regex'], + [], + {match: ''}, +); +const CLA__CLA__CLA_COMMENT_CHECK__MATCH__STEP_MOCK = utils.getMockStep( + 'CLA comment check', + 'CLA comment check', + 'CLA', + ['text', 'regex'], + [], + {match: 'I have read the CLA Document and I hereby sign the CLA'}, +); +const CLA__CLA__CLA_COMMENT_RE_CHECK__NO_MATCH__STEP_MOCK = utils.getMockStep( + 'CLA comment re-check', + 'CLA comment re-check', + 'CLA', + ['text', 'regex'], + [], + {match: ''}, +); +const CLA__CLA__CLA_COMMENT_RE_CHECK__MATCH__STEP_MOCK = utils.getMockStep( + 'CLA comment re-check', + 'CLA comment re-check', + 'CLA', + ['text', 'regex'], + [], + {match: 'recheck'}, +); +const CLA__CLA__CLA_ASSISTANT__STEP_MOCK = utils.getMockStep( + 'CLA Assistant', + 'CLA Assistant', + 'CLA', + ['path-to-signatures', 'path-to-document', 'branch', 'remote-organization-name', 'remote-repository-name', 'lock-pullrequest-aftermerge', 'allowlist'], + ['GITHUB_TOKEN', 'PERSONAL_ACCESS_TOKEN'], +); +const CLA__CLA__NO_MATCHES__STEP_MOCKS = [ + CLA__CLA__CLA_COMMENT_CHECK__NO_MATCH__STEP_MOCK, + CLA__CLA__CLA_COMMENT_RE_CHECK__NO_MATCH__STEP_MOCK, + CLA__CLA__CLA_ASSISTANT__STEP_MOCK, +]; +const CLA__CLA__CHECK_MATCH__STEP_MOCKS = [ + CLA__CLA__CLA_COMMENT_CHECK__MATCH__STEP_MOCK, + CLA__CLA__CLA_COMMENT_RE_CHECK__NO_MATCH__STEP_MOCK, + CLA__CLA__CLA_ASSISTANT__STEP_MOCK, +]; +const CLA__CLA__RECHECK_MATCH__STEP_MOCKS = [ + CLA__CLA__CLA_COMMENT_CHECK__NO_MATCH__STEP_MOCK, + CLA__CLA__CLA_COMMENT_RE_CHECK__MATCH__STEP_MOCK, + CLA__CLA__CLA_ASSISTANT__STEP_MOCK, +]; + +module.exports = { + CLA__CLA__NO_MATCHES__STEP_MOCKS, + CLA__CLA__CHECK_MATCH__STEP_MOCKS, + CLA__CLA__RECHECK_MATCH__STEP_MOCKS, +}; From 9263449146caf40efafc531f147451bb94866d3a Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Fri, 24 Mar 2023 12:18:04 +0100 Subject: [PATCH 055/504] Add tests Added test for the `createNewVersion.yml` workflow See: https://github.com/Expensify/App/issues/13604 --- .github/workflows/createNewVersion.yml | 12 +- workflow_tests/README.md | 4 + .../assertions/createNewVersionAssertions.js | 130 +++++++++++ workflow_tests/createNewVersion.test.js | 220 ++++++++++++++++++ workflow_tests/mocks/createNewVersionMocks.js | 113 +++++++++ workflow_tests/utils/preGenerateTest.js | 7 +- workflow_tests/utils/utils.js | 2 +- 7 files changed, 479 insertions(+), 9 deletions(-) create mode 100644 workflow_tests/assertions/createNewVersionAssertions.js create mode 100644 workflow_tests/createNewVersion.test.js create mode 100644 workflow_tests/mocks/createNewVersionMocks.js diff --git a/.github/workflows/createNewVersion.yml b/.github/workflows/createNewVersion.yml index b8bcd71d0f08..7ac01e49fa46 100644 --- a/.github/workflows/createNewVersion.yml +++ b/.github/workflows/createNewVersion.yml @@ -47,15 +47,18 @@ jobs: steps: # Version: 3.0.2 - - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 + - name: Check out + uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 with: fetch-depth: 0 - - uses: Expensify/App/.github/actions/composite/setupGitForOSBotify@main + - name: Setup git for OSBotify + uses: Expensify/App/.github/actions/composite/setupGitForOSBotify@main with: GPG_PASSPHRASE: ${{ secrets.LARGE_SECRET_PASSPHRASE }} - - uses: softprops/turnstyle@ca99add00ff0c9cbc697d22631d2992f377e5bd5 + - name: Run turnstyle + uses: softprops/turnstyle@ca99add00ff0c9cbc697d22631d2992f377e5bd5 with: poll-interval-seconds: 10 env: @@ -95,7 +98,8 @@ jobs: OS_BOTIFY_TOKEN: ${{ secrets.OS_BOTIFY_TOKEN }} GPG_PASSPHRASE: ${{ secrets.LARGE_SECRET_PASSPHRASE }} - - if: ${{ failure() }} + - name: Announce failed workflow in Slack + if: ${{ failure() }} uses: Expensify/App/.github/actions/composite/announceFailedWorkflowInSlack@main with: SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} diff --git a/workflow_tests/README.md b/workflow_tests/README.md index e6b98f71ab5b..00d48da8e5fa 100644 --- a/workflow_tests/README.md +++ b/workflow_tests/README.md @@ -396,3 +396,7 @@ Assert results are as expected. This can, for example, include using `expect()` assertions.assertSomethingHappend(result); assertions.assertSomethingDidNotHappen(result, false); ``` + +## FAQ +### I'm positive that one of the jobs should run, but it doesn't - why? +#### Check the runner type (`runs-on`) it may not be set (which `Act` does not like) or it may be set one of the unsupported types (primarily the `macos-...` runner types). You can always overwrite the runner type with `utils.setJobRunners()` helper method diff --git a/workflow_tests/assertions/createNewVersionAssertions.js b/workflow_tests/assertions/createNewVersionAssertions.js new file mode 100644 index 000000000000..d867ef7395de --- /dev/null +++ b/workflow_tests/assertions/createNewVersionAssertions.js @@ -0,0 +1,130 @@ +const utils = require('../utils/utils'); + +const assertValidateActorJobExecuted = (workflowResult, didExecute = true) => { + const steps = [ + utils.getStepAssertion( + 'Get user permissions', + true, + null, + 'VALIDATEACTOR', + 'Get user permissions', + [], + [{key: 'GITHUB_TOKEN', value: '***'}], + ), + ]; + + for (const expectedStep of steps) { + if (didExecute) { + expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); + } else { + expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); + } + } +}; +const assertCreateNewVersionJobExecuted = (workflowResult, semverLevel = 'BUILD', didExecute = true, isSuccessful = true) => { + const steps = [ + utils.getStepAssertion( + 'Check out', + true, + null, + 'CREATENEWVERSION', + 'Check out', + [{key: 'fetch-depth', value: '0'}], + [], + ), + utils.getStepAssertion( + 'Setup git for OSBotify', + true, + null, + 'CREATENEWVERSION', + 'Setup git for OSBotify', + [{key: 'GPG_PASSPHRASE', value: '***'}], + [], + ), + utils.getStepAssertion( + 'Run turnstyle', + true, + null, + 'CREATENEWVERSION', + 'Run turnstyle', + [{key: 'poll-interval-seconds', value: '10'}], + [{key: 'GITHUB_TOKEN', value: '***'}], + ), + utils.getStepAssertion( + 'Create new branch', + true, + null, + 'CREATENEWVERSION', + 'Create new branch', + [], + [], + ), + utils.getStepAssertion( + 'Generate version', + true, + null, + 'CREATENEWVERSION', + 'Generate version', + [{key: 'GITHUB_TOKEN', value: '***'}, {key: 'SEMVER_LEVEL', value: semverLevel}], + [], + ), + utils.getStepAssertion( + 'Commit new version', + true, + null, + 'CREATENEWVERSION', + 'Commit new version', + [], + [], + ), + utils.getStepAssertion( + 'Update main branch', + true, + null, + 'CREATENEWVERSION', + 'Update main branch', + [ + {key: 'TARGET_BRANCH', value: 'main'}, + {key: 'SOURCE_BRANCH', value: `version-${semverLevel}-abcdef`}, + {key: 'OS_BOTIFY_TOKEN', value: '***'}, + {key: 'GPG_PASSPHRASE', value: '***'}, + ], + [], + ), + ]; + + for (const expectedStep of steps) { + if (didExecute) { + if (isSuccessful) { + expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); + } + } else { + expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); + } + } + + const failedSteps = [ + utils.getStepAssertion( + 'Announce failed workflow in Slack', + true, + null, + 'CREATENEWVERSION', + 'Announce failed workflow in Slack', + [{key: 'SLACK_WEBHOOK', value: '***'}], + [], + ), + ]; + + for (const step of failedSteps) { + if (didExecute && !isSuccessful) { + expect(workflowResult).toEqual(expect.arrayContaining([step])); + } else { + expect(workflowResult).not.toEqual(expect.arrayContaining([step])); + } + } +}; + +module.exports = { + assertValidateActorJobExecuted, + assertCreateNewVersionJobExecuted, +}; diff --git a/workflow_tests/createNewVersion.test.js b/workflow_tests/createNewVersion.test.js new file mode 100644 index 000000000000..e798926ed2c7 --- /dev/null +++ b/workflow_tests/createNewVersion.test.js @@ -0,0 +1,220 @@ +const path = require('path'); +const kieMockGithub = require('@kie/mock-github'); +const utils = require('./utils/utils'); +const assertions = require('./assertions/createNewVersionAssertions'); +const mocks = require('./mocks/createNewVersionMocks'); +const eAct = require('./utils/ExtendedAct'); + +jest.setTimeout(60 * 1000); // 60 sec +let mockGithub; +const FILES_TO_COPY_INTO_TEST_REPO = [ + { + src: path.resolve(__dirname, '..', '.github', 'actions'), + dest: '.github/actions', + }, + { + src: path.resolve(__dirname, '..', '.github', 'libs'), + dest: '.github/libs', + }, + { + src: path.resolve(__dirname, '..', '.github', 'scripts'), + dest: '.github/scripts', + }, + { + src: path.resolve(__dirname, '..', '.github', 'workflows', 'createNewVersion.yml'), + dest: '.github/workflows/createNewVersion.yml', + }, +]; + +describe('test workflow createNewVersion', () => { + beforeEach(async () => { + // create a local repository and copy required files + mockGithub = new kieMockGithub.MockGithub({ + repo: { + testCreateNewVersionWorkflowRepo: { + files: FILES_TO_COPY_INTO_TEST_REPO, + }, + }, + }); + + await mockGithub.setup(); + }); + + afterEach(async () => { + await mockGithub.teardown(); + }); + + describe('event is workflow_call', () => { + const event = 'workflow_call'; + const inputs = { + SEMVER_LEVEL: 'BUILD', + }; + const secrets = { + LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', + OS_BOTIFY_TOKEN: 'dummy_osbotify_token', + SLACK_WEBHOOK: 'dummy_webhook', + }; + const githubToken = 'dummy_github_token'; + + describe('actor is admin', () => { + const validateActorMockSteps = mocks.CREATENEWVERSION__VALIDATEACTOR__ADMIN__STEP_MOCKS; + it('executes full workflow', async () => { + const repoPath = mockGithub.repo.getPath('testCreateNewVersionWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'createNewVersion.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + act = utils.setUpActParams( + act, + event, + {}, + secrets, + githubToken, + {}, + inputs, + ); + act = utils.setJobRunners(act, {createNewVersion: 'ubuntu-latest'}, workflowPath); + const testMockSteps = { + validateActor: validateActorMockSteps, + createNewVersion: mocks.CREATENEWVERSION__CREATENEWVERSION__STEP_MOCKS, + }; + const result = await act + .runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor: 'Dummy Author', + }); + assertions.assertValidateActorJobExecuted(result); + assertions.assertCreateNewVersionJobExecuted(result); + }); + }); + + describe('actor is writer', () => { + const validateActorMockSteps = mocks.CREATENEWVERSION__VALIDATEACTOR__WRITER__STEP_MOCKS; + it('executes full workflow', async () => { + const repoPath = mockGithub.repo.getPath('testCreateNewVersionWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'createNewVersion.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + act = utils.setUpActParams( + act, + event, + {}, + secrets, + githubToken, + {}, + inputs, + ); + act = utils.setJobRunners(act, {createNewVersion: 'ubuntu-latest'}, workflowPath); + const testMockSteps = { + validateActor: validateActorMockSteps, + createNewVersion: mocks.CREATENEWVERSION__CREATENEWVERSION__STEP_MOCKS, + }; + const result = await act + .runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor: 'Dummy Author', + }); + assertions.assertValidateActorJobExecuted(result); + assertions.assertCreateNewVersionJobExecuted(result); + }); + }); + + describe('actor is reader', () => { + const validateActorMockSteps = mocks.CREATENEWVERSION__VALIDATEACTOR__NO_PERMISSION__STEP_MOCKS; + it('stops after validation', async () => { + const repoPath = mockGithub.repo.getPath('testCreateNewVersionWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'createNewVersion.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + act = utils.setUpActParams( + act, + event, + {}, + secrets, + githubToken, + {}, + inputs, + ); + act = utils.setJobRunners(act, {createNewVersion: 'ubuntu-latest'}, workflowPath); + const testMockSteps = { + validateActor: validateActorMockSteps, + createNewVersion: mocks.CREATENEWVERSION__CREATENEWVERSION__STEP_MOCKS, + }; + const result = await act + .runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor: 'Dummy Author', + }); + assertions.assertValidateActorJobExecuted(result); + assertions.assertCreateNewVersionJobExecuted(result, 'BUILD', false); + }); + }); + + describe('one step fails', () => { + it('announces failure on Slack', async () => { + const repoPath = mockGithub.repo.getPath('testCreateNewVersionWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'createNewVersion.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + act = utils.setUpActParams( + act, + event, + {}, + secrets, + githubToken, + {}, + inputs, + ); + act = utils.setJobRunners(act, {createNewVersion: 'ubuntu-latest'}, workflowPath); + const testMockSteps = { + validateActor: mocks.CREATENEWVERSION__VALIDATEACTOR__ADMIN__STEP_MOCKS, + createNewVersion: JSON.parse(JSON.stringify(mocks.CREATENEWVERSION__CREATENEWVERSION__STEP_MOCKS)), + }; + testMockSteps.createNewVersion[5] = utils.getMockStep( + 'Commit new version', + 'Commit new version', + 'CREATENEWVERSION', + [], + [], + [], + [], + false, + ); + const result = await act + .runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor: 'Dummy Author', + }); + assertions.assertValidateActorJobExecuted(result); + assertions.assertCreateNewVersionJobExecuted(result, 'BUILD', true, false); + }); + }); + + it('chooses source branch depending on the SEMVER_LEVEL', async () => { + const repoPath = mockGithub.repo.getPath('testCreateNewVersionWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'createNewVersion.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + act = utils.setUpActParams( + act, + event, + {}, + secrets, + githubToken, + {}, + {SEMVER_LEVEL: 'MAJOR'}, + ); + act = utils.setJobRunners(act, {createNewVersion: 'ubuntu-latest'}, workflowPath); + const testMockSteps = { + validateActor: mocks.CREATENEWVERSION__VALIDATEACTOR__ADMIN__STEP_MOCKS, + createNewVersion: mocks.CREATENEWVERSION__CREATENEWVERSION__STEP_MOCKS, + }; + const result = await act + .runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor: 'Dummy Author', + }); + assertions.assertValidateActorJobExecuted(result); + assertions.assertCreateNewVersionJobExecuted(result, 'MAJOR'); + }); + }); +}); diff --git a/workflow_tests/mocks/createNewVersionMocks.js b/workflow_tests/mocks/createNewVersionMocks.js new file mode 100644 index 000000000000..86b3e32c18b7 --- /dev/null +++ b/workflow_tests/mocks/createNewVersionMocks.js @@ -0,0 +1,113 @@ +const utils = require('../utils/utils'); + +// validateactor +const CREATENEWVERSION__VALIDATEACTOR__GET_USER_PERMISSIONS__ADMIN__STEP_MOCK = utils.getMockStep( + 'Get user permissions', + 'Get user permissions', + 'VALIDATEACTOR', + [], + ['GITHUB_TOKEN'], + {PERMISSION: 'admin'}, +); +const CREATENEWVERSION__VALIDATEACTOR__GET_USER_PERMISSIONS__WRITE__STEP_MOCK = utils.getMockStep( + 'Get user permissions', + 'Get user permissions', + 'VALIDATEACTOR', + [], + ['GITHUB_TOKEN'], + {PERMISSION: 'write'}, +); +const CREATENEWVERSION__VALIDATEACTOR__GET_USER_PERMISSIONS__NONE__STEP_MOCK = utils.getMockStep( + 'Get user permissions', + 'Get user permissions', + 'VALIDATEACTOR', + [], + ['GITHUB_TOKEN'], + {PERMISSION: 'read'}, +); +const CREATENEWVERSION__VALIDATEACTOR__ADMIN__STEP_MOCKS = [ + CREATENEWVERSION__VALIDATEACTOR__GET_USER_PERMISSIONS__ADMIN__STEP_MOCK, +]; +const CREATENEWVERSION__VALIDATEACTOR__WRITER__STEP_MOCKS = [ + CREATENEWVERSION__VALIDATEACTOR__GET_USER_PERMISSIONS__WRITE__STEP_MOCK, +]; +const CREATENEWVERSION__VALIDATEACTOR__NO_PERMISSION__STEP_MOCKS = [ + CREATENEWVERSION__VALIDATEACTOR__GET_USER_PERMISSIONS__NONE__STEP_MOCK, +]; + +// createnewversion +const CREATENEWVERSION__CREATENEWVERSION__CHECK_OUT__STEP_MOCK = utils.getMockStep( + 'Check out', + 'Check out', + 'CREATENEWVERSION', + ['fetch-depth'], + [], +); +const CREATENEWVERSION__CREATENEWVERSION__SETUP_GIT_FOR_OSBOTIFY__STEP_MOCK = utils.getMockStep( + 'Setup git for OSBotify', + 'Setup git for OSBotify', + 'CREATENEWVERSION', + ['GPG_PASSPHRASE'], + [], +); +const CREATENEWVERSION__CREATENEWVERSION__RUN_TURNSTYLE__STEP_MOCK = utils.getMockStep( + 'Run turnstyle', + 'Run turnstyle', + 'CREATENEWVERSION', + ['poll-interval-seconds'], + ['GITHUB_TOKEN'], +); +const CREATENEWVERSION__CREATENEWVERSION__CREATE_NEW_BRANCH__STEP_MOCK = utils.getMockStep( + 'Create new branch', + 'Create new branch', + 'CREATENEWVERSION', + [], + [], + [], + {VERSION_BRANCH: 'version-${{ github.event.inputs.SEMVER_LEVEL }}-abcdef'}, +); +const CREATENEWVERSION__CREATENEWVERSION__GENERATE_VERSION__STEP_MOCK = utils.getMockStep( + 'Generate version', + 'Generate version', + 'CREATENEWVERSION', + ['GITHUB_TOKEN', 'SEMVER_LEVEL'], + [], +); +const CREATENEWVERSION__CREATENEWVERSION__COMMIT_NEW_VERSION__STEP_MOCK = utils.getMockStep( + 'Commit new version', + 'Commit new version', + 'CREATENEWVERSION', + [], + [], +); +const CREATENEWVERSION__CREATENEWVERSION__UPDATE_MAIN_BRANCH__STEP_MOCK = utils.getMockStep( + 'Update main branch', + 'Update main branch', + 'CREATENEWVERSION', + ['TARGET_BRANCH', 'SOURCE_BRANCH', 'OS_BOTIFY_TOKEN', 'GPG_PASSPHRASE'], + [], +); +const CREATENEWVERSION__CREATENEWVERSION__ANNOUNCE_FAILED_WORKFLOW_IN_SLACK__STEP_MOCK = utils.getMockStep( + 'Announce failed workflow in Slack', + 'Announce failed workflow in Slack', + 'CREATENEWVERSION', + ['SLACK_WEBHOOK'], + [], +); +const CREATENEWVERSION__CREATENEWVERSION__STEP_MOCKS = [ + CREATENEWVERSION__CREATENEWVERSION__CHECK_OUT__STEP_MOCK, + CREATENEWVERSION__CREATENEWVERSION__SETUP_GIT_FOR_OSBOTIFY__STEP_MOCK, + CREATENEWVERSION__CREATENEWVERSION__RUN_TURNSTYLE__STEP_MOCK, + CREATENEWVERSION__CREATENEWVERSION__CREATE_NEW_BRANCH__STEP_MOCK, + CREATENEWVERSION__CREATENEWVERSION__GENERATE_VERSION__STEP_MOCK, + CREATENEWVERSION__CREATENEWVERSION__COMMIT_NEW_VERSION__STEP_MOCK, + CREATENEWVERSION__CREATENEWVERSION__UPDATE_MAIN_BRANCH__STEP_MOCK, + CREATENEWVERSION__CREATENEWVERSION__ANNOUNCE_FAILED_WORKFLOW_IN_SLACK__STEP_MOCK, +]; + +module.exports = { + CREATENEWVERSION__VALIDATEACTOR__ADMIN__STEP_MOCKS, + CREATENEWVERSION__VALIDATEACTOR__WRITER__STEP_MOCKS, + CREATENEWVERSION__VALIDATEACTOR__NO_PERMISSION__STEP_MOCKS, + CREATENEWVERSION__CREATENEWVERSION__STEP_MOCKS, +}; diff --git a/workflow_tests/utils/preGenerateTest.js b/workflow_tests/utils/preGenerateTest.js index 1801eab4c4ad..19d65dec4c4b 100644 --- a/workflow_tests/utils/preGenerateTest.js +++ b/workflow_tests/utils/preGenerateTest.js @@ -12,7 +12,6 @@ const workflowFileRegex = new RegExp(workflowFilePattern, 'g'); const capitalize = s => (s && s.charAt(0).toUpperCase() + s.slice(1)) || ''; const mockFileTemplate = (mockSteps, exports) => `const utils = require('../utils/utils'); - ${mockSteps} ${exports} `; @@ -128,11 +127,11 @@ const ${jobAssertionName} = (workflowResult, didExecute = true) => { };`; const mocksExportsTemplate = (jobMocks) => ` module.exports = { - ${jobMocks.map((jobMock) => `${jobMock},`)} + ${jobMocks.map((jobMock) => `${jobMock}`)} };`; const assertionsExportsTemplate = (jobAssertions) => ` module.exports = { - ${jobAssertions.map((jobAssertion) => `${jobAssertion},`)} + ${jobAssertions.map((jobAssertion) => `${jobAssertion}`)} };`; const checkArguments = (args) => { @@ -192,7 +191,7 @@ const getMockFileContent = (workflowName, jobs) => { let content = ''; const jobMocks = []; for (const [jobId, job] of Object.entries(jobs)) { - let mockStepsContent = `// ${jobId.toLowerCase()}`; + let mockStepsContent = `\n// ${jobId.toLowerCase()}`; const stepMocks = []; for (const step of job.steps) { const stepMockName = `${workflowName.toUpperCase()}__${jobId.toUpperCase()}__${step.name.replaceAll(' ', '_').replaceAll('-', '_').replaceAll(',', '').replaceAll('#', '').toUpperCase()}__STEP_MOCK`; diff --git a/workflow_tests/utils/utils.js b/workflow_tests/utils/utils.js index 867527ca566b..b6a7bb34e0e6 100644 --- a/workflow_tests/utils/utils.js +++ b/workflow_tests/utils/utils.js @@ -49,7 +49,7 @@ const getMockStep = (name, message, job_id = null, inputs = null, in_envs = null mockWithCommand += ` ${message}`; if (inputs) { for (const input of inputs) { - mockWithCommand += `, ${input}="\${{ inputs.${input} }}"`; + mockWithCommand += `, ${input}="\${{ inputs.${input} }}\${{ github.event.inputs.${input} }}"`; } } if (in_envs) { From 6fc2a6644332572a46558836d10b5a5cdb9d09ec Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Fri, 24 Mar 2023 13:12:03 +0100 Subject: [PATCH 056/504] Refactor tests Slightly refactored existing tests See: https://github.com/Expensify/App/issues/13604 --- workflow_tests/authorChecklist.test.js | 145 ++++++++++++---------- workflow_tests/cherryPick.test.js | 110 ++++++++-------- workflow_tests/cla.test.js | 55 ++++---- workflow_tests/deploy.test.js | 60 ++++----- workflow_tests/finishReleaseCycle.test.js | 50 ++++---- workflow_tests/lockDeploys.test.js | 66 +++++----- workflow_tests/platformDeploy.test.js | 44 +++---- workflow_tests/preDeploy.test.js | 108 ++++++++-------- 8 files changed, 323 insertions(+), 315 deletions(-) diff --git a/workflow_tests/authorChecklist.test.js b/workflow_tests/authorChecklist.test.js index 6beb778cea4b..23a96d7ee71c 100644 --- a/workflow_tests/authorChecklist.test.js +++ b/workflow_tests/authorChecklist.test.js @@ -5,6 +5,7 @@ const assertions = require('./assertions/authorChecklistAssertions'); const mocks = require('./mocks/authorChecklistMocks'); const eAct = require('./utils/ExtendedAct'); +jest.setTimeout(60 * 1000); let mockGithub; const FILES_TO_COPY_INTO_TEST_REPO = [ { @@ -25,190 +26,196 @@ const FILES_TO_COPY_INTO_TEST_REPO = [ }, ]; -beforeEach(async () => { - // create a local repository and copy required files - mockGithub = new kieMockGithub.MockGithub({ - repo: { - testAuthorChecklistWorkflowRepo: { - files: FILES_TO_COPY_INTO_TEST_REPO, +describe('test workflow authorChecklist', () => { + const githubToken = 'dummy_github_token'; + beforeEach(async () => { + // create a local repository and copy required files + mockGithub = new kieMockGithub.MockGithub({ + repo: { + testAuthorChecklistWorkflowRepo: { + files: FILES_TO_COPY_INTO_TEST_REPO, + }, }, - }, - }); - - await mockGithub.setup(); -}); + }); -afterEach(async () => { - await mockGithub.teardown(); -}); + await mockGithub.setup(); + }); -describe('test workflow authorChecklist', () => { + afterEach(async () => { + await mockGithub.teardown(); + }); describe('pull request opened', () => { + const event = 'pull_request'; + const eventOptions = { + action: 'opened', + }; describe('actor is not OSBotify', () => { - test('workflow executes', async () => { + const actor = 'Dummy Author'; + it('executes workflow', async () => { const repoPath = mockGithub.repo.getPath('testAuthorChecklistWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'authorChecklist.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams( act, - 'pull_request', - { - action: 'opened', - }, + event, + eventOptions, {}, - 'dummy_github_token', + githubToken, ); const testMockSteps = { checklist: mocks.AUTHORCHECKLIST__CHECKLIST__STEP_MOCKS, }; const result = await act - .runEvent('pull_request', { + .runEvent(event, { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, - actor: 'Dummy Author', + actor, }); assertions.assertChecklistJobExecuted(result); - }, 60000); + }); }); describe('actor is OSBotify', () => { - test('workflow does not execute', async () => { + const actor = 'OSBotify'; + it('does not execute workflow', async () => { const repoPath = mockGithub.repo.getPath('testAuthorChecklistWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'authorChecklist.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams( act, - 'pull_request', - { - action: 'opened', - }, + event, + eventOptions, {}, - 'dummy_github_token', + githubToken, ); const testMockSteps = { checklist: mocks.AUTHORCHECKLIST__CHECKLIST__STEP_MOCKS, }; const result = await act - .runEvent('pull_request', { + .runEvent(event, { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, - actor: 'OSBotify', + actor, }); assertions.assertChecklistJobExecuted(result, false); - }, 60000); + }); }); }); describe('pull request edited', () => { + const event = 'pull_request'; + const eventOptions = { + action: 'edited', + }; describe('actor is not OSBotify', () => { - test('workflow executes', async () => { + const actor = 'Dummy Author'; + it('executes workflow', async () => { const repoPath = mockGithub.repo.getPath('testAuthorChecklistWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'authorChecklist.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams( act, - 'pull_request', - { - action: 'edited', - }, + event, + eventOptions, {}, - 'dummy_github_token', + githubToken, ); const testMockSteps = { checklist: mocks.AUTHORCHECKLIST__CHECKLIST__STEP_MOCKS, }; const result = await act - .runEvent('pull_request', { + .runEvent(event, { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, - actor: 'Dummy Author', + actor, }); assertions.assertChecklistJobExecuted(result); - }, 60000); + }); }); describe('actor is OSBotify', () => { - test('workflow does not execute', async () => { + const actor = 'OSBotify'; + it('does not execute workflow', async () => { const repoPath = mockGithub.repo.getPath('testAuthorChecklistWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'authorChecklist.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams( act, - 'pull_request', - { - action: 'edited', - }, + event, + eventOptions, {}, - 'dummy_github_token', + githubToken, ); const testMockSteps = { checklist: mocks.AUTHORCHECKLIST__CHECKLIST__STEP_MOCKS, }; const result = await act - .runEvent('pull_request', { + .runEvent(event, { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, - actor: 'OSBotify', + actor, }); assertions.assertChecklistJobExecuted(result, false); - }, 60000); + }); }); }); describe('pull request reopened', () => { + const event = 'pull_request'; + const eventOptions = { + action: 'reopened', + }; describe('actor is not OSBotify', () => { - test('workflow executes', async () => { + const actor = 'Dummy Author'; + it('executes workflow', async () => { const repoPath = mockGithub.repo.getPath('testAuthorChecklistWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'authorChecklist.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams( act, - 'pull_request', - { - action: 'reopened', - }, + event, + eventOptions, {}, - 'dummy_github_token', + githubToken, ); const testMockSteps = { checklist: mocks.AUTHORCHECKLIST__CHECKLIST__STEP_MOCKS, }; const result = await act - .runEvent('pull_request', { + .runEvent(event, { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, - actor: 'Dummy Author', + actor, }); assertions.assertChecklistJobExecuted(result); - }, 60000); + }); }); describe('actor is OSBotify', () => { - test('workflow does not execute', async () => { + const actor = 'OSBotify'; + it('does not execute workflow', async () => { const repoPath = mockGithub.repo.getPath('testAuthorChecklistWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'authorChecklist.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams( act, - 'pull_request', - { - action: 'reopened', - }, + event, + eventOptions, {}, - 'dummy_github_token', + githubToken, ); const testMockSteps = { checklist: mocks.AUTHORCHECKLIST__CHECKLIST__STEP_MOCKS, }; const result = await act - .runEvent('pull_request', { + .runEvent(event, { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, - actor: 'OSBotify', + actor, }); assertions.assertChecklistJobExecuted(result, false); - }, 60000); + }); }); }); }); diff --git a/workflow_tests/cherryPick.test.js b/workflow_tests/cherryPick.test.js index ea593d1d7a52..9a95a2da038a 100644 --- a/workflow_tests/cherryPick.test.js +++ b/workflow_tests/cherryPick.test.js @@ -5,6 +5,7 @@ const assertions = require('./assertions/cherryPickAssertions'); const mocks = require('./mocks/cherryPickMocks'); const eAct = require('./utils/ExtendedAct'); +jest.setTimeout(60 * 1000); let mockGithub; const FILES_TO_COPY_INTO_TEST_REPO = [ { @@ -25,23 +26,6 @@ const FILES_TO_COPY_INTO_TEST_REPO = [ }, ]; -beforeEach(async () => { - // create a local repository and copy required files - mockGithub = new kieMockGithub.MockGithub({ - repo: { - testCherryPickWorkflowRepo: { - files: FILES_TO_COPY_INTO_TEST_REPO, - }, - }, - }); - - await mockGithub.setup(); -}); - -afterEach(async () => { - await mockGithub.teardown(); -}); - const runWorkflow = async (act, event, repoPath, testMockSteps, actor) => await act .runEvent(event, { workflowFile: path.join(repoPath, '.github', 'workflows'), @@ -74,6 +58,22 @@ const setUpActParams = (act, event, newVersion) => utils.setUpActParams( ); describe('test workflow cherryPick', () => { + beforeEach(async () => { + // create a local repository and copy required files + mockGithub = new kieMockGithub.MockGithub({ + repo: { + testCherryPickWorkflowRepo: { + files: FILES_TO_COPY_INTO_TEST_REPO, + }, + }, + }); + + await mockGithub.setup(); + }); + + afterEach(async () => { + await mockGithub.teardown(); + }); describe('manual workflow dispatch', () => { const event = 'workflow_dispatch'; describe('actor is not deployer', () => { @@ -83,7 +83,7 @@ describe('test workflow cherryPick', () => { cherryPick: mocks.getCherryPickMockSteps(true, true, true), }; const actor = 'Dummy Author'; - test('workflow ends after validate job', async () => { + it('workflow ends after validate job', async () => { const repoPath = mockGithub.repo.getPath('testCherryPickWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); @@ -113,7 +113,7 @@ describe('test workflow cherryPick', () => { assertions.assertValidateActorJobExecuted(result, actor); assertions.assertCreateNewVersionJobExecuted(result, false); assertions.assertCherryPickJobExecuted(result, actor, '1234', '1.2.3', false); - }, 60000); + }); }); describe('actor is OSBotify', () => { const testMockSteps = { @@ -125,7 +125,7 @@ describe('test workflow cherryPick', () => { const mergeConflicts = false; const versionsMatch = true; const prIsMergeable = true; - test('behaviour is the same as with actor being the deployer', async () => { + it('behaviour is the same as with actor being the deployer', async () => { const pathsAndAct = getPathsAndAct(); const repoPath = pathsAndAct.repoPath; let act = pathsAndAct.act; @@ -147,7 +147,7 @@ describe('test workflow cherryPick', () => { prIsMergeable, newVersion, ); - }, 60000); + }); }); describe('actor is a deployer', () => { const testMockSteps = { @@ -163,7 +163,7 @@ describe('test workflow cherryPick', () => { const versionsMatch = true; describe('PR is mergeable', () => { const prIsMergeable = true; - test('workflow executes, new version created, PR approved and merged automatically', async () => { + it('workflow executes, new version created, PR approved and merged automatically', async () => { const pathsAndAct = getPathsAndAct(); const repoPath = pathsAndAct.repoPath; let act = pathsAndAct.act; @@ -185,11 +185,11 @@ describe('test workflow cherryPick', () => { prIsMergeable, newVersion, ); - }, 60000); + }); }); describe('PR is not mergeable', () => { const prIsMergeable = false; - test('workflow executes, new version created, PR is not merged automatically', async () => { + it('workflow executes, new version created, PR is not merged automatically', async () => { const pathsAndAct = getPathsAndAct(); const repoPath = pathsAndAct.repoPath; let act = pathsAndAct.act; @@ -211,14 +211,14 @@ describe('test workflow cherryPick', () => { prIsMergeable, newVersion, ); - }, 60000); + }); }); }); describe('version do not match', () => { const versionsMatch = false; describe('PR is mergeable', () => { const prIsMergeable = true; - test('workflow executes, new version created, PR auto-assigned and commented, approved and merged automatically', async () => { + it('workflow executes, new version created, PR auto-assigned and commented, approved and merged automatically', async () => { const pathsAndAct = getPathsAndAct(); const repoPath = pathsAndAct.repoPath; let act = pathsAndAct.act; @@ -240,11 +240,11 @@ describe('test workflow cherryPick', () => { prIsMergeable, newVersion, ); - }, 60000); + }); }); describe('PR is not mergeable', () => { const prIsMergeable = false; - test('workflow executes, new version created, PR auto-assigned and commented, not merged automatically', async () => { + it('workflow executes, new version created, PR auto-assigned and commented, not merged automatically', async () => { const pathsAndAct = getPathsAndAct(); const repoPath = pathsAndAct.repoPath; let act = pathsAndAct.act; @@ -266,7 +266,7 @@ describe('test workflow cherryPick', () => { prIsMergeable, newVersion, ); - }, 60000); + }); }); }); }); @@ -276,7 +276,7 @@ describe('test workflow cherryPick', () => { const versionsMatch = true; describe('PR is mergeable', () => { const prIsMergeable = true; - test('workflow executes, new version created, PR auto-assigned and commented, not merged automatically', async () => { + it('workflow executes, new version created, PR auto-assigned and commented, not merged automatically', async () => { const pathsAndAct = getPathsAndAct(); const repoPath = pathsAndAct.repoPath; let act = pathsAndAct.act; @@ -298,11 +298,11 @@ describe('test workflow cherryPick', () => { prIsMergeable, newVersion, ); - }, 60000); + }); }); describe('PR is not mergeable', () => { const prIsMergeable = false; - test('workflow executes, new version created, PR auto-assigned and commented, not merged automatically', async () => { + it('workflow executes, new version created, PR auto-assigned and commented, not merged automatically', async () => { const pathsAndAct = getPathsAndAct(); const repoPath = pathsAndAct.repoPath; let act = pathsAndAct.act; @@ -324,14 +324,14 @@ describe('test workflow cherryPick', () => { prIsMergeable, newVersion, ); - }, 60000); + }); }); }); describe('version do not match', () => { const versionsMatch = false; describe('PR is mergeable', () => { const prIsMergeable = true; - test('workflow executes, new version created, PR auto-assigned and commented, not merged automatically', async () => { + it('workflow executes, new version created, PR auto-assigned and commented, not merged automatically', async () => { const pathsAndAct = getPathsAndAct(); const repoPath = pathsAndAct.repoPath; let act = pathsAndAct.act; @@ -353,11 +353,11 @@ describe('test workflow cherryPick', () => { prIsMergeable, newVersion, ); - }, 60000); + }); }); describe('PR is not mergeable', () => { const prIsMergeable = false; - test('workflow executes, new version created, PR auto-assigned and commented, not merged automatically', async () => { + it('workflow executes, new version created, PR auto-assigned and commented, not merged automatically', async () => { const pathsAndAct = getPathsAndAct(); const repoPath = pathsAndAct.repoPath; let act = pathsAndAct.act; @@ -379,7 +379,7 @@ describe('test workflow cherryPick', () => { prIsMergeable, newVersion, ); - }, 60000); + }); }); }); }); @@ -393,7 +393,7 @@ describe('test workflow cherryPick', () => { const versionsMatch = true; describe('PR is mergeable', () => { const prIsMergeable = true; - test('workflow executes, PR approved and merged automatically', async () => { + it('workflow executes, PR approved and merged automatically', async () => { const pathsAndAct = getPathsAndAct(); const repoPath = pathsAndAct.repoPath; let act = pathsAndAct.act; @@ -415,11 +415,11 @@ describe('test workflow cherryPick', () => { prIsMergeable, newVersion, ); - }, 60000); + }); }); describe('PR is not mergeable', () => { const prIsMergeable = false; - test('workflow executes, PR is not merged automatically', async () => { + it('workflow executes, PR is not merged automatically', async () => { const pathsAndAct = getPathsAndAct(); const repoPath = pathsAndAct.repoPath; let act = pathsAndAct.act; @@ -441,14 +441,14 @@ describe('test workflow cherryPick', () => { prIsMergeable, newVersion, ); - }, 60000); + }); }); }); describe('version do not match', () => { const versionsMatch = false; describe('PR is mergeable', () => { const prIsMergeable = true; - test('workflow executes, PR auto-assigned and commented, approved and merged automatically', async () => { + it('workflow executes, PR auto-assigned and commented, approved and merged automatically', async () => { const pathsAndAct = getPathsAndAct(); const repoPath = pathsAndAct.repoPath; let act = pathsAndAct.act; @@ -470,11 +470,11 @@ describe('test workflow cherryPick', () => { prIsMergeable, newVersion, ); - }, 60000); + }); }); describe('PR is not mergeable', () => { const prIsMergeable = false; - test('workflow executes, PR auto-assigned and commented, not merged automatically', async () => { + it('workflow executes, PR auto-assigned and commented, not merged automatically', async () => { const pathsAndAct = getPathsAndAct(); const repoPath = pathsAndAct.repoPath; let act = pathsAndAct.act; @@ -496,7 +496,7 @@ describe('test workflow cherryPick', () => { prIsMergeable, newVersion, ); - }, 60000); + }); }); }); }); @@ -506,7 +506,7 @@ describe('test workflow cherryPick', () => { const versionsMatch = true; describe('PR is mergeable', () => { const prIsMergeable = true; - test('workflow executes, PR auto-assigned and commented, not merged automatically', async () => { + it('workflow executes, PR auto-assigned and commented, not merged automatically', async () => { const pathsAndAct = getPathsAndAct(); const repoPath = pathsAndAct.repoPath; let act = pathsAndAct.act; @@ -528,11 +528,11 @@ describe('test workflow cherryPick', () => { prIsMergeable, newVersion, ); - }, 60000); + }); }); describe('PR is not mergeable', () => { const prIsMergeable = false; - test('workflow executes, PR auto-assigned and commented, not merged automatically', async () => { + it('workflow executes, PR auto-assigned and commented, not merged automatically', async () => { const pathsAndAct = getPathsAndAct(); const repoPath = pathsAndAct.repoPath; let act = pathsAndAct.act; @@ -554,14 +554,14 @@ describe('test workflow cherryPick', () => { prIsMergeable, newVersion, ); - }, 60000); + }); }); }); describe('version do not match', () => { const versionsMatch = false; describe('PR is mergeable', () => { const prIsMergeable = true; - test('workflow executes, PR auto-assigned and commented, not merged automatically', async () => { + it('workflow executes, PR auto-assigned and commented, not merged automatically', async () => { const pathsAndAct = getPathsAndAct(); const repoPath = pathsAndAct.repoPath; let act = pathsAndAct.act; @@ -583,11 +583,11 @@ describe('test workflow cherryPick', () => { prIsMergeable, newVersion, ); - }, 60000); + }); }); describe('PR is not mergeable', () => { const prIsMergeable = false; - test('workflow executes, PR auto-assigned and commented, not merged automatically', async () => { + it('workflow executes, PR auto-assigned and commented, not merged automatically', async () => { const pathsAndAct = getPathsAndAct(); const repoPath = pathsAndAct.repoPath; let act = pathsAndAct.act; @@ -609,7 +609,7 @@ describe('test workflow cherryPick', () => { prIsMergeable, newVersion, ); - }, 60000); + }); }); }); }); @@ -618,7 +618,7 @@ describe('test workflow cherryPick', () => { }); describe('autmatic trigger', () => { const event = 'pull_request'; - test('workflow does not execute', async () => { + it('workflow does not execute', async () => { const repoPath = mockGithub.repo.getPath('testCherryPickWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); @@ -653,6 +653,6 @@ describe('test workflow cherryPick', () => { assertions.assertValidateActorJobExecuted(result, 'Dummy Author', false); assertions.assertCreateNewVersionJobExecuted(result, false); assertions.assertCherryPickJobExecuted(result, 'Dummy Author', '1234', '1.2.3', false); - }, 60000); + }); }); }); diff --git a/workflow_tests/cla.test.js b/workflow_tests/cla.test.js index abc87098e3cb..9034e51700b7 100644 --- a/workflow_tests/cla.test.js +++ b/workflow_tests/cla.test.js @@ -5,6 +5,7 @@ const assertions = require('./assertions/claAssertions'); const mocks = require('./mocks/claMocks'); const eAct = require('./utils/ExtendedAct'); +jest.setTimeout(60 * 1000); let mockGithub; const FILES_TO_COPY_INTO_TEST_REPO = [ { @@ -25,29 +26,29 @@ const FILES_TO_COPY_INTO_TEST_REPO = [ }, ]; -beforeEach(async () => { - // create a local repository and copy required files - mockGithub = new kieMockGithub.MockGithub({ - repo: { - testClaWorkflowRepo: { - files: FILES_TO_COPY_INTO_TEST_REPO, - }, - }, - }); - - await mockGithub.setup(); -}); - -afterEach(async () => { - await mockGithub.teardown(); -}); - describe('test workflow cla', () => { const secrets = { CLA_BOTIFY_TOKEN: 'dummy_cla_botify_token', }; const githubToken = 'dummy_github_token'; const actor = 'Dummy Author'; + + beforeEach(async () => { + // create a local repository and copy required files + mockGithub = new kieMockGithub.MockGithub({ + repo: { + testClaWorkflowRepo: { + files: FILES_TO_COPY_INTO_TEST_REPO, + }, + }, + }); + + await mockGithub.setup(); + }); + + afterEach(async () => { + await mockGithub.teardown(); + }); describe('event is issue_comment', () => { const event = 'issue_comment'; describe('no regex matches', () => { @@ -63,7 +64,7 @@ describe('test workflow cla', () => { body: commentBody, }, }; - test('workflow executes, CLA assistant step not run', async () => { + it('workflow executes, CLA assistant step not run', async () => { const repoPath = mockGithub.repo.getPath('testClaWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'cla.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); @@ -85,7 +86,7 @@ describe('test workflow cla', () => { }); assertions.assertCLAJobExecuted(result, commentBody, `${repoPath}/remote/origin`, true, false); - }, 60000); + }); }); describe('check regex matches', () => { const commentBody = 'I have read the CLA Document and I hereby sign the CLA'; @@ -100,7 +101,7 @@ describe('test workflow cla', () => { body: commentBody, }, }; - test('workflow executes, CLA assistant step run', async () => { + it('workflow executes, CLA assistant step run', async () => { const repoPath = mockGithub.repo.getPath('testClaWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'cla.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); @@ -122,7 +123,7 @@ describe('test workflow cla', () => { }); assertions.assertCLAJobExecuted(result, commentBody, `${repoPath}/remote/origin`, true, true); - }, 60000); + }); }); describe('re-check regex matches', () => { const commentBody = 'recheck'; @@ -137,7 +138,7 @@ describe('test workflow cla', () => { body: commentBody, }, }; - test('workflow executes, CLA assistant step run', async () => { + it('workflow executes, CLA assistant step run', async () => { const repoPath = mockGithub.repo.getPath('testClaWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'cla.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); @@ -159,7 +160,7 @@ describe('test workflow cla', () => { }); assertions.assertCLAJobExecuted(result, commentBody, `${repoPath}/remote/origin`, true, true); - }, 60000); + }); }); }); describe('event is pull_request_target', () => { @@ -173,7 +174,7 @@ describe('test workflow cla', () => { }, }, }; - test('workflow executes, CLA assistant step still run', async () => { + it('workflow executes, CLA assistant step still run', async () => { const repoPath = mockGithub.repo.getPath('testClaWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'cla.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); @@ -195,12 +196,12 @@ describe('test workflow cla', () => { }); assertions.assertCLAJobExecuted(result, '', `${repoPath}/remote/origin`, true, true); - }, 60000); + }); }); }); describe('different event', () => { const event = 'push'; - test('workflow does not execute', async () => { + it('workflow does not execute', async () => { const eventData = { ref: 'main', }; @@ -225,6 +226,6 @@ describe('test workflow cla', () => { }); assertions.assertCLAJobExecuted(result, '', `${repoPath}/remote/origin`, false); - }, 60000); + }); }); }); diff --git a/workflow_tests/deploy.test.js b/workflow_tests/deploy.test.js index d573630bcf00..89f18c35cfcb 100644 --- a/workflow_tests/deploy.test.js +++ b/workflow_tests/deploy.test.js @@ -5,6 +5,7 @@ const assertions = require('./assertions/deployAssertions'); const mocks = require('./mocks/deployMocks'); const eAct = require('./utils/ExtendedAct'); +jest.setTimeout(60 * 1000); let mockGithub; const FILES_TO_COPY_INTO_TEST_REPO = [ { @@ -25,27 +26,26 @@ const FILES_TO_COPY_INTO_TEST_REPO = [ }, ]; -beforeEach(async () => { - // create a local repository and copy required files - mockGithub = new kieMockGithub.MockGithub({ - repo: { - testDeployWorkflowRepo: { - files: FILES_TO_COPY_INTO_TEST_REPO, - pushedBranches: ['staging', 'production'], +describe('test workflow deploy', () => { + beforeEach(async () => { + // create a local repository and copy required files + mockGithub = new kieMockGithub.MockGithub({ + repo: { + testDeployWorkflowRepo: { + files: FILES_TO_COPY_INTO_TEST_REPO, + pushedBranches: ['staging', 'production'], + }, }, - }, - }); - - await mockGithub.setup(); -}); + }); -afterEach(async () => { - await mockGithub.teardown(); -}); + await mockGithub.setup(); + }); -describe('test workflow deploy', () => { + afterEach(async () => { + await mockGithub.teardown(); + }); describe('push as OSBotify', () => { - test('to main - nothing triggered', async () => { + it('to main - nothing triggered', async () => { const repoPath = mockGithub.repo.getPath('testDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'deploy.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); @@ -75,9 +75,9 @@ describe('test workflow deploy', () => { assertions.assertValidateJobExecuted(result); assertions.assertDeployStagingJobExecuted(result, false); assertions.assertDeployProductionJobExecuted(result, false); - }, 60000); + }); - test('to staging - deployStaging triggered', async () => { + it('to staging - deployStaging triggered', async () => { const repoPath = mockGithub.repo.getPath('testDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'deploy.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); @@ -107,9 +107,9 @@ describe('test workflow deploy', () => { assertions.assertValidateJobExecuted(result); assertions.assertDeployStagingJobExecuted(result); assertions.assertDeployProductionJobExecuted(result, false); - }, 60000); + }); - test('to production - deployProduction triggered', async () => { + it('to production - deployProduction triggered', async () => { const repoPath = mockGithub.repo.getPath('testDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'deploy.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); @@ -139,10 +139,10 @@ describe('test workflow deploy', () => { assertions.assertValidateJobExecuted(result); assertions.assertDeployStagingJobExecuted(result, false); assertions.assertDeployProductionJobExecuted(result); - }, 60000); + }); }); describe('push as user', () => { - test('to main - nothing triggered', async () => { + it('to main - nothing triggered', async () => { const repoPath = mockGithub.repo.getPath('testDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'deploy.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); @@ -172,9 +172,9 @@ describe('test workflow deploy', () => { assertions.assertValidateJobExecuted(result); assertions.assertDeployStagingJobExecuted(result, false); assertions.assertDeployProductionJobExecuted(result, false); - }, 60000); + }); - test('to staging - nothing triggered', async () => { + it('to staging - nothing triggered', async () => { const repoPath = mockGithub.repo.getPath('testDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'deploy.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); @@ -204,9 +204,9 @@ describe('test workflow deploy', () => { assertions.assertValidateJobExecuted(result); assertions.assertDeployStagingJobExecuted(result, false); assertions.assertDeployProductionJobExecuted(result, false); - }, 60000); + }); - test('to production - nothing triggered', async () => { + it('to production - nothing triggered', async () => { const repoPath = mockGithub.repo.getPath('testDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'deploy.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); @@ -236,10 +236,10 @@ describe('test workflow deploy', () => { assertions.assertValidateJobExecuted(result); assertions.assertDeployStagingJobExecuted(result, false); assertions.assertDeployProductionJobExecuted(result, false); - }, 60000); + }); }); - test('different event than push - workflow does not execute', async () => { + it('different event than push - workflow does not execute', async () => { const repoPath = mockGithub.repo.getPath('testdeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'deploy.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); @@ -290,5 +290,5 @@ describe('test workflow deploy', () => { assertions.assertValidateJobExecuted(result, false); assertions.assertDeployStagingJobExecuted(result, false); assertions.assertDeployProductionJobExecuted(result, false); - }, 60000); + }); }); diff --git a/workflow_tests/finishReleaseCycle.test.js b/workflow_tests/finishReleaseCycle.test.js index cb4263f3dd1a..16149b2cf07b 100644 --- a/workflow_tests/finishReleaseCycle.test.js +++ b/workflow_tests/finishReleaseCycle.test.js @@ -5,6 +5,7 @@ const assertions = require('./assertions/finishReleaseCycleAssertions'); const mocks = require('./mocks/finishReleaseCycleMocks'); const eAct = require('./utils/ExtendedAct'); +jest.setTimeout(60 * 1000); let mockGithub; const FILES_TO_COPY_INTO_TEST_REPO = [ { @@ -25,29 +26,28 @@ const FILES_TO_COPY_INTO_TEST_REPO = [ }, ]; -beforeEach(async () => { - // create a local repository and copy required files - mockGithub = new kieMockGithub.MockGithub({ - repo: { - testFinishReleaseCycleWorkflowRepo: { - files: FILES_TO_COPY_INTO_TEST_REPO, +describe('test workflow finishReleaseCycle', () => { + beforeEach(async () => { + // create a local repository and copy required files + mockGithub = new kieMockGithub.MockGithub({ + repo: { + testFinishReleaseCycleWorkflowRepo: { + files: FILES_TO_COPY_INTO_TEST_REPO, + }, }, - }, - }); - - await mockGithub.setup(); -}); + }); -afterEach(async () => { - await mockGithub.teardown(); -}); + await mockGithub.setup(); + }); -describe('test workflow finishReleaseCycle', () => { + afterEach(async () => { + await mockGithub.teardown(); + }); describe('issue closed', () => { describe('issue has StagingDeployCash', () => { describe('actor is a team member', () => { describe('no deploy blockers', () => { - test('production updated, new version created, new StagingDeployCash created', async () => { + it('production updated, new version created, new StagingDeployCash created', async () => { const repoPath = mockGithub.repo.getPath('testFinishReleaseCycleWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'finishReleaseCycle.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); @@ -86,9 +86,9 @@ describe('test workflow finishReleaseCycle', () => { assertions.assertUpdateProductionJobExecuted(result); assertions.assertCreateNewPatchVersionJobExecuted(result); assertions.assertCreateNewStagingDeployCashJobExecuted(result, '1.2.3'); - }, 60000); + }); describe('createNewStagingDeployCash fails', () => { - test('failure announced on Slack', async () => { + it('failure announced on Slack', async () => { const repoPath = mockGithub.repo.getPath('testFinishReleaseCycleWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'finishReleaseCycle.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); @@ -137,11 +137,11 @@ describe('test workflow finishReleaseCycle', () => { assertions.assertUpdateProductionJobExecuted(result); assertions.assertCreateNewPatchVersionJobExecuted(result); assertions.assertCreateNewStagingDeployCashJobExecuted(result, '1.2.3', true, false); - }, 60000); + }); }); }); describe('deploy blockers', () => { - test('production not updated, new version not created, new StagingDeployCash not created, issue reopened', async () => { + it('production not updated, new version not created, new StagingDeployCash not created, issue reopened', async () => { const repoPath = mockGithub.repo.getPath('testFinishReleaseCycleWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'finishReleaseCycle.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); @@ -180,11 +180,11 @@ describe('test workflow finishReleaseCycle', () => { assertions.assertUpdateProductionJobExecuted(result, false); assertions.assertCreateNewPatchVersionJobExecuted(result, false); assertions.assertCreateNewStagingDeployCashJobExecuted(result, '1.2.3', false); - }, 60000); + }); }); }); describe('actor is not a team member', () => { - test('production not updated, new version not created, new StagingDeployCash not created, issue reopened', async () => { + it('production not updated, new version not created, new StagingDeployCash not created, issue reopened', async () => { const repoPath = mockGithub.repo.getPath('testFinishReleaseCycleWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'finishReleaseCycle.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); @@ -223,11 +223,11 @@ describe('test workflow finishReleaseCycle', () => { assertions.assertUpdateProductionJobExecuted(result, false); assertions.assertCreateNewPatchVersionJobExecuted(result, false); assertions.assertCreateNewStagingDeployCashJobExecuted(result, '1.2.3', false); - }, 60000); + }); }); }); describe('issue does not have StagingDeployCash', () => { - test('validate job not run', async () => { + it('validate job not run', async () => { const repoPath = mockGithub.repo.getPath('testFinishReleaseCycleWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'finishReleaseCycle.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); @@ -268,7 +268,7 @@ describe('test workflow finishReleaseCycle', () => { assertions.assertUpdateProductionJobExecuted(result, false); assertions.assertCreateNewPatchVersionJobExecuted(result, false); assertions.assertCreateNewStagingDeployCashJobExecuted(result, '1.2.3', false); - }, 60000); + }); }); }); }); diff --git a/workflow_tests/lockDeploys.test.js b/workflow_tests/lockDeploys.test.js index 853b6cd6bac4..44979dbdf5f5 100644 --- a/workflow_tests/lockDeploys.test.js +++ b/workflow_tests/lockDeploys.test.js @@ -5,6 +5,7 @@ const assertions = require('./assertions/lockDeploysAssertions'); const mocks = require('./mocks/lockDeploysMocks'); const eAct = require('./utils/ExtendedAct'); +jest.setTimeout(60 * 1000); let mockGithub; const FILES_TO_COPY_INTO_TEST_REPO = [ { @@ -25,29 +26,28 @@ const FILES_TO_COPY_INTO_TEST_REPO = [ }, ]; -beforeEach(async () => { - // create a local repository and copy required files - mockGithub = new kieMockGithub.MockGithub({ - repo: { - testLockDeploysWorkflowRepo: { - files: FILES_TO_COPY_INTO_TEST_REPO, +describe('test workflow lockDeploys', () => { + beforeEach(async () => { + // create a local repository and copy required files + mockGithub = new kieMockGithub.MockGithub({ + repo: { + testLockDeploysWorkflowRepo: { + files: FILES_TO_COPY_INTO_TEST_REPO, + }, }, - }, - }); - - await mockGithub.setup(); -}); + }); -afterEach(async () => { - await mockGithub.teardown(); -}); + await mockGithub.setup(); + }); -describe('test workflow lockDeploys', () => { + afterEach(async () => { + await mockGithub.teardown(); + }); describe('issue labeled', () => { describe('label is LockCashDeploys', () => { describe('issue has StagingDeployCash', () => { describe('actor is not OSBotify', () => { - test('job triggered, comment left in StagingDeployCash', async () => { + it('job triggered, comment left in StagingDeployCash', async () => { const repoPath = mockGithub.repo.getPath('testLockDeploysWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'lockDeploys.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); @@ -89,9 +89,9 @@ describe('test workflow lockDeploys', () => { }); assertions.assertlockStagingDeploysJobExecuted(result); - }, 60000); + }); - test('one step fails, comment not left in StagingDeployCash, announced failure in Slack', async () => { + it('one step fails, comment not left in StagingDeployCash, announced failure in Slack', async () => { const repoPath = mockGithub.repo.getPath('testLockDeploysWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'lockDeploys.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); @@ -143,11 +143,11 @@ describe('test workflow lockDeploys', () => { }); assertions.assertlockStagingDeploysJobFailedAfterFirstStep(result); - }, 60000); + }); }); describe('actor is OSBotify', () => { - test('job not triggered, comment not left in StagingDeployCash', async () => { + it('job not triggered, comment not left in StagingDeployCash', async () => { const repoPath = mockGithub.repo.getPath('testLockDeploysWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'lockDeploys.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); @@ -189,13 +189,13 @@ describe('test workflow lockDeploys', () => { }); assertions.assertlockStagingDeploysJobExecuted(result, false); - }, 60000); + }); }); }); describe('issue does not have StagingDeployCash', () => { describe('actor is not OSBotify', () => { - test('job not triggered, comment not left in StagingDeployCash', async () => { + it('job not triggered, comment not left in StagingDeployCash', async () => { const repoPath = mockGithub.repo.getPath('testLockDeploysWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'lockDeploys.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); @@ -239,11 +239,11 @@ describe('test workflow lockDeploys', () => { }); assertions.assertlockStagingDeploysJobExecuted(result, false); - }, 60000); + }); }); describe('actor is OSBotify', () => { - test('job not triggered, comment not left in StagingDeployCash', async () => { + it('job not triggered, comment not left in StagingDeployCash', async () => { const repoPath = mockGithub.repo.getPath('testLockDeploysWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'lockDeploys.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); @@ -287,7 +287,7 @@ describe('test workflow lockDeploys', () => { }); assertions.assertlockStagingDeploysJobExecuted(result, false); - }, 60000); + }); }); }); }); @@ -295,7 +295,7 @@ describe('test workflow lockDeploys', () => { describe('label is not LockCashDeploys', () => { describe('issue has StagingDeployCash', () => { describe('actor is not OSBotify', () => { - test('job not triggered, comment not left in StagingDeployCash', async () => { + it('job not triggered, comment not left in StagingDeployCash', async () => { const repoPath = mockGithub.repo.getPath('testLockDeploysWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'lockDeploys.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); @@ -337,11 +337,11 @@ describe('test workflow lockDeploys', () => { }); assertions.assertlockStagingDeploysJobExecuted(result, false); - }, 60000); + }); }); describe('actor is OSBotify', () => { - test('job not triggered, comment not left in StagingDeployCash', async () => { + it('job not triggered, comment not left in StagingDeployCash', async () => { const repoPath = mockGithub.repo.getPath('testLockDeploysWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'lockDeploys.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); @@ -383,13 +383,13 @@ describe('test workflow lockDeploys', () => { }); assertions.assertlockStagingDeploysJobExecuted(result, false); - }, 60000); + }); }); }); describe('issue does not have StagingDeployCash', () => { describe('actor is not OSBotify', () => { - test('job not triggered, comment not left in StagingDeployCash', async () => { + it('job not triggered, comment not left in StagingDeployCash', async () => { const repoPath = mockGithub.repo.getPath('testLockDeploysWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'lockDeploys.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); @@ -433,11 +433,11 @@ describe('test workflow lockDeploys', () => { }); assertions.assertlockStagingDeploysJobExecuted(result, false); - }, 60000); + }); }); describe('actor is OSBotify', () => { - test('job not triggered, comment not left in StagingDeployCash', async () => { + it('job not triggered, comment not left in StagingDeployCash', async () => { const repoPath = mockGithub.repo.getPath('testLockDeploysWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'lockDeploys.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); @@ -481,7 +481,7 @@ describe('test workflow lockDeploys', () => { }); assertions.assertlockStagingDeploysJobExecuted(result, false); - }, 60000); + }); }); }); }); diff --git a/workflow_tests/platformDeploy.test.js b/workflow_tests/platformDeploy.test.js index f350758a2fca..d79e11908523 100644 --- a/workflow_tests/platformDeploy.test.js +++ b/workflow_tests/platformDeploy.test.js @@ -5,6 +5,7 @@ const assertions = require('./assertions/platformDeployAssertions'); const mocks = require('./mocks/platformDeployMocks'); const eAct = require('./utils/ExtendedAct'); +jest.setTimeout(60 * 1000); let mockGithub; const FILES_TO_COPY_INTO_TEST_REPO = [ { @@ -25,28 +26,27 @@ const FILES_TO_COPY_INTO_TEST_REPO = [ }, ]; -beforeEach(async () => { - // create a local repository and copy required files - mockGithub = new kieMockGithub.MockGithub({ - repo: { - testPlatformDeployWorkflowRepo: { - files: FILES_TO_COPY_INTO_TEST_REPO, - pushedBranches: [], +describe('test workflow platformDeploy', () => { + beforeEach(async () => { + // create a local repository and copy required files + mockGithub = new kieMockGithub.MockGithub({ + repo: { + testPlatformDeployWorkflowRepo: { + files: FILES_TO_COPY_INTO_TEST_REPO, + pushedBranches: [], + }, }, - }, - }); - - await mockGithub.setup(); -}); + }); -afterEach(async () => { - await mockGithub.teardown(); -}); + await mockGithub.setup(); + }); -describe('test workflow platformDeploy', () => { + afterEach(async () => { + await mockGithub.teardown(); + }); describe('push', () => { describe('tag', () => { - test('as team member - platform deploy executes on staging', async () => { + it('as team member - platform deploy executes on staging', async () => { const repoPath = mockGithub.repo.getPath('testPlatformDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'platformDeploy.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); @@ -116,9 +116,9 @@ describe('test workflow platformDeploy', () => { assertions.assertPostSlackOnFailureJobExecuted(result, false); assertions.assertPostSlackOnSuccessJobExecuted(result, true, false); assertions.assertPostGithubCommentJobExecuted(result, true, false); - }, 60000); + }); - test('as OSBotify - platform deploy executes on staging', async () => { + it('as OSBotify - platform deploy executes on staging', async () => { const repoPath = mockGithub.repo.getPath('testPlatformDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'platformDeploy.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); @@ -188,9 +188,9 @@ describe('test workflow platformDeploy', () => { assertions.assertPostSlackOnFailureJobExecuted(result, false); assertions.assertPostSlackOnSuccessJobExecuted(result, true, false); assertions.assertPostGithubCommentJobExecuted(result, true, false); - }, 60000); + }); - test('as outsider - platform deploy does not execute', async () => { + it('as outsider - platform deploy does not execute', async () => { const repoPath = mockGithub.repo.getPath('testPlatformDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'platformDeploy.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); @@ -260,7 +260,7 @@ describe('test workflow platformDeploy', () => { assertions.assertPostSlackOnFailureJobExecuted(result, false); assertions.assertPostSlackOnSuccessJobExecuted(result, false); assertions.assertPostGithubCommentJobExecuted(result, true, false, false); - }, 60000); + }); }); describe('branch', () => { diff --git a/workflow_tests/preDeploy.test.js b/workflow_tests/preDeploy.test.js index 2339b7390986..caecbb6a6318 100644 --- a/workflow_tests/preDeploy.test.js +++ b/workflow_tests/preDeploy.test.js @@ -5,6 +5,7 @@ const assertions = require('./assertions/preDeployAssertions'); const mocks = require('./mocks/preDeployMocks'); const eAct = require('./utils/ExtendedAct'); +jest.setTimeout(60 * 1000); let mockGithub; const FILES_TO_COPY_INTO_TEST_REPO = [ { @@ -25,26 +26,25 @@ const FILES_TO_COPY_INTO_TEST_REPO = [ }, ]; -beforeEach(async () => { - // create a local repository and copy required files - mockGithub = new kieMockGithub.MockGithub({ - repo: { - testPreDeployWorkflowRepo: { - files: FILES_TO_COPY_INTO_TEST_REPO, - pushedBranches: ['different_branch'], +describe('test workflow preDeploy', () => { + beforeEach(async () => { + // create a local repository and copy required files + mockGithub = new kieMockGithub.MockGithub({ + repo: { + testPreDeployWorkflowRepo: { + files: FILES_TO_COPY_INTO_TEST_REPO, + pushedBranches: ['different_branch'], + }, }, - }, - }); - - await mockGithub.setup(); -}); + }); -afterEach(async () => { - await mockGithub.teardown(); -}); + await mockGithub.setup(); + }); -describe('test workflow preDeploy', () => { - test('push to main - workflow executes', async () => { + afterEach(async () => { + await mockGithub.teardown(); + }); + it('push to main - workflow executes', async () => { // get path to the local test repo const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; @@ -97,10 +97,10 @@ describe('test workflow preDeploy', () => { assertions.assertSkipDeployJobExecuted(result, false); assertions.assertCreateNewVersionJobExecuted(result); assertions.assertUpdateStagingJobExecuted(result); - }, 60000); + }); // using a different branch does not seem to work as described in documentation - // test('push to different branch - workflow does not execute', async () => { + // it('push to different branch - workflow does not execute', async () => { // const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; // const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); // let act = new eAct.ExtendedAct(repoPath, workflowPath); @@ -141,9 +141,9 @@ describe('test workflow preDeploy', () => { // assertions.assertSkipDeployJobExecuted(result, false); // assertions.assertCreateNewVersionJobExecuted(result, false); // assertions.assertUpdateStagingJobExecuted(result, false); - // }, 60000); + // }); - test('different event than push - workflow does not execute', async () => { + it('different event than push - workflow does not execute', async () => { const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); @@ -209,10 +209,10 @@ describe('test workflow preDeploy', () => { assertions.assertSkipDeployJobExecuted(result, false); assertions.assertCreateNewVersionJobExecuted(result, false); assertions.assertUpdateStagingJobExecuted(result, false); - }, 60000); + }); describe('confirm passing build', () => { - test('lint job failed - workflow exits', async () => { + it('lint job failed - workflow exits', async () => { const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); @@ -289,9 +289,9 @@ describe('test workflow preDeploy', () => { assertions.assertSkipDeployJobExecuted(result, false); assertions.assertCreateNewVersionJobExecuted(result, false); assertions.assertUpdateStagingJobExecuted(result, false); - }, 60000); + }); - test('test job failed - workflow exits', async () => { + it('test job failed - workflow exits', async () => { const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); @@ -368,9 +368,9 @@ describe('test workflow preDeploy', () => { assertions.assertSkipDeployJobExecuted(result, false); assertions.assertCreateNewVersionJobExecuted(result, false); assertions.assertUpdateStagingJobExecuted(result, false); - }, 60000); + }); - test('lint and test job succeed - workflow continues', async () => { + it('lint and test job succeed - workflow continues', async () => { const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); @@ -409,11 +409,11 @@ describe('test workflow preDeploy', () => { assertions.assertSkipDeployJobExecuted(result, false); assertions.assertCreateNewVersionJobExecuted(result); assertions.assertUpdateStagingJobExecuted(result); - }, 60000); + }); }); describe('new contributor welcome message', () => { - test('actor is OSBotify - no comment left', async () => { + it('actor is OSBotify - no comment left', async () => { const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); @@ -450,9 +450,9 @@ describe('test workflow preDeploy', () => { assertions.assertE2ETestsJobExecuted(result, false); // Act does not support ubuntu-20.04-64core runner and omits the job assertions.assertChooseDeployActionsJobExecuted(result); assertions.assertNewContributorWelcomeMessageJobExecuted(result, false); - }, 60000); + }); - test('actor is Expensify employee - no comment left', async () => { + it('actor is Expensify employee - no comment left', async () => { const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); @@ -489,9 +489,9 @@ describe('test workflow preDeploy', () => { assertions.assertE2ETestsJobExecuted(result, false); // Act does not support ubuntu-20.04-64core runner and omits the job assertions.assertChooseDeployActionsJobExecuted(result); assertions.assertNewContributorWelcomeMessageJobExecuted(result, false); - }, 60000); + }); - test('actor is not Expensify employee, its not their first PR - job triggers, but no comment left', async () => { + it('actor is not Expensify employee, its not their first PR - job triggers, but no comment left', async () => { const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); @@ -528,9 +528,9 @@ describe('test workflow preDeploy', () => { assertions.assertE2ETestsJobExecuted(result, false); // Act does not support ubuntu-20.04-64core runner and omits the job assertions.assertChooseDeployActionsJobExecuted(result); assertions.assertNewContributorWelcomeMessageJobExecuted(result, true, false, false); - }, 60000); + }); - test('actor is not Expensify employee, and its their first PR - job triggers and comment left', async () => { + it('actor is not Expensify employee, and its their first PR - job triggers and comment left', async () => { const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); @@ -567,13 +567,13 @@ describe('test workflow preDeploy', () => { assertions.assertE2ETestsJobExecuted(result, false); // Act does not support ubuntu-20.04-64core runner and omits the job assertions.assertChooseDeployActionsJobExecuted(result); assertions.assertNewContributorWelcomeMessageJobExecuted(result, true, false, true); - }, 60000); + }); }); describe('choose deploy actions', () => { describe('no CP label', () => { describe('staging locked', () => { - test('not automated PR - deploy skipped and comment left', async () => { + it('not automated PR - deploy skipped and comment left', async () => { const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); @@ -611,9 +611,9 @@ describe('test workflow preDeploy', () => { assertions.assertCreateNewVersionJobExecuted(result, false); assertions.assertUpdateStagingJobExecuted(result, false, false); assertions.assertUpdateStagingJobFailed(result, false); - }, 60000); + }); - test('automated PR - deploy skipped, but no comment left', async () => { + it('automated PR - deploy skipped, but no comment left', async () => { const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); @@ -651,11 +651,11 @@ describe('test workflow preDeploy', () => { assertions.assertCreateNewVersionJobExecuted(result, false); assertions.assertUpdateStagingJobExecuted(result, false, false); assertions.assertUpdateStagingJobFailed(result, false); - }, 60000); + }); }); describe('staging not locked', () => { - test('not automated PR - proceed with deploy', async () => { + it('not automated PR - proceed with deploy', async () => { const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); @@ -697,9 +697,9 @@ describe('test workflow preDeploy', () => { assertions.assertCreateNewVersionJobExecuted(result); assertions.assertUpdateStagingJobExecuted(result, true, false); assertions.assertUpdateStagingJobFailed(result, false); - }, 60000); + }); - test('automated PR - deploy skipped, but no comment left', async () => { + it('automated PR - deploy skipped, but no comment left', async () => { const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); @@ -740,13 +740,13 @@ describe('test workflow preDeploy', () => { assertions.assertCreateNewVersionJobExecuted(result, false); assertions.assertUpdateStagingJobExecuted(result, false, false); assertions.assertUpdateStagingJobFailed(result, false); - }, 60000); + }); }); }); describe('CP label', () => { describe('staging locked', () => { - test('not automated PR - proceed with deploy', async () => { + it('not automated PR - proceed with deploy', async () => { const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); @@ -788,9 +788,9 @@ describe('test workflow preDeploy', () => { assertions.assertCreateNewVersionJobExecuted(result); assertions.assertUpdateStagingJobExecuted(result, true, true); assertions.assertUpdateStagingJobFailed(result, false); - }, 60000); + }); - test('automated PR - proceed with deploy', async () => { + it('automated PR - proceed with deploy', async () => { const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); @@ -832,11 +832,11 @@ describe('test workflow preDeploy', () => { assertions.assertCreateNewVersionJobExecuted(result); assertions.assertUpdateStagingJobExecuted(result, true, true); assertions.assertUpdateStagingJobFailed(result, false); - }, 60000); + }); }); describe('staging not locked', () => { - test('not automated PR - proceed with deploy', async () => { + it('not automated PR - proceed with deploy', async () => { const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); @@ -878,9 +878,9 @@ describe('test workflow preDeploy', () => { assertions.assertCreateNewVersionJobExecuted(result); assertions.assertUpdateStagingJobExecuted(result, true, false); assertions.assertUpdateStagingJobFailed(result, false); - }, 60000); + }); - test('automated PR - proceed with deploy', async () => { + it('automated PR - proceed with deploy', async () => { const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); @@ -922,11 +922,11 @@ describe('test workflow preDeploy', () => { assertions.assertCreateNewVersionJobExecuted(result); assertions.assertUpdateStagingJobExecuted(result, true, false); assertions.assertUpdateStagingJobFailed(result, false); - }, 60000); + }); }); }); - test('one of updateStaging steps failed - failure announced in Slack', async () => { + it('one of updateStaging steps failed - failure announced in Slack', async () => { const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); @@ -966,6 +966,6 @@ describe('test workflow preDeploy', () => { assertions.assertSkipDeployJobExecuted(result, false); assertions.assertCreateNewVersionJobExecuted(result); assertions.assertUpdateStagingJobFailed(result, true); - }, 60000); + }); }); }); From 1894bc2b2a34d1d5c87109f5f3e88466715fbe3c Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Fri, 24 Mar 2023 13:58:56 +0100 Subject: [PATCH 057/504] Add tests Added tests for `deployBlocker` workflow See: https://github.com/Expensify/App/issues/13604 --- .github/workflows/deployBlocker.yml | 6 +- .../assertions/deployBlockerAssertions.js | 105 +++++++++++ workflow_tests/createNewVersion.test.js | 2 +- workflow_tests/deployBlocker.test.js | 163 ++++++++++++++++++ workflow_tests/mocks/deployBlockerMocks.js | 71 ++++++++ workflow_tests/utils/preGenerateTest.js | 48 +++--- workflow_tests/utils/utils.js | 46 ++++- 7 files changed, 408 insertions(+), 33 deletions(-) create mode 100644 workflow_tests/assertions/deployBlockerAssertions.js create mode 100644 workflow_tests/deployBlocker.test.js create mode 100644 workflow_tests/mocks/deployBlockerMocks.js diff --git a/.github/workflows/deployBlocker.yml b/.github/workflows/deployBlocker.yml index 30e937722596..b001e0f3f643 100644 --- a/.github/workflows/deployBlocker.yml +++ b/.github/workflows/deployBlocker.yml @@ -11,7 +11,8 @@ jobs: if: ${{ github.event.label.name == 'DeployBlockerCash' }} steps: - - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 + - name: Checkout + uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 with: fetch-depth: 0 token: ${{ secrets.GITHUB_TOKEN }} @@ -64,7 +65,8 @@ jobs: 2. Find someone who can quickly fix the issue. 3. Fix the issue yourself. - - if: ${{ failure() }} + - name: Announce failed workflow in Slack + if: ${{ failure() }} uses: Expensify/App/.github/actions/composite/announceFailedWorkflowInSlack@main with: SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} diff --git a/workflow_tests/assertions/deployBlockerAssertions.js b/workflow_tests/assertions/deployBlockerAssertions.js new file mode 100644 index 000000000000..dbc1f18b737e --- /dev/null +++ b/workflow_tests/assertions/deployBlockerAssertions.js @@ -0,0 +1,105 @@ +const utils = require('../utils/utils'); + +const assertDeployBlockerJobExecuted = (workflowResult, issueTitle, issueNumber, didExecute = true, isSuccessful = true) => { + const steps = [ + utils.getStepAssertion( + 'Checkout', + true, + null, + 'DEPLOYBLOCKER', + 'Checkout', + [{key: 'fetch-depth', value: '0'}, {key: 'token', value: '***'}], + [], + ), + utils.getStepAssertion( + 'Get URL, title, & number of new deploy blocker (issue)', + true, + null, + 'DEPLOYBLOCKER', + 'Get URL, title and number of new deploy blocker - issue', + [], + [{key: 'TITLE', value: issueTitle}], + ), + utils.getStepAssertion( + 'Update StagingDeployCash with new deploy blocker', + true, + null, + 'DEPLOYBLOCKER', + 'Update StagingDeployCash with new deploy blocker', + [{key: 'GITHUB_TOKEN', value: '***'}], + [], + ), + utils.getStepAssertion( + 'Give the issue/PR the Hourly, Engineering labels', + true, + null, + 'DEPLOYBLOCKER', + 'Give the issue/PR the Hourly, Engineering labels', + [{key: 'add-labels', value: 'Hourly, Engineering'}, {key: 'remove-labels', value: 'Daily, Weekly, Monthly'}], + [], + ), + utils.getStepAssertion( + 'Comment on deferred PR', + true, + null, + 'DEPLOYBLOCKER', + 'Comment on deferred PR', + [{key: 'github_token', value: '***'}, {key: 'number', value: issueNumber}], + [], + ), + ]; + + for (const expectedStep of steps) { + if (didExecute) { + if (isSuccessful) { + expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); + } + } else { + expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); + } + } + + const successSteps = [ + utils.getStepAssertion( + 'Post the issue in the #expensify-open-source slack room', + true, + null, + 'DEPLOYBLOCKER', + 'Post the issue in the expensify-open-source slack room', + [{key: 'status', value: 'custom'}], + [{key: 'GITHUB_TOKEN', value: '***'}, {key: 'SLACK_WEBHOOK_URL', value: '***'}], + ), + ]; + + for (const step of successSteps) { + if (didExecute && isSuccessful) { + expect(workflowResult).toEqual(expect.arrayContaining([step])); + } else { + expect(workflowResult).not.toEqual(expect.arrayContaining([step])); + } + } + + const failedSteps = [ + utils.getStepAssertion( + 'Announce failed workflow in Slack', + true, + null, + 'DEPLOYBLOCKER', + 'Announce failed workflow in Slack', + [{key: 'SLACK_WEBHOOK', value: '***'}], + [], + ), + ]; + + for (const step of failedSteps) { + if (didExecute && !isSuccessful) { + expect(workflowResult).toEqual(expect.arrayContaining([step])); + } else { + expect(workflowResult).not.toEqual(expect.arrayContaining([step])); + } + } +}; + +module.exports = { + assertDeployBlockerJobExecuted, +}; diff --git a/workflow_tests/createNewVersion.test.js b/workflow_tests/createNewVersion.test.js index e798926ed2c7..e663eccfed7f 100644 --- a/workflow_tests/createNewVersion.test.js +++ b/workflow_tests/createNewVersion.test.js @@ -166,7 +166,7 @@ describe('test workflow createNewVersion', () => { act = utils.setJobRunners(act, {createNewVersion: 'ubuntu-latest'}, workflowPath); const testMockSteps = { validateActor: mocks.CREATENEWVERSION__VALIDATEACTOR__ADMIN__STEP_MOCKS, - createNewVersion: JSON.parse(JSON.stringify(mocks.CREATENEWVERSION__CREATENEWVERSION__STEP_MOCKS)), + createNewVersion: utils.deepCopy(mocks.CREATENEWVERSION__CREATENEWVERSION__STEP_MOCKS), }; testMockSteps.createNewVersion[5] = utils.getMockStep( 'Commit new version', diff --git a/workflow_tests/deployBlocker.test.js b/workflow_tests/deployBlocker.test.js new file mode 100644 index 000000000000..8a4fe393bfe0 --- /dev/null +++ b/workflow_tests/deployBlocker.test.js @@ -0,0 +1,163 @@ +const path = require('path'); +const kieMockGithub = require('@kie/mock-github'); +const utils = require('./utils/utils'); +const assertions = require('./assertions/deployBlockerAssertions'); +const mocks = require('./mocks/deployBlockerMocks'); +const eAct = require('./utils/ExtendedAct'); + +jest.setTimeout(60 * 1000); +let mockGithub; +const FILES_TO_COPY_INTO_TEST_REPO = [ + { + src: path.resolve(__dirname, '..', '.github', 'actions'), + dest: '.github/actions', + }, + { + src: path.resolve(__dirname, '..', '.github', 'libs'), + dest: '.github/libs', + }, + { + src: path.resolve(__dirname, '..', '.github', 'scripts'), + dest: '.github/scripts', + }, + { + src: path.resolve(__dirname, '..', '.github', 'workflows', 'deployBlocker.yml'), + dest: '.github/workflows/deployBlocker.yml', + }, +]; + +describe('test workflow deployBlocker', () => { + const githubToken = 'dummy_github_token'; + const actor = 'Dummy Author'; + const secrets = { + OS_BOTIFY_TOKEN: 'dummy_osbotify_token', + SLACK_WEBHOOK: 'dummy_slack_webhook', + }; + beforeEach(async () => { + // create a local repository and copy required files + mockGithub = new kieMockGithub.MockGithub({ + repo: { + testDeployBlockerWorkflowRepo: { + files: FILES_TO_COPY_INTO_TEST_REPO, + + // if any branches besides main are need add: pushedBranches: ['staging', 'production'], + }, + }, + }); + + await mockGithub.setup(); + }); + + afterEach(async () => { + await mockGithub.teardown(); + }); + describe('issue labeled', () => { + const event = 'issues'; + const eventOptions = { + action: 'labeled', + label: { + name: 'DeployBlockerCash', + }, + issue: { + title: 'Labeled issue title', + number: '1234', + html_url: 'http://issue.html.url', + }, + }; + describe('label is DeployBlockerCash', () => { + const testEventOptions = utils.deepCopy(eventOptions); + testEventOptions.label = {name: 'DeployBlockerCash'}; + it('runs the workflow and announces success on Slack', async () => { + const repoPath = mockGithub.repo.getPath('testDeployBlockerWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'deployBlocker.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + act = utils.setUpActParams( + act, + event, + testEventOptions, + secrets, + githubToken, + {}, + {}, + ); + const testMockSteps = { + deployBlocker: mocks.DEPLOYBLOCKER__DEPLOYBLOCKER__STEP_MOCKS, + }; + const result = await act + .runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor, + }); + + assertions.assertDeployBlockerJobExecuted(result, 'Labeled issue title', '1234'); + }); + describe('one step fails', () => { + it('announces failure on Slack', async () => { + const repoPath = mockGithub.repo.getPath('testDeployBlockerWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'deployBlocker.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + act = utils.setUpActParams( + act, + event, + testEventOptions, + secrets, + githubToken, + {}, + {}, + ); + const testMockSteps = { + deployBlocker: utils.deepCopy(mocks.DEPLOYBLOCKER__DEPLOYBLOCKER__STEP_MOCKS), + }; + testMockSteps.deployBlocker[2] = utils.getMockStep( + 'Update StagingDeployCash with new deploy blocker', + 'Update StagingDeployCash with new deploy blocker', + 'DEPLOYBLOCKER', + ['GITHUB_TOKEN'], + [], + {}, + {}, + false, + ); + const result = await act + .runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor, + }); + + assertions.assertDeployBlockerJobExecuted(result, 'Labeled issue title', '1234', true, false); + }); + }); + }); + describe('label is different', () => { + const testEventOptions = utils.deepCopy(eventOptions); + testEventOptions.label = {name: 'Different Label'}; + it('does not run workflow', async () => { + const repoPath = mockGithub.repo.getPath('testDeployBlockerWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'deployBlocker.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + act = utils.setUpActParams( + act, + event, + testEventOptions, + secrets, + githubToken, + {}, + {}, + ); + const testMockSteps = { + deployBlocker: mocks.DEPLOYBLOCKER__DEPLOYBLOCKER__STEP_MOCKS, + }; + const result = await act + .runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor, + }); + + assertions.assertDeployBlockerJobExecuted(result, '', '', false); + }); + }); + }); +}); diff --git a/workflow_tests/mocks/deployBlockerMocks.js b/workflow_tests/mocks/deployBlockerMocks.js new file mode 100644 index 000000000000..4c8410b70c4d --- /dev/null +++ b/workflow_tests/mocks/deployBlockerMocks.js @@ -0,0 +1,71 @@ +const utils = require('../utils/utils'); + +// deployblocker +const DEPLOYBLOCKER__DEPLOYBLOCKER__CHECKOUT__STEP_MOCK = utils.getMockStep( + 'Checkout', + 'Checkout', + 'DEPLOYBLOCKER', + ['fetch-depth', 'token'], + [], +); +const DEPLOYBLOCKER__DEPLOYBLOCKER__GET_URL_TITLE_AND_NUMBER_OF_NEW_DEPLOY_BLOCKER_ISSUE__STEP_MOCK = utils.getMockStep( + 'Get URL, title, & number of new deploy blocker (issue)', + 'Get URL, title and number of new deploy blocker - issue', + 'DEPLOYBLOCKER', + [], + ['TITLE'], + {}, + { + DEPLOY_BLOCKER_URL: '${{ github.event.issue.html_url }}', + DEPLOY_BLOCKER_NUMBER: '${{ github.event.issue.number }}', + DEPLOY_BLOCKER_TITLE: '${{ github.event.issue.title }}', + }, +); +const DEPLOYBLOCKER__DEPLOYBLOCKER__UPDATE_STAGINGDEPLOYCASH_WITH_NEW_DEPLOY_BLOCKER__STEP_MOCK = utils.getMockStep( + 'Update StagingDeployCash with new deploy blocker', + 'Update StagingDeployCash with new deploy blocker', + 'DEPLOYBLOCKER', + ['GITHUB_TOKEN'], + [], +); +const DEPLOYBLOCKER__DEPLOYBLOCKER__GIVE_THE_ISSUE_OR_PR_THE_HOURLY_ENGINEERING_LABELS__STEP_MOCK = utils.getMockStep( + 'Give the issue/PR the Hourly, Engineering labels', + 'Give the issue/PR the Hourly, Engineering labels', + 'DEPLOYBLOCKER', + ['add-labels', 'remove-labels'], + [], +); +const DEPLOYBLOCKER__DEPLOYBLOCKER__POST_THE_ISSUE_IN_THE_EXPENSIFY_OPEN_SOURCE_SLACK_ROOM__STEP_MOCK = utils.getMockStep( + 'Post the issue in the #expensify-open-source slack room', + 'Post the issue in the expensify-open-source slack room', + 'DEPLOYBLOCKER', + ['status'], + ['GITHUB_TOKEN', 'SLACK_WEBHOOK_URL'], +); +const DEPLOYBLOCKER__DEPLOYBLOCKER__COMMENT_ON_DEFERRED_PR__STEP_MOCK = utils.getMockStep( + 'Comment on deferred PR', + 'Comment on deferred PR', + 'DEPLOYBLOCKER', + ['github_token', 'number'], + [], +); +const DEPLOYBLOCKER__DEPLOYBLOCKER__ANNOUNCE_FAILED_WORKFLOW_IN_SLACK__STEP_MOCK = utils.getMockStep( + 'Announce failed workflow in Slack', + 'Announce failed workflow in Slack', + 'DEPLOYBLOCKER', + ['SLACK_WEBHOOK'], + [], +); +const DEPLOYBLOCKER__DEPLOYBLOCKER__STEP_MOCKS = [ + DEPLOYBLOCKER__DEPLOYBLOCKER__CHECKOUT__STEP_MOCK, + DEPLOYBLOCKER__DEPLOYBLOCKER__GET_URL_TITLE_AND_NUMBER_OF_NEW_DEPLOY_BLOCKER_ISSUE__STEP_MOCK, + DEPLOYBLOCKER__DEPLOYBLOCKER__UPDATE_STAGINGDEPLOYCASH_WITH_NEW_DEPLOY_BLOCKER__STEP_MOCK, + DEPLOYBLOCKER__DEPLOYBLOCKER__GIVE_THE_ISSUE_OR_PR_THE_HOURLY_ENGINEERING_LABELS__STEP_MOCK, + DEPLOYBLOCKER__DEPLOYBLOCKER__POST_THE_ISSUE_IN_THE_EXPENSIFY_OPEN_SOURCE_SLACK_ROOM__STEP_MOCK, + DEPLOYBLOCKER__DEPLOYBLOCKER__COMMENT_ON_DEFERRED_PR__STEP_MOCK, + DEPLOYBLOCKER__DEPLOYBLOCKER__ANNOUNCE_FAILED_WORKFLOW_IN_SLACK__STEP_MOCK, +]; + +module.exports = { + DEPLOYBLOCKER__DEPLOYBLOCKER__STEP_MOCKS, +}; diff --git a/workflow_tests/utils/preGenerateTest.js b/workflow_tests/utils/preGenerateTest.js index 19d65dec4c4b..4587705f7c54 100644 --- a/workflow_tests/utils/preGenerateTest.js +++ b/workflow_tests/utils/preGenerateTest.js @@ -26,6 +26,7 @@ const assertions = require('./assertions/${workflowName}Assertions'); const mocks = require('./mocks/${workflowName}Mocks'); const eAct = require('./utils/ExtendedAct'); +jest.setTimeout(60 * 1000); let mockGithub; const FILES_TO_COPY_INTO_TEST_REPO = [ { @@ -46,34 +47,37 @@ const FILES_TO_COPY_INTO_TEST_REPO = [ }, ]; -beforeEach(async () => { - // create a local repository and copy required files - mockGithub = new kieMockGithub.MockGithub({ - repo: { - test${capitalize(workflowName)}WorkflowRepo: { - files: FILES_TO_COPY_INTO_TEST_REPO, - - // if any branches besides main are need add: pushedBranches: ['staging', 'production'], +describe('test workflow ${workflowName}', () => { + const githubToken = 'dummy_github_token', + const actor = 'Dummy Actor'; + beforeEach(async () => { + // create a local repository and copy required files + mockGithub = new kieMockGithub.MockGithub({ + repo: { + test${capitalize(workflowName)}WorkflowRepo: { + files: FILES_TO_COPY_INTO_TEST_REPO, + + // if any branches besides main are need add: pushedBranches: ['staging', 'production'], + }, }, - }, + }); + + await mockGithub.setup(); + }); + + afterEach(async () => { + await mockGithub.teardown(); }); - - await mockGithub.setup(); -}); - -afterEach(async () => { - await mockGithub.teardown(); -}); - -describe('test workflow ${workflowName}', () => { test('test stub', async () => { const repoPath = mockGithub.repo.getPath('test${capitalize(workflowName)}WorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', '${workflowName}.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams( act, - - // set up params if needed + '[EVENT]', + {}, + {}, + githubToken, ); const testMockSteps = { // mock steps with imported mocks @@ -82,11 +86,11 @@ describe('test workflow ${workflowName}', () => { .runEvent('[EVENT]', { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, - actor: 'Dummy Author', + actor, }); // assert execution with imported assertions - }, 60000); + }); }); `; const mockStepTemplate = (stepMockName, step, jobId) => ` diff --git a/workflow_tests/utils/utils.js b/workflow_tests/utils/utils.js index b6a7bb34e0e6..e3b3d74f611f 100644 --- a/workflow_tests/utils/utils.js +++ b/workflow_tests/utils/utils.js @@ -1,7 +1,15 @@ const yaml = require('yaml'); const fs = require('fs'); -const setUpActParams = (act, event = null, eventOptions = null, secrets = null, githubToken = null, envVars = null, inputs = null) => { +function setUpActParams( + act, + event = null, + eventOptions = null, + secrets = null, + githubToken = null, + envVars = null, + inputs = null, +) { let updated_act = act; if (event && eventOptions) { @@ -38,9 +46,18 @@ const setUpActParams = (act, event = null, eventOptions = null, secrets = null, } return updated_act; -}; +} -const getMockStep = (name, message, job_id = null, inputs = null, in_envs = null, outputs = null, out_envs = null, isSuccessful = true) => { +function getMockStep( + name, + message, + job_id = null, + inputs = null, + in_envs = null, + outputs = null, + out_envs = null, + isSuccessful = true, +) { const mockStepName = name; let mockWithCommand = 'echo [MOCK]'; if (job_id) { @@ -74,9 +91,17 @@ const getMockStep = (name, message, job_id = null, inputs = null, in_envs = null name: mockStepName, mockWith: mockWithCommand, }; -}; +} -const getStepAssertion = (name, isSuccessful = true, expectedOutput = null, jobId = null, message = null, inputs = null, envs = null) => { +function getStepAssertion( + name, + isSuccessful = true, + expectedOutput = null, + jobId = null, + message = null, + inputs = null, + envs = null, +) { const stepName = `Main ${name}`; const stepStatus = isSuccessful ? 0 : 1; let stepOutput; @@ -106,9 +131,9 @@ const getStepAssertion = (name, isSuccessful = true, expectedOutput = null, jobI status: stepStatus, output: stepOutput, }; -}; +} -const setJobRunners = (act, jobs, workflowPath) => { +function setJobRunners(act, jobs, workflowPath) { if (!act || !jobs || !workflowPath) { return act; } @@ -120,11 +145,16 @@ const setJobRunners = (act, jobs, workflowPath) => { } fs.writeFileSync(workflowPath, yaml.stringify(workflow), 'utf8'); return act; -}; +} + +function deepCopy(originalObject) { + return JSON.parse(JSON.stringify(originalObject)); +} module.exports = { setUpActParams, getMockStep, getStepAssertion, setJobRunners, + deepCopy, }; From a7598f92931d1cb05512d5dd56f45538d93fba44 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Fri, 24 Mar 2023 14:11:42 +0100 Subject: [PATCH 058/504] Add tests Added tests for `lint` workflow See: https://github.com/Expensify/App/issues/13604 --- .github/workflows/lint.yml | 6 +- workflow_tests/assertions/lintAssertions.js | 54 ++++++ workflow_tests/lint.test.js | 188 ++++++++++++++++++++ workflow_tests/mocks/lintMocks.js | 41 +++++ workflow_tests/utils/preGenerateTest.js | 4 +- 5 files changed, 289 insertions(+), 4 deletions(-) create mode 100644 workflow_tests/assertions/lintAssertions.js create mode 100644 workflow_tests/lint.test.js create mode 100644 workflow_tests/mocks/lintMocks.js diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 795271cab60a..9e15d33f90b3 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -11,9 +11,11 @@ jobs: if: ${{ github.actor != 'OSBotify' || github.event_name == 'workflow_call' }} runs-on: ubuntu-latest steps: - - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 + - name: Checkout + uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 - - uses: Expensify/App/.github/actions/composite/setupNode@main + - name: Setup Node + uses: Expensify/App/.github/actions/composite/setupNode@main - name: Lint JavaScript with ESLint run: npm run lint diff --git a/workflow_tests/assertions/lintAssertions.js b/workflow_tests/assertions/lintAssertions.js new file mode 100644 index 000000000000..3e8862fca63f --- /dev/null +++ b/workflow_tests/assertions/lintAssertions.js @@ -0,0 +1,54 @@ +const utils = require('../utils/utils'); + +const assertLintJobExecuted = (workflowResult, didExecute = true) => { + const steps = [ + utils.getStepAssertion( + 'Checkout', + true, + null, + 'LINT', + 'Checkout', + [], + [], + ), + utils.getStepAssertion( + 'Setup Node', + true, + null, + 'LINT', + 'Setup Node', + [], + [], + ), + utils.getStepAssertion( + 'Lint JavaScript with ESLint', + true, + null, + 'LINT', + 'Lint JavaScript with ESLint', + [], + [{key: 'CI', value: 'true'}], + ), + utils.getStepAssertion( + 'Lint shell scripts with ShellCheck', + true, + null, + 'LINT', + 'Lint shell scripts with ShellCheck', + [], + [], + ), + ]; + + for (const expectedStep of steps) { + if (didExecute) { + expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); + } else { + expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); + } + } +}; + +module.exports = { + assertLintJobExecuted, +}; diff --git a/workflow_tests/lint.test.js b/workflow_tests/lint.test.js new file mode 100644 index 000000000000..6b0669bfbdd4 --- /dev/null +++ b/workflow_tests/lint.test.js @@ -0,0 +1,188 @@ +const path = require('path'); +const kieMockGithub = require('@kie/mock-github'); +const utils = require('./utils/utils'); +const assertions = require('./assertions/lintAssertions'); +const mocks = require('./mocks/lintMocks'); +const eAct = require('./utils/ExtendedAct'); + +jest.setTimeout(60 * 1000); +let mockGithub; +const FILES_TO_COPY_INTO_TEST_REPO = [ + { + src: path.resolve(__dirname, '..', '.github', 'actions'), + dest: '.github/actions', + }, + { + src: path.resolve(__dirname, '..', '.github', 'libs'), + dest: '.github/libs', + }, + { + src: path.resolve(__dirname, '..', '.github', 'scripts'), + dest: '.github/scripts', + }, + { + src: path.resolve(__dirname, '..', '.github', 'workflows', 'lint.yml'), + dest: '.github/workflows/lint.yml', + }, +]; + +describe('test workflow lint', () => { + const githubToken = 'dummy_github_token'; + const actor = 'Dummy Actor'; + beforeEach(async () => { + // create a local repository and copy required files + mockGithub = new kieMockGithub.MockGithub({ + repo: { + testLintWorkflowRepo: { + files: FILES_TO_COPY_INTO_TEST_REPO, + + // if any branches besides main are need add: pushedBranches: ['staging', 'production'], + }, + }, + }); + + await mockGithub.setup(); + }); + + afterEach(async () => { + await mockGithub.teardown(); + }); + describe('event is workflow_call', () => { + const event = 'workflow_call'; + const eventOptions = {}; + it('runs the lint', async () => { + const repoPath = mockGithub.repo.getPath('testLintWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'lint.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + act = utils.setUpActParams( + act, + event, + eventOptions, + {}, + githubToken, + ); + const testMockSteps = { + lint: mocks.LINT__LINT__STEP_MOCKS, + }; + const result = await act + .runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor, + }); + + assertions.assertLintJobExecuted(result); + }); + describe('actor is OSBotify', () => { + const testActor = 'OSBotify'; + it('runs the lint', async () => { + const repoPath = mockGithub.repo.getPath('testLintWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'lint.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + act = utils.setUpActParams( + act, + event, + eventOptions, + {}, + githubToken, + ); + const testMockSteps = { + lint: mocks.LINT__LINT__STEP_MOCKS, + }; + const result = await act + .runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor: testActor, + }); + + assertions.assertLintJobExecuted(result); + }); + }); + }); + describe('event is pull_request', () => { + const event = 'pull_request'; + describe('pull_request is opened', () => { + const eventOptions = { + action: 'opened', + }; + it('runs the lint', async () => { + const repoPath = mockGithub.repo.getPath('testLintWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'lint.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + act = utils.setUpActParams( + act, + event, + eventOptions, + {}, + githubToken, + ); + const testMockSteps = { + lint: mocks.LINT__LINT__STEP_MOCKS, + }; + const result = await act + .runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor, + }); + + assertions.assertLintJobExecuted(result); + }); + describe('actor is OSBotify', () => { + const testActor = 'OSBotify'; + it('does not run the lint', async () => { + const repoPath = mockGithub.repo.getPath('testLintWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'lint.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + act = utils.setUpActParams( + act, + event, + eventOptions, + {}, + githubToken, + ); + const testMockSteps = { + lint: mocks.LINT__LINT__STEP_MOCKS, + }; + const result = await act + .runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor: testActor, + }); + + assertions.assertLintJobExecuted(result, false); + }); + }); + }); + describe('pull_request is synchronized', () => { + const eventOptions = { + action: 'synchronize', + }; + it('runs the lint', async () => { + const repoPath = mockGithub.repo.getPath('testLintWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'lint.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + act = utils.setUpActParams( + act, + event, + eventOptions, + {}, + githubToken, + ); + const testMockSteps = { + lint: mocks.LINT__LINT__STEP_MOCKS, + }; + const result = await act + .runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor, + }); + + assertions.assertLintJobExecuted(result); + }); + }); + }); +}); diff --git a/workflow_tests/mocks/lintMocks.js b/workflow_tests/mocks/lintMocks.js new file mode 100644 index 000000000000..de2da8394e5f --- /dev/null +++ b/workflow_tests/mocks/lintMocks.js @@ -0,0 +1,41 @@ +const utils = require('../utils/utils'); + +// lint +const LINT__LINT__CHECKOUT__STEP_MOCK = utils.getMockStep( + 'Checkout', + 'Checkout', + 'LINT', + [], + [], +); +const LINT__LINT__SETUP_NODE__STEP_MOCK = utils.getMockStep( + 'Setup Node', + 'Setup Node', + 'LINT', + [], + [], +); +const LINT__LINT__LINT_JAVASCRIPT_WITH_ESLINT__STEP_MOCK = utils.getMockStep( + 'Lint JavaScript with ESLint', + 'Lint JavaScript with ESLint', + 'LINT', + [], + ['CI'], +); +const LINT__LINT__LINT_SHELL_SCRIPTS_WITH_SHELLCHECK__STEP_MOCK = utils.getMockStep( + 'Lint shell scripts with ShellCheck', + 'Lint shell scripts with ShellCheck', + 'LINT', + [], + [], +); +const LINT__LINT__STEP_MOCKS = [ + LINT__LINT__CHECKOUT__STEP_MOCK, + LINT__LINT__SETUP_NODE__STEP_MOCK, + LINT__LINT__LINT_JAVASCRIPT_WITH_ESLINT__STEP_MOCK, + LINT__LINT__LINT_SHELL_SCRIPTS_WITH_SHELLCHECK__STEP_MOCK, +]; + +module.exports = { + LINT__LINT__STEP_MOCKS, +}; diff --git a/workflow_tests/utils/preGenerateTest.js b/workflow_tests/utils/preGenerateTest.js index 4587705f7c54..80e701945ead 100644 --- a/workflow_tests/utils/preGenerateTest.js +++ b/workflow_tests/utils/preGenerateTest.js @@ -48,7 +48,7 @@ const FILES_TO_COPY_INTO_TEST_REPO = [ ]; describe('test workflow ${workflowName}', () => { - const githubToken = 'dummy_github_token', + const githubToken = 'dummy_github_token'; const actor = 'Dummy Actor'; beforeEach(async () => { // create a local repository and copy required files @@ -68,7 +68,7 @@ describe('test workflow ${workflowName}', () => { afterEach(async () => { await mockGithub.teardown(); }); - test('test stub', async () => { + it('test stub', async () => { const repoPath = mockGithub.repo.getPath('test${capitalize(workflowName)}WorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', '${workflowName}.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); From 0e6e74cf2108fd7333bf43b9008e02952cd2ce47 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Fri, 24 Mar 2023 14:20:51 +0100 Subject: [PATCH 059/504] Add tests Added tests for `reviewerChecklist` workflow See: https://github.com/Expensify/App/issues/13604 --- .../assertions/reviewerChecklistAssertions.js | 27 +++++ .../mocks/reviewerChecklistMocks.js | 17 +++ workflow_tests/reviewerChecklist.test.js | 100 ++++++++++++++++++ 3 files changed, 144 insertions(+) create mode 100644 workflow_tests/assertions/reviewerChecklistAssertions.js create mode 100644 workflow_tests/mocks/reviewerChecklistMocks.js create mode 100644 workflow_tests/reviewerChecklist.test.js diff --git a/workflow_tests/assertions/reviewerChecklistAssertions.js b/workflow_tests/assertions/reviewerChecklistAssertions.js new file mode 100644 index 000000000000..0453f4654768 --- /dev/null +++ b/workflow_tests/assertions/reviewerChecklistAssertions.js @@ -0,0 +1,27 @@ +const utils = require('../utils/utils'); + +const assertChecklistJobExecuted = (workflowResult, didExecute = true) => { + const steps = [ + utils.getStepAssertion( + 'reviewerChecklist.js', + true, + null, + 'CHECKLIST', + 'reviewerChecklist.js', + [{key: 'GITHUB_TOKEN', value: '***'}], + [], + ), + ]; + + for (const expectedStep of steps) { + if (didExecute) { + expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); + } else { + expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); + } + } +}; + +module.exports = { + assertChecklistJobExecuted, +}; diff --git a/workflow_tests/mocks/reviewerChecklistMocks.js b/workflow_tests/mocks/reviewerChecklistMocks.js new file mode 100644 index 000000000000..bf82791646f4 --- /dev/null +++ b/workflow_tests/mocks/reviewerChecklistMocks.js @@ -0,0 +1,17 @@ +const utils = require('../utils/utils'); + +// checklist +const REVIEWERCHECKLIST__CHECKLIST__REVIEWERCHECKLIST_JS__STEP_MOCK = utils.getMockStep( + 'reviewerChecklist.js', + 'reviewerChecklist.js', + 'CHECKLIST', + ['GITHUB_TOKEN'], + [], +); +const REVIEWERCHECKLIST__CHECKLIST__STEP_MOCKS = [ + REVIEWERCHECKLIST__CHECKLIST__REVIEWERCHECKLIST_JS__STEP_MOCK, +]; + +module.exports = { + REVIEWERCHECKLIST__CHECKLIST__STEP_MOCKS, +}; diff --git a/workflow_tests/reviewerChecklist.test.js b/workflow_tests/reviewerChecklist.test.js new file mode 100644 index 000000000000..fb019c74cf9f --- /dev/null +++ b/workflow_tests/reviewerChecklist.test.js @@ -0,0 +1,100 @@ +const path = require('path'); +const kieMockGithub = require('@kie/mock-github'); +const utils = require('./utils/utils'); +const assertions = require('./assertions/reviewerChecklistAssertions'); +const mocks = require('./mocks/reviewerChecklistMocks'); +const eAct = require('./utils/ExtendedAct'); + +jest.setTimeout(60 * 1000); +let mockGithub; +const FILES_TO_COPY_INTO_TEST_REPO = [ + { + src: path.resolve(__dirname, '..', '.github', 'actions'), + dest: '.github/actions', + }, + { + src: path.resolve(__dirname, '..', '.github', 'libs'), + dest: '.github/libs', + }, + { + src: path.resolve(__dirname, '..', '.github', 'scripts'), + dest: '.github/scripts', + }, + { + src: path.resolve(__dirname, '..', '.github', 'workflows', 'reviewerChecklist.yml'), + dest: '.github/workflows/reviewerChecklist.yml', + }, +]; + +describe('test workflow reviewerChecklist', () => { + const githubToken = 'dummy_github_token'; + const actor = 'Dummy Actor'; + beforeEach(async () => { + // create a local repository and copy required files + mockGithub = new kieMockGithub.MockGithub({ + repo: { + testReviewerChecklistWorkflowRepo: { + files: FILES_TO_COPY_INTO_TEST_REPO, + }, + }, + }); + await mockGithub.setup(); + }); + + afterEach(async () => { + await mockGithub.teardown(); + }); + describe('event is pull_request_review', () => { + const event = 'pull_request_review'; + const eventOptions = {}; + it('runs the workflow', async () => { + const repoPath = mockGithub.repo.getPath('testReviewerChecklistWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'reviewerChecklist.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + act = utils.setUpActParams( + act, + event, + eventOptions, + {}, + githubToken, + ); + const testMockSteps = { + checklist: mocks.REVIEWERCHECKLIST__CHECKLIST__STEP_MOCKS, + }; + const result = await act + .runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor, + }); + + assertions.assertChecklistJobExecuted(result); + }); + describe('actor is OSBotify', () => { + const osbotifyActor = 'OSBotify'; + it('does not run the workflow', async () => { + const repoPath = mockGithub.repo.getPath('testReviewerChecklistWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'reviewerChecklist.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + act = utils.setUpActParams( + act, + event, + eventOptions, + {}, + githubToken, + ); + const testMockSteps = { + checklist: mocks.REVIEWERCHECKLIST__CHECKLIST__STEP_MOCKS, + }; + const result = await act + .runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor: osbotifyActor, + }); + + assertions.assertChecklistJobExecuted(result, false); + }); + }); + }); +}); From 24c72e3cdd58f68ecd56e8a68861186b483d5439 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Mon, 27 Mar 2023 11:48:51 +0200 Subject: [PATCH 060/504] Add tests Added tests for `test` workflow See: https://github.com/Expensify/App/issues/13604 --- .github/workflows/test.yml | 12 ++- workflow_tests/assertions/testAssertions.js | 113 ++++++++++++++++++++ workflow_tests/mocks/testMocks.js | 78 ++++++++++++++ 3 files changed, 199 insertions(+), 4 deletions(-) create mode 100644 workflow_tests/assertions/testAssertions.js create mode 100644 workflow_tests/mocks/testMocks.js diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7cc2547f34c3..9c092b26676a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -18,9 +18,11 @@ jobs: chunk: [ 1, 2, 3 ] name: test (job ${{ fromJSON(matrix.chunk) }}) steps: - - uses: actions/checkout@885641592076c27bfb56c028cd5612cdad63e16d + - name: Checkout + uses: actions/checkout@885641592076c27bfb56c028cd5612cdad63e16d - - uses: Expensify/App/.github/actions/composite/setupNode@main + - name: Setup Node + uses: Expensify/App/.github/actions/composite/setupNode@main - name: Get number of CPU cores id: cpu-cores @@ -51,9 +53,11 @@ jobs: runs-on: ubuntu-latest name: Shell tests steps: - - uses: actions/checkout@885641592076c27bfb56c028cd5612cdad63e16d + - name: Checkout + uses: actions/checkout@885641592076c27bfb56c028cd5612cdad63e16d - - uses: Expensify/App/.github/actions/composite/setupNode@main + - name: Setup Node + uses: Expensify/App/.github/actions/composite/setupNode@main - name: getPullRequestsMergedBetween run: tests/unit/getPullRequestsMergedBetweenTest.sh diff --git a/workflow_tests/assertions/testAssertions.js b/workflow_tests/assertions/testAssertions.js new file mode 100644 index 000000000000..fd4d350c1374 --- /dev/null +++ b/workflow_tests/assertions/testAssertions.js @@ -0,0 +1,113 @@ +const utils = require('../utils/utils'); + +const assertJestJobExecuted = (workflowResult, didExecute = true, timesExecuted = 3) => { + const steps = [ + utils.getStepAssertion( + 'Checkout', + true, + null, + 'JEST', + 'Checkout', + [], + [], + ), + utils.getStepAssertion( + 'Setup Node', + true, + null, + 'JEST', + 'Setup Node', + [], + [], + ), + utils.getStepAssertion( + 'Get number of CPU cores', + true, + null, + 'JEST', + 'Get number of CPU cores', + [], + [], + ), + utils.getStepAssertion( + 'Cache Jest cache', + true, + null, + 'JEST', + 'Cache Jest cache', + [{key: 'path', value: '.jest-cache'}, {key: 'key', value: 'Linux-jest'}], + [], + ), + utils.getStepAssertion( + 'Jest tests', + true, + null, + 'JEST', + 'Jest tests', + [], + [], + ), + ]; + + for (const expectedStep of steps) { + if (didExecute) { + expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); + let cnt = 0; + for (const executedStep of workflowResult) { + if ( + executedStep.name === expectedStep.name + && executedStep.output === expectedStep.output + && executedStep.status === expectedStep.status + ) { + cnt += 1; + } + } + expect(cnt).toEqual(timesExecuted); + } else { + expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); + } + } +}; +const assertShellTestsJobExecuted = (workflowResult, didExecute = true) => { + const steps = [ + utils.getStepAssertion( + 'Checkout', + true, + null, + 'SHELLTESTS', + 'Checkout', + [], + [], + ), + utils.getStepAssertion( + 'Setup Node', + true, + null, + 'SHELLTESTS', + 'Setup Node', + [], + [], + ), + utils.getStepAssertion( + 'getPullRequestsMergedBetween', + true, + null, + 'SHELLTESTS', + 'getPullRequestsMergedBetween', + [], + [], + ), + ]; + + for (const expectedStep of steps) { + if (didExecute) { + expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); + } else { + expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); + } + } +}; + +module.exports = { + assertJestJobExecuted, assertShellTestsJobExecuted, +}; diff --git a/workflow_tests/mocks/testMocks.js b/workflow_tests/mocks/testMocks.js new file mode 100644 index 000000000000..051b876b3ebf --- /dev/null +++ b/workflow_tests/mocks/testMocks.js @@ -0,0 +1,78 @@ +const utils = require('../utils/utils'); + +// jest +const TEST__JEST__CHECKOUT__STEP_MOCK = utils.getMockStep( + 'Checkout', + 'Checkout', + 'JEST', + [], + [], +); +const TEST__JEST__SETUP_NODE__STEP_MOCK = utils.getMockStep( + 'Setup Node', + 'Setup Node', + 'JEST', + [], + [], +); +const TEST__JEST__GET_NUMBER_OF_CPU_CORES__STEP_MOCK = utils.getMockStep( + 'Get number of CPU cores', + 'Get number of CPU cores', + 'JEST', + [], + [], + {count: 8}, +); +const TEST__JEST__CACHE_JEST_CACHE__STEP_MOCK = utils.getMockStep( + 'Cache Jest cache', + 'Cache Jest cache', + 'JEST', + ['path', 'key'], + [], +); +const TEST__JEST__JEST_TESTS__STEP_MOCK = utils.getMockStep( + 'Jest tests', + 'Jest tests', + 'JEST', + [], + [], +); +const TEST__JEST__STEP_MOCKS = [ + TEST__JEST__CHECKOUT__STEP_MOCK, + TEST__JEST__SETUP_NODE__STEP_MOCK, + TEST__JEST__GET_NUMBER_OF_CPU_CORES__STEP_MOCK, + TEST__JEST__CACHE_JEST_CACHE__STEP_MOCK, + TEST__JEST__JEST_TESTS__STEP_MOCK, +]; + +// shelltests +const TEST__SHELLTESTS__CHECKOUT__STEP_MOCK = utils.getMockStep( + 'Checkout', + 'Checkout', + 'SHELLTESTS', + [], + [], +); +const TEST__SHELLTESTS__SETUP_NODE__STEP_MOCK = utils.getMockStep( + 'Setup Node', + 'Setup Node', + 'SHELLTESTS', + [], + [], +); +const TEST__SHELLTESTS__GETPULLREQUESTSMERGEDBETWEEN__STEP_MOCK = utils.getMockStep( + 'getPullRequestsMergedBetween', + 'getPullRequestsMergedBetween', + 'SHELLTESTS', + [], + [], +); +const TEST__SHELLTESTS__STEP_MOCKS = [ + TEST__SHELLTESTS__CHECKOUT__STEP_MOCK, + TEST__SHELLTESTS__SETUP_NODE__STEP_MOCK, + TEST__SHELLTESTS__GETPULLREQUESTSMERGEDBETWEEN__STEP_MOCK, +]; + +module.exports = { + TEST__JEST__STEP_MOCKS, TEST__SHELLTESTS__STEP_MOCKS, +}; From f725614f4491ed4a76548afe1b757d28100c8fdb Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Mon, 27 Mar 2023 11:49:06 +0200 Subject: [PATCH 061/504] Add tests Added tests for `test` workflow See: https://github.com/Expensify/App/issues/13604 --- workflow_tests/test.test.js | 224 ++++++++++++++++++++++++++++++++++++ 1 file changed, 224 insertions(+) create mode 100644 workflow_tests/test.test.js diff --git a/workflow_tests/test.test.js b/workflow_tests/test.test.js new file mode 100644 index 000000000000..360ff93aeb26 --- /dev/null +++ b/workflow_tests/test.test.js @@ -0,0 +1,224 @@ +const path = require('path'); +const kieMockGithub = require('@kie/mock-github'); +const utils = require('./utils/utils'); +const assertions = require('./assertions/testAssertions'); +const mocks = require('./mocks/testMocks'); +const eAct = require('./utils/ExtendedAct'); + +jest.setTimeout(60 * 1000); +let mockGithub; +const FILES_TO_COPY_INTO_TEST_REPO = [ + { + src: path.resolve(__dirname, '..', '.github', 'actions'), + dest: '.github/actions', + }, + { + src: path.resolve(__dirname, '..', '.github', 'libs'), + dest: '.github/libs', + }, + { + src: path.resolve(__dirname, '..', '.github', 'scripts'), + dest: '.github/scripts', + }, + { + src: path.resolve(__dirname, '..', '.github', 'workflows', 'test.yml'), + dest: '.github/workflows/test.yml', + }, +]; + +describe('test workflow test', () => { + const githubToken = 'dummy_github_token'; + const actor = 'Dummy Actor'; + const osbotifyActor = 'OSBotify'; + beforeEach(async () => { + // create a local repository and copy required files + mockGithub = new kieMockGithub.MockGithub({ + repo: { + testTestWorkflowRepo: { + files: FILES_TO_COPY_INTO_TEST_REPO, + }, + }, + }); + + await mockGithub.setup(); + }); + + afterEach(async () => { + await mockGithub.teardown(); + }); + + describe('pull request opened', () => { + const event = 'pull_request'; + const eventOptions = { + action: 'opened', + }; + it('runs all tests', async () => { + const repoPath = mockGithub.repo.getPath('testTestWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'test.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + act = utils.setUpActParams( + act, + event, + eventOptions, + {}, + githubToken, + ); + const testMockSteps = { + jest: mocks.TEST__JEST__STEP_MOCKS, + shellTests: mocks.TEST__SHELLTESTS__STEP_MOCKS, + }; + const result = await act + .runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor, + }); + + assertions.assertJestJobExecuted(result); + assertions.assertShellTestsJobExecuted(result); + }); + describe('actor is OSBotify', () => { + it('does not run tests', async () => { + const repoPath = mockGithub.repo.getPath('testTestWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'test.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + act = utils.setUpActParams( + act, + event, + eventOptions, + {}, + githubToken, + ); + const testMockSteps = { + jest: mocks.TEST__JEST__STEP_MOCKS, + shellTests: mocks.TEST__SHELLTESTS__STEP_MOCKS, + }; + const result = await act + .runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor: osbotifyActor, + }); + + assertions.assertJestJobExecuted(result, false); + assertions.assertShellTestsJobExecuted(result, false); + }); + }); + }); + + describe('pull request synchronized', () => { + const event = 'pull_request'; + const eventOptions = { + action: 'synchronize', + }; + it('runs all tests', async () => { + const repoPath = mockGithub.repo.getPath('testTestWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'test.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + act = utils.setUpActParams( + act, + event, + eventOptions, + {}, + githubToken, + ); + const testMockSteps = { + jest: mocks.TEST__JEST__STEP_MOCKS, + shellTests: mocks.TEST__SHELLTESTS__STEP_MOCKS, + }; + const result = await act + .runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor, + }); + + assertions.assertJestJobExecuted(result); + assertions.assertShellTestsJobExecuted(result); + }); + describe('actor is OSBotify', () => { + it('does not run tests', async () => { + const repoPath = mockGithub.repo.getPath('testTestWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'test.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + act = utils.setUpActParams( + act, + event, + eventOptions, + {}, + githubToken, + ); + const testMockSteps = { + jest: mocks.TEST__JEST__STEP_MOCKS, + shellTests: mocks.TEST__SHELLTESTS__STEP_MOCKS, + }; + const result = await act + .runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor: osbotifyActor, + }); + + assertions.assertJestJobExecuted(result, false); + assertions.assertShellTestsJobExecuted(result, false); + }); + }); + }); + + describe('event is workflow_call', () => { + const event = 'workflow_call'; + const eventOptions = {}; + it('runs all tests', async () => { + const repoPath = mockGithub.repo.getPath('testTestWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'test.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + act = utils.setUpActParams( + act, + event, + eventOptions, + {}, + githubToken, + ); + const testMockSteps = { + jest: mocks.TEST__JEST__STEP_MOCKS, + shellTests: mocks.TEST__SHELLTESTS__STEP_MOCKS, + }; + const result = await act + .runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor, + }); + + assertions.assertJestJobExecuted(result); + assertions.assertShellTestsJobExecuted(result); + }); + describe('actor is OSBotify', () => { + it('runs all tests normally', async () => { + const repoPath = mockGithub.repo.getPath('testTestWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'test.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + act = utils.setUpActParams( + act, + event, + eventOptions, + {}, + githubToken, + ); + const testMockSteps = { + jest: mocks.TEST__JEST__STEP_MOCKS, + shellTests: mocks.TEST__SHELLTESTS__STEP_MOCKS, + }; + const result = await act + .runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor: osbotifyActor, + }); + + assertions.assertJestJobExecuted(result); + assertions.assertShellTestsJobExecuted(result); + }); + }); + }); +}); From 2fa6af39393ff0407fe61357016e3a461467306e Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Mon, 27 Mar 2023 11:59:42 +0200 Subject: [PATCH 062/504] Add tests Added tests for `validateGithubActions` workflow See: https://github.com/Expensify/App/issues/13604 --- .github/workflows/validateGithubActions.yml | 6 +- .../validateGithubActionsAssertions.js | 54 +++++++++ .../mocks/validateGithubActionsMocks.js | 41 +++++++ workflow_tests/validateGithubActions.test.js | 106 ++++++++++++++++++ 4 files changed, 205 insertions(+), 2 deletions(-) create mode 100644 workflow_tests/assertions/validateGithubActionsAssertions.js create mode 100644 workflow_tests/mocks/validateGithubActionsMocks.js create mode 100644 workflow_tests/validateGithubActions.test.js diff --git a/.github/workflows/validateGithubActions.yml b/.github/workflows/validateGithubActions.yml index d731158e646b..2ae1bc559fa4 100644 --- a/.github/workflows/validateGithubActions.yml +++ b/.github/workflows/validateGithubActions.yml @@ -13,11 +13,13 @@ jobs: runs-on: ubuntu-latest steps: # This action checks-out the repository, so the workflow can access it. - - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 + - name: Checkout + uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 with: fetch-depth: 0 - - uses: Expensify/App/.github/actions/composite/setupNode@main + - name: Setup Node + uses: Expensify/App/.github/actions/composite/setupNode@main # Rebuild all the actions on this branch and check for a diff. Fail if there is one, # because that would be a sign that the PR author did not rebuild the Github Actions diff --git a/workflow_tests/assertions/validateGithubActionsAssertions.js b/workflow_tests/assertions/validateGithubActionsAssertions.js new file mode 100644 index 000000000000..c1e6056f6ce9 --- /dev/null +++ b/workflow_tests/assertions/validateGithubActionsAssertions.js @@ -0,0 +1,54 @@ +const utils = require('../utils/utils'); + +const assertVerifyJobExecuted = (workflowResult, didExecute = true) => { + const steps = [ + utils.getStepAssertion( + 'Checkout', + true, + null, + 'VERIFY', + 'Checkout', + [{key: 'fetch-depth', value: '0'}], + [], + ), + utils.getStepAssertion( + 'Setup Node', + true, + null, + 'VERIFY', + 'Setup Node', + [], + [], + ), + utils.getStepAssertion( + 'Verify Javascript Action Builds', + true, + null, + 'VERIFY', + 'Verify Javascript Action Builds', + [], + [], + ), + utils.getStepAssertion( + 'Validate actions and workflows', + true, + null, + 'VERIFY', + 'Validate actions and workflows', + [], + [], + ), + ]; + + for (const expectedStep of steps) { + if (didExecute) { + expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); + } else { + expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); + } + } +}; + +module.exports = { + assertVerifyJobExecuted, +}; diff --git a/workflow_tests/mocks/validateGithubActionsMocks.js b/workflow_tests/mocks/validateGithubActionsMocks.js new file mode 100644 index 000000000000..f8ec11213da7 --- /dev/null +++ b/workflow_tests/mocks/validateGithubActionsMocks.js @@ -0,0 +1,41 @@ +const utils = require('../utils/utils'); + +// verify +const VALIDATEGITHUBACTIONS__VERIFY__CHECKOUT__STEP_MOCK = utils.getMockStep( + 'Checkout', + 'Checkout', + 'VERIFY', + ['fetch-depth'], + [], +); +const VALIDATEGITHUBACTIONS__VERIFY__SETUP_NODE__STEP_MOCK = utils.getMockStep( + 'Setup Node', + 'Setup Node', + 'VERIFY', + [], + [], +); +const VALIDATEGITHUBACTIONS__VERIFY__VERIFY_JAVASCRIPT_ACTION_BUILDS__STEP_MOCK = utils.getMockStep( + 'Verify Javascript Action Builds', + 'Verify Javascript Action Builds', + 'VERIFY', + [], + [], +); +const VALIDATEGITHUBACTIONS__VERIFY__VALIDATE_ACTIONS_AND_WORKFLOWS__STEP_MOCK = utils.getMockStep( + 'Validate actions and workflows', + 'Validate actions and workflows', + 'VERIFY', + [], + [], +); +const VALIDATEGITHUBACTIONS__VERIFY__STEP_MOCKS = [ + VALIDATEGITHUBACTIONS__VERIFY__CHECKOUT__STEP_MOCK, + VALIDATEGITHUBACTIONS__VERIFY__SETUP_NODE__STEP_MOCK, + VALIDATEGITHUBACTIONS__VERIFY__VERIFY_JAVASCRIPT_ACTION_BUILDS__STEP_MOCK, + VALIDATEGITHUBACTIONS__VERIFY__VALIDATE_ACTIONS_AND_WORKFLOWS__STEP_MOCK, +]; + +module.exports = { + VALIDATEGITHUBACTIONS__VERIFY__STEP_MOCKS, +}; diff --git a/workflow_tests/validateGithubActions.test.js b/workflow_tests/validateGithubActions.test.js new file mode 100644 index 000000000000..45a6d6561622 --- /dev/null +++ b/workflow_tests/validateGithubActions.test.js @@ -0,0 +1,106 @@ +const path = require('path'); +const kieMockGithub = require('@kie/mock-github'); +const utils = require('./utils/utils'); +const assertions = require('./assertions/validateGithubActionsAssertions'); +const mocks = require('./mocks/validateGithubActionsMocks'); +const eAct = require('./utils/ExtendedAct'); + +jest.setTimeout(60 * 1000); +let mockGithub; +const FILES_TO_COPY_INTO_TEST_REPO = [ + { + src: path.resolve(__dirname, '..', '.github', 'actions'), + dest: '.github/actions', + }, + { + src: path.resolve(__dirname, '..', '.github', 'libs'), + dest: '.github/libs', + }, + { + src: path.resolve(__dirname, '..', '.github', 'scripts'), + dest: '.github/scripts', + }, + { + src: path.resolve(__dirname, '..', '.github', 'workflows', 'validateGithubActions.yml'), + dest: '.github/workflows/validateGithubActions.yml', + }, +]; + +describe('test workflow validateGithubActions', () => { + const githubToken = 'dummy_github_token'; + const actor = 'Dummy Actor'; + beforeEach(async () => { + // create a local repository and copy required files + mockGithub = new kieMockGithub.MockGithub({ + repo: { + testValidateGithubActionsWorkflowRepo: { + files: FILES_TO_COPY_INTO_TEST_REPO, + }, + }, + }); + + await mockGithub.setup(); + }); + + afterEach(async () => { + await mockGithub.teardown(); + }); + describe('pull request opened', () => { + const event = 'pull_request'; + const eventOptions = { + action: 'opened', + }; + it('executes verification', async () => { + const repoPath = mockGithub.repo.getPath('testValidateGithubActionsWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'validateGithubActions.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + act = utils.setUpActParams( + act, + event, + eventOptions, + {}, + githubToken, + ); + const testMockSteps = { + verify: mocks.VALIDATEGITHUBACTIONS__VERIFY__STEP_MOCKS, + }; + const result = await act + .runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor, + }); + + assertions.assertVerifyJobExecuted(result); + }); + }); + describe('pull request synchronized', () => { + const event = 'pull_request'; + const eventOptions = { + action: 'synchronize', + }; + it('executes verification', async () => { + const repoPath = mockGithub.repo.getPath('testValidateGithubActionsWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'validateGithubActions.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + act = utils.setUpActParams( + act, + event, + eventOptions, + {}, + githubToken, + ); + const testMockSteps = { + verify: mocks.VALIDATEGITHUBACTIONS__VERIFY__STEP_MOCKS, + }; + const result = await act + .runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor, + }); + + assertions.assertVerifyJobExecuted(result); + }); + }); +}); From 4428ec77a1b627f9cb5691d79f34367a400de98d Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Mon, 27 Mar 2023 12:11:17 +0200 Subject: [PATCH 063/504] Add tests Added tests for `warnCPLabel` workflow See: https://github.com/Expensify/App/issues/13604 --- .github/workflows/warnCPLabel.yml | 4 +- .../assertions/warnCPLabelAssertions.js | 49 ++++++ workflow_tests/mocks/warnCPLabelMocks.js | 25 +++ workflow_tests/warnCPLabel.test.js | 149 ++++++++++++++++++ 4 files changed, 226 insertions(+), 1 deletion(-) create mode 100644 workflow_tests/assertions/warnCPLabelAssertions.js create mode 100644 workflow_tests/mocks/warnCPLabelMocks.js create mode 100644 workflow_tests/warnCPLabel.test.js diff --git a/.github/workflows/warnCPLabel.yml b/.github/workflows/warnCPLabel.yml index c488bb1836d6..5479b734f77b 100644 --- a/.github/workflows/warnCPLabel.yml +++ b/.github/workflows/warnCPLabel.yml @@ -19,7 +19,9 @@ jobs: :warning: :warning: **Heads up! This pull request has the `CP Staging` label** :warning: :warning: If you applied the `CP Staging` label before the PR was merged, the PR will be be immediately deployed to staging even if the [open `StagingDeployCash` deploy checklist](https://github.com/Expensify/App/issues?q=is%3Aopen+is%3Aissue+label%3AStagingDeployCash) is locked. However if you applied the `CP Staging` after the PR was merged it's possible it won't be CP'ed automatically. If you need it to be CP'ed to staging, tag a member of @Expensify/mobile-deployers to CP it manually, otherwise you can wait for it to go out with the next deploy. - - if: ${{ failure() }} + + - name: Announce failed workflow in Slack + if: ${{ failure() }} uses: Expensify/App/.github/actions/composite/announceFailedWorkflowInSlack@main with: SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} diff --git a/workflow_tests/assertions/warnCPLabelAssertions.js b/workflow_tests/assertions/warnCPLabelAssertions.js new file mode 100644 index 000000000000..c15e346d3f76 --- /dev/null +++ b/workflow_tests/assertions/warnCPLabelAssertions.js @@ -0,0 +1,49 @@ +const utils = require('../utils/utils'); + +const assertWarnCPLabelJobExecuted = (workflowResult, didExecute = true, isSuccessful = true) => { + const steps = [ + utils.getStepAssertion( + 'Comment on PR to explain the CP Staging label', + true, + null, + 'WARNCPLABEL', + 'Comment on PR to explain the CP Staging label', + [{key: 'github_token', value: '***'}], + [], + ), + ]; + + for (const expectedStep of steps) { + if (didExecute) { + if (isSuccessful) { + expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); + } + } else { + expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); + } + } + + const failedSteps = [ + utils.getStepAssertion( + 'Announce failed workflow in Slack', + true, + null, + 'WARNCPLABEL', + 'Announce failed workflow in Slack', + [{key: 'SLACK_WEBHOOK', value: '***'}], + [], + ), + ]; + + for (const step of failedSteps) { + if (didExecute && !isSuccessful) { + expect(workflowResult).toEqual(expect.arrayContaining([step])); + } else { + expect(workflowResult).not.toEqual(expect.arrayContaining([step])); + } + } +}; + +module.exports = { + assertWarnCPLabelJobExecuted, +}; diff --git a/workflow_tests/mocks/warnCPLabelMocks.js b/workflow_tests/mocks/warnCPLabelMocks.js new file mode 100644 index 000000000000..334be03221d1 --- /dev/null +++ b/workflow_tests/mocks/warnCPLabelMocks.js @@ -0,0 +1,25 @@ +const utils = require('../utils/utils'); + +// warncplabel +const WARNCPLABEL__WARNCPLABEL__COMMENT_ON_PR_TO_EXPLAIN_THE_CP_STAGING_LABEL__STEP_MOCK = utils.getMockStep( + 'Comment on PR to explain the CP Staging label', + 'Comment on PR to explain the CP Staging label', + 'WARNCPLABEL', + ['github_token'], + [], +); +const WARNCPLABEL__WARNCPLABEL__ANNOUNCE_FAILED_WORKFLOW_IN_SLACK__STEP_MOCK = utils.getMockStep( + 'Announce failed workflow in Slack', + 'Announce failed workflow in Slack', + 'WARNCPLABEL', + ['SLACK_WEBHOOK'], + [], +); +const WARNCPLABEL__WARNCPLABEL__STEP_MOCKS = [ + WARNCPLABEL__WARNCPLABEL__COMMENT_ON_PR_TO_EXPLAIN_THE_CP_STAGING_LABEL__STEP_MOCK, + WARNCPLABEL__WARNCPLABEL__ANNOUNCE_FAILED_WORKFLOW_IN_SLACK__STEP_MOCK, +]; + +module.exports = { + WARNCPLABEL__WARNCPLABEL__STEP_MOCKS, +}; diff --git a/workflow_tests/warnCPLabel.test.js b/workflow_tests/warnCPLabel.test.js new file mode 100644 index 000000000000..326cacd57a84 --- /dev/null +++ b/workflow_tests/warnCPLabel.test.js @@ -0,0 +1,149 @@ +const path = require('path'); +const kieMockGithub = require('@kie/mock-github'); +const utils = require('./utils/utils'); +const assertions = require('./assertions/warnCPLabelAssertions'); +const mocks = require('./mocks/warnCPLabelMocks'); +const eAct = require('./utils/ExtendedAct'); + +jest.setTimeout(60 * 1000); +let mockGithub; +const FILES_TO_COPY_INTO_TEST_REPO = [ + { + src: path.resolve(__dirname, '..', '.github', 'actions'), + dest: '.github/actions', + }, + { + src: path.resolve(__dirname, '..', '.github', 'libs'), + dest: '.github/libs', + }, + { + src: path.resolve(__dirname, '..', '.github', 'scripts'), + dest: '.github/scripts', + }, + { + src: path.resolve(__dirname, '..', '.github', 'workflows', 'warnCPLabel.yml'), + dest: '.github/workflows/warnCPLabel.yml', + }, +]; + +describe('test workflow warnCPLabel', () => { + const githubToken = 'dummy_github_token'; + const actor = 'Dummy Actor'; + beforeEach(async () => { + // create a local repository and copy required files + mockGithub = new kieMockGithub.MockGithub({ + repo: { + testWarnCPLabelWorkflowRepo: { + files: FILES_TO_COPY_INTO_TEST_REPO, + }, + }, + }); + + await mockGithub.setup(); + }); + + afterEach(async () => { + await mockGithub.teardown(); + }); + describe('pull request target labeled', () => { + const event = 'pull_request_target'; + const eventOptions = { + action: 'labeled', + label: { + name: 'CP Staging', + }, + }; + const secrets = { + SLACK_WEBHOOK: 'dummy_slack_webhook', + }; + it('executes workflow', async () => { + const repoPath = mockGithub.repo.getPath('testWarnCPLabelWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'warnCPLabel.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + act = utils.setUpActParams( + act, + event, + eventOptions, + secrets, + githubToken, + ); + const testMockSteps = { + warnCPLabel: mocks.WARNCPLABEL__WARNCPLABEL__STEP_MOCKS, + }; + const result = await act + .runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor, + }); + + assertions.assertWarnCPLabelJobExecuted(result); + }); + describe('first step fails', () => { + it('executes workflow, announces failure on Slack', async () => { + const repoPath = mockGithub.repo.getPath('testWarnCPLabelWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'warnCPLabel.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + act = utils.setUpActParams( + act, + event, + eventOptions, + secrets, + githubToken, + ); + const testMockSteps = { + warnCPLabel: utils.deepCopy(mocks.WARNCPLABEL__WARNCPLABEL__STEP_MOCKS), + }; + testMockSteps.warnCPLabel[0] = utils.getMockStep( + 'Comment on PR to explain the CP Staging label', + 'Comment on PR to explain the CP Staging label', + 'WARNCPLABEL', + ['github_token'], + [], + {}, + {}, + false, + ); + const result = await act + .runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor, + }); + + assertions.assertWarnCPLabelJobExecuted(result, true, false); + }); + }); + describe('label different than CP Staging', () => { + const differentEventOptions = { + action: 'labeled', + label: { + name: 'Some Different Label', + }, + }; + it('does not execute workflow', async () => { + const repoPath = mockGithub.repo.getPath('testWarnCPLabelWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'warnCPLabel.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + act = utils.setUpActParams( + act, + event, + differentEventOptions, + secrets, + githubToken, + ); + const testMockSteps = { + warnCPLabel: mocks.WARNCPLABEL__WARNCPLABEL__STEP_MOCKS, + }; + const result = await act + .runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor, + }); + + assertions.assertWarnCPLabelJobExecuted(result, false); + }); + }); + }); +}); From a01c9c3dfd3082b922fa88339a535f3057b2c795 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Mon, 27 Mar 2023 12:35:11 +0200 Subject: [PATCH 064/504] Add tests Added tests for `verifySignedCommits` workflow See: https://github.com/Expensify/App/issues/13604 --- .github/workflows/verifySignedCommits.yml | 3 +- .../verifySignedCommitsAssertions.js | 27 +++++ .../mocks/verifySignedCommitsMocks.js | 17 +++ workflow_tests/verifySignedCommits.test.js | 106 ++++++++++++++++++ 4 files changed, 152 insertions(+), 1 deletion(-) create mode 100644 workflow_tests/assertions/verifySignedCommitsAssertions.js create mode 100644 workflow_tests/mocks/verifySignedCommitsMocks.js create mode 100644 workflow_tests/verifySignedCommits.test.js diff --git a/.github/workflows/verifySignedCommits.yml b/.github/workflows/verifySignedCommits.yml index e1068e71e041..ee1b0c4c78da 100644 --- a/.github/workflows/verifySignedCommits.yml +++ b/.github/workflows/verifySignedCommits.yml @@ -9,6 +9,7 @@ jobs: verifySignedCommits: runs-on: ubuntu-latest steps: - - uses: Expensify/App/.github/actions/javascript/verifySignedCommits@main + - name: Verify signed commits + uses: Expensify/App/.github/actions/javascript/verifySignedCommits@main with: GITHUB_TOKEN: ${{ github.token }} diff --git a/workflow_tests/assertions/verifySignedCommitsAssertions.js b/workflow_tests/assertions/verifySignedCommitsAssertions.js new file mode 100644 index 000000000000..3ea2b03e47c7 --- /dev/null +++ b/workflow_tests/assertions/verifySignedCommitsAssertions.js @@ -0,0 +1,27 @@ +const utils = require('../utils/utils'); + +const assertVerifySignedCommitsJobExecuted = (workflowResult, didExecute = true) => { + const steps = [ + utils.getStepAssertion( + 'Verify signed commits', + true, + null, + 'VERIFYSIGNEDCOMMITS', + 'Verify signed commits', + [{key: 'GITHUB_TOKEN', value: '***'}], + [], + ), + ]; + + for (const expectedStep of steps) { + if (didExecute) { + expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); + } else { + expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); + } + } +}; + +module.exports = { + assertVerifySignedCommitsJobExecuted, +}; diff --git a/workflow_tests/mocks/verifySignedCommitsMocks.js b/workflow_tests/mocks/verifySignedCommitsMocks.js new file mode 100644 index 000000000000..e01d89b2b18f --- /dev/null +++ b/workflow_tests/mocks/verifySignedCommitsMocks.js @@ -0,0 +1,17 @@ +const utils = require('../utils/utils'); + +// verifysignedcommits +const VERIFYSIGNEDCOMMITS__VERIFYSIGNEDCOMMITS__VERIFY_SIGNED_COMMITS__STEP_MOCK = utils.getMockStep( + 'Verify signed commits', + 'Verify signed commits', + 'VERIFYSIGNEDCOMMITS', + ['GITHUB_TOKEN'], + [], +); +const VERIFYSIGNEDCOMMITS__VERIFYSIGNEDCOMMITS__STEP_MOCKS = [ + VERIFYSIGNEDCOMMITS__VERIFYSIGNEDCOMMITS__VERIFY_SIGNED_COMMITS__STEP_MOCK, +]; + +module.exports = { + VERIFYSIGNEDCOMMITS__VERIFYSIGNEDCOMMITS__STEP_MOCKS, +}; diff --git a/workflow_tests/verifySignedCommits.test.js b/workflow_tests/verifySignedCommits.test.js new file mode 100644 index 000000000000..ff8ecb7f6785 --- /dev/null +++ b/workflow_tests/verifySignedCommits.test.js @@ -0,0 +1,106 @@ +const path = require('path'); +const kieMockGithub = require('@kie/mock-github'); +const utils = require('./utils/utils'); +const assertions = require('./assertions/verifySignedCommitsAssertions'); +const mocks = require('./mocks/verifySignedCommitsMocks'); +const eAct = require('./utils/ExtendedAct'); + +jest.setTimeout(60 * 1000); +let mockGithub; +const FILES_TO_COPY_INTO_TEST_REPO = [ + { + src: path.resolve(__dirname, '..', '.github', 'actions'), + dest: '.github/actions', + }, + { + src: path.resolve(__dirname, '..', '.github', 'libs'), + dest: '.github/libs', + }, + { + src: path.resolve(__dirname, '..', '.github', 'scripts'), + dest: '.github/scripts', + }, + { + src: path.resolve(__dirname, '..', '.github', 'workflows', 'verifySignedCommits.yml'), + dest: '.github/workflows/verifySignedCommits.yml', + }, +]; + +describe('test workflow verifySignedCommits', () => { + const githubToken = 'dummy_github_token'; + const actor = 'Dummy Actor'; + beforeEach(async () => { + // create a local repository and copy required files + mockGithub = new kieMockGithub.MockGithub({ + repo: { + testVerifySignedCommitsWorkflowRepo: { + files: FILES_TO_COPY_INTO_TEST_REPO, + }, + }, + }); + + await mockGithub.setup(); + }); + + afterEach(async () => { + await mockGithub.teardown(); + }); + describe('pull request opened', () => { + const event = 'pull_request'; + const eventOptions = { + action: 'opened', + }; + it('test stub', async () => { + const repoPath = mockGithub.repo.getPath('testVerifySignedCommitsWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'verifySignedCommits.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + act = utils.setUpActParams( + act, + event, + eventOptions, + {}, + githubToken, + ); + const testMockSteps = { + verifySignedCommits: mocks.VERIFYSIGNEDCOMMITS__VERIFYSIGNEDCOMMITS__STEP_MOCKS, + }; + const result = await act + .runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor, + }); + + assertions.assertVerifySignedCommitsJobExecuted(result); + }); + }); + describe('pull request synchronized', () => { + const event = 'pull_request'; + const eventOptions = { + action: 'synchronize', + }; + it('test stub', async () => { + const repoPath = mockGithub.repo.getPath('testVerifySignedCommitsWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'verifySignedCommits.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + act = utils.setUpActParams( + act, + event, + eventOptions, + {}, + githubToken, + ); + const testMockSteps = { + verifySignedCommits: mocks.VERIFYSIGNEDCOMMITS__VERIFYSIGNEDCOMMITS__STEP_MOCKS, + }; + const result = await act + .runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor, + }); + + assertions.assertVerifySignedCommitsJobExecuted(result); + }); + }); +}); From bec56b0da5a6be9e8606c21f35f655dedbb2065d Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Mon, 27 Mar 2023 12:44:34 +0200 Subject: [PATCH 065/504] Add tests Added tests for `verifyPodfile` workflow See: https://github.com/Expensify/App/issues/13604 --- .github/workflows/verifyPodfile.yml | 9 +- .../assertions/verifyPodfileAssertions.js | 45 +++++ workflow_tests/mocks/verifyPodfileMocks.js | 33 ++++ workflow_tests/verifyPodfile.test.js | 177 ++++++++++++++++++ 4 files changed, 261 insertions(+), 3 deletions(-) create mode 100644 workflow_tests/assertions/verifyPodfileAssertions.js create mode 100644 workflow_tests/mocks/verifyPodfileMocks.js create mode 100644 workflow_tests/verifyPodfile.test.js diff --git a/.github/workflows/verifyPodfile.yml b/.github/workflows/verifyPodfile.yml index 892b7c03c2de..557df1d94867 100644 --- a/.github/workflows/verifyPodfile.yml +++ b/.github/workflows/verifyPodfile.yml @@ -15,10 +15,13 @@ jobs: runs-on: macos-latest steps: # This action checks-out the repository, so the workflow can access it. - - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 + - name: Checkout + uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 with: fetch-depth: 0 - - uses: Expensify/App/.github/actions/composite/setupNode@main + - name: Setup Node + uses: Expensify/App/.github/actions/composite/setupNode@main - - run: ./.github/scripts/verifyPodfile.sh + - name: Verify podfile + run: ./.github/scripts/verifyPodfile.sh diff --git a/workflow_tests/assertions/verifyPodfileAssertions.js b/workflow_tests/assertions/verifyPodfileAssertions.js new file mode 100644 index 000000000000..499359d488b3 --- /dev/null +++ b/workflow_tests/assertions/verifyPodfileAssertions.js @@ -0,0 +1,45 @@ +const utils = require('../utils/utils'); + +const assertVerifyJobExecuted = (workflowResult, didExecute = true) => { + const steps = [ + utils.getStepAssertion( + 'Checkout', + true, + null, + 'VERIFY', + 'Checkout', + [{key: 'fetch-depth', value: '0'}], + [], + ), + utils.getStepAssertion( + 'Setup Node', + true, + null, + 'VERIFY', + 'Setup Node', + [], + [], + ), + utils.getStepAssertion( + 'Verify podfile', + true, + null, + 'VERIFY', + 'Verify podfile', + [], + [], + ), + ]; + + for (const expectedStep of steps) { + if (didExecute) { + expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); + } else { + expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); + } + } +}; + +module.exports = { + assertVerifyJobExecuted, +}; diff --git a/workflow_tests/mocks/verifyPodfileMocks.js b/workflow_tests/mocks/verifyPodfileMocks.js new file mode 100644 index 000000000000..c44f51b7b784 --- /dev/null +++ b/workflow_tests/mocks/verifyPodfileMocks.js @@ -0,0 +1,33 @@ +const utils = require('../utils/utils'); + +// verify +const VERIFYPODFILE__VERIFY__CHECKOUT__STEP_MOCK = utils.getMockStep( + 'Checkout', + 'Checkout', + 'VERIFY', + ['fetch-depth'], + [], +); +const VERIFYPODFILE__VERIFY__SETUP_NODE__STEP_MOCK = utils.getMockStep( + 'Setup Node', + 'Setup Node', + 'VERIFY', + [], + [], +); +const VERIFYPODFILE__VERIFY__VERIFY_PODFILE__STEP_MOCK = utils.getMockStep( + 'Verify podfile', + 'Verify podfile', + 'VERIFY', + [], + [], +); +const VERIFYPODFILE__VERIFY__STEP_MOCKS = [ + VERIFYPODFILE__VERIFY__CHECKOUT__STEP_MOCK, + VERIFYPODFILE__VERIFY__SETUP_NODE__STEP_MOCK, + VERIFYPODFILE__VERIFY__VERIFY_PODFILE__STEP_MOCK, +]; + +module.exports = { + VERIFYPODFILE__VERIFY__STEP_MOCKS, +}; diff --git a/workflow_tests/verifyPodfile.test.js b/workflow_tests/verifyPodfile.test.js new file mode 100644 index 000000000000..7529f509787e --- /dev/null +++ b/workflow_tests/verifyPodfile.test.js @@ -0,0 +1,177 @@ +const path = require('path'); +const kieMockGithub = require('@kie/mock-github'); +const utils = require('./utils/utils'); +const assertions = require('./assertions/verifyPodfileAssertions'); +const mocks = require('./mocks/verifyPodfileMocks'); +const eAct = require('./utils/ExtendedAct'); + +jest.setTimeout(60 * 1000); +let mockGithub; +const FILES_TO_COPY_INTO_TEST_REPO = [ + { + src: path.resolve(__dirname, '..', '.github', 'actions'), + dest: '.github/actions', + }, + { + src: path.resolve(__dirname, '..', '.github', 'libs'), + dest: '.github/libs', + }, + { + src: path.resolve(__dirname, '..', '.github', 'scripts'), + dest: '.github/scripts', + }, + { + src: path.resolve(__dirname, '..', '.github', 'workflows', 'verifyPodfile.yml'), + dest: '.github/workflows/verifyPodfile.yml', + }, +]; + +describe('test workflow verifyPodfile', () => { + const githubToken = 'dummy_github_token'; + const actor = 'Dummy Actor'; + const osbotifyActor = 'OSBotify'; + beforeEach(async () => { + // create a local repository and copy required files + mockGithub = new kieMockGithub.MockGithub({ + repo: { + testVerifyPodfileWorkflowRepo: { + files: FILES_TO_COPY_INTO_TEST_REPO, + }, + }, + }); + + await mockGithub.setup(); + }); + + afterEach(async () => { + await mockGithub.teardown(); + }); + describe('pull request opened', () => { + const event = 'pull_request'; + const eventOptions = { + action: 'opened', + }; + it('executes workflow', async () => { + const repoPath = mockGithub.repo.getPath('testVerifyPodfileWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'verifyPodfile.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + act = utils.setUpActParams( + act, + event, + eventOptions, + {}, + githubToken, + ); + act = utils.setJobRunners( + act, + {verify: 'ubuntu-latest'}, + workflowPath, + ); + const testMockSteps = { + verify: mocks.VERIFYPODFILE__VERIFY__STEP_MOCKS, + }; + const result = await act + .runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor, + }); + + assertions.assertVerifyJobExecuted(result); + }); + describe('actor is OSBotify', () => { + it('does not execute workflow', async () => { + const repoPath = mockGithub.repo.getPath('testVerifyPodfileWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'verifyPodfile.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + act = utils.setUpActParams( + act, + event, + eventOptions, + {}, + githubToken, + ); + act = utils.setJobRunners( + act, + {verify: 'ubuntu-latest'}, + workflowPath, + ); + const testMockSteps = { + verify: mocks.VERIFYPODFILE__VERIFY__STEP_MOCKS, + }; + const result = await act + .runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor: osbotifyActor, + }); + + assertions.assertVerifyJobExecuted(result, false); + }); + }); + }); + describe('pull request synchronized', () => { + const event = 'pull_request'; + const eventOptions = { + action: 'synchronize', + }; + it('executes workflow', async () => { + const repoPath = mockGithub.repo.getPath('testVerifyPodfileWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'verifyPodfile.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + act = utils.setUpActParams( + act, + event, + eventOptions, + {}, + githubToken, + ); + act = utils.setJobRunners( + act, + {verify: 'ubuntu-latest'}, + workflowPath, + ); + const testMockSteps = { + verify: mocks.VERIFYPODFILE__VERIFY__STEP_MOCKS, + }; + const result = await act + .runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor, + }); + + assertions.assertVerifyJobExecuted(result); + }); + describe('actor is OSBotify', () => { + it('does not execute workflow', async () => { + const repoPath = mockGithub.repo.getPath('testVerifyPodfileWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'verifyPodfile.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + act = utils.setUpActParams( + act, + event, + eventOptions, + {}, + githubToken, + ); + act = utils.setJobRunners( + act, + {verify: 'ubuntu-latest'}, + workflowPath, + ); + const testMockSteps = { + verify: mocks.VERIFYPODFILE__VERIFY__STEP_MOCKS, + }; + const result = await act + .runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor: osbotifyActor, + }); + + assertions.assertVerifyJobExecuted(result, false); + }); + }); + }); +}); From ca06e2cb26c872e4facb58023cfacdea17bf36f2 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Tue, 28 Mar 2023 12:53:43 +0200 Subject: [PATCH 066/504] Add tests Added tests for `testBuild` workflow See: https://github.com/Expensify/App/issues/13604 --- .github/workflows/testBuild.yml | 46 +- .../assertions/testBuildAssertions.js | 525 +++++++++ workflow_tests/mocks/testBuildMocks.js | 379 +++++++ workflow_tests/testBuild.test.js | 1001 +++++++++++++++++ 4 files changed, 1935 insertions(+), 16 deletions(-) create mode 100644 workflow_tests/assertions/testBuildAssertions.js create mode 100644 workflow_tests/mocks/testBuildMocks.js create mode 100644 workflow_tests/testBuild.test.js diff --git a/.github/workflows/testBuild.yml b/.github/workflows/testBuild.yml index cee2ad4c3b83..e71377e092ae 100644 --- a/.github/workflows/testBuild.yml +++ b/.github/workflows/testBuild.yml @@ -19,7 +19,8 @@ jobs: outputs: READY_TO_BUILD: ${{ fromJSON(steps.isUserTeamMember.outputs.isTeamMember) && fromJSON(steps.hasReadyToBuildLabel.outputs.HAS_READY_TO_BUILD_LABEL) }} steps: - - id: isUserTeamMember + - name: Is team member + id: isUserTeamMember uses: tspascoal/get-user-teams-membership@baf2e6adf4c3b897bd65a7e3184305c165aec872 with: GITHUB_TOKEN: ${{ secrets.OS_BOTIFY_TOKEN }} @@ -67,7 +68,8 @@ jobs: PULL_REQUEST_NUMBER: ${{ github.event.number || github.event.inputs.PULL_REQUEST_NUMBER }} steps: # This action checks-out the repository, so the workflow can access it. - - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 + - name: Checkout + uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 with: ref: ${{ github.event.pull_request.head.sha || needs.getBranchRef.outputs.REF }} @@ -77,9 +79,11 @@ jobs: sed -i 's/ENVIRONMENT=staging/ENVIRONMENT=adhoc/' .env.adhoc echo "PULL_REQUEST_NUMBER=$PULL_REQUEST_NUMBER" >> .env.adhoc - - uses: Expensify/App/.github/actions/composite/setupNode@main + - name: Setup Node + uses: Expensify/App/.github/actions/composite/setupNode@main - - uses: ruby/setup-ruby@eae47962baca661befdfd24e4d6c34ade04858f7 + - name: Setup Ruby + uses: ruby/setup-ruby@eae47962baca661befdfd24e4d6c34ade04858f7 with: ruby-version: '2.7' bundler-cache: true @@ -109,7 +113,8 @@ jobs: S3_BUCKET: ad-hoc-expensify-cash S3_REGION: us-east-1 - - uses: actions/upload-artifact@v3 + - name: Upload Artifact + uses: actions/upload-artifact@v3 with: name: android path: ./android_paths.json @@ -123,7 +128,8 @@ jobs: runs-on: macos-12-xl steps: # This action checks-out the repository, so the workflow can access it. - - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 + - name: Checkout + uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 with: ref: ${{ github.event.pull_request.head.sha || needs.getBranchRef.outputs.REF }} @@ -133,9 +139,11 @@ jobs: sed -i '' 's/ENVIRONMENT=staging/ENVIRONMENT=adhoc/' .env.adhoc echo "PULL_REQUEST_NUMBER=$PULL_REQUEST_NUMBER" >> .env.adhoc - - uses: Expensify/App/.github/actions/composite/setupNode@main + - name: Setup Node + uses: Expensify/App/.github/actions/composite/setupNode@main - - uses: ruby/setup-ruby@eae47962baca661befdfd24e4d6c34ade04858f7 + - name: Setup Ruby + uses: ruby/setup-ruby@eae47962baca661befdfd24e4d6c34ade04858f7 with: ruby-version: '2.7' bundler-cache: true @@ -171,7 +179,8 @@ jobs: S3_BUCKET: ad-hoc-expensify-cash S3_REGION: us-east-1 - - uses: actions/upload-artifact@v3 + - name: Upload Artifact + uses: actions/upload-artifact@v3 with: name: ios path: ./ios_paths.json @@ -185,7 +194,8 @@ jobs: runs-on: macos-12 steps: # This action checks-out the repository, so the workflow can access it. - - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 + - name: Checkout + uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 with: ref: ${{ github.event.pull_request.head.sha || needs.getBranchRef.outputs.REF }} fetch-depth: 0 @@ -196,7 +206,8 @@ jobs: sed -i '' 's/ENVIRONMENT=staging/ENVIRONMENT=adhoc/' .env.adhoc echo "PULL_REQUEST_NUMBER=$PULL_REQUEST_NUMBER" >> .env.adhoc - - uses: Expensify/App/.github/actions/composite/setupNode@main + - name: Setup Node + uses: Expensify/App/.github/actions/composite/setupNode@main - name: Decrypt Developer ID Certificate run: cd desktop && gpg --quiet --batch --yes --decrypt --passphrase="$DEVELOPER_ID_SECRET_PASSPHRASE" --output developer_id.p12 developer_id.p12.gpg @@ -227,7 +238,8 @@ jobs: PULL_REQUEST_NUMBER: ${{ github.event.number || github.event.inputs.PULL_REQUEST_NUMBER }} runs-on: ubuntu-latest steps: - - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 + - name: Checkout + uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 with: fetch-depth: 0 ref: ${{ github.event.pull_request.head.sha || needs.getBranchRef.outputs.REF }} @@ -238,7 +250,8 @@ jobs: sed -i 's/ENVIRONMENT=staging/ENVIRONMENT=adhoc/' .env.adhoc echo "PULL_REQUEST_NUMBER=$PULL_REQUEST_NUMBER" >> .env.adhoc - - uses: Expensify/App/.github/actions/composite/setupNode@main + - name: Setup Node + uses: Expensify/App/.github/actions/composite/setupNode@main - name: Configure AWS Credentials uses: Expensify/App/.github/actions/composite/configureAwsCredentials@main @@ -259,7 +272,7 @@ jobs: postGithubComment: runs-on: ubuntu-latest name: Post a GitHub comment with app download links for testing - needs: [validateActor, getBranchRef, android, ios, desktop, web] + needs: [validateActor, getBranchRef, android, iOS, desktop, web] if: ${{ always() }} env: PULL_REQUEST_NUMBER: ${{ github.event.number || github.event.inputs.PULL_REQUEST_NUMBER }} @@ -270,7 +283,8 @@ jobs: with: ref: ${{ github.event.pull_request.head.sha || needs.getBranchRef.outputs.REF }} - - uses: actions/download-artifact@v3 + - name: Download Artifact + uses: actions/download-artifact@v3 if: ${{ fromJSON(needs.validateActor.outputs.READY_TO_BUILD) }} - name: Read JSONs with android paths @@ -286,7 +300,7 @@ jobs: - name: Read JSONs with iOS paths id: get_ios_path - if: ${{ needs.ios.result == 'success' }} + if: ${{ needs.iOS.result == 'success' }} run: | content_ios="$(cat ./ios/ios_paths.json)" content_ios="${content_ios//'%'/'%25'}" diff --git a/workflow_tests/assertions/testBuildAssertions.js b/workflow_tests/assertions/testBuildAssertions.js new file mode 100644 index 000000000000..19034740562d --- /dev/null +++ b/workflow_tests/assertions/testBuildAssertions.js @@ -0,0 +1,525 @@ +const utils = require('../utils/utils'); + +const assertValidateActorJobExecuted = (workflowResult, actor = 'Dummy Actor', pullRequestNumber = '1234', didExecute = true) => { + const steps = [ + utils.getStepAssertion( + 'Is team member', + true, + null, + 'VALIDATEACTOR', + 'Is team member', + [{key: 'GITHUB_TOKEN', value: '***'}, {key: 'username', value: actor}, {key: 'team', value: 'Expensify/expensify'}], + [], + ), + utils.getStepAssertion( + 'Set HAS_READY_TO_BUILD_LABEL flag', + true, + null, + 'VALIDATEACTOR', + 'Set HAS_READY_TO_BUILD_LABEL flag', + [], + [{key: 'PULL_REQUEST_NUMBER', value: pullRequestNumber}, {key: 'GITHUB_TOKEN', value: '***'}], + ), + ]; + + for (const expectedStep of steps) { + if (didExecute) { + expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); + } else { + expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); + } + } +}; +const assertGetBranchRefJobExecuted = (workflowResult, didExecute = true) => { + const steps = [ + utils.getStepAssertion( + 'Checkout', + true, + null, + 'GETBRANCHREF', + 'Checkout', + [], + [], + ), + utils.getStepAssertion( + 'Check if pull request number is correct', + true, + null, + 'GETBRANCHREF', + 'Check if pull request number is correct', + [], + [{key: 'GITHUB_TOKEN', value: '***'}], + ), + ]; + + for (const expectedStep of steps) { + if (didExecute) { + expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); + } else { + expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); + } + } +}; +const assertAndroidJobExecuted = (workflowResult, ref = '', didExecute = true, failsAt = -1) => { + const steps = [ + utils.getStepAssertion( + 'Checkout', + true, + null, + 'ANDROID', + 'Checkout', + [{key: 'ref', value: ref}], + [], + ), + utils.getStepAssertion( + 'Setup Node', + true, + null, + 'ANDROID', + 'Setup Node', + [], + [], + ), + utils.getStepAssertion( + 'Setup Ruby', + true, + null, + 'ANDROID', + 'Setup Ruby', + [{key: 'ruby-version', value: '2.7'}, {key: 'bundler-cache', value: true}], + [], + ), + utils.getStepAssertion( + 'Decrypt keystore', + true, + null, + 'ANDROID', + 'Decrypt keystore', + [], + [{key: 'LARGE_SECRET_PASSPHRASE', value: '***'}], + ), + utils.getStepAssertion( + 'Decrypt json key', + true, + null, + 'ANDROID', + 'Decrypt json key', + [], + [{key: 'LARGE_SECRET_PASSPHRASE', value: '***'}], + ), + utils.getStepAssertion( + 'Configure AWS Credentials', + true, + null, + 'ANDROID', + 'Configure AWS Credentials', + [{key: 'AWS_ACCESS_KEY_ID', value: '***'}, {key: 'AWS_SECRET_ACCESS_KEY', value: '***'}], + [], + ), + utils.getStepAssertion( + 'Run Fastlane beta test', + true, + null, + 'ANDROID', + 'Run Fastlane beta test', + [], + [ + {key: 'S3_ACCESS_KEY', value: '***'}, + {key: 'S3_SECRET_ACCESS_KEY', value: '***'}, + {key: 'S3_BUCKET', value: 'ad-hoc-expensify-cash'}, + {key: 'S3_REGION', value: 'us-east-1'}, + ], + ), + utils.getStepAssertion( + 'Upload Artifact', + true, + null, + 'ANDROID', + 'Upload Artifact', + [{key: 'name', value: 'android'}, {key: 'path', value: './android_paths.json'}], + [], + ), + ]; + + for (const [i, expectedStep] of steps.entries()) { + if (didExecute) { + if (failsAt === -1 || i < failsAt) { + // either whole job is successful, or steps up to this point are successful + expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); + } else if (i === failsAt) { + // this is the failing step + expectedStep.status = 1; + expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); + } else { + // steps after failed one do not execute + expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); + } + } else { + expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); + } + } +}; +const assertIOSJobExecuted = (workflowResult, ref = '', didExecute = true, failsAt = -1) => { + const steps = [ + utils.getStepAssertion( + 'Checkout', + true, + null, + 'IOS', + 'Checkout', + [{key: 'ref', value: ref}], + [], + ), + utils.getStepAssertion( + 'Setup Node', + true, + null, + 'IOS', + 'Setup Node', + [], + [], + ), + utils.getStepAssertion( + 'Setup Ruby', + true, + null, + 'IOS', + 'Setup Ruby', + [{key: 'ruby-version', value: '2.7'}, {key: 'bundler-cache', value: true}], + [], + ), + utils.getStepAssertion( + 'Install cocoapods', + true, + null, + 'IOS', + 'Install cocoapods', + [ + {key: 'timeout_minutes', value: '10'}, + {key: 'max_attempts', value: '5'}, + {key: 'command', value: 'cd ios && pod install'}, + ], + [], + ), + utils.getStepAssertion( + 'Decrypt profile', + true, + null, + 'IOS', + 'Decrypt profile', + [], + [{key: 'LARGE_SECRET_PASSPHRASE', value: '***'}], + ), + utils.getStepAssertion( + 'Decrypt certificate', + true, + null, + 'IOS', + 'Decrypt certificate', + [], + [{key: 'LARGE_SECRET_PASSPHRASE', value: '***'}], + ), + utils.getStepAssertion( + 'Configure AWS Credentials', + true, + null, + 'IOS', + 'Configure AWS Credentials', + [{key: 'AWS_ACCESS_KEY_ID', value: '***'}, {key: 'AWS_SECRET_ACCESS_KEY', value: '***'}], + [], + ), + utils.getStepAssertion( + 'Run Fastlane', + true, + null, + 'IOS', + 'Run Fastlane', + [], + [ + {key: 'S3_ACCESS_KEY', value: '***'}, + {key: 'S3_SECRET_ACCESS_KEY', value: '***'}, + {key: 'S3_BUCKET', value: 'ad-hoc-expensify-cash'}, + {key: 'S3_REGION', value: 'us-east-1'}, + ], + ), + utils.getStepAssertion( + 'Upload Artifact', + true, + null, + 'IOS', + 'Upload Artifact', + [{key: 'name', value: 'ios'}, {key: 'path', value: './ios_paths.json'}], + [], + ), + ]; + + for (const [i, expectedStep] of steps.entries()) { + if (didExecute) { + if (failsAt === -1 || i < failsAt) { + // either whole job is successful, or steps up to this point are successful + expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); + } else if (i === failsAt) { + // this is the failing step + expectedStep.status = 1; + expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); + } else { + // steps after failed one do not execute + expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); + } + } else { + expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); + } + } +}; +const assertDesktopJobExecuted = (workflowResult, ref = '', didExecute = true, failsAt = -1) => { + const steps = [ + utils.getStepAssertion( + 'Checkout', + true, + null, + 'DESKTOP', + 'Checkout', + [{key: 'ref', value: ref}, {key: 'fetch-depth', value: '0'}], + [], + ), + utils.getStepAssertion( + 'Setup Node', + true, + null, + 'DESKTOP', + 'Setup Node', + [], + [], + ), + utils.getStepAssertion( + 'Decrypt Developer ID Certificate', + true, + null, + 'DESKTOP', + 'Decrypt Developer ID Certificate', + [], + [{key: 'DEVELOPER_ID_SECRET_PASSPHRASE', value: '***'}], + ), + utils.getStepAssertion( + 'Configure AWS Credentials', + true, + null, + 'DESKTOP', + 'Configure AWS Credentials', + [{key: 'AWS_ACCESS_KEY_ID', value: '***'}, {key: 'AWS_SECRET_ACCESS_KEY', value: '***'}], + [], + ), + utils.getStepAssertion( + 'Build desktop app for testing', + true, + null, + 'DESKTOP', + 'Build desktop app for testing', + [], + [ + {key: 'CSC_LINK', value: '***'}, + {key: 'CSC_KEY_PASSWORD', value: '***'}, + {key: 'APPLE_ID', value: '***'}, + {key: 'APPLE_ID_PASSWORD', value: '***'}, + {key: 'AWS_ACCESS_KEY_ID', value: '***'}, + {key: 'AWS_SECRET_ACCESS_KEY', value: '***'}, + ], + ), + ]; + + for (const [i, expectedStep] of steps.entries()) { + if (didExecute) { + if (failsAt === -1 || i < failsAt) { + // either whole job is successful, or steps up to this point are successful + expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); + } else if (i === failsAt) { + // this is the failing step + expectedStep.status = 1; + expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); + } else { + // steps after failed one do not execute + expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); + } + } else { + expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); + } + } +}; +const assertWebJobExecuted = (workflowResult, ref = '', didExecute = true, failsAt = -1) => { + const steps = [ + utils.getStepAssertion( + 'Checkout', + true, + null, + 'WEB', + 'Checkout', + [{key: 'fetch-depth', value: '0'}, {key: 'ref', value: ref}], + [], + ), + utils.getStepAssertion( + 'Setup Node', + true, + null, + 'WEB', + 'Setup Node', + [], + [], + ), + utils.getStepAssertion( + 'Configure AWS Credentials', + true, + null, + 'WEB', + 'Configure AWS Credentials', + [{key: 'AWS_ACCESS_KEY_ID', value: '***'}, {key: 'AWS_SECRET_ACCESS_KEY', value: '***'}], + [], + ), + utils.getStepAssertion( + 'Build web for testing', + true, + null, + 'WEB', + 'Build web for testing', + [], + [], + ), + utils.getStepAssertion( + 'Build docs', + true, + null, + 'WEB', + 'Build docs', + [], + [], + ), + utils.getStepAssertion( + 'Deploy to S3 for internal testing', + true, + null, + 'WEB', + 'Deploy to S3 for internal testing', + [], + [], + ), + ]; + + for (const [i, expectedStep] of steps.entries()) { + if (didExecute) { + if (failsAt === -1 || i < failsAt) { + // either whole job is successful, or steps up to this point are successful + expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); + } else if (i === failsAt) { + // this is the failing step + expectedStep.status = 1; + expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); + } else { + // steps after failed one do not execute + expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); + } + } else { + expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); + } + } +}; +const assertPostGithubCommentJobExecuted = (workflowResult, ref = '', pullRequestNumber = '1234', didExecute = true, androidStatus = 'success', iOSStatus = 'success', desktopStatus = 'success', webStatus = 'success') => { + const steps = [ + utils.getStepAssertion( + 'Checkout', + true, + null, + 'POSTGITHUBCOMMENT', + 'Checkout', + [{key: 'ref', value: ref}], + [], + ), + utils.getStepAssertion( + 'Download Artifact', + true, + null, + 'POSTGITHUBCOMMENT', + 'Download Artifact', + [], + [], + ), + ]; + if (androidStatus === 'success') { + steps.push( + utils.getStepAssertion( + 'Read JSONs with android paths', + true, + null, + 'POSTGITHUBCOMMENT', + 'Read JSONs with android paths', + [], + [], + ), + ); + } + if (iOSStatus === 'success') { + steps.push( + utils.getStepAssertion( + 'Read JSONs with iOS paths', + true, + null, + 'POSTGITHUBCOMMENT', + 'Read JSONs with iOS paths', + [], + [], + ), + ); + } + steps.push( + utils.getStepAssertion( + 'maintain-comment', + true, + null, + 'POSTGITHUBCOMMENT', + 'maintain-comment', + [ + {key: 'token', value: '***'}, + {key: 'body-include', value: 'Use the links below to test this build in android and iOS. Happy testing!'}, + {key: 'number', value: pullRequestNumber}, + {key: 'delete', value: true}, + ], + [], + ), + utils.getStepAssertion( + 'Publish links to apps for download', + true, + null, + 'POSTGITHUBCOMMENT', + 'Publish links to apps for download', + [ + {key: 'PR_NUMBER', value: pullRequestNumber}, + {key: 'GITHUB_TOKEN', value: '***'}, + {key: 'ANDROID', value: androidStatus}, + {key: 'DESKTOP', value: desktopStatus}, + {key: 'IOS', value: iOSStatus}, + {key: 'WEB', value: webStatus}, + {key: 'ANDROID_LINK', value: androidStatus === 'success' ? 'http://dummy.android.link' : ''}, + {key: 'DESKTOP_LINK', value: `https://ad-hoc-expensify-cash.s3.amazonaws.com/desktop/${pullRequestNumber}/NewExpensify.dmg`}, + {key: 'IOS_LINK', value: iOSStatus === 'success' ? 'http://dummy.ios.link' : ''}, + {key: 'WEB_LINK', value: `https://${pullRequestNumber}.pr-testing.expensify.com`}, + ], + [], + ), + ); + + for (const expectedStep of steps) { + if (didExecute) { + expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); + } else { + expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); + } + } +}; + +module.exports = { + assertValidateActorJobExecuted, + assertGetBranchRefJobExecuted, + assertAndroidJobExecuted, + assertIOSJobExecuted, + assertDesktopJobExecuted, + assertWebJobExecuted, + assertPostGithubCommentJobExecuted, +}; diff --git a/workflow_tests/mocks/testBuildMocks.js b/workflow_tests/mocks/testBuildMocks.js new file mode 100644 index 000000000000..b63c35cff452 --- /dev/null +++ b/workflow_tests/mocks/testBuildMocks.js @@ -0,0 +1,379 @@ +const utils = require('../utils/utils'); + +// validateactor +const TESTBUILD__VALIDATEACTOR__IS_TEAM_MEMBER__TRUE__STEP_MOCK = utils.getMockStep( + 'Is team member', + 'Is team member', + 'VALIDATEACTOR', + ['GITHUB_TOKEN', 'username', 'team'], + [], + {isTeamMember: true}, +); +const TESTBUILD__VALIDATEACTOR__IS_TEAM_MEMBER__FALSE__STEP_MOCK = utils.getMockStep( + 'Is team member', + 'Is team member', + 'VALIDATEACTOR', + ['GITHUB_TOKEN', 'username', 'team'], + [], + {isTeamMember: false}, +); +const TESTBUILD__VALIDATEACTOR__SET_HAS_READY_TO_BUILD_LABEL_FLAG__TRUE__STEP_MOCK = utils.getMockStep( + 'Set HAS_READY_TO_BUILD_LABEL flag', + 'Set HAS_READY_TO_BUILD_LABEL flag', + 'VALIDATEACTOR', + [], + ['PULL_REQUEST_NUMBER', 'GITHUB_TOKEN'], + {HAS_READY_TO_BUILD_LABEL: true}, +); +const TESTBUILD__VALIDATEACTOR__SET_HAS_READY_TO_BUILD_LABEL_FLAG__FALSE__STEP_MOCK = utils.getMockStep( + 'Set HAS_READY_TO_BUILD_LABEL flag', + 'Set HAS_READY_TO_BUILD_LABEL flag', + 'VALIDATEACTOR', + [], + ['PULL_REQUEST_NUMBER', 'GITHUB_TOKEN'], + {HAS_READY_TO_BUILD_LABEL: false}, +); +const TESTBUILD__VALIDATEACTOR__TEAM_MEMBER_HAS_FLAG__STEP_MOCKS = [ + TESTBUILD__VALIDATEACTOR__IS_TEAM_MEMBER__TRUE__STEP_MOCK, + TESTBUILD__VALIDATEACTOR__SET_HAS_READY_TO_BUILD_LABEL_FLAG__TRUE__STEP_MOCK, +]; +const TESTBUILD__VALIDATEACTOR__TEAM_MEMBER_NO_FLAG__STEP_MOCKS = [ + TESTBUILD__VALIDATEACTOR__IS_TEAM_MEMBER__TRUE__STEP_MOCK, + TESTBUILD__VALIDATEACTOR__SET_HAS_READY_TO_BUILD_LABEL_FLAG__FALSE__STEP_MOCK, +]; +const TESTBUILD__VALIDATEACTOR__NO_TEAM_MEMBER_HAS_FLAG__STEP_MOCKS = [ + TESTBUILD__VALIDATEACTOR__IS_TEAM_MEMBER__FALSE__STEP_MOCK, + TESTBUILD__VALIDATEACTOR__SET_HAS_READY_TO_BUILD_LABEL_FLAG__TRUE__STEP_MOCK, +]; +const TESTBUILD__VALIDATEACTOR__NO_TEAM_MEMBER_NO_FLAG__STEP_MOCKS = [ + TESTBUILD__VALIDATEACTOR__IS_TEAM_MEMBER__FALSE__STEP_MOCK, + TESTBUILD__VALIDATEACTOR__SET_HAS_READY_TO_BUILD_LABEL_FLAG__FALSE__STEP_MOCK, +]; + +// getbranchref +const TESTBUILD__GETBRANCHREF__CHECKOUT__STEP_MOCK = utils.getMockStep( + 'Checkout', + 'Checkout', + 'GETBRANCHREF', + [], + [], +); +const TESTBUILD__GETBRANCHREF__CHECK_IF_PULL_REQUEST_NUMBER_IS_CORRECT__STEP_MOCK = utils.getMockStep( + 'Check if pull request number is correct', + 'Check if pull request number is correct', + 'GETBRANCHREF', + [], + ['GITHUB_TOKEN'], + {REF: 'test-ref'}, +); +const TESTBUILD__GETBRANCHREF__STEP_MOCKS = [ + TESTBUILD__GETBRANCHREF__CHECKOUT__STEP_MOCK, + TESTBUILD__GETBRANCHREF__CHECK_IF_PULL_REQUEST_NUMBER_IS_CORRECT__STEP_MOCK, +]; + +// android +const TESTBUILD__ANDROID__CHECKOUT__STEP_MOCK = utils.getMockStep( + 'Checkout', + 'Checkout', + 'ANDROID', + ['ref'], + [], +); +const TESTBUILD__ANDROID__SETUP_NODE__STEP_MOCK = utils.getMockStep( + 'Setup Node', + 'Setup Node', + 'ANDROID', + [], + [], +); +const TESTBUILD__ANDROID__SETUP_RUBY__STEP_MOCK = utils.getMockStep( + 'Setup Ruby', + 'Setup Ruby', + 'ANDROID', + ['ruby-version', 'bundler-cache'], + [], +); +const TESTBUILD__ANDROID__DECRYPT_KEYSTORE__STEP_MOCK = utils.getMockStep( + 'Decrypt keystore', + 'Decrypt keystore', + 'ANDROID', + [], + ['LARGE_SECRET_PASSPHRASE'], +); +const TESTBUILD__ANDROID__DECRYPT_JSON_KEY__STEP_MOCK = utils.getMockStep( + 'Decrypt json key', + 'Decrypt json key', + 'ANDROID', + [], + ['LARGE_SECRET_PASSPHRASE'], +); +const TESTBUILD__ANDROID__CONFIGURE_AWS_CREDENTIALS__STEP_MOCK = utils.getMockStep( + 'Configure AWS Credentials', + 'Configure AWS Credentials', + 'ANDROID', + ['AWS_ACCESS_KEY_ID', 'AWS_SECRET_ACCESS_KEY'], + [], +); +const TESTBUILD__ANDROID__RUN_FASTLANE_BETA_TEST__STEP_MOCK = utils.getMockStep( + 'Run Fastlane beta test', + 'Run Fastlane beta test', + 'ANDROID', + [], + ['S3_ACCESS_KEY', 'S3_SECRET_ACCESS_KEY', 'S3_BUCKET', 'S3_REGION'], +); +const TESTBUILD__ANDROID__UPLOAD_ARTIFACT__STEP_MOCK = utils.getMockStep( + 'Upload Artifact', + 'Upload Artifact', + 'ANDROID', + ['name', 'path'], + [], +); +const TESTBUILD__ANDROID__STEP_MOCKS = [ + TESTBUILD__ANDROID__CHECKOUT__STEP_MOCK, + TESTBUILD__ANDROID__SETUP_NODE__STEP_MOCK, + TESTBUILD__ANDROID__SETUP_RUBY__STEP_MOCK, + TESTBUILD__ANDROID__DECRYPT_KEYSTORE__STEP_MOCK, + TESTBUILD__ANDROID__DECRYPT_JSON_KEY__STEP_MOCK, + TESTBUILD__ANDROID__CONFIGURE_AWS_CREDENTIALS__STEP_MOCK, + TESTBUILD__ANDROID__RUN_FASTLANE_BETA_TEST__STEP_MOCK, + TESTBUILD__ANDROID__UPLOAD_ARTIFACT__STEP_MOCK, +]; + +// ios +const TESTBUILD__IOS__CHECKOUT__STEP_MOCK = utils.getMockStep( + 'Checkout', + 'Checkout', + 'IOS', + ['ref'], + [], +); +const TESTBUILD__IOS__SETUP_NODE__STEP_MOCK = utils.getMockStep( + 'Setup Node', + 'Setup Node', + 'IOS', + [], + [], +); +const TESTBUILD__IOS__SETUP_RUBY__STEP_MOCK = utils.getMockStep( + 'Setup Ruby', + 'Setup Ruby', + 'IOS', + ['ruby-version', 'bundler-cache'], + [], +); +const TESTBUILD__IOS__INSTALL_COCOAPODS__STEP_MOCK = utils.getMockStep( + 'Install cocoapods', + 'Install cocoapods', + 'IOS', + ['timeout_minutes', 'max_attempts', 'command'], + [], +); +const TESTBUILD__IOS__DECRYPT_PROFILE__STEP_MOCK = utils.getMockStep( + 'Decrypt profile', + 'Decrypt profile', + 'IOS', + [], + ['LARGE_SECRET_PASSPHRASE'], +); +const TESTBUILD__IOS__DECRYPT_CERTIFICATE__STEP_MOCK = utils.getMockStep( + 'Decrypt certificate', + 'Decrypt certificate', + 'IOS', + [], + ['LARGE_SECRET_PASSPHRASE'], +); +const TESTBUILD__IOS__CONFIGURE_AWS_CREDENTIALS__STEP_MOCK = utils.getMockStep( + 'Configure AWS Credentials', + 'Configure AWS Credentials', + 'IOS', + ['AWS_ACCESS_KEY_ID', 'AWS_SECRET_ACCESS_KEY'], + [], +); +const TESTBUILD__IOS__RUN_FASTLANE__STEP_MOCK = utils.getMockStep( + 'Run Fastlane', + 'Run Fastlane', + 'IOS', + [], + ['S3_ACCESS_KEY', 'S3_SECRET_ACCESS_KEY', 'S3_BUCKET', 'S3_REGION'], +); +const TESTBUILD__IOS__UPLOAD_ARTIFACT__STEP_MOCK = utils.getMockStep( + 'Upload Artifact', + 'Upload Artifact', + 'IOS', + ['name', 'path'], + [], +); +const TESTBUILD__IOS__STEP_MOCKS = [ + TESTBUILD__IOS__CHECKOUT__STEP_MOCK, + TESTBUILD__IOS__SETUP_NODE__STEP_MOCK, + TESTBUILD__IOS__SETUP_RUBY__STEP_MOCK, + TESTBUILD__IOS__INSTALL_COCOAPODS__STEP_MOCK, + TESTBUILD__IOS__DECRYPT_PROFILE__STEP_MOCK, + TESTBUILD__IOS__DECRYPT_CERTIFICATE__STEP_MOCK, + TESTBUILD__IOS__CONFIGURE_AWS_CREDENTIALS__STEP_MOCK, + TESTBUILD__IOS__RUN_FASTLANE__STEP_MOCK, + TESTBUILD__IOS__UPLOAD_ARTIFACT__STEP_MOCK, +]; + +// desktop +const TESTBUILD__DESKTOP__CHECKOUT__STEP_MOCK = utils.getMockStep( + 'Checkout', + 'Checkout', + 'DESKTOP', + ['ref', 'fetch-depth'], + [], +); +const TESTBUILD__DESKTOP__SETUP_NODE__STEP_MOCK = utils.getMockStep( + 'Setup Node', + 'Setup Node', + 'DESKTOP', + [], + [], +); +const TESTBUILD__DESKTOP__DECRYPT_DEVELOPER_ID_CERTIFICATE__STEP_MOCK = utils.getMockStep( + 'Decrypt Developer ID Certificate', + 'Decrypt Developer ID Certificate', + 'DESKTOP', + [], + ['DEVELOPER_ID_SECRET_PASSPHRASE'], +); +const TESTBUILD__DESKTOP__CONFIGURE_AWS_CREDENTIALS__STEP_MOCK = utils.getMockStep( + 'Configure AWS Credentials', + 'Configure AWS Credentials', + 'DESKTOP', + ['AWS_ACCESS_KEY_ID', 'AWS_SECRET_ACCESS_KEY'], + [], +); +const TESTBUILD__DESKTOP__BUILD_DESKTOP_APP_FOR_TESTING__STEP_MOCK = utils.getMockStep( + 'Build desktop app for testing', + 'Build desktop app for testing', + 'DESKTOP', + [], + ['CSC_LINK', 'CSC_KEY_PASSWORD', 'APPLE_ID', 'APPLE_ID_PASSWORD', 'AWS_ACCESS_KEY_ID', 'AWS_SECRET_ACCESS_KEY'], +); +const TESTBUILD__DESKTOP__STEP_MOCKS = [ + TESTBUILD__DESKTOP__CHECKOUT__STEP_MOCK, + TESTBUILD__DESKTOP__SETUP_NODE__STEP_MOCK, + TESTBUILD__DESKTOP__DECRYPT_DEVELOPER_ID_CERTIFICATE__STEP_MOCK, + TESTBUILD__DESKTOP__CONFIGURE_AWS_CREDENTIALS__STEP_MOCK, + TESTBUILD__DESKTOP__BUILD_DESKTOP_APP_FOR_TESTING__STEP_MOCK, +]; + +// web +const TESTBUILD__WEB__CHECKOUT__STEP_MOCK = utils.getMockStep( + 'Checkout', + 'Checkout', + 'WEB', + ['fetch-depth', 'ref'], + [], +); +const TESTBUILD__WEB__SETUP_NODE__STEP_MOCK = utils.getMockStep( + 'Setup Node', + 'Setup Node', + 'WEB', + [], + [], +); +const TESTBUILD__WEB__CONFIGURE_AWS_CREDENTIALS__STEP_MOCK = utils.getMockStep( + 'Configure AWS Credentials', + 'Configure AWS Credentials', + 'WEB', + ['AWS_ACCESS_KEY_ID', 'AWS_SECRET_ACCESS_KEY'], + [], +); +const TESTBUILD__WEB__BUILD_WEB_FOR_TESTING__STEP_MOCK = utils.getMockStep( + 'Build web for testing', + 'Build web for testing', + 'WEB', + [], + [], +); +const TESTBUILD__WEB__BUILD_DOCS__STEP_MOCK = utils.getMockStep( + 'Build docs', + 'Build docs', + 'WEB', + [], + [], +); +const TESTBUILD__WEB__DEPLOY_TO_S3_FOR_INTERNAL_TESTING__STEP_MOCK = utils.getMockStep( + 'Deploy to S3 for internal testing', + 'Deploy to S3 for internal testing', + 'WEB', + [], + [], +); +const TESTBUILD__WEB__STEP_MOCKS = [ + TESTBUILD__WEB__CHECKOUT__STEP_MOCK, + TESTBUILD__WEB__SETUP_NODE__STEP_MOCK, + TESTBUILD__WEB__CONFIGURE_AWS_CREDENTIALS__STEP_MOCK, + TESTBUILD__WEB__BUILD_WEB_FOR_TESTING__STEP_MOCK, + TESTBUILD__WEB__BUILD_DOCS__STEP_MOCK, + TESTBUILD__WEB__DEPLOY_TO_S3_FOR_INTERNAL_TESTING__STEP_MOCK, +]; + +// postgithubcomment +const TESTBUILD__POSTGITHUBCOMMENT__CHECKOUT__STEP_MOCK = utils.getMockStep( + 'Checkout', + 'Checkout', + 'POSTGITHUBCOMMENT', + ['ref'], + [], +); +const TESTBUILD__POSTGITHUBCOMMENT__DOWNLOAD_ARTIFACT__STEP_MOCK = utils.getMockStep( + 'Download Artifact', + 'Download Artifact', + 'POSTGITHUBCOMMENT', + [], + [], +); +const TESTBUILD__POSTGITHUBCOMMENT__READ_JSONS_WITH_ANDROID_PATHS__STEP_MOCK = utils.getMockStep( + 'Read JSONs with android paths', + 'Read JSONs with android paths', + 'POSTGITHUBCOMMENT', + [], + [], + {android_paths: '{\\"html_path\\": \\"http://dummy.android.link\\"}'}, +); +const TESTBUILD__POSTGITHUBCOMMENT__READ_JSONS_WITH_IOS_PATHS__STEP_MOCK = utils.getMockStep( + 'Read JSONs with iOS paths', + 'Read JSONs with iOS paths', + 'POSTGITHUBCOMMENT', + [], + [], + {ios_paths: '{\\"html_path\\": \\"http://dummy.ios.link\\"}'}, +); +const TESTBUILD__POSTGITHUBCOMMENT__MAINTAIN_COMMENT__STEP_MOCK = utils.getMockStep( + 'maintain-comment', + 'maintain-comment', + 'POSTGITHUBCOMMENT', + ['token', 'body-include', 'number', 'delete'], + [], +); +const TESTBUILD__POSTGITHUBCOMMENT__PUBLISH_LINKS_TO_APPS_FOR_DOWNLOAD__STEP_MOCK = utils.getMockStep( + 'Publish links to apps for download', + 'Publish links to apps for download', + 'POSTGITHUBCOMMENT', + ['PR_NUMBER', 'GITHUB_TOKEN', 'ANDROID', 'DESKTOP', 'IOS', 'WEB', 'ANDROID_LINK', 'DESKTOP_LINK', 'IOS_LINK', 'WEB_LINK'], + [], +); +const TESTBUILD__POSTGITHUBCOMMENT__STEP_MOCKS = [ + TESTBUILD__POSTGITHUBCOMMENT__CHECKOUT__STEP_MOCK, + TESTBUILD__POSTGITHUBCOMMENT__DOWNLOAD_ARTIFACT__STEP_MOCK, + TESTBUILD__POSTGITHUBCOMMENT__READ_JSONS_WITH_ANDROID_PATHS__STEP_MOCK, + TESTBUILD__POSTGITHUBCOMMENT__READ_JSONS_WITH_IOS_PATHS__STEP_MOCK, + TESTBUILD__POSTGITHUBCOMMENT__MAINTAIN_COMMENT__STEP_MOCK, + TESTBUILD__POSTGITHUBCOMMENT__PUBLISH_LINKS_TO_APPS_FOR_DOWNLOAD__STEP_MOCK, +]; + +module.exports = { + TESTBUILD__VALIDATEACTOR__TEAM_MEMBER_HAS_FLAG__STEP_MOCKS, + TESTBUILD__VALIDATEACTOR__TEAM_MEMBER_NO_FLAG__STEP_MOCKS, + TESTBUILD__VALIDATEACTOR__NO_TEAM_MEMBER_HAS_FLAG__STEP_MOCKS, + TESTBUILD__VALIDATEACTOR__NO_TEAM_MEMBER_NO_FLAG__STEP_MOCKS, + TESTBUILD__GETBRANCHREF__STEP_MOCKS, + TESTBUILD__ANDROID__STEP_MOCKS, + TESTBUILD__IOS__STEP_MOCKS, + TESTBUILD__DESKTOP__STEP_MOCKS, + TESTBUILD__WEB__STEP_MOCKS, + TESTBUILD__POSTGITHUBCOMMENT__STEP_MOCKS, +}; diff --git a/workflow_tests/testBuild.test.js b/workflow_tests/testBuild.test.js new file mode 100644 index 000000000000..d9dca51e2d07 --- /dev/null +++ b/workflow_tests/testBuild.test.js @@ -0,0 +1,1001 @@ +const path = require('path'); +const kieMockGithub = require('@kie/mock-github'); +const utils = require('./utils/utils'); +const assertions = require('./assertions/testBuildAssertions'); +const mocks = require('./mocks/testBuildMocks'); +const eAct = require('./utils/ExtendedAct'); + +jest.setTimeout(60 * 1000); +let mockGithub; +const FILES_TO_COPY_INTO_TEST_REPO = [ + { + src: path.resolve(__dirname, '..', '.github', 'actions'), + dest: '.github/actions', + }, + { + src: path.resolve(__dirname, '..', '.github', 'libs'), + dest: '.github/libs', + }, + { + src: path.resolve(__dirname, '..', '.github', 'scripts'), + dest: '.github/scripts', + }, + { + src: path.resolve(__dirname, '..', '.github', 'workflows', 'testBuild.yml'), + dest: '.github/workflows/testBuild.yml', + }, +]; + +describe('test workflow testBuild', () => { + const githubToken = 'dummy_github_token'; + const actor = 'Dummy Actor'; + const secrets = { + OS_BOTIFY_TOKEN: 'dummy_osbotify_token', + LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', + AWS_ACCESS_KEY_ID: 'dummy_aws_access_kry_id', + AWS_SECRET_ACCESS_KEY: 'dummy_aws_secret_access_key', + DEVELOPER_ID_SECRET_PASSPHRASE: 'dummy_developer_id_secret_passphrase', + CSC_LINK: 'dummy_csc_link', + CSC_KEY_PASSWORD: 'dummy_csc_key_password', + APPLE_ID_PASSWORD: 'dummy_apple_id_password', + APPLE_ID: 'dummy_apple_id_value', + }; + beforeEach(async () => { + // create a local repository and copy required files + mockGithub = new kieMockGithub.MockGithub({ + repo: { + testTestBuildWorkflowRepo: { + files: FILES_TO_COPY_INTO_TEST_REPO, + }, + }, + }); + + await mockGithub.setup(); + }); + + afterEach(async () => { + await mockGithub.teardown(); + }); + describe('event is workflow_dispatch', () => { + const event = 'workflow_dispatch'; + const inputs = { + PULL_REQUEST_NUMBER: '1234', + }; + it('executes workflow', async () => { + const repoPath = mockGithub.repo.getPath('testTestBuildWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'testBuild.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + act = utils.setUpActParams( + act, + event, + {}, + secrets, + githubToken, + {}, + inputs, + ); + act = utils.setJobRunners( + act, + {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest'}, + workflowPath, + ); + const testMockSteps = { + validateActor: mocks.TESTBUILD__VALIDATEACTOR__TEAM_MEMBER_HAS_FLAG__STEP_MOCKS, + getBranchRef: mocks.TESTBUILD__GETBRANCHREF__STEP_MOCKS, + android: mocks.TESTBUILD__ANDROID__STEP_MOCKS, + iOS: mocks.TESTBUILD__IOS__STEP_MOCKS, + desktop: mocks.TESTBUILD__DESKTOP__STEP_MOCKS, + web: mocks.TESTBUILD__WEB__STEP_MOCKS, + postGithubComment: mocks.TESTBUILD__POSTGITHUBCOMMENT__STEP_MOCKS, + }; + const result = await act + .runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor, + }); + + assertions.assertValidateActorJobExecuted(result, actor, '1234'); + assertions.assertGetBranchRefJobExecuted(result); + assertions.assertAndroidJobExecuted(result, 'test-ref'); + assertions.assertIOSJobExecuted(result, 'test-ref'); + assertions.assertDesktopJobExecuted(result, 'test-ref'); + assertions.assertWebJobExecuted(result, 'test-ref'); + assertions.assertPostGithubCommentJobExecuted(result, 'test-ref'); + }); + describe('actor is not a team member', () => { + it('stops the workflow after validation', async () => { + const repoPath = mockGithub.repo.getPath('testTestBuildWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'testBuild.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + act = utils.setUpActParams( + act, + event, + {}, + secrets, + githubToken, + {}, + inputs, + ); + act = utils.setJobRunners( + act, + {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest'}, + workflowPath, + ); + const testMockSteps = { + validateActor: mocks.TESTBUILD__VALIDATEACTOR__NO_TEAM_MEMBER_HAS_FLAG__STEP_MOCKS, + getBranchRef: mocks.TESTBUILD__GETBRANCHREF__STEP_MOCKS, + android: mocks.TESTBUILD__ANDROID__STEP_MOCKS, + iOS: mocks.TESTBUILD__IOS__STEP_MOCKS, + desktop: mocks.TESTBUILD__DESKTOP__STEP_MOCKS, + web: mocks.TESTBUILD__WEB__STEP_MOCKS, + postGithubComment: mocks.TESTBUILD__POSTGITHUBCOMMENT__STEP_MOCKS, + }; + const result = await act + .runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor, + }); + + assertions.assertValidateActorJobExecuted(result, actor, '1234'); + assertions.assertGetBranchRefJobExecuted(result, false); + assertions.assertAndroidJobExecuted(result, 'test-ref', false); + assertions.assertIOSJobExecuted(result, 'test-ref', false); + assertions.assertDesktopJobExecuted(result, 'test-ref', false); + assertions.assertWebJobExecuted(result, 'test-ref', false); + assertions.assertPostGithubCommentJobExecuted(result, 'test-ref', '1234', false); + }); + }); + describe('PR does not have READY_TO_BUILD label', () => { + it('stops the workflow after validation', async () => { + const repoPath = mockGithub.repo.getPath('testTestBuildWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'testBuild.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + act = utils.setUpActParams( + act, + event, + {}, + secrets, + githubToken, + {}, + inputs, + ); + act = utils.setJobRunners( + act, + {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest'}, + workflowPath, + ); + const testMockSteps = { + validateActor: mocks.TESTBUILD__VALIDATEACTOR__TEAM_MEMBER_NO_FLAG__STEP_MOCKS, + getBranchRef: mocks.TESTBUILD__GETBRANCHREF__STEP_MOCKS, + android: mocks.TESTBUILD__ANDROID__STEP_MOCKS, + iOS: mocks.TESTBUILD__IOS__STEP_MOCKS, + desktop: mocks.TESTBUILD__DESKTOP__STEP_MOCKS, + web: mocks.TESTBUILD__WEB__STEP_MOCKS, + postGithubComment: mocks.TESTBUILD__POSTGITHUBCOMMENT__STEP_MOCKS, + }; + const result = await act + .runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor, + }); + + assertions.assertValidateActorJobExecuted(result, actor, '1234'); + assertions.assertGetBranchRefJobExecuted(result, false); + assertions.assertAndroidJobExecuted(result, 'test-ref', false); + assertions.assertIOSJobExecuted(result, 'test-ref', false); + assertions.assertDesktopJobExecuted(result, 'test-ref', false); + assertions.assertWebJobExecuted(result, 'test-ref', false); + assertions.assertPostGithubCommentJobExecuted(result, 'test-ref', '1234', false); + }); + }); + describe('actor is not a team member and PR does not have READY_TO_BUILD label', () => { + it('stops the workflow after validation', async () => { + const repoPath = mockGithub.repo.getPath('testTestBuildWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'testBuild.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + act = utils.setUpActParams( + act, + event, + {}, + secrets, + githubToken, + {}, + inputs, + ); + act = utils.setJobRunners( + act, + {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest'}, + workflowPath, + ); + const testMockSteps = { + validateActor: mocks.TESTBUILD__VALIDATEACTOR__NO_TEAM_MEMBER_NO_FLAG__STEP_MOCKS, + getBranchRef: mocks.TESTBUILD__GETBRANCHREF__STEP_MOCKS, + android: mocks.TESTBUILD__ANDROID__STEP_MOCKS, + iOS: mocks.TESTBUILD__IOS__STEP_MOCKS, + desktop: mocks.TESTBUILD__DESKTOP__STEP_MOCKS, + web: mocks.TESTBUILD__WEB__STEP_MOCKS, + postGithubComment: mocks.TESTBUILD__POSTGITHUBCOMMENT__STEP_MOCKS, + }; + const result = await act + .runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor, + }); + + assertions.assertValidateActorJobExecuted(result, actor, '1234'); + assertions.assertGetBranchRefJobExecuted(result, false); + assertions.assertAndroidJobExecuted(result, 'test-ref', false); + assertions.assertIOSJobExecuted(result, 'test-ref', false); + assertions.assertDesktopJobExecuted(result, 'test-ref', false); + assertions.assertWebJobExecuted(result, 'test-ref', false); + assertions.assertPostGithubCommentJobExecuted(result, 'test-ref', '1234', false); + }); + }); + describe('android fails', () => { + it('executes workflow, failure reflected', async () => { + const repoPath = mockGithub.repo.getPath('testTestBuildWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'testBuild.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + act = utils.setUpActParams( + act, + event, + {}, + secrets, + githubToken, + {}, + inputs, + ); + act = utils.setJobRunners( + act, + {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest'}, + workflowPath, + ); + const testMockSteps = { + validateActor: mocks.TESTBUILD__VALIDATEACTOR__TEAM_MEMBER_HAS_FLAG__STEP_MOCKS, + getBranchRef: mocks.TESTBUILD__GETBRANCHREF__STEP_MOCKS, + android: utils.deepCopy(mocks.TESTBUILD__ANDROID__STEP_MOCKS), + iOS: mocks.TESTBUILD__IOS__STEP_MOCKS, + desktop: mocks.TESTBUILD__DESKTOP__STEP_MOCKS, + web: mocks.TESTBUILD__WEB__STEP_MOCKS, + postGithubComment: mocks.TESTBUILD__POSTGITHUBCOMMENT__STEP_MOCKS, + }; + testMockSteps.android[3] = utils.getMockStep( + 'Decrypt keystore', + 'Decrypt keystore', + 'ANDROID', + [], + ['LARGE_SECRET_PASSPHRASE'], + {}, + {}, + false, + ); + const result = await act + .runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor, + }); + + assertions.assertValidateActorJobExecuted(result, actor, '1234'); + assertions.assertGetBranchRefJobExecuted(result); + assertions.assertAndroidJobExecuted(result, 'test-ref', true, 3); + assertions.assertIOSJobExecuted(result, 'test-ref'); + assertions.assertDesktopJobExecuted(result, 'test-ref'); + assertions.assertWebJobExecuted(result, 'test-ref'); + assertions.assertPostGithubCommentJobExecuted(result, 'test-ref', '1234', true, 'failure', 'success', 'success', 'success'); + }); + }); + describe('iOS fails', () => { + it('executes workflow, failure reflected', async () => { + const repoPath = mockGithub.repo.getPath('testTestBuildWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'testBuild.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + act = utils.setUpActParams( + act, + event, + {}, + secrets, + githubToken, + {}, + inputs, + ); + act = utils.setJobRunners( + act, + {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest'}, + workflowPath, + ); + const testMockSteps = { + validateActor: mocks.TESTBUILD__VALIDATEACTOR__TEAM_MEMBER_HAS_FLAG__STEP_MOCKS, + getBranchRef: mocks.TESTBUILD__GETBRANCHREF__STEP_MOCKS, + android: mocks.TESTBUILD__ANDROID__STEP_MOCKS, + iOS: utils.deepCopy(mocks.TESTBUILD__IOS__STEP_MOCKS), + desktop: mocks.TESTBUILD__DESKTOP__STEP_MOCKS, + web: mocks.TESTBUILD__WEB__STEP_MOCKS, + postGithubComment: mocks.TESTBUILD__POSTGITHUBCOMMENT__STEP_MOCKS, + }; + testMockSteps.iOS[3] = utils.getMockStep( + 'Install cocoapods', + 'Install cocoapods', + 'IOS', + ['timeout_minutes', 'max_attempts', 'command'], + [], + {}, + {}, + false, + ); + const result = await act + .runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor, + }); + + assertions.assertValidateActorJobExecuted(result, actor, '1234'); + assertions.assertGetBranchRefJobExecuted(result); + assertions.assertAndroidJobExecuted(result, 'test-ref'); + assertions.assertIOSJobExecuted(result, 'test-ref', true, 3); + assertions.assertDesktopJobExecuted(result, 'test-ref'); + assertions.assertWebJobExecuted(result, 'test-ref'); + assertions.assertPostGithubCommentJobExecuted(result, 'test-ref', '1234', true, 'success', 'failure', 'success', 'success'); + }); + }); + describe('desktop fails', () => { + it('executes workflow, failure reflected', async () => { + const repoPath = mockGithub.repo.getPath('testTestBuildWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'testBuild.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + act = utils.setUpActParams( + act, + event, + {}, + secrets, + githubToken, + {}, + inputs, + ); + act = utils.setJobRunners( + act, + {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest'}, + workflowPath, + ); + const testMockSteps = { + validateActor: mocks.TESTBUILD__VALIDATEACTOR__TEAM_MEMBER_HAS_FLAG__STEP_MOCKS, + getBranchRef: mocks.TESTBUILD__GETBRANCHREF__STEP_MOCKS, + android: mocks.TESTBUILD__ANDROID__STEP_MOCKS, + iOS: mocks.TESTBUILD__IOS__STEP_MOCKS, + desktop: utils.deepCopy(mocks.TESTBUILD__DESKTOP__STEP_MOCKS), + web: mocks.TESTBUILD__WEB__STEP_MOCKS, + postGithubComment: mocks.TESTBUILD__POSTGITHUBCOMMENT__STEP_MOCKS, + }; + testMockSteps.desktop[2] = utils.getMockStep( + 'Decrypt Developer ID Certificate', + 'Decrypt Developer ID Certificate', + 'DESKTOP', + [], + ['DEVELOPER_ID_SECRET_PASSPHRASE'], + {}, + {}, + false, + ); + const result = await act + .runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor, + }); + + assertions.assertValidateActorJobExecuted(result, actor, '1234'); + assertions.assertGetBranchRefJobExecuted(result); + assertions.assertAndroidJobExecuted(result, 'test-ref'); + assertions.assertIOSJobExecuted(result, 'test-ref'); + assertions.assertDesktopJobExecuted(result, 'test-ref', true, 2); + assertions.assertWebJobExecuted(result, 'test-ref'); + assertions.assertPostGithubCommentJobExecuted(result, 'test-ref', '1234', true, 'success', 'success', 'failure', 'success'); + }); + }); + describe('web fails', () => { + it('executes workflow, failure reflected', async () => { + const repoPath = mockGithub.repo.getPath('testTestBuildWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'testBuild.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + act = utils.setUpActParams( + act, + event, + {}, + secrets, + githubToken, + {}, + inputs, + ); + act = utils.setJobRunners( + act, + {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest'}, + workflowPath, + ); + const testMockSteps = { + validateActor: mocks.TESTBUILD__VALIDATEACTOR__TEAM_MEMBER_HAS_FLAG__STEP_MOCKS, + getBranchRef: mocks.TESTBUILD__GETBRANCHREF__STEP_MOCKS, + android: mocks.TESTBUILD__ANDROID__STEP_MOCKS, + iOS: mocks.TESTBUILD__IOS__STEP_MOCKS, + desktop: mocks.TESTBUILD__DESKTOP__STEP_MOCKS, + web: utils.deepCopy(mocks.TESTBUILD__WEB__STEP_MOCKS), + postGithubComment: mocks.TESTBUILD__POSTGITHUBCOMMENT__STEP_MOCKS, + }; + testMockSteps.web[2] = utils.getMockStep( + 'Configure AWS Credentials', + 'Configure AWS Credentials', + 'WEB', + ['AWS_ACCESS_KEY_ID', 'AWS_SECRET_ACCESS_KEY'], + [], + {}, + {}, + false, + ); + const result = await act + .runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor, + }); + + assertions.assertValidateActorJobExecuted(result, actor, '1234'); + assertions.assertGetBranchRefJobExecuted(result); + assertions.assertAndroidJobExecuted(result, 'test-ref'); + assertions.assertIOSJobExecuted(result, 'test-ref'); + assertions.assertDesktopJobExecuted(result, 'test-ref'); + assertions.assertWebJobExecuted(result, 'test-ref', true, 2); + assertions.assertPostGithubCommentJobExecuted(result, 'test-ref', '1234', true, 'success', 'success', 'success', 'failure'); + }); + }); + }); + describe('pull request opened', () => { + const event = 'pull_request_target'; + const eventOptions = { + action: 'opened', + number: '1234', + pull_request: { + head: { + sha: 'test-ref', + }, + }, + }; + it('executes workflow, withuout getBranchRef', async () => { + const repoPath = mockGithub.repo.getPath('testTestBuildWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'testBuild.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + act = utils.setUpActParams( + act, + event, + eventOptions, + secrets, + githubToken, + {}, + ); + act = utils.setJobRunners( + act, + {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest'}, + workflowPath, + ); + const testMockSteps = { + validateActor: mocks.TESTBUILD__VALIDATEACTOR__TEAM_MEMBER_HAS_FLAG__STEP_MOCKS, + getBranchRef: mocks.TESTBUILD__GETBRANCHREF__STEP_MOCKS, + android: mocks.TESTBUILD__ANDROID__STEP_MOCKS, + iOS: mocks.TESTBUILD__IOS__STEP_MOCKS, + desktop: mocks.TESTBUILD__DESKTOP__STEP_MOCKS, + web: mocks.TESTBUILD__WEB__STEP_MOCKS, + postGithubComment: mocks.TESTBUILD__POSTGITHUBCOMMENT__STEP_MOCKS, + }; + const result = await act + .runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor, + }); + + assertions.assertValidateActorJobExecuted(result, actor, '1234'); + assertions.assertGetBranchRefJobExecuted(result, false); + assertions.assertAndroidJobExecuted(result, 'test-ref'); + assertions.assertIOSJobExecuted(result, 'test-ref'); + assertions.assertDesktopJobExecuted(result, 'test-ref'); + assertions.assertWebJobExecuted(result, 'test-ref'); + assertions.assertPostGithubCommentJobExecuted(result, 'test-ref'); + }); + describe('actor is not a team member', () => { + it('stops the workflow after validation', async () => { + const repoPath = mockGithub.repo.getPath('testTestBuildWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'testBuild.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + act = utils.setUpActParams( + act, + event, + eventOptions, + secrets, + githubToken, + {}, + ); + act = utils.setJobRunners( + act, + {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest'}, + workflowPath, + ); + const testMockSteps = { + validateActor: mocks.TESTBUILD__VALIDATEACTOR__NO_TEAM_MEMBER_HAS_FLAG__STEP_MOCKS, + getBranchRef: mocks.TESTBUILD__GETBRANCHREF__STEP_MOCKS, + android: mocks.TESTBUILD__ANDROID__STEP_MOCKS, + iOS: mocks.TESTBUILD__IOS__STEP_MOCKS, + desktop: mocks.TESTBUILD__DESKTOP__STEP_MOCKS, + web: mocks.TESTBUILD__WEB__STEP_MOCKS, + postGithubComment: mocks.TESTBUILD__POSTGITHUBCOMMENT__STEP_MOCKS, + }; + const result = await act + .runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor, + }); + + assertions.assertValidateActorJobExecuted(result, actor, '1234'); + assertions.assertGetBranchRefJobExecuted(result, false); + assertions.assertAndroidJobExecuted(result, 'test-ref', false); + assertions.assertIOSJobExecuted(result, 'test-ref', false); + assertions.assertDesktopJobExecuted(result, 'test-ref', false); + assertions.assertWebJobExecuted(result, 'test-ref', false); + assertions.assertPostGithubCommentJobExecuted(result, 'test-ref', '1234', false); + }); + }); + describe('PR does not have READY_TO_BUILD label', () => { + it('stops the workflow after validation', async () => { + const repoPath = mockGithub.repo.getPath('testTestBuildWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'testBuild.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + act = utils.setUpActParams( + act, + event, + eventOptions, + secrets, + githubToken, + {}, + ); + act = utils.setJobRunners( + act, + {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest'}, + workflowPath, + ); + const testMockSteps = { + validateActor: mocks.TESTBUILD__VALIDATEACTOR__TEAM_MEMBER_NO_FLAG__STEP_MOCKS, + getBranchRef: mocks.TESTBUILD__GETBRANCHREF__STEP_MOCKS, + android: mocks.TESTBUILD__ANDROID__STEP_MOCKS, + iOS: mocks.TESTBUILD__IOS__STEP_MOCKS, + desktop: mocks.TESTBUILD__DESKTOP__STEP_MOCKS, + web: mocks.TESTBUILD__WEB__STEP_MOCKS, + postGithubComment: mocks.TESTBUILD__POSTGITHUBCOMMENT__STEP_MOCKS, + }; + const result = await act + .runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor, + }); + + assertions.assertValidateActorJobExecuted(result, actor, '1234'); + assertions.assertGetBranchRefJobExecuted(result, false); + assertions.assertAndroidJobExecuted(result, 'test-ref', false); + assertions.assertIOSJobExecuted(result, 'test-ref', false); + assertions.assertDesktopJobExecuted(result, 'test-ref', false); + assertions.assertWebJobExecuted(result, 'test-ref', false); + assertions.assertPostGithubCommentJobExecuted(result, 'test-ref', '1234', false); + }); + }); + describe('actor is not a team member and PR does not have READY_TO_BUILD label', () => { + it('stops the workflow after validation', async () => { + const repoPath = mockGithub.repo.getPath('testTestBuildWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'testBuild.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + act = utils.setUpActParams( + act, + event, + eventOptions, + secrets, + githubToken, + {}, + ); + act = utils.setJobRunners( + act, + {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest'}, + workflowPath, + ); + const testMockSteps = { + validateActor: mocks.TESTBUILD__VALIDATEACTOR__NO_TEAM_MEMBER_NO_FLAG__STEP_MOCKS, + getBranchRef: mocks.TESTBUILD__GETBRANCHREF__STEP_MOCKS, + android: mocks.TESTBUILD__ANDROID__STEP_MOCKS, + iOS: mocks.TESTBUILD__IOS__STEP_MOCKS, + desktop: mocks.TESTBUILD__DESKTOP__STEP_MOCKS, + web: mocks.TESTBUILD__WEB__STEP_MOCKS, + postGithubComment: mocks.TESTBUILD__POSTGITHUBCOMMENT__STEP_MOCKS, + }; + const result = await act + .runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor, + }); + + assertions.assertValidateActorJobExecuted(result, actor, '1234'); + assertions.assertGetBranchRefJobExecuted(result, false); + assertions.assertAndroidJobExecuted(result, 'test-ref', false); + assertions.assertIOSJobExecuted(result, 'test-ref', false); + assertions.assertDesktopJobExecuted(result, 'test-ref', false); + assertions.assertWebJobExecuted(result, 'test-ref', false); + assertions.assertPostGithubCommentJobExecuted(result, 'test-ref', '1234', false); + }); + }); + }); + describe('pull request synchronized', () => { + const event = 'pull_request_target'; + const eventOptions = { + action: 'synchronize', + number: '1234', + pull_request: { + head: { + sha: 'test-ref', + }, + }, + }; + it('executes workflow, withuout getBranchRef', async () => { + const repoPath = mockGithub.repo.getPath('testTestBuildWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'testBuild.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + act = utils.setUpActParams( + act, + event, + eventOptions, + secrets, + githubToken, + {}, + ); + act = utils.setJobRunners( + act, + {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest'}, + workflowPath, + ); + const testMockSteps = { + validateActor: mocks.TESTBUILD__VALIDATEACTOR__TEAM_MEMBER_HAS_FLAG__STEP_MOCKS, + getBranchRef: mocks.TESTBUILD__GETBRANCHREF__STEP_MOCKS, + android: mocks.TESTBUILD__ANDROID__STEP_MOCKS, + iOS: mocks.TESTBUILD__IOS__STEP_MOCKS, + desktop: mocks.TESTBUILD__DESKTOP__STEP_MOCKS, + web: mocks.TESTBUILD__WEB__STEP_MOCKS, + postGithubComment: mocks.TESTBUILD__POSTGITHUBCOMMENT__STEP_MOCKS, + }; + const result = await act + .runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor, + }); + + assertions.assertValidateActorJobExecuted(result, actor, '1234'); + assertions.assertGetBranchRefJobExecuted(result, false); + assertions.assertAndroidJobExecuted(result, 'test-ref'); + assertions.assertIOSJobExecuted(result, 'test-ref'); + assertions.assertDesktopJobExecuted(result, 'test-ref'); + assertions.assertWebJobExecuted(result, 'test-ref'); + assertions.assertPostGithubCommentJobExecuted(result, 'test-ref'); + }); + describe('actor is not a team member', () => { + it('stops the workflow after validation', async () => { + const repoPath = mockGithub.repo.getPath('testTestBuildWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'testBuild.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + act = utils.setUpActParams( + act, + event, + eventOptions, + secrets, + githubToken, + {}, + ); + act = utils.setJobRunners( + act, + {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest'}, + workflowPath, + ); + const testMockSteps = { + validateActor: mocks.TESTBUILD__VALIDATEACTOR__NO_TEAM_MEMBER_HAS_FLAG__STEP_MOCKS, + getBranchRef: mocks.TESTBUILD__GETBRANCHREF__STEP_MOCKS, + android: mocks.TESTBUILD__ANDROID__STEP_MOCKS, + iOS: mocks.TESTBUILD__IOS__STEP_MOCKS, + desktop: mocks.TESTBUILD__DESKTOP__STEP_MOCKS, + web: mocks.TESTBUILD__WEB__STEP_MOCKS, + postGithubComment: mocks.TESTBUILD__POSTGITHUBCOMMENT__STEP_MOCKS, + }; + const result = await act + .runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor, + }); + + assertions.assertValidateActorJobExecuted(result, actor, '1234'); + assertions.assertGetBranchRefJobExecuted(result, false); + assertions.assertAndroidJobExecuted(result, 'test-ref', false); + assertions.assertIOSJobExecuted(result, 'test-ref', false); + assertions.assertDesktopJobExecuted(result, 'test-ref', false); + assertions.assertWebJobExecuted(result, 'test-ref', false); + assertions.assertPostGithubCommentJobExecuted(result, 'test-ref', '1234', false); + }); + }); + describe('PR does not have READY_TO_BUILD label', () => { + it('stops the workflow after validation', async () => { + const repoPath = mockGithub.repo.getPath('testTestBuildWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'testBuild.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + act = utils.setUpActParams( + act, + event, + eventOptions, + secrets, + githubToken, + {}, + ); + act = utils.setJobRunners( + act, + {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest'}, + workflowPath, + ); + const testMockSteps = { + validateActor: mocks.TESTBUILD__VALIDATEACTOR__TEAM_MEMBER_NO_FLAG__STEP_MOCKS, + getBranchRef: mocks.TESTBUILD__GETBRANCHREF__STEP_MOCKS, + android: mocks.TESTBUILD__ANDROID__STEP_MOCKS, + iOS: mocks.TESTBUILD__IOS__STEP_MOCKS, + desktop: mocks.TESTBUILD__DESKTOP__STEP_MOCKS, + web: mocks.TESTBUILD__WEB__STEP_MOCKS, + postGithubComment: mocks.TESTBUILD__POSTGITHUBCOMMENT__STEP_MOCKS, + }; + const result = await act + .runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor, + }); + + assertions.assertValidateActorJobExecuted(result, actor, '1234'); + assertions.assertGetBranchRefJobExecuted(result, false); + assertions.assertAndroidJobExecuted(result, 'test-ref', false); + assertions.assertIOSJobExecuted(result, 'test-ref', false); + assertions.assertDesktopJobExecuted(result, 'test-ref', false); + assertions.assertWebJobExecuted(result, 'test-ref', false); + assertions.assertPostGithubCommentJobExecuted(result, 'test-ref', '1234', false); + }); + }); + describe('actor is not a team member and PR does not have READY_TO_BUILD label', () => { + it('stops the workflow after validation', async () => { + const repoPath = mockGithub.repo.getPath('testTestBuildWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'testBuild.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + act = utils.setUpActParams( + act, + event, + eventOptions, + secrets, + githubToken, + {}, + ); + act = utils.setJobRunners( + act, + {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest'}, + workflowPath, + ); + const testMockSteps = { + validateActor: mocks.TESTBUILD__VALIDATEACTOR__NO_TEAM_MEMBER_NO_FLAG__STEP_MOCKS, + getBranchRef: mocks.TESTBUILD__GETBRANCHREF__STEP_MOCKS, + android: mocks.TESTBUILD__ANDROID__STEP_MOCKS, + iOS: mocks.TESTBUILD__IOS__STEP_MOCKS, + desktop: mocks.TESTBUILD__DESKTOP__STEP_MOCKS, + web: mocks.TESTBUILD__WEB__STEP_MOCKS, + postGithubComment: mocks.TESTBUILD__POSTGITHUBCOMMENT__STEP_MOCKS, + }; + const result = await act + .runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor, + }); + + assertions.assertValidateActorJobExecuted(result, actor, '1234'); + assertions.assertGetBranchRefJobExecuted(result, false); + assertions.assertAndroidJobExecuted(result, 'test-ref', false); + assertions.assertIOSJobExecuted(result, 'test-ref', false); + assertions.assertDesktopJobExecuted(result, 'test-ref', false); + assertions.assertWebJobExecuted(result, 'test-ref', false); + assertions.assertPostGithubCommentJobExecuted(result, 'test-ref', '1234', false); + }); + }); + }); + describe('pull request labeled', () => { + const event = 'pull_request_target'; + const eventOptions = { + action: 'labeled', + number: '1234', + pull_request: { + head: { + sha: 'test-ref', + }, + }, + }; + it('executes workflow, withuout getBranchRef', async () => { + const repoPath = mockGithub.repo.getPath('testTestBuildWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'testBuild.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + act = utils.setUpActParams( + act, + event, + eventOptions, + secrets, + githubToken, + {}, + ); + act = utils.setJobRunners( + act, + {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest'}, + workflowPath, + ); + const testMockSteps = { + validateActor: mocks.TESTBUILD__VALIDATEACTOR__TEAM_MEMBER_HAS_FLAG__STEP_MOCKS, + getBranchRef: mocks.TESTBUILD__GETBRANCHREF__STEP_MOCKS, + android: mocks.TESTBUILD__ANDROID__STEP_MOCKS, + iOS: mocks.TESTBUILD__IOS__STEP_MOCKS, + desktop: mocks.TESTBUILD__DESKTOP__STEP_MOCKS, + web: mocks.TESTBUILD__WEB__STEP_MOCKS, + postGithubComment: mocks.TESTBUILD__POSTGITHUBCOMMENT__STEP_MOCKS, + }; + const result = await act + .runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor, + }); + + assertions.assertValidateActorJobExecuted(result, actor, '1234'); + assertions.assertGetBranchRefJobExecuted(result, false); + assertions.assertAndroidJobExecuted(result, 'test-ref'); + assertions.assertIOSJobExecuted(result, 'test-ref'); + assertions.assertDesktopJobExecuted(result, 'test-ref'); + assertions.assertWebJobExecuted(result, 'test-ref'); + assertions.assertPostGithubCommentJobExecuted(result, 'test-ref'); + }); + describe('actor is not a team member', () => { + it('stops the workflow after validation', async () => { + const repoPath = mockGithub.repo.getPath('testTestBuildWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'testBuild.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + act = utils.setUpActParams( + act, + event, + eventOptions, + secrets, + githubToken, + {}, + ); + act = utils.setJobRunners( + act, + {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest'}, + workflowPath, + ); + const testMockSteps = { + validateActor: mocks.TESTBUILD__VALIDATEACTOR__NO_TEAM_MEMBER_HAS_FLAG__STEP_MOCKS, + getBranchRef: mocks.TESTBUILD__GETBRANCHREF__STEP_MOCKS, + android: mocks.TESTBUILD__ANDROID__STEP_MOCKS, + iOS: mocks.TESTBUILD__IOS__STEP_MOCKS, + desktop: mocks.TESTBUILD__DESKTOP__STEP_MOCKS, + web: mocks.TESTBUILD__WEB__STEP_MOCKS, + postGithubComment: mocks.TESTBUILD__POSTGITHUBCOMMENT__STEP_MOCKS, + }; + const result = await act + .runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor, + }); + + assertions.assertValidateActorJobExecuted(result, actor, '1234'); + assertions.assertGetBranchRefJobExecuted(result, false); + assertions.assertAndroidJobExecuted(result, 'test-ref', false); + assertions.assertIOSJobExecuted(result, 'test-ref', false); + assertions.assertDesktopJobExecuted(result, 'test-ref', false); + assertions.assertWebJobExecuted(result, 'test-ref', false); + assertions.assertPostGithubCommentJobExecuted(result, 'test-ref', '1234', false); + }); + }); + describe('PR does not have READY_TO_BUILD label', () => { + it('stops the workflow after validation', async () => { + const repoPath = mockGithub.repo.getPath('testTestBuildWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'testBuild.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + act = utils.setUpActParams( + act, + event, + eventOptions, + secrets, + githubToken, + {}, + ); + act = utils.setJobRunners( + act, + {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest'}, + workflowPath, + ); + const testMockSteps = { + validateActor: mocks.TESTBUILD__VALIDATEACTOR__TEAM_MEMBER_NO_FLAG__STEP_MOCKS, + getBranchRef: mocks.TESTBUILD__GETBRANCHREF__STEP_MOCKS, + android: mocks.TESTBUILD__ANDROID__STEP_MOCKS, + iOS: mocks.TESTBUILD__IOS__STEP_MOCKS, + desktop: mocks.TESTBUILD__DESKTOP__STEP_MOCKS, + web: mocks.TESTBUILD__WEB__STEP_MOCKS, + postGithubComment: mocks.TESTBUILD__POSTGITHUBCOMMENT__STEP_MOCKS, + }; + const result = await act + .runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor, + }); + + assertions.assertValidateActorJobExecuted(result, actor, '1234'); + assertions.assertGetBranchRefJobExecuted(result, false); + assertions.assertAndroidJobExecuted(result, 'test-ref', false); + assertions.assertIOSJobExecuted(result, 'test-ref', false); + assertions.assertDesktopJobExecuted(result, 'test-ref', false); + assertions.assertWebJobExecuted(result, 'test-ref', false); + assertions.assertPostGithubCommentJobExecuted(result, 'test-ref', '1234', false); + }); + }); + describe('actor is not a team member and PR does not have READY_TO_BUILD label', () => { + it('stops the workflow after validation', async () => { + const repoPath = mockGithub.repo.getPath('testTestBuildWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'testBuild.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + act = utils.setUpActParams( + act, + event, + eventOptions, + secrets, + githubToken, + {}, + ); + act = utils.setJobRunners( + act, + {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest'}, + workflowPath, + ); + const testMockSteps = { + validateActor: mocks.TESTBUILD__VALIDATEACTOR__NO_TEAM_MEMBER_NO_FLAG__STEP_MOCKS, + getBranchRef: mocks.TESTBUILD__GETBRANCHREF__STEP_MOCKS, + android: mocks.TESTBUILD__ANDROID__STEP_MOCKS, + iOS: mocks.TESTBUILD__IOS__STEP_MOCKS, + desktop: mocks.TESTBUILD__DESKTOP__STEP_MOCKS, + web: mocks.TESTBUILD__WEB__STEP_MOCKS, + postGithubComment: mocks.TESTBUILD__POSTGITHUBCOMMENT__STEP_MOCKS, + }; + const result = await act + .runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor, + }); + + assertions.assertValidateActorJobExecuted(result, actor, '1234'); + assertions.assertGetBranchRefJobExecuted(result, false); + assertions.assertAndroidJobExecuted(result, 'test-ref', false); + assertions.assertIOSJobExecuted(result, 'test-ref', false); + assertions.assertDesktopJobExecuted(result, 'test-ref', false); + assertions.assertWebJobExecuted(result, 'test-ref', false); + assertions.assertPostGithubCommentJobExecuted(result, 'test-ref', '1234', false); + }); + }); + }); +}); From b54d479fb0bc8f530988683dcfc1ab5d14acf9ae Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Tue, 28 Mar 2023 15:02:54 +0200 Subject: [PATCH 067/504] Fix tests Fixed `cherryPick` tests that started failing after a recent refactor See: https://github.com/Expensify/App/issues/13604 --- workflow_tests/README.md | 8 +- workflow_tests/cherryPick.test.js | 629 +++++++++++++++++++----- workflow_tests/mocks/cherryPickMocks.js | 12 +- workflow_tests/utils/utils.js | 2 +- 4 files changed, 516 insertions(+), 135 deletions(-) diff --git a/workflow_tests/README.md b/workflow_tests/README.md index 00d48da8e5fa..49a5c73649fa 100644 --- a/workflow_tests/README.md +++ b/workflow_tests/README.md @@ -399,4 +399,10 @@ assertions.assertSomethingDidNotHappen(result, false); ## FAQ ### I'm positive that one of the jobs should run, but it doesn't - why? -#### Check the runner type (`runs-on`) it may not be set (which `Act` does not like) or it may be set one of the unsupported types (primarily the `macos-...` runner types). You can always overwrite the runner type with `utils.setJobRunners()` helper method +#### Check the runner type (`runs-on`) it may not be set (which `Act` does not like) or it may be set to one of the unsupported types (primarily the `macos-...` runner types). You can always overwrite the runner type with `utils.setJobRunners()` helper method +### My workflow has many jobs, each with many steps, how do I start testing it without spending hours on setup? +#### First of all, consider splitting the workflow into several smaller pieces, with the main one acting as coordinator and calling the others. Secondly, you can bootstrap the test with `npm run workflow-test:generate .yml`, which will generate mocks and assertions for you, as well as the stub of the test file +### After using `workflow-test:generate` the files are incomplete, or they have errors. Why? +#### Make sure that the workflow file you want to test, has all steps with names, as the bootstrapping script uses step names to locate and mock them - same with assertions +### I want to just run the test that I am working on, without all the others - how can I do it? +#### You can pass parameters to the `npm run workflow-test` command as you would with `jest` or `npm test` - `npm run workflow-test -- -i ` will run just the tests within `testfile`. You can also filter further with `-t ` diff --git a/workflow_tests/cherryPick.test.js b/workflow_tests/cherryPick.test.js index 9a95a2da038a..b5ad050886bd 100644 --- a/workflow_tests/cherryPick.test.js +++ b/workflow_tests/cherryPick.test.js @@ -26,37 +26,6 @@ const FILES_TO_COPY_INTO_TEST_REPO = [ }, ]; -const runWorkflow = async (act, event, repoPath, testMockSteps, actor) => await act - .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows'), - mockSteps: testMockSteps, - actor, - }); - -const getPathsAndAct = () => { - const repoPath = mockGithub.repo.getPath('testCherryPickWorkflowRepo') || ''; - const workflowPath = path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'); - const act = new eAct.ExtendedAct(repoPath, workflowPath); - return {repoPath, workflowPath, act}; -}; - -const setUpActParams = (act, event, newVersion) => utils.setUpActParams( - act, - event, - null, - { - OS_BOTIFY_TOKEN: 'dummy_token', - LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', - SLACK_WEBHOOK: 'dummy_slack_webhook', - }, - 'dummy_github_token', - null, - { - PULL_REQUEST_NUMBER: '1234', - NEW_VERSION: newVersion, - }, -); - describe('test workflow cherryPick', () => { beforeEach(async () => { // create a local repository and copy required files @@ -77,11 +46,6 @@ describe('test workflow cherryPick', () => { describe('manual workflow dispatch', () => { const event = 'workflow_dispatch'; describe('actor is not deployer', () => { - const testMockSteps = { - validateActor: mocks.CHERRYPICK__VALIDATEACTOR__FALSE__STEP_MOCKS, - createNewVersion: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, - cherryPick: mocks.getCherryPickMockSteps(true, true, true), - }; const actor = 'Dummy Author'; it('workflow ends after validate job', async () => { const repoPath = mockGithub.repo.getPath('testCherryPickWorkflowRepo') || ''; @@ -103,6 +67,11 @@ describe('test workflow cherryPick', () => { NEW_VERSION: '', }, ); + const testMockSteps = { + validateActor: mocks.CHERRYPICK__VALIDATEACTOR__FALSE__STEP_MOCKS, + createNewVersion: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, + cherryPick: mocks.getCherryPickMockSteps(true, true, true), + }; const result = await act .runEvent(event, { workflowFile: path.join(repoPath, '.github', 'workflows'), @@ -116,22 +85,42 @@ describe('test workflow cherryPick', () => { }); }); describe('actor is OSBotify', () => { - const testMockSteps = { - validateActor: mocks.CHERRYPICK__VALIDATEACTOR__FALSE__STEP_MOCKS, - createNewVersion: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, - }; const actor = 'OSBotify'; const newVersion = ''; const mergeConflicts = false; const versionsMatch = true; const prIsMergeable = true; it('behaviour is the same as with actor being the deployer', async () => { - const pathsAndAct = getPathsAndAct(); - const repoPath = pathsAndAct.repoPath; - let act = pathsAndAct.act; - testMockSteps.cherryPick = mocks.getCherryPickMockSteps(versionsMatch, prIsMergeable, !mergeConflicts); - act = setUpActParams(act, event, newVersion); - const result = await runWorkflow(act, event, repoPath, testMockSteps, actor); + const repoPath = mockGithub.repo.getPath('testCherryPickWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + const testMockSteps = { + validateActor: mocks.CHERRYPICK__VALIDATEACTOR__FALSE__STEP_MOCKS, + createNewVersion: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, + cherryPick: mocks.getCherryPickMockSteps(versionsMatch, prIsMergeable, !mergeConflicts), + }; + act = utils.setUpActParams( + act, + event, + null, + { + OS_BOTIFY_TOKEN: 'dummy_token', + LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', + SLACK_WEBHOOK: 'dummy_slack_webhook', + }, + 'dummy_github_token', + null, + { + PULL_REQUEST_NUMBER: '1234', + NEW_VERSION: newVersion, + }, + ); + const result = await act + .runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor, + }); assertions.assertValidateActorJobExecuted(result, actor); assertions.assertCreateNewVersionJobExecuted(result); @@ -150,10 +139,6 @@ describe('test workflow cherryPick', () => { }); }); describe('actor is a deployer', () => { - const testMockSteps = { - validateActor: mocks.CHERRYPICK__VALIDATEACTOR__TRUE__STEP_MOCKS, - createNewVersion: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, - }; const actor = 'Dummy Author'; describe('input version not set', () => { const newVersion = ''; @@ -164,12 +149,36 @@ describe('test workflow cherryPick', () => { describe('PR is mergeable', () => { const prIsMergeable = true; it('workflow executes, new version created, PR approved and merged automatically', async () => { - const pathsAndAct = getPathsAndAct(); - const repoPath = pathsAndAct.repoPath; - let act = pathsAndAct.act; + const repoPath = mockGithub.repo.getPath('testCherryPickWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + const testMockSteps = { + validateActor: mocks.CHERRYPICK__VALIDATEACTOR__TRUE__STEP_MOCKS, + createNewVersion: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, + }; testMockSteps.cherryPick = mocks.getCherryPickMockSteps(versionsMatch, prIsMergeable, !mergeConflicts); - act = setUpActParams(act, event, newVersion); - const result = await runWorkflow(act, event, repoPath, testMockSteps, actor); + act = utils.setUpActParams( + act, + event, + null, + { + OS_BOTIFY_TOKEN: 'dummy_token', + LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', + SLACK_WEBHOOK: 'dummy_slack_webhook', + }, + 'dummy_github_token', + null, + { + PULL_REQUEST_NUMBER: '1234', + NEW_VERSION: newVersion, + }, + ); + const result = await act + .runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor, + }); assertions.assertValidateActorJobExecuted(result, actor); assertions.assertCreateNewVersionJobExecuted(result); @@ -190,12 +199,36 @@ describe('test workflow cherryPick', () => { describe('PR is not mergeable', () => { const prIsMergeable = false; it('workflow executes, new version created, PR is not merged automatically', async () => { - const pathsAndAct = getPathsAndAct(); - const repoPath = pathsAndAct.repoPath; - let act = pathsAndAct.act; + const repoPath = mockGithub.repo.getPath('testCherryPickWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + const testMockSteps = { + validateActor: mocks.CHERRYPICK__VALIDATEACTOR__TRUE__STEP_MOCKS, + createNewVersion: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, + }; testMockSteps.cherryPick = mocks.getCherryPickMockSteps(versionsMatch, prIsMergeable, !mergeConflicts); - act = setUpActParams(act, event, newVersion); - const result = await runWorkflow(act, event, repoPath, testMockSteps, actor); + act = utils.setUpActParams( + act, + event, + null, + { + OS_BOTIFY_TOKEN: 'dummy_token', + LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', + SLACK_WEBHOOK: 'dummy_slack_webhook', + }, + 'dummy_github_token', + null, + { + PULL_REQUEST_NUMBER: '1234', + NEW_VERSION: newVersion, + }, + ); + const result = await act + .runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor, + }); assertions.assertValidateActorJobExecuted(result, actor); assertions.assertCreateNewVersionJobExecuted(result); @@ -219,12 +252,36 @@ describe('test workflow cherryPick', () => { describe('PR is mergeable', () => { const prIsMergeable = true; it('workflow executes, new version created, PR auto-assigned and commented, approved and merged automatically', async () => { - const pathsAndAct = getPathsAndAct(); - const repoPath = pathsAndAct.repoPath; - let act = pathsAndAct.act; + const repoPath = mockGithub.repo.getPath('testCherryPickWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + const testMockSteps = { + validateActor: mocks.CHERRYPICK__VALIDATEACTOR__TRUE__STEP_MOCKS, + createNewVersion: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, + }; testMockSteps.cherryPick = mocks.getCherryPickMockSteps(versionsMatch, prIsMergeable, !mergeConflicts); - act = setUpActParams(act, event, newVersion); - const result = await runWorkflow(act, event, repoPath, testMockSteps, actor); + act = utils.setUpActParams( + act, + event, + null, + { + OS_BOTIFY_TOKEN: 'dummy_token', + LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', + SLACK_WEBHOOK: 'dummy_slack_webhook', + }, + 'dummy_github_token', + null, + { + PULL_REQUEST_NUMBER: '1234', + NEW_VERSION: newVersion, + }, + ); + const result = await act + .runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor, + }); assertions.assertValidateActorJobExecuted(result, actor); assertions.assertCreateNewVersionJobExecuted(result); @@ -245,12 +302,36 @@ describe('test workflow cherryPick', () => { describe('PR is not mergeable', () => { const prIsMergeable = false; it('workflow executes, new version created, PR auto-assigned and commented, not merged automatically', async () => { - const pathsAndAct = getPathsAndAct(); - const repoPath = pathsAndAct.repoPath; - let act = pathsAndAct.act; + const repoPath = mockGithub.repo.getPath('testCherryPickWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + const testMockSteps = { + validateActor: mocks.CHERRYPICK__VALIDATEACTOR__TRUE__STEP_MOCKS, + createNewVersion: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, + }; testMockSteps.cherryPick = mocks.getCherryPickMockSteps(versionsMatch, prIsMergeable, !mergeConflicts); - act = setUpActParams(act, event, newVersion); - const result = await runWorkflow(act, event, repoPath, testMockSteps, actor); + act = utils.setUpActParams( + act, + event, + null, + { + OS_BOTIFY_TOKEN: 'dummy_token', + LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', + SLACK_WEBHOOK: 'dummy_slack_webhook', + }, + 'dummy_github_token', + null, + { + PULL_REQUEST_NUMBER: '1234', + NEW_VERSION: newVersion, + }, + ); + const result = await act + .runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor, + }); assertions.assertValidateActorJobExecuted(result, actor); assertions.assertCreateNewVersionJobExecuted(result); @@ -277,12 +358,36 @@ describe('test workflow cherryPick', () => { describe('PR is mergeable', () => { const prIsMergeable = true; it('workflow executes, new version created, PR auto-assigned and commented, not merged automatically', async () => { - const pathsAndAct = getPathsAndAct(); - const repoPath = pathsAndAct.repoPath; - let act = pathsAndAct.act; + const repoPath = mockGithub.repo.getPath('testCherryPickWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + const testMockSteps = { + validateActor: mocks.CHERRYPICK__VALIDATEACTOR__TRUE__STEP_MOCKS, + createNewVersion: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, + }; testMockSteps.cherryPick = mocks.getCherryPickMockSteps(versionsMatch, prIsMergeable, !mergeConflicts); - act = setUpActParams(act, event, newVersion); - const result = await runWorkflow(act, event, repoPath, testMockSteps, actor); + act = utils.setUpActParams( + act, + event, + null, + { + OS_BOTIFY_TOKEN: 'dummy_token', + LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', + SLACK_WEBHOOK: 'dummy_slack_webhook', + }, + 'dummy_github_token', + null, + { + PULL_REQUEST_NUMBER: '1234', + NEW_VERSION: newVersion, + }, + ); + const result = await act + .runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor, + }); assertions.assertValidateActorJobExecuted(result, actor); assertions.assertCreateNewVersionJobExecuted(result); @@ -303,12 +408,36 @@ describe('test workflow cherryPick', () => { describe('PR is not mergeable', () => { const prIsMergeable = false; it('workflow executes, new version created, PR auto-assigned and commented, not merged automatically', async () => { - const pathsAndAct = getPathsAndAct(); - const repoPath = pathsAndAct.repoPath; - let act = pathsAndAct.act; + const repoPath = mockGithub.repo.getPath('testCherryPickWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + const testMockSteps = { + validateActor: mocks.CHERRYPICK__VALIDATEACTOR__TRUE__STEP_MOCKS, + createNewVersion: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, + }; testMockSteps.cherryPick = mocks.getCherryPickMockSteps(versionsMatch, prIsMergeable, !mergeConflicts); - act = setUpActParams(act, event, newVersion); - const result = await runWorkflow(act, event, repoPath, testMockSteps, actor); + act = utils.setUpActParams( + act, + event, + null, + { + OS_BOTIFY_TOKEN: 'dummy_token', + LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', + SLACK_WEBHOOK: 'dummy_slack_webhook', + }, + 'dummy_github_token', + null, + { + PULL_REQUEST_NUMBER: '1234', + NEW_VERSION: newVersion, + }, + ); + const result = await act + .runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor, + }); assertions.assertValidateActorJobExecuted(result, actor); assertions.assertCreateNewVersionJobExecuted(result); @@ -332,12 +461,36 @@ describe('test workflow cherryPick', () => { describe('PR is mergeable', () => { const prIsMergeable = true; it('workflow executes, new version created, PR auto-assigned and commented, not merged automatically', async () => { - const pathsAndAct = getPathsAndAct(); - const repoPath = pathsAndAct.repoPath; - let act = pathsAndAct.act; + const repoPath = mockGithub.repo.getPath('testCherryPickWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + const testMockSteps = { + validateActor: mocks.CHERRYPICK__VALIDATEACTOR__TRUE__STEP_MOCKS, + createNewVersion: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, + }; testMockSteps.cherryPick = mocks.getCherryPickMockSteps(versionsMatch, prIsMergeable, !mergeConflicts); - act = setUpActParams(act, event, newVersion); - const result = await runWorkflow(act, event, repoPath, testMockSteps, actor); + act = utils.setUpActParams( + act, + event, + null, + { + OS_BOTIFY_TOKEN: 'dummy_token', + LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', + SLACK_WEBHOOK: 'dummy_slack_webhook', + }, + 'dummy_github_token', + null, + { + PULL_REQUEST_NUMBER: '1234', + NEW_VERSION: newVersion, + }, + ); + const result = await act + .runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor, + }); assertions.assertValidateActorJobExecuted(result, actor); assertions.assertCreateNewVersionJobExecuted(result); @@ -358,12 +511,36 @@ describe('test workflow cherryPick', () => { describe('PR is not mergeable', () => { const prIsMergeable = false; it('workflow executes, new version created, PR auto-assigned and commented, not merged automatically', async () => { - const pathsAndAct = getPathsAndAct(); - const repoPath = pathsAndAct.repoPath; - let act = pathsAndAct.act; + const repoPath = mockGithub.repo.getPath('testCherryPickWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + const testMockSteps = { + validateActor: mocks.CHERRYPICK__VALIDATEACTOR__TRUE__STEP_MOCKS, + createNewVersion: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, + }; testMockSteps.cherryPick = mocks.getCherryPickMockSteps(versionsMatch, prIsMergeable, !mergeConflicts); - act = setUpActParams(act, event, newVersion); - const result = await runWorkflow(act, event, repoPath, testMockSteps, actor); + act = utils.setUpActParams( + act, + event, + null, + { + OS_BOTIFY_TOKEN: 'dummy_token', + LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', + SLACK_WEBHOOK: 'dummy_slack_webhook', + }, + 'dummy_github_token', + null, + { + PULL_REQUEST_NUMBER: '1234', + NEW_VERSION: newVersion, + }, + ); + const result = await act + .runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor, + }); assertions.assertValidateActorJobExecuted(result, actor); assertions.assertCreateNewVersionJobExecuted(result); @@ -394,12 +571,36 @@ describe('test workflow cherryPick', () => { describe('PR is mergeable', () => { const prIsMergeable = true; it('workflow executes, PR approved and merged automatically', async () => { - const pathsAndAct = getPathsAndAct(); - const repoPath = pathsAndAct.repoPath; - let act = pathsAndAct.act; + const repoPath = mockGithub.repo.getPath('testCherryPickWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + const testMockSteps = { + validateActor: mocks.CHERRYPICK__VALIDATEACTOR__TRUE__STEP_MOCKS, + createNewVersion: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, + }; testMockSteps.cherryPick = mocks.getCherryPickMockSteps(versionsMatch, prIsMergeable, !mergeConflicts); - act = setUpActParams(act, event, newVersion); - const result = await runWorkflow(act, event, repoPath, testMockSteps, actor); + act = utils.setUpActParams( + act, + event, + null, + { + OS_BOTIFY_TOKEN: 'dummy_token', + LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', + SLACK_WEBHOOK: 'dummy_slack_webhook', + }, + 'dummy_github_token', + null, + { + PULL_REQUEST_NUMBER: '1234', + NEW_VERSION: newVersion, + }, + ); + const result = await act + .runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor, + }); assertions.assertValidateActorJobExecuted(result, actor); assertions.assertCreateNewVersionJobExecuted(result, false); @@ -420,12 +621,36 @@ describe('test workflow cherryPick', () => { describe('PR is not mergeable', () => { const prIsMergeable = false; it('workflow executes, PR is not merged automatically', async () => { - const pathsAndAct = getPathsAndAct(); - const repoPath = pathsAndAct.repoPath; - let act = pathsAndAct.act; + const repoPath = mockGithub.repo.getPath('testCherryPickWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + const testMockSteps = { + validateActor: mocks.CHERRYPICK__VALIDATEACTOR__TRUE__STEP_MOCKS, + createNewVersion: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, + }; testMockSteps.cherryPick = mocks.getCherryPickMockSteps(versionsMatch, prIsMergeable, !mergeConflicts); - act = setUpActParams(act, event, newVersion); - const result = await runWorkflow(act, event, repoPath, testMockSteps, actor); + act = utils.setUpActParams( + act, + event, + null, + { + OS_BOTIFY_TOKEN: 'dummy_token', + LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', + SLACK_WEBHOOK: 'dummy_slack_webhook', + }, + 'dummy_github_token', + null, + { + PULL_REQUEST_NUMBER: '1234', + NEW_VERSION: newVersion, + }, + ); + const result = await act + .runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor, + }); assertions.assertValidateActorJobExecuted(result, actor); assertions.assertCreateNewVersionJobExecuted(result, false); @@ -449,12 +674,36 @@ describe('test workflow cherryPick', () => { describe('PR is mergeable', () => { const prIsMergeable = true; it('workflow executes, PR auto-assigned and commented, approved and merged automatically', async () => { - const pathsAndAct = getPathsAndAct(); - const repoPath = pathsAndAct.repoPath; - let act = pathsAndAct.act; + const repoPath = mockGithub.repo.getPath('testCherryPickWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + const testMockSteps = { + validateActor: mocks.CHERRYPICK__VALIDATEACTOR__TRUE__STEP_MOCKS, + createNewVersion: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, + }; testMockSteps.cherryPick = mocks.getCherryPickMockSteps(versionsMatch, prIsMergeable, !mergeConflicts); - act = setUpActParams(act, event, newVersion); - const result = await runWorkflow(act, event, repoPath, testMockSteps, actor); + act = utils.setUpActParams( + act, + event, + null, + { + OS_BOTIFY_TOKEN: 'dummy_token', + LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', + SLACK_WEBHOOK: 'dummy_slack_webhook', + }, + 'dummy_github_token', + null, + { + PULL_REQUEST_NUMBER: '1234', + NEW_VERSION: newVersion, + }, + ); + const result = await act + .runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor, + }); assertions.assertValidateActorJobExecuted(result, actor); assertions.assertCreateNewVersionJobExecuted(result, false); @@ -475,12 +724,36 @@ describe('test workflow cherryPick', () => { describe('PR is not mergeable', () => { const prIsMergeable = false; it('workflow executes, PR auto-assigned and commented, not merged automatically', async () => { - const pathsAndAct = getPathsAndAct(); - const repoPath = pathsAndAct.repoPath; - let act = pathsAndAct.act; + const repoPath = mockGithub.repo.getPath('testCherryPickWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + const testMockSteps = { + validateActor: mocks.CHERRYPICK__VALIDATEACTOR__TRUE__STEP_MOCKS, + createNewVersion: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, + }; testMockSteps.cherryPick = mocks.getCherryPickMockSteps(versionsMatch, prIsMergeable, !mergeConflicts); - act = setUpActParams(act, event, newVersion); - const result = await runWorkflow(act, event, repoPath, testMockSteps, actor); + act = utils.setUpActParams( + act, + event, + null, + { + OS_BOTIFY_TOKEN: 'dummy_token', + LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', + SLACK_WEBHOOK: 'dummy_slack_webhook', + }, + 'dummy_github_token', + null, + { + PULL_REQUEST_NUMBER: '1234', + NEW_VERSION: newVersion, + }, + ); + const result = await act + .runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor, + }); assertions.assertValidateActorJobExecuted(result, actor); assertions.assertCreateNewVersionJobExecuted(result, false); @@ -507,12 +780,36 @@ describe('test workflow cherryPick', () => { describe('PR is mergeable', () => { const prIsMergeable = true; it('workflow executes, PR auto-assigned and commented, not merged automatically', async () => { - const pathsAndAct = getPathsAndAct(); - const repoPath = pathsAndAct.repoPath; - let act = pathsAndAct.act; + const repoPath = mockGithub.repo.getPath('testCherryPickWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + const testMockSteps = { + validateActor: mocks.CHERRYPICK__VALIDATEACTOR__TRUE__STEP_MOCKS, + createNewVersion: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, + }; testMockSteps.cherryPick = mocks.getCherryPickMockSteps(versionsMatch, prIsMergeable, !mergeConflicts); - act = setUpActParams(act, event, newVersion); - const result = await runWorkflow(act, event, repoPath, testMockSteps, actor); + act = utils.setUpActParams( + act, + event, + null, + { + OS_BOTIFY_TOKEN: 'dummy_token', + LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', + SLACK_WEBHOOK: 'dummy_slack_webhook', + }, + 'dummy_github_token', + null, + { + PULL_REQUEST_NUMBER: '1234', + NEW_VERSION: newVersion, + }, + ); + const result = await act + .runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor, + }); assertions.assertValidateActorJobExecuted(result, actor); assertions.assertCreateNewVersionJobExecuted(result, false); @@ -533,12 +830,36 @@ describe('test workflow cherryPick', () => { describe('PR is not mergeable', () => { const prIsMergeable = false; it('workflow executes, PR auto-assigned and commented, not merged automatically', async () => { - const pathsAndAct = getPathsAndAct(); - const repoPath = pathsAndAct.repoPath; - let act = pathsAndAct.act; + const repoPath = mockGithub.repo.getPath('testCherryPickWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + const testMockSteps = { + validateActor: mocks.CHERRYPICK__VALIDATEACTOR__TRUE__STEP_MOCKS, + createNewVersion: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, + }; testMockSteps.cherryPick = mocks.getCherryPickMockSteps(versionsMatch, prIsMergeable, !mergeConflicts); - act = setUpActParams(act, event, newVersion); - const result = await runWorkflow(act, event, repoPath, testMockSteps, actor); + act = utils.setUpActParams( + act, + event, + null, + { + OS_BOTIFY_TOKEN: 'dummy_token', + LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', + SLACK_WEBHOOK: 'dummy_slack_webhook', + }, + 'dummy_github_token', + null, + { + PULL_REQUEST_NUMBER: '1234', + NEW_VERSION: newVersion, + }, + ); + const result = await act + .runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor, + }); assertions.assertValidateActorJobExecuted(result, actor); assertions.assertCreateNewVersionJobExecuted(result, false); @@ -562,12 +883,36 @@ describe('test workflow cherryPick', () => { describe('PR is mergeable', () => { const prIsMergeable = true; it('workflow executes, PR auto-assigned and commented, not merged automatically', async () => { - const pathsAndAct = getPathsAndAct(); - const repoPath = pathsAndAct.repoPath; - let act = pathsAndAct.act; + const repoPath = mockGithub.repo.getPath('testCherryPickWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + const testMockSteps = { + validateActor: mocks.CHERRYPICK__VALIDATEACTOR__TRUE__STEP_MOCKS, + createNewVersion: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, + }; testMockSteps.cherryPick = mocks.getCherryPickMockSteps(versionsMatch, prIsMergeable, !mergeConflicts); - act = setUpActParams(act, event, newVersion); - const result = await runWorkflow(act, event, repoPath, testMockSteps, actor); + act = utils.setUpActParams( + act, + event, + null, + { + OS_BOTIFY_TOKEN: 'dummy_token', + LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', + SLACK_WEBHOOK: 'dummy_slack_webhook', + }, + 'dummy_github_token', + null, + { + PULL_REQUEST_NUMBER: '1234', + NEW_VERSION: newVersion, + }, + ); + const result = await act + .runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor, + }); assertions.assertValidateActorJobExecuted(result, actor); assertions.assertCreateNewVersionJobExecuted(result, false); @@ -588,12 +933,36 @@ describe('test workflow cherryPick', () => { describe('PR is not mergeable', () => { const prIsMergeable = false; it('workflow executes, PR auto-assigned and commented, not merged automatically', async () => { - const pathsAndAct = getPathsAndAct(); - const repoPath = pathsAndAct.repoPath; - let act = pathsAndAct.act; + const repoPath = mockGithub.repo.getPath('testCherryPickWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + const testMockSteps = { + validateActor: mocks.CHERRYPICK__VALIDATEACTOR__TRUE__STEP_MOCKS, + createNewVersion: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, + }; testMockSteps.cherryPick = mocks.getCherryPickMockSteps(versionsMatch, prIsMergeable, !mergeConflicts); - act = setUpActParams(act, event, newVersion); - const result = await runWorkflow(act, event, repoPath, testMockSteps, actor); + act = utils.setUpActParams( + act, + event, + null, + { + OS_BOTIFY_TOKEN: 'dummy_token', + LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', + SLACK_WEBHOOK: 'dummy_slack_webhook', + }, + 'dummy_github_token', + null, + { + PULL_REQUEST_NUMBER: '1234', + NEW_VERSION: newVersion, + }, + ); + const result = await act + .runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows'), + mockSteps: testMockSteps, + actor, + }); assertions.assertValidateActorJobExecuted(result, actor); assertions.assertCreateNewVersionJobExecuted(result, false); diff --git a/workflow_tests/mocks/cherryPickMocks.js b/workflow_tests/mocks/cherryPickMocks.js index 55f538ba0480..f02000a6f7c0 100644 --- a/workflow_tests/mocks/cherryPickMocks.js +++ b/workflow_tests/mocks/cherryPickMocks.js @@ -203,16 +203,22 @@ const getCherryPickMockSteps = (upToDate, isMergeable, shouldMerge) => [ CHERRYPICK__CHERRYPICK__GET_MERGE_COMMIT_FOR_CP_PULL_REQUEST__STEP_MOCK, CHERRYPICK__CHERRYPICK__GET_MERGE_COMMIT_FOR_VERSION_BUMP_PULL_REQUEST__STEP_MOCK, CHERRYPICK__CHERRYPICK__CHERRY_PICK_THE_VERSION_BUMP_TO_NEW_BRANCH__STEP_MOCK, - shouldMerge ? CHERRYPICK__CHERRYPICK__CHERRY_PICK_THE_MERGE_COMMIT_OF_TARGET_PR_TO_NEW_BRANCH__SHOULD_MERGE__STEP_MOCK : CHERRYPICK__CHERRYPICK__CHERRY_PICK_THE_MERGE_COMMIT_OF_TARGET_PR_TO_NEW_BRANCH__SHOULD_NOT_MERGE__STEP_MOCK, + shouldMerge + ? CHERRYPICK__CHERRYPICK__CHERRY_PICK_THE_MERGE_COMMIT_OF_TARGET_PR_TO_NEW_BRANCH__SHOULD_MERGE__STEP_MOCK + : CHERRYPICK__CHERRYPICK__CHERRY_PICK_THE_MERGE_COMMIT_OF_TARGET_PR_TO_NEW_BRANCH__SHOULD_NOT_MERGE__STEP_MOCK, CHERRYPICK__CHERRYPICK__PUSH_CHANGES_TO_CP_BRANCH__STEP_MOCK, CHERRYPICK__CHERRYPICK__CREATE_PULL_REQUEST__STEP_MOCK, - upToDate ? CHERRYPICK__CHERRYPICK__CHECK_IF_SHORTVERSIONSTRING_IS_UP_TO_DATE_TRUE__STEP_MOCK : CHERRYPICK__CHERRYPICK__CHECK_IF_SHORTVERSIONSTRING_IS_UP_TO_DATE_FALSE__STEP_MOCK, + upToDate + ? CHERRYPICK__CHERRYPICK__CHECK_IF_SHORTVERSIONSTRING_IS_UP_TO_DATE_TRUE__STEP_MOCK + : CHERRYPICK__CHERRYPICK__CHECK_IF_SHORTVERSIONSTRING_IS_UP_TO_DATE_FALSE__STEP_MOCK, CHERRYPICK__CHERRYPICK__AUTO_ASSIGN_PR_IF_THERE_ARE_MERGE_CONFLICTS_OR_IF_THE_BUNDLE_VERSIONS_ARE_MISMATCHED__STEP_MOCK, CHERRYPICK__CHERRYPICK__ASSIGN_THE_PR_TO_THE_DEPLOYER__STEP_MOCK, CHERRYPICK__CHERRYPICK__IF_PR_HAS_MERGE_CONFLICTS_COMMENT_WITH_INSTRUCTIONS_FOR_ASSIGNEE__STEP_MOCK, CHERRYPICK__CHERRYPICK__IF_PR_HAS_A_BUNDLE_VERSION_MISMATCH_COMMENT_WITH_THE_INSTRUCTIONS_FOR_ASSIGNEE__STEP_MOCK, CHERRYPICK__CHERRYPICK__AUTO_APPROVE_THE_PR__STEP_MOCK, - isMergeable ? CHERRYPICK__CHERRYPICK__CHECK_IF_PULL_REQUEST_IS_MERGEABLE_TRUE__STEP_MOCK : CHERRYPICK__CHERRYPICK__CHECK_IF_PULL_REQUEST_IS_MERGEABLE_FALSE__STEP_MOCK, + isMergeable + ? CHERRYPICK__CHERRYPICK__CHECK_IF_PULL_REQUEST_IS_MERGEABLE_TRUE__STEP_MOCK + : CHERRYPICK__CHERRYPICK__CHECK_IF_PULL_REQUEST_IS_MERGEABLE_FALSE__STEP_MOCK, CHERRYPICK__CHERRYPICK__AUTO_MERGE_THE_PR__STEP_MOCK, CHERRYPICK__CHERRYPICK__ANNOUNCES_A_CP_FAILURE_IN_THE_ANNOUNCE_SLACK_ROOM__STEP_MOCK, ]; diff --git a/workflow_tests/utils/utils.js b/workflow_tests/utils/utils.js index e3b3d74f611f..dc375a74cf93 100644 --- a/workflow_tests/utils/utils.js +++ b/workflow_tests/utils/utils.js @@ -66,7 +66,7 @@ function getMockStep( mockWithCommand += ` ${message}`; if (inputs) { for (const input of inputs) { - mockWithCommand += `, ${input}="\${{ inputs.${input} }}\${{ github.event.inputs.${input} }}"`; + mockWithCommand += `, ${input}="\${{ inputs.${input} && inputs.${input} || github.event.inputs.${input} }}"`; } } if (in_envs) { From 9275387136a5d4e4aa72b4022624cfc07a59891d Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Tue, 28 Mar 2023 15:05:51 +0200 Subject: [PATCH 068/504] Update readme Updated FAQ See: https://github.com/Expensify/App/issues/13604 --- workflow_tests/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/workflow_tests/README.md b/workflow_tests/README.md index 49a5c73649fa..3ff4b3f34081 100644 --- a/workflow_tests/README.md +++ b/workflow_tests/README.md @@ -403,6 +403,6 @@ assertions.assertSomethingDidNotHappen(result, false); ### My workflow has many jobs, each with many steps, how do I start testing it without spending hours on setup? #### First of all, consider splitting the workflow into several smaller pieces, with the main one acting as coordinator and calling the others. Secondly, you can bootstrap the test with `npm run workflow-test:generate .yml`, which will generate mocks and assertions for you, as well as the stub of the test file ### After using `workflow-test:generate` the files are incomplete, or they have errors. Why? -#### Make sure that the workflow file you want to test, has all steps with names, as the bootstrapping script uses step names to locate and mock them - same with assertions +#### Make sure that the workflow file you want to test, has all steps with names, as the bootstrapping script uses step names to locate and mock them - same with assertions. After you've added the `name` properties to steps, remove the previously generated files and run the command again ### I want to just run the test that I am working on, without all the others - how can I do it? #### You can pass parameters to the `npm run workflow-test` command as you would with `jest` or `npm test` - `npm run workflow-test -- -i ` will run just the tests within `testfile`. You can also filter further with `-t ` From 323be7c0f55d9d4d8f40d35280c5f9b640ceec26 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Tue, 28 Mar 2023 15:12:33 +0200 Subject: [PATCH 069/504] Fix test Fix failing `deploy` tests after a recent refactor See: https://github.com/Expensify/App/issues/13604 --- workflow_tests/deploy.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/workflow_tests/deploy.test.js b/workflow_tests/deploy.test.js index 89f18c35cfcb..f7999b9d0a2c 100644 --- a/workflow_tests/deploy.test.js +++ b/workflow_tests/deploy.test.js @@ -240,7 +240,7 @@ describe('test workflow deploy', () => { }); it('different event than push - workflow does not execute', async () => { - const repoPath = mockGithub.repo.getPath('testdeployWorkflowRepo') || ''; + const repoPath = mockGithub.repo.getPath('testDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'deploy.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); const testMockSteps = { From 23d0f7842e07777806e2beaa1a6772857b665002 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Tue, 28 Mar 2023 15:18:29 +0200 Subject: [PATCH 070/504] Update package.json Removed redundant `-t` filter from command See: https://github.com/Expensify/App/issues/13604 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 76f69f0abee2..de0318198e13 100644 --- a/package.json +++ b/package.json @@ -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 -t \"test workflow\"", + "workflow-test": "npm test -- --config=workflow_tests/jest.config.js", "workflow-test:generate": "node workflow_tests/utils/preGenerateTest.js" }, "dependencies": { From 917d3d3c053decbdc47dbddd3b163fa90a845290 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Wed, 29 Mar 2023 10:24:25 +0200 Subject: [PATCH 071/504] Fix tests Fixed `preDeploy` tests that broke after merging in the source repos main branch See: https://github.com/Expensify/App/issues/13604 --- .github/workflows/preDeploy.yml | 11 +- package.json | 2 +- .../assertions/preDeployAssertions.js | 182 ------------------ workflow_tests/mocks/preDeployMocks.js | 149 +------------- workflow_tests/preDeploy.test.js | 99 ++-------- 5 files changed, 33 insertions(+), 410 deletions(-) diff --git a/.github/workflows/preDeploy.yml b/.github/workflows/preDeploy.yml index 7beea5a3361a..cffa2a5d7ed1 100644 --- a/.github/workflows/preDeploy.yml +++ b/.github/workflows/preDeploy.yml @@ -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 }} diff --git a/package.json b/package.json index de0318198e13..096687d3cbff 100644 --- a/package.json +++ b/package.json @@ -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": { diff --git a/workflow_tests/assertions/preDeployAssertions.js b/workflow_tests/assertions/preDeployAssertions.js index 1b089b6385c2..85a51c980215 100644 --- a/workflow_tests/assertions/preDeployAssertions.js +++ b/workflow_tests/assertions/preDeployAssertions.js @@ -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( @@ -518,7 +337,6 @@ module.exports = { assertTestJobExecuted, assertIsExpensifyEmployeeJobExecuted, assertNewContributorWelcomeMessageJobExecuted, - assertE2ETestsJobExecuted, assertChooseDeployActionsJobExecuted, assertSkipDeployJobExecuted, assertCreateNewVersionJobExecuted, diff --git a/workflow_tests/mocks/preDeployMocks.js b/workflow_tests/mocks/preDeployMocks.js index 47aeb77fc87c..fefa7a20313f 100644 --- a/workflow_tests/mocks/preDeployMocks.js +++ b/workflow_tests/mocks/preDeployMocks.js @@ -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 = { @@ -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, }; diff --git a/workflow_tests/preDeploy.test.js b/workflow_tests/preDeploy.test.js index caecbb6a6318..5b4a94020f5d 100644 --- a/workflow_tests/preDeploy.test.js +++ b/workflow_tests/preDeploy.test.js @@ -76,7 +76,7 @@ describe('test workflow preDeploy', () => { updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, - 'e2e-tests': mocks.E2E_TESTS_JOB_MOCK_STEPS, + e2ePerformanceTests: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, }; // run an event and get the result @@ -92,57 +92,12 @@ describe('test workflow preDeploy', () => { assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); assertions.assertIsExpensifyEmployeeJobExecuted(result); - assertions.assertE2ETestsJobExecuted(result, false); // Act does not support ubuntu-20.04-64core runner and omits the job assertions.assertChooseDeployActionsJobExecuted(result); assertions.assertSkipDeployJobExecuted(result, false); assertions.assertCreateNewVersionJobExecuted(result); assertions.assertUpdateStagingJobExecuted(result); }); - // using a different branch does not seem to work as described in documentation - // it('push to different branch - workflow does not execute', async () => { - // const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; - // const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); - // let act = new eAct.ExtendedAct(repoPath, workflowPath); - // act = utils.setUpActParams( - // act, - // 'push', - // { - // ref: 'refs/heads/different_branch', - // }, - // { - // OS_BOTIFY_TOKEN: 'dummy_token', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', - // }, - // 'dummy_github_token', - // ); - // const testMockSteps = { - // lint: mocks.LINT_JOB_MOCK_STEPS, - // test: mocks.TEST_JOB_MOCK_STEPS, - // confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, - // chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__CP_LABEL__STAGING_UNLOCKED, - // skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, - // createNewVersion: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, - // updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, - // isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, - // newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, - // 'e2e-tests': mocks.E2E_TESTS_JOB_MOCK_STEPS, - // }; - // const result = await act - // .runEvent('push', { - // workflowFile: path.join(repoPath, '.github', 'workflows'), - // mockSteps: testMockSteps, - // actor: 'Dummy Tester', - // }); - // assertions.assertLintJobExecuted(result, false); - // assertions.assertTestJobExecuted(result, false); - // assertions.assertIsExpensifyEmployeeJobExecuted(result, false); - // assertions.assertE2ETestsJobExecuted(result, false); // Act does not support ubuntu-20.04-64core runner and omits the job - // assertions.assertChooseDeployActionsJobExecuted(result, false); - // assertions.assertSkipDeployJobExecuted(result, false); - // assertions.assertCreateNewVersionJobExecuted(result, false); - // assertions.assertUpdateStagingJobExecuted(result, false); - // }); - it('different event than push - workflow does not execute', async () => { const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); @@ -157,7 +112,7 @@ describe('test workflow preDeploy', () => { updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, - 'e2e-tests': mocks.E2E_TESTS_JOB_MOCK_STEPS, + e2ePerformanceTests: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, }; // pull_request @@ -179,7 +134,6 @@ describe('test workflow preDeploy', () => { assertions.assertLintJobExecuted(result, false); assertions.assertTestJobExecuted(result, false); assertions.assertIsExpensifyEmployeeJobExecuted(result, false); - assertions.assertE2ETestsJobExecuted(result, false); // Act does not support ubuntu-20.04-64core runner and omits the job assertions.assertChooseDeployActionsJobExecuted(result, false); assertions.assertSkipDeployJobExecuted(result, false); assertions.assertCreateNewVersionJobExecuted(result, false); @@ -204,7 +158,6 @@ describe('test workflow preDeploy', () => { assertions.assertLintJobExecuted(result, false); assertions.assertTestJobExecuted(result, false); assertions.assertIsExpensifyEmployeeJobExecuted(result, false); - assertions.assertE2ETestsJobExecuted(result, false); // Act does not support ubuntu-20.04-64core runner and omits the job assertions.assertChooseDeployActionsJobExecuted(result, false); assertions.assertSkipDeployJobExecuted(result, false); assertions.assertCreateNewVersionJobExecuted(result, false); @@ -246,7 +199,7 @@ describe('test workflow preDeploy', () => { updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, - 'e2e-tests': mocks.E2E_TESTS_JOB_MOCK_STEPS, + e2ePerformanceTests: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, }; const result = await act .runEvent('push', { @@ -284,7 +237,6 @@ describe('test workflow preDeploy', () => { ), ], )); - assertions.assertE2ETestsJobExecuted(result, false); // Act does not support ubuntu-20.04-64core runner and omits the job assertions.assertChooseDeployActionsJobExecuted(result, false); assertions.assertSkipDeployJobExecuted(result, false); assertions.assertCreateNewVersionJobExecuted(result, false); @@ -325,7 +277,7 @@ describe('test workflow preDeploy', () => { updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, - 'e2e-tests': mocks.E2E_TESTS_JOB_MOCK_STEPS, + e2ePerformanceTests: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, }; const result = await act .runEvent('push', { @@ -363,7 +315,6 @@ describe('test workflow preDeploy', () => { ), ], )); - assertions.assertE2ETestsJobExecuted(result, false); // Act does not support ubuntu-20.04-64core runner and omits the job assertions.assertChooseDeployActionsJobExecuted(result, false); assertions.assertSkipDeployJobExecuted(result, false); assertions.assertCreateNewVersionJobExecuted(result, false); @@ -393,7 +344,7 @@ describe('test workflow preDeploy', () => { updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, - 'e2e-tests': mocks.E2E_TESTS_JOB_MOCK_STEPS, + e2ePerformanceTests: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, }; const result = await act .runEvent('push', { @@ -404,7 +355,6 @@ describe('test workflow preDeploy', () => { assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); assertions.assertIsExpensifyEmployeeJobExecuted(result); - assertions.assertE2ETestsJobExecuted(result, false); // Act does not support ubuntu-20.04-64core runner and omits the job assertions.assertChooseDeployActionsJobExecuted(result); assertions.assertSkipDeployJobExecuted(result, false); assertions.assertCreateNewVersionJobExecuted(result); @@ -436,7 +386,7 @@ describe('test workflow preDeploy', () => { updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__FALSE, newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__OSBOTIFY, - 'e2e-tests': mocks.E2E_TESTS_JOB_MOCK_STEPS, + e2ePerformanceTests: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, }; const result = await act .runEvent('push', { @@ -447,7 +397,6 @@ describe('test workflow preDeploy', () => { assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); assertions.assertIsExpensifyEmployeeJobExecuted(result); - assertions.assertE2ETestsJobExecuted(result, false); // Act does not support ubuntu-20.04-64core runner and omits the job assertions.assertChooseDeployActionsJobExecuted(result); assertions.assertNewContributorWelcomeMessageJobExecuted(result, false); }); @@ -475,7 +424,7 @@ describe('test workflow preDeploy', () => { updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, - 'e2e-tests': mocks.E2E_TESTS_JOB_MOCK_STEPS, + e2ePerformanceTests: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, }; const result = await act .runEvent('push', { @@ -486,7 +435,6 @@ describe('test workflow preDeploy', () => { assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); assertions.assertIsExpensifyEmployeeJobExecuted(result); - assertions.assertE2ETestsJobExecuted(result, false); // Act does not support ubuntu-20.04-64core runner and omits the job assertions.assertChooseDeployActionsJobExecuted(result); assertions.assertNewContributorWelcomeMessageJobExecuted(result, false); }); @@ -514,7 +462,7 @@ describe('test workflow preDeploy', () => { updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__FALSE, newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, - 'e2e-tests': mocks.E2E_TESTS_JOB_MOCK_STEPS, + e2ePerformanceTests: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, }; const result = await act .runEvent('push', { @@ -525,7 +473,6 @@ describe('test workflow preDeploy', () => { assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); assertions.assertIsExpensifyEmployeeJobExecuted(result); - assertions.assertE2ETestsJobExecuted(result, false); // Act does not support ubuntu-20.04-64core runner and omits the job assertions.assertChooseDeployActionsJobExecuted(result); assertions.assertNewContributorWelcomeMessageJobExecuted(result, true, false, false); }); @@ -553,7 +500,7 @@ describe('test workflow preDeploy', () => { updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__FALSE, newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__ONE_PR, - 'e2e-tests': mocks.E2E_TESTS_JOB_MOCK_STEPS, + e2ePerformanceTests: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, }; const result = await act .runEvent('push', { @@ -564,7 +511,6 @@ describe('test workflow preDeploy', () => { assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); assertions.assertIsExpensifyEmployeeJobExecuted(result); - assertions.assertE2ETestsJobExecuted(result, false); // Act does not support ubuntu-20.04-64core runner and omits the job assertions.assertChooseDeployActionsJobExecuted(result); assertions.assertNewContributorWelcomeMessageJobExecuted(result, true, false, true); }); @@ -594,7 +540,7 @@ describe('test workflow preDeploy', () => { updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, - 'e2e-tests': mocks.E2E_TESTS_JOB_MOCK_STEPS, + e2ePerformanceTests: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, }; const result = await act .runEvent('push', { @@ -605,7 +551,6 @@ describe('test workflow preDeploy', () => { assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); assertions.assertIsExpensifyEmployeeJobExecuted(result); - assertions.assertE2ETestsJobExecuted(result, false); // Act does not support ubuntu-20.04-64core runner and omits the job assertions.assertChooseDeployActionsJobExecuted(result); assertions.assertSkipDeployJobExecuted(result); assertions.assertCreateNewVersionJobExecuted(result, false); @@ -634,7 +579,7 @@ describe('test workflow preDeploy', () => { updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__OSBOTIFY, - 'e2e-tests': mocks.E2E_TESTS_JOB_MOCK_STEPS, + e2ePerformanceTests: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, }; const result = await act .runEvent('push', { @@ -645,7 +590,6 @@ describe('test workflow preDeploy', () => { assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); assertions.assertIsExpensifyEmployeeJobExecuted(result); - assertions.assertE2ETestsJobExecuted(result, false); // Act does not support ubuntu-20.04-64core runner and omits the job assertions.assertChooseDeployActionsJobExecuted(result); assertions.assertSkipDeployJobExecuted(result, false); assertions.assertCreateNewVersionJobExecuted(result, false); @@ -680,7 +624,7 @@ describe('test workflow preDeploy', () => { updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, - 'e2e-tests': mocks.E2E_TESTS_JOB_MOCK_STEPS, + e2ePerformanceTests: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, }; const result = await act .runEvent('push', { @@ -691,7 +635,6 @@ describe('test workflow preDeploy', () => { assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); assertions.assertIsExpensifyEmployeeJobExecuted(result); - assertions.assertE2ETestsJobExecuted(result, false); // Act does not support ubuntu-20.04-64core runner and omits the job assertions.assertChooseDeployActionsJobExecuted(result); assertions.assertSkipDeployJobExecuted(result, false); assertions.assertCreateNewVersionJobExecuted(result); @@ -723,7 +666,7 @@ describe('test workflow preDeploy', () => { updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__OSBOTIFY, - 'e2e-tests': mocks.E2E_TESTS_JOB_MOCK_STEPS, + e2ePerformanceTests: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, }; const result = await act .runEvent('push', { @@ -734,7 +677,6 @@ describe('test workflow preDeploy', () => { assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); assertions.assertIsExpensifyEmployeeJobExecuted(result); - assertions.assertE2ETestsJobExecuted(result, false); // Act does not support ubuntu-20.04-64core runner and omits the job assertions.assertChooseDeployActionsJobExecuted(result); assertions.assertSkipDeployJobExecuted(result, false); assertions.assertCreateNewVersionJobExecuted(result, false); @@ -771,7 +713,7 @@ describe('test workflow preDeploy', () => { updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, - 'e2e-tests': mocks.E2E_TESTS_JOB_MOCK_STEPS, + e2ePerformanceTests: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, }; const result = await act .runEvent('push', { @@ -782,7 +724,6 @@ describe('test workflow preDeploy', () => { assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); assertions.assertIsExpensifyEmployeeJobExecuted(result); - assertions.assertE2ETestsJobExecuted(result, false); // Act does not support ubuntu-20.04-64core runner and omits the job assertions.assertChooseDeployActionsJobExecuted(result); assertions.assertSkipDeployJobExecuted(result, false); assertions.assertCreateNewVersionJobExecuted(result); @@ -815,7 +756,7 @@ describe('test workflow preDeploy', () => { updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, - 'e2e-tests': mocks.E2E_TESTS_JOB_MOCK_STEPS, + e2ePerformanceTests: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, }; const result = await act .runEvent('push', { @@ -826,7 +767,6 @@ describe('test workflow preDeploy', () => { assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); assertions.assertIsExpensifyEmployeeJobExecuted(result); - assertions.assertE2ETestsJobExecuted(result, false); // Act does not support ubuntu-20.04-64core runner and omits the job assertions.assertChooseDeployActionsJobExecuted(result); assertions.assertSkipDeployJobExecuted(result, false); assertions.assertCreateNewVersionJobExecuted(result); @@ -861,7 +801,7 @@ describe('test workflow preDeploy', () => { updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, - 'e2e-tests': mocks.E2E_TESTS_JOB_MOCK_STEPS, + e2ePerformanceTests: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, }; const result = await act .runEvent('push', { @@ -872,7 +812,6 @@ describe('test workflow preDeploy', () => { assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); assertions.assertIsExpensifyEmployeeJobExecuted(result); - assertions.assertE2ETestsJobExecuted(result, false); // Act does not support ubuntu-20.04-64core runner and omits the job assertions.assertChooseDeployActionsJobExecuted(result); assertions.assertSkipDeployJobExecuted(result, false); assertions.assertCreateNewVersionJobExecuted(result); @@ -905,7 +844,7 @@ describe('test workflow preDeploy', () => { updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, - 'e2e-tests': mocks.E2E_TESTS_JOB_MOCK_STEPS, + e2ePerformanceTests: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, }; const result = await act .runEvent('push', { @@ -916,7 +855,6 @@ describe('test workflow preDeploy', () => { assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); assertions.assertIsExpensifyEmployeeJobExecuted(result); - assertions.assertE2ETestsJobExecuted(result, false); // Act does not support ubuntu-20.04-64core runner and omits the job assertions.assertChooseDeployActionsJobExecuted(result); assertions.assertSkipDeployJobExecuted(result, false); assertions.assertCreateNewVersionJobExecuted(result); @@ -949,7 +887,7 @@ describe('test workflow preDeploy', () => { updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, - 'e2e-tests': mocks.E2E_TESTS_JOB_MOCK_STEPS, + e2ePerformanceTests: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, }; testMockSteps.updateStaging[3].mockWith = 'exit 1'; const result = await act @@ -961,7 +899,6 @@ describe('test workflow preDeploy', () => { assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); assertions.assertIsExpensifyEmployeeJobExecuted(result); - assertions.assertE2ETestsJobExecuted(result, false); // Act does not support ubuntu-20.04-64core runner and omits the job assertions.assertChooseDeployActionsJobExecuted(result); assertions.assertSkipDeployJobExecuted(result, false); assertions.assertCreateNewVersionJobExecuted(result); From 0e83c0c3bd2bd43a136768592981f85208e86485 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Thu, 30 Mar 2023 15:34:04 +0200 Subject: [PATCH 072/504] Fix workflow file Fixed previously broken `preDeploy` workflow file See: https://github.com/Expensify/App/issues/13604 --- .github/workflows/preDeploy.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/preDeploy.yml b/.github/workflows/preDeploy.yml index cffa2a5d7ed1..8678931b935e 100644 --- a/.github/workflows/preDeploy.yml +++ b/.github/workflows/preDeploy.yml @@ -244,7 +244,6 @@ jobs: e2ePerformanceTests: needs: [chooseDeployActions] if: ${{ needs.chooseDeployActions.outputs.SHOULD_DEPLOY }} - steps: steps: - name: Perform E2E tests uses: Expensify/App/.github/workflows/e2ePerformanceTests.yml@main From 78662134cec45cef881792fbb503e87f3edfa6cf Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Fri, 31 Mar 2023 09:53:31 +0200 Subject: [PATCH 073/504] Move dependencies Moved the dependencies for testing workflows to dev-dependencies See: https://github.com/Expensify/App/issues/13604 --- package.json | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 096687d3cbff..620772d43685 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,7 @@ "@gorhom/portal": "^1.0.14", "@kie/act-js": "^2.0.1", "@kie/mock-github": "^1.0.0", - "@oguzhnatly/react-native-image-manipulator": "github:Expensify/react-native-image-manipulator#5cdae3d4455b03a04c57f50be3863e2fe6c92c52", + "@oguzhnatly/react-native-image-manipulator": "github:Expensify/react-native-image-manipulator#c5f654fc9d0ad7cc5b89d50b34ecf8b0e3f4d050", "@onfido/react-native-sdk": "7.4.0", "@react-native-async-storage/async-storage": "^1.17.10", "@react-native-camera-roll/camera-roll": "5.4.0", @@ -143,8 +143,7 @@ "semver": "^7.3.8", "shim-keyboard-event-key": "^1.0.3", "underscore": "^1.13.1", - "urbanairship-react-native": "^14.6.1", - "yaml": "^2.2.1" + "urbanairship-react-native": "^14.6.1" }, "devDependencies": { "@actions/core": "1.10.0", @@ -157,6 +156,8 @@ "@babel/preset-react": "^7.10.4", "@babel/runtime": "^7.11.2", "@electron/notarize": "^1.2.3", + "@kie/act-js": "^2.0.1", + "@kie/mock-github": "^1.0.0", "@octokit/core": "4.0.4", "@octokit/plugin-paginate-rest": "3.1.0", "@octokit/plugin-throttling": "4.1.0", @@ -226,7 +227,8 @@ "webpack-cli": "^4.10.0", "webpack-dev-server": "^4.9.3", "webpack-font-preload-plugin": "^1.5.0", - "webpack-merge": "^5.8.0" + "webpack-merge": "^5.8.0", + "yaml": "^2.2.1" }, "overrides": { "react-native": "$react-native" From 11c591994d45d65ec777b71768845871bcbe15da Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Fri, 31 Mar 2023 10:08:12 +0200 Subject: [PATCH 074/504] Move repo files Moved the test repo files definition to the utils file See: https://github.com/Expensify/App/issues/13604 --- workflow_tests/authorChecklist.test.js | 13 +------------ workflow_tests/cherryPick.test.js | 13 +------------ workflow_tests/cla.test.js | 13 +------------ workflow_tests/createNewVersion.test.js | 13 +------------ workflow_tests/deploy.test.js | 13 +------------ workflow_tests/deployBlocker.test.js | 13 +------------ workflow_tests/finishReleaseCycle.test.js | 13 +------------ workflow_tests/lint.test.js | 13 +------------ workflow_tests/lockDeploys.test.js | 13 +------------ workflow_tests/platformDeploy.test.js | 13 +------------ workflow_tests/preDeploy.test.js | 13 +------------ workflow_tests/reviewerChecklist.test.js | 13 +------------ workflow_tests/test.test.js | 13 +------------ workflow_tests/testBuild.test.js | 13 +------------ workflow_tests/utils/utils.js | 17 +++++++++++++++++ workflow_tests/validateGithubActions.test.js | 13 +------------ workflow_tests/verifyPodfile.test.js | 13 +------------ workflow_tests/verifySignedCommits.test.js | 13 +------------ workflow_tests/warnCPLabel.test.js | 13 +------------ 19 files changed, 35 insertions(+), 216 deletions(-) diff --git a/workflow_tests/authorChecklist.test.js b/workflow_tests/authorChecklist.test.js index 23a96d7ee71c..24dbaf86f718 100644 --- a/workflow_tests/authorChecklist.test.js +++ b/workflow_tests/authorChecklist.test.js @@ -8,18 +8,7 @@ const eAct = require('./utils/ExtendedAct'); jest.setTimeout(60 * 1000); let mockGithub; const FILES_TO_COPY_INTO_TEST_REPO = [ - { - src: path.resolve(__dirname, '..', '.github', 'actions'), - dest: '.github/actions', - }, - { - src: path.resolve(__dirname, '..', '.github', 'libs'), - dest: '.github/libs', - }, - { - src: path.resolve(__dirname, '..', '.github', 'scripts'), - dest: '.github/scripts', - }, + ...utils.deepCopy(utils.FILES_TO_COPY_INTO_TEST_REPO), { src: path.resolve(__dirname, '..', '.github', 'workflows', 'authorChecklist.yml'), dest: '.github/workflows/authorChecklist.yml', diff --git a/workflow_tests/cherryPick.test.js b/workflow_tests/cherryPick.test.js index b5ad050886bd..794aedb5062b 100644 --- a/workflow_tests/cherryPick.test.js +++ b/workflow_tests/cherryPick.test.js @@ -8,18 +8,7 @@ const eAct = require('./utils/ExtendedAct'); jest.setTimeout(60 * 1000); let mockGithub; const FILES_TO_COPY_INTO_TEST_REPO = [ - { - src: path.resolve(__dirname, '..', '.github', 'actions'), - dest: '.github/actions', - }, - { - src: path.resolve(__dirname, '..', '.github', 'libs'), - dest: '.github/libs', - }, - { - src: path.resolve(__dirname, '..', '.github', 'scripts'), - dest: '.github/scripts', - }, + ...utils.deepCopy(utils.FILES_TO_COPY_INTO_TEST_REPO), { src: path.resolve(__dirname, '..', '.github', 'workflows', 'cherryPick.yml'), dest: '.github/workflows/cherryPick.yml', diff --git a/workflow_tests/cla.test.js b/workflow_tests/cla.test.js index 9034e51700b7..efd08276d472 100644 --- a/workflow_tests/cla.test.js +++ b/workflow_tests/cla.test.js @@ -8,18 +8,7 @@ const eAct = require('./utils/ExtendedAct'); jest.setTimeout(60 * 1000); let mockGithub; const FILES_TO_COPY_INTO_TEST_REPO = [ - { - src: path.resolve(__dirname, '..', '.github', 'actions'), - dest: '.github/actions', - }, - { - src: path.resolve(__dirname, '..', '.github', 'libs'), - dest: '.github/libs', - }, - { - src: path.resolve(__dirname, '..', '.github', 'scripts'), - dest: '.github/scripts', - }, + ...utils.deepCopy(utils.FILES_TO_COPY_INTO_TEST_REPO), { src: path.resolve(__dirname, '..', '.github', 'workflows', 'cla.yml'), dest: '.github/workflows/cla.yml', diff --git a/workflow_tests/createNewVersion.test.js b/workflow_tests/createNewVersion.test.js index e663eccfed7f..5e2c3431c9cf 100644 --- a/workflow_tests/createNewVersion.test.js +++ b/workflow_tests/createNewVersion.test.js @@ -8,18 +8,7 @@ const eAct = require('./utils/ExtendedAct'); jest.setTimeout(60 * 1000); // 60 sec let mockGithub; const FILES_TO_COPY_INTO_TEST_REPO = [ - { - src: path.resolve(__dirname, '..', '.github', 'actions'), - dest: '.github/actions', - }, - { - src: path.resolve(__dirname, '..', '.github', 'libs'), - dest: '.github/libs', - }, - { - src: path.resolve(__dirname, '..', '.github', 'scripts'), - dest: '.github/scripts', - }, + ...utils.deepCopy(utils.FILES_TO_COPY_INTO_TEST_REPO), { src: path.resolve(__dirname, '..', '.github', 'workflows', 'createNewVersion.yml'), dest: '.github/workflows/createNewVersion.yml', diff --git a/workflow_tests/deploy.test.js b/workflow_tests/deploy.test.js index f7999b9d0a2c..05a3320fc1c1 100644 --- a/workflow_tests/deploy.test.js +++ b/workflow_tests/deploy.test.js @@ -8,18 +8,7 @@ const eAct = require('./utils/ExtendedAct'); jest.setTimeout(60 * 1000); let mockGithub; const FILES_TO_COPY_INTO_TEST_REPO = [ - { - src: path.resolve(__dirname, '..', '.github', 'actions'), - dest: '.github/actions', - }, - { - src: path.resolve(__dirname, '..', '.github', 'libs'), - dest: '.github/libs', - }, - { - src: path.resolve(__dirname, '..', '.github', 'scripts'), - dest: '.github/scripts', - }, + ...utils.deepCopy(utils.FILES_TO_COPY_INTO_TEST_REPO), { src: path.resolve(__dirname, '..', '.github', 'workflows', 'deploy.yml'), dest: '.github/workflows/deploy.yml', diff --git a/workflow_tests/deployBlocker.test.js b/workflow_tests/deployBlocker.test.js index 8a4fe393bfe0..2b86ed637c4c 100644 --- a/workflow_tests/deployBlocker.test.js +++ b/workflow_tests/deployBlocker.test.js @@ -8,18 +8,7 @@ const eAct = require('./utils/ExtendedAct'); jest.setTimeout(60 * 1000); let mockGithub; const FILES_TO_COPY_INTO_TEST_REPO = [ - { - src: path.resolve(__dirname, '..', '.github', 'actions'), - dest: '.github/actions', - }, - { - src: path.resolve(__dirname, '..', '.github', 'libs'), - dest: '.github/libs', - }, - { - src: path.resolve(__dirname, '..', '.github', 'scripts'), - dest: '.github/scripts', - }, + ...utils.deepCopy(utils.FILES_TO_COPY_INTO_TEST_REPO), { src: path.resolve(__dirname, '..', '.github', 'workflows', 'deployBlocker.yml'), dest: '.github/workflows/deployBlocker.yml', diff --git a/workflow_tests/finishReleaseCycle.test.js b/workflow_tests/finishReleaseCycle.test.js index 16149b2cf07b..b16bd7df918c 100644 --- a/workflow_tests/finishReleaseCycle.test.js +++ b/workflow_tests/finishReleaseCycle.test.js @@ -8,18 +8,7 @@ const eAct = require('./utils/ExtendedAct'); jest.setTimeout(60 * 1000); let mockGithub; const FILES_TO_COPY_INTO_TEST_REPO = [ - { - src: path.resolve(__dirname, '..', '.github', 'actions'), - dest: '.github/actions', - }, - { - src: path.resolve(__dirname, '..', '.github', 'libs'), - dest: '.github/libs', - }, - { - src: path.resolve(__dirname, '..', '.github', 'scripts'), - dest: '.github/scripts', - }, + ...utils.deepCopy(utils.FILES_TO_COPY_INTO_TEST_REPO), { src: path.resolve(__dirname, '..', '.github', 'workflows', 'finishReleaseCycle.yml'), dest: '.github/workflows/finishReleaseCycle.yml', diff --git a/workflow_tests/lint.test.js b/workflow_tests/lint.test.js index 6b0669bfbdd4..cd6e9ab3533f 100644 --- a/workflow_tests/lint.test.js +++ b/workflow_tests/lint.test.js @@ -8,18 +8,7 @@ const eAct = require('./utils/ExtendedAct'); jest.setTimeout(60 * 1000); let mockGithub; const FILES_TO_COPY_INTO_TEST_REPO = [ - { - src: path.resolve(__dirname, '..', '.github', 'actions'), - dest: '.github/actions', - }, - { - src: path.resolve(__dirname, '..', '.github', 'libs'), - dest: '.github/libs', - }, - { - src: path.resolve(__dirname, '..', '.github', 'scripts'), - dest: '.github/scripts', - }, + ...utils.deepCopy(utils.FILES_TO_COPY_INTO_TEST_REPO), { src: path.resolve(__dirname, '..', '.github', 'workflows', 'lint.yml'), dest: '.github/workflows/lint.yml', diff --git a/workflow_tests/lockDeploys.test.js b/workflow_tests/lockDeploys.test.js index 44979dbdf5f5..a48a39e638a8 100644 --- a/workflow_tests/lockDeploys.test.js +++ b/workflow_tests/lockDeploys.test.js @@ -8,18 +8,7 @@ const eAct = require('./utils/ExtendedAct'); jest.setTimeout(60 * 1000); let mockGithub; const FILES_TO_COPY_INTO_TEST_REPO = [ - { - src: path.resolve(__dirname, '..', '.github', 'actions'), - dest: '.github/actions', - }, - { - src: path.resolve(__dirname, '..', '.github', 'libs'), - dest: '.github/libs', - }, - { - src: path.resolve(__dirname, '..', '.github', 'scripts'), - dest: '.github/scripts', - }, + ...utils.deepCopy(utils.FILES_TO_COPY_INTO_TEST_REPO), { src: path.resolve(__dirname, '..', '.github', 'workflows', 'lockDeploys.yml'), dest: '.github/workflows/lockDeploys.yml', diff --git a/workflow_tests/platformDeploy.test.js b/workflow_tests/platformDeploy.test.js index d79e11908523..e3187b9870d0 100644 --- a/workflow_tests/platformDeploy.test.js +++ b/workflow_tests/platformDeploy.test.js @@ -8,18 +8,7 @@ const eAct = require('./utils/ExtendedAct'); jest.setTimeout(60 * 1000); let mockGithub; const FILES_TO_COPY_INTO_TEST_REPO = [ - { - src: path.resolve(__dirname, '..', '.github', 'actions'), - dest: '.github/actions', - }, - { - src: path.resolve(__dirname, '..', '.github', 'libs'), - dest: '.github/libs', - }, - { - src: path.resolve(__dirname, '..', '.github', 'scripts'), - dest: '.github/scripts', - }, + ...utils.deepCopy(utils.FILES_TO_COPY_INTO_TEST_REPO), { src: path.resolve(__dirname, '..', '.github', 'workflows', 'platformDeploy.yml'), dest: '.github/workflows/platformDeploy.yml', diff --git a/workflow_tests/preDeploy.test.js b/workflow_tests/preDeploy.test.js index 5b4a94020f5d..b42cf63e5e26 100644 --- a/workflow_tests/preDeploy.test.js +++ b/workflow_tests/preDeploy.test.js @@ -8,18 +8,7 @@ const eAct = require('./utils/ExtendedAct'); jest.setTimeout(60 * 1000); let mockGithub; const FILES_TO_COPY_INTO_TEST_REPO = [ - { - src: path.resolve(__dirname, '..', '.github', 'actions'), - dest: '.github/actions', - }, - { - src: path.resolve(__dirname, '..', '.github', 'libs'), - dest: '.github/libs', - }, - { - src: path.resolve(__dirname, '..', '.github', 'scripts'), - dest: '.github/scripts', - }, + ...utils.deepCopy(utils.FILES_TO_COPY_INTO_TEST_REPO), { src: path.resolve(__dirname, '..', '.github', 'workflows', 'preDeploy.yml'), dest: '.github/workflows/preDeploy.yml', diff --git a/workflow_tests/reviewerChecklist.test.js b/workflow_tests/reviewerChecklist.test.js index fb019c74cf9f..9dfd928fbdf1 100644 --- a/workflow_tests/reviewerChecklist.test.js +++ b/workflow_tests/reviewerChecklist.test.js @@ -8,18 +8,7 @@ const eAct = require('./utils/ExtendedAct'); jest.setTimeout(60 * 1000); let mockGithub; const FILES_TO_COPY_INTO_TEST_REPO = [ - { - src: path.resolve(__dirname, '..', '.github', 'actions'), - dest: '.github/actions', - }, - { - src: path.resolve(__dirname, '..', '.github', 'libs'), - dest: '.github/libs', - }, - { - src: path.resolve(__dirname, '..', '.github', 'scripts'), - dest: '.github/scripts', - }, + ...utils.deepCopy(utils.FILES_TO_COPY_INTO_TEST_REPO), { src: path.resolve(__dirname, '..', '.github', 'workflows', 'reviewerChecklist.yml'), dest: '.github/workflows/reviewerChecklist.yml', diff --git a/workflow_tests/test.test.js b/workflow_tests/test.test.js index 360ff93aeb26..b2e719b9e6b8 100644 --- a/workflow_tests/test.test.js +++ b/workflow_tests/test.test.js @@ -8,18 +8,7 @@ const eAct = require('./utils/ExtendedAct'); jest.setTimeout(60 * 1000); let mockGithub; const FILES_TO_COPY_INTO_TEST_REPO = [ - { - src: path.resolve(__dirname, '..', '.github', 'actions'), - dest: '.github/actions', - }, - { - src: path.resolve(__dirname, '..', '.github', 'libs'), - dest: '.github/libs', - }, - { - src: path.resolve(__dirname, '..', '.github', 'scripts'), - dest: '.github/scripts', - }, + ...utils.deepCopy(utils.FILES_TO_COPY_INTO_TEST_REPO), { src: path.resolve(__dirname, '..', '.github', 'workflows', 'test.yml'), dest: '.github/workflows/test.yml', diff --git a/workflow_tests/testBuild.test.js b/workflow_tests/testBuild.test.js index d9dca51e2d07..30681661677f 100644 --- a/workflow_tests/testBuild.test.js +++ b/workflow_tests/testBuild.test.js @@ -8,18 +8,7 @@ const eAct = require('./utils/ExtendedAct'); jest.setTimeout(60 * 1000); let mockGithub; const FILES_TO_COPY_INTO_TEST_REPO = [ - { - src: path.resolve(__dirname, '..', '.github', 'actions'), - dest: '.github/actions', - }, - { - src: path.resolve(__dirname, '..', '.github', 'libs'), - dest: '.github/libs', - }, - { - src: path.resolve(__dirname, '..', '.github', 'scripts'), - dest: '.github/scripts', - }, + ...utils.deepCopy(utils.FILES_TO_COPY_INTO_TEST_REPO), { src: path.resolve(__dirname, '..', '.github', 'workflows', 'testBuild.yml'), dest: '.github/workflows/testBuild.yml', diff --git a/workflow_tests/utils/utils.js b/workflow_tests/utils/utils.js index dc375a74cf93..b6bce19f683b 100644 --- a/workflow_tests/utils/utils.js +++ b/workflow_tests/utils/utils.js @@ -1,5 +1,6 @@ const yaml = require('yaml'); const fs = require('fs'); +const path = require('path'); function setUpActParams( act, @@ -151,10 +152,26 @@ function deepCopy(originalObject) { return JSON.parse(JSON.stringify(originalObject)); } +const FILES_TO_COPY_INTO_TEST_REPO = [ + { + src: path.resolve(__dirname, '..', '..', '.github', 'actions'), + dest: '.github/actions', + }, + { + src: path.resolve(__dirname, '..', '..', '.github', 'libs'), + dest: '.github/libs', + }, + { + src: path.resolve(__dirname, '..', '..', '.github', 'scripts'), + dest: '.github/scripts', + }, +]; + module.exports = { setUpActParams, getMockStep, getStepAssertion, setJobRunners, deepCopy, + FILES_TO_COPY_INTO_TEST_REPO, }; diff --git a/workflow_tests/validateGithubActions.test.js b/workflow_tests/validateGithubActions.test.js index 45a6d6561622..6aca9266c3ab 100644 --- a/workflow_tests/validateGithubActions.test.js +++ b/workflow_tests/validateGithubActions.test.js @@ -8,18 +8,7 @@ const eAct = require('./utils/ExtendedAct'); jest.setTimeout(60 * 1000); let mockGithub; const FILES_TO_COPY_INTO_TEST_REPO = [ - { - src: path.resolve(__dirname, '..', '.github', 'actions'), - dest: '.github/actions', - }, - { - src: path.resolve(__dirname, '..', '.github', 'libs'), - dest: '.github/libs', - }, - { - src: path.resolve(__dirname, '..', '.github', 'scripts'), - dest: '.github/scripts', - }, + ...utils.deepCopy(utils.FILES_TO_COPY_INTO_TEST_REPO), { src: path.resolve(__dirname, '..', '.github', 'workflows', 'validateGithubActions.yml'), dest: '.github/workflows/validateGithubActions.yml', diff --git a/workflow_tests/verifyPodfile.test.js b/workflow_tests/verifyPodfile.test.js index 7529f509787e..ad770f1ba968 100644 --- a/workflow_tests/verifyPodfile.test.js +++ b/workflow_tests/verifyPodfile.test.js @@ -8,18 +8,7 @@ const eAct = require('./utils/ExtendedAct'); jest.setTimeout(60 * 1000); let mockGithub; const FILES_TO_COPY_INTO_TEST_REPO = [ - { - src: path.resolve(__dirname, '..', '.github', 'actions'), - dest: '.github/actions', - }, - { - src: path.resolve(__dirname, '..', '.github', 'libs'), - dest: '.github/libs', - }, - { - src: path.resolve(__dirname, '..', '.github', 'scripts'), - dest: '.github/scripts', - }, + ...utils.deepCopy(utils.FILES_TO_COPY_INTO_TEST_REPO), { src: path.resolve(__dirname, '..', '.github', 'workflows', 'verifyPodfile.yml'), dest: '.github/workflows/verifyPodfile.yml', diff --git a/workflow_tests/verifySignedCommits.test.js b/workflow_tests/verifySignedCommits.test.js index ff8ecb7f6785..076541c08354 100644 --- a/workflow_tests/verifySignedCommits.test.js +++ b/workflow_tests/verifySignedCommits.test.js @@ -8,18 +8,7 @@ const eAct = require('./utils/ExtendedAct'); jest.setTimeout(60 * 1000); let mockGithub; const FILES_TO_COPY_INTO_TEST_REPO = [ - { - src: path.resolve(__dirname, '..', '.github', 'actions'), - dest: '.github/actions', - }, - { - src: path.resolve(__dirname, '..', '.github', 'libs'), - dest: '.github/libs', - }, - { - src: path.resolve(__dirname, '..', '.github', 'scripts'), - dest: '.github/scripts', - }, + ...utils.deepCopy(utils.FILES_TO_COPY_INTO_TEST_REPO), { src: path.resolve(__dirname, '..', '.github', 'workflows', 'verifySignedCommits.yml'), dest: '.github/workflows/verifySignedCommits.yml', diff --git a/workflow_tests/warnCPLabel.test.js b/workflow_tests/warnCPLabel.test.js index 326cacd57a84..b99ede323395 100644 --- a/workflow_tests/warnCPLabel.test.js +++ b/workflow_tests/warnCPLabel.test.js @@ -8,18 +8,7 @@ const eAct = require('./utils/ExtendedAct'); jest.setTimeout(60 * 1000); let mockGithub; const FILES_TO_COPY_INTO_TEST_REPO = [ - { - src: path.resolve(__dirname, '..', '.github', 'actions'), - dest: '.github/actions', - }, - { - src: path.resolve(__dirname, '..', '.github', 'libs'), - dest: '.github/libs', - }, - { - src: path.resolve(__dirname, '..', '.github', 'scripts'), - dest: '.github/scripts', - }, + ...utils.deepCopy(utils.FILES_TO_COPY_INTO_TEST_REPO), { src: path.resolve(__dirname, '..', '.github', 'workflows', 'warnCPLabel.yml'), dest: '.github/workflows/warnCPLabel.yml', From 115f3c47eca7bcb22b0c4045f04312c045be1746 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Fri, 31 Mar 2023 10:09:50 +0200 Subject: [PATCH 075/504] Rename functions Renamed two of the utils functions from `get...` to `create...` See: https://github.com/Expensify/App/issues/13604 --- workflow_tests/utils/utils.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/workflow_tests/utils/utils.js b/workflow_tests/utils/utils.js index b6bce19f683b..ec00a6870d50 100644 --- a/workflow_tests/utils/utils.js +++ b/workflow_tests/utils/utils.js @@ -49,7 +49,7 @@ function setUpActParams( return updated_act; } -function getMockStep( +function createMockStep( name, message, job_id = null, @@ -94,7 +94,7 @@ function getMockStep( }; } -function getStepAssertion( +function createStepAssertion( name, isSuccessful = true, expectedOutput = null, @@ -169,8 +169,8 @@ const FILES_TO_COPY_INTO_TEST_REPO = [ module.exports = { setUpActParams, - getMockStep, - getStepAssertion, + getMockStep: createMockStep, + getStepAssertion: createStepAssertion, setJobRunners, deepCopy, FILES_TO_COPY_INTO_TEST_REPO, From a5c8fd07f614f27afc3eba40996837080395b025 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Fri, 31 Mar 2023 10:11:12 +0200 Subject: [PATCH 076/504] Rename references Renamed the references of the previously renamed functions See: https://github.com/Expensify/App/issues/13604 --- .../assertions/authorChecklistAssertions.js | 2 +- .../assertions/cherryPickAssertions.js | 42 +++---- workflow_tests/assertions/claAssertions.js | 6 +- .../assertions/createNewVersionAssertions.js | 18 +-- workflow_tests/assertions/deployAssertions.js | 24 ++-- .../assertions/deployBlockerAssertions.js | 14 +-- .../finishReleaseCycleAssertions.js | 20 ++-- workflow_tests/assertions/lintAssertions.js | 8 +- .../assertions/lockDeploysAssertions.js | 14 +-- .../assertions/platformDeployAssertions.js | 104 ++++++++--------- .../assertions/preDeployAssertions.js | 52 ++++----- .../assertions/reviewerChecklistAssertions.js | 2 +- workflow_tests/assertions/testAssertions.js | 16 +-- .../assertions/testBuildAssertions.js | 76 ++++++------- .../validateGithubActionsAssertions.js | 8 +- .../assertions/verifyPodfileAssertions.js | 6 +- .../verifySignedCommitsAssertions.js | 2 +- .../assertions/warnCPLabelAssertions.js | 4 +- workflow_tests/createNewVersion.test.js | 2 +- workflow_tests/deployBlocker.test.js | 2 +- workflow_tests/finishReleaseCycle.test.js | 2 +- workflow_tests/lockDeploys.test.js | 2 +- workflow_tests/mocks/authorChecklistMocks.js | 2 +- workflow_tests/mocks/cherryPickMocks.js | 48 ++++---- workflow_tests/mocks/claMocks.js | 10 +- workflow_tests/mocks/createNewVersionMocks.js | 22 ++-- workflow_tests/mocks/deployBlockerMocks.js | 14 +-- workflow_tests/mocks/deployMocks.js | 26 ++--- .../mocks/finishReleaseCycleMocks.js | 24 ++-- workflow_tests/mocks/lintMocks.js | 8 +- workflow_tests/mocks/lockDeploysMocks.js | 8 +- workflow_tests/mocks/platformDeployMocks.js | 106 +++++++++--------- workflow_tests/mocks/preDeployMocks.js | 62 +++++----- .../mocks/reviewerChecklistMocks.js | 2 +- workflow_tests/mocks/testBuildMocks.js | 80 ++++++------- workflow_tests/mocks/testMocks.js | 16 +-- .../mocks/validateGithubActionsMocks.js | 8 +- workflow_tests/mocks/verifyPodfileMocks.js | 6 +- .../mocks/verifySignedCommitsMocks.js | 2 +- workflow_tests/mocks/warnCPLabelMocks.js | 4 +- workflow_tests/preDeploy.test.js | 16 +-- workflow_tests/testBuild.test.js | 8 +- workflow_tests/utils/utils.js | 4 +- workflow_tests/warnCPLabel.test.js | 2 +- 44 files changed, 452 insertions(+), 452 deletions(-) diff --git a/workflow_tests/assertions/authorChecklistAssertions.js b/workflow_tests/assertions/authorChecklistAssertions.js index a1ca5840426b..5eb687fdbb5d 100644 --- a/workflow_tests/assertions/authorChecklistAssertions.js +++ b/workflow_tests/assertions/authorChecklistAssertions.js @@ -2,7 +2,7 @@ const utils = require('../utils/utils'); const assertChecklistJobExecuted = (workflowResult, didExecute = true) => { const steps = [ - utils.getStepAssertion( + utils.createStepAssertion( 'authorChecklist.js', true, null, diff --git a/workflow_tests/assertions/cherryPickAssertions.js b/workflow_tests/assertions/cherryPickAssertions.js index f86f07f491f5..d9bce263d524 100644 --- a/workflow_tests/assertions/cherryPickAssertions.js +++ b/workflow_tests/assertions/cherryPickAssertions.js @@ -2,7 +2,7 @@ const utils = require('../utils/utils'); const assertValidateActorJobExecuted = (workflowResult, username = 'Dummy Author', didExecute = true) => { const steps = [ - utils.getStepAssertion( + utils.createStepAssertion( 'Check if user is deployer', true, null, @@ -24,7 +24,7 @@ const assertValidateActorJobExecuted = (workflowResult, username = 'Dummy Author const assertCreateNewVersionJobExecuted = (workflowResult, didExecute = true) => { const steps = [ - utils.getStepAssertion( + utils.createStepAssertion( 'Create new version', true, null, @@ -58,7 +58,7 @@ const assertCherryPickJobExecuted = ( isSuccessful = true, ) => { const steps = [ - utils.getStepAssertion( + utils.createStepAssertion( 'Checkout staging branch', true, null, @@ -67,7 +67,7 @@ const assertCherryPickJobExecuted = ( [{key: 'ref', value: 'staging'}, {key: 'token', value: '***'}], [], ), - utils.getStepAssertion( + utils.createStepAssertion( 'Set up git for OSBotify', true, null, @@ -76,7 +76,7 @@ const assertCherryPickJobExecuted = ( [{key: 'GPG_PASSPHRASE', value: '***'}], [], ), - utils.getStepAssertion( + utils.createStepAssertion( 'Create branch for new pull request', true, null, @@ -85,7 +85,7 @@ const assertCherryPickJobExecuted = ( [], [], ), - utils.getStepAssertion( + utils.createStepAssertion( 'Get merge commit for CP pull request', true, null, @@ -94,12 +94,12 @@ const assertCherryPickJobExecuted = ( [{key: 'GITHUB_TOKEN', value: '***'}, {key: 'USER', value: user}, {key: 'PULL_REQUEST_NUMBER', value: pullRequestNumber}], [], ), - utils.getStepAssertion( + utils.createStepAssertion( 'Save correct NEW_VERSION to env', true, inputNewVersion ? `New version is ${inputNewVersion}` : 'New version is', ), - utils.getStepAssertion( + utils.createStepAssertion( 'Get merge commit for version-bump pull request', true, null, @@ -108,7 +108,7 @@ const assertCherryPickJobExecuted = ( [{key: 'GITHUB_TOKEN', value: '***'}, {key: 'USER', value: 'OSBotify'}, {key: 'TITLE_REGEX', value: `Update version to ${newVersion}`}], [], ), - utils.getStepAssertion( + utils.createStepAssertion( 'Cherry-pick the version-bump to new branch', true, null, @@ -117,7 +117,7 @@ const assertCherryPickJobExecuted = ( [], [], ), - utils.getStepAssertion( + utils.createStepAssertion( 'Cherry-pick the merge commit of target PR to new branch', true, null, @@ -126,7 +126,7 @@ const assertCherryPickJobExecuted = ( [], [], ), - utils.getStepAssertion( + utils.createStepAssertion( 'Push changes to CP branch', true, null, @@ -135,7 +135,7 @@ const assertCherryPickJobExecuted = ( [], [], ), - utils.getStepAssertion( + utils.createStepAssertion( 'Create Pull Request', true, null, @@ -144,7 +144,7 @@ const assertCherryPickJobExecuted = ( [], [{key: 'GITHUB_TOKEN', value: '***'}], ), - utils.getStepAssertion( + utils.createStepAssertion( 'Check if ShortVersionString is up to date', true, null, @@ -153,7 +153,7 @@ const assertCherryPickJobExecuted = ( [], [], ), - utils.getStepAssertion( + utils.createStepAssertion( 'Check if pull request is mergeable', true, null, @@ -173,7 +173,7 @@ const assertCherryPickJobExecuted = ( } const conflictsSteps = [ - utils.getStepAssertion( + utils.createStepAssertion( 'Auto-assign PR if there are merge conflicts or if the bundle versions are mismatched', true, null, @@ -193,7 +193,7 @@ const assertCherryPickJobExecuted = ( } const manualMergeSteps = [ - utils.getStepAssertion( + utils.createStepAssertion( 'Assign the PR to the deployer', true, null, @@ -202,7 +202,7 @@ const assertCherryPickJobExecuted = ( [], [{key: 'GITHUB_TOKEN', value: '***'}], ), - utils.getStepAssertion( + utils.createStepAssertion( 'If PR has merge conflicts, comment with instructions for assignee', true, null, @@ -222,7 +222,7 @@ const assertCherryPickJobExecuted = ( } const autoMergeSteps = [ - utils.getStepAssertion( + utils.createStepAssertion( 'Auto-approve the PR', true, null, @@ -242,7 +242,7 @@ const assertCherryPickJobExecuted = ( } const versionMismatchSteps = [ - utils.getStepAssertion( + utils.createStepAssertion( 'If PR has a bundle version mismatch, comment with the instructions for assignee', true, null, @@ -262,7 +262,7 @@ const assertCherryPickJobExecuted = ( } const failedSteps = [ - utils.getStepAssertion( + utils.createStepAssertion( 'Announces a CP failure in the #announce Slack room', true, null, @@ -282,7 +282,7 @@ const assertCherryPickJobExecuted = ( } const autoMergeableSteps = [ - utils.getStepAssertion( + utils.createStepAssertion( 'Auto-merge the PR', true, null, diff --git a/workflow_tests/assertions/claAssertions.js b/workflow_tests/assertions/claAssertions.js index 1056f0dc5f78..bc414134c572 100644 --- a/workflow_tests/assertions/claAssertions.js +++ b/workflow_tests/assertions/claAssertions.js @@ -2,7 +2,7 @@ const utils = require('../utils/utils'); const assertCLAJobExecuted = (workflowResult, commentBody = '', githubRepository = '', didExecute = true, runAssitant = true) => { const steps = [ - utils.getStepAssertion( + utils.createStepAssertion( 'CLA comment check', true, null, @@ -11,7 +11,7 @@ const assertCLAJobExecuted = (workflowResult, commentBody = '', githubRepository [{key: 'text', value: commentBody}, {key: 'regex', value: '\\s*I have read the CLA Document and I hereby sign the CLA\\s*'}], [], ), - utils.getStepAssertion( + utils.createStepAssertion( 'CLA comment re-check', true, null, @@ -31,7 +31,7 @@ const assertCLAJobExecuted = (workflowResult, commentBody = '', githubRepository } const assistantSteps = [ - utils.getStepAssertion( + utils.createStepAssertion( 'CLA Assistant', true, null, diff --git a/workflow_tests/assertions/createNewVersionAssertions.js b/workflow_tests/assertions/createNewVersionAssertions.js index d867ef7395de..08fad472eab1 100644 --- a/workflow_tests/assertions/createNewVersionAssertions.js +++ b/workflow_tests/assertions/createNewVersionAssertions.js @@ -2,7 +2,7 @@ const utils = require('../utils/utils'); const assertValidateActorJobExecuted = (workflowResult, didExecute = true) => { const steps = [ - utils.getStepAssertion( + utils.createStepAssertion( 'Get user permissions', true, null, @@ -23,7 +23,7 @@ const assertValidateActorJobExecuted = (workflowResult, didExecute = true) => { }; const assertCreateNewVersionJobExecuted = (workflowResult, semverLevel = 'BUILD', didExecute = true, isSuccessful = true) => { const steps = [ - utils.getStepAssertion( + utils.createStepAssertion( 'Check out', true, null, @@ -32,7 +32,7 @@ const assertCreateNewVersionJobExecuted = (workflowResult, semverLevel = 'BUILD' [{key: 'fetch-depth', value: '0'}], [], ), - utils.getStepAssertion( + utils.createStepAssertion( 'Setup git for OSBotify', true, null, @@ -41,7 +41,7 @@ const assertCreateNewVersionJobExecuted = (workflowResult, semverLevel = 'BUILD' [{key: 'GPG_PASSPHRASE', value: '***'}], [], ), - utils.getStepAssertion( + utils.createStepAssertion( 'Run turnstyle', true, null, @@ -50,7 +50,7 @@ const assertCreateNewVersionJobExecuted = (workflowResult, semverLevel = 'BUILD' [{key: 'poll-interval-seconds', value: '10'}], [{key: 'GITHUB_TOKEN', value: '***'}], ), - utils.getStepAssertion( + utils.createStepAssertion( 'Create new branch', true, null, @@ -59,7 +59,7 @@ const assertCreateNewVersionJobExecuted = (workflowResult, semverLevel = 'BUILD' [], [], ), - utils.getStepAssertion( + utils.createStepAssertion( 'Generate version', true, null, @@ -68,7 +68,7 @@ const assertCreateNewVersionJobExecuted = (workflowResult, semverLevel = 'BUILD' [{key: 'GITHUB_TOKEN', value: '***'}, {key: 'SEMVER_LEVEL', value: semverLevel}], [], ), - utils.getStepAssertion( + utils.createStepAssertion( 'Commit new version', true, null, @@ -77,7 +77,7 @@ const assertCreateNewVersionJobExecuted = (workflowResult, semverLevel = 'BUILD' [], [], ), - utils.getStepAssertion( + utils.createStepAssertion( 'Update main branch', true, null, @@ -104,7 +104,7 @@ const assertCreateNewVersionJobExecuted = (workflowResult, semverLevel = 'BUILD' } const failedSteps = [ - utils.getStepAssertion( + utils.createStepAssertion( 'Announce failed workflow in Slack', true, null, diff --git a/workflow_tests/assertions/deployAssertions.js b/workflow_tests/assertions/deployAssertions.js index c8917921df11..372c7c42a7fc 100644 --- a/workflow_tests/assertions/deployAssertions.js +++ b/workflow_tests/assertions/deployAssertions.js @@ -2,7 +2,7 @@ const utils = require('../utils/utils'); const assertValidateJobExecuted = (workflowResult, didExecute = true) => { const steps = [ - utils.getStepAssertion( + utils.createStepAssertion( 'Get merged pull request', true, null, @@ -28,7 +28,7 @@ const assertValidateJobExecuted = (workflowResult, didExecute = true) => { const assertDeployStagingJobExecuted = (workflowResult, didExecute = true) => { const steps = [ - utils.getStepAssertion( + utils.createStepAssertion( 'Checkout staging branch', true, null, @@ -36,7 +36,7 @@ const assertDeployStagingJobExecuted = (workflowResult, didExecute = true) => { 'Checking out staging branch', [{key: 'ref', value: 'staging'}, {key: 'token', value: '***'}], ), - utils.getStepAssertion( + utils.createStepAssertion( 'Setup git for OSBotify', true, null, @@ -44,14 +44,14 @@ const assertDeployStagingJobExecuted = (workflowResult, didExecute = true) => { 'Setting up git for OSBotify', [{key: 'GPG_PASSPHRASE', value: '***'}], ), - utils.getStepAssertion( + utils.createStepAssertion( 'Tag version', true, null, 'DEPLOY_STAGING', 'Tagging new version', ), - utils.getStepAssertion( + utils.createStepAssertion( '🚀 Push tags to trigger staging deploy 🚀', true, null, @@ -71,7 +71,7 @@ const assertDeployStagingJobExecuted = (workflowResult, didExecute = true) => { const assertDeployProductionJobExecuted = (workflowResult, didExecute = true) => { const steps = [ - utils.getStepAssertion( + utils.createStepAssertion( 'Checkout', true, null, @@ -79,7 +79,7 @@ const assertDeployProductionJobExecuted = (workflowResult, didExecute = true) => 'Checking out', [{key: 'fetch-depth', value: '0'}, {key: 'token', value: '***'}], ), - utils.getStepAssertion( + utils.createStepAssertion( 'Setup git for OSBotify', true, null, @@ -87,21 +87,21 @@ const assertDeployProductionJobExecuted = (workflowResult, didExecute = true) => 'Setting up git for OSBotify', [{key: 'GPG_PASSPHRASE', value: '***'}], ), - utils.getStepAssertion( + utils.createStepAssertion( 'Checkout production branch', true, null, 'DEPLOY_PRODUCTION', 'Checking out production branch', ), - utils.getStepAssertion( + utils.createStepAssertion( 'Get current app version', true, null, 'DEPLOY_PRODUCTION', 'Getting current app version', ), - utils.getStepAssertion( + utils.createStepAssertion( 'Get Release Pull Request List', true, null, @@ -109,7 +109,7 @@ const assertDeployProductionJobExecuted = (workflowResult, didExecute = true) => 'Getting release PR list', [{key: 'TAG', value: '1.2.3'}, {key: 'GITHUB_TOKEN', value: '***'}, {key: 'IS_PRODUCTION_DEPLOY', value: 'true'}], ), - utils.getStepAssertion( + utils.createStepAssertion( 'Generate Release Body', true, null, @@ -117,7 +117,7 @@ const assertDeployProductionJobExecuted = (workflowResult, didExecute = true) => 'Generating release body', [{key: 'PR_LIST', value: '[1.2.1, 1.2.2]'}], ), - utils.getStepAssertion( + utils.createStepAssertion( '🚀 Create release to trigger production deploy 🚀', true, null, diff --git a/workflow_tests/assertions/deployBlockerAssertions.js b/workflow_tests/assertions/deployBlockerAssertions.js index dbc1f18b737e..13ef0bbb23a6 100644 --- a/workflow_tests/assertions/deployBlockerAssertions.js +++ b/workflow_tests/assertions/deployBlockerAssertions.js @@ -2,7 +2,7 @@ const utils = require('../utils/utils'); const assertDeployBlockerJobExecuted = (workflowResult, issueTitle, issueNumber, didExecute = true, isSuccessful = true) => { const steps = [ - utils.getStepAssertion( + utils.createStepAssertion( 'Checkout', true, null, @@ -11,7 +11,7 @@ const assertDeployBlockerJobExecuted = (workflowResult, issueTitle, issueNumber, [{key: 'fetch-depth', value: '0'}, {key: 'token', value: '***'}], [], ), - utils.getStepAssertion( + utils.createStepAssertion( 'Get URL, title, & number of new deploy blocker (issue)', true, null, @@ -20,7 +20,7 @@ const assertDeployBlockerJobExecuted = (workflowResult, issueTitle, issueNumber, [], [{key: 'TITLE', value: issueTitle}], ), - utils.getStepAssertion( + utils.createStepAssertion( 'Update StagingDeployCash with new deploy blocker', true, null, @@ -29,7 +29,7 @@ const assertDeployBlockerJobExecuted = (workflowResult, issueTitle, issueNumber, [{key: 'GITHUB_TOKEN', value: '***'}], [], ), - utils.getStepAssertion( + utils.createStepAssertion( 'Give the issue/PR the Hourly, Engineering labels', true, null, @@ -38,7 +38,7 @@ const assertDeployBlockerJobExecuted = (workflowResult, issueTitle, issueNumber, [{key: 'add-labels', value: 'Hourly, Engineering'}, {key: 'remove-labels', value: 'Daily, Weekly, Monthly'}], [], ), - utils.getStepAssertion( + utils.createStepAssertion( 'Comment on deferred PR', true, null, @@ -60,7 +60,7 @@ const assertDeployBlockerJobExecuted = (workflowResult, issueTitle, issueNumber, } const successSteps = [ - utils.getStepAssertion( + utils.createStepAssertion( 'Post the issue in the #expensify-open-source slack room', true, null, @@ -80,7 +80,7 @@ const assertDeployBlockerJobExecuted = (workflowResult, issueTitle, issueNumber, } const failedSteps = [ - utils.getStepAssertion( + utils.createStepAssertion( 'Announce failed workflow in Slack', true, null, diff --git a/workflow_tests/assertions/finishReleaseCycleAssertions.js b/workflow_tests/assertions/finishReleaseCycleAssertions.js index 613366f9d262..ff3ac8253da0 100644 --- a/workflow_tests/assertions/finishReleaseCycleAssertions.js +++ b/workflow_tests/assertions/finishReleaseCycleAssertions.js @@ -2,7 +2,7 @@ const utils = require('../utils/utils'); const assertValidateJobExecuted = (workflowResult, username = 'Dummy Author', issueNumber = '', didExecute = true, isTeamMember = true, hasBlockers = false) => { const steps = [ - utils.getStepAssertion( + utils.createStepAssertion( 'Validate actor is deployer', true, null, @@ -18,7 +18,7 @@ const assertValidateJobExecuted = (workflowResult, username = 'Dummy Author', is ]; if (isTeamMember) { steps.push( - utils.getStepAssertion( + utils.createStepAssertion( 'Check for any deploy blockers', true, null, @@ -43,7 +43,7 @@ const assertValidateJobExecuted = (workflowResult, username = 'Dummy Author', is // eslint-disable-next-line rulesdir/no-negated-variables const notTeamMemberSteps = [ - utils.getStepAssertion( + utils.createStepAssertion( 'Reopen and comment on issue (not a team member)', true, null, @@ -67,7 +67,7 @@ const assertValidateJobExecuted = (workflowResult, username = 'Dummy Author', is } const blockerSteps = [ - utils.getStepAssertion( + utils.createStepAssertion( 'Reopen and comment on issue (has blockers)', true, null, @@ -92,7 +92,7 @@ const assertValidateJobExecuted = (workflowResult, username = 'Dummy Author', is const assertUpdateProductionJobExecuted = (workflowResult, didExecute = true) => { const steps = [ - utils.getStepAssertion( + utils.createStepAssertion( 'Update production branch', true, null, @@ -118,7 +118,7 @@ const assertUpdateProductionJobExecuted = (workflowResult, didExecute = true) => const assertCreateNewPatchVersionJobExecuted = (workflowResult, didExecute = true) => { const steps = [ - utils.getStepAssertion( + utils.createStepAssertion( 'Create new version', true, null, @@ -140,7 +140,7 @@ const assertCreateNewPatchVersionJobExecuted = (workflowResult, didExecute = tru const assertCreateNewStagingDeployCashJobExecuted = (workflowResult, newVersion = '', didExecute = true, isSuccessful = true) => { const steps = [ - utils.getStepAssertion( + utils.createStepAssertion( 'Update staging branch to trigger staging deploy', true, null, @@ -153,7 +153,7 @@ const assertCreateNewStagingDeployCashJobExecuted = (workflowResult, newVersion ], [], ), - utils.getStepAssertion( + utils.createStepAssertion( 'Tag version', true, null, @@ -162,7 +162,7 @@ const assertCreateNewStagingDeployCashJobExecuted = (workflowResult, newVersion [], [], ), - utils.getStepAssertion( + utils.createStepAssertion( 'Create new StagingDeployCash', true, null, @@ -189,7 +189,7 @@ const assertCreateNewStagingDeployCashJobExecuted = (workflowResult, newVersion } const failProdSteps = [ - utils.getStepAssertion( + utils.createStepAssertion( 'Announce failed workflow in Slack', true, null, diff --git a/workflow_tests/assertions/lintAssertions.js b/workflow_tests/assertions/lintAssertions.js index 3e8862fca63f..7b6371d30ab0 100644 --- a/workflow_tests/assertions/lintAssertions.js +++ b/workflow_tests/assertions/lintAssertions.js @@ -2,7 +2,7 @@ const utils = require('../utils/utils'); const assertLintJobExecuted = (workflowResult, didExecute = true) => { const steps = [ - utils.getStepAssertion( + utils.createStepAssertion( 'Checkout', true, null, @@ -11,7 +11,7 @@ const assertLintJobExecuted = (workflowResult, didExecute = true) => { [], [], ), - utils.getStepAssertion( + utils.createStepAssertion( 'Setup Node', true, null, @@ -20,7 +20,7 @@ const assertLintJobExecuted = (workflowResult, didExecute = true) => { [], [], ), - utils.getStepAssertion( + utils.createStepAssertion( 'Lint JavaScript with ESLint', true, null, @@ -29,7 +29,7 @@ const assertLintJobExecuted = (workflowResult, didExecute = true) => { [], [{key: 'CI', value: 'true'}], ), - utils.getStepAssertion( + utils.createStepAssertion( 'Lint shell scripts with ShellCheck', true, null, diff --git a/workflow_tests/assertions/lockDeploysAssertions.js b/workflow_tests/assertions/lockDeploysAssertions.js index 9d6b83ab157a..e0e218ddf89a 100644 --- a/workflow_tests/assertions/lockDeploysAssertions.js +++ b/workflow_tests/assertions/lockDeploysAssertions.js @@ -2,7 +2,7 @@ const utils = require('../utils/utils'); const assertlockStagingDeploysJobExecuted = (workflowResult, didExecute = true, isSuccessful = true) => { const steps = [ - utils.getStepAssertion( + utils.createStepAssertion( 'Checkout', true, null, @@ -11,7 +11,7 @@ const assertlockStagingDeploysJobExecuted = (workflowResult, didExecute = true, [{key: 'ref', value: 'main'}, {key: 'fetch-depth', value: '0'}, {key: 'token', value: '***'}], [], ), - utils.getStepAssertion( + utils.createStepAssertion( 'Wait for staging deploys to finish', true, null, @@ -20,7 +20,7 @@ const assertlockStagingDeploysJobExecuted = (workflowResult, didExecute = true, [{key: 'GITHUB_TOKEN', value: '***'}], [], ), - utils.getStepAssertion( + utils.createStepAssertion( 'Comment in StagingDeployCash to give Applause the 🟢 to begin QA', true, null, @@ -40,7 +40,7 @@ const assertlockStagingDeploysJobExecuted = (workflowResult, didExecute = true, } const failProdSteps = [ - utils.getStepAssertion( + utils.createStepAssertion( 'Announce failed workflow', true, null, @@ -62,7 +62,7 @@ const assertlockStagingDeploysJobExecuted = (workflowResult, didExecute = true, const assertlockStagingDeploysJobFailedAfterFirstStep = (workflowResult) => { const steps = [ - utils.getStepAssertion( + utils.createStepAssertion( 'Checkout', true, null, @@ -71,7 +71,7 @@ const assertlockStagingDeploysJobFailedAfterFirstStep = (workflowResult) => { [{key: 'ref', value: 'main'}, {key: 'fetch-depth', value: '0'}, {key: 'token', value: '***'}], [], ), - utils.getStepAssertion( + utils.createStepAssertion( 'Wait for staging deploys to finish', false, null, @@ -80,7 +80,7 @@ const assertlockStagingDeploysJobFailedAfterFirstStep = (workflowResult) => { [{key: 'GITHUB_TOKEN', value: '***'}], [], ), - utils.getStepAssertion( + utils.createStepAssertion( 'Announce failed workflow', true, null, diff --git a/workflow_tests/assertions/platformDeployAssertions.js b/workflow_tests/assertions/platformDeployAssertions.js index a41f5d9f2e72..711daf515b01 100644 --- a/workflow_tests/assertions/platformDeployAssertions.js +++ b/workflow_tests/assertions/platformDeployAssertions.js @@ -2,7 +2,7 @@ const utils = require('../utils/utils'); const assertVerifyActorJobExecuted = (workflowResult, username, didExecute = true) => { const steps = [ - utils.getStepAssertion( + utils.createStepAssertion( 'Check if user is deployer', true, null, @@ -23,7 +23,7 @@ const assertVerifyActorJobExecuted = (workflowResult, username, didExecute = tru const assertAndroidJobExecuted = (workflowResult, didExecute = true, isProduction = true, isSuccessful = true) => { const steps = [ - utils.getStepAssertion( + utils.createStepAssertion( 'Checkout', true, null, @@ -31,14 +31,14 @@ const assertAndroidJobExecuted = (workflowResult, didExecute = true, isProductio 'Checking out', [{key: 'fetch-depth', value: '0'}], ), - utils.getStepAssertion( + utils.createStepAssertion( 'Setup Node', true, null, 'ANDROID', 'Setting up Node', ), - utils.getStepAssertion( + utils.createStepAssertion( 'Setup Ruby', true, null, @@ -46,7 +46,7 @@ const assertAndroidJobExecuted = (workflowResult, didExecute = true, isProductio 'Setting up Ruby', [{key: 'ruby-version', value: '2.7'}, {key: 'bundler-cache', value: 'true'}], ), - utils.getStepAssertion( + utils.createStepAssertion( 'Decrypt keystore', true, null, @@ -55,7 +55,7 @@ const assertAndroidJobExecuted = (workflowResult, didExecute = true, isProductio null, [{key: 'LARGE_SECRET_PASSPHRASE', value: '***'}], ), - utils.getStepAssertion( + utils.createStepAssertion( 'Decrypt json key', true, null, @@ -64,7 +64,7 @@ const assertAndroidJobExecuted = (workflowResult, didExecute = true, isProductio null, [{key: 'LARGE_SECRET_PASSPHRASE', value: '***'}], ), - utils.getStepAssertion( + utils.createStepAssertion( 'Set version in ENV', true, null, @@ -74,7 +74,7 @@ const assertAndroidJobExecuted = (workflowResult, didExecute = true, isProductio ]; if (!isProduction) { steps.push( - utils.getStepAssertion( + utils.createStepAssertion( 'Run Fastlane beta', true, null, @@ -86,7 +86,7 @@ const assertAndroidJobExecuted = (workflowResult, didExecute = true, isProductio ); } else { steps.push( - utils.getStepAssertion( + utils.createStepAssertion( 'Run Fastlane production', true, null, @@ -98,7 +98,7 @@ const assertAndroidJobExecuted = (workflowResult, didExecute = true, isProductio ); } steps.push( - utils.getStepAssertion( + utils.createStepAssertion( 'Archive Android sourcemaps', true, null, @@ -109,7 +109,7 @@ const assertAndroidJobExecuted = (workflowResult, didExecute = true, isProductio ); if (!isProduction) { steps.push( - utils.getStepAssertion( + utils.createStepAssertion( 'Upload Android version to Browser Stack', true, null, @@ -130,7 +130,7 @@ const assertAndroidJobExecuted = (workflowResult, didExecute = true, isProductio } const failProdSteps = [ - utils.getStepAssertion( + utils.createStepAssertion( 'Warn deployers if Android production deploy failed', true, null, @@ -152,7 +152,7 @@ const assertAndroidJobExecuted = (workflowResult, didExecute = true, isProductio const assertDesktopJobExecuted = (workflowResult, didExecute = true, isProduction = true) => { const steps = [ - utils.getStepAssertion( + utils.createStepAssertion( 'Checkout', true, null, @@ -160,14 +160,14 @@ const assertDesktopJobExecuted = (workflowResult, didExecute = true, isProductio 'Checking out', [{key: 'fetch-depth', value: '0'}], ), - utils.getStepAssertion( + utils.createStepAssertion( 'Setup Node', true, null, 'DESKTOP', 'Setting up Node', ), - utils.getStepAssertion( + utils.createStepAssertion( 'Decrypt Developer ID Certificate', true, null, @@ -179,7 +179,7 @@ const assertDesktopJobExecuted = (workflowResult, didExecute = true, isProductio ]; if (isProduction) { steps.push( - utils.getStepAssertion( + utils.createStepAssertion( 'Build production desktop app', true, null, @@ -191,7 +191,7 @@ const assertDesktopJobExecuted = (workflowResult, didExecute = true, isProductio ); } else { steps.push( - utils.getStepAssertion( + utils.createStepAssertion( 'Build staging desktop app', true, null, @@ -214,7 +214,7 @@ const assertDesktopJobExecuted = (workflowResult, didExecute = true, isProductio const assertIOSJobExecuted = (workflowResult, didExecute = true, isProduction = true, isSuccessful = true) => { const steps = [ - utils.getStepAssertion( + utils.createStepAssertion( 'Checkout', true, null, @@ -222,14 +222,14 @@ const assertIOSJobExecuted = (workflowResult, didExecute = true, isProduction = 'Checking out', [{key: 'fetch-depth', value: '0'}], ), - utils.getStepAssertion( + utils.createStepAssertion( 'Setup Node', true, null, 'IOS', 'Setting up Node', ), - utils.getStepAssertion( + utils.createStepAssertion( 'Setup Ruby', true, null, @@ -237,7 +237,7 @@ const assertIOSJobExecuted = (workflowResult, didExecute = true, isProduction = 'Setting up Ruby', [{key: 'ruby-version', value: '2.7'}, {key: 'bundler-cache', value: 'true'}], ), - utils.getStepAssertion( + utils.createStepAssertion( 'Install cocoapods', true, null, @@ -245,7 +245,7 @@ const assertIOSJobExecuted = (workflowResult, didExecute = true, isProduction = 'Installing cocoapods', [{key: 'timeout_minutes', value: '10'}, {key: 'max_attempts', value: '5'}, {key: 'command', value: 'cd ios && pod install'}], ), - utils.getStepAssertion( + utils.createStepAssertion( 'Decrypt profile', true, null, @@ -254,7 +254,7 @@ const assertIOSJobExecuted = (workflowResult, didExecute = true, isProduction = null, [{key: 'LARGE_SECRET_PASSPHRASE', value: '***'}], ), - utils.getStepAssertion( + utils.createStepAssertion( 'Decrypt certificate', true, null, @@ -263,7 +263,7 @@ const assertIOSJobExecuted = (workflowResult, didExecute = true, isProduction = null, [{key: 'LARGE_SECRET_PASSPHRASE', value: '***'}], ), - utils.getStepAssertion( + utils.createStepAssertion( 'Decrypt App Store Connect API key', true, null, @@ -275,7 +275,7 @@ const assertIOSJobExecuted = (workflowResult, didExecute = true, isProduction = ]; if (!isProduction) { steps.push( - utils.getStepAssertion( + utils.createStepAssertion( 'Run Fastlane', true, null, @@ -287,7 +287,7 @@ const assertIOSJobExecuted = (workflowResult, didExecute = true, isProduction = ); } steps.push( - utils.getStepAssertion( + utils.createStepAssertion( 'Archive iOS sourcemaps', true, null, @@ -298,7 +298,7 @@ const assertIOSJobExecuted = (workflowResult, didExecute = true, isProduction = ); if (!isProduction) { steps.push( - utils.getStepAssertion( + utils.createStepAssertion( 'Upload iOS version to Browser Stack', true, null, @@ -310,14 +310,14 @@ const assertIOSJobExecuted = (workflowResult, didExecute = true, isProduction = ); } else { steps.push( - utils.getStepAssertion( + utils.createStepAssertion( 'Set iOS version in ENV', true, null, 'IOS', 'Setting iOS version', ), - utils.getStepAssertion( + utils.createStepAssertion( 'Run Fastlane for App Store release', true, null, @@ -338,7 +338,7 @@ const assertIOSJobExecuted = (workflowResult, didExecute = true, isProduction = } const failProdSteps = [ - utils.getStepAssertion( + utils.createStepAssertion( 'Warn deployers if iOS production deploy failed', true, null, @@ -360,7 +360,7 @@ const assertIOSJobExecuted = (workflowResult, didExecute = true, isProduction = const assertWebJobExecuted = (workflowResult, didExecute = true, isProduction = true) => { const steps = [ - utils.getStepAssertion( + utils.createStepAssertion( 'Checkout', true, null, @@ -368,21 +368,21 @@ const assertWebJobExecuted = (workflowResult, didExecute = true, isProduction = 'Checking out', [{key: 'fetch-depth', value: '0'}], ), - utils.getStepAssertion( + utils.createStepAssertion( 'Setup Node', true, null, 'WEB', 'Setting up Node', ), - utils.getStepAssertion( + utils.createStepAssertion( 'Setup Cloudflare CLI', true, null, 'WEB', 'Setting up Cloudflare CLI', ), - utils.getStepAssertion( + utils.createStepAssertion( 'Configure AWS Credentials', true, null, @@ -393,7 +393,7 @@ const assertWebJobExecuted = (workflowResult, didExecute = true, isProduction = ]; if (isProduction) { steps.push( - utils.getStepAssertion( + utils.createStepAssertion( 'Build web for production', true, null, @@ -403,7 +403,7 @@ const assertWebJobExecuted = (workflowResult, didExecute = true, isProduction = ); } else { steps.push( - utils.getStepAssertion( + utils.createStepAssertion( 'Build web for staging', true, null, @@ -413,7 +413,7 @@ const assertWebJobExecuted = (workflowResult, didExecute = true, isProduction = ); } steps.push( - utils.getStepAssertion( + utils.createStepAssertion( 'Build docs', true, null, @@ -423,14 +423,14 @@ const assertWebJobExecuted = (workflowResult, didExecute = true, isProduction = ); if (isProduction) { steps.push( - utils.getStepAssertion( + utils.createStepAssertion( 'Deploy production to S3', true, null, 'WEB', 'Deploying production to S3', ), - utils.getStepAssertion( + utils.createStepAssertion( 'Purge production Cloudflare cache', true, null, @@ -442,14 +442,14 @@ const assertWebJobExecuted = (workflowResult, didExecute = true, isProduction = ); } else { steps.push( - utils.getStepAssertion( + utils.createStepAssertion( 'Deploy staging to S3', true, null, 'WEB', 'Deploying staging to S3', ), - utils.getStepAssertion( + utils.createStepAssertion( 'Purge staging Cloudflare cache', true, null, @@ -472,7 +472,7 @@ const assertWebJobExecuted = (workflowResult, didExecute = true, isProduction = const assertPostSlackOnFailureJobExecuted = (workflowResult, didExecute = true) => { const steps = [ - utils.getStepAssertion( + utils.createStepAssertion( 'Post Slack message on failure', true, null, @@ -493,21 +493,21 @@ const assertPostSlackOnFailureJobExecuted = (workflowResult, didExecute = true) const assertPostSlackOnSuccessJobExecuted = (workflowResult, didExecute = true, isProduction = true) => { const steps = [ - utils.getStepAssertion( + utils.createStepAssertion( 'Checkout', true, null, 'POST_SLACK_SUCCESS', 'Checking out', ), - utils.getStepAssertion( + utils.createStepAssertion( 'Set version', true, null, 'POST_SLACK_SUCCESS', 'Setting version', ), - utils.getStepAssertion( + utils.createStepAssertion( 'Announces the deploy in the #announce Slack room', true, null, @@ -516,7 +516,7 @@ const assertPostSlackOnSuccessJobExecuted = (workflowResult, didExecute = true, [{key: 'status', value: 'custom'}], [{key: 'GITHUB_TOKEN', value: '***'}, {key: 'SLACK_WEBHOOK_URL', value: '***'}], ), - utils.getStepAssertion( + utils.createStepAssertion( 'Announces the deploy in the #deployer Slack room', true, null, @@ -528,7 +528,7 @@ const assertPostSlackOnSuccessJobExecuted = (workflowResult, didExecute = true, ]; if (isProduction) { steps.push( - utils.getStepAssertion( + utils.createStepAssertion( 'Announces the deploy in the #expensify-open-source Slack room', true, null, @@ -551,7 +551,7 @@ const assertPostSlackOnSuccessJobExecuted = (workflowResult, didExecute = true, const assertPostGithubCommentJobExecuted = (workflowResult, didExecute = true, isProduction = true, didDeploy = true) => { const steps = [ - utils.getStepAssertion( + utils.createStepAssertion( 'Checkout', true, null, @@ -559,21 +559,21 @@ const assertPostGithubCommentJobExecuted = (workflowResult, didExecute = true, i 'Checking out', [{key: 'fetch-depth', value: '0'}], ), - utils.getStepAssertion( + utils.createStepAssertion( 'Setup Node', true, null, 'POST_GITHUB_COMMENT', 'Setting up Node', ), - utils.getStepAssertion( + utils.createStepAssertion( 'Set version', true, null, 'POST_GITHUB_COMMENT', 'Setting version', ), - utils.getStepAssertion( + utils.createStepAssertion( 'Get Release Pull Request List', true, null, @@ -581,7 +581,7 @@ const assertPostGithubCommentJobExecuted = (workflowResult, didExecute = true, i 'Getting release pull request list', [{key: 'TAG', value: '1.2.3'}, {key: 'GITHUB_TOKEN', value: '***'}, {key: 'IS_PRODUCTION_DEPLOY', value: isProduction ? 'true' : 'false'}], ), - utils.getStepAssertion( + utils.createStepAssertion( 'Comment on issues', true, null, diff --git a/workflow_tests/assertions/preDeployAssertions.js b/workflow_tests/assertions/preDeployAssertions.js index 85a51c980215..6fb387d7b4fe 100644 --- a/workflow_tests/assertions/preDeployAssertions.js +++ b/workflow_tests/assertions/preDeployAssertions.js @@ -2,7 +2,7 @@ const utils = require('../utils/utils'); const assertLintJobExecuted = (workflowResult, didExecute = true) => { const steps = [ - utils.getStepAssertion( + utils.createStepAssertion( 'Run lint workflow', true, null, @@ -22,7 +22,7 @@ const assertLintJobExecuted = (workflowResult, didExecute = true) => { const assertTestJobExecuted = (workflowResult, didExecute = true) => { const steps = [ - utils.getStepAssertion( + utils.createStepAssertion( 'Run test workflow', true, null, @@ -42,7 +42,7 @@ const assertTestJobExecuted = (workflowResult, didExecute = true) => { const assertIsExpensifyEmployeeJobExecuted = (workflowResult, didExecute = true) => { const steps = [ - utils.getStepAssertion( + utils.createStepAssertion( 'Get merged pull request', true, null, @@ -50,7 +50,7 @@ const assertIsExpensifyEmployeeJobExecuted = (workflowResult, didExecute = true) 'Getting merged pull request', [{key: 'github_token', value: '***'}], ), - utils.getStepAssertion( + utils.createStepAssertion( 'Check whether the actor is member of Expensify/expensify team', true, null, @@ -71,7 +71,7 @@ const assertIsExpensifyEmployeeJobExecuted = (workflowResult, didExecute = true) const assertNewContributorWelcomeMessageJobExecuted = (workflowResult, didExecute = true, isOsBotify = false, isFirstPr = false) => { const steps = [ - utils.getStepAssertion( + utils.createStepAssertion( 'Checkout', true, null, @@ -79,7 +79,7 @@ const assertNewContributorWelcomeMessageJobExecuted = (workflowResult, didExecut 'Checking out', [{key: 'token', value: '***'}], ), - utils.getStepAssertion( + utils.createStepAssertion( 'Get merged pull request', true, null, @@ -87,7 +87,7 @@ const assertNewContributorWelcomeMessageJobExecuted = (workflowResult, didExecut 'Getting merged pull request', [{key: 'github_token', value: '***'}], ), - utils.getStepAssertion( + utils.createStepAssertion( isOsBotify ? 'Get PR count for OSBotify' : 'Get PR count for Dummy Author', true, null, @@ -98,7 +98,7 @@ const assertNewContributorWelcomeMessageJobExecuted = (workflowResult, didExecut ]; if (isFirstPr) { steps.push( - utils.getStepAssertion( + utils.createStepAssertion( isOsBotify ? 'Comment on OSBotify\\\'s first pull request!' : 'Comment on Dummy Author\\\'s first pull request!', true, null, @@ -120,7 +120,7 @@ const assertNewContributorWelcomeMessageJobExecuted = (workflowResult, didExecut const assertChooseDeployActionsJobExecuted = (workflowResult, didExecute = true) => { const steps = [ - utils.getStepAssertion( + utils.createStepAssertion( 'Get merged pull request', true, null, @@ -128,7 +128,7 @@ const assertChooseDeployActionsJobExecuted = (workflowResult, didExecute = true) 'Getting merged pull request', [{key: 'github_token', value: '***'}], ), - utils.getStepAssertion( + utils.createStepAssertion( 'Check if StagingDeployCash is locked', true, null, @@ -136,17 +136,17 @@ const assertChooseDeployActionsJobExecuted = (workflowResult, didExecute = true) 'Checking StagingDeployCash', [{key: 'GITHUB_TOKEN', value: '***'}], ), - utils.getStepAssertion( + utils.createStepAssertion( 'Check if merged pull request was an automated PR', true, '', ), - utils.getStepAssertion( + utils.createStepAssertion( 'Check if merged pull request has `CP Staging` label', true, '', ), - utils.getStepAssertion( + utils.createStepAssertion( 'Check if merged pull request should trigger a deploy', true, '', @@ -164,7 +164,7 @@ const assertChooseDeployActionsJobExecuted = (workflowResult, didExecute = true) const assertSkipDeployJobExecuted = (workflowResult, didExecute = true) => { const steps = [ - utils.getStepAssertion( + utils.createStepAssertion( 'Comment on deferred PR', true, null, @@ -185,7 +185,7 @@ const assertSkipDeployJobExecuted = (workflowResult, didExecute = true) => { const assertCreateNewVersionJobExecuted = (workflowResult, didExecute = true) => { const steps = [ - utils.getStepAssertion( + utils.createStepAssertion( 'Create new version', true, null, @@ -205,7 +205,7 @@ const assertCreateNewVersionJobExecuted = (workflowResult, didExecute = true) => const assertUpdateStagingJobExecuted = (workflowResult, didExecute = true, shouldCp = false) => { const steps = [ - utils.getStepAssertion( + utils.createStepAssertion( 'Run turnstyle', true, null, @@ -216,7 +216,7 @@ const assertUpdateStagingJobExecuted = (workflowResult, didExecute = true, shoul ]; if (shouldCp) { steps.push( - utils.getStepAssertion( + utils.createStepAssertion( 'Cherry-pick PR to staging', true, null, @@ -227,7 +227,7 @@ const assertUpdateStagingJobExecuted = (workflowResult, didExecute = true, shoul ); } else { steps.push( - utils.getStepAssertion( + utils.createStepAssertion( 'Update staging branch from main', true, null, @@ -238,7 +238,7 @@ const assertUpdateStagingJobExecuted = (workflowResult, didExecute = true, shoul ); } steps.push( - utils.getStepAssertion( + utils.createStepAssertion( 'Checkout staging', true, null, @@ -246,14 +246,14 @@ const assertUpdateStagingJobExecuted = (workflowResult, didExecute = true, shoul 'Checking out staging', [{key: 'ref', value: 'staging'}, {key: 'fetch-depth', value: '0'}], ), - utils.getStepAssertion( + utils.createStepAssertion( 'Tag staging', true, null, 'UPDATE_STAGING', 'Tagging staging', ), - utils.getStepAssertion( + utils.createStepAssertion( 'Update StagingDeployCash', true, null, @@ -261,7 +261,7 @@ const assertUpdateStagingJobExecuted = (workflowResult, didExecute = true, shoul 'Updating StagingDeployCash', [{key: 'GITHUB_TOKEN', value: '***'}, {key: 'NPM_VERSION', value: '1.2.3'}], ), - utils.getStepAssertion( + utils.createStepAssertion( 'Find open StagingDeployCash', true, null, @@ -273,7 +273,7 @@ const assertUpdateStagingJobExecuted = (workflowResult, didExecute = true, shoul ); if (shouldCp) { steps.push( - utils.getStepAssertion( + utils.createStepAssertion( 'Comment in StagingDeployCash to alert Applause that a new pull request has been cherry-picked', true, null, @@ -282,7 +282,7 @@ const assertUpdateStagingJobExecuted = (workflowResult, didExecute = true, shoul null, [{key: 'GITHUB_TOKEN', value: '***'}], ), - utils.getStepAssertion( + utils.createStepAssertion( 'Wait for staging deploys to finish', true, null, @@ -290,7 +290,7 @@ const assertUpdateStagingJobExecuted = (workflowResult, didExecute = true, shoul 'Waiting for staging deploy to finish', [{key: 'GITHUB_TOKEN', value: '***'}, {key: 'TAG', value: '1.2.3'}], ), - utils.getStepAssertion( + utils.createStepAssertion( 'Comment in StagingDeployCash to alert Applause that cherry-picked pull request has been deployed.', true, null, @@ -313,7 +313,7 @@ const assertUpdateStagingJobExecuted = (workflowResult, didExecute = true, shoul const assertUpdateStagingJobFailed = (workflowResult, didFail = false) => { const steps = [ - utils.getStepAssertion( + utils.createStepAssertion( 'Announce failed workflow in Slack', true, null, diff --git a/workflow_tests/assertions/reviewerChecklistAssertions.js b/workflow_tests/assertions/reviewerChecklistAssertions.js index 0453f4654768..a77790724f77 100644 --- a/workflow_tests/assertions/reviewerChecklistAssertions.js +++ b/workflow_tests/assertions/reviewerChecklistAssertions.js @@ -2,7 +2,7 @@ const utils = require('../utils/utils'); const assertChecklistJobExecuted = (workflowResult, didExecute = true) => { const steps = [ - utils.getStepAssertion( + utils.createStepAssertion( 'reviewerChecklist.js', true, null, diff --git a/workflow_tests/assertions/testAssertions.js b/workflow_tests/assertions/testAssertions.js index fd4d350c1374..78c5b9f7509d 100644 --- a/workflow_tests/assertions/testAssertions.js +++ b/workflow_tests/assertions/testAssertions.js @@ -2,7 +2,7 @@ const utils = require('../utils/utils'); const assertJestJobExecuted = (workflowResult, didExecute = true, timesExecuted = 3) => { const steps = [ - utils.getStepAssertion( + utils.createStepAssertion( 'Checkout', true, null, @@ -11,7 +11,7 @@ const assertJestJobExecuted = (workflowResult, didExecute = true, timesExecuted [], [], ), - utils.getStepAssertion( + utils.createStepAssertion( 'Setup Node', true, null, @@ -20,7 +20,7 @@ const assertJestJobExecuted = (workflowResult, didExecute = true, timesExecuted [], [], ), - utils.getStepAssertion( + utils.createStepAssertion( 'Get number of CPU cores', true, null, @@ -29,7 +29,7 @@ const assertJestJobExecuted = (workflowResult, didExecute = true, timesExecuted [], [], ), - utils.getStepAssertion( + utils.createStepAssertion( 'Cache Jest cache', true, null, @@ -38,7 +38,7 @@ const assertJestJobExecuted = (workflowResult, didExecute = true, timesExecuted [{key: 'path', value: '.jest-cache'}, {key: 'key', value: 'Linux-jest'}], [], ), - utils.getStepAssertion( + utils.createStepAssertion( 'Jest tests', true, null, @@ -70,7 +70,7 @@ const assertJestJobExecuted = (workflowResult, didExecute = true, timesExecuted }; const assertShellTestsJobExecuted = (workflowResult, didExecute = true) => { const steps = [ - utils.getStepAssertion( + utils.createStepAssertion( 'Checkout', true, null, @@ -79,7 +79,7 @@ const assertShellTestsJobExecuted = (workflowResult, didExecute = true) => { [], [], ), - utils.getStepAssertion( + utils.createStepAssertion( 'Setup Node', true, null, @@ -88,7 +88,7 @@ const assertShellTestsJobExecuted = (workflowResult, didExecute = true) => { [], [], ), - utils.getStepAssertion( + utils.createStepAssertion( 'getPullRequestsMergedBetween', true, null, diff --git a/workflow_tests/assertions/testBuildAssertions.js b/workflow_tests/assertions/testBuildAssertions.js index 19034740562d..11b73a4863b0 100644 --- a/workflow_tests/assertions/testBuildAssertions.js +++ b/workflow_tests/assertions/testBuildAssertions.js @@ -2,7 +2,7 @@ const utils = require('../utils/utils'); const assertValidateActorJobExecuted = (workflowResult, actor = 'Dummy Actor', pullRequestNumber = '1234', didExecute = true) => { const steps = [ - utils.getStepAssertion( + utils.createStepAssertion( 'Is team member', true, null, @@ -11,7 +11,7 @@ const assertValidateActorJobExecuted = (workflowResult, actor = 'Dummy Actor', p [{key: 'GITHUB_TOKEN', value: '***'}, {key: 'username', value: actor}, {key: 'team', value: 'Expensify/expensify'}], [], ), - utils.getStepAssertion( + utils.createStepAssertion( 'Set HAS_READY_TO_BUILD_LABEL flag', true, null, @@ -32,7 +32,7 @@ const assertValidateActorJobExecuted = (workflowResult, actor = 'Dummy Actor', p }; const assertGetBranchRefJobExecuted = (workflowResult, didExecute = true) => { const steps = [ - utils.getStepAssertion( + utils.createStepAssertion( 'Checkout', true, null, @@ -41,7 +41,7 @@ const assertGetBranchRefJobExecuted = (workflowResult, didExecute = true) => { [], [], ), - utils.getStepAssertion( + utils.createStepAssertion( 'Check if pull request number is correct', true, null, @@ -62,7 +62,7 @@ const assertGetBranchRefJobExecuted = (workflowResult, didExecute = true) => { }; const assertAndroidJobExecuted = (workflowResult, ref = '', didExecute = true, failsAt = -1) => { const steps = [ - utils.getStepAssertion( + utils.createStepAssertion( 'Checkout', true, null, @@ -71,7 +71,7 @@ const assertAndroidJobExecuted = (workflowResult, ref = '', didExecute = true, f [{key: 'ref', value: ref}], [], ), - utils.getStepAssertion( + utils.createStepAssertion( 'Setup Node', true, null, @@ -80,7 +80,7 @@ const assertAndroidJobExecuted = (workflowResult, ref = '', didExecute = true, f [], [], ), - utils.getStepAssertion( + utils.createStepAssertion( 'Setup Ruby', true, null, @@ -89,7 +89,7 @@ const assertAndroidJobExecuted = (workflowResult, ref = '', didExecute = true, f [{key: 'ruby-version', value: '2.7'}, {key: 'bundler-cache', value: true}], [], ), - utils.getStepAssertion( + utils.createStepAssertion( 'Decrypt keystore', true, null, @@ -98,7 +98,7 @@ const assertAndroidJobExecuted = (workflowResult, ref = '', didExecute = true, f [], [{key: 'LARGE_SECRET_PASSPHRASE', value: '***'}], ), - utils.getStepAssertion( + utils.createStepAssertion( 'Decrypt json key', true, null, @@ -107,7 +107,7 @@ const assertAndroidJobExecuted = (workflowResult, ref = '', didExecute = true, f [], [{key: 'LARGE_SECRET_PASSPHRASE', value: '***'}], ), - utils.getStepAssertion( + utils.createStepAssertion( 'Configure AWS Credentials', true, null, @@ -116,7 +116,7 @@ const assertAndroidJobExecuted = (workflowResult, ref = '', didExecute = true, f [{key: 'AWS_ACCESS_KEY_ID', value: '***'}, {key: 'AWS_SECRET_ACCESS_KEY', value: '***'}], [], ), - utils.getStepAssertion( + utils.createStepAssertion( 'Run Fastlane beta test', true, null, @@ -130,7 +130,7 @@ const assertAndroidJobExecuted = (workflowResult, ref = '', didExecute = true, f {key: 'S3_REGION', value: 'us-east-1'}, ], ), - utils.getStepAssertion( + utils.createStepAssertion( 'Upload Artifact', true, null, @@ -161,7 +161,7 @@ const assertAndroidJobExecuted = (workflowResult, ref = '', didExecute = true, f }; const assertIOSJobExecuted = (workflowResult, ref = '', didExecute = true, failsAt = -1) => { const steps = [ - utils.getStepAssertion( + utils.createStepAssertion( 'Checkout', true, null, @@ -170,7 +170,7 @@ const assertIOSJobExecuted = (workflowResult, ref = '', didExecute = true, fails [{key: 'ref', value: ref}], [], ), - utils.getStepAssertion( + utils.createStepAssertion( 'Setup Node', true, null, @@ -179,7 +179,7 @@ const assertIOSJobExecuted = (workflowResult, ref = '', didExecute = true, fails [], [], ), - utils.getStepAssertion( + utils.createStepAssertion( 'Setup Ruby', true, null, @@ -188,7 +188,7 @@ const assertIOSJobExecuted = (workflowResult, ref = '', didExecute = true, fails [{key: 'ruby-version', value: '2.7'}, {key: 'bundler-cache', value: true}], [], ), - utils.getStepAssertion( + utils.createStepAssertion( 'Install cocoapods', true, null, @@ -201,7 +201,7 @@ const assertIOSJobExecuted = (workflowResult, ref = '', didExecute = true, fails ], [], ), - utils.getStepAssertion( + utils.createStepAssertion( 'Decrypt profile', true, null, @@ -210,7 +210,7 @@ const assertIOSJobExecuted = (workflowResult, ref = '', didExecute = true, fails [], [{key: 'LARGE_SECRET_PASSPHRASE', value: '***'}], ), - utils.getStepAssertion( + utils.createStepAssertion( 'Decrypt certificate', true, null, @@ -219,7 +219,7 @@ const assertIOSJobExecuted = (workflowResult, ref = '', didExecute = true, fails [], [{key: 'LARGE_SECRET_PASSPHRASE', value: '***'}], ), - utils.getStepAssertion( + utils.createStepAssertion( 'Configure AWS Credentials', true, null, @@ -228,7 +228,7 @@ const assertIOSJobExecuted = (workflowResult, ref = '', didExecute = true, fails [{key: 'AWS_ACCESS_KEY_ID', value: '***'}, {key: 'AWS_SECRET_ACCESS_KEY', value: '***'}], [], ), - utils.getStepAssertion( + utils.createStepAssertion( 'Run Fastlane', true, null, @@ -242,7 +242,7 @@ const assertIOSJobExecuted = (workflowResult, ref = '', didExecute = true, fails {key: 'S3_REGION', value: 'us-east-1'}, ], ), - utils.getStepAssertion( + utils.createStepAssertion( 'Upload Artifact', true, null, @@ -273,7 +273,7 @@ const assertIOSJobExecuted = (workflowResult, ref = '', didExecute = true, fails }; const assertDesktopJobExecuted = (workflowResult, ref = '', didExecute = true, failsAt = -1) => { const steps = [ - utils.getStepAssertion( + utils.createStepAssertion( 'Checkout', true, null, @@ -282,7 +282,7 @@ const assertDesktopJobExecuted = (workflowResult, ref = '', didExecute = true, f [{key: 'ref', value: ref}, {key: 'fetch-depth', value: '0'}], [], ), - utils.getStepAssertion( + utils.createStepAssertion( 'Setup Node', true, null, @@ -291,7 +291,7 @@ const assertDesktopJobExecuted = (workflowResult, ref = '', didExecute = true, f [], [], ), - utils.getStepAssertion( + utils.createStepAssertion( 'Decrypt Developer ID Certificate', true, null, @@ -300,7 +300,7 @@ const assertDesktopJobExecuted = (workflowResult, ref = '', didExecute = true, f [], [{key: 'DEVELOPER_ID_SECRET_PASSPHRASE', value: '***'}], ), - utils.getStepAssertion( + utils.createStepAssertion( 'Configure AWS Credentials', true, null, @@ -309,7 +309,7 @@ const assertDesktopJobExecuted = (workflowResult, ref = '', didExecute = true, f [{key: 'AWS_ACCESS_KEY_ID', value: '***'}, {key: 'AWS_SECRET_ACCESS_KEY', value: '***'}], [], ), - utils.getStepAssertion( + utils.createStepAssertion( 'Build desktop app for testing', true, null, @@ -347,7 +347,7 @@ const assertDesktopJobExecuted = (workflowResult, ref = '', didExecute = true, f }; const assertWebJobExecuted = (workflowResult, ref = '', didExecute = true, failsAt = -1) => { const steps = [ - utils.getStepAssertion( + utils.createStepAssertion( 'Checkout', true, null, @@ -356,7 +356,7 @@ const assertWebJobExecuted = (workflowResult, ref = '', didExecute = true, fails [{key: 'fetch-depth', value: '0'}, {key: 'ref', value: ref}], [], ), - utils.getStepAssertion( + utils.createStepAssertion( 'Setup Node', true, null, @@ -365,7 +365,7 @@ const assertWebJobExecuted = (workflowResult, ref = '', didExecute = true, fails [], [], ), - utils.getStepAssertion( + utils.createStepAssertion( 'Configure AWS Credentials', true, null, @@ -374,7 +374,7 @@ const assertWebJobExecuted = (workflowResult, ref = '', didExecute = true, fails [{key: 'AWS_ACCESS_KEY_ID', value: '***'}, {key: 'AWS_SECRET_ACCESS_KEY', value: '***'}], [], ), - utils.getStepAssertion( + utils.createStepAssertion( 'Build web for testing', true, null, @@ -383,7 +383,7 @@ const assertWebJobExecuted = (workflowResult, ref = '', didExecute = true, fails [], [], ), - utils.getStepAssertion( + utils.createStepAssertion( 'Build docs', true, null, @@ -392,7 +392,7 @@ const assertWebJobExecuted = (workflowResult, ref = '', didExecute = true, fails [], [], ), - utils.getStepAssertion( + utils.createStepAssertion( 'Deploy to S3 for internal testing', true, null, @@ -423,7 +423,7 @@ const assertWebJobExecuted = (workflowResult, ref = '', didExecute = true, fails }; const assertPostGithubCommentJobExecuted = (workflowResult, ref = '', pullRequestNumber = '1234', didExecute = true, androidStatus = 'success', iOSStatus = 'success', desktopStatus = 'success', webStatus = 'success') => { const steps = [ - utils.getStepAssertion( + utils.createStepAssertion( 'Checkout', true, null, @@ -432,7 +432,7 @@ const assertPostGithubCommentJobExecuted = (workflowResult, ref = '', pullReques [{key: 'ref', value: ref}], [], ), - utils.getStepAssertion( + utils.createStepAssertion( 'Download Artifact', true, null, @@ -444,7 +444,7 @@ const assertPostGithubCommentJobExecuted = (workflowResult, ref = '', pullReques ]; if (androidStatus === 'success') { steps.push( - utils.getStepAssertion( + utils.createStepAssertion( 'Read JSONs with android paths', true, null, @@ -457,7 +457,7 @@ const assertPostGithubCommentJobExecuted = (workflowResult, ref = '', pullReques } if (iOSStatus === 'success') { steps.push( - utils.getStepAssertion( + utils.createStepAssertion( 'Read JSONs with iOS paths', true, null, @@ -469,7 +469,7 @@ const assertPostGithubCommentJobExecuted = (workflowResult, ref = '', pullReques ); } steps.push( - utils.getStepAssertion( + utils.createStepAssertion( 'maintain-comment', true, null, @@ -483,7 +483,7 @@ const assertPostGithubCommentJobExecuted = (workflowResult, ref = '', pullReques ], [], ), - utils.getStepAssertion( + utils.createStepAssertion( 'Publish links to apps for download', true, null, diff --git a/workflow_tests/assertions/validateGithubActionsAssertions.js b/workflow_tests/assertions/validateGithubActionsAssertions.js index c1e6056f6ce9..4bd990f9ac88 100644 --- a/workflow_tests/assertions/validateGithubActionsAssertions.js +++ b/workflow_tests/assertions/validateGithubActionsAssertions.js @@ -2,7 +2,7 @@ const utils = require('../utils/utils'); const assertVerifyJobExecuted = (workflowResult, didExecute = true) => { const steps = [ - utils.getStepAssertion( + utils.createStepAssertion( 'Checkout', true, null, @@ -11,7 +11,7 @@ const assertVerifyJobExecuted = (workflowResult, didExecute = true) => { [{key: 'fetch-depth', value: '0'}], [], ), - utils.getStepAssertion( + utils.createStepAssertion( 'Setup Node', true, null, @@ -20,7 +20,7 @@ const assertVerifyJobExecuted = (workflowResult, didExecute = true) => { [], [], ), - utils.getStepAssertion( + utils.createStepAssertion( 'Verify Javascript Action Builds', true, null, @@ -29,7 +29,7 @@ const assertVerifyJobExecuted = (workflowResult, didExecute = true) => { [], [], ), - utils.getStepAssertion( + utils.createStepAssertion( 'Validate actions and workflows', true, null, diff --git a/workflow_tests/assertions/verifyPodfileAssertions.js b/workflow_tests/assertions/verifyPodfileAssertions.js index 499359d488b3..502c78254661 100644 --- a/workflow_tests/assertions/verifyPodfileAssertions.js +++ b/workflow_tests/assertions/verifyPodfileAssertions.js @@ -2,7 +2,7 @@ const utils = require('../utils/utils'); const assertVerifyJobExecuted = (workflowResult, didExecute = true) => { const steps = [ - utils.getStepAssertion( + utils.createStepAssertion( 'Checkout', true, null, @@ -11,7 +11,7 @@ const assertVerifyJobExecuted = (workflowResult, didExecute = true) => { [{key: 'fetch-depth', value: '0'}], [], ), - utils.getStepAssertion( + utils.createStepAssertion( 'Setup Node', true, null, @@ -20,7 +20,7 @@ const assertVerifyJobExecuted = (workflowResult, didExecute = true) => { [], [], ), - utils.getStepAssertion( + utils.createStepAssertion( 'Verify podfile', true, null, diff --git a/workflow_tests/assertions/verifySignedCommitsAssertions.js b/workflow_tests/assertions/verifySignedCommitsAssertions.js index 3ea2b03e47c7..7ab98a3c1a6b 100644 --- a/workflow_tests/assertions/verifySignedCommitsAssertions.js +++ b/workflow_tests/assertions/verifySignedCommitsAssertions.js @@ -2,7 +2,7 @@ const utils = require('../utils/utils'); const assertVerifySignedCommitsJobExecuted = (workflowResult, didExecute = true) => { const steps = [ - utils.getStepAssertion( + utils.createStepAssertion( 'Verify signed commits', true, null, diff --git a/workflow_tests/assertions/warnCPLabelAssertions.js b/workflow_tests/assertions/warnCPLabelAssertions.js index c15e346d3f76..5b2550e3eb3c 100644 --- a/workflow_tests/assertions/warnCPLabelAssertions.js +++ b/workflow_tests/assertions/warnCPLabelAssertions.js @@ -2,7 +2,7 @@ const utils = require('../utils/utils'); const assertWarnCPLabelJobExecuted = (workflowResult, didExecute = true, isSuccessful = true) => { const steps = [ - utils.getStepAssertion( + utils.createStepAssertion( 'Comment on PR to explain the CP Staging label', true, null, @@ -24,7 +24,7 @@ const assertWarnCPLabelJobExecuted = (workflowResult, didExecute = true, isSucce } const failedSteps = [ - utils.getStepAssertion( + utils.createStepAssertion( 'Announce failed workflow in Slack', true, null, diff --git a/workflow_tests/createNewVersion.test.js b/workflow_tests/createNewVersion.test.js index 5e2c3431c9cf..1db7207816d0 100644 --- a/workflow_tests/createNewVersion.test.js +++ b/workflow_tests/createNewVersion.test.js @@ -157,7 +157,7 @@ describe('test workflow createNewVersion', () => { validateActor: mocks.CREATENEWVERSION__VALIDATEACTOR__ADMIN__STEP_MOCKS, createNewVersion: utils.deepCopy(mocks.CREATENEWVERSION__CREATENEWVERSION__STEP_MOCKS), }; - testMockSteps.createNewVersion[5] = utils.getMockStep( + testMockSteps.createNewVersion[5] = utils.createMockStep( 'Commit new version', 'Commit new version', 'CREATENEWVERSION', diff --git a/workflow_tests/deployBlocker.test.js b/workflow_tests/deployBlocker.test.js index 2b86ed637c4c..dcfc8dbeba6f 100644 --- a/workflow_tests/deployBlocker.test.js +++ b/workflow_tests/deployBlocker.test.js @@ -98,7 +98,7 @@ describe('test workflow deployBlocker', () => { const testMockSteps = { deployBlocker: utils.deepCopy(mocks.DEPLOYBLOCKER__DEPLOYBLOCKER__STEP_MOCKS), }; - testMockSteps.deployBlocker[2] = utils.getMockStep( + testMockSteps.deployBlocker[2] = utils.createMockStep( 'Update StagingDeployCash with new deploy blocker', 'Update StagingDeployCash with new deploy blocker', 'DEPLOYBLOCKER', diff --git a/workflow_tests/finishReleaseCycle.test.js b/workflow_tests/finishReleaseCycle.test.js index b16bd7df918c..1fe4392aea00 100644 --- a/workflow_tests/finishReleaseCycle.test.js +++ b/workflow_tests/finishReleaseCycle.test.js @@ -106,7 +106,7 @@ describe('test workflow finishReleaseCycle', () => { createNewPatchVersion: mocks.FINISHRELEASECYCLE__CREATENEWPATCHVERSION__STEP_MOCKS, createNewStagingDeployCash: mocks.FINISHRELEASECYCLE__CREATENEWSTAGINGDEPLOYCASH__STEP_MOCKS, }; - testMockSteps.createNewStagingDeployCash[2] = utils.getMockStep( + testMockSteps.createNewStagingDeployCash[2] = utils.createMockStep( 'Create new StagingDeployCash', 'Creating new StagingDeployCash', 'CREATENEWSTAGINGDEPLOYCASH', diff --git a/workflow_tests/lockDeploys.test.js b/workflow_tests/lockDeploys.test.js index a48a39e638a8..5a2116a50b6b 100644 --- a/workflow_tests/lockDeploys.test.js +++ b/workflow_tests/lockDeploys.test.js @@ -114,7 +114,7 @@ describe('test workflow lockDeploys', () => { const testMockSteps = { lockStagingDeploys: mocks.LOCKDEPLOYS__LOCKSTAGINGDEPLOYS__STEP_MOCKS, }; - testMockSteps.lockStagingDeploys[1] = utils.getMockStep( + testMockSteps.lockStagingDeploys[1] = utils.createMockStep( 'Wait for staging deploys to finish', 'Waiting for staging deploys to finish', 'LOCKSTAGINGDEPLOYS', diff --git a/workflow_tests/mocks/authorChecklistMocks.js b/workflow_tests/mocks/authorChecklistMocks.js index d27330928012..4c6ae43045ff 100644 --- a/workflow_tests/mocks/authorChecklistMocks.js +++ b/workflow_tests/mocks/authorChecklistMocks.js @@ -1,7 +1,7 @@ const utils = require('../utils/utils'); // checklist -const AUTHORCHECKLIST__CHECKLIST__AUTHORCHECKLIST_JS__STEP_MOCK = utils.getMockStep( +const AUTHORCHECKLIST__CHECKLIST__AUTHORCHECKLIST_JS__STEP_MOCK = utils.createMockStep( 'authorChecklist.js', 'Running authorChecklist.js', 'CHECKLIST', diff --git a/workflow_tests/mocks/cherryPickMocks.js b/workflow_tests/mocks/cherryPickMocks.js index f02000a6f7c0..c2c5db950f0f 100644 --- a/workflow_tests/mocks/cherryPickMocks.js +++ b/workflow_tests/mocks/cherryPickMocks.js @@ -1,7 +1,7 @@ const utils = require('../utils/utils'); // validateactor -const CHERRYPICK__VALIDATEACTOR__CHECK_IF_USER_IS_DEPLOYER_TRUE__STEP_MOCK = utils.getMockStep( +const CHERRYPICK__VALIDATEACTOR__CHECK_IF_USER_IS_DEPLOYER_TRUE__STEP_MOCK = utils.createMockStep( 'Check if user is deployer', 'Checking if user is a deployer', 'VALIDATEACTOR', @@ -9,7 +9,7 @@ const CHERRYPICK__VALIDATEACTOR__CHECK_IF_USER_IS_DEPLOYER_TRUE__STEP_MOCK = uti [], {isTeamMember: true}, ); -const CHERRYPICK__VALIDATEACTOR__CHECK_IF_USER_IS_DEPLOYER_FALSE__STEP_MOCK = utils.getMockStep( +const CHERRYPICK__VALIDATEACTOR__CHECK_IF_USER_IS_DEPLOYER_FALSE__STEP_MOCK = utils.createMockStep( 'Check if user is deployer', 'Checking if user is a deployer', 'VALIDATEACTOR', @@ -25,7 +25,7 @@ const CHERRYPICK__VALIDATEACTOR__FALSE__STEP_MOCKS = [ ]; // createnewversion -const CHERRYPICK__CREATENEWVERSION__CREATE_NEW_VERSION__STEP_MOCK = utils.getMockStep( +const CHERRYPICK__CREATENEWVERSION__CREATE_NEW_VERSION__STEP_MOCK = utils.createMockStep( 'Create new version', 'Creating new version', 'CREATENEWVERSION', @@ -38,28 +38,28 @@ const CHERRYPICK__CREATENEWVERSION__STEP_MOCKS = [ ]; // cherrypick -const CHERRYPICK__CHERRYPICK__CHECKOUT_STAGING_BRANCH__STEP_MOCK = utils.getMockStep( +const CHERRYPICK__CHERRYPICK__CHECKOUT_STAGING_BRANCH__STEP_MOCK = utils.createMockStep( 'Checkout staging branch', 'Checking out staging branch', 'CHERRYPICK', ['ref', 'token'], [], ); -const CHERRYPICK__CHERRYPICK__SET_UP_GIT_FOR_OSBOTIFY__STEP_MOCK = utils.getMockStep( +const CHERRYPICK__CHERRYPICK__SET_UP_GIT_FOR_OSBOTIFY__STEP_MOCK = utils.createMockStep( 'Set up git for OSBotify', 'Setting up git for OSBotify', 'CHERRYPICK', ['GPG_PASSPHRASE'], [], ); -const CHERRYPICK__CHERRYPICK__CREATE_BRANCH_FOR_NEW_PULL_REQUEST__STEP_MOCK = utils.getMockStep( +const CHERRYPICK__CHERRYPICK__CREATE_BRANCH_FOR_NEW_PULL_REQUEST__STEP_MOCK = utils.createMockStep( 'Create branch for new pull request', 'Creating branch for new pull request', 'CHERRYPICK', [], [], ); -const CHERRYPICK__CHERRYPICK__GET_MERGE_COMMIT_FOR_CP_PULL_REQUEST__STEP_MOCK = utils.getMockStep( +const CHERRYPICK__CHERRYPICK__GET_MERGE_COMMIT_FOR_CP_PULL_REQUEST__STEP_MOCK = utils.createMockStep( 'Get merge commit for CP pull request', 'Getting merge commit for CP pull request', 'CHERRYPICK', @@ -67,7 +67,7 @@ const CHERRYPICK__CHERRYPICK__GET_MERGE_COMMIT_FOR_CP_PULL_REQUEST__STEP_MOCK = [], {MERGE_ACTOR: '@dummyauthor'}, ); -const CHERRYPICK__CHERRYPICK__GET_MERGE_COMMIT_FOR_VERSION_BUMP_PULL_REQUEST__STEP_MOCK = utils.getMockStep( +const CHERRYPICK__CHERRYPICK__GET_MERGE_COMMIT_FOR_VERSION_BUMP_PULL_REQUEST__STEP_MOCK = utils.createMockStep( 'Get merge commit for version-bump pull request', 'Getting merge commit for version-bump pull request', 'CHERRYPICK', @@ -75,14 +75,14 @@ const CHERRYPICK__CHERRYPICK__GET_MERGE_COMMIT_FOR_VERSION_BUMP_PULL_REQUEST__ST [], {MERGE_COMMIT_SHA: '0123456789abcdef'}, ); -const CHERRYPICK__CHERRYPICK__CHERRY_PICK_THE_VERSION_BUMP_TO_NEW_BRANCH__STEP_MOCK = utils.getMockStep( +const CHERRYPICK__CHERRYPICK__CHERRY_PICK_THE_VERSION_BUMP_TO_NEW_BRANCH__STEP_MOCK = utils.createMockStep( 'Cherry-pick the version-bump to new branch', 'Cherry-picking the version-bump to new branch', 'CHERRYPICK', [], [], ); -const CHERRYPICK__CHERRYPICK__CHERRY_PICK_THE_MERGE_COMMIT_OF_TARGET_PR_TO_NEW_BRANCH__SHOULD_MERGE__STEP_MOCK = utils.getMockStep( +const CHERRYPICK__CHERRYPICK__CHERRY_PICK_THE_MERGE_COMMIT_OF_TARGET_PR_TO_NEW_BRANCH__SHOULD_MERGE__STEP_MOCK = utils.createMockStep( 'Cherry-pick the merge commit of target PR to new branch', 'Cherry-picking the merge commit of target PR to new branch', 'CHERRYPICK', @@ -91,7 +91,7 @@ const CHERRYPICK__CHERRYPICK__CHERRY_PICK_THE_MERGE_COMMIT_OF_TARGET_PR_TO_NEW_B {SHOULD_AUTOMERGE: true}, ); // eslint-disable-next-line rulesdir/no-negated-variables -const CHERRYPICK__CHERRYPICK__CHERRY_PICK_THE_MERGE_COMMIT_OF_TARGET_PR_TO_NEW_BRANCH__SHOULD_NOT_MERGE__STEP_MOCK = utils.getMockStep( +const CHERRYPICK__CHERRYPICK__CHERRY_PICK_THE_MERGE_COMMIT_OF_TARGET_PR_TO_NEW_BRANCH__SHOULD_NOT_MERGE__STEP_MOCK = utils.createMockStep( 'Cherry-pick the merge commit of target PR to new branch', 'Cherry-picking the merge commit of target PR to new branch', 'CHERRYPICK', @@ -99,14 +99,14 @@ const CHERRYPICK__CHERRYPICK__CHERRY_PICK_THE_MERGE_COMMIT_OF_TARGET_PR_TO_NEW_B [], {SHOULD_AUTOMERGE: false}, ); -const CHERRYPICK__CHERRYPICK__PUSH_CHANGES_TO_CP_BRANCH__STEP_MOCK = utils.getMockStep( +const CHERRYPICK__CHERRYPICK__PUSH_CHANGES_TO_CP_BRANCH__STEP_MOCK = utils.createMockStep( 'Push changes to CP branch', 'Pushing changes to CP branch', 'CHERRYPICK', [], [], ); -const CHERRYPICK__CHERRYPICK__CREATE_PULL_REQUEST__STEP_MOCK = utils.getMockStep( +const CHERRYPICK__CHERRYPICK__CREATE_PULL_REQUEST__STEP_MOCK = utils.createMockStep( 'Create Pull Request', 'Creating Pull Request', 'CHERRYPICK', @@ -114,7 +114,7 @@ const CHERRYPICK__CHERRYPICK__CREATE_PULL_REQUEST__STEP_MOCK = utils.getMockStep ['GITHUB_TOKEN'], {PR_NUMBER: '1234'}, ); -const CHERRYPICK__CHERRYPICK__CHECK_IF_SHORTVERSIONSTRING_IS_UP_TO_DATE_TRUE__STEP_MOCK = utils.getMockStep( +const CHERRYPICK__CHERRYPICK__CHECK_IF_SHORTVERSIONSTRING_IS_UP_TO_DATE_TRUE__STEP_MOCK = utils.createMockStep( 'Check if ShortVersionString is up to date', 'Checking if ShortVersionString is up to date', 'CHERRYPICK', @@ -122,7 +122,7 @@ const CHERRYPICK__CHERRYPICK__CHECK_IF_SHORTVERSIONSTRING_IS_UP_TO_DATE_TRUE__ST [], {BUNDLE_VERSIONS_MATCH: true}, ); -const CHERRYPICK__CHERRYPICK__CHECK_IF_SHORTVERSIONSTRING_IS_UP_TO_DATE_FALSE__STEP_MOCK = utils.getMockStep( +const CHERRYPICK__CHERRYPICK__CHECK_IF_SHORTVERSIONSTRING_IS_UP_TO_DATE_FALSE__STEP_MOCK = utils.createMockStep( 'Check if ShortVersionString is up to date', 'Checking if ShortVersionString is up to date', 'CHERRYPICK', @@ -130,42 +130,42 @@ const CHERRYPICK__CHERRYPICK__CHECK_IF_SHORTVERSIONSTRING_IS_UP_TO_DATE_FALSE__S [], {BUNDLE_VERSIONS_MATCH: false}, ); -const CHERRYPICK__CHERRYPICK__AUTO_ASSIGN_PR_IF_THERE_ARE_MERGE_CONFLICTS_OR_IF_THE_BUNDLE_VERSIONS_ARE_MISMATCHED__STEP_MOCK = utils.getMockStep( +const CHERRYPICK__CHERRYPICK__AUTO_ASSIGN_PR_IF_THERE_ARE_MERGE_CONFLICTS_OR_IF_THE_BUNDLE_VERSIONS_ARE_MISMATCHED__STEP_MOCK = utils.createMockStep( 'Auto-assign PR if there are merge conflicts or if the bundle versions are mismatched', 'Auto-assigning PR', 'CHERRYPICK', [], ['GITHUB_TOKEN'], ); -const CHERRYPICK__CHERRYPICK__ASSIGN_THE_PR_TO_THE_DEPLOYER__STEP_MOCK = utils.getMockStep( +const CHERRYPICK__CHERRYPICK__ASSIGN_THE_PR_TO_THE_DEPLOYER__STEP_MOCK = utils.createMockStep( 'Assign the PR to the deployer', 'Assigning the PR to the deployer', 'CHERRYPICK', [], ['GITHUB_TOKEN'], ); -const CHERRYPICK__CHERRYPICK__IF_PR_HAS_MERGE_CONFLICTS_COMMENT_WITH_INSTRUCTIONS_FOR_ASSIGNEE__STEP_MOCK = utils.getMockStep( +const CHERRYPICK__CHERRYPICK__IF_PR_HAS_MERGE_CONFLICTS_COMMENT_WITH_INSTRUCTIONS_FOR_ASSIGNEE__STEP_MOCK = utils.createMockStep( 'If PR has merge conflicts, comment with instructions for assignee', 'Commenting with instructions for assignee', 'CHERRYPICK', [], ['GITHUB_TOKEN'], ); -const CHERRYPICK__CHERRYPICK__IF_PR_HAS_A_BUNDLE_VERSION_MISMATCH_COMMENT_WITH_THE_INSTRUCTIONS_FOR_ASSIGNEE__STEP_MOCK = utils.getMockStep( +const CHERRYPICK__CHERRYPICK__IF_PR_HAS_A_BUNDLE_VERSION_MISMATCH_COMMENT_WITH_THE_INSTRUCTIONS_FOR_ASSIGNEE__STEP_MOCK = utils.createMockStep( 'If PR has a bundle version mismatch, comment with the instructions for assignee', 'Commenting with the instructions for assignee', 'CHERRYPICK', [], ['GITHUB_TOKEN'], ); -const CHERRYPICK__CHERRYPICK__AUTO_APPROVE_THE_PR__STEP_MOCK = utils.getMockStep( +const CHERRYPICK__CHERRYPICK__AUTO_APPROVE_THE_PR__STEP_MOCK = utils.createMockStep( 'Auto-approve the PR', 'Auto-approving the PR', 'CHERRYPICK', [], ['GITHUB_TOKEN'], ); -const CHERRYPICK__CHERRYPICK__CHECK_IF_PULL_REQUEST_IS_MERGEABLE_TRUE__STEP_MOCK = utils.getMockStep( +const CHERRYPICK__CHERRYPICK__CHECK_IF_PULL_REQUEST_IS_MERGEABLE_TRUE__STEP_MOCK = utils.createMockStep( 'Check if pull request is mergeable', 'Checking if pull request is mergeable', 'CHERRYPICK', @@ -173,7 +173,7 @@ const CHERRYPICK__CHERRYPICK__CHECK_IF_PULL_REQUEST_IS_MERGEABLE_TRUE__STEP_MOCK [], {IS_MERGEABLE: true}, ); -const CHERRYPICK__CHERRYPICK__CHECK_IF_PULL_REQUEST_IS_MERGEABLE_FALSE__STEP_MOCK = utils.getMockStep( +const CHERRYPICK__CHERRYPICK__CHECK_IF_PULL_REQUEST_IS_MERGEABLE_FALSE__STEP_MOCK = utils.createMockStep( 'Check if pull request is mergeable', 'Checking if pull request is mergeable', 'CHERRYPICK', @@ -181,14 +181,14 @@ const CHERRYPICK__CHERRYPICK__CHECK_IF_PULL_REQUEST_IS_MERGEABLE_FALSE__STEP_MOC [], {IS_MERGEABLE: false}, ); -const CHERRYPICK__CHERRYPICK__AUTO_MERGE_THE_PR__STEP_MOCK = utils.getMockStep( +const CHERRYPICK__CHERRYPICK__AUTO_MERGE_THE_PR__STEP_MOCK = utils.createMockStep( 'Auto-merge the PR', 'Auto-merging the PR', 'CHERRYPICK', [], ['GITHUB_TOKEN'], ); -const CHERRYPICK__CHERRYPICK__ANNOUNCES_A_CP_FAILURE_IN_THE_ANNOUNCE_SLACK_ROOM__STEP_MOCK = utils.getMockStep( +const CHERRYPICK__CHERRYPICK__ANNOUNCES_A_CP_FAILURE_IN_THE_ANNOUNCE_SLACK_ROOM__STEP_MOCK = utils.createMockStep( 'Announces a CP failure in the #announce Slack room', 'Announcing a CP failure', 'CHERRYPICK', diff --git a/workflow_tests/mocks/claMocks.js b/workflow_tests/mocks/claMocks.js index 5fbf6ebe629f..115085526c49 100644 --- a/workflow_tests/mocks/claMocks.js +++ b/workflow_tests/mocks/claMocks.js @@ -1,7 +1,7 @@ const utils = require('../utils/utils'); // cla -const CLA__CLA__CLA_COMMENT_CHECK__NO_MATCH__STEP_MOCK = utils.getMockStep( +const CLA__CLA__CLA_COMMENT_CHECK__NO_MATCH__STEP_MOCK = utils.createMockStep( 'CLA comment check', 'CLA comment check', 'CLA', @@ -9,7 +9,7 @@ const CLA__CLA__CLA_COMMENT_CHECK__NO_MATCH__STEP_MOCK = utils.getMockStep( [], {match: ''}, ); -const CLA__CLA__CLA_COMMENT_CHECK__MATCH__STEP_MOCK = utils.getMockStep( +const CLA__CLA__CLA_COMMENT_CHECK__MATCH__STEP_MOCK = utils.createMockStep( 'CLA comment check', 'CLA comment check', 'CLA', @@ -17,7 +17,7 @@ const CLA__CLA__CLA_COMMENT_CHECK__MATCH__STEP_MOCK = utils.getMockStep( [], {match: 'I have read the CLA Document and I hereby sign the CLA'}, ); -const CLA__CLA__CLA_COMMENT_RE_CHECK__NO_MATCH__STEP_MOCK = utils.getMockStep( +const CLA__CLA__CLA_COMMENT_RE_CHECK__NO_MATCH__STEP_MOCK = utils.createMockStep( 'CLA comment re-check', 'CLA comment re-check', 'CLA', @@ -25,7 +25,7 @@ const CLA__CLA__CLA_COMMENT_RE_CHECK__NO_MATCH__STEP_MOCK = utils.getMockStep( [], {match: ''}, ); -const CLA__CLA__CLA_COMMENT_RE_CHECK__MATCH__STEP_MOCK = utils.getMockStep( +const CLA__CLA__CLA_COMMENT_RE_CHECK__MATCH__STEP_MOCK = utils.createMockStep( 'CLA comment re-check', 'CLA comment re-check', 'CLA', @@ -33,7 +33,7 @@ const CLA__CLA__CLA_COMMENT_RE_CHECK__MATCH__STEP_MOCK = utils.getMockStep( [], {match: 'recheck'}, ); -const CLA__CLA__CLA_ASSISTANT__STEP_MOCK = utils.getMockStep( +const CLA__CLA__CLA_ASSISTANT__STEP_MOCK = utils.createMockStep( 'CLA Assistant', 'CLA Assistant', 'CLA', diff --git a/workflow_tests/mocks/createNewVersionMocks.js b/workflow_tests/mocks/createNewVersionMocks.js index 86b3e32c18b7..b69c79d9109d 100644 --- a/workflow_tests/mocks/createNewVersionMocks.js +++ b/workflow_tests/mocks/createNewVersionMocks.js @@ -1,7 +1,7 @@ const utils = require('../utils/utils'); // validateactor -const CREATENEWVERSION__VALIDATEACTOR__GET_USER_PERMISSIONS__ADMIN__STEP_MOCK = utils.getMockStep( +const CREATENEWVERSION__VALIDATEACTOR__GET_USER_PERMISSIONS__ADMIN__STEP_MOCK = utils.createMockStep( 'Get user permissions', 'Get user permissions', 'VALIDATEACTOR', @@ -9,7 +9,7 @@ const CREATENEWVERSION__VALIDATEACTOR__GET_USER_PERMISSIONS__ADMIN__STEP_MOCK = ['GITHUB_TOKEN'], {PERMISSION: 'admin'}, ); -const CREATENEWVERSION__VALIDATEACTOR__GET_USER_PERMISSIONS__WRITE__STEP_MOCK = utils.getMockStep( +const CREATENEWVERSION__VALIDATEACTOR__GET_USER_PERMISSIONS__WRITE__STEP_MOCK = utils.createMockStep( 'Get user permissions', 'Get user permissions', 'VALIDATEACTOR', @@ -17,7 +17,7 @@ const CREATENEWVERSION__VALIDATEACTOR__GET_USER_PERMISSIONS__WRITE__STEP_MOCK = ['GITHUB_TOKEN'], {PERMISSION: 'write'}, ); -const CREATENEWVERSION__VALIDATEACTOR__GET_USER_PERMISSIONS__NONE__STEP_MOCK = utils.getMockStep( +const CREATENEWVERSION__VALIDATEACTOR__GET_USER_PERMISSIONS__NONE__STEP_MOCK = utils.createMockStep( 'Get user permissions', 'Get user permissions', 'VALIDATEACTOR', @@ -36,28 +36,28 @@ const CREATENEWVERSION__VALIDATEACTOR__NO_PERMISSION__STEP_MOCKS = [ ]; // createnewversion -const CREATENEWVERSION__CREATENEWVERSION__CHECK_OUT__STEP_MOCK = utils.getMockStep( +const CREATENEWVERSION__CREATENEWVERSION__CHECK_OUT__STEP_MOCK = utils.createMockStep( 'Check out', 'Check out', 'CREATENEWVERSION', ['fetch-depth'], [], ); -const CREATENEWVERSION__CREATENEWVERSION__SETUP_GIT_FOR_OSBOTIFY__STEP_MOCK = utils.getMockStep( +const CREATENEWVERSION__CREATENEWVERSION__SETUP_GIT_FOR_OSBOTIFY__STEP_MOCK = utils.createMockStep( 'Setup git for OSBotify', 'Setup git for OSBotify', 'CREATENEWVERSION', ['GPG_PASSPHRASE'], [], ); -const CREATENEWVERSION__CREATENEWVERSION__RUN_TURNSTYLE__STEP_MOCK = utils.getMockStep( +const CREATENEWVERSION__CREATENEWVERSION__RUN_TURNSTYLE__STEP_MOCK = utils.createMockStep( 'Run turnstyle', 'Run turnstyle', 'CREATENEWVERSION', ['poll-interval-seconds'], ['GITHUB_TOKEN'], ); -const CREATENEWVERSION__CREATENEWVERSION__CREATE_NEW_BRANCH__STEP_MOCK = utils.getMockStep( +const CREATENEWVERSION__CREATENEWVERSION__CREATE_NEW_BRANCH__STEP_MOCK = utils.createMockStep( 'Create new branch', 'Create new branch', 'CREATENEWVERSION', @@ -66,28 +66,28 @@ const CREATENEWVERSION__CREATENEWVERSION__CREATE_NEW_BRANCH__STEP_MOCK = utils.g [], {VERSION_BRANCH: 'version-${{ github.event.inputs.SEMVER_LEVEL }}-abcdef'}, ); -const CREATENEWVERSION__CREATENEWVERSION__GENERATE_VERSION__STEP_MOCK = utils.getMockStep( +const CREATENEWVERSION__CREATENEWVERSION__GENERATE_VERSION__STEP_MOCK = utils.createMockStep( 'Generate version', 'Generate version', 'CREATENEWVERSION', ['GITHUB_TOKEN', 'SEMVER_LEVEL'], [], ); -const CREATENEWVERSION__CREATENEWVERSION__COMMIT_NEW_VERSION__STEP_MOCK = utils.getMockStep( +const CREATENEWVERSION__CREATENEWVERSION__COMMIT_NEW_VERSION__STEP_MOCK = utils.createMockStep( 'Commit new version', 'Commit new version', 'CREATENEWVERSION', [], [], ); -const CREATENEWVERSION__CREATENEWVERSION__UPDATE_MAIN_BRANCH__STEP_MOCK = utils.getMockStep( +const CREATENEWVERSION__CREATENEWVERSION__UPDATE_MAIN_BRANCH__STEP_MOCK = utils.createMockStep( 'Update main branch', 'Update main branch', 'CREATENEWVERSION', ['TARGET_BRANCH', 'SOURCE_BRANCH', 'OS_BOTIFY_TOKEN', 'GPG_PASSPHRASE'], [], ); -const CREATENEWVERSION__CREATENEWVERSION__ANNOUNCE_FAILED_WORKFLOW_IN_SLACK__STEP_MOCK = utils.getMockStep( +const CREATENEWVERSION__CREATENEWVERSION__ANNOUNCE_FAILED_WORKFLOW_IN_SLACK__STEP_MOCK = utils.createMockStep( 'Announce failed workflow in Slack', 'Announce failed workflow in Slack', 'CREATENEWVERSION', diff --git a/workflow_tests/mocks/deployBlockerMocks.js b/workflow_tests/mocks/deployBlockerMocks.js index 4c8410b70c4d..549a34e2c295 100644 --- a/workflow_tests/mocks/deployBlockerMocks.js +++ b/workflow_tests/mocks/deployBlockerMocks.js @@ -1,14 +1,14 @@ const utils = require('../utils/utils'); // deployblocker -const DEPLOYBLOCKER__DEPLOYBLOCKER__CHECKOUT__STEP_MOCK = utils.getMockStep( +const DEPLOYBLOCKER__DEPLOYBLOCKER__CHECKOUT__STEP_MOCK = utils.createMockStep( 'Checkout', 'Checkout', 'DEPLOYBLOCKER', ['fetch-depth', 'token'], [], ); -const DEPLOYBLOCKER__DEPLOYBLOCKER__GET_URL_TITLE_AND_NUMBER_OF_NEW_DEPLOY_BLOCKER_ISSUE__STEP_MOCK = utils.getMockStep( +const DEPLOYBLOCKER__DEPLOYBLOCKER__GET_URL_TITLE_AND_NUMBER_OF_NEW_DEPLOY_BLOCKER_ISSUE__STEP_MOCK = utils.createMockStep( 'Get URL, title, & number of new deploy blocker (issue)', 'Get URL, title and number of new deploy blocker - issue', 'DEPLOYBLOCKER', @@ -21,35 +21,35 @@ const DEPLOYBLOCKER__DEPLOYBLOCKER__GET_URL_TITLE_AND_NUMBER_OF_NEW_DEPLOY_BLOCK DEPLOY_BLOCKER_TITLE: '${{ github.event.issue.title }}', }, ); -const DEPLOYBLOCKER__DEPLOYBLOCKER__UPDATE_STAGINGDEPLOYCASH_WITH_NEW_DEPLOY_BLOCKER__STEP_MOCK = utils.getMockStep( +const DEPLOYBLOCKER__DEPLOYBLOCKER__UPDATE_STAGINGDEPLOYCASH_WITH_NEW_DEPLOY_BLOCKER__STEP_MOCK = utils.createMockStep( 'Update StagingDeployCash with new deploy blocker', 'Update StagingDeployCash with new deploy blocker', 'DEPLOYBLOCKER', ['GITHUB_TOKEN'], [], ); -const DEPLOYBLOCKER__DEPLOYBLOCKER__GIVE_THE_ISSUE_OR_PR_THE_HOURLY_ENGINEERING_LABELS__STEP_MOCK = utils.getMockStep( +const DEPLOYBLOCKER__DEPLOYBLOCKER__GIVE_THE_ISSUE_OR_PR_THE_HOURLY_ENGINEERING_LABELS__STEP_MOCK = utils.createMockStep( 'Give the issue/PR the Hourly, Engineering labels', 'Give the issue/PR the Hourly, Engineering labels', 'DEPLOYBLOCKER', ['add-labels', 'remove-labels'], [], ); -const DEPLOYBLOCKER__DEPLOYBLOCKER__POST_THE_ISSUE_IN_THE_EXPENSIFY_OPEN_SOURCE_SLACK_ROOM__STEP_MOCK = utils.getMockStep( +const DEPLOYBLOCKER__DEPLOYBLOCKER__POST_THE_ISSUE_IN_THE_EXPENSIFY_OPEN_SOURCE_SLACK_ROOM__STEP_MOCK = utils.createMockStep( 'Post the issue in the #expensify-open-source slack room', 'Post the issue in the expensify-open-source slack room', 'DEPLOYBLOCKER', ['status'], ['GITHUB_TOKEN', 'SLACK_WEBHOOK_URL'], ); -const DEPLOYBLOCKER__DEPLOYBLOCKER__COMMENT_ON_DEFERRED_PR__STEP_MOCK = utils.getMockStep( +const DEPLOYBLOCKER__DEPLOYBLOCKER__COMMENT_ON_DEFERRED_PR__STEP_MOCK = utils.createMockStep( 'Comment on deferred PR', 'Comment on deferred PR', 'DEPLOYBLOCKER', ['github_token', 'number'], [], ); -const DEPLOYBLOCKER__DEPLOYBLOCKER__ANNOUNCE_FAILED_WORKFLOW_IN_SLACK__STEP_MOCK = utils.getMockStep( +const DEPLOYBLOCKER__DEPLOYBLOCKER__ANNOUNCE_FAILED_WORKFLOW_IN_SLACK__STEP_MOCK = utils.createMockStep( 'Announce failed workflow in Slack', 'Announce failed workflow in Slack', 'DEPLOYBLOCKER', diff --git a/workflow_tests/mocks/deployMocks.js b/workflow_tests/mocks/deployMocks.js index 2b71fb1f0b0a..de6e73c3d268 100644 --- a/workflow_tests/mocks/deployMocks.js +++ b/workflow_tests/mocks/deployMocks.js @@ -1,6 +1,6 @@ const utils = require('../utils/utils'); -const VALIDATE__GET_MERGED_PR__STEP_MOCK = utils.getMockStep( +const VALIDATE__GET_MERGED_PR__STEP_MOCK = utils.createMockStep( 'Get merged pull request', 'Getting merged PR', 'VALIDATE', @@ -8,7 +8,7 @@ const VALIDATE__GET_MERGED_PR__STEP_MOCK = utils.getMockStep( [], {author: 'Dummy Author'}, ); -const VALIDATE__GET_MERGED_PR__OSBOTIFY__STEP_MOCK = utils.getMockStep( +const VALIDATE__GET_MERGED_PR__OSBOTIFY__STEP_MOCK = utils.createMockStep( 'Get merged pull request', 'Getting merged PR', 'VALIDATE', @@ -28,24 +28,24 @@ const VALIDATE__OSBOTIFY__STEP_MOCKS = [ // 2nd step normal ]; -const DEPLOY_STAGING__CHECKOUT__STEP_MOCK = utils.getMockStep( +const DEPLOY_STAGING__CHECKOUT__STEP_MOCK = utils.createMockStep( 'Checkout staging branch', 'Checking out staging branch', 'DEPLOY_STAGING', ['ref', 'token'], ); -const DEPLOY_STAGING__SETUP_GIT__STEP_MOCK = utils.getMockStep( +const DEPLOY_STAGING__SETUP_GIT__STEP_MOCK = utils.createMockStep( 'Setup git for OSBotify', 'Setting up git for OSBotify', 'DEPLOY_STAGING', ['GPG_PASSPHRASE'], ); -const DEPLOY_STAGING__TAG_VERSION__STEP_MOCK = utils.getMockStep( +const DEPLOY_STAGING__TAG_VERSION__STEP_MOCK = utils.createMockStep( 'Tag version', 'Tagging new version', 'DEPLOY_STAGING', ); -const DEPLOY_STAGING__PUSH_TAG__STEP_MOCK = utils.getMockStep( +const DEPLOY_STAGING__PUSH_TAG__STEP_MOCK = utils.createMockStep( '🚀 Push tags to trigger staging deploy 🚀', 'Pushing tag to trigger staging deploy', 'DEPLOY_STAGING', @@ -57,24 +57,24 @@ const DEPLOY_STAGING_STEP_MOCKS = [ DEPLOY_STAGING__PUSH_TAG__STEP_MOCK, ]; -const DEPLOY_PRODUCTION__CHECKOUT__STEP_MOCK = utils.getMockStep( +const DEPLOY_PRODUCTION__CHECKOUT__STEP_MOCK = utils.createMockStep( 'Checkout', 'Checking out', 'DEPLOY_PRODUCTION', ['fetch-depth', 'token'], ); -const DEPLOY_PRODUCTION__SETUP_GIT__STEP_MOCK = utils.getMockStep( +const DEPLOY_PRODUCTION__SETUP_GIT__STEP_MOCK = utils.createMockStep( 'Setup git for OSBotify', 'Setting up git for OSBotify', 'DEPLOY_PRODUCTION', ['GPG_PASSPHRASE'], ); -const DEPLOY_PRODUCTION__CHECKOUT_PRODUCTION__STEP_MOCK = utils.getMockStep( +const DEPLOY_PRODUCTION__CHECKOUT_PRODUCTION__STEP_MOCK = utils.createMockStep( 'Checkout production branch', 'Checking out production branch', 'DEPLOY_PRODUCTION', ); -const DEPLOY_PRODUCTION__CURRENT_APP_VERSION__STEP_MOCK = utils.getMockStep( +const DEPLOY_PRODUCTION__CURRENT_APP_VERSION__STEP_MOCK = utils.createMockStep( 'Get current app version', 'Getting current app version', 'DEPLOY_PRODUCTION', @@ -83,7 +83,7 @@ const DEPLOY_PRODUCTION__CURRENT_APP_VERSION__STEP_MOCK = utils.getMockStep( null, {PRODUCTION_VERSION: '1.2.3'}, ); -const DEPLOY_PRODUCTION__RELEASE_PR_LIST__STEP_MOCK = utils.getMockStep( +const DEPLOY_PRODUCTION__RELEASE_PR_LIST__STEP_MOCK = utils.createMockStep( 'Get Release Pull Request List', 'Getting release PR list', 'DEPLOY_PRODUCTION', @@ -91,7 +91,7 @@ const DEPLOY_PRODUCTION__RELEASE_PR_LIST__STEP_MOCK = utils.getMockStep( null, {PR_LIST: '["1.2.1", "1.2.2"]'}, ); -const DEPLOY_PRODUCTION__GENERATE_RELEASE_BODY__STEP_MOCK = utils.getMockStep( +const DEPLOY_PRODUCTION__GENERATE_RELEASE_BODY__STEP_MOCK = utils.createMockStep( 'Generate Release Body', 'Generating release body', 'DEPLOY_PRODUCTION', @@ -99,7 +99,7 @@ const DEPLOY_PRODUCTION__GENERATE_RELEASE_BODY__STEP_MOCK = utils.getMockStep( null, {RELEASE_BODY: 'Release body'}, ); -const DEPLOY_PRODUCTION__CREATE_RELEASE__STEP_MOCK = utils.getMockStep( +const DEPLOY_PRODUCTION__CREATE_RELEASE__STEP_MOCK = utils.createMockStep( '🚀 Create release to trigger production deploy 🚀', 'Creating release to trigger production deploy', 'DEPLOY_PRODUCTION', diff --git a/workflow_tests/mocks/finishReleaseCycleMocks.js b/workflow_tests/mocks/finishReleaseCycleMocks.js index b14f92a7413f..54eb66fa539c 100644 --- a/workflow_tests/mocks/finishReleaseCycleMocks.js +++ b/workflow_tests/mocks/finishReleaseCycleMocks.js @@ -1,7 +1,7 @@ const utils = require('../utils/utils'); // validate -const FINISHRELEASECYCLE__VALIDATE__VALIDATE_ACTOR_IS_DEPLOYER_TRUE__STEP_MOCK = utils.getMockStep( +const FINISHRELEASECYCLE__VALIDATE__VALIDATE_ACTOR_IS_DEPLOYER_TRUE__STEP_MOCK = utils.createMockStep( 'Validate actor is deployer', 'Validating if actor is deployer', 'VALIDATE', @@ -9,7 +9,7 @@ const FINISHRELEASECYCLE__VALIDATE__VALIDATE_ACTOR_IS_DEPLOYER_TRUE__STEP_MOCK = [], {isTeamMember: true}, ); -const FINISHRELEASECYCLE__VALIDATE__VALIDATE_ACTOR_IS_DEPLOYER_FALSE__STEP_MOCK = utils.getMockStep( +const FINISHRELEASECYCLE__VALIDATE__VALIDATE_ACTOR_IS_DEPLOYER_FALSE__STEP_MOCK = utils.createMockStep( 'Validate actor is deployer', 'Validating if actor is deployer', 'VALIDATE', @@ -18,14 +18,14 @@ const FINISHRELEASECYCLE__VALIDATE__VALIDATE_ACTOR_IS_DEPLOYER_FALSE__STEP_MOCK {isTeamMember: false}, ); // eslint-disable-next-line rulesdir/no-negated-variables -const FINISHRELEASECYCLE__VALIDATE__REOPEN_AND_COMMENT_ON_ISSUE_NOT_A_TEAM_MEMBER__STEP_MOCK = utils.getMockStep( +const FINISHRELEASECYCLE__VALIDATE__REOPEN_AND_COMMENT_ON_ISSUE_NOT_A_TEAM_MEMBER__STEP_MOCK = utils.createMockStep( 'Reopen and comment on issue (not a team member)', 'Reopening issue - not a team member', 'VALIDATE', ['GITHUB_TOKEN', 'ISSUE_NUMBER', 'COMMENT'], [], ); -const FINISHRELEASECYCLE__VALIDATE__CHECK_FOR_ANY_DEPLOY_BLOCKERS_FALSE__STEP_MOCK = utils.getMockStep( +const FINISHRELEASECYCLE__VALIDATE__CHECK_FOR_ANY_DEPLOY_BLOCKERS_FALSE__STEP_MOCK = utils.createMockStep( 'Check for any deploy blockers', 'Checking for deploy blockers', 'VALIDATE', @@ -33,7 +33,7 @@ const FINISHRELEASECYCLE__VALIDATE__CHECK_FOR_ANY_DEPLOY_BLOCKERS_FALSE__STEP_MO [], {HAS_DEPLOY_BLOCKERS: false}, ); -const FINISHRELEASECYCLE__VALIDATE__CHECK_FOR_ANY_DEPLOY_BLOCKERS_TRUE__STEP_MOCK = utils.getMockStep( +const FINISHRELEASECYCLE__VALIDATE__CHECK_FOR_ANY_DEPLOY_BLOCKERS_TRUE__STEP_MOCK = utils.createMockStep( 'Check for any deploy blockers', 'Checking for deploy blockers', 'VALIDATE', @@ -41,7 +41,7 @@ const FINISHRELEASECYCLE__VALIDATE__CHECK_FOR_ANY_DEPLOY_BLOCKERS_TRUE__STEP_MOC [], {HAS_DEPLOY_BLOCKERS: true}, ); -const FINISHRELEASECYCLE__VALIDATE__REOPEN_AND_COMMENT_ON_ISSUE_HAS_BLOCKERS__STEP_MOCK = utils.getMockStep( +const FINISHRELEASECYCLE__VALIDATE__REOPEN_AND_COMMENT_ON_ISSUE_HAS_BLOCKERS__STEP_MOCK = utils.createMockStep( 'Reopen and comment on issue (has blockers)', 'Reopening issue - blockers', 'VALIDATE', @@ -76,7 +76,7 @@ const FINISHRELEASECYCLE__VALIDATE__NOT_TEAM_MEMBER_BLOCKERS__STEP_MOCKS = [ ]; // updateproduction -const FINISHRELEASECYCLE__UPDATEPRODUCTION__UPDATE_PRODUCTION_BRANCH__STEP_MOCK = utils.getMockStep( +const FINISHRELEASECYCLE__UPDATEPRODUCTION__UPDATE_PRODUCTION_BRANCH__STEP_MOCK = utils.createMockStep( 'Update production branch', 'Updating production branch', 'UPDATEPRODUCTION', @@ -88,7 +88,7 @@ const FINISHRELEASECYCLE__UPDATEPRODUCTION__STEP_MOCKS = [ ]; // createnewpatchversion -const FINISHRELEASECYCLE__CREATENEWPATCHVERSION__CREATE_NEW_VERSION__STEP_MOCK = utils.getMockStep( +const FINISHRELEASECYCLE__CREATENEWPATCHVERSION__CREATE_NEW_VERSION__STEP_MOCK = utils.createMockStep( 'Create new version', 'Creating new version', 'CREATENEWPATCHVERSION', @@ -101,28 +101,28 @@ const FINISHRELEASECYCLE__CREATENEWPATCHVERSION__STEP_MOCKS = [ ]; // createnewstagingdeploycash -const FINISHRELEASECYCLE__CREATENEWSTAGINGDEPLOYCASH__UPDATE_STAGING_BRANCH_TO_TRIGGER_STAGING_DEPLOY__STEP_MOCK = utils.getMockStep( +const FINISHRELEASECYCLE__CREATENEWSTAGINGDEPLOYCASH__UPDATE_STAGING_BRANCH_TO_TRIGGER_STAGING_DEPLOY__STEP_MOCK = utils.createMockStep( 'Update staging branch to trigger staging deploy', 'Updating staging branch', 'CREATENEWSTAGINGDEPLOYCASH', ['TARGET_BRANCH', 'OS_BOTIFY_TOKEN', 'GPG_PASSPHRASE'], [], ); -const FINISHRELEASECYCLE__CREATENEWSTAGINGDEPLOYCASH__TAG_VERSION__STEP_MOCK = utils.getMockStep( +const FINISHRELEASECYCLE__CREATENEWSTAGINGDEPLOYCASH__TAG_VERSION__STEP_MOCK = utils.createMockStep( 'Tag version', 'Tagging version', 'CREATENEWSTAGINGDEPLOYCASH', [], [], ); -const FINISHRELEASECYCLE__CREATENEWSTAGINGDEPLOYCASH__CREATE_NEW_STAGINGDEPLOYCASH__STEP_MOCK = utils.getMockStep( +const FINISHRELEASECYCLE__CREATENEWSTAGINGDEPLOYCASH__CREATE_NEW_STAGINGDEPLOYCASH__STEP_MOCK = utils.createMockStep( 'Create new StagingDeployCash', 'Creating new StagingDeployCash', 'CREATENEWSTAGINGDEPLOYCASH', ['GITHUB_TOKEN', 'NPM_VERSION'], [], ); -const FINISHRELEASECYCLE__CREATENEWSTAGINGDEPLOYCASH__ANNOUNCE_FAILED_WORKFLOW_IN_SLACK__STEP_MOCK = utils.getMockStep( +const FINISHRELEASECYCLE__CREATENEWSTAGINGDEPLOYCASH__ANNOUNCE_FAILED_WORKFLOW_IN_SLACK__STEP_MOCK = utils.createMockStep( 'Announce failed workflow in Slack', 'Announcing failed workflow', 'CREATENEWSTAGINGDEPLOYCASH', diff --git a/workflow_tests/mocks/lintMocks.js b/workflow_tests/mocks/lintMocks.js index de2da8394e5f..2349c3ef4f03 100644 --- a/workflow_tests/mocks/lintMocks.js +++ b/workflow_tests/mocks/lintMocks.js @@ -1,28 +1,28 @@ const utils = require('../utils/utils'); // lint -const LINT__LINT__CHECKOUT__STEP_MOCK = utils.getMockStep( +const LINT__LINT__CHECKOUT__STEP_MOCK = utils.createMockStep( 'Checkout', 'Checkout', 'LINT', [], [], ); -const LINT__LINT__SETUP_NODE__STEP_MOCK = utils.getMockStep( +const LINT__LINT__SETUP_NODE__STEP_MOCK = utils.createMockStep( 'Setup Node', 'Setup Node', 'LINT', [], [], ); -const LINT__LINT__LINT_JAVASCRIPT_WITH_ESLINT__STEP_MOCK = utils.getMockStep( +const LINT__LINT__LINT_JAVASCRIPT_WITH_ESLINT__STEP_MOCK = utils.createMockStep( 'Lint JavaScript with ESLint', 'Lint JavaScript with ESLint', 'LINT', [], ['CI'], ); -const LINT__LINT__LINT_SHELL_SCRIPTS_WITH_SHELLCHECK__STEP_MOCK = utils.getMockStep( +const LINT__LINT__LINT_SHELL_SCRIPTS_WITH_SHELLCHECK__STEP_MOCK = utils.createMockStep( 'Lint shell scripts with ShellCheck', 'Lint shell scripts with ShellCheck', 'LINT', diff --git a/workflow_tests/mocks/lockDeploysMocks.js b/workflow_tests/mocks/lockDeploysMocks.js index 629406695a8e..09d44e92a21a 100644 --- a/workflow_tests/mocks/lockDeploysMocks.js +++ b/workflow_tests/mocks/lockDeploysMocks.js @@ -1,28 +1,28 @@ const utils = require('../utils/utils'); // lockstagingdeploys -const LOCKDEPLOYS__LOCKSTAGINGDEPLOYS__CHECKOUT__STEP_MOCK = utils.getMockStep( +const LOCKDEPLOYS__LOCKSTAGINGDEPLOYS__CHECKOUT__STEP_MOCK = utils.createMockStep( 'Checkout', 'Checking out', 'LOCKSTAGINGDEPLOYS', ['ref', 'fetch-depth', 'token'], [], ); -const LOCKDEPLOYS__LOCKSTAGINGDEPLOYS__WAIT_FOR_STAGING_DEPLOYS_TO_FINISH__STEP_MOCK = utils.getMockStep( +const LOCKDEPLOYS__LOCKSTAGINGDEPLOYS__WAIT_FOR_STAGING_DEPLOYS_TO_FINISH__STEP_MOCK = utils.createMockStep( 'Wait for staging deploys to finish', 'Waiting for staging deploys to finish', 'LOCKSTAGINGDEPLOYS', ['GITHUB_TOKEN'], [], ); -const LOCKDEPLOYS__LOCKSTAGINGDEPLOYS__COMMENT_IN_STAGINGDEPLOYCASH_TO_GIVE_APPLAUSE_THE_GREEN_LIGHT_TO_BEGIN_QA__STEP_MOCK = utils.getMockStep( +const LOCKDEPLOYS__LOCKSTAGINGDEPLOYS__COMMENT_IN_STAGINGDEPLOYCASH_TO_GIVE_APPLAUSE_THE_GREEN_LIGHT_TO_BEGIN_QA__STEP_MOCK = utils.createMockStep( 'Comment in StagingDeployCash to give Applause the 🟢 to begin QA', 'Commenting in StagingDeployCash', 'LOCKSTAGINGDEPLOYS', [], ['GITHUB_TOKEN'], ); -const LOCKDEPLOYS__LOCKSTAGINGDEPLOYS__ANNOUNCE_FAILED_WORKFLOW__STEP_MOCK = utils.getMockStep( +const LOCKDEPLOYS__LOCKSTAGINGDEPLOYS__ANNOUNCE_FAILED_WORKFLOW__STEP_MOCK = utils.createMockStep( 'Announce failed workflow', 'Announcing failed workflow in Slack', 'LOCKSTAGINGDEPLOYS', diff --git a/workflow_tests/mocks/platformDeployMocks.js b/workflow_tests/mocks/platformDeployMocks.js index bb7304338665..e03e91e5ee01 100644 --- a/workflow_tests/mocks/platformDeployMocks.js +++ b/workflow_tests/mocks/platformDeployMocks.js @@ -1,7 +1,7 @@ const utils = require('../utils/utils'); // validateActor -const PLATFORM_DEPLOY__VALIDATE_ACTOR__CHECK_USER_DEPLOYER__TEAM_MEMBER__STEP_MOCK = utils.getMockStep( +const PLATFORM_DEPLOY__VALIDATE_ACTOR__CHECK_USER_DEPLOYER__TEAM_MEMBER__STEP_MOCK = utils.createMockStep( 'Check if user is deployer', 'Checking if the user is a deployer', 'VALIDATE_ACTOR', @@ -9,7 +9,7 @@ const PLATFORM_DEPLOY__VALIDATE_ACTOR__CHECK_USER_DEPLOYER__TEAM_MEMBER__STEP_MO null, {isTeamMember: true}, ); -const PLATFORM_DEPLOY__VALIDATE_ACTOR__CHECK_USER_DEPLOYER__OUTSIDER__STEP_MOCK = utils.getMockStep( +const PLATFORM_DEPLOY__VALIDATE_ACTOR__CHECK_USER_DEPLOYER__OUTSIDER__STEP_MOCK = utils.createMockStep( 'Check if user is deployer', 'Checking if the user is a deployer', 'VALIDATE_ACTOR', @@ -25,38 +25,38 @@ const PLATFORM_DEPLOY__VALIDATE_ACTOR__OUTSIDER__STEP_MOCKS = [ ]; // android -const PLATFORM_DEPLOY__ANDROID__CHECKOUT__STEP_MOCK = utils.getMockStep( +const PLATFORM_DEPLOY__ANDROID__CHECKOUT__STEP_MOCK = utils.createMockStep( 'Checkout', 'Checking out', 'ANDROID', ['fetch-depth'], ); -const PLATFORM_DEPLOY__ANDROID__SETUP_NODE__STEP_MOCK = utils.getMockStep( +const PLATFORM_DEPLOY__ANDROID__SETUP_NODE__STEP_MOCK = utils.createMockStep( 'Setup Node', 'Setting up Node', 'ANDROID', ); -const PLATFORM_DEPLOY__ANDROID__SETUP_RUBY__STEP_MOCK = utils.getMockStep( +const PLATFORM_DEPLOY__ANDROID__SETUP_RUBY__STEP_MOCK = utils.createMockStep( 'Setup Ruby', 'Setting up Ruby', 'ANDROID', ['ruby-version', 'bundler-cache'], ); -const PLATFORM_DEPLOY__ANDROID__DECRYPT_KEYSTORE__STEP_MOCK = utils.getMockStep( +const PLATFORM_DEPLOY__ANDROID__DECRYPT_KEYSTORE__STEP_MOCK = utils.createMockStep( 'Decrypt keystore', 'Decrypting keystore', 'ANDROID', null, ['LARGE_SECRET_PASSPHRASE'], ); -const PLATFORM_DEPLOY__ANDROID__DECRYPT_JSON_KEY__STEP_MOCK = utils.getMockStep( +const PLATFORM_DEPLOY__ANDROID__DECRYPT_JSON_KEY__STEP_MOCK = utils.createMockStep( 'Decrypt json key', 'Decrypting JSON key', 'ANDROID', null, ['LARGE_SECRET_PASSPHRASE'], ); -const PLATFORM_DEPLOY__ANDROID__SET_VERSION__STEP_MOCK = utils.getMockStep( +const PLATFORM_DEPLOY__ANDROID__SET_VERSION__STEP_MOCK = utils.createMockStep( 'Set version in ENV', 'Setting version in ENV', 'ANDROID', @@ -65,34 +65,34 @@ const PLATFORM_DEPLOY__ANDROID__SET_VERSION__STEP_MOCK = utils.getMockStep( null, {VERSION_CODE: '1.2.3'}, ); -const PLATFORM_DEPLOY__ANDROID__FASTLANE_BETA__STEP_MOCK = utils.getMockStep( +const PLATFORM_DEPLOY__ANDROID__FASTLANE_BETA__STEP_MOCK = utils.createMockStep( 'Run Fastlane beta', 'Running Fastlane beta', 'ANDROID', null, ['MYAPP_UPLOAD_STORE_PASSWORD', 'MYAPP_UPLOAD_KEY_PASSWORD'], ); -const PLATFORM_DEPLOY__ANDROID__FASTLANE_PRODUCTION__STEP_MOCK = utils.getMockStep( +const PLATFORM_DEPLOY__ANDROID__FASTLANE_PRODUCTION__STEP_MOCK = utils.createMockStep( 'Run Fastlane production', 'Running Fastlane production', 'ANDROID', null, ['VERSION'], ); -const PLATFORM_DEPLOY__ANDROID__ARCHIVE_SOURCEMAPS__STEP_MOCK = utils.getMockStep( +const PLATFORM_DEPLOY__ANDROID__ARCHIVE_SOURCEMAPS__STEP_MOCK = utils.createMockStep( 'Archive Android sourcemaps', 'Archiving Android sourcemaps', 'ANDROID', ['name', 'path'], ); -const PLATFORM_DEPLOY__ANDROID__UPLOAD_TO_BROWSER_STACK__STEP_MOCK = utils.getMockStep( +const PLATFORM_DEPLOY__ANDROID__UPLOAD_TO_BROWSER_STACK__STEP_MOCK = utils.createMockStep( 'Upload Android version to Browser Stack', 'Uploading Android version to Browser Stack', 'ANDROID', null, ['BROWSERSTACK'], ); -const PLATFORM_DEPLOY__ANDROID__WARN_DEPLOYERS__STEP_MOCK = utils.getMockStep( +const PLATFORM_DEPLOY__ANDROID__WARN_DEPLOYERS__STEP_MOCK = utils.createMockStep( 'Warn deployers if Android production deploy failed', 'Warning deployers of failed production deploy', 'ANDROID', @@ -114,32 +114,32 @@ const PLATFORM_DEPLOY__ANDROID__STEP_MOCKS = [ ]; // desktop -const PLATFORM_DEPLOY__DESKTOP__CHECKOUT__STEP_MOCK = utils.getMockStep( +const PLATFORM_DEPLOY__DESKTOP__CHECKOUT__STEP_MOCK = utils.createMockStep( 'Checkout', 'Checking out', 'DESKTOP', ['fetch-depth'], ); -const PLATFORM_DEPLOY__DESKTOP__SETUP_NODE__STEP_MOCK = utils.getMockStep( +const PLATFORM_DEPLOY__DESKTOP__SETUP_NODE__STEP_MOCK = utils.createMockStep( 'Setup Node', 'Setting up Node', 'DESKTOP', ); -const PLATFORM_DEPLOY__DESKTOP__DECRYPT_ID__STEP_MOCK = utils.getMockStep( +const PLATFORM_DEPLOY__DESKTOP__DECRYPT_ID__STEP_MOCK = utils.createMockStep( 'Decrypt Developer ID Certificate', 'Decrypting developer id certificate', 'DESKTOP', null, ['DEVELOPER_ID_SECRET_PASSPHRASE'], ); -const PLATFORM_DEPLOY__DESKTOP__BUILD_PRODUCTION__STEP_MOCK = utils.getMockStep( +const PLATFORM_DEPLOY__DESKTOP__BUILD_PRODUCTION__STEP_MOCK = utils.createMockStep( 'Build production desktop app', 'Building production desktop app', 'DESKTOP', null, ['CSC_LINK', 'CSC_KEY_PASSWORD', 'APPLE_ID', 'APPLE_ID_PASSWORD', 'AWS_ACCESS_KEY_ID', 'AWS_SECRET_ACCESS_KEY'], ); -const PLATFORM_DEPLOY__DESKTOP__BUILD_STAGING__STEP_MOCK = utils.getMockStep( +const PLATFORM_DEPLOY__DESKTOP__BUILD_STAGING__STEP_MOCK = utils.createMockStep( 'Build staging desktop app', 'Building staging desktop app', 'DESKTOP', @@ -155,71 +155,71 @@ const PLATFORM_DEPLOY__DESKTOP__STEP_MOCKS = [ ]; // ios -const PLATFORM_DEPLOY__IOS__CHECKOUT__STEP_MOCK = utils.getMockStep( +const PLATFORM_DEPLOY__IOS__CHECKOUT__STEP_MOCK = utils.createMockStep( 'Checkout', 'Checking out', 'IOS', ['fetch-depth'], ); -const PLATFORM_DEPLOY__IOS__SETUP_NODE__STEP_MOCK = utils.getMockStep( +const PLATFORM_DEPLOY__IOS__SETUP_NODE__STEP_MOCK = utils.createMockStep( 'Setup Node', 'Setting up Node', 'IOS', ); -const PLATFORM_DEPLOY__IOS__SETUP_RUBY__STEP_MOCK = utils.getMockStep( +const PLATFORM_DEPLOY__IOS__SETUP_RUBY__STEP_MOCK = utils.createMockStep( 'Setup Ruby', 'Setting up Ruby', 'IOS', ['ruby-version', 'bundler-cache'], ); -const PLATFORM_DEPLOY__IOS__COCOAPODS__STEP_MOCK = utils.getMockStep( +const PLATFORM_DEPLOY__IOS__COCOAPODS__STEP_MOCK = utils.createMockStep( 'Install cocoapods', 'Installing cocoapods', 'IOS', ['timeout_minutes', 'max_attempts', 'command'], ); -const PLATFORM_DEPLOY__IOS__DECRYPT_PROFILE__STEP_MOCK = utils.getMockStep( +const PLATFORM_DEPLOY__IOS__DECRYPT_PROFILE__STEP_MOCK = utils.createMockStep( 'Decrypt profile', 'Decrypting profile', 'IOS', null, ['LARGE_SECRET_PASSPHRASE'], ); -const PLATFORM_DEPLOY__IOS__DECRYPT_CERTIFICATE__STEP_MOCK = utils.getMockStep( +const PLATFORM_DEPLOY__IOS__DECRYPT_CERTIFICATE__STEP_MOCK = utils.createMockStep( 'Decrypt certificate', 'Decrypting certificate', 'IOS', null, ['LARGE_SECRET_PASSPHRASE'], ); -const PLATFORM_DEPLOY__IOS__DECRYPT_APP_STORE_API_KEY__STEP_MOCK = utils.getMockStep( +const PLATFORM_DEPLOY__IOS__DECRYPT_APP_STORE_API_KEY__STEP_MOCK = utils.createMockStep( 'Decrypt App Store Connect API key', 'Decrypting App Store API key', 'IOS', null, ['LARGE_SECRET_PASSPHRASE'], ); -const PLATFORM_DEPLOY__IOS__FASTLANE__STEP_MOCK = utils.getMockStep( +const PLATFORM_DEPLOY__IOS__FASTLANE__STEP_MOCK = utils.createMockStep( 'Run Fastlane', 'Running Fastlane', 'IOS', null, ['APPLE_CONTACT_EMAIL', 'APPLE_CONTACT_PHONE', 'APPLE_DEMO_EMAIL', 'APPLE_DEMO_PASSWORD'], ); -const PLATFORM_DEPLOY__IOS__ARCHIVE_SOURCEMAPS__STEP_MOCK = utils.getMockStep( +const PLATFORM_DEPLOY__IOS__ARCHIVE_SOURCEMAPS__STEP_MOCK = utils.createMockStep( 'Archive iOS sourcemaps', 'Archiving sourcemaps', 'IOS', ['name', 'path'], ); -const PLATFORM_DEPLOY__IOS__UPLOAD_BROWSERSTACK__STEP_MOCK = utils.getMockStep( +const PLATFORM_DEPLOY__IOS__UPLOAD_BROWSERSTACK__STEP_MOCK = utils.createMockStep( 'Upload iOS version to Browser Stack', 'Uploading version to Browser Stack', 'IOS', null, ['BROWSERSTACK'], ); -const PLATFORM_DEPLOY__IOS__SET_VERSION__STEP_MOCK = utils.getMockStep( +const PLATFORM_DEPLOY__IOS__SET_VERSION__STEP_MOCK = utils.createMockStep( 'Set iOS version in ENV', 'Setting iOS version', 'IOS', @@ -228,14 +228,14 @@ const PLATFORM_DEPLOY__IOS__SET_VERSION__STEP_MOCK = utils.getMockStep( null, {IOS_VERSION: '1.2.3'}, ); -const PLATFORM_DEPLOY__IOS__RELEASE_FASTLANE__STEP_MOCK = utils.getMockStep( +const PLATFORM_DEPLOY__IOS__RELEASE_FASTLANE__STEP_MOCK = utils.createMockStep( 'Run Fastlane for App Store release', 'Running Fastlane for release', 'IOS', null, ['VERSION'], ); -const PLATFORM_DEPLOY__IOS__WARN_FAIL__STEP_MOCK = utils.getMockStep( +const PLATFORM_DEPLOY__IOS__WARN_FAIL__STEP_MOCK = utils.createMockStep( 'Warn deployers if iOS production deploy failed', 'Warning developers of failed deploy', 'IOS', @@ -259,61 +259,61 @@ const PLATFORM_DEPLOY__IOS__STEP_MOCKS = [ ]; // web -const PLATFORM_DEPLOY__WEB__CHECKOUT__STEP_MOCK = utils.getMockStep( +const PLATFORM_DEPLOY__WEB__CHECKOUT__STEP_MOCK = utils.createMockStep( 'Checkout', 'Checking out', 'WEB', ['fetch-depth'], ); -const PLATFORM_DEPLOY__WEB__SETUP_NODE__STEP_MOCK = utils.getMockStep( +const PLATFORM_DEPLOY__WEB__SETUP_NODE__STEP_MOCK = utils.createMockStep( 'Setup Node', 'Setting up Node', 'WEB', ); -const PLATFORM_DEPLOY__WEB__CLOUDFLARE__STEP_MOCK = utils.getMockStep( +const PLATFORM_DEPLOY__WEB__CLOUDFLARE__STEP_MOCK = utils.createMockStep( 'Setup Cloudflare CLI', 'Setting up Cloudflare CLI', 'WEB', ); -const PLATFORM_DEPLOY__WEB__AWS_CREDENTIALS__STEP_MOCK = utils.getMockStep( +const PLATFORM_DEPLOY__WEB__AWS_CREDENTIALS__STEP_MOCK = utils.createMockStep( 'Configure AWS Credentials', 'Configuring AWS credentials', 'WEB', ['AWS_ACCESS_KEY_ID', 'AWS_SECRET_ACCESS_KEY'], ); -const PLATFORM_DEPLOY__WEB__BUILD_PRODUCTION__STEP_MOCK = utils.getMockStep( +const PLATFORM_DEPLOY__WEB__BUILD_PRODUCTION__STEP_MOCK = utils.createMockStep( 'Build web for production', 'Building web for production', 'WEB', ); -const PLATFORM_DEPLOY__WEB__BUILD_STAGING__STEP_MOCK = utils.getMockStep( +const PLATFORM_DEPLOY__WEB__BUILD_STAGING__STEP_MOCK = utils.createMockStep( 'Build web for staging', 'Building web for staging', 'WEB', ); -const PLATFORM_DEPLOY__WEB__BUILD_DOCS__STEP_MOCK = utils.getMockStep( +const PLATFORM_DEPLOY__WEB__BUILD_DOCS__STEP_MOCK = utils.createMockStep( 'Build docs', 'Building docs', 'WEB', ); -const PLATFORM_DEPLOY__WEB__DEPLOY_PRODUCTION_S3__STEP_MOCK = utils.getMockStep( +const PLATFORM_DEPLOY__WEB__DEPLOY_PRODUCTION_S3__STEP_MOCK = utils.createMockStep( 'Deploy production to S3', 'Deploying production to S3', 'WEB', ); -const PLATFORM_DEPLOY__WEB__DEPLOY_STAGING_S3__STEP_MOCK = utils.getMockStep( +const PLATFORM_DEPLOY__WEB__DEPLOY_STAGING_S3__STEP_MOCK = utils.createMockStep( 'Deploy staging to S3', 'Deploying staging to S3', 'WEB', ); -const PLATFORM_DEPLOY__WEB__PURGE_PRODUCTION_CACHE__STEP_MOCK = utils.getMockStep( +const PLATFORM_DEPLOY__WEB__PURGE_PRODUCTION_CACHE__STEP_MOCK = utils.createMockStep( 'Purge production Cloudflare cache', 'Purging production Cloudflare cache', 'WEB', null, ['CF_API_KEY'], ); -const PLATFORM_DEPLOY__WEB__PURGE_STAGING_CACHE__STEP_MOCK = utils.getMockStep( +const PLATFORM_DEPLOY__WEB__PURGE_STAGING_CACHE__STEP_MOCK = utils.createMockStep( 'Purge staging Cloudflare cache', 'Purging staging Cloudflare cache', 'WEB', @@ -335,7 +335,7 @@ const PLATFORM_DEPLOY__WEB__STEP_MOCKS = [ ]; // post slack message on failure -const PLATFORM_DEPLOY__POST_SLACK_FAIL__POST_SLACK__STEP_MOCK = utils.getMockStep( +const PLATFORM_DEPLOY__POST_SLACK_FAIL__POST_SLACK__STEP_MOCK = utils.createMockStep( 'Post Slack message on failure', 'Posting Slack message on platform deploy failure', 'POST_SLACK_FAIL', @@ -346,12 +346,12 @@ const PLATFORM_DEPLOY__POST_SLACK_FAIL__STEP_MOCKS = [ ]; // post slack message on success -const PLATFORM_DEPLOY__POST_SLACK_SUCCESS__CHECKOUT__STEP_MOCK = utils.getMockStep( +const PLATFORM_DEPLOY__POST_SLACK_SUCCESS__CHECKOUT__STEP_MOCK = utils.createMockStep( 'Checkout', 'Checking out', 'POST_SLACK_SUCCESS', ); -const PLATFORM_DEPLOY__POST_SLACK_SUCCESS__SET_VERSION__STEP_MOCK = utils.getMockStep( +const PLATFORM_DEPLOY__POST_SLACK_SUCCESS__SET_VERSION__STEP_MOCK = utils.createMockStep( 'Set version', 'Setting version', 'POST_SLACK_SUCCESS', @@ -360,21 +360,21 @@ const PLATFORM_DEPLOY__POST_SLACK_SUCCESS__SET_VERSION__STEP_MOCK = utils.getMoc null, {VERSION: '1.2.3'}, ); -const PLATFORM_DEPLOY__POST_SLACK_SUCCESS__ANNOUNCE_CHANNEL__STEP_MOCK = utils.getMockStep( +const PLATFORM_DEPLOY__POST_SLACK_SUCCESS__ANNOUNCE_CHANNEL__STEP_MOCK = utils.createMockStep( 'Announces the deploy in the #announce Slack room', 'Posting message to \\#announce channel', 'POST_SLACK_SUCCESS', ['status'], ['GITHUB_TOKEN', 'SLACK_WEBHOOK_URL'], ); -const PLATFORM_DEPLOY__POST_SLACK_SUCCESS__DEPLOYER_CHANNEL__STEP_MOCK = utils.getMockStep( +const PLATFORM_DEPLOY__POST_SLACK_SUCCESS__DEPLOYER_CHANNEL__STEP_MOCK = utils.createMockStep( 'Announces the deploy in the #deployer Slack room', 'Posting message to \\#deployer channel', 'POST_SLACK_SUCCESS', ['status'], ['GITHUB_TOKEN', 'SLACK_WEBHOOK_URL'], ); -const PLATFORM_DEPLOY__POST_SLACK_SUCCESS__EXPENSIFY_CHANNEL__STEP_MOCK = utils.getMockStep( +const PLATFORM_DEPLOY__POST_SLACK_SUCCESS__EXPENSIFY_CHANNEL__STEP_MOCK = utils.createMockStep( 'Announces a production deploy in the #expensify-open-source Slack room', 'Posting message to \\#expensify-open-source channel', 'POST_SLACK_SUCCESS', @@ -390,18 +390,18 @@ const PLATFORM_DEPLOY__POST_SLACK_SUCCESS__STEP_MOCKS = [ ]; // post github comment -const PLATFORM_DEPLOY__POST_GIHUB_COMMENT__CHECKOUT__STEP_MOCK = utils.getMockStep( +const PLATFORM_DEPLOY__POST_GIHUB_COMMENT__CHECKOUT__STEP_MOCK = utils.createMockStep( 'Checkout', 'Checking out', 'POST_GITHUB_COMMENT', ['fetch-depth'], ); -const PLATFORM_DEPLOY__POST_GIHUB_COMMENT__SETUP_NODE__STEP_MOCK = utils.getMockStep( +const PLATFORM_DEPLOY__POST_GIHUB_COMMENT__SETUP_NODE__STEP_MOCK = utils.createMockStep( 'Setup Node', 'Setting up Node', 'POST_GITHUB_COMMENT', ); -const PLATFORM_DEPLOY__POST_GIHUB_COMMENT__SET_VERSION__STEP_MOCK = utils.getMockStep( +const PLATFORM_DEPLOY__POST_GIHUB_COMMENT__SET_VERSION__STEP_MOCK = utils.createMockStep( 'Set version', 'Setting version', 'POST_GITHUB_COMMENT', @@ -410,7 +410,7 @@ const PLATFORM_DEPLOY__POST_GIHUB_COMMENT__SET_VERSION__STEP_MOCK = utils.getMoc null, {VERSION: '1.2.3'}, ); -const PLATFORM_DEPLOY__POST_GIHUB_COMMENT__GET_PR_LIST__STEP_MOCK = utils.getMockStep( +const PLATFORM_DEPLOY__POST_GIHUB_COMMENT__GET_PR_LIST__STEP_MOCK = utils.createMockStep( 'Get Release Pull Request List', 'Getting release pull request list', 'POST_GITHUB_COMMENT', @@ -418,7 +418,7 @@ const PLATFORM_DEPLOY__POST_GIHUB_COMMENT__GET_PR_LIST__STEP_MOCK = utils.getMoc null, {PR_LIST: '[1.2.1, 1.2.2]'}, ); -const PLATFORM_DEPLOY__POST_GIHUB_COMMENT__COMMENT__STEP_MOCK = utils.getMockStep( +const PLATFORM_DEPLOY__POST_GIHUB_COMMENT__COMMENT__STEP_MOCK = utils.createMockStep( 'Comment on issues', 'Commenting on issues', 'POST_GITHUB_COMMENT', diff --git a/workflow_tests/mocks/preDeployMocks.js b/workflow_tests/mocks/preDeployMocks.js index fefa7a20313f..66c8eda9c336 100644 --- a/workflow_tests/mocks/preDeployMocks.js +++ b/workflow_tests/mocks/preDeployMocks.js @@ -1,7 +1,7 @@ const utils = require('../utils/utils'); // lint -const LINT_WORKFLOW_MOCK_STEP = utils.getMockStep( +const LINT_WORKFLOW_MOCK_STEP = utils.createMockStep( 'Run lint workflow', 'Running lint workflow', 'LINT', @@ -11,7 +11,7 @@ const LINT_JOB_MOCK_STEPS = [ ]; // test -const TEST_WORKFLOW_MOCK_STEP = utils.getMockStep( +const TEST_WORKFLOW_MOCK_STEP = utils.createMockStep( 'Run test workflow', 'Running test workflow', 'TEST', @@ -21,7 +21,7 @@ const TEST_JOB_MOCK_STEPS = [ ]; // confirm_passing_build -const ANNOUNCE_IN_SLACK_MOCK_STEP = utils.getMockStep( +const ANNOUNCE_IN_SLACK_MOCK_STEP = utils.createMockStep( 'Announce failed workflow in Slack', 'Announcing failed workflow in slack', 'CONFIRM_PASSING_BUILD', @@ -34,7 +34,7 @@ const CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS = [ ]; // choose_deploy_actions -const GET_MERGED_PULL_REQUEST_MOCK_STEP__CHOOSE_DEPLOY__CP_LABEL = utils.getMockStep( +const GET_MERGED_PULL_REQUEST_MOCK_STEP__CHOOSE_DEPLOY__CP_LABEL = utils.createMockStep( 'Get merged pull request', 'Getting merged pull request', 'CHOOSE_DEPLOY_ACTIONS', @@ -42,7 +42,7 @@ const GET_MERGED_PULL_REQUEST_MOCK_STEP__CHOOSE_DEPLOY__CP_LABEL = utils.getMock null, {number: '123', labels: '[\'CP Staging\']'}, ); -const GET_MERGED_PULL_REQUEST_MOCK_STEP__CHOOSE_DEPLOY = utils.getMockStep( +const GET_MERGED_PULL_REQUEST_MOCK_STEP__CHOOSE_DEPLOY = utils.createMockStep( 'Get merged pull request', 'Getting merged pull request', 'CHOOSE_DEPLOY_ACTIONS', @@ -50,7 +50,7 @@ const GET_MERGED_PULL_REQUEST_MOCK_STEP__CHOOSE_DEPLOY = utils.getMockStep( null, {number: '123', labels: '[]'}, ); -const CHECK_IF_STAGINGDEPLOYCASH_IS_LOCKED_MOCK_STEP__LOCKED = utils.getMockStep( +const CHECK_IF_STAGINGDEPLOYCASH_IS_LOCKED_MOCK_STEP__LOCKED = utils.createMockStep( 'Check if StagingDeployCash is locked', 'Checking StagingDeployCash', 'CHOOSE_DEPLOY_ACTIONS', @@ -58,7 +58,7 @@ const CHECK_IF_STAGINGDEPLOYCASH_IS_LOCKED_MOCK_STEP__LOCKED = utils.getMockStep null, {IS_LOCKED: true}, ); -const CHECK_IF_STAGINGDEPLOYCASH_IS_LOCKED_MOCK_STEP__UNLOCKED = utils.getMockStep( +const CHECK_IF_STAGINGDEPLOYCASH_IS_LOCKED_MOCK_STEP__UNLOCKED = utils.createMockStep( 'Check if StagingDeployCash is locked', 'Checking StagingDeployCash', 'CHOOSE_DEPLOY_ACTIONS', @@ -92,7 +92,7 @@ const CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__CP_LABEL__STAGING_UNLOCKED = [ ]; // skip_deploy -const COMMENT_ON_DEFERRED_PR_MOCK_STEP = utils.getMockStep( +const COMMENT_ON_DEFERRED_PR_MOCK_STEP = utils.createMockStep( 'Comment on deferred PR', 'Skipping deploy', 'SKIP_DEPLOY', @@ -103,7 +103,7 @@ const SKIP_DEPLOY_JOB_MOCK_STEPS = [ ]; // create_new_version -const CREATE_NEW_VERSION_MOCK_STEP = utils.getMockStep( +const CREATE_NEW_VERSION_MOCK_STEP = utils.createMockStep( 'Create new version', 'Creating new version', 'CREATE_NEW_VERSION', @@ -116,43 +116,43 @@ const CREATE_NEW_VERSION_JOB_MOCK_STEPS = [ ]; // update_staging -const RUN_TURNSTYLE_MOCK_STEP = utils.getMockStep( +const RUN_TURNSTYLE_MOCK_STEP = utils.createMockStep( 'Run turnstyle', 'Running turnstyle', 'UPDATE_STAGING', ['poll-interval-seconds'], ['GITHUB_TOKEN'], ); -const UPDATE_STAGING_BRANCH_MOCK_STEP = utils.getMockStep( +const UPDATE_STAGING_BRANCH_MOCK_STEP = utils.createMockStep( 'Update staging branch from main', 'Updating staging branch', 'UPDATE_STAGING', ['TARGET_BRANCH', 'OS_BOTIFY_TOKEN', 'GPG_PASSPHRASE'], ); -const CHERRYPICK_PR_MOCK_STEP = utils.getMockStep( +const CHERRYPICK_PR_MOCK_STEP = utils.createMockStep( 'Cherry-pick PR to staging', 'Cherry picking', 'UPDATE_STAGING', ['GITHUB_TOKEN', 'WORKFLOW', 'INPUTS'], ); -const CHECKOUT_STAGING_MOCK_STEP = utils.getMockStep( +const CHECKOUT_STAGING_MOCK_STEP = utils.createMockStep( 'Checkout staging', 'Checking out staging', 'UPDATE_STAGING', ['ref', 'fetch-depth'], ); -const TAG_STAGING_MOCK_STEP = utils.getMockStep( +const TAG_STAGING_MOCK_STEP = utils.createMockStep( 'Tag staging', 'Tagging staging', 'UPDATE_STAGING', ); -const UPDATE_STAGINGDEPLOYCASH_MOCK_STEP = utils.getMockStep( +const UPDATE_STAGINGDEPLOYCASH_MOCK_STEP = utils.createMockStep( 'Update StagingDeployCash', 'Updating StagingDeployCash', 'UPDATE_STAGING', ['GITHUB_TOKEN', 'NPM_VERSION'], ); -const FIND_OPEN_STAGINGDEPLOYCASH_MOCK_STEP = utils.getMockStep( +const FIND_OPEN_STAGINGDEPLOYCASH_MOCK_STEP = utils.createMockStep( 'Find open StagingDeployCash', 'Finding open StagingDeployCash', 'UPDATE_STAGING', @@ -160,27 +160,27 @@ const FIND_OPEN_STAGINGDEPLOYCASH_MOCK_STEP = utils.getMockStep( ['GITHUB_TOKEN'], {STAGING_DEPLOY_CASH: '1234'}, ); -const COMMENT_TO_ALERT_APPLAUSE_CHERRYPICK_MOCK_STEP = utils.getMockStep( +const COMMENT_TO_ALERT_APPLAUSE_CHERRYPICK_MOCK_STEP = utils.createMockStep( 'Comment in StagingDeployCash to alert Applause that a new pull request has been cherry-picked', 'Commenting in StagingDeployCash', 'UPDATE_STAGING', null, ['GITHUB_TOKEN'], ); -const WAIT_FOR_STAGING_DEPLOYS_MOCK_STEP = utils.getMockStep( +const WAIT_FOR_STAGING_DEPLOYS_MOCK_STEP = utils.createMockStep( 'Wait for staging deploys to finish', 'Waiting for staging deploy to finish', 'UPDATE_STAGING', ['GITHUB_TOKEN', 'TAG'], ); -const COMMENT_TO_ALERT_APPLAUSE_DEPLOY_MOCK_STEP = utils.getMockStep( +const COMMENT_TO_ALERT_APPLAUSE_DEPLOY_MOCK_STEP = utils.createMockStep( 'Comment in StagingDeployCash to alert Applause that cherry-picked pull request has been deployed.', 'Commenting in StagingDeployCash', 'UPDATE_STAGING', null, ['GITHUB_TOKEN'], ); -const ANNOUNCE_FAILED_WORKFLOW_IN_SLACK_MOCK_STEP = utils.getMockStep( +const ANNOUNCE_FAILED_WORKFLOW_IN_SLACK_MOCK_STEP = utils.createMockStep( 'Announce failed workflow in Slack', 'Announcing failed workflow in Slack', 'UPDATE_STAGING', @@ -201,7 +201,7 @@ const UPDATE_STAGING_JOB_MOCK_STEPS = [ ]; // is_expensify_employee -const GET_MERGED_PULL_REQUEST_MOCK_STEP__IS_EXPENSIFY_EMPLOYEE = utils.getMockStep( +const GET_MERGED_PULL_REQUEST_MOCK_STEP__IS_EXPENSIFY_EMPLOYEE = utils.createMockStep( 'Get merged pull request', 'Getting merged pull request', 'IS_EXPENSIFY_EMPLOYEE', @@ -209,7 +209,7 @@ const GET_MERGED_PULL_REQUEST_MOCK_STEP__IS_EXPENSIFY_EMPLOYEE = utils.getMockSt null, {author: 'Dummy Author'}, ); -const CHECK_TEAM_MEMBERSHIP_MOCK_STEP__TRUE = utils.getMockStep( +const CHECK_TEAM_MEMBERSHIP_MOCK_STEP__TRUE = utils.createMockStep( 'Check whether the actor is member of Expensify/expensify team', 'Checking actors Expensify membership', 'IS_EXPENSIFY_EMPLOYEE', @@ -221,7 +221,7 @@ const IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE = [ GET_MERGED_PULL_REQUEST_MOCK_STEP__IS_EXPENSIFY_EMPLOYEE, CHECK_TEAM_MEMBERSHIP_MOCK_STEP__TRUE, ]; -const CHECK_TEAM_MEMBERSHIP_MOCK_STEP__FALSE = utils.getMockStep( +const CHECK_TEAM_MEMBERSHIP_MOCK_STEP__FALSE = utils.createMockStep( 'Check whether the actor is member of Expensify/expensify team', 'Checking actors Expensify membership', 'IS_EXPENSIFY_EMPLOYEE', @@ -235,7 +235,7 @@ const IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__FALSE = [ ]; // new_contributor_welcome_message -const CHECKOUT_MOCK_STEP = utils.getMockStep( +const CHECKOUT_MOCK_STEP = utils.createMockStep( 'Checkout', 'Checking out', 'NEW_CONTRIBUTOR_WELCOME_MESSAGE', @@ -243,7 +243,7 @@ const CHECKOUT_MOCK_STEP = utils.getMockStep( null, {author: 'Dummy Author'}, ); -const CHECKOUT_MOCK_STEP__OSBOTIFY = utils.getMockStep( +const CHECKOUT_MOCK_STEP__OSBOTIFY = utils.createMockStep( 'Checkout', 'Checking out', 'NEW_CONTRIBUTOR_WELCOME_MESSAGE', @@ -251,7 +251,7 @@ const CHECKOUT_MOCK_STEP__OSBOTIFY = utils.getMockStep( null, {author: 'OSBotify'}, ); -const GET_MERGED_PULL_REQUEST_MOCK_STEP__WELCOME_MESSAGE = utils.getMockStep( +const GET_MERGED_PULL_REQUEST_MOCK_STEP__WELCOME_MESSAGE = utils.createMockStep( 'Get merged pull request', 'Getting merged pull request', 'NEW_CONTRIBUTOR_WELCOME_MESSAGE', @@ -259,7 +259,7 @@ const GET_MERGED_PULL_REQUEST_MOCK_STEP__WELCOME_MESSAGE = utils.getMockStep( null, {number: '12345', author: 'Dummy Author'}, ); -const GET_MERGED_PULL_REQUEST_MOCK_STEP__WELCOME_MESSAGE__OSBOTIFY = utils.getMockStep( +const GET_MERGED_PULL_REQUEST_MOCK_STEP__WELCOME_MESSAGE__OSBOTIFY = utils.createMockStep( 'Get merged pull request', 'Getting merged pull request', 'NEW_CONTRIBUTOR_WELCOME_MESSAGE', @@ -267,7 +267,7 @@ const GET_MERGED_PULL_REQUEST_MOCK_STEP__WELCOME_MESSAGE__OSBOTIFY = utils.getMo null, {number: '12345', author: 'OSBotify'}, ); -const GET_PR_COUNT_MOCK_STEP__1 = utils.getMockStep( +const GET_PR_COUNT_MOCK_STEP__1 = utils.createMockStep( 'Get PR count for ${{ steps.getMergedPullRequest.outputs.author }}', 'Getting PR count', 'NEW_CONTRIBUTOR_WELCOME_MESSAGE', @@ -276,7 +276,7 @@ const GET_PR_COUNT_MOCK_STEP__1 = utils.getMockStep( null, {PR_COUNT: '1'}, ); -const GET_PR_COUNT_MOCK_STEP__10 = utils.getMockStep( +const GET_PR_COUNT_MOCK_STEP__10 = utils.createMockStep( 'Get PR count for ${{ steps.getMergedPullRequest.outputs.author }}', 'Getting PR count', 'NEW_CONTRIBUTOR_WELCOME_MESSAGE', @@ -285,7 +285,7 @@ const GET_PR_COUNT_MOCK_STEP__10 = utils.getMockStep( null, {PR_COUNT: '10'}, ); -const COMMENT_ON_FIRST_PULL_REQUEST_MOCK_STEP = utils.getMockStep( +const COMMENT_ON_FIRST_PULL_REQUEST_MOCK_STEP = utils.createMockStep( 'Comment on ${{ steps.getMergedPullRequest.outputs.author }}\\\'s first pull request!', 'Creating comment', 'NEW_CONTRIBUTOR_WELCOME_MESSAGE', @@ -310,7 +310,7 @@ const NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__OSBOTIFY = [ COMMENT_ON_FIRST_PULL_REQUEST_MOCK_STEP, ]; -const PREDEPLOY__E2EPERFORMANCETESTS__PERFORM_E2E_TESTS__MOCK_STEP = utils.getMockStep( +const PREDEPLOY__E2EPERFORMANCETESTS__PERFORM_E2E_TESTS__MOCK_STEP = utils.createMockStep( 'Perform E2E tests', 'Perform E2E tests', 'E2EPERFORMANCETESTS', diff --git a/workflow_tests/mocks/reviewerChecklistMocks.js b/workflow_tests/mocks/reviewerChecklistMocks.js index bf82791646f4..4315d2fdb1ae 100644 --- a/workflow_tests/mocks/reviewerChecklistMocks.js +++ b/workflow_tests/mocks/reviewerChecklistMocks.js @@ -1,7 +1,7 @@ const utils = require('../utils/utils'); // checklist -const REVIEWERCHECKLIST__CHECKLIST__REVIEWERCHECKLIST_JS__STEP_MOCK = utils.getMockStep( +const REVIEWERCHECKLIST__CHECKLIST__REVIEWERCHECKLIST_JS__STEP_MOCK = utils.createMockStep( 'reviewerChecklist.js', 'reviewerChecklist.js', 'CHECKLIST', diff --git a/workflow_tests/mocks/testBuildMocks.js b/workflow_tests/mocks/testBuildMocks.js index b63c35cff452..5c934716a772 100644 --- a/workflow_tests/mocks/testBuildMocks.js +++ b/workflow_tests/mocks/testBuildMocks.js @@ -1,7 +1,7 @@ const utils = require('../utils/utils'); // validateactor -const TESTBUILD__VALIDATEACTOR__IS_TEAM_MEMBER__TRUE__STEP_MOCK = utils.getMockStep( +const TESTBUILD__VALIDATEACTOR__IS_TEAM_MEMBER__TRUE__STEP_MOCK = utils.createMockStep( 'Is team member', 'Is team member', 'VALIDATEACTOR', @@ -9,7 +9,7 @@ const TESTBUILD__VALIDATEACTOR__IS_TEAM_MEMBER__TRUE__STEP_MOCK = utils.getMockS [], {isTeamMember: true}, ); -const TESTBUILD__VALIDATEACTOR__IS_TEAM_MEMBER__FALSE__STEP_MOCK = utils.getMockStep( +const TESTBUILD__VALIDATEACTOR__IS_TEAM_MEMBER__FALSE__STEP_MOCK = utils.createMockStep( 'Is team member', 'Is team member', 'VALIDATEACTOR', @@ -17,7 +17,7 @@ const TESTBUILD__VALIDATEACTOR__IS_TEAM_MEMBER__FALSE__STEP_MOCK = utils.getMock [], {isTeamMember: false}, ); -const TESTBUILD__VALIDATEACTOR__SET_HAS_READY_TO_BUILD_LABEL_FLAG__TRUE__STEP_MOCK = utils.getMockStep( +const TESTBUILD__VALIDATEACTOR__SET_HAS_READY_TO_BUILD_LABEL_FLAG__TRUE__STEP_MOCK = utils.createMockStep( 'Set HAS_READY_TO_BUILD_LABEL flag', 'Set HAS_READY_TO_BUILD_LABEL flag', 'VALIDATEACTOR', @@ -25,7 +25,7 @@ const TESTBUILD__VALIDATEACTOR__SET_HAS_READY_TO_BUILD_LABEL_FLAG__TRUE__STEP_MO ['PULL_REQUEST_NUMBER', 'GITHUB_TOKEN'], {HAS_READY_TO_BUILD_LABEL: true}, ); -const TESTBUILD__VALIDATEACTOR__SET_HAS_READY_TO_BUILD_LABEL_FLAG__FALSE__STEP_MOCK = utils.getMockStep( +const TESTBUILD__VALIDATEACTOR__SET_HAS_READY_TO_BUILD_LABEL_FLAG__FALSE__STEP_MOCK = utils.createMockStep( 'Set HAS_READY_TO_BUILD_LABEL flag', 'Set HAS_READY_TO_BUILD_LABEL flag', 'VALIDATEACTOR', @@ -51,14 +51,14 @@ const TESTBUILD__VALIDATEACTOR__NO_TEAM_MEMBER_NO_FLAG__STEP_MOCKS = [ ]; // getbranchref -const TESTBUILD__GETBRANCHREF__CHECKOUT__STEP_MOCK = utils.getMockStep( +const TESTBUILD__GETBRANCHREF__CHECKOUT__STEP_MOCK = utils.createMockStep( 'Checkout', 'Checkout', 'GETBRANCHREF', [], [], ); -const TESTBUILD__GETBRANCHREF__CHECK_IF_PULL_REQUEST_NUMBER_IS_CORRECT__STEP_MOCK = utils.getMockStep( +const TESTBUILD__GETBRANCHREF__CHECK_IF_PULL_REQUEST_NUMBER_IS_CORRECT__STEP_MOCK = utils.createMockStep( 'Check if pull request number is correct', 'Check if pull request number is correct', 'GETBRANCHREF', @@ -72,56 +72,56 @@ const TESTBUILD__GETBRANCHREF__STEP_MOCKS = [ ]; // android -const TESTBUILD__ANDROID__CHECKOUT__STEP_MOCK = utils.getMockStep( +const TESTBUILD__ANDROID__CHECKOUT__STEP_MOCK = utils.createMockStep( 'Checkout', 'Checkout', 'ANDROID', ['ref'], [], ); -const TESTBUILD__ANDROID__SETUP_NODE__STEP_MOCK = utils.getMockStep( +const TESTBUILD__ANDROID__SETUP_NODE__STEP_MOCK = utils.createMockStep( 'Setup Node', 'Setup Node', 'ANDROID', [], [], ); -const TESTBUILD__ANDROID__SETUP_RUBY__STEP_MOCK = utils.getMockStep( +const TESTBUILD__ANDROID__SETUP_RUBY__STEP_MOCK = utils.createMockStep( 'Setup Ruby', 'Setup Ruby', 'ANDROID', ['ruby-version', 'bundler-cache'], [], ); -const TESTBUILD__ANDROID__DECRYPT_KEYSTORE__STEP_MOCK = utils.getMockStep( +const TESTBUILD__ANDROID__DECRYPT_KEYSTORE__STEP_MOCK = utils.createMockStep( 'Decrypt keystore', 'Decrypt keystore', 'ANDROID', [], ['LARGE_SECRET_PASSPHRASE'], ); -const TESTBUILD__ANDROID__DECRYPT_JSON_KEY__STEP_MOCK = utils.getMockStep( +const TESTBUILD__ANDROID__DECRYPT_JSON_KEY__STEP_MOCK = utils.createMockStep( 'Decrypt json key', 'Decrypt json key', 'ANDROID', [], ['LARGE_SECRET_PASSPHRASE'], ); -const TESTBUILD__ANDROID__CONFIGURE_AWS_CREDENTIALS__STEP_MOCK = utils.getMockStep( +const TESTBUILD__ANDROID__CONFIGURE_AWS_CREDENTIALS__STEP_MOCK = utils.createMockStep( 'Configure AWS Credentials', 'Configure AWS Credentials', 'ANDROID', ['AWS_ACCESS_KEY_ID', 'AWS_SECRET_ACCESS_KEY'], [], ); -const TESTBUILD__ANDROID__RUN_FASTLANE_BETA_TEST__STEP_MOCK = utils.getMockStep( +const TESTBUILD__ANDROID__RUN_FASTLANE_BETA_TEST__STEP_MOCK = utils.createMockStep( 'Run Fastlane beta test', 'Run Fastlane beta test', 'ANDROID', [], ['S3_ACCESS_KEY', 'S3_SECRET_ACCESS_KEY', 'S3_BUCKET', 'S3_REGION'], ); -const TESTBUILD__ANDROID__UPLOAD_ARTIFACT__STEP_MOCK = utils.getMockStep( +const TESTBUILD__ANDROID__UPLOAD_ARTIFACT__STEP_MOCK = utils.createMockStep( 'Upload Artifact', 'Upload Artifact', 'ANDROID', @@ -140,63 +140,63 @@ const TESTBUILD__ANDROID__STEP_MOCKS = [ ]; // ios -const TESTBUILD__IOS__CHECKOUT__STEP_MOCK = utils.getMockStep( +const TESTBUILD__IOS__CHECKOUT__STEP_MOCK = utils.createMockStep( 'Checkout', 'Checkout', 'IOS', ['ref'], [], ); -const TESTBUILD__IOS__SETUP_NODE__STEP_MOCK = utils.getMockStep( +const TESTBUILD__IOS__SETUP_NODE__STEP_MOCK = utils.createMockStep( 'Setup Node', 'Setup Node', 'IOS', [], [], ); -const TESTBUILD__IOS__SETUP_RUBY__STEP_MOCK = utils.getMockStep( +const TESTBUILD__IOS__SETUP_RUBY__STEP_MOCK = utils.createMockStep( 'Setup Ruby', 'Setup Ruby', 'IOS', ['ruby-version', 'bundler-cache'], [], ); -const TESTBUILD__IOS__INSTALL_COCOAPODS__STEP_MOCK = utils.getMockStep( +const TESTBUILD__IOS__INSTALL_COCOAPODS__STEP_MOCK = utils.createMockStep( 'Install cocoapods', 'Install cocoapods', 'IOS', ['timeout_minutes', 'max_attempts', 'command'], [], ); -const TESTBUILD__IOS__DECRYPT_PROFILE__STEP_MOCK = utils.getMockStep( +const TESTBUILD__IOS__DECRYPT_PROFILE__STEP_MOCK = utils.createMockStep( 'Decrypt profile', 'Decrypt profile', 'IOS', [], ['LARGE_SECRET_PASSPHRASE'], ); -const TESTBUILD__IOS__DECRYPT_CERTIFICATE__STEP_MOCK = utils.getMockStep( +const TESTBUILD__IOS__DECRYPT_CERTIFICATE__STEP_MOCK = utils.createMockStep( 'Decrypt certificate', 'Decrypt certificate', 'IOS', [], ['LARGE_SECRET_PASSPHRASE'], ); -const TESTBUILD__IOS__CONFIGURE_AWS_CREDENTIALS__STEP_MOCK = utils.getMockStep( +const TESTBUILD__IOS__CONFIGURE_AWS_CREDENTIALS__STEP_MOCK = utils.createMockStep( 'Configure AWS Credentials', 'Configure AWS Credentials', 'IOS', ['AWS_ACCESS_KEY_ID', 'AWS_SECRET_ACCESS_KEY'], [], ); -const TESTBUILD__IOS__RUN_FASTLANE__STEP_MOCK = utils.getMockStep( +const TESTBUILD__IOS__RUN_FASTLANE__STEP_MOCK = utils.createMockStep( 'Run Fastlane', 'Run Fastlane', 'IOS', [], ['S3_ACCESS_KEY', 'S3_SECRET_ACCESS_KEY', 'S3_BUCKET', 'S3_REGION'], ); -const TESTBUILD__IOS__UPLOAD_ARTIFACT__STEP_MOCK = utils.getMockStep( +const TESTBUILD__IOS__UPLOAD_ARTIFACT__STEP_MOCK = utils.createMockStep( 'Upload Artifact', 'Upload Artifact', 'IOS', @@ -216,35 +216,35 @@ const TESTBUILD__IOS__STEP_MOCKS = [ ]; // desktop -const TESTBUILD__DESKTOP__CHECKOUT__STEP_MOCK = utils.getMockStep( +const TESTBUILD__DESKTOP__CHECKOUT__STEP_MOCK = utils.createMockStep( 'Checkout', 'Checkout', 'DESKTOP', ['ref', 'fetch-depth'], [], ); -const TESTBUILD__DESKTOP__SETUP_NODE__STEP_MOCK = utils.getMockStep( +const TESTBUILD__DESKTOP__SETUP_NODE__STEP_MOCK = utils.createMockStep( 'Setup Node', 'Setup Node', 'DESKTOP', [], [], ); -const TESTBUILD__DESKTOP__DECRYPT_DEVELOPER_ID_CERTIFICATE__STEP_MOCK = utils.getMockStep( +const TESTBUILD__DESKTOP__DECRYPT_DEVELOPER_ID_CERTIFICATE__STEP_MOCK = utils.createMockStep( 'Decrypt Developer ID Certificate', 'Decrypt Developer ID Certificate', 'DESKTOP', [], ['DEVELOPER_ID_SECRET_PASSPHRASE'], ); -const TESTBUILD__DESKTOP__CONFIGURE_AWS_CREDENTIALS__STEP_MOCK = utils.getMockStep( +const TESTBUILD__DESKTOP__CONFIGURE_AWS_CREDENTIALS__STEP_MOCK = utils.createMockStep( 'Configure AWS Credentials', 'Configure AWS Credentials', 'DESKTOP', ['AWS_ACCESS_KEY_ID', 'AWS_SECRET_ACCESS_KEY'], [], ); -const TESTBUILD__DESKTOP__BUILD_DESKTOP_APP_FOR_TESTING__STEP_MOCK = utils.getMockStep( +const TESTBUILD__DESKTOP__BUILD_DESKTOP_APP_FOR_TESTING__STEP_MOCK = utils.createMockStep( 'Build desktop app for testing', 'Build desktop app for testing', 'DESKTOP', @@ -260,42 +260,42 @@ const TESTBUILD__DESKTOP__STEP_MOCKS = [ ]; // web -const TESTBUILD__WEB__CHECKOUT__STEP_MOCK = utils.getMockStep( +const TESTBUILD__WEB__CHECKOUT__STEP_MOCK = utils.createMockStep( 'Checkout', 'Checkout', 'WEB', ['fetch-depth', 'ref'], [], ); -const TESTBUILD__WEB__SETUP_NODE__STEP_MOCK = utils.getMockStep( +const TESTBUILD__WEB__SETUP_NODE__STEP_MOCK = utils.createMockStep( 'Setup Node', 'Setup Node', 'WEB', [], [], ); -const TESTBUILD__WEB__CONFIGURE_AWS_CREDENTIALS__STEP_MOCK = utils.getMockStep( +const TESTBUILD__WEB__CONFIGURE_AWS_CREDENTIALS__STEP_MOCK = utils.createMockStep( 'Configure AWS Credentials', 'Configure AWS Credentials', 'WEB', ['AWS_ACCESS_KEY_ID', 'AWS_SECRET_ACCESS_KEY'], [], ); -const TESTBUILD__WEB__BUILD_WEB_FOR_TESTING__STEP_MOCK = utils.getMockStep( +const TESTBUILD__WEB__BUILD_WEB_FOR_TESTING__STEP_MOCK = utils.createMockStep( 'Build web for testing', 'Build web for testing', 'WEB', [], [], ); -const TESTBUILD__WEB__BUILD_DOCS__STEP_MOCK = utils.getMockStep( +const TESTBUILD__WEB__BUILD_DOCS__STEP_MOCK = utils.createMockStep( 'Build docs', 'Build docs', 'WEB', [], [], ); -const TESTBUILD__WEB__DEPLOY_TO_S3_FOR_INTERNAL_TESTING__STEP_MOCK = utils.getMockStep( +const TESTBUILD__WEB__DEPLOY_TO_S3_FOR_INTERNAL_TESTING__STEP_MOCK = utils.createMockStep( 'Deploy to S3 for internal testing', 'Deploy to S3 for internal testing', 'WEB', @@ -312,21 +312,21 @@ const TESTBUILD__WEB__STEP_MOCKS = [ ]; // postgithubcomment -const TESTBUILD__POSTGITHUBCOMMENT__CHECKOUT__STEP_MOCK = utils.getMockStep( +const TESTBUILD__POSTGITHUBCOMMENT__CHECKOUT__STEP_MOCK = utils.createMockStep( 'Checkout', 'Checkout', 'POSTGITHUBCOMMENT', ['ref'], [], ); -const TESTBUILD__POSTGITHUBCOMMENT__DOWNLOAD_ARTIFACT__STEP_MOCK = utils.getMockStep( +const TESTBUILD__POSTGITHUBCOMMENT__DOWNLOAD_ARTIFACT__STEP_MOCK = utils.createMockStep( 'Download Artifact', 'Download Artifact', 'POSTGITHUBCOMMENT', [], [], ); -const TESTBUILD__POSTGITHUBCOMMENT__READ_JSONS_WITH_ANDROID_PATHS__STEP_MOCK = utils.getMockStep( +const TESTBUILD__POSTGITHUBCOMMENT__READ_JSONS_WITH_ANDROID_PATHS__STEP_MOCK = utils.createMockStep( 'Read JSONs with android paths', 'Read JSONs with android paths', 'POSTGITHUBCOMMENT', @@ -334,7 +334,7 @@ const TESTBUILD__POSTGITHUBCOMMENT__READ_JSONS_WITH_ANDROID_PATHS__STEP_MOCK = u [], {android_paths: '{\\"html_path\\": \\"http://dummy.android.link\\"}'}, ); -const TESTBUILD__POSTGITHUBCOMMENT__READ_JSONS_WITH_IOS_PATHS__STEP_MOCK = utils.getMockStep( +const TESTBUILD__POSTGITHUBCOMMENT__READ_JSONS_WITH_IOS_PATHS__STEP_MOCK = utils.createMockStep( 'Read JSONs with iOS paths', 'Read JSONs with iOS paths', 'POSTGITHUBCOMMENT', @@ -342,14 +342,14 @@ const TESTBUILD__POSTGITHUBCOMMENT__READ_JSONS_WITH_IOS_PATHS__STEP_MOCK = utils [], {ios_paths: '{\\"html_path\\": \\"http://dummy.ios.link\\"}'}, ); -const TESTBUILD__POSTGITHUBCOMMENT__MAINTAIN_COMMENT__STEP_MOCK = utils.getMockStep( +const TESTBUILD__POSTGITHUBCOMMENT__MAINTAIN_COMMENT__STEP_MOCK = utils.createMockStep( 'maintain-comment', 'maintain-comment', 'POSTGITHUBCOMMENT', ['token', 'body-include', 'number', 'delete'], [], ); -const TESTBUILD__POSTGITHUBCOMMENT__PUBLISH_LINKS_TO_APPS_FOR_DOWNLOAD__STEP_MOCK = utils.getMockStep( +const TESTBUILD__POSTGITHUBCOMMENT__PUBLISH_LINKS_TO_APPS_FOR_DOWNLOAD__STEP_MOCK = utils.createMockStep( 'Publish links to apps for download', 'Publish links to apps for download', 'POSTGITHUBCOMMENT', diff --git a/workflow_tests/mocks/testMocks.js b/workflow_tests/mocks/testMocks.js index 051b876b3ebf..4e43aa182d3b 100644 --- a/workflow_tests/mocks/testMocks.js +++ b/workflow_tests/mocks/testMocks.js @@ -1,21 +1,21 @@ const utils = require('../utils/utils'); // jest -const TEST__JEST__CHECKOUT__STEP_MOCK = utils.getMockStep( +const TEST__JEST__CHECKOUT__STEP_MOCK = utils.createMockStep( 'Checkout', 'Checkout', 'JEST', [], [], ); -const TEST__JEST__SETUP_NODE__STEP_MOCK = utils.getMockStep( +const TEST__JEST__SETUP_NODE__STEP_MOCK = utils.createMockStep( 'Setup Node', 'Setup Node', 'JEST', [], [], ); -const TEST__JEST__GET_NUMBER_OF_CPU_CORES__STEP_MOCK = utils.getMockStep( +const TEST__JEST__GET_NUMBER_OF_CPU_CORES__STEP_MOCK = utils.createMockStep( 'Get number of CPU cores', 'Get number of CPU cores', 'JEST', @@ -23,14 +23,14 @@ const TEST__JEST__GET_NUMBER_OF_CPU_CORES__STEP_MOCK = utils.getMockStep( [], {count: 8}, ); -const TEST__JEST__CACHE_JEST_CACHE__STEP_MOCK = utils.getMockStep( +const TEST__JEST__CACHE_JEST_CACHE__STEP_MOCK = utils.createMockStep( 'Cache Jest cache', 'Cache Jest cache', 'JEST', ['path', 'key'], [], ); -const TEST__JEST__JEST_TESTS__STEP_MOCK = utils.getMockStep( +const TEST__JEST__JEST_TESTS__STEP_MOCK = utils.createMockStep( 'Jest tests', 'Jest tests', 'JEST', @@ -46,21 +46,21 @@ const TEST__JEST__STEP_MOCKS = [ ]; // shelltests -const TEST__SHELLTESTS__CHECKOUT__STEP_MOCK = utils.getMockStep( +const TEST__SHELLTESTS__CHECKOUT__STEP_MOCK = utils.createMockStep( 'Checkout', 'Checkout', 'SHELLTESTS', [], [], ); -const TEST__SHELLTESTS__SETUP_NODE__STEP_MOCK = utils.getMockStep( +const TEST__SHELLTESTS__SETUP_NODE__STEP_MOCK = utils.createMockStep( 'Setup Node', 'Setup Node', 'SHELLTESTS', [], [], ); -const TEST__SHELLTESTS__GETPULLREQUESTSMERGEDBETWEEN__STEP_MOCK = utils.getMockStep( +const TEST__SHELLTESTS__GETPULLREQUESTSMERGEDBETWEEN__STEP_MOCK = utils.createMockStep( 'getPullRequestsMergedBetween', 'getPullRequestsMergedBetween', 'SHELLTESTS', diff --git a/workflow_tests/mocks/validateGithubActionsMocks.js b/workflow_tests/mocks/validateGithubActionsMocks.js index f8ec11213da7..4be1596966ba 100644 --- a/workflow_tests/mocks/validateGithubActionsMocks.js +++ b/workflow_tests/mocks/validateGithubActionsMocks.js @@ -1,28 +1,28 @@ const utils = require('../utils/utils'); // verify -const VALIDATEGITHUBACTIONS__VERIFY__CHECKOUT__STEP_MOCK = utils.getMockStep( +const VALIDATEGITHUBACTIONS__VERIFY__CHECKOUT__STEP_MOCK = utils.createMockStep( 'Checkout', 'Checkout', 'VERIFY', ['fetch-depth'], [], ); -const VALIDATEGITHUBACTIONS__VERIFY__SETUP_NODE__STEP_MOCK = utils.getMockStep( +const VALIDATEGITHUBACTIONS__VERIFY__SETUP_NODE__STEP_MOCK = utils.createMockStep( 'Setup Node', 'Setup Node', 'VERIFY', [], [], ); -const VALIDATEGITHUBACTIONS__VERIFY__VERIFY_JAVASCRIPT_ACTION_BUILDS__STEP_MOCK = utils.getMockStep( +const VALIDATEGITHUBACTIONS__VERIFY__VERIFY_JAVASCRIPT_ACTION_BUILDS__STEP_MOCK = utils.createMockStep( 'Verify Javascript Action Builds', 'Verify Javascript Action Builds', 'VERIFY', [], [], ); -const VALIDATEGITHUBACTIONS__VERIFY__VALIDATE_ACTIONS_AND_WORKFLOWS__STEP_MOCK = utils.getMockStep( +const VALIDATEGITHUBACTIONS__VERIFY__VALIDATE_ACTIONS_AND_WORKFLOWS__STEP_MOCK = utils.createMockStep( 'Validate actions and workflows', 'Validate actions and workflows', 'VERIFY', diff --git a/workflow_tests/mocks/verifyPodfileMocks.js b/workflow_tests/mocks/verifyPodfileMocks.js index c44f51b7b784..df9889a0e718 100644 --- a/workflow_tests/mocks/verifyPodfileMocks.js +++ b/workflow_tests/mocks/verifyPodfileMocks.js @@ -1,21 +1,21 @@ const utils = require('../utils/utils'); // verify -const VERIFYPODFILE__VERIFY__CHECKOUT__STEP_MOCK = utils.getMockStep( +const VERIFYPODFILE__VERIFY__CHECKOUT__STEP_MOCK = utils.createMockStep( 'Checkout', 'Checkout', 'VERIFY', ['fetch-depth'], [], ); -const VERIFYPODFILE__VERIFY__SETUP_NODE__STEP_MOCK = utils.getMockStep( +const VERIFYPODFILE__VERIFY__SETUP_NODE__STEP_MOCK = utils.createMockStep( 'Setup Node', 'Setup Node', 'VERIFY', [], [], ); -const VERIFYPODFILE__VERIFY__VERIFY_PODFILE__STEP_MOCK = utils.getMockStep( +const VERIFYPODFILE__VERIFY__VERIFY_PODFILE__STEP_MOCK = utils.createMockStep( 'Verify podfile', 'Verify podfile', 'VERIFY', diff --git a/workflow_tests/mocks/verifySignedCommitsMocks.js b/workflow_tests/mocks/verifySignedCommitsMocks.js index e01d89b2b18f..18f71f09ee69 100644 --- a/workflow_tests/mocks/verifySignedCommitsMocks.js +++ b/workflow_tests/mocks/verifySignedCommitsMocks.js @@ -1,7 +1,7 @@ const utils = require('../utils/utils'); // verifysignedcommits -const VERIFYSIGNEDCOMMITS__VERIFYSIGNEDCOMMITS__VERIFY_SIGNED_COMMITS__STEP_MOCK = utils.getMockStep( +const VERIFYSIGNEDCOMMITS__VERIFYSIGNEDCOMMITS__VERIFY_SIGNED_COMMITS__STEP_MOCK = utils.createMockStep( 'Verify signed commits', 'Verify signed commits', 'VERIFYSIGNEDCOMMITS', diff --git a/workflow_tests/mocks/warnCPLabelMocks.js b/workflow_tests/mocks/warnCPLabelMocks.js index 334be03221d1..cf77ef23a6ef 100644 --- a/workflow_tests/mocks/warnCPLabelMocks.js +++ b/workflow_tests/mocks/warnCPLabelMocks.js @@ -1,14 +1,14 @@ const utils = require('../utils/utils'); // warncplabel -const WARNCPLABEL__WARNCPLABEL__COMMENT_ON_PR_TO_EXPLAIN_THE_CP_STAGING_LABEL__STEP_MOCK = utils.getMockStep( +const WARNCPLABEL__WARNCPLABEL__COMMENT_ON_PR_TO_EXPLAIN_THE_CP_STAGING_LABEL__STEP_MOCK = utils.createMockStep( 'Comment on PR to explain the CP Staging label', 'Comment on PR to explain the CP Staging label', 'WARNCPLABEL', ['github_token'], [], ); -const WARNCPLABEL__WARNCPLABEL__ANNOUNCE_FAILED_WORKFLOW_IN_SLACK__STEP_MOCK = utils.getMockStep( +const WARNCPLABEL__WARNCPLABEL__ANNOUNCE_FAILED_WORKFLOW_IN_SLACK__STEP_MOCK = utils.createMockStep( 'Announce failed workflow in Slack', 'Announce failed workflow in Slack', 'WARNCPLABEL', diff --git a/workflow_tests/preDeploy.test.js b/workflow_tests/preDeploy.test.js index b42cf63e5e26..e811765d6791 100644 --- a/workflow_tests/preDeploy.test.js +++ b/workflow_tests/preDeploy.test.js @@ -169,7 +169,7 @@ describe('test workflow preDeploy', () => { ); const testMockSteps = { lint: [ - utils.getMockStep( + utils.createMockStep( 'Run lint workflow', 'Running lint workflow - Lint workflow failed', 'LINT', @@ -198,7 +198,7 @@ describe('test workflow preDeploy', () => { }); expect(result).toEqual(expect.arrayContaining( [ - utils.getStepAssertion( + utils.createStepAssertion( 'Run lint workflow', false, null, @@ -211,7 +211,7 @@ describe('test workflow preDeploy', () => { assertions.assertIsExpensifyEmployeeJobExecuted(result); expect(result).toEqual(expect.arrayContaining( [ - utils.getStepAssertion( + utils.createStepAssertion( 'Announce failed workflow in Slack', true, null, @@ -219,7 +219,7 @@ describe('test workflow preDeploy', () => { 'Announcing failed workflow in slack', [{key: 'SLACK_WEBHOOK', value: '***'}], ), - utils.getStepAssertion( + utils.createStepAssertion( 'Exit failed workflow', false, '', @@ -248,7 +248,7 @@ describe('test workflow preDeploy', () => { const testMockSteps = { lint: mocks.LINT_JOB_MOCK_STEPS, test: [ - utils.getMockStep( + utils.createMockStep( 'Run test workflow', 'Running test workflow - Test workflow failed', 'TEST', @@ -277,7 +277,7 @@ describe('test workflow preDeploy', () => { assertions.assertLintJobExecuted(result); expect(result).toEqual(expect.arrayContaining( [ - utils.getStepAssertion( + utils.createStepAssertion( 'Run test workflow', false, null, @@ -289,7 +289,7 @@ describe('test workflow preDeploy', () => { assertions.assertIsExpensifyEmployeeJobExecuted(result); expect(result).toEqual(expect.arrayContaining( [ - utils.getStepAssertion( + utils.createStepAssertion( 'Announce failed workflow in Slack', true, null, @@ -297,7 +297,7 @@ describe('test workflow preDeploy', () => { 'Announcing failed workflow in slack', [{key: 'SLACK_WEBHOOK', value: '***'}], ), - utils.getStepAssertion( + utils.createStepAssertion( 'Exit failed workflow', false, '', diff --git a/workflow_tests/testBuild.test.js b/workflow_tests/testBuild.test.js index 30681661677f..53bb9b9c18f3 100644 --- a/workflow_tests/testBuild.test.js +++ b/workflow_tests/testBuild.test.js @@ -252,7 +252,7 @@ describe('test workflow testBuild', () => { web: mocks.TESTBUILD__WEB__STEP_MOCKS, postGithubComment: mocks.TESTBUILD__POSTGITHUBCOMMENT__STEP_MOCKS, }; - testMockSteps.android[3] = utils.getMockStep( + testMockSteps.android[3] = utils.createMockStep( 'Decrypt keystore', 'Decrypt keystore', 'ANDROID', @@ -306,7 +306,7 @@ describe('test workflow testBuild', () => { web: mocks.TESTBUILD__WEB__STEP_MOCKS, postGithubComment: mocks.TESTBUILD__POSTGITHUBCOMMENT__STEP_MOCKS, }; - testMockSteps.iOS[3] = utils.getMockStep( + testMockSteps.iOS[3] = utils.createMockStep( 'Install cocoapods', 'Install cocoapods', 'IOS', @@ -360,7 +360,7 @@ describe('test workflow testBuild', () => { web: mocks.TESTBUILD__WEB__STEP_MOCKS, postGithubComment: mocks.TESTBUILD__POSTGITHUBCOMMENT__STEP_MOCKS, }; - testMockSteps.desktop[2] = utils.getMockStep( + testMockSteps.desktop[2] = utils.createMockStep( 'Decrypt Developer ID Certificate', 'Decrypt Developer ID Certificate', 'DESKTOP', @@ -414,7 +414,7 @@ describe('test workflow testBuild', () => { web: utils.deepCopy(mocks.TESTBUILD__WEB__STEP_MOCKS), postGithubComment: mocks.TESTBUILD__POSTGITHUBCOMMENT__STEP_MOCKS, }; - testMockSteps.web[2] = utils.getMockStep( + testMockSteps.web[2] = utils.createMockStep( 'Configure AWS Credentials', 'Configure AWS Credentials', 'WEB', diff --git a/workflow_tests/utils/utils.js b/workflow_tests/utils/utils.js index ec00a6870d50..e526bf417e75 100644 --- a/workflow_tests/utils/utils.js +++ b/workflow_tests/utils/utils.js @@ -169,8 +169,8 @@ const FILES_TO_COPY_INTO_TEST_REPO = [ module.exports = { setUpActParams, - getMockStep: createMockStep, - getStepAssertion: createStepAssertion, + createMockStep, + createStepAssertion, setJobRunners, deepCopy, FILES_TO_COPY_INTO_TEST_REPO, diff --git a/workflow_tests/warnCPLabel.test.js b/workflow_tests/warnCPLabel.test.js index b99ede323395..3dc694c353df 100644 --- a/workflow_tests/warnCPLabel.test.js +++ b/workflow_tests/warnCPLabel.test.js @@ -83,7 +83,7 @@ describe('test workflow warnCPLabel', () => { const testMockSteps = { warnCPLabel: utils.deepCopy(mocks.WARNCPLABEL__WARNCPLABEL__STEP_MOCKS), }; - testMockSteps.warnCPLabel[0] = utils.getMockStep( + testMockSteps.warnCPLabel[0] = utils.createMockStep( 'Comment on PR to explain the CP Staging label', 'Comment on PR to explain the CP Staging label', 'WARNCPLABEL', From 7982c3f7753644dc51c2bc0493c63ced5ea819fd Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Fri, 31 Mar 2023 10:14:15 +0200 Subject: [PATCH 077/504] Update readme Added the link to `Act` documentation on necessary prerequisites (like Docker) See: https://github.com/Expensify/App/issues/13604 --- workflow_tests/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/workflow_tests/README.md b/workflow_tests/README.md index 3ff4b3f34081..aa401a24bf67 100644 --- a/workflow_tests/README.md +++ b/workflow_tests/README.md @@ -21,6 +21,7 @@ running `act pull_request -e event_data.json` with `event_data.json` having `{"a ## Setup - Install dependencies from `package.json` file with `npm install` +- Make sure you have fulfilled the [prerequisites](https://github.com/nektos/act#necessary-prerequisites-for-running-act) for running `Act` - Install `Act` with `brew install act` and follow the documentation on [first Act run](https://github.com/nektos/act#first-act-run) - Set the environment variable `ACT_BINARY` to the path to your `Act` executable (`which act` if you're not sure what the path is) - You should be ready to run the tests now with `npm test -- --config=workflow_tests/jest.config.js` From c6562162feafdb5353c47bb92a6ded3f06629e1b Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Fri, 31 Mar 2023 10:20:58 +0200 Subject: [PATCH 078/504] Update readme Added a new section on running the tests See: https://github.com/Expensify/App/issues/13604 --- workflow_tests/README.md | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/workflow_tests/README.md b/workflow_tests/README.md index aa401a24bf67..5b2e09f9a33e 100644 --- a/workflow_tests/README.md +++ b/workflow_tests/README.md @@ -24,9 +24,22 @@ running `act pull_request -e event_data.json` with `event_data.json` having `{"a - Make sure you have fulfilled the [prerequisites](https://github.com/nektos/act#necessary-prerequisites-for-running-act) for running `Act` - Install `Act` with `brew install act` and follow the documentation on [first Act run](https://github.com/nektos/act#first-act-run) - Set the environment variable `ACT_BINARY` to the path to your `Act` executable (`which act` if you're not sure what the path is) -- You should be ready to run the tests now with `npm test -- --config=workflow_tests/jest.config.js` +- You should be ready to run the tests now with `npm run workflow-test` - You can pre-generate new mocks/assertions/test files for a given workflow by running `npm run workflow-test:generate ` +## Running +- To run the workflow tests simply use + - `npm run workflow-test` + - this will run all the tests sequentially, which can take some time +- To run a specific test suite you can use + - `npm run workflow-test -- -i ` + - this will run only the test from that specific test file +- To run a specific test or subset of tests use + - `npm run workflow-test -- -t ""` + - this will run only the tests having `` in their name/description +- You can combine these like `npm run workflow-test -- -i workflow_tests/preDeploy.test.js -t "single specific test"` +- You can also use all other options which are normally usable with `jest` + ## File structure The testing framework file structure within the repository is as follows: - `App/` - main application folder From 05c497b7ed45afc8de268993930046ae03db47ed Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Fri, 28 Apr 2023 12:10:31 +0200 Subject: [PATCH 079/504] Add logging raw output to file Added logging the raw output from `act` into files under `workflow-tests/logs/.log`. Raw output should have more information in case there are some errors instead of just returning an empty array like `act-js` does See: https://github.com/Expensify/App/issues/13604 --- .gitignore | 3 +++ workflow_tests/authorChecklist.test.js | 6 ++++++ workflow_tests/cherryPick.test.js | 19 +++++++++++++++++++ workflow_tests/cla.test.js | 5 +++++ workflow_tests/createNewVersion.test.js | 5 +++++ workflow_tests/deploy.test.js | 8 ++++++++ workflow_tests/deployBlocker.test.js | 3 +++ workflow_tests/finishReleaseCycle.test.js | 5 +++++ workflow_tests/lint.test.js | 5 +++++ workflow_tests/lockDeploys.test.js | 9 +++++++++ workflow_tests/platformDeploy.test.js | 3 +++ workflow_tests/preDeploy.test.js | 19 +++++++++++++++++++ workflow_tests/reviewerChecklist.test.js | 2 ++ workflow_tests/test.test.js | 6 ++++++ workflow_tests/testBuild.test.js | 20 ++++++++++++++++++++ workflow_tests/utils/utils.js | 9 +++++++++ workflow_tests/validateGithubActions.test.js | 2 ++ workflow_tests/verifyPodfile.test.js | 4 ++++ workflow_tests/verifySignedCommits.test.js | 2 ++ workflow_tests/warnCPLabel.test.js | 3 +++ 20 files changed, 138 insertions(+) diff --git a/.gitignore b/.gitignore index cc7ab513ccd8..d17cd48710da 100644 --- a/.gitignore +++ b/.gitignore @@ -98,3 +98,6 @@ tests/e2e/results/ # Mock-github /repo/ + +# Workflow test logs +/workflow_tests/logs/ diff --git a/workflow_tests/authorChecklist.test.js b/workflow_tests/authorChecklist.test.js index 24dbaf86f718..f0da6f23dec3 100644 --- a/workflow_tests/authorChecklist.test.js +++ b/workflow_tests/authorChecklist.test.js @@ -59,6 +59,7 @@ describe('test workflow authorChecklist', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor, + logFile: utils.getLogFilePath('authorChecklist'), }); assertions.assertChecklistJobExecuted(result); @@ -85,6 +86,7 @@ describe('test workflow authorChecklist', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor, + logFile: utils.getLogFilePath('authorChecklist'), }); assertions.assertChecklistJobExecuted(result, false); @@ -117,6 +119,7 @@ describe('test workflow authorChecklist', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor, + logFile: utils.getLogFilePath('authorChecklist'), }); assertions.assertChecklistJobExecuted(result); @@ -143,6 +146,7 @@ describe('test workflow authorChecklist', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor, + logFile: utils.getLogFilePath('authorChecklist'), }); assertions.assertChecklistJobExecuted(result, false); @@ -175,6 +179,7 @@ describe('test workflow authorChecklist', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor, + logFile: utils.getLogFilePath('authorChecklist'), }); assertions.assertChecklistJobExecuted(result); @@ -201,6 +206,7 @@ describe('test workflow authorChecklist', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor, + logFile: utils.getLogFilePath('authorChecklist'), }); assertions.assertChecklistJobExecuted(result, false); diff --git a/workflow_tests/cherryPick.test.js b/workflow_tests/cherryPick.test.js index 794aedb5062b..967044103b49 100644 --- a/workflow_tests/cherryPick.test.js +++ b/workflow_tests/cherryPick.test.js @@ -66,6 +66,7 @@ describe('test workflow cherryPick', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor, + logFile: utils.getLogFilePath('cherryPick'), }); assertions.assertValidateActorJobExecuted(result, actor); @@ -109,6 +110,7 @@ describe('test workflow cherryPick', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor, + logFile: utils.getLogFilePath('cherryPick'), }); assertions.assertValidateActorJobExecuted(result, actor); @@ -167,6 +169,7 @@ describe('test workflow cherryPick', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor, + logFile: utils.getLogFilePath('cherryPick'), }); assertions.assertValidateActorJobExecuted(result, actor); @@ -217,6 +220,7 @@ describe('test workflow cherryPick', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor, + logFile: utils.getLogFilePath('cherryPick'), }); assertions.assertValidateActorJobExecuted(result, actor); @@ -270,6 +274,7 @@ describe('test workflow cherryPick', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor, + logFile: utils.getLogFilePath('cherryPick'), }); assertions.assertValidateActorJobExecuted(result, actor); @@ -320,6 +325,7 @@ describe('test workflow cherryPick', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor, + logFile: utils.getLogFilePath('cherryPick'), }); assertions.assertValidateActorJobExecuted(result, actor); @@ -376,6 +382,7 @@ describe('test workflow cherryPick', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor, + logFile: utils.getLogFilePath('cherryPick'), }); assertions.assertValidateActorJobExecuted(result, actor); @@ -426,6 +433,7 @@ describe('test workflow cherryPick', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor, + logFile: utils.getLogFilePath('cherryPick'), }); assertions.assertValidateActorJobExecuted(result, actor); @@ -479,6 +487,7 @@ describe('test workflow cherryPick', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor, + logFile: utils.getLogFilePath('cherryPick'), }); assertions.assertValidateActorJobExecuted(result, actor); @@ -529,6 +538,7 @@ describe('test workflow cherryPick', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor, + logFile: utils.getLogFilePath('cherryPick'), }); assertions.assertValidateActorJobExecuted(result, actor); @@ -589,6 +599,7 @@ describe('test workflow cherryPick', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor, + logFile: utils.getLogFilePath('cherryPick'), }); assertions.assertValidateActorJobExecuted(result, actor); @@ -639,6 +650,7 @@ describe('test workflow cherryPick', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor, + logFile: utils.getLogFilePath('cherryPick'), }); assertions.assertValidateActorJobExecuted(result, actor); @@ -692,6 +704,7 @@ describe('test workflow cherryPick', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor, + logFile: utils.getLogFilePath('cherryPick'), }); assertions.assertValidateActorJobExecuted(result, actor); @@ -742,6 +755,7 @@ describe('test workflow cherryPick', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor, + logFile: utils.getLogFilePath('cherryPick'), }); assertions.assertValidateActorJobExecuted(result, actor); @@ -798,6 +812,7 @@ describe('test workflow cherryPick', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor, + logFile: utils.getLogFilePath('cherryPick'), }); assertions.assertValidateActorJobExecuted(result, actor); @@ -848,6 +863,7 @@ describe('test workflow cherryPick', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor, + logFile: utils.getLogFilePath('cherryPick'), }); assertions.assertValidateActorJobExecuted(result, actor); @@ -901,6 +917,7 @@ describe('test workflow cherryPick', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor, + logFile: utils.getLogFilePath('cherryPick'), }); assertions.assertValidateActorJobExecuted(result, actor); @@ -951,6 +968,7 @@ describe('test workflow cherryPick', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor, + logFile: utils.getLogFilePath('cherryPick'), }); assertions.assertValidateActorJobExecuted(result, actor); @@ -1006,6 +1024,7 @@ describe('test workflow cherryPick', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor: 'Dummy Author', + logFile: utils.getLogFilePath('cherryPick'), }); assertions.assertValidateActorJobExecuted(result, 'Dummy Author', false); diff --git a/workflow_tests/cla.test.js b/workflow_tests/cla.test.js index efd08276d472..0e162cd88289 100644 --- a/workflow_tests/cla.test.js +++ b/workflow_tests/cla.test.js @@ -72,6 +72,7 @@ describe('test workflow cla', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor, + logFile: utils.getLogFilePath('cla'), }); assertions.assertCLAJobExecuted(result, commentBody, `${repoPath}/remote/origin`, true, false); @@ -109,6 +110,7 @@ describe('test workflow cla', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor, + logFile: utils.getLogFilePath('cla'), }); assertions.assertCLAJobExecuted(result, commentBody, `${repoPath}/remote/origin`, true, true); @@ -146,6 +148,7 @@ describe('test workflow cla', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor, + logFile: utils.getLogFilePath('cla'), }); assertions.assertCLAJobExecuted(result, commentBody, `${repoPath}/remote/origin`, true, true); @@ -182,6 +185,7 @@ describe('test workflow cla', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor, + logFile: utils.getLogFilePath('cla'), }); assertions.assertCLAJobExecuted(result, '', `${repoPath}/remote/origin`, true, true); @@ -212,6 +216,7 @@ describe('test workflow cla', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor, + logFile: utils.getLogFilePath('cla'), }); assertions.assertCLAJobExecuted(result, '', `${repoPath}/remote/origin`, false); diff --git a/workflow_tests/createNewVersion.test.js b/workflow_tests/createNewVersion.test.js index 1db7207816d0..d7c920349983 100644 --- a/workflow_tests/createNewVersion.test.js +++ b/workflow_tests/createNewVersion.test.js @@ -70,6 +70,7 @@ describe('test workflow createNewVersion', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor: 'Dummy Author', + logFile: utils.getLogFilePath('createNewVersion'), }); assertions.assertValidateActorJobExecuted(result); assertions.assertCreateNewVersionJobExecuted(result); @@ -101,6 +102,7 @@ describe('test workflow createNewVersion', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor: 'Dummy Author', + logFile: utils.getLogFilePath('createNewVersion'), }); assertions.assertValidateActorJobExecuted(result); assertions.assertCreateNewVersionJobExecuted(result); @@ -132,6 +134,7 @@ describe('test workflow createNewVersion', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor: 'Dummy Author', + logFile: utils.getLogFilePath('createNewVersion'), }); assertions.assertValidateActorJobExecuted(result); assertions.assertCreateNewVersionJobExecuted(result, 'BUILD', false); @@ -172,6 +175,7 @@ describe('test workflow createNewVersion', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor: 'Dummy Author', + logFile: utils.getLogFilePath('createNewVersion'), }); assertions.assertValidateActorJobExecuted(result); assertions.assertCreateNewVersionJobExecuted(result, 'BUILD', true, false); @@ -201,6 +205,7 @@ describe('test workflow createNewVersion', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor: 'Dummy Author', + logFile: utils.getLogFilePath('createNewVersion'), }); assertions.assertValidateActorJobExecuted(result); assertions.assertCreateNewVersionJobExecuted(result, 'MAJOR'); diff --git a/workflow_tests/deploy.test.js b/workflow_tests/deploy.test.js index 05a3320fc1c1..c0faf050c426 100644 --- a/workflow_tests/deploy.test.js +++ b/workflow_tests/deploy.test.js @@ -60,6 +60,7 @@ describe('test workflow deploy', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor: 'OSBotify', + logFile: utils.getLogFilePath('deploy'), }); assertions.assertValidateJobExecuted(result); assertions.assertDeployStagingJobExecuted(result, false); @@ -92,6 +93,7 @@ describe('test workflow deploy', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor: 'OSBotify', + logFile: utils.getLogFilePath('deploy'), }); assertions.assertValidateJobExecuted(result); assertions.assertDeployStagingJobExecuted(result); @@ -124,6 +126,7 @@ describe('test workflow deploy', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor: 'OSBotify', + logFile: utils.getLogFilePath('deploy'), }); assertions.assertValidateJobExecuted(result); assertions.assertDeployStagingJobExecuted(result, false); @@ -157,6 +160,7 @@ describe('test workflow deploy', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor: 'Dummy Author', + logFile: utils.getLogFilePath('deploy'), }); assertions.assertValidateJobExecuted(result); assertions.assertDeployStagingJobExecuted(result, false); @@ -189,6 +193,7 @@ describe('test workflow deploy', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor: 'Dummy Author', + logFile: utils.getLogFilePath('deploy'), }); assertions.assertValidateJobExecuted(result); assertions.assertDeployStagingJobExecuted(result, false); @@ -221,6 +226,7 @@ describe('test workflow deploy', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor: 'Dummy Author', + logFile: utils.getLogFilePath('deploy'), }); assertions.assertValidateJobExecuted(result); assertions.assertDeployStagingJobExecuted(result, false); @@ -254,6 +260,7 @@ describe('test workflow deploy', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor: 'Dummy Author', + logFile: utils.getLogFilePath('deploy'), }); assertions.assertValidateJobExecuted(result, false); assertions.assertDeployStagingJobExecuted(result, false); @@ -275,6 +282,7 @@ describe('test workflow deploy', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor: 'Dummy Author', + logFile: utils.getLogFilePath('deploy'), }); assertions.assertValidateJobExecuted(result, false); assertions.assertDeployStagingJobExecuted(result, false); diff --git a/workflow_tests/deployBlocker.test.js b/workflow_tests/deployBlocker.test.js index dcfc8dbeba6f..7009fc1bf065 100644 --- a/workflow_tests/deployBlocker.test.js +++ b/workflow_tests/deployBlocker.test.js @@ -77,6 +77,7 @@ describe('test workflow deployBlocker', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor, + logFile: utils.getLogFilePath('deployBlocker'), }); assertions.assertDeployBlockerJobExecuted(result, 'Labeled issue title', '1234'); @@ -113,6 +114,7 @@ describe('test workflow deployBlocker', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor, + logFile: utils.getLogFilePath('deployBlocker'), }); assertions.assertDeployBlockerJobExecuted(result, 'Labeled issue title', '1234', true, false); @@ -143,6 +145,7 @@ describe('test workflow deployBlocker', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor, + logFile: utils.getLogFilePath('deployBlocker'), }); assertions.assertDeployBlockerJobExecuted(result, '', '', false); diff --git a/workflow_tests/finishReleaseCycle.test.js b/workflow_tests/finishReleaseCycle.test.js index 1fe4392aea00..5f79bcca5a0b 100644 --- a/workflow_tests/finishReleaseCycle.test.js +++ b/workflow_tests/finishReleaseCycle.test.js @@ -70,6 +70,7 @@ describe('test workflow finishReleaseCycle', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor: 'Dummy Author', + logFile: utils.getLogFilePath('finishReleaseCycle'), }); assertions.assertValidateJobExecuted(result, 'Dummy Author', '1234'); assertions.assertUpdateProductionJobExecuted(result); @@ -121,6 +122,7 @@ describe('test workflow finishReleaseCycle', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor: 'Dummy Author', + logFile: utils.getLogFilePath('finishReleaseCycle'), }); assertions.assertValidateJobExecuted(result, 'Dummy Author', '1234'); assertions.assertUpdateProductionJobExecuted(result); @@ -164,6 +166,7 @@ describe('test workflow finishReleaseCycle', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor: 'Dummy Author', + logFile: utils.getLogFilePath('finishReleaseCycle'), }); assertions.assertValidateJobExecuted(result, 'Dummy Author', '1234', true, true, true); assertions.assertUpdateProductionJobExecuted(result, false); @@ -207,6 +210,7 @@ describe('test workflow finishReleaseCycle', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor: 'Dummy Author', + logFile: utils.getLogFilePath('finishReleaseCycle'), }); assertions.assertValidateJobExecuted(result, 'Dummy Author', '1234', true, false, false); assertions.assertUpdateProductionJobExecuted(result, false); @@ -252,6 +256,7 @@ describe('test workflow finishReleaseCycle', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor: 'Dummy Author', + logFile: utils.getLogFilePath('finishReleaseCycle'), }); assertions.assertValidateJobExecuted(result, 'Dummy Author', '1234', false); assertions.assertUpdateProductionJobExecuted(result, false); diff --git a/workflow_tests/lint.test.js b/workflow_tests/lint.test.js index cd6e9ab3533f..71810f6acc21 100644 --- a/workflow_tests/lint.test.js +++ b/workflow_tests/lint.test.js @@ -58,6 +58,7 @@ describe('test workflow lint', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor, + logFile: utils.getLogFilePath('lint'), }); assertions.assertLintJobExecuted(result); @@ -83,6 +84,7 @@ describe('test workflow lint', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor: testActor, + logFile: utils.getLogFilePath('lint'), }); assertions.assertLintJobExecuted(result); @@ -114,6 +116,7 @@ describe('test workflow lint', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor, + logFile: utils.getLogFilePath('lint'), }); assertions.assertLintJobExecuted(result); @@ -139,6 +142,7 @@ describe('test workflow lint', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor: testActor, + logFile: utils.getLogFilePath('lint'), }); assertions.assertLintJobExecuted(result, false); @@ -168,6 +172,7 @@ describe('test workflow lint', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor, + logFile: utils.getLogFilePath('lint'), }); assertions.assertLintJobExecuted(result); diff --git a/workflow_tests/lockDeploys.test.js b/workflow_tests/lockDeploys.test.js index 5a2116a50b6b..dd048fcf2d57 100644 --- a/workflow_tests/lockDeploys.test.js +++ b/workflow_tests/lockDeploys.test.js @@ -75,6 +75,7 @@ describe('test workflow lockDeploys', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor: 'Dummy Author', + logFile: utils.getLogFilePath('lockDeploys'), }); assertions.assertlockStagingDeploysJobExecuted(result); @@ -129,6 +130,7 @@ describe('test workflow lockDeploys', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor: 'Dummy Author', + logFile: utils.getLogFilePath('lockDeploys'), }); assertions.assertlockStagingDeploysJobFailedAfterFirstStep(result); @@ -175,6 +177,7 @@ describe('test workflow lockDeploys', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor: 'OSBotify', + logFile: utils.getLogFilePath('lockDeploys'), }); assertions.assertlockStagingDeploysJobExecuted(result, false); @@ -225,6 +228,7 @@ describe('test workflow lockDeploys', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor: 'Dummy Author', + logFile: utils.getLogFilePath('lockDeploys'), }); assertions.assertlockStagingDeploysJobExecuted(result, false); @@ -273,6 +277,7 @@ describe('test workflow lockDeploys', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor: 'OSBotify', + logFile: utils.getLogFilePath('lockDeploys'), }); assertions.assertlockStagingDeploysJobExecuted(result, false); @@ -323,6 +328,7 @@ describe('test workflow lockDeploys', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor: 'Dummy Author', + logFile: utils.getLogFilePath('lockDeploys'), }); assertions.assertlockStagingDeploysJobExecuted(result, false); @@ -369,6 +375,7 @@ describe('test workflow lockDeploys', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor: 'OSBotify', + logFile: utils.getLogFilePath('lockDeploys'), }); assertions.assertlockStagingDeploysJobExecuted(result, false); @@ -419,6 +426,7 @@ describe('test workflow lockDeploys', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor: 'Dummy Author', + logFile: utils.getLogFilePath('lockDeploys'), }); assertions.assertlockStagingDeploysJobExecuted(result, false); @@ -467,6 +475,7 @@ describe('test workflow lockDeploys', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor: 'OSBotify', + logFile: utils.getLogFilePath('lockDeploys'), }); assertions.assertlockStagingDeploysJobExecuted(result, false); diff --git a/workflow_tests/platformDeploy.test.js b/workflow_tests/platformDeploy.test.js index e3187b9870d0..85ed23ce409b 100644 --- a/workflow_tests/platformDeploy.test.js +++ b/workflow_tests/platformDeploy.test.js @@ -95,6 +95,7 @@ describe('test workflow platformDeploy', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor: 'Dummy Author', + logFile: utils.getLogFilePath('platformDeploy'), }); assertions.assertVerifyActorJobExecuted(result, 'Dummy Author'); @@ -167,6 +168,7 @@ describe('test workflow platformDeploy', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor: 'OSBotify', + logFile: utils.getLogFilePath('platformDeploy'), }); assertions.assertVerifyActorJobExecuted(result, 'OSBotify'); @@ -239,6 +241,7 @@ describe('test workflow platformDeploy', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor: 'Dummy Author', + logFile: utils.getLogFilePath('platformDeploy'), }); assertions.assertVerifyActorJobExecuted(result, 'Dummy Author'); diff --git a/workflow_tests/preDeploy.test.js b/workflow_tests/preDeploy.test.js index e811765d6791..2783e4aecf75 100644 --- a/workflow_tests/preDeploy.test.js +++ b/workflow_tests/preDeploy.test.js @@ -74,6 +74,7 @@ describe('test workflow preDeploy', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor: 'Dummy Tester', + logFile: utils.getLogFilePath('preDeploy'), }); // assert results (some steps can run in parallel to each other so the order is not assured @@ -119,6 +120,7 @@ describe('test workflow preDeploy', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor: 'Dummy Tester', + logFile: utils.getLogFilePath('preDeploy'), }); assertions.assertLintJobExecuted(result, false); assertions.assertTestJobExecuted(result, false); @@ -143,6 +145,7 @@ describe('test workflow preDeploy', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor: 'Dummy Tester', + logFile: utils.getLogFilePath('preDeploy'), }); assertions.assertLintJobExecuted(result, false); assertions.assertTestJobExecuted(result, false); @@ -195,6 +198,7 @@ describe('test workflow preDeploy', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor: 'Dummy Tester', + logFile: utils.getLogFilePath('preDeploy'), }); expect(result).toEqual(expect.arrayContaining( [ @@ -273,6 +277,7 @@ describe('test workflow preDeploy', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor: 'Dummy Tester', + logFile: utils.getLogFilePath('preDeploy'), }); assertions.assertLintJobExecuted(result); expect(result).toEqual(expect.arrayContaining( @@ -340,6 +345,7 @@ describe('test workflow preDeploy', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor: 'Dummy Tester', + logFile: utils.getLogFilePath('preDeploy'), }); assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); @@ -382,6 +388,7 @@ describe('test workflow preDeploy', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor: 'OSBotify', + logFile: utils.getLogFilePath('preDeploy'), }); assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); @@ -420,6 +427,7 @@ describe('test workflow preDeploy', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor: 'Dummy Tester', + logFile: utils.getLogFilePath('preDeploy'), }); assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); @@ -458,6 +466,7 @@ describe('test workflow preDeploy', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor: 'Dummy Tester', + logFile: utils.getLogFilePath('preDeploy'), }); assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); @@ -496,6 +505,7 @@ describe('test workflow preDeploy', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor: 'Dummy Tester', + logFile: utils.getLogFilePath('preDeploy'), }); assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); @@ -536,6 +546,7 @@ describe('test workflow preDeploy', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor: 'Dummy Tester', + logFile: utils.getLogFilePath('preDeploy'), }); assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); @@ -575,6 +586,7 @@ describe('test workflow preDeploy', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor: 'OSBotify', + logFile: utils.getLogFilePath('preDeploy'), }); assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); @@ -620,6 +632,7 @@ describe('test workflow preDeploy', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor: 'Dummy Tester', + logFile: utils.getLogFilePath('preDeploy'), }); assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); @@ -662,6 +675,7 @@ describe('test workflow preDeploy', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor: 'OSBotify', + logFile: utils.getLogFilePath('preDeploy'), }); assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); @@ -709,6 +723,7 @@ describe('test workflow preDeploy', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor: 'Dummy Tester', + logFile: utils.getLogFilePath('preDeploy'), }); assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); @@ -752,6 +767,7 @@ describe('test workflow preDeploy', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor: 'OSBotify', + logFile: utils.getLogFilePath('preDeploy'), }); assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); @@ -797,6 +813,7 @@ describe('test workflow preDeploy', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor: 'Dummy Tester', + logFile: utils.getLogFilePath('preDeploy'), }); assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); @@ -840,6 +857,7 @@ describe('test workflow preDeploy', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor: 'OSBotify', + logFile: utils.getLogFilePath('preDeploy'), }); assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); @@ -884,6 +902,7 @@ describe('test workflow preDeploy', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor: 'OSBotify', + logFile: utils.getLogFilePath('preDeploy'), }); assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); diff --git a/workflow_tests/reviewerChecklist.test.js b/workflow_tests/reviewerChecklist.test.js index 9dfd928fbdf1..69eaf3b7ab4d 100644 --- a/workflow_tests/reviewerChecklist.test.js +++ b/workflow_tests/reviewerChecklist.test.js @@ -55,6 +55,7 @@ describe('test workflow reviewerChecklist', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor, + logFile: utils.getLogFilePath('reviewerChecklist'), }); assertions.assertChecklistJobExecuted(result); @@ -80,6 +81,7 @@ describe('test workflow reviewerChecklist', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor: osbotifyActor, + logFile: utils.getLogFilePath('reviewerChecklist'), }); assertions.assertChecklistJobExecuted(result, false); diff --git a/workflow_tests/test.test.js b/workflow_tests/test.test.js index b2e719b9e6b8..21f973519927 100644 --- a/workflow_tests/test.test.js +++ b/workflow_tests/test.test.js @@ -61,6 +61,7 @@ describe('test workflow test', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor, + logFile: utils.getLogFilePath('test'), }); assertions.assertJestJobExecuted(result); @@ -87,6 +88,7 @@ describe('test workflow test', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor: osbotifyActor, + logFile: utils.getLogFilePath('test'), }); assertions.assertJestJobExecuted(result, false); @@ -120,6 +122,7 @@ describe('test workflow test', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor, + logFile: utils.getLogFilePath('test'), }); assertions.assertJestJobExecuted(result); @@ -146,6 +149,7 @@ describe('test workflow test', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor: osbotifyActor, + logFile: utils.getLogFilePath('test'), }); assertions.assertJestJobExecuted(result, false); @@ -177,6 +181,7 @@ describe('test workflow test', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor, + logFile: utils.getLogFilePath('test'), }); assertions.assertJestJobExecuted(result); @@ -203,6 +208,7 @@ describe('test workflow test', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor: osbotifyActor, + logFile: utils.getLogFilePath('test'), }); assertions.assertJestJobExecuted(result); diff --git a/workflow_tests/testBuild.test.js b/workflow_tests/testBuild.test.js index 53bb9b9c18f3..68d371c2561e 100644 --- a/workflow_tests/testBuild.test.js +++ b/workflow_tests/testBuild.test.js @@ -82,6 +82,7 @@ describe('test workflow testBuild', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor, + logFile: utils.getLogFilePath('testBuild'), }); assertions.assertValidateActorJobExecuted(result, actor, '1234'); @@ -125,6 +126,7 @@ describe('test workflow testBuild', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor, + logFile: utils.getLogFilePath('testBuild'), }); assertions.assertValidateActorJobExecuted(result, actor, '1234'); @@ -169,6 +171,7 @@ describe('test workflow testBuild', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor, + logFile: utils.getLogFilePath('testBuild'), }); assertions.assertValidateActorJobExecuted(result, actor, '1234'); @@ -213,6 +216,7 @@ describe('test workflow testBuild', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor, + logFile: utils.getLogFilePath('testBuild'), }); assertions.assertValidateActorJobExecuted(result, actor, '1234'); @@ -267,6 +271,7 @@ describe('test workflow testBuild', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor, + logFile: utils.getLogFilePath('testBuild'), }); assertions.assertValidateActorJobExecuted(result, actor, '1234'); @@ -321,6 +326,7 @@ describe('test workflow testBuild', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor, + logFile: utils.getLogFilePath('testBuild'), }); assertions.assertValidateActorJobExecuted(result, actor, '1234'); @@ -375,6 +381,7 @@ describe('test workflow testBuild', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor, + logFile: utils.getLogFilePath('testBuild'), }); assertions.assertValidateActorJobExecuted(result, actor, '1234'); @@ -429,6 +436,7 @@ describe('test workflow testBuild', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor, + logFile: utils.getLogFilePath('testBuild'), }); assertions.assertValidateActorJobExecuted(result, actor, '1234'); @@ -483,6 +491,7 @@ describe('test workflow testBuild', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor, + logFile: utils.getLogFilePath('testBuild'), }); assertions.assertValidateActorJobExecuted(result, actor, '1234'); @@ -525,6 +534,7 @@ describe('test workflow testBuild', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor, + logFile: utils.getLogFilePath('testBuild'), }); assertions.assertValidateActorJobExecuted(result, actor, '1234'); @@ -568,6 +578,7 @@ describe('test workflow testBuild', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor, + logFile: utils.getLogFilePath('testBuild'), }); assertions.assertValidateActorJobExecuted(result, actor, '1234'); @@ -611,6 +622,7 @@ describe('test workflow testBuild', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor, + logFile: utils.getLogFilePath('testBuild'), }); assertions.assertValidateActorJobExecuted(result, actor, '1234'); @@ -665,6 +677,7 @@ describe('test workflow testBuild', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor, + logFile: utils.getLogFilePath('testBuild'), }); assertions.assertValidateActorJobExecuted(result, actor, '1234'); @@ -707,6 +720,7 @@ describe('test workflow testBuild', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor, + logFile: utils.getLogFilePath('testBuild'), }); assertions.assertValidateActorJobExecuted(result, actor, '1234'); @@ -750,6 +764,7 @@ describe('test workflow testBuild', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor, + logFile: utils.getLogFilePath('testBuild'), }); assertions.assertValidateActorJobExecuted(result, actor, '1234'); @@ -793,6 +808,7 @@ describe('test workflow testBuild', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor, + logFile: utils.getLogFilePath('testBuild'), }); assertions.assertValidateActorJobExecuted(result, actor, '1234'); @@ -847,6 +863,7 @@ describe('test workflow testBuild', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor, + logFile: utils.getLogFilePath('testBuild'), }); assertions.assertValidateActorJobExecuted(result, actor, '1234'); @@ -889,6 +906,7 @@ describe('test workflow testBuild', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor, + logFile: utils.getLogFilePath('testBuild'), }); assertions.assertValidateActorJobExecuted(result, actor, '1234'); @@ -932,6 +950,7 @@ describe('test workflow testBuild', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor, + logFile: utils.getLogFilePath('testBuild'), }); assertions.assertValidateActorJobExecuted(result, actor, '1234'); @@ -975,6 +994,7 @@ describe('test workflow testBuild', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor, + logFile: utils.getLogFilePath('testBuild'), }); assertions.assertValidateActorJobExecuted(result, actor, '1234'); diff --git a/workflow_tests/utils/utils.js b/workflow_tests/utils/utils.js index e526bf417e75..dbe9e79902fa 100644 --- a/workflow_tests/utils/utils.js +++ b/workflow_tests/utils/utils.js @@ -152,6 +152,14 @@ function deepCopy(originalObject) { return JSON.parse(JSON.stringify(originalObject)); } +function getLogFilePath(workflowName) { + const logsDir = path.resolve(__dirname, '..', 'logs'); + if (!fs.existsSync(logsDir)) { + fs.mkdirSync(logsDir); + } + return path.resolve(logsDir, `${workflowName}.log`); +} + const FILES_TO_COPY_INTO_TEST_REPO = [ { src: path.resolve(__dirname, '..', '..', '.github', 'actions'), @@ -173,5 +181,6 @@ module.exports = { createStepAssertion, setJobRunners, deepCopy, + getLogFilePath, FILES_TO_COPY_INTO_TEST_REPO, }; diff --git a/workflow_tests/validateGithubActions.test.js b/workflow_tests/validateGithubActions.test.js index 6aca9266c3ab..b8d1a0c5337e 100644 --- a/workflow_tests/validateGithubActions.test.js +++ b/workflow_tests/validateGithubActions.test.js @@ -58,6 +58,7 @@ describe('test workflow validateGithubActions', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor, + logFile: utils.getLogFilePath('validateGithubActions'), }); assertions.assertVerifyJobExecuted(result); @@ -87,6 +88,7 @@ describe('test workflow validateGithubActions', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor, + logFile: utils.getLogFilePath('validateGithubActions'), }); assertions.assertVerifyJobExecuted(result); diff --git a/workflow_tests/verifyPodfile.test.js b/workflow_tests/verifyPodfile.test.js index ad770f1ba968..5c18f94133c4 100644 --- a/workflow_tests/verifyPodfile.test.js +++ b/workflow_tests/verifyPodfile.test.js @@ -64,6 +64,7 @@ describe('test workflow verifyPodfile', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor, + logFile: utils.getLogFilePath('verifyPodfile'), }); assertions.assertVerifyJobExecuted(result); @@ -93,6 +94,7 @@ describe('test workflow verifyPodfile', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor: osbotifyActor, + logFile: utils.getLogFilePath('verifyPodfile'), }); assertions.assertVerifyJobExecuted(result, false); @@ -128,6 +130,7 @@ describe('test workflow verifyPodfile', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor, + logFile: utils.getLogFilePath('verifyPodfile'), }); assertions.assertVerifyJobExecuted(result); @@ -157,6 +160,7 @@ describe('test workflow verifyPodfile', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor: osbotifyActor, + logFile: utils.getLogFilePath('verifyPodfile'), }); assertions.assertVerifyJobExecuted(result, false); diff --git a/workflow_tests/verifySignedCommits.test.js b/workflow_tests/verifySignedCommits.test.js index 076541c08354..7a8549ee5548 100644 --- a/workflow_tests/verifySignedCommits.test.js +++ b/workflow_tests/verifySignedCommits.test.js @@ -58,6 +58,7 @@ describe('test workflow verifySignedCommits', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor, + logFile: utils.getLogFilePath('verifySignedCommits'), }); assertions.assertVerifySignedCommitsJobExecuted(result); @@ -87,6 +88,7 @@ describe('test workflow verifySignedCommits', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor, + logFile: utils.getLogFilePath('verifySignedCommits'), }); assertions.assertVerifySignedCommitsJobExecuted(result); diff --git a/workflow_tests/warnCPLabel.test.js b/workflow_tests/warnCPLabel.test.js index 3dc694c353df..4ae61d141bf6 100644 --- a/workflow_tests/warnCPLabel.test.js +++ b/workflow_tests/warnCPLabel.test.js @@ -64,6 +64,7 @@ describe('test workflow warnCPLabel', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor, + logFile: utils.getLogFilePath('warnCPLabel'), }); assertions.assertWarnCPLabelJobExecuted(result); @@ -98,6 +99,7 @@ describe('test workflow warnCPLabel', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor, + logFile: utils.getLogFilePath('warnCPLabel'), }); assertions.assertWarnCPLabelJobExecuted(result, true, false); @@ -129,6 +131,7 @@ describe('test workflow warnCPLabel', () => { workflowFile: path.join(repoPath, '.github', 'workflows'), mockSteps: testMockSteps, actor, + logFile: utils.getLogFilePath('warnCPLabel'), }); assertions.assertWarnCPLabelJobExecuted(result, false); From 0e717b294286a23b5b8d14dc59e13a655227ec55 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Fri, 28 Apr 2023 20:03:46 +0200 Subject: [PATCH 080/504] Update workflow paths and fix test after merge After merging the base repo main branch `act-js` got updated to version 2.0.8 and now requires a path to the workflow file instead of a path to workflows directory. Also, one of the workflows has been changed in the meantime so the test had to be adjusted See: https://github.com/Expensify/App/issues/13604 --- .../assertions/testBuildAssertions.js | 36 ++++++++++++ workflow_tests/authorChecklist.test.js | 12 ++-- workflow_tests/cherryPick.test.js | 38 ++++++------- workflow_tests/cla.test.js | 10 ++-- workflow_tests/createNewVersion.test.js | 10 ++-- workflow_tests/deploy.test.js | 16 +++--- workflow_tests/deployBlocker.test.js | 6 +- workflow_tests/finishReleaseCycle.test.js | 10 ++-- workflow_tests/lint.test.js | 10 ++-- workflow_tests/lockDeploys.test.js | 18 +++--- workflow_tests/mocks/testBuildMocks.js | 36 +++++++++++- workflow_tests/platformDeploy.test.js | 11 +--- workflow_tests/preDeploy.test.js | 38 ++++++------- workflow_tests/reviewerChecklist.test.js | 4 +- workflow_tests/test.test.js | 12 ++-- workflow_tests/testBuild.test.js | 56 +++++++++---------- workflow_tests/validateGithubActions.test.js | 4 +- workflow_tests/verifyPodfile.test.js | 8 +-- workflow_tests/verifySignedCommits.test.js | 4 +- workflow_tests/warnCPLabel.test.js | 6 +- 20 files changed, 204 insertions(+), 141 deletions(-) diff --git a/workflow_tests/assertions/testBuildAssertions.js b/workflow_tests/assertions/testBuildAssertions.js index 11b73a4863b0..87d78f35e9dd 100644 --- a/workflow_tests/assertions/testBuildAssertions.js +++ b/workflow_tests/assertions/testBuildAssertions.js @@ -71,6 +71,15 @@ const assertAndroidJobExecuted = (workflowResult, ref = '', didExecute = true, f [{key: 'ref', value: ref}], [], ), + utils.createStepAssertion( + 'Create .env.adhoc file based on staging and add PULL_REQUEST_NUMBER env to it', + true, + null, + 'ANDROID', + 'Creating .env.adhoc file based on staging', + [], + [], + ), utils.createStepAssertion( 'Setup Node', true, @@ -170,6 +179,15 @@ const assertIOSJobExecuted = (workflowResult, ref = '', didExecute = true, fails [{key: 'ref', value: ref}], [], ), + utils.createStepAssertion( + 'Create .env.adhoc file based on staging and add PULL_REQUEST_NUMBER env to it', + true, + null, + 'IOS', + 'Creating .env.adhoc file based on staging', + [], + [], + ), utils.createStepAssertion( 'Setup Node', true, @@ -282,6 +300,15 @@ const assertDesktopJobExecuted = (workflowResult, ref = '', didExecute = true, f [{key: 'ref', value: ref}, {key: 'fetch-depth', value: '0'}], [], ), + utils.createStepAssertion( + 'Create .env.adhoc file based on staging and add PULL_REQUEST_NUMBER env to it', + true, + null, + 'DESKTOP', + 'Creating .env.adhoc file based on staging', + [], + [], + ), utils.createStepAssertion( 'Setup Node', true, @@ -356,6 +383,15 @@ const assertWebJobExecuted = (workflowResult, ref = '', didExecute = true, fails [{key: 'fetch-depth', value: '0'}, {key: 'ref', value: ref}], [], ), + utils.createStepAssertion( + 'Create .env.adhoc file based on staging and add PULL_REQUEST_NUMBER env to it', + true, + null, + 'WEB', + 'Creating .env.adhoc file based on staging', + [], + [], + ), utils.createStepAssertion( 'Setup Node', true, diff --git a/workflow_tests/authorChecklist.test.js b/workflow_tests/authorChecklist.test.js index f0da6f23dec3..cbc849fa4df1 100644 --- a/workflow_tests/authorChecklist.test.js +++ b/workflow_tests/authorChecklist.test.js @@ -56,7 +56,7 @@ describe('test workflow authorChecklist', () => { }; const result = await act .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'authorChecklist.yml'), mockSteps: testMockSteps, actor, logFile: utils.getLogFilePath('authorChecklist'), @@ -83,7 +83,7 @@ describe('test workflow authorChecklist', () => { }; const result = await act .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'authorChecklist.yml'), mockSteps: testMockSteps, actor, logFile: utils.getLogFilePath('authorChecklist'), @@ -116,7 +116,7 @@ describe('test workflow authorChecklist', () => { }; const result = await act .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'authorChecklist.yml'), mockSteps: testMockSteps, actor, logFile: utils.getLogFilePath('authorChecklist'), @@ -143,7 +143,7 @@ describe('test workflow authorChecklist', () => { }; const result = await act .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'authorChecklist.yml'), mockSteps: testMockSteps, actor, logFile: utils.getLogFilePath('authorChecklist'), @@ -176,7 +176,7 @@ describe('test workflow authorChecklist', () => { }; const result = await act .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'authorChecklist.yml'), mockSteps: testMockSteps, actor, logFile: utils.getLogFilePath('authorChecklist'), @@ -203,7 +203,7 @@ describe('test workflow authorChecklist', () => { }; const result = await act .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'authorChecklist.yml'), mockSteps: testMockSteps, actor, logFile: utils.getLogFilePath('authorChecklist'), diff --git a/workflow_tests/cherryPick.test.js b/workflow_tests/cherryPick.test.js index 967044103b49..a939520ab996 100644 --- a/workflow_tests/cherryPick.test.js +++ b/workflow_tests/cherryPick.test.js @@ -63,7 +63,7 @@ describe('test workflow cherryPick', () => { }; const result = await act .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), mockSteps: testMockSteps, actor, logFile: utils.getLogFilePath('cherryPick'), @@ -107,7 +107,7 @@ describe('test workflow cherryPick', () => { ); const result = await act .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), mockSteps: testMockSteps, actor, logFile: utils.getLogFilePath('cherryPick'), @@ -166,7 +166,7 @@ describe('test workflow cherryPick', () => { ); const result = await act .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), mockSteps: testMockSteps, actor, logFile: utils.getLogFilePath('cherryPick'), @@ -217,7 +217,7 @@ describe('test workflow cherryPick', () => { ); const result = await act .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), mockSteps: testMockSteps, actor, logFile: utils.getLogFilePath('cherryPick'), @@ -271,7 +271,7 @@ describe('test workflow cherryPick', () => { ); const result = await act .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), mockSteps: testMockSteps, actor, logFile: utils.getLogFilePath('cherryPick'), @@ -322,7 +322,7 @@ describe('test workflow cherryPick', () => { ); const result = await act .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), mockSteps: testMockSteps, actor, logFile: utils.getLogFilePath('cherryPick'), @@ -379,7 +379,7 @@ describe('test workflow cherryPick', () => { ); const result = await act .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), mockSteps: testMockSteps, actor, logFile: utils.getLogFilePath('cherryPick'), @@ -430,7 +430,7 @@ describe('test workflow cherryPick', () => { ); const result = await act .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), mockSteps: testMockSteps, actor, logFile: utils.getLogFilePath('cherryPick'), @@ -484,7 +484,7 @@ describe('test workflow cherryPick', () => { ); const result = await act .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), mockSteps: testMockSteps, actor, logFile: utils.getLogFilePath('cherryPick'), @@ -535,7 +535,7 @@ describe('test workflow cherryPick', () => { ); const result = await act .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), mockSteps: testMockSteps, actor, logFile: utils.getLogFilePath('cherryPick'), @@ -596,7 +596,7 @@ describe('test workflow cherryPick', () => { ); const result = await act .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), mockSteps: testMockSteps, actor, logFile: utils.getLogFilePath('cherryPick'), @@ -647,7 +647,7 @@ describe('test workflow cherryPick', () => { ); const result = await act .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), mockSteps: testMockSteps, actor, logFile: utils.getLogFilePath('cherryPick'), @@ -701,7 +701,7 @@ describe('test workflow cherryPick', () => { ); const result = await act .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), mockSteps: testMockSteps, actor, logFile: utils.getLogFilePath('cherryPick'), @@ -752,7 +752,7 @@ describe('test workflow cherryPick', () => { ); const result = await act .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), mockSteps: testMockSteps, actor, logFile: utils.getLogFilePath('cherryPick'), @@ -809,7 +809,7 @@ describe('test workflow cherryPick', () => { ); const result = await act .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), mockSteps: testMockSteps, actor, logFile: utils.getLogFilePath('cherryPick'), @@ -860,7 +860,7 @@ describe('test workflow cherryPick', () => { ); const result = await act .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), mockSteps: testMockSteps, actor, logFile: utils.getLogFilePath('cherryPick'), @@ -914,7 +914,7 @@ describe('test workflow cherryPick', () => { ); const result = await act .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), mockSteps: testMockSteps, actor, logFile: utils.getLogFilePath('cherryPick'), @@ -965,7 +965,7 @@ describe('test workflow cherryPick', () => { ); const result = await act .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), mockSteps: testMockSteps, actor, logFile: utils.getLogFilePath('cherryPick'), @@ -1021,7 +1021,7 @@ describe('test workflow cherryPick', () => { }; const result = await act .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), mockSteps: testMockSteps, actor: 'Dummy Author', logFile: utils.getLogFilePath('cherryPick'), diff --git a/workflow_tests/cla.test.js b/workflow_tests/cla.test.js index 0e162cd88289..65a8920368ca 100644 --- a/workflow_tests/cla.test.js +++ b/workflow_tests/cla.test.js @@ -69,7 +69,7 @@ describe('test workflow cla', () => { }; const result = await act .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'cla.yml'), mockSteps: testMockSteps, actor, logFile: utils.getLogFilePath('cla'), @@ -107,7 +107,7 @@ describe('test workflow cla', () => { }; const result = await act .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'cla.yml'), mockSteps: testMockSteps, actor, logFile: utils.getLogFilePath('cla'), @@ -145,7 +145,7 @@ describe('test workflow cla', () => { }; const result = await act .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'cla.yml'), mockSteps: testMockSteps, actor, logFile: utils.getLogFilePath('cla'), @@ -182,7 +182,7 @@ describe('test workflow cla', () => { }; const result = await act .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'cla.yml'), mockSteps: testMockSteps, actor, logFile: utils.getLogFilePath('cla'), @@ -213,7 +213,7 @@ describe('test workflow cla', () => { }; const result = await act .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'cla.yml'), mockSteps: testMockSteps, actor, logFile: utils.getLogFilePath('cla'), diff --git a/workflow_tests/createNewVersion.test.js b/workflow_tests/createNewVersion.test.js index d7c920349983..87455f156590 100644 --- a/workflow_tests/createNewVersion.test.js +++ b/workflow_tests/createNewVersion.test.js @@ -67,7 +67,7 @@ describe('test workflow createNewVersion', () => { }; const result = await act .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'createNewVersion.yml'), mockSteps: testMockSteps, actor: 'Dummy Author', logFile: utils.getLogFilePath('createNewVersion'), @@ -99,7 +99,7 @@ describe('test workflow createNewVersion', () => { }; const result = await act .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'createNewVersion.yml'), mockSteps: testMockSteps, actor: 'Dummy Author', logFile: utils.getLogFilePath('createNewVersion'), @@ -131,7 +131,7 @@ describe('test workflow createNewVersion', () => { }; const result = await act .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'createNewVersion.yml'), mockSteps: testMockSteps, actor: 'Dummy Author', logFile: utils.getLogFilePath('createNewVersion'), @@ -172,7 +172,7 @@ describe('test workflow createNewVersion', () => { ); const result = await act .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'createNewVersion.yml'), mockSteps: testMockSteps, actor: 'Dummy Author', logFile: utils.getLogFilePath('createNewVersion'), @@ -202,7 +202,7 @@ describe('test workflow createNewVersion', () => { }; const result = await act .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'createNewVersion.yml'), mockSteps: testMockSteps, actor: 'Dummy Author', logFile: utils.getLogFilePath('createNewVersion'), diff --git a/workflow_tests/deploy.test.js b/workflow_tests/deploy.test.js index c0faf050c426..72f5c91a1300 100644 --- a/workflow_tests/deploy.test.js +++ b/workflow_tests/deploy.test.js @@ -57,7 +57,7 @@ describe('test workflow deploy', () => { }; const result = await act .runEvent('push', { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'deploy.yml'), mockSteps: testMockSteps, actor: 'OSBotify', logFile: utils.getLogFilePath('deploy'), @@ -90,7 +90,7 @@ describe('test workflow deploy', () => { }; const result = await act .runEvent('push', { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'deploy.yml'), mockSteps: testMockSteps, actor: 'OSBotify', logFile: utils.getLogFilePath('deploy'), @@ -123,7 +123,7 @@ describe('test workflow deploy', () => { }; const result = await act .runEvent('push', { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'deploy.yml'), mockSteps: testMockSteps, actor: 'OSBotify', logFile: utils.getLogFilePath('deploy'), @@ -157,7 +157,7 @@ describe('test workflow deploy', () => { }; const result = await act .runEvent('push', { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'deploy.yml'), mockSteps: testMockSteps, actor: 'Dummy Author', logFile: utils.getLogFilePath('deploy'), @@ -190,7 +190,7 @@ describe('test workflow deploy', () => { }; const result = await act .runEvent('push', { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'deploy.yml'), mockSteps: testMockSteps, actor: 'Dummy Author', logFile: utils.getLogFilePath('deploy'), @@ -223,7 +223,7 @@ describe('test workflow deploy', () => { }; const result = await act .runEvent('push', { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'deploy.yml'), mockSteps: testMockSteps, actor: 'Dummy Author', logFile: utils.getLogFilePath('deploy'), @@ -257,7 +257,7 @@ describe('test workflow deploy', () => { ); let result = await act .runEvent('pull_request', { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'deploy.yml'), mockSteps: testMockSteps, actor: 'Dummy Author', logFile: utils.getLogFilePath('deploy'), @@ -279,7 +279,7 @@ describe('test workflow deploy', () => { ); result = await act .runEvent('workflow_dispatch', { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'deploy.yml'), mockSteps: testMockSteps, actor: 'Dummy Author', logFile: utils.getLogFilePath('deploy'), diff --git a/workflow_tests/deployBlocker.test.js b/workflow_tests/deployBlocker.test.js index 7009fc1bf065..6a86636cd62e 100644 --- a/workflow_tests/deployBlocker.test.js +++ b/workflow_tests/deployBlocker.test.js @@ -74,7 +74,7 @@ describe('test workflow deployBlocker', () => { }; const result = await act .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'deployBlocker.yml'), mockSteps: testMockSteps, actor, logFile: utils.getLogFilePath('deployBlocker'), @@ -111,7 +111,7 @@ describe('test workflow deployBlocker', () => { ); const result = await act .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'deployBlocker.yml'), mockSteps: testMockSteps, actor, logFile: utils.getLogFilePath('deployBlocker'), @@ -142,7 +142,7 @@ describe('test workflow deployBlocker', () => { }; const result = await act .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'deployBlocker.yml'), mockSteps: testMockSteps, actor, logFile: utils.getLogFilePath('deployBlocker'), diff --git a/workflow_tests/finishReleaseCycle.test.js b/workflow_tests/finishReleaseCycle.test.js index 5f79bcca5a0b..994b154142e2 100644 --- a/workflow_tests/finishReleaseCycle.test.js +++ b/workflow_tests/finishReleaseCycle.test.js @@ -67,7 +67,7 @@ describe('test workflow finishReleaseCycle', () => { }; const result = await act .runEvent('issues', { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'finishReleaseCycle.yml'), mockSteps: testMockSteps, actor: 'Dummy Author', logFile: utils.getLogFilePath('finishReleaseCycle'), @@ -119,7 +119,7 @@ describe('test workflow finishReleaseCycle', () => { ); const result = await act .runEvent('issues', { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'finishReleaseCycle.yml'), mockSteps: testMockSteps, actor: 'Dummy Author', logFile: utils.getLogFilePath('finishReleaseCycle'), @@ -163,7 +163,7 @@ describe('test workflow finishReleaseCycle', () => { }; const result = await act .runEvent('issues', { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'finishReleaseCycle.yml'), mockSteps: testMockSteps, actor: 'Dummy Author', logFile: utils.getLogFilePath('finishReleaseCycle'), @@ -207,7 +207,7 @@ describe('test workflow finishReleaseCycle', () => { }; const result = await act .runEvent('issues', { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'finishReleaseCycle.yml'), mockSteps: testMockSteps, actor: 'Dummy Author', logFile: utils.getLogFilePath('finishReleaseCycle'), @@ -253,7 +253,7 @@ describe('test workflow finishReleaseCycle', () => { }; const result = await act .runEvent('issues', { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'finishReleaseCycle.yml'), mockSteps: testMockSteps, actor: 'Dummy Author', logFile: utils.getLogFilePath('finishReleaseCycle'), diff --git a/workflow_tests/lint.test.js b/workflow_tests/lint.test.js index 71810f6acc21..efdabb319bc3 100644 --- a/workflow_tests/lint.test.js +++ b/workflow_tests/lint.test.js @@ -55,7 +55,7 @@ describe('test workflow lint', () => { }; const result = await act .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'lint.yml'), mockSteps: testMockSteps, actor, logFile: utils.getLogFilePath('lint'), @@ -81,7 +81,7 @@ describe('test workflow lint', () => { }; const result = await act .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'lint.yml'), mockSteps: testMockSteps, actor: testActor, logFile: utils.getLogFilePath('lint'), @@ -113,7 +113,7 @@ describe('test workflow lint', () => { }; const result = await act .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'lint.yml'), mockSteps: testMockSteps, actor, logFile: utils.getLogFilePath('lint'), @@ -139,7 +139,7 @@ describe('test workflow lint', () => { }; const result = await act .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'lint.yml'), mockSteps: testMockSteps, actor: testActor, logFile: utils.getLogFilePath('lint'), @@ -169,7 +169,7 @@ describe('test workflow lint', () => { }; const result = await act .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'lint.yml'), mockSteps: testMockSteps, actor, logFile: utils.getLogFilePath('lint'), diff --git a/workflow_tests/lockDeploys.test.js b/workflow_tests/lockDeploys.test.js index dd048fcf2d57..06543c1348f5 100644 --- a/workflow_tests/lockDeploys.test.js +++ b/workflow_tests/lockDeploys.test.js @@ -72,7 +72,7 @@ describe('test workflow lockDeploys', () => { }; const result = await act .runEvent('issues', { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'lockDeploys.yml'), mockSteps: testMockSteps, actor: 'Dummy Author', logFile: utils.getLogFilePath('lockDeploys'), @@ -127,7 +127,7 @@ describe('test workflow lockDeploys', () => { ); const result = await act .runEvent('issues', { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'lockDeploys.yml'), mockSteps: testMockSteps, actor: 'Dummy Author', logFile: utils.getLogFilePath('lockDeploys'), @@ -174,7 +174,7 @@ describe('test workflow lockDeploys', () => { }; const result = await act .runEvent('issues', { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'lockDeploys.yml'), mockSteps: testMockSteps, actor: 'OSBotify', logFile: utils.getLogFilePath('lockDeploys'), @@ -225,7 +225,7 @@ describe('test workflow lockDeploys', () => { }; const result = await act .runEvent('issues', { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'lockDeploys.yml'), mockSteps: testMockSteps, actor: 'Dummy Author', logFile: utils.getLogFilePath('lockDeploys'), @@ -274,7 +274,7 @@ describe('test workflow lockDeploys', () => { }; const result = await act .runEvent('issues', { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'lockDeploys.yml'), mockSteps: testMockSteps, actor: 'OSBotify', logFile: utils.getLogFilePath('lockDeploys'), @@ -325,7 +325,7 @@ describe('test workflow lockDeploys', () => { }; const result = await act .runEvent('issues', { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'lockDeploys.yml'), mockSteps: testMockSteps, actor: 'Dummy Author', logFile: utils.getLogFilePath('lockDeploys'), @@ -372,7 +372,7 @@ describe('test workflow lockDeploys', () => { }; const result = await act .runEvent('issues', { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'lockDeploys.yml'), mockSteps: testMockSteps, actor: 'OSBotify', logFile: utils.getLogFilePath('lockDeploys'), @@ -423,7 +423,7 @@ describe('test workflow lockDeploys', () => { }; const result = await act .runEvent('issues', { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'lockDeploys.yml'), mockSteps: testMockSteps, actor: 'Dummy Author', logFile: utils.getLogFilePath('lockDeploys'), @@ -472,7 +472,7 @@ describe('test workflow lockDeploys', () => { }; const result = await act .runEvent('issues', { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'lockDeploys.yml'), mockSteps: testMockSteps, actor: 'OSBotify', logFile: utils.getLogFilePath('lockDeploys'), diff --git a/workflow_tests/mocks/testBuildMocks.js b/workflow_tests/mocks/testBuildMocks.js index 5c934716a772..a8a3d77150b5 100644 --- a/workflow_tests/mocks/testBuildMocks.js +++ b/workflow_tests/mocks/testBuildMocks.js @@ -79,6 +79,13 @@ const TESTBUILD__ANDROID__CHECKOUT__STEP_MOCK = utils.createMockStep( ['ref'], [], ); +const TESTBUILD__ANDROID__CREATE_ENV_ADHOC__STEP_MOCK = utils.createMockStep( + 'Create .env.adhoc file based on staging and add PULL_REQUEST_NUMBER env to it', + 'Creating .env.adhoc file based on staging', + 'ANDROID', + [], + [], +); const TESTBUILD__ANDROID__SETUP_NODE__STEP_MOCK = utils.createMockStep( 'Setup Node', 'Setup Node', @@ -130,6 +137,7 @@ const TESTBUILD__ANDROID__UPLOAD_ARTIFACT__STEP_MOCK = utils.createMockStep( ); const TESTBUILD__ANDROID__STEP_MOCKS = [ TESTBUILD__ANDROID__CHECKOUT__STEP_MOCK, + TESTBUILD__ANDROID__CREATE_ENV_ADHOC__STEP_MOCK, TESTBUILD__ANDROID__SETUP_NODE__STEP_MOCK, TESTBUILD__ANDROID__SETUP_RUBY__STEP_MOCK, TESTBUILD__ANDROID__DECRYPT_KEYSTORE__STEP_MOCK, @@ -147,6 +155,13 @@ const TESTBUILD__IOS__CHECKOUT__STEP_MOCK = utils.createMockStep( ['ref'], [], ); +const TESTBUILD__IOS__CREATE_ENV_ADHOC__STEP_MOCK = utils.createMockStep( + 'Create .env.adhoc file based on staging and add PULL_REQUEST_NUMBER env to it', + 'Creating .env.adhoc file based on staging', + 'IOS', + [], + [], +); const TESTBUILD__IOS__SETUP_NODE__STEP_MOCK = utils.createMockStep( 'Setup Node', 'Setup Node', @@ -205,6 +220,7 @@ const TESTBUILD__IOS__UPLOAD_ARTIFACT__STEP_MOCK = utils.createMockStep( ); const TESTBUILD__IOS__STEP_MOCKS = [ TESTBUILD__IOS__CHECKOUT__STEP_MOCK, + TESTBUILD__IOS__CREATE_ENV_ADHOC__STEP_MOCK, TESTBUILD__IOS__SETUP_NODE__STEP_MOCK, TESTBUILD__IOS__SETUP_RUBY__STEP_MOCK, TESTBUILD__IOS__INSTALL_COCOAPODS__STEP_MOCK, @@ -223,6 +239,13 @@ const TESTBUILD__DESKTOP__CHECKOUT__STEP_MOCK = utils.createMockStep( ['ref', 'fetch-depth'], [], ); +const TESTBUILD__DESKTOP__CREATE_ENV_ADHOC__STEP_MOCK = utils.createMockStep( + 'Create .env.adhoc file based on staging and add PULL_REQUEST_NUMBER env to it', + 'Creating .env.adhoc file based on staging', + 'DESKTOP', + [], + [], +); const TESTBUILD__DESKTOP__SETUP_NODE__STEP_MOCK = utils.createMockStep( 'Setup Node', 'Setup Node', @@ -253,6 +276,7 @@ const TESTBUILD__DESKTOP__BUILD_DESKTOP_APP_FOR_TESTING__STEP_MOCK = utils.creat ); const TESTBUILD__DESKTOP__STEP_MOCKS = [ TESTBUILD__DESKTOP__CHECKOUT__STEP_MOCK, + TESTBUILD__DESKTOP__CREATE_ENV_ADHOC__STEP_MOCK, TESTBUILD__DESKTOP__SETUP_NODE__STEP_MOCK, TESTBUILD__DESKTOP__DECRYPT_DEVELOPER_ID_CERTIFICATE__STEP_MOCK, TESTBUILD__DESKTOP__CONFIGURE_AWS_CREDENTIALS__STEP_MOCK, @@ -267,6 +291,13 @@ const TESTBUILD__WEB__CHECKOUT__STEP_MOCK = utils.createMockStep( ['fetch-depth', 'ref'], [], ); +const TESTBUILD__WEB__CREATE_ENV_ADHOC__STEP_MOCK = utils.createMockStep( + 'Create .env.adhoc file based on staging and add PULL_REQUEST_NUMBER env to it', + 'Creating .env.adhoc file based on staging', + 'WEB', + [], + [], +); const TESTBUILD__WEB__SETUP_NODE__STEP_MOCK = utils.createMockStep( 'Setup Node', 'Setup Node', @@ -304,6 +335,7 @@ const TESTBUILD__WEB__DEPLOY_TO_S3_FOR_INTERNAL_TESTING__STEP_MOCK = utils.creat ); const TESTBUILD__WEB__STEP_MOCKS = [ TESTBUILD__WEB__CHECKOUT__STEP_MOCK, + TESTBUILD__WEB__CREATE_ENV_ADHOC__STEP_MOCK, TESTBUILD__WEB__SETUP_NODE__STEP_MOCK, TESTBUILD__WEB__CONFIGURE_AWS_CREDENTIALS__STEP_MOCK, TESTBUILD__WEB__BUILD_WEB_FOR_TESTING__STEP_MOCK, @@ -332,7 +364,7 @@ const TESTBUILD__POSTGITHUBCOMMENT__READ_JSONS_WITH_ANDROID_PATHS__STEP_MOCK = u 'POSTGITHUBCOMMENT', [], [], - {android_paths: '{\\"html_path\\": \\"http://dummy.android.link\\"}'}, + {android_path: 'http://dummy.android.link'}, ); const TESTBUILD__POSTGITHUBCOMMENT__READ_JSONS_WITH_IOS_PATHS__STEP_MOCK = utils.createMockStep( 'Read JSONs with iOS paths', @@ -340,7 +372,7 @@ const TESTBUILD__POSTGITHUBCOMMENT__READ_JSONS_WITH_IOS_PATHS__STEP_MOCK = utils 'POSTGITHUBCOMMENT', [], [], - {ios_paths: '{\\"html_path\\": \\"http://dummy.ios.link\\"}'}, + {ios_path: 'http://dummy.ios.link'}, ); const TESTBUILD__POSTGITHUBCOMMENT__MAINTAIN_COMMENT__STEP_MOCK = utils.createMockStep( 'maintain-comment', diff --git a/workflow_tests/platformDeploy.test.js b/workflow_tests/platformDeploy.test.js index 85ed23ce409b..c8a93c30abeb 100644 --- a/workflow_tests/platformDeploy.test.js +++ b/workflow_tests/platformDeploy.test.js @@ -92,7 +92,7 @@ describe('test workflow platformDeploy', () => { }; const result = await act .runEvent('push', { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'platformDeploy.yml'), mockSteps: testMockSteps, actor: 'Dummy Author', logFile: utils.getLogFilePath('platformDeploy'), @@ -165,7 +165,7 @@ describe('test workflow platformDeploy', () => { }; const result = await act .runEvent('push', { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'platformDeploy.yml'), mockSteps: testMockSteps, actor: 'OSBotify', logFile: utils.getLogFilePath('platformDeploy'), @@ -238,7 +238,7 @@ describe('test workflow platformDeploy', () => { }; const result = await act .runEvent('push', { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'platformDeploy.yml'), mockSteps: testMockSteps, actor: 'Dummy Author', logFile: utils.getLogFilePath('platformDeploy'), @@ -254,10 +254,5 @@ describe('test workflow platformDeploy', () => { assertions.assertPostGithubCommentJobExecuted(result, true, false, false); }); }); - - describe('branch', () => { - // changing ref_type does not seem to work as described in documentation - - }); }); }); diff --git a/workflow_tests/preDeploy.test.js b/workflow_tests/preDeploy.test.js index 2783e4aecf75..e1729f48b3c9 100644 --- a/workflow_tests/preDeploy.test.js +++ b/workflow_tests/preDeploy.test.js @@ -71,7 +71,7 @@ describe('test workflow preDeploy', () => { // run an event and get the result const result = await act .runEvent('push', { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), mockSteps: testMockSteps, actor: 'Dummy Tester', logFile: utils.getLogFilePath('preDeploy'), @@ -117,7 +117,7 @@ describe('test workflow preDeploy', () => { ); let result = await act .runEvent('pull_request', { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), mockSteps: testMockSteps, actor: 'Dummy Tester', logFile: utils.getLogFilePath('preDeploy'), @@ -142,7 +142,7 @@ describe('test workflow preDeploy', () => { ); result = await act .runEvent('workflow_dispatch', { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), mockSteps: testMockSteps, actor: 'Dummy Tester', logFile: utils.getLogFilePath('preDeploy'), @@ -195,7 +195,7 @@ describe('test workflow preDeploy', () => { }; const result = await act .runEvent('push', { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), mockSteps: testMockSteps, actor: 'Dummy Tester', logFile: utils.getLogFilePath('preDeploy'), @@ -274,7 +274,7 @@ describe('test workflow preDeploy', () => { }; const result = await act .runEvent('push', { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), mockSteps: testMockSteps, actor: 'Dummy Tester', logFile: utils.getLogFilePath('preDeploy'), @@ -342,7 +342,7 @@ describe('test workflow preDeploy', () => { }; const result = await act .runEvent('push', { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), mockSteps: testMockSteps, actor: 'Dummy Tester', logFile: utils.getLogFilePath('preDeploy'), @@ -385,7 +385,7 @@ describe('test workflow preDeploy', () => { }; const result = await act .runEvent('push', { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), mockSteps: testMockSteps, actor: 'OSBotify', logFile: utils.getLogFilePath('preDeploy'), @@ -424,7 +424,7 @@ describe('test workflow preDeploy', () => { }; const result = await act .runEvent('push', { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), mockSteps: testMockSteps, actor: 'Dummy Tester', logFile: utils.getLogFilePath('preDeploy'), @@ -463,7 +463,7 @@ describe('test workflow preDeploy', () => { }; const result = await act .runEvent('push', { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), mockSteps: testMockSteps, actor: 'Dummy Tester', logFile: utils.getLogFilePath('preDeploy'), @@ -502,7 +502,7 @@ describe('test workflow preDeploy', () => { }; const result = await act .runEvent('push', { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), mockSteps: testMockSteps, actor: 'Dummy Tester', logFile: utils.getLogFilePath('preDeploy'), @@ -543,7 +543,7 @@ describe('test workflow preDeploy', () => { }; const result = await act .runEvent('push', { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), mockSteps: testMockSteps, actor: 'Dummy Tester', logFile: utils.getLogFilePath('preDeploy'), @@ -583,7 +583,7 @@ describe('test workflow preDeploy', () => { }; const result = await act .runEvent('push', { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), mockSteps: testMockSteps, actor: 'OSBotify', logFile: utils.getLogFilePath('preDeploy'), @@ -629,7 +629,7 @@ describe('test workflow preDeploy', () => { }; const result = await act .runEvent('push', { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), mockSteps: testMockSteps, actor: 'Dummy Tester', logFile: utils.getLogFilePath('preDeploy'), @@ -672,7 +672,7 @@ describe('test workflow preDeploy', () => { }; const result = await act .runEvent('push', { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), mockSteps: testMockSteps, actor: 'OSBotify', logFile: utils.getLogFilePath('preDeploy'), @@ -720,7 +720,7 @@ describe('test workflow preDeploy', () => { }; const result = await act .runEvent('push', { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), mockSteps: testMockSteps, actor: 'Dummy Tester', logFile: utils.getLogFilePath('preDeploy'), @@ -764,7 +764,7 @@ describe('test workflow preDeploy', () => { }; const result = await act .runEvent('push', { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), mockSteps: testMockSteps, actor: 'OSBotify', logFile: utils.getLogFilePath('preDeploy'), @@ -810,7 +810,7 @@ describe('test workflow preDeploy', () => { }; const result = await act .runEvent('push', { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), mockSteps: testMockSteps, actor: 'Dummy Tester', logFile: utils.getLogFilePath('preDeploy'), @@ -854,7 +854,7 @@ describe('test workflow preDeploy', () => { }; const result = await act .runEvent('push', { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), mockSteps: testMockSteps, actor: 'OSBotify', logFile: utils.getLogFilePath('preDeploy'), @@ -899,7 +899,7 @@ describe('test workflow preDeploy', () => { testMockSteps.updateStaging[3].mockWith = 'exit 1'; const result = await act .runEvent('push', { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), mockSteps: testMockSteps, actor: 'OSBotify', logFile: utils.getLogFilePath('preDeploy'), diff --git a/workflow_tests/reviewerChecklist.test.js b/workflow_tests/reviewerChecklist.test.js index 69eaf3b7ab4d..5c4ce9870562 100644 --- a/workflow_tests/reviewerChecklist.test.js +++ b/workflow_tests/reviewerChecklist.test.js @@ -52,7 +52,7 @@ describe('test workflow reviewerChecklist', () => { }; const result = await act .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'reviewerChecklist.yml'), mockSteps: testMockSteps, actor, logFile: utils.getLogFilePath('reviewerChecklist'), @@ -78,7 +78,7 @@ describe('test workflow reviewerChecklist', () => { }; const result = await act .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'reviewerChecklist.yml'), mockSteps: testMockSteps, actor: osbotifyActor, logFile: utils.getLogFilePath('reviewerChecklist'), diff --git a/workflow_tests/test.test.js b/workflow_tests/test.test.js index 21f973519927..519d4db1f278 100644 --- a/workflow_tests/test.test.js +++ b/workflow_tests/test.test.js @@ -58,7 +58,7 @@ describe('test workflow test', () => { }; const result = await act .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'test.yml'), mockSteps: testMockSteps, actor, logFile: utils.getLogFilePath('test'), @@ -85,7 +85,7 @@ describe('test workflow test', () => { }; const result = await act .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'test.yml'), mockSteps: testMockSteps, actor: osbotifyActor, logFile: utils.getLogFilePath('test'), @@ -119,7 +119,7 @@ describe('test workflow test', () => { }; const result = await act .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'test.yml'), mockSteps: testMockSteps, actor, logFile: utils.getLogFilePath('test'), @@ -146,7 +146,7 @@ describe('test workflow test', () => { }; const result = await act .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'test.yml'), mockSteps: testMockSteps, actor: osbotifyActor, logFile: utils.getLogFilePath('test'), @@ -178,7 +178,7 @@ describe('test workflow test', () => { }; const result = await act .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'test.yml'), mockSteps: testMockSteps, actor, logFile: utils.getLogFilePath('test'), @@ -205,7 +205,7 @@ describe('test workflow test', () => { }; const result = await act .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'test.yml'), mockSteps: testMockSteps, actor: osbotifyActor, logFile: utils.getLogFilePath('test'), diff --git a/workflow_tests/testBuild.test.js b/workflow_tests/testBuild.test.js index 68d371c2561e..b3844512c74a 100644 --- a/workflow_tests/testBuild.test.js +++ b/workflow_tests/testBuild.test.js @@ -79,7 +79,7 @@ describe('test workflow testBuild', () => { }; const result = await act .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'testBuild.yml'), mockSteps: testMockSteps, actor, logFile: utils.getLogFilePath('testBuild'), @@ -123,7 +123,7 @@ describe('test workflow testBuild', () => { }; const result = await act .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'testBuild.yml'), mockSteps: testMockSteps, actor, logFile: utils.getLogFilePath('testBuild'), @@ -168,7 +168,7 @@ describe('test workflow testBuild', () => { }; const result = await act .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'testBuild.yml'), mockSteps: testMockSteps, actor, logFile: utils.getLogFilePath('testBuild'), @@ -213,7 +213,7 @@ describe('test workflow testBuild', () => { }; const result = await act .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'testBuild.yml'), mockSteps: testMockSteps, actor, logFile: utils.getLogFilePath('testBuild'), @@ -256,7 +256,7 @@ describe('test workflow testBuild', () => { web: mocks.TESTBUILD__WEB__STEP_MOCKS, postGithubComment: mocks.TESTBUILD__POSTGITHUBCOMMENT__STEP_MOCKS, }; - testMockSteps.android[3] = utils.createMockStep( + testMockSteps.android[4] = utils.createMockStep( 'Decrypt keystore', 'Decrypt keystore', 'ANDROID', @@ -268,7 +268,7 @@ describe('test workflow testBuild', () => { ); const result = await act .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'testBuild.yml'), mockSteps: testMockSteps, actor, logFile: utils.getLogFilePath('testBuild'), @@ -276,7 +276,7 @@ describe('test workflow testBuild', () => { assertions.assertValidateActorJobExecuted(result, actor, '1234'); assertions.assertGetBranchRefJobExecuted(result); - assertions.assertAndroidJobExecuted(result, 'test-ref', true, 3); + assertions.assertAndroidJobExecuted(result, 'test-ref', true, 4); assertions.assertIOSJobExecuted(result, 'test-ref'); assertions.assertDesktopJobExecuted(result, 'test-ref'); assertions.assertWebJobExecuted(result, 'test-ref'); @@ -311,7 +311,7 @@ describe('test workflow testBuild', () => { web: mocks.TESTBUILD__WEB__STEP_MOCKS, postGithubComment: mocks.TESTBUILD__POSTGITHUBCOMMENT__STEP_MOCKS, }; - testMockSteps.iOS[3] = utils.createMockStep( + testMockSteps.iOS[4] = utils.createMockStep( 'Install cocoapods', 'Install cocoapods', 'IOS', @@ -323,7 +323,7 @@ describe('test workflow testBuild', () => { ); const result = await act .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'testBuild.yml'), mockSteps: testMockSteps, actor, logFile: utils.getLogFilePath('testBuild'), @@ -332,7 +332,7 @@ describe('test workflow testBuild', () => { assertions.assertValidateActorJobExecuted(result, actor, '1234'); assertions.assertGetBranchRefJobExecuted(result); assertions.assertAndroidJobExecuted(result, 'test-ref'); - assertions.assertIOSJobExecuted(result, 'test-ref', true, 3); + assertions.assertIOSJobExecuted(result, 'test-ref', true, 4); assertions.assertDesktopJobExecuted(result, 'test-ref'); assertions.assertWebJobExecuted(result, 'test-ref'); assertions.assertPostGithubCommentJobExecuted(result, 'test-ref', '1234', true, 'success', 'failure', 'success', 'success'); @@ -366,7 +366,7 @@ describe('test workflow testBuild', () => { web: mocks.TESTBUILD__WEB__STEP_MOCKS, postGithubComment: mocks.TESTBUILD__POSTGITHUBCOMMENT__STEP_MOCKS, }; - testMockSteps.desktop[2] = utils.createMockStep( + testMockSteps.desktop[3] = utils.createMockStep( 'Decrypt Developer ID Certificate', 'Decrypt Developer ID Certificate', 'DESKTOP', @@ -378,7 +378,7 @@ describe('test workflow testBuild', () => { ); const result = await act .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'testBuild.yml'), mockSteps: testMockSteps, actor, logFile: utils.getLogFilePath('testBuild'), @@ -388,7 +388,7 @@ describe('test workflow testBuild', () => { assertions.assertGetBranchRefJobExecuted(result); assertions.assertAndroidJobExecuted(result, 'test-ref'); assertions.assertIOSJobExecuted(result, 'test-ref'); - assertions.assertDesktopJobExecuted(result, 'test-ref', true, 2); + assertions.assertDesktopJobExecuted(result, 'test-ref', true, 3); assertions.assertWebJobExecuted(result, 'test-ref'); assertions.assertPostGithubCommentJobExecuted(result, 'test-ref', '1234', true, 'success', 'success', 'failure', 'success'); }); @@ -421,7 +421,7 @@ describe('test workflow testBuild', () => { web: utils.deepCopy(mocks.TESTBUILD__WEB__STEP_MOCKS), postGithubComment: mocks.TESTBUILD__POSTGITHUBCOMMENT__STEP_MOCKS, }; - testMockSteps.web[2] = utils.createMockStep( + testMockSteps.web[3] = utils.createMockStep( 'Configure AWS Credentials', 'Configure AWS Credentials', 'WEB', @@ -433,7 +433,7 @@ describe('test workflow testBuild', () => { ); const result = await act .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'testBuild.yml'), mockSteps: testMockSteps, actor, logFile: utils.getLogFilePath('testBuild'), @@ -444,7 +444,7 @@ describe('test workflow testBuild', () => { assertions.assertAndroidJobExecuted(result, 'test-ref'); assertions.assertIOSJobExecuted(result, 'test-ref'); assertions.assertDesktopJobExecuted(result, 'test-ref'); - assertions.assertWebJobExecuted(result, 'test-ref', true, 2); + assertions.assertWebJobExecuted(result, 'test-ref', true, 3); assertions.assertPostGithubCommentJobExecuted(result, 'test-ref', '1234', true, 'success', 'success', 'success', 'failure'); }); }); @@ -488,7 +488,7 @@ describe('test workflow testBuild', () => { }; const result = await act .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'testBuild.yml'), mockSteps: testMockSteps, actor, logFile: utils.getLogFilePath('testBuild'), @@ -531,7 +531,7 @@ describe('test workflow testBuild', () => { }; const result = await act .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'testBuild.yml'), mockSteps: testMockSteps, actor, logFile: utils.getLogFilePath('testBuild'), @@ -575,7 +575,7 @@ describe('test workflow testBuild', () => { }; const result = await act .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'testBuild.yml'), mockSteps: testMockSteps, actor, logFile: utils.getLogFilePath('testBuild'), @@ -619,7 +619,7 @@ describe('test workflow testBuild', () => { }; const result = await act .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'testBuild.yml'), mockSteps: testMockSteps, actor, logFile: utils.getLogFilePath('testBuild'), @@ -674,7 +674,7 @@ describe('test workflow testBuild', () => { }; const result = await act .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'testBuild.yml'), mockSteps: testMockSteps, actor, logFile: utils.getLogFilePath('testBuild'), @@ -717,7 +717,7 @@ describe('test workflow testBuild', () => { }; const result = await act .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'testBuild.yml'), mockSteps: testMockSteps, actor, logFile: utils.getLogFilePath('testBuild'), @@ -761,7 +761,7 @@ describe('test workflow testBuild', () => { }; const result = await act .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'testBuild.yml'), mockSteps: testMockSteps, actor, logFile: utils.getLogFilePath('testBuild'), @@ -805,7 +805,7 @@ describe('test workflow testBuild', () => { }; const result = await act .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'testBuild.yml'), mockSteps: testMockSteps, actor, logFile: utils.getLogFilePath('testBuild'), @@ -860,7 +860,7 @@ describe('test workflow testBuild', () => { }; const result = await act .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'testBuild.yml'), mockSteps: testMockSteps, actor, logFile: utils.getLogFilePath('testBuild'), @@ -903,7 +903,7 @@ describe('test workflow testBuild', () => { }; const result = await act .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'testBuild.yml'), mockSteps: testMockSteps, actor, logFile: utils.getLogFilePath('testBuild'), @@ -947,7 +947,7 @@ describe('test workflow testBuild', () => { }; const result = await act .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'testBuild.yml'), mockSteps: testMockSteps, actor, logFile: utils.getLogFilePath('testBuild'), @@ -991,7 +991,7 @@ describe('test workflow testBuild', () => { }; const result = await act .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'testBuild.yml'), mockSteps: testMockSteps, actor, logFile: utils.getLogFilePath('testBuild'), diff --git a/workflow_tests/validateGithubActions.test.js b/workflow_tests/validateGithubActions.test.js index b8d1a0c5337e..167151d5a4bf 100644 --- a/workflow_tests/validateGithubActions.test.js +++ b/workflow_tests/validateGithubActions.test.js @@ -55,7 +55,7 @@ describe('test workflow validateGithubActions', () => { }; const result = await act .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'validateGithubActions.yml'), mockSteps: testMockSteps, actor, logFile: utils.getLogFilePath('validateGithubActions'), @@ -85,7 +85,7 @@ describe('test workflow validateGithubActions', () => { }; const result = await act .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'validateGithubActions.yml'), mockSteps: testMockSteps, actor, logFile: utils.getLogFilePath('validateGithubActions'), diff --git a/workflow_tests/verifyPodfile.test.js b/workflow_tests/verifyPodfile.test.js index 5c18f94133c4..f5eef3a40d9a 100644 --- a/workflow_tests/verifyPodfile.test.js +++ b/workflow_tests/verifyPodfile.test.js @@ -61,7 +61,7 @@ describe('test workflow verifyPodfile', () => { }; const result = await act .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'verifyPodfile.yml'), mockSteps: testMockSteps, actor, logFile: utils.getLogFilePath('verifyPodfile'), @@ -91,7 +91,7 @@ describe('test workflow verifyPodfile', () => { }; const result = await act .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'verifyPodfile.yml'), mockSteps: testMockSteps, actor: osbotifyActor, logFile: utils.getLogFilePath('verifyPodfile'), @@ -127,7 +127,7 @@ describe('test workflow verifyPodfile', () => { }; const result = await act .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'verifyPodfile.yml'), mockSteps: testMockSteps, actor, logFile: utils.getLogFilePath('verifyPodfile'), @@ -157,7 +157,7 @@ describe('test workflow verifyPodfile', () => { }; const result = await act .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'verifyPodfile.yml'), mockSteps: testMockSteps, actor: osbotifyActor, logFile: utils.getLogFilePath('verifyPodfile'), diff --git a/workflow_tests/verifySignedCommits.test.js b/workflow_tests/verifySignedCommits.test.js index 7a8549ee5548..5d38266c651f 100644 --- a/workflow_tests/verifySignedCommits.test.js +++ b/workflow_tests/verifySignedCommits.test.js @@ -55,7 +55,7 @@ describe('test workflow verifySignedCommits', () => { }; const result = await act .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'verifySignedCommits.yml'), mockSteps: testMockSteps, actor, logFile: utils.getLogFilePath('verifySignedCommits'), @@ -85,7 +85,7 @@ describe('test workflow verifySignedCommits', () => { }; const result = await act .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'verifySignedCommits.yml'), mockSteps: testMockSteps, actor, logFile: utils.getLogFilePath('verifySignedCommits'), diff --git a/workflow_tests/warnCPLabel.test.js b/workflow_tests/warnCPLabel.test.js index 4ae61d141bf6..4da0be04e1a9 100644 --- a/workflow_tests/warnCPLabel.test.js +++ b/workflow_tests/warnCPLabel.test.js @@ -61,7 +61,7 @@ describe('test workflow warnCPLabel', () => { }; const result = await act .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'warnCPLabel.yml'), mockSteps: testMockSteps, actor, logFile: utils.getLogFilePath('warnCPLabel'), @@ -96,7 +96,7 @@ describe('test workflow warnCPLabel', () => { ); const result = await act .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'warnCPLabel.yml'), mockSteps: testMockSteps, actor, logFile: utils.getLogFilePath('warnCPLabel'), @@ -128,7 +128,7 @@ describe('test workflow warnCPLabel', () => { }; const result = await act .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows'), + workflowFile: path.join(repoPath, '.github', 'workflows', 'warnCPLabel.yml'), mockSteps: testMockSteps, actor, logFile: utils.getLogFilePath('warnCPLabel'), From 7d6f1f84eb0d8ef28d0236287131f0d18cfbecc4 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Mon, 22 May 2023 10:58:38 +0200 Subject: [PATCH 081/504] Remove mock repo dir before tests Added an utils method to force remove all remnants of the mock repo that might be left behind after forcibly terminating the tests previously. The removal happens before all tests See: https://github.com/Expensify/App/issues/13604 --- workflow_tests/authorChecklist.test.js | 7 +++++++ workflow_tests/cherryPick.test.js | 6 ++++++ workflow_tests/cla.test.js | 6 ++++++ workflow_tests/createNewVersion.test.js | 6 ++++++ workflow_tests/deploy.test.js | 6 ++++++ workflow_tests/deployBlocker.test.js | 7 +++++++ workflow_tests/finishReleaseCycle.test.js | 6 ++++++ workflow_tests/lint.test.js | 7 +++++++ workflow_tests/lockDeploys.test.js | 6 ++++++ workflow_tests/platformDeploy.test.js | 6 ++++++ workflow_tests/preDeploy.test.js | 6 ++++++ workflow_tests/reviewerChecklist.test.js | 7 +++++++ workflow_tests/test.test.js | 7 +++++++ workflow_tests/testBuild.test.js | 7 +++++++ workflow_tests/utils/utils.js | 8 ++++++++ workflow_tests/validateGithubActions.test.js | 7 +++++++ workflow_tests/verifyPodfile.test.js | 7 +++++++ workflow_tests/verifySignedCommits.test.js | 7 +++++++ workflow_tests/warnCPLabel.test.js | 7 +++++++ 19 files changed, 126 insertions(+) diff --git a/workflow_tests/authorChecklist.test.js b/workflow_tests/authorChecklist.test.js index cbc849fa4df1..cca43a229d58 100644 --- a/workflow_tests/authorChecklist.test.js +++ b/workflow_tests/authorChecklist.test.js @@ -17,6 +17,13 @@ const FILES_TO_COPY_INTO_TEST_REPO = [ describe('test workflow authorChecklist', () => { const githubToken = 'dummy_github_token'; + + beforeAll(async () => { + // in case of the tests being interrupted without cleanup the mock repo directory may be left behind + // which breaks the next test run, this removes any possible leftovers + utils.removeMockRepoDir(); + }); + beforeEach(async () => { // create a local repository and copy required files mockGithub = new kieMockGithub.MockGithub({ diff --git a/workflow_tests/cherryPick.test.js b/workflow_tests/cherryPick.test.js index a939520ab996..2a3a39db1bcd 100644 --- a/workflow_tests/cherryPick.test.js +++ b/workflow_tests/cherryPick.test.js @@ -16,6 +16,12 @@ const FILES_TO_COPY_INTO_TEST_REPO = [ ]; describe('test workflow cherryPick', () => { + beforeAll(async () => { + // in case of the tests being interrupted without cleanup the mock repo directory may be left behind + // which breaks the next test run, this removes any possible leftovers + utils.removeMockRepoDir(); + }); + beforeEach(async () => { // create a local repository and copy required files mockGithub = new kieMockGithub.MockGithub({ diff --git a/workflow_tests/cla.test.js b/workflow_tests/cla.test.js index 65a8920368ca..d1cbb09bba2f 100644 --- a/workflow_tests/cla.test.js +++ b/workflow_tests/cla.test.js @@ -22,6 +22,12 @@ describe('test workflow cla', () => { const githubToken = 'dummy_github_token'; const actor = 'Dummy Author'; + beforeAll(async () => { + // in case of the tests being interrupted without cleanup the mock repo directory may be left behind + // which breaks the next test run, this removes any possible leftovers + utils.removeMockRepoDir(); + }); + beforeEach(async () => { // create a local repository and copy required files mockGithub = new kieMockGithub.MockGithub({ diff --git a/workflow_tests/createNewVersion.test.js b/workflow_tests/createNewVersion.test.js index 87455f156590..3b1d1631f7cc 100644 --- a/workflow_tests/createNewVersion.test.js +++ b/workflow_tests/createNewVersion.test.js @@ -16,6 +16,12 @@ const FILES_TO_COPY_INTO_TEST_REPO = [ ]; describe('test workflow createNewVersion', () => { + beforeAll(async () => { + // in case of the tests being interrupted without cleanup the mock repo directory may be left behind + // which breaks the next test run, this removes any possible leftovers + utils.removeMockRepoDir(); + }); + beforeEach(async () => { // create a local repository and copy required files mockGithub = new kieMockGithub.MockGithub({ diff --git a/workflow_tests/deploy.test.js b/workflow_tests/deploy.test.js index 72f5c91a1300..2735533518c9 100644 --- a/workflow_tests/deploy.test.js +++ b/workflow_tests/deploy.test.js @@ -16,6 +16,12 @@ const FILES_TO_COPY_INTO_TEST_REPO = [ ]; describe('test workflow deploy', () => { + beforeAll(async () => { + // in case of the tests being interrupted without cleanup the mock repo directory may be left behind + // which breaks the next test run, this removes any possible leftovers + utils.removeMockRepoDir(); + }); + beforeEach(async () => { // create a local repository and copy required files mockGithub = new kieMockGithub.MockGithub({ diff --git a/workflow_tests/deployBlocker.test.js b/workflow_tests/deployBlocker.test.js index 6a86636cd62e..dfb4191feb79 100644 --- a/workflow_tests/deployBlocker.test.js +++ b/workflow_tests/deployBlocker.test.js @@ -22,6 +22,13 @@ describe('test workflow deployBlocker', () => { OS_BOTIFY_TOKEN: 'dummy_osbotify_token', SLACK_WEBHOOK: 'dummy_slack_webhook', }; + + beforeAll(async () => { + // in case of the tests being interrupted without cleanup the mock repo directory may be left behind + // which breaks the next test run, this removes any possible leftovers + utils.removeMockRepoDir(); + }); + beforeEach(async () => { // create a local repository and copy required files mockGithub = new kieMockGithub.MockGithub({ diff --git a/workflow_tests/finishReleaseCycle.test.js b/workflow_tests/finishReleaseCycle.test.js index 994b154142e2..18db64507c14 100644 --- a/workflow_tests/finishReleaseCycle.test.js +++ b/workflow_tests/finishReleaseCycle.test.js @@ -16,6 +16,12 @@ const FILES_TO_COPY_INTO_TEST_REPO = [ ]; describe('test workflow finishReleaseCycle', () => { + beforeAll(async () => { + // in case of the tests being interrupted without cleanup the mock repo directory may be left behind + // which breaks the next test run, this removes any possible leftovers + utils.removeMockRepoDir(); + }); + beforeEach(async () => { // create a local repository and copy required files mockGithub = new kieMockGithub.MockGithub({ diff --git a/workflow_tests/lint.test.js b/workflow_tests/lint.test.js index efdabb319bc3..5ce2eac7c6ec 100644 --- a/workflow_tests/lint.test.js +++ b/workflow_tests/lint.test.js @@ -18,6 +18,13 @@ const FILES_TO_COPY_INTO_TEST_REPO = [ describe('test workflow lint', () => { const githubToken = 'dummy_github_token'; const actor = 'Dummy Actor'; + + beforeAll(async () => { + // in case of the tests being interrupted without cleanup the mock repo directory may be left behind + // which breaks the next test run, this removes any possible leftovers + utils.removeMockRepoDir(); + }); + beforeEach(async () => { // create a local repository and copy required files mockGithub = new kieMockGithub.MockGithub({ diff --git a/workflow_tests/lockDeploys.test.js b/workflow_tests/lockDeploys.test.js index 06543c1348f5..6f477fe17925 100644 --- a/workflow_tests/lockDeploys.test.js +++ b/workflow_tests/lockDeploys.test.js @@ -16,6 +16,12 @@ const FILES_TO_COPY_INTO_TEST_REPO = [ ]; describe('test workflow lockDeploys', () => { + beforeAll(async () => { + // in case of the tests being interrupted without cleanup the mock repo directory may be left behind + // which breaks the next test run, this removes any possible leftovers + utils.removeMockRepoDir(); + }); + beforeEach(async () => { // create a local repository and copy required files mockGithub = new kieMockGithub.MockGithub({ diff --git a/workflow_tests/platformDeploy.test.js b/workflow_tests/platformDeploy.test.js index c8a93c30abeb..bc2944ae4432 100644 --- a/workflow_tests/platformDeploy.test.js +++ b/workflow_tests/platformDeploy.test.js @@ -16,6 +16,12 @@ const FILES_TO_COPY_INTO_TEST_REPO = [ ]; describe('test workflow platformDeploy', () => { + beforeAll(async () => { + // in case of the tests being interrupted without cleanup the mock repo directory may be left behind + // which breaks the next test run, this removes any possible leftovers + utils.removeMockRepoDir(); + }); + beforeEach(async () => { // create a local repository and copy required files mockGithub = new kieMockGithub.MockGithub({ diff --git a/workflow_tests/preDeploy.test.js b/workflow_tests/preDeploy.test.js index e1729f48b3c9..72fc42457a92 100644 --- a/workflow_tests/preDeploy.test.js +++ b/workflow_tests/preDeploy.test.js @@ -16,6 +16,12 @@ const FILES_TO_COPY_INTO_TEST_REPO = [ ]; describe('test workflow preDeploy', () => { + beforeAll(async () => { + // in case of the tests being interrupted without cleanup the mock repo directory may be left behind + // which breaks the next test run, this removes any possible leftovers + utils.removeMockRepoDir(); + }); + beforeEach(async () => { // create a local repository and copy required files mockGithub = new kieMockGithub.MockGithub({ diff --git a/workflow_tests/reviewerChecklist.test.js b/workflow_tests/reviewerChecklist.test.js index 5c4ce9870562..a742408af4b9 100644 --- a/workflow_tests/reviewerChecklist.test.js +++ b/workflow_tests/reviewerChecklist.test.js @@ -18,6 +18,13 @@ const FILES_TO_COPY_INTO_TEST_REPO = [ describe('test workflow reviewerChecklist', () => { const githubToken = 'dummy_github_token'; const actor = 'Dummy Actor'; + + beforeAll(async () => { + // in case of the tests being interrupted without cleanup the mock repo directory may be left behind + // which breaks the next test run, this removes any possible leftovers + utils.removeMockRepoDir(); + }); + beforeEach(async () => { // create a local repository and copy required files mockGithub = new kieMockGithub.MockGithub({ diff --git a/workflow_tests/test.test.js b/workflow_tests/test.test.js index 519d4db1f278..5a10cb0d9117 100644 --- a/workflow_tests/test.test.js +++ b/workflow_tests/test.test.js @@ -19,6 +19,13 @@ describe('test workflow test', () => { const githubToken = 'dummy_github_token'; const actor = 'Dummy Actor'; const osbotifyActor = 'OSBotify'; + + beforeAll(async () => { + // in case of the tests being interrupted without cleanup the mock repo directory may be left behind + // which breaks the next test run, this removes any possible leftovers + utils.removeMockRepoDir(); + }); + beforeEach(async () => { // create a local repository and copy required files mockGithub = new kieMockGithub.MockGithub({ diff --git a/workflow_tests/testBuild.test.js b/workflow_tests/testBuild.test.js index b3844512c74a..2411c7ac5e7c 100644 --- a/workflow_tests/testBuild.test.js +++ b/workflow_tests/testBuild.test.js @@ -29,6 +29,13 @@ describe('test workflow testBuild', () => { APPLE_ID_PASSWORD: 'dummy_apple_id_password', APPLE_ID: 'dummy_apple_id_value', }; + + beforeAll(async () => { + // in case of the tests being interrupted without cleanup the mock repo directory may be left behind + // which breaks the next test run, this removes any possible leftovers + utils.removeMockRepoDir(); + }); + beforeEach(async () => { // create a local repository and copy required files mockGithub = new kieMockGithub.MockGithub({ diff --git a/workflow_tests/utils/utils.js b/workflow_tests/utils/utils.js index dbe9e79902fa..0516e092cc63 100644 --- a/workflow_tests/utils/utils.js +++ b/workflow_tests/utils/utils.js @@ -160,6 +160,13 @@ function getLogFilePath(workflowName) { return path.resolve(logsDir, `${workflowName}.log`); } +function removeMockRepoDir() { + const mockDirRepo = path.resolve(__dirname, '..', '..', 'repo'); + if (fs.existsSync(mockDirRepo)) { + fs.rmSync(mockDirRepo, {recursive: true, force: true}); + } +} + const FILES_TO_COPY_INTO_TEST_REPO = [ { src: path.resolve(__dirname, '..', '..', '.github', 'actions'), @@ -183,4 +190,5 @@ module.exports = { deepCopy, getLogFilePath, FILES_TO_COPY_INTO_TEST_REPO, + removeMockRepoDir, }; diff --git a/workflow_tests/validateGithubActions.test.js b/workflow_tests/validateGithubActions.test.js index 167151d5a4bf..9f855377b034 100644 --- a/workflow_tests/validateGithubActions.test.js +++ b/workflow_tests/validateGithubActions.test.js @@ -18,6 +18,13 @@ const FILES_TO_COPY_INTO_TEST_REPO = [ describe('test workflow validateGithubActions', () => { const githubToken = 'dummy_github_token'; const actor = 'Dummy Actor'; + + beforeAll(async () => { + // in case of the tests being interrupted without cleanup the mock repo directory may be left behind + // which breaks the next test run, this removes any possible leftovers + utils.removeMockRepoDir(); + }); + beforeEach(async () => { // create a local repository and copy required files mockGithub = new kieMockGithub.MockGithub({ diff --git a/workflow_tests/verifyPodfile.test.js b/workflow_tests/verifyPodfile.test.js index f5eef3a40d9a..393d089080cd 100644 --- a/workflow_tests/verifyPodfile.test.js +++ b/workflow_tests/verifyPodfile.test.js @@ -19,6 +19,13 @@ describe('test workflow verifyPodfile', () => { const githubToken = 'dummy_github_token'; const actor = 'Dummy Actor'; const osbotifyActor = 'OSBotify'; + + beforeAll(async () => { + // in case of the tests being interrupted without cleanup the mock repo directory may be left behind + // which breaks the next test run, this removes any possible leftovers + utils.removeMockRepoDir(); + }); + beforeEach(async () => { // create a local repository and copy required files mockGithub = new kieMockGithub.MockGithub({ diff --git a/workflow_tests/verifySignedCommits.test.js b/workflow_tests/verifySignedCommits.test.js index 5d38266c651f..322ca8813ebc 100644 --- a/workflow_tests/verifySignedCommits.test.js +++ b/workflow_tests/verifySignedCommits.test.js @@ -18,6 +18,13 @@ const FILES_TO_COPY_INTO_TEST_REPO = [ describe('test workflow verifySignedCommits', () => { const githubToken = 'dummy_github_token'; const actor = 'Dummy Actor'; + + beforeAll(async () => { + // in case of the tests being interrupted without cleanup the mock repo directory may be left behind + // which breaks the next test run, this removes any possible leftovers + utils.removeMockRepoDir(); + }); + beforeEach(async () => { // create a local repository and copy required files mockGithub = new kieMockGithub.MockGithub({ diff --git a/workflow_tests/warnCPLabel.test.js b/workflow_tests/warnCPLabel.test.js index 4da0be04e1a9..3b3325847ecc 100644 --- a/workflow_tests/warnCPLabel.test.js +++ b/workflow_tests/warnCPLabel.test.js @@ -18,6 +18,13 @@ const FILES_TO_COPY_INTO_TEST_REPO = [ describe('test workflow warnCPLabel', () => { const githubToken = 'dummy_github_token'; const actor = 'Dummy Actor'; + + beforeAll(async () => { + // in case of the tests being interrupted without cleanup the mock repo directory may be left behind + // which breaks the next test run, this removes any possible leftovers + utils.removeMockRepoDir(); + }); + beforeEach(async () => { // create a local repository and copy required files mockGithub = new kieMockGithub.MockGithub({ From 0b4e066913f55d281fb4b1ec58dc18ab2d462307 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Mon, 22 May 2023 11:03:35 +0200 Subject: [PATCH 082/504] Reorder README Moved setup and running sections of the README up See: https://github.com/Expensify/App/issues/13604 --- workflow_tests/README.md | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/workflow_tests/README.md b/workflow_tests/README.md index 5b2e09f9a33e..70565375cce6 100644 --- a/workflow_tests/README.md +++ b/workflow_tests/README.md @@ -6,19 +6,6 @@ The workflow testing framework consists mainly of 3 components: - [Mock-github](https://github.com/kiegroup/mock-github) - package allowing for creation of local repositories, which can be used to make sure that the workflow tests have access only to these files that they should and that they won't modify the actual repository - [Act-js](https://github.com/kiegroup/act-js) - JS wrapper around [Act](https://github.com/nektos/act). Act is a tool that allows to run GitHub Actions workflows locally, and Act-js allows to configure and run Act from JS code, like Jest tests. It also provides additional tools like mocking workflow steps and retrieving the workflow output a JSON, which allows for comparison of the actual output with expected values -## Limitations -Not all workflows can always be tested this way, for example: -- Act and Act-js do not support all the runner types available in GitHub Actions, like `macOS` runners or some specific version of `Ubuntu` runners like `ubuntu-20.04-64core`. In these cases the job will be omitted entirely and cannot be tested -- Testing more complex workflows in their entirety can be extremely time-consuming and cumbersome. It is often optimal to mock most of the steps with expressions printing the input and output conditions -- Due to the way `Act` and `Act-js` handle workflow output, not much can be checked in the test. What is available, namely whether the job/step executed or not, whether it was successful or not and what its printed output was, should be enough in most scenarios -- `Act` does not seem to support the conditions set on event parameters when determining whether to run the workflow or not, namely for a workflow defined with: -```yaml -on: - pull_request: - types: [opened, edited, reopened] -``` -running `act pull_request -e event_data.json` with `event_data.json` having `{"action": "opened"}` will execute the workflow (as expected), running for example `act push` will not execute it (as expected), but running `act pull_request -e event_data.json` with `event_data.json` having for example `{"action": "assigned"}` **will still execute the workflow** even though it should only be executed with `action` being `opened`, `edited` or `reopened`. This only applies to running the workflow with `Act`, in the GitHub environment it still works as expected - ## Setup - Install dependencies from `package.json` file with `npm install` - Make sure you have fulfilled the [prerequisites](https://github.com/nektos/act#necessary-prerequisites-for-running-act) for running `Act` @@ -40,6 +27,19 @@ running `act pull_request -e event_data.json` with `event_data.json` having `{"a - You can combine these like `npm run workflow-test -- -i workflow_tests/preDeploy.test.js -t "single specific test"` - You can also use all other options which are normally usable with `jest` +## Limitations +Not all workflows can always be tested this way, for example: +- Act and Act-js do not support all the runner types available in GitHub Actions, like `macOS` runners or some specific version of `Ubuntu` runners like `ubuntu-20.04-64core`. In these cases the job will be omitted entirely and cannot be tested +- Testing more complex workflows in their entirety can be extremely time-consuming and cumbersome. It is often optimal to mock most of the steps with expressions printing the input and output conditions +- Due to the way `Act` and `Act-js` handle workflow output, not much can be checked in the test. What is available, namely whether the job/step executed or not, whether it was successful or not and what its printed output was, should be enough in most scenarios +- `Act` does not seem to support the conditions set on event parameters when determining whether to run the workflow or not, namely for a workflow defined with: +```yaml +on: + pull_request: + types: [opened, edited, reopened] +``` +running `act pull_request -e event_data.json` with `event_data.json` having `{"action": "opened"}` will execute the workflow (as expected), running for example `act push` will not execute it (as expected), but running `act pull_request -e event_data.json` with `event_data.json` having for example `{"action": "assigned"}` **will still execute the workflow** even though it should only be executed with `action` being `opened`, `edited` or `reopened`. This only applies to running the workflow with `Act`, in the GitHub environment it still works as expected + ## File structure The testing framework file structure within the repository is as follows: - `App/` - main application folder From eb021d86b6d6cd984dadc9d2f76d5dd79ee3e8a0 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Mon, 22 May 2023 11:24:19 +0200 Subject: [PATCH 083/504] Rework logfiles creation Logfiles are now created 1 per test, not per test suite, in a subdirectory named after the workflow under test See: https://github.com/Expensify/App/issues/13604 --- workflow_tests/authorChecklist.test.js | 12 +++--- workflow_tests/cherryPick.test.js | 38 +++++++++---------- workflow_tests/cla.test.js | 10 ++--- workflow_tests/createNewVersion.test.js | 10 ++--- workflow_tests/deploy.test.js | 16 ++++---- workflow_tests/deployBlocker.test.js | 6 +-- workflow_tests/finishReleaseCycle.test.js | 10 ++--- workflow_tests/lint.test.js | 10 ++--- workflow_tests/lockDeploys.test.js | 18 ++++----- workflow_tests/platformDeploy.test.js | 6 +-- workflow_tests/preDeploy.test.js | 38 +++++++++---------- workflow_tests/reviewerChecklist.test.js | 4 +- workflow_tests/test.test.js | 12 +++--- workflow_tests/testBuild.test.js | 40 ++++++++++---------- workflow_tests/utils/utils.js | 8 +++- workflow_tests/validateGithubActions.test.js | 4 +- workflow_tests/verifyPodfile.test.js | 8 ++-- workflow_tests/verifySignedCommits.test.js | 4 +- workflow_tests/warnCPLabel.test.js | 6 +-- 19 files changed, 132 insertions(+), 128 deletions(-) diff --git a/workflow_tests/authorChecklist.test.js b/workflow_tests/authorChecklist.test.js index cca43a229d58..59a048896a0b 100644 --- a/workflow_tests/authorChecklist.test.js +++ b/workflow_tests/authorChecklist.test.js @@ -66,7 +66,7 @@ describe('test workflow authorChecklist', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'authorChecklist.yml'), mockSteps: testMockSteps, actor, - logFile: utils.getLogFilePath('authorChecklist'), + logFile: utils.getLogFilePath('authorChecklist', expect.getState().currentTestName), }); assertions.assertChecklistJobExecuted(result); @@ -93,7 +93,7 @@ describe('test workflow authorChecklist', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'authorChecklist.yml'), mockSteps: testMockSteps, actor, - logFile: utils.getLogFilePath('authorChecklist'), + logFile: utils.getLogFilePath('authorChecklist', expect.getState().currentTestName), }); assertions.assertChecklistJobExecuted(result, false); @@ -126,7 +126,7 @@ describe('test workflow authorChecklist', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'authorChecklist.yml'), mockSteps: testMockSteps, actor, - logFile: utils.getLogFilePath('authorChecklist'), + logFile: utils.getLogFilePath('authorChecklist', expect.getState().currentTestName), }); assertions.assertChecklistJobExecuted(result); @@ -153,7 +153,7 @@ describe('test workflow authorChecklist', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'authorChecklist.yml'), mockSteps: testMockSteps, actor, - logFile: utils.getLogFilePath('authorChecklist'), + logFile: utils.getLogFilePath('authorChecklist', expect.getState().currentTestName), }); assertions.assertChecklistJobExecuted(result, false); @@ -186,7 +186,7 @@ describe('test workflow authorChecklist', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'authorChecklist.yml'), mockSteps: testMockSteps, actor, - logFile: utils.getLogFilePath('authorChecklist'), + logFile: utils.getLogFilePath('authorChecklist', expect.getState().currentTestName), }); assertions.assertChecklistJobExecuted(result); @@ -213,7 +213,7 @@ describe('test workflow authorChecklist', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'authorChecklist.yml'), mockSteps: testMockSteps, actor, - logFile: utils.getLogFilePath('authorChecklist'), + logFile: utils.getLogFilePath('authorChecklist', expect.getState().currentTestName), }); assertions.assertChecklistJobExecuted(result, false); diff --git a/workflow_tests/cherryPick.test.js b/workflow_tests/cherryPick.test.js index 2a3a39db1bcd..db8a8fbd4f6e 100644 --- a/workflow_tests/cherryPick.test.js +++ b/workflow_tests/cherryPick.test.js @@ -72,7 +72,7 @@ describe('test workflow cherryPick', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), mockSteps: testMockSteps, actor, - logFile: utils.getLogFilePath('cherryPick'), + logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), }); assertions.assertValidateActorJobExecuted(result, actor); @@ -116,7 +116,7 @@ describe('test workflow cherryPick', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), mockSteps: testMockSteps, actor, - logFile: utils.getLogFilePath('cherryPick'), + logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), }); assertions.assertValidateActorJobExecuted(result, actor); @@ -175,7 +175,7 @@ describe('test workflow cherryPick', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), mockSteps: testMockSteps, actor, - logFile: utils.getLogFilePath('cherryPick'), + logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), }); assertions.assertValidateActorJobExecuted(result, actor); @@ -226,7 +226,7 @@ describe('test workflow cherryPick', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), mockSteps: testMockSteps, actor, - logFile: utils.getLogFilePath('cherryPick'), + logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), }); assertions.assertValidateActorJobExecuted(result, actor); @@ -280,7 +280,7 @@ describe('test workflow cherryPick', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), mockSteps: testMockSteps, actor, - logFile: utils.getLogFilePath('cherryPick'), + logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), }); assertions.assertValidateActorJobExecuted(result, actor); @@ -331,7 +331,7 @@ describe('test workflow cherryPick', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), mockSteps: testMockSteps, actor, - logFile: utils.getLogFilePath('cherryPick'), + logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), }); assertions.assertValidateActorJobExecuted(result, actor); @@ -388,7 +388,7 @@ describe('test workflow cherryPick', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), mockSteps: testMockSteps, actor, - logFile: utils.getLogFilePath('cherryPick'), + logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), }); assertions.assertValidateActorJobExecuted(result, actor); @@ -439,7 +439,7 @@ describe('test workflow cherryPick', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), mockSteps: testMockSteps, actor, - logFile: utils.getLogFilePath('cherryPick'), + logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), }); assertions.assertValidateActorJobExecuted(result, actor); @@ -493,7 +493,7 @@ describe('test workflow cherryPick', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), mockSteps: testMockSteps, actor, - logFile: utils.getLogFilePath('cherryPick'), + logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), }); assertions.assertValidateActorJobExecuted(result, actor); @@ -544,7 +544,7 @@ describe('test workflow cherryPick', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), mockSteps: testMockSteps, actor, - logFile: utils.getLogFilePath('cherryPick'), + logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), }); assertions.assertValidateActorJobExecuted(result, actor); @@ -605,7 +605,7 @@ describe('test workflow cherryPick', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), mockSteps: testMockSteps, actor, - logFile: utils.getLogFilePath('cherryPick'), + logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), }); assertions.assertValidateActorJobExecuted(result, actor); @@ -656,7 +656,7 @@ describe('test workflow cherryPick', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), mockSteps: testMockSteps, actor, - logFile: utils.getLogFilePath('cherryPick'), + logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), }); assertions.assertValidateActorJobExecuted(result, actor); @@ -710,7 +710,7 @@ describe('test workflow cherryPick', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), mockSteps: testMockSteps, actor, - logFile: utils.getLogFilePath('cherryPick'), + logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), }); assertions.assertValidateActorJobExecuted(result, actor); @@ -761,7 +761,7 @@ describe('test workflow cherryPick', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), mockSteps: testMockSteps, actor, - logFile: utils.getLogFilePath('cherryPick'), + logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), }); assertions.assertValidateActorJobExecuted(result, actor); @@ -818,7 +818,7 @@ describe('test workflow cherryPick', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), mockSteps: testMockSteps, actor, - logFile: utils.getLogFilePath('cherryPick'), + logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), }); assertions.assertValidateActorJobExecuted(result, actor); @@ -869,7 +869,7 @@ describe('test workflow cherryPick', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), mockSteps: testMockSteps, actor, - logFile: utils.getLogFilePath('cherryPick'), + logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), }); assertions.assertValidateActorJobExecuted(result, actor); @@ -923,7 +923,7 @@ describe('test workflow cherryPick', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), mockSteps: testMockSteps, actor, - logFile: utils.getLogFilePath('cherryPick'), + logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), }); assertions.assertValidateActorJobExecuted(result, actor); @@ -974,7 +974,7 @@ describe('test workflow cherryPick', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), mockSteps: testMockSteps, actor, - logFile: utils.getLogFilePath('cherryPick'), + logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), }); assertions.assertValidateActorJobExecuted(result, actor); @@ -1030,7 +1030,7 @@ describe('test workflow cherryPick', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), mockSteps: testMockSteps, actor: 'Dummy Author', - logFile: utils.getLogFilePath('cherryPick'), + logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), }); assertions.assertValidateActorJobExecuted(result, 'Dummy Author', false); diff --git a/workflow_tests/cla.test.js b/workflow_tests/cla.test.js index d1cbb09bba2f..6ed6ce291395 100644 --- a/workflow_tests/cla.test.js +++ b/workflow_tests/cla.test.js @@ -78,7 +78,7 @@ describe('test workflow cla', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'cla.yml'), mockSteps: testMockSteps, actor, - logFile: utils.getLogFilePath('cla'), + logFile: utils.getLogFilePath('cla', expect.getState().currentTestName), }); assertions.assertCLAJobExecuted(result, commentBody, `${repoPath}/remote/origin`, true, false); @@ -116,7 +116,7 @@ describe('test workflow cla', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'cla.yml'), mockSteps: testMockSteps, actor, - logFile: utils.getLogFilePath('cla'), + logFile: utils.getLogFilePath('cla', expect.getState().currentTestName), }); assertions.assertCLAJobExecuted(result, commentBody, `${repoPath}/remote/origin`, true, true); @@ -154,7 +154,7 @@ describe('test workflow cla', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'cla.yml'), mockSteps: testMockSteps, actor, - logFile: utils.getLogFilePath('cla'), + logFile: utils.getLogFilePath('cla', expect.getState().currentTestName), }); assertions.assertCLAJobExecuted(result, commentBody, `${repoPath}/remote/origin`, true, true); @@ -191,7 +191,7 @@ describe('test workflow cla', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'cla.yml'), mockSteps: testMockSteps, actor, - logFile: utils.getLogFilePath('cla'), + logFile: utils.getLogFilePath('cla', expect.getState().currentTestName), }); assertions.assertCLAJobExecuted(result, '', `${repoPath}/remote/origin`, true, true); @@ -222,7 +222,7 @@ describe('test workflow cla', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'cla.yml'), mockSteps: testMockSteps, actor, - logFile: utils.getLogFilePath('cla'), + logFile: utils.getLogFilePath('cla', expect.getState().currentTestName), }); assertions.assertCLAJobExecuted(result, '', `${repoPath}/remote/origin`, false); diff --git a/workflow_tests/createNewVersion.test.js b/workflow_tests/createNewVersion.test.js index 3b1d1631f7cc..890af650f9ad 100644 --- a/workflow_tests/createNewVersion.test.js +++ b/workflow_tests/createNewVersion.test.js @@ -76,7 +76,7 @@ describe('test workflow createNewVersion', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'createNewVersion.yml'), mockSteps: testMockSteps, actor: 'Dummy Author', - logFile: utils.getLogFilePath('createNewVersion'), + logFile: utils.getLogFilePath('createNewVersion', expect.getState().currentTestName), }); assertions.assertValidateActorJobExecuted(result); assertions.assertCreateNewVersionJobExecuted(result); @@ -108,7 +108,7 @@ describe('test workflow createNewVersion', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'createNewVersion.yml'), mockSteps: testMockSteps, actor: 'Dummy Author', - logFile: utils.getLogFilePath('createNewVersion'), + logFile: utils.getLogFilePath('createNewVersion', expect.getState().currentTestName), }); assertions.assertValidateActorJobExecuted(result); assertions.assertCreateNewVersionJobExecuted(result); @@ -140,7 +140,7 @@ describe('test workflow createNewVersion', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'createNewVersion.yml'), mockSteps: testMockSteps, actor: 'Dummy Author', - logFile: utils.getLogFilePath('createNewVersion'), + logFile: utils.getLogFilePath('createNewVersion', expect.getState().currentTestName), }); assertions.assertValidateActorJobExecuted(result); assertions.assertCreateNewVersionJobExecuted(result, 'BUILD', false); @@ -181,7 +181,7 @@ describe('test workflow createNewVersion', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'createNewVersion.yml'), mockSteps: testMockSteps, actor: 'Dummy Author', - logFile: utils.getLogFilePath('createNewVersion'), + logFile: utils.getLogFilePath('createNewVersion', expect.getState().currentTestName), }); assertions.assertValidateActorJobExecuted(result); assertions.assertCreateNewVersionJobExecuted(result, 'BUILD', true, false); @@ -211,7 +211,7 @@ describe('test workflow createNewVersion', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'createNewVersion.yml'), mockSteps: testMockSteps, actor: 'Dummy Author', - logFile: utils.getLogFilePath('createNewVersion'), + logFile: utils.getLogFilePath('createNewVersion', expect.getState().currentTestName), }); assertions.assertValidateActorJobExecuted(result); assertions.assertCreateNewVersionJobExecuted(result, 'MAJOR'); diff --git a/workflow_tests/deploy.test.js b/workflow_tests/deploy.test.js index 2735533518c9..7d6797b54fba 100644 --- a/workflow_tests/deploy.test.js +++ b/workflow_tests/deploy.test.js @@ -66,7 +66,7 @@ describe('test workflow deploy', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'deploy.yml'), mockSteps: testMockSteps, actor: 'OSBotify', - logFile: utils.getLogFilePath('deploy'), + logFile: utils.getLogFilePath('deploy', expect.getState().currentTestName), }); assertions.assertValidateJobExecuted(result); assertions.assertDeployStagingJobExecuted(result, false); @@ -99,7 +99,7 @@ describe('test workflow deploy', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'deploy.yml'), mockSteps: testMockSteps, actor: 'OSBotify', - logFile: utils.getLogFilePath('deploy'), + logFile: utils.getLogFilePath('deploy', expect.getState().currentTestName), }); assertions.assertValidateJobExecuted(result); assertions.assertDeployStagingJobExecuted(result); @@ -132,7 +132,7 @@ describe('test workflow deploy', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'deploy.yml'), mockSteps: testMockSteps, actor: 'OSBotify', - logFile: utils.getLogFilePath('deploy'), + logFile: utils.getLogFilePath('deploy', expect.getState().currentTestName), }); assertions.assertValidateJobExecuted(result); assertions.assertDeployStagingJobExecuted(result, false); @@ -166,7 +166,7 @@ describe('test workflow deploy', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'deploy.yml'), mockSteps: testMockSteps, actor: 'Dummy Author', - logFile: utils.getLogFilePath('deploy'), + logFile: utils.getLogFilePath('deploy', expect.getState().currentTestName), }); assertions.assertValidateJobExecuted(result); assertions.assertDeployStagingJobExecuted(result, false); @@ -199,7 +199,7 @@ describe('test workflow deploy', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'deploy.yml'), mockSteps: testMockSteps, actor: 'Dummy Author', - logFile: utils.getLogFilePath('deploy'), + logFile: utils.getLogFilePath('deploy', expect.getState().currentTestName), }); assertions.assertValidateJobExecuted(result); assertions.assertDeployStagingJobExecuted(result, false); @@ -232,7 +232,7 @@ describe('test workflow deploy', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'deploy.yml'), mockSteps: testMockSteps, actor: 'Dummy Author', - logFile: utils.getLogFilePath('deploy'), + logFile: utils.getLogFilePath('deploy', expect.getState().currentTestName), }); assertions.assertValidateJobExecuted(result); assertions.assertDeployStagingJobExecuted(result, false); @@ -266,7 +266,7 @@ describe('test workflow deploy', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'deploy.yml'), mockSteps: testMockSteps, actor: 'Dummy Author', - logFile: utils.getLogFilePath('deploy'), + logFile: utils.getLogFilePath('deploy', expect.getState().currentTestName), }); assertions.assertValidateJobExecuted(result, false); assertions.assertDeployStagingJobExecuted(result, false); @@ -288,7 +288,7 @@ describe('test workflow deploy', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'deploy.yml'), mockSteps: testMockSteps, actor: 'Dummy Author', - logFile: utils.getLogFilePath('deploy'), + logFile: utils.getLogFilePath('deploy', expect.getState().currentTestName), }); assertions.assertValidateJobExecuted(result, false); assertions.assertDeployStagingJobExecuted(result, false); diff --git a/workflow_tests/deployBlocker.test.js b/workflow_tests/deployBlocker.test.js index dfb4191feb79..1b3582228310 100644 --- a/workflow_tests/deployBlocker.test.js +++ b/workflow_tests/deployBlocker.test.js @@ -84,7 +84,7 @@ describe('test workflow deployBlocker', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'deployBlocker.yml'), mockSteps: testMockSteps, actor, - logFile: utils.getLogFilePath('deployBlocker'), + logFile: utils.getLogFilePath('deployBlocker', expect.getState().currentTestName), }); assertions.assertDeployBlockerJobExecuted(result, 'Labeled issue title', '1234'); @@ -121,7 +121,7 @@ describe('test workflow deployBlocker', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'deployBlocker.yml'), mockSteps: testMockSteps, actor, - logFile: utils.getLogFilePath('deployBlocker'), + logFile: utils.getLogFilePath('deployBlocker', expect.getState().currentTestName), }); assertions.assertDeployBlockerJobExecuted(result, 'Labeled issue title', '1234', true, false); @@ -152,7 +152,7 @@ describe('test workflow deployBlocker', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'deployBlocker.yml'), mockSteps: testMockSteps, actor, - logFile: utils.getLogFilePath('deployBlocker'), + logFile: utils.getLogFilePath('deployBlocker', expect.getState().currentTestName), }); assertions.assertDeployBlockerJobExecuted(result, '', '', false); diff --git a/workflow_tests/finishReleaseCycle.test.js b/workflow_tests/finishReleaseCycle.test.js index 18db64507c14..a7ea208c66de 100644 --- a/workflow_tests/finishReleaseCycle.test.js +++ b/workflow_tests/finishReleaseCycle.test.js @@ -76,7 +76,7 @@ describe('test workflow finishReleaseCycle', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'finishReleaseCycle.yml'), mockSteps: testMockSteps, actor: 'Dummy Author', - logFile: utils.getLogFilePath('finishReleaseCycle'), + logFile: utils.getLogFilePath('finishReleaseCycle', expect.getState().currentTestName), }); assertions.assertValidateJobExecuted(result, 'Dummy Author', '1234'); assertions.assertUpdateProductionJobExecuted(result); @@ -128,7 +128,7 @@ describe('test workflow finishReleaseCycle', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'finishReleaseCycle.yml'), mockSteps: testMockSteps, actor: 'Dummy Author', - logFile: utils.getLogFilePath('finishReleaseCycle'), + logFile: utils.getLogFilePath('finishReleaseCycle', expect.getState().currentTestName), }); assertions.assertValidateJobExecuted(result, 'Dummy Author', '1234'); assertions.assertUpdateProductionJobExecuted(result); @@ -172,7 +172,7 @@ describe('test workflow finishReleaseCycle', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'finishReleaseCycle.yml'), mockSteps: testMockSteps, actor: 'Dummy Author', - logFile: utils.getLogFilePath('finishReleaseCycle'), + logFile: utils.getLogFilePath('finishReleaseCycle', expect.getState().currentTestName), }); assertions.assertValidateJobExecuted(result, 'Dummy Author', '1234', true, true, true); assertions.assertUpdateProductionJobExecuted(result, false); @@ -216,7 +216,7 @@ describe('test workflow finishReleaseCycle', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'finishReleaseCycle.yml'), mockSteps: testMockSteps, actor: 'Dummy Author', - logFile: utils.getLogFilePath('finishReleaseCycle'), + logFile: utils.getLogFilePath('finishReleaseCycle', expect.getState().currentTestName), }); assertions.assertValidateJobExecuted(result, 'Dummy Author', '1234', true, false, false); assertions.assertUpdateProductionJobExecuted(result, false); @@ -262,7 +262,7 @@ describe('test workflow finishReleaseCycle', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'finishReleaseCycle.yml'), mockSteps: testMockSteps, actor: 'Dummy Author', - logFile: utils.getLogFilePath('finishReleaseCycle'), + logFile: utils.getLogFilePath('finishReleaseCycle', expect.getState().currentTestName), }); assertions.assertValidateJobExecuted(result, 'Dummy Author', '1234', false); assertions.assertUpdateProductionJobExecuted(result, false); diff --git a/workflow_tests/lint.test.js b/workflow_tests/lint.test.js index 5ce2eac7c6ec..16de3ace83ef 100644 --- a/workflow_tests/lint.test.js +++ b/workflow_tests/lint.test.js @@ -65,7 +65,7 @@ describe('test workflow lint', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'lint.yml'), mockSteps: testMockSteps, actor, - logFile: utils.getLogFilePath('lint'), + logFile: utils.getLogFilePath('lint', expect.getState().currentTestName), }); assertions.assertLintJobExecuted(result); @@ -91,7 +91,7 @@ describe('test workflow lint', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'lint.yml'), mockSteps: testMockSteps, actor: testActor, - logFile: utils.getLogFilePath('lint'), + logFile: utils.getLogFilePath('lint', expect.getState().currentTestName), }); assertions.assertLintJobExecuted(result); @@ -123,7 +123,7 @@ describe('test workflow lint', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'lint.yml'), mockSteps: testMockSteps, actor, - logFile: utils.getLogFilePath('lint'), + logFile: utils.getLogFilePath('lint', expect.getState().currentTestName), }); assertions.assertLintJobExecuted(result); @@ -149,7 +149,7 @@ describe('test workflow lint', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'lint.yml'), mockSteps: testMockSteps, actor: testActor, - logFile: utils.getLogFilePath('lint'), + logFile: utils.getLogFilePath('lint', expect.getState().currentTestName), }); assertions.assertLintJobExecuted(result, false); @@ -179,7 +179,7 @@ describe('test workflow lint', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'lint.yml'), mockSteps: testMockSteps, actor, - logFile: utils.getLogFilePath('lint'), + logFile: utils.getLogFilePath('lint', expect.getState().currentTestName), }); assertions.assertLintJobExecuted(result); diff --git a/workflow_tests/lockDeploys.test.js b/workflow_tests/lockDeploys.test.js index 6f477fe17925..81850395e79a 100644 --- a/workflow_tests/lockDeploys.test.js +++ b/workflow_tests/lockDeploys.test.js @@ -81,7 +81,7 @@ describe('test workflow lockDeploys', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'lockDeploys.yml'), mockSteps: testMockSteps, actor: 'Dummy Author', - logFile: utils.getLogFilePath('lockDeploys'), + logFile: utils.getLogFilePath('lockDeploys', expect.getState().currentTestName), }); assertions.assertlockStagingDeploysJobExecuted(result); @@ -136,7 +136,7 @@ describe('test workflow lockDeploys', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'lockDeploys.yml'), mockSteps: testMockSteps, actor: 'Dummy Author', - logFile: utils.getLogFilePath('lockDeploys'), + logFile: utils.getLogFilePath('lockDeploys', expect.getState().currentTestName), }); assertions.assertlockStagingDeploysJobFailedAfterFirstStep(result); @@ -183,7 +183,7 @@ describe('test workflow lockDeploys', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'lockDeploys.yml'), mockSteps: testMockSteps, actor: 'OSBotify', - logFile: utils.getLogFilePath('lockDeploys'), + logFile: utils.getLogFilePath('lockDeploys', expect.getState().currentTestName), }); assertions.assertlockStagingDeploysJobExecuted(result, false); @@ -234,7 +234,7 @@ describe('test workflow lockDeploys', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'lockDeploys.yml'), mockSteps: testMockSteps, actor: 'Dummy Author', - logFile: utils.getLogFilePath('lockDeploys'), + logFile: utils.getLogFilePath('lockDeploys', expect.getState().currentTestName), }); assertions.assertlockStagingDeploysJobExecuted(result, false); @@ -283,7 +283,7 @@ describe('test workflow lockDeploys', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'lockDeploys.yml'), mockSteps: testMockSteps, actor: 'OSBotify', - logFile: utils.getLogFilePath('lockDeploys'), + logFile: utils.getLogFilePath('lockDeploys', expect.getState().currentTestName), }); assertions.assertlockStagingDeploysJobExecuted(result, false); @@ -334,7 +334,7 @@ describe('test workflow lockDeploys', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'lockDeploys.yml'), mockSteps: testMockSteps, actor: 'Dummy Author', - logFile: utils.getLogFilePath('lockDeploys'), + logFile: utils.getLogFilePath('lockDeploys', expect.getState().currentTestName), }); assertions.assertlockStagingDeploysJobExecuted(result, false); @@ -381,7 +381,7 @@ describe('test workflow lockDeploys', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'lockDeploys.yml'), mockSteps: testMockSteps, actor: 'OSBotify', - logFile: utils.getLogFilePath('lockDeploys'), + logFile: utils.getLogFilePath('lockDeploys', expect.getState().currentTestName), }); assertions.assertlockStagingDeploysJobExecuted(result, false); @@ -432,7 +432,7 @@ describe('test workflow lockDeploys', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'lockDeploys.yml'), mockSteps: testMockSteps, actor: 'Dummy Author', - logFile: utils.getLogFilePath('lockDeploys'), + logFile: utils.getLogFilePath('lockDeploys', expect.getState().currentTestName), }); assertions.assertlockStagingDeploysJobExecuted(result, false); @@ -481,7 +481,7 @@ describe('test workflow lockDeploys', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'lockDeploys.yml'), mockSteps: testMockSteps, actor: 'OSBotify', - logFile: utils.getLogFilePath('lockDeploys'), + logFile: utils.getLogFilePath('lockDeploys', expect.getState().currentTestName), }); assertions.assertlockStagingDeploysJobExecuted(result, false); diff --git a/workflow_tests/platformDeploy.test.js b/workflow_tests/platformDeploy.test.js index bc2944ae4432..1bdffa89fa4a 100644 --- a/workflow_tests/platformDeploy.test.js +++ b/workflow_tests/platformDeploy.test.js @@ -101,7 +101,7 @@ describe('test workflow platformDeploy', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'platformDeploy.yml'), mockSteps: testMockSteps, actor: 'Dummy Author', - logFile: utils.getLogFilePath('platformDeploy'), + logFile: utils.getLogFilePath('platformDeploy', expect.getState().currentTestName), }); assertions.assertVerifyActorJobExecuted(result, 'Dummy Author'); @@ -174,7 +174,7 @@ describe('test workflow platformDeploy', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'platformDeploy.yml'), mockSteps: testMockSteps, actor: 'OSBotify', - logFile: utils.getLogFilePath('platformDeploy'), + logFile: utils.getLogFilePath('platformDeploy', expect.getState().currentTestName), }); assertions.assertVerifyActorJobExecuted(result, 'OSBotify'); @@ -247,7 +247,7 @@ describe('test workflow platformDeploy', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'platformDeploy.yml'), mockSteps: testMockSteps, actor: 'Dummy Author', - logFile: utils.getLogFilePath('platformDeploy'), + logFile: utils.getLogFilePath('platformDeploy', expect.getState().currentTestName), }); assertions.assertVerifyActorJobExecuted(result, 'Dummy Author'); diff --git a/workflow_tests/preDeploy.test.js b/workflow_tests/preDeploy.test.js index 72fc42457a92..542883deb00e 100644 --- a/workflow_tests/preDeploy.test.js +++ b/workflow_tests/preDeploy.test.js @@ -80,7 +80,7 @@ describe('test workflow preDeploy', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), mockSteps: testMockSteps, actor: 'Dummy Tester', - logFile: utils.getLogFilePath('preDeploy'), + logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), }); // assert results (some steps can run in parallel to each other so the order is not assured @@ -126,7 +126,7 @@ describe('test workflow preDeploy', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), mockSteps: testMockSteps, actor: 'Dummy Tester', - logFile: utils.getLogFilePath('preDeploy'), + logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), }); assertions.assertLintJobExecuted(result, false); assertions.assertTestJobExecuted(result, false); @@ -151,7 +151,7 @@ describe('test workflow preDeploy', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), mockSteps: testMockSteps, actor: 'Dummy Tester', - logFile: utils.getLogFilePath('preDeploy'), + logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), }); assertions.assertLintJobExecuted(result, false); assertions.assertTestJobExecuted(result, false); @@ -204,7 +204,7 @@ describe('test workflow preDeploy', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), mockSteps: testMockSteps, actor: 'Dummy Tester', - logFile: utils.getLogFilePath('preDeploy'), + logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), }); expect(result).toEqual(expect.arrayContaining( [ @@ -283,7 +283,7 @@ describe('test workflow preDeploy', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), mockSteps: testMockSteps, actor: 'Dummy Tester', - logFile: utils.getLogFilePath('preDeploy'), + logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), }); assertions.assertLintJobExecuted(result); expect(result).toEqual(expect.arrayContaining( @@ -351,7 +351,7 @@ describe('test workflow preDeploy', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), mockSteps: testMockSteps, actor: 'Dummy Tester', - logFile: utils.getLogFilePath('preDeploy'), + logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), }); assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); @@ -394,7 +394,7 @@ describe('test workflow preDeploy', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), mockSteps: testMockSteps, actor: 'OSBotify', - logFile: utils.getLogFilePath('preDeploy'), + logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), }); assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); @@ -433,7 +433,7 @@ describe('test workflow preDeploy', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), mockSteps: testMockSteps, actor: 'Dummy Tester', - logFile: utils.getLogFilePath('preDeploy'), + logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), }); assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); @@ -472,7 +472,7 @@ describe('test workflow preDeploy', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), mockSteps: testMockSteps, actor: 'Dummy Tester', - logFile: utils.getLogFilePath('preDeploy'), + logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), }); assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); @@ -511,7 +511,7 @@ describe('test workflow preDeploy', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), mockSteps: testMockSteps, actor: 'Dummy Tester', - logFile: utils.getLogFilePath('preDeploy'), + logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), }); assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); @@ -552,7 +552,7 @@ describe('test workflow preDeploy', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), mockSteps: testMockSteps, actor: 'Dummy Tester', - logFile: utils.getLogFilePath('preDeploy'), + logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), }); assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); @@ -592,7 +592,7 @@ describe('test workflow preDeploy', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), mockSteps: testMockSteps, actor: 'OSBotify', - logFile: utils.getLogFilePath('preDeploy'), + logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), }); assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); @@ -638,7 +638,7 @@ describe('test workflow preDeploy', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), mockSteps: testMockSteps, actor: 'Dummy Tester', - logFile: utils.getLogFilePath('preDeploy'), + logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), }); assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); @@ -681,7 +681,7 @@ describe('test workflow preDeploy', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), mockSteps: testMockSteps, actor: 'OSBotify', - logFile: utils.getLogFilePath('preDeploy'), + logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), }); assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); @@ -729,7 +729,7 @@ describe('test workflow preDeploy', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), mockSteps: testMockSteps, actor: 'Dummy Tester', - logFile: utils.getLogFilePath('preDeploy'), + logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), }); assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); @@ -773,7 +773,7 @@ describe('test workflow preDeploy', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), mockSteps: testMockSteps, actor: 'OSBotify', - logFile: utils.getLogFilePath('preDeploy'), + logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), }); assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); @@ -819,7 +819,7 @@ describe('test workflow preDeploy', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), mockSteps: testMockSteps, actor: 'Dummy Tester', - logFile: utils.getLogFilePath('preDeploy'), + logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), }); assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); @@ -863,7 +863,7 @@ describe('test workflow preDeploy', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), mockSteps: testMockSteps, actor: 'OSBotify', - logFile: utils.getLogFilePath('preDeploy'), + logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), }); assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); @@ -908,7 +908,7 @@ describe('test workflow preDeploy', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), mockSteps: testMockSteps, actor: 'OSBotify', - logFile: utils.getLogFilePath('preDeploy'), + logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), }); assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); diff --git a/workflow_tests/reviewerChecklist.test.js b/workflow_tests/reviewerChecklist.test.js index a742408af4b9..261842be282a 100644 --- a/workflow_tests/reviewerChecklist.test.js +++ b/workflow_tests/reviewerChecklist.test.js @@ -62,7 +62,7 @@ describe('test workflow reviewerChecklist', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'reviewerChecklist.yml'), mockSteps: testMockSteps, actor, - logFile: utils.getLogFilePath('reviewerChecklist'), + logFile: utils.getLogFilePath('reviewerChecklist', expect.getState().currentTestName), }); assertions.assertChecklistJobExecuted(result); @@ -88,7 +88,7 @@ describe('test workflow reviewerChecklist', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'reviewerChecklist.yml'), mockSteps: testMockSteps, actor: osbotifyActor, - logFile: utils.getLogFilePath('reviewerChecklist'), + logFile: utils.getLogFilePath('reviewerChecklist', expect.getState().currentTestName), }); assertions.assertChecklistJobExecuted(result, false); diff --git a/workflow_tests/test.test.js b/workflow_tests/test.test.js index 5a10cb0d9117..f266ffa5e8d6 100644 --- a/workflow_tests/test.test.js +++ b/workflow_tests/test.test.js @@ -68,7 +68,7 @@ describe('test workflow test', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'test.yml'), mockSteps: testMockSteps, actor, - logFile: utils.getLogFilePath('test'), + logFile: utils.getLogFilePath('test', expect.getState().currentTestName), }); assertions.assertJestJobExecuted(result); @@ -95,7 +95,7 @@ describe('test workflow test', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'test.yml'), mockSteps: testMockSteps, actor: osbotifyActor, - logFile: utils.getLogFilePath('test'), + logFile: utils.getLogFilePath('test', expect.getState().currentTestName), }); assertions.assertJestJobExecuted(result, false); @@ -129,7 +129,7 @@ describe('test workflow test', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'test.yml'), mockSteps: testMockSteps, actor, - logFile: utils.getLogFilePath('test'), + logFile: utils.getLogFilePath('test', expect.getState().currentTestName), }); assertions.assertJestJobExecuted(result); @@ -156,7 +156,7 @@ describe('test workflow test', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'test.yml'), mockSteps: testMockSteps, actor: osbotifyActor, - logFile: utils.getLogFilePath('test'), + logFile: utils.getLogFilePath('test', expect.getState().currentTestName), }); assertions.assertJestJobExecuted(result, false); @@ -188,7 +188,7 @@ describe('test workflow test', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'test.yml'), mockSteps: testMockSteps, actor, - logFile: utils.getLogFilePath('test'), + logFile: utils.getLogFilePath('test', expect.getState().currentTestName), }); assertions.assertJestJobExecuted(result); @@ -215,7 +215,7 @@ describe('test workflow test', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'test.yml'), mockSteps: testMockSteps, actor: osbotifyActor, - logFile: utils.getLogFilePath('test'), + logFile: utils.getLogFilePath('test', expect.getState().currentTestName), }); assertions.assertJestJobExecuted(result); diff --git a/workflow_tests/testBuild.test.js b/workflow_tests/testBuild.test.js index 2411c7ac5e7c..68153caae550 100644 --- a/workflow_tests/testBuild.test.js +++ b/workflow_tests/testBuild.test.js @@ -89,7 +89,7 @@ describe('test workflow testBuild', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'testBuild.yml'), mockSteps: testMockSteps, actor, - logFile: utils.getLogFilePath('testBuild'), + logFile: utils.getLogFilePath('testBuild', expect.getState().currentTestName), }); assertions.assertValidateActorJobExecuted(result, actor, '1234'); @@ -133,7 +133,7 @@ describe('test workflow testBuild', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'testBuild.yml'), mockSteps: testMockSteps, actor, - logFile: utils.getLogFilePath('testBuild'), + logFile: utils.getLogFilePath('testBuild', expect.getState().currentTestName), }); assertions.assertValidateActorJobExecuted(result, actor, '1234'); @@ -178,7 +178,7 @@ describe('test workflow testBuild', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'testBuild.yml'), mockSteps: testMockSteps, actor, - logFile: utils.getLogFilePath('testBuild'), + logFile: utils.getLogFilePath('testBuild', expect.getState().currentTestName), }); assertions.assertValidateActorJobExecuted(result, actor, '1234'); @@ -223,7 +223,7 @@ describe('test workflow testBuild', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'testBuild.yml'), mockSteps: testMockSteps, actor, - logFile: utils.getLogFilePath('testBuild'), + logFile: utils.getLogFilePath('testBuild', expect.getState().currentTestName), }); assertions.assertValidateActorJobExecuted(result, actor, '1234'); @@ -278,7 +278,7 @@ describe('test workflow testBuild', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'testBuild.yml'), mockSteps: testMockSteps, actor, - logFile: utils.getLogFilePath('testBuild'), + logFile: utils.getLogFilePath('testBuild', expect.getState().currentTestName), }); assertions.assertValidateActorJobExecuted(result, actor, '1234'); @@ -333,7 +333,7 @@ describe('test workflow testBuild', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'testBuild.yml'), mockSteps: testMockSteps, actor, - logFile: utils.getLogFilePath('testBuild'), + logFile: utils.getLogFilePath('testBuild', expect.getState().currentTestName), }); assertions.assertValidateActorJobExecuted(result, actor, '1234'); @@ -388,7 +388,7 @@ describe('test workflow testBuild', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'testBuild.yml'), mockSteps: testMockSteps, actor, - logFile: utils.getLogFilePath('testBuild'), + logFile: utils.getLogFilePath('testBuild', expect.getState().currentTestName), }); assertions.assertValidateActorJobExecuted(result, actor, '1234'); @@ -443,7 +443,7 @@ describe('test workflow testBuild', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'testBuild.yml'), mockSteps: testMockSteps, actor, - logFile: utils.getLogFilePath('testBuild'), + logFile: utils.getLogFilePath('testBuild', expect.getState().currentTestName), }); assertions.assertValidateActorJobExecuted(result, actor, '1234'); @@ -498,7 +498,7 @@ describe('test workflow testBuild', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'testBuild.yml'), mockSteps: testMockSteps, actor, - logFile: utils.getLogFilePath('testBuild'), + logFile: utils.getLogFilePath('testBuild', expect.getState().currentTestName), }); assertions.assertValidateActorJobExecuted(result, actor, '1234'); @@ -541,7 +541,7 @@ describe('test workflow testBuild', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'testBuild.yml'), mockSteps: testMockSteps, actor, - logFile: utils.getLogFilePath('testBuild'), + logFile: utils.getLogFilePath('testBuild', expect.getState().currentTestName), }); assertions.assertValidateActorJobExecuted(result, actor, '1234'); @@ -585,7 +585,7 @@ describe('test workflow testBuild', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'testBuild.yml'), mockSteps: testMockSteps, actor, - logFile: utils.getLogFilePath('testBuild'), + logFile: utils.getLogFilePath('testBuild', expect.getState().currentTestName), }); assertions.assertValidateActorJobExecuted(result, actor, '1234'); @@ -629,7 +629,7 @@ describe('test workflow testBuild', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'testBuild.yml'), mockSteps: testMockSteps, actor, - logFile: utils.getLogFilePath('testBuild'), + logFile: utils.getLogFilePath('testBuild', expect.getState().currentTestName), }); assertions.assertValidateActorJobExecuted(result, actor, '1234'); @@ -684,7 +684,7 @@ describe('test workflow testBuild', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'testBuild.yml'), mockSteps: testMockSteps, actor, - logFile: utils.getLogFilePath('testBuild'), + logFile: utils.getLogFilePath('testBuild', expect.getState().currentTestName), }); assertions.assertValidateActorJobExecuted(result, actor, '1234'); @@ -727,7 +727,7 @@ describe('test workflow testBuild', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'testBuild.yml'), mockSteps: testMockSteps, actor, - logFile: utils.getLogFilePath('testBuild'), + logFile: utils.getLogFilePath('testBuild', expect.getState().currentTestName), }); assertions.assertValidateActorJobExecuted(result, actor, '1234'); @@ -771,7 +771,7 @@ describe('test workflow testBuild', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'testBuild.yml'), mockSteps: testMockSteps, actor, - logFile: utils.getLogFilePath('testBuild'), + logFile: utils.getLogFilePath('testBuild', expect.getState().currentTestName), }); assertions.assertValidateActorJobExecuted(result, actor, '1234'); @@ -815,7 +815,7 @@ describe('test workflow testBuild', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'testBuild.yml'), mockSteps: testMockSteps, actor, - logFile: utils.getLogFilePath('testBuild'), + logFile: utils.getLogFilePath('testBuild', expect.getState().currentTestName), }); assertions.assertValidateActorJobExecuted(result, actor, '1234'); @@ -870,7 +870,7 @@ describe('test workflow testBuild', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'testBuild.yml'), mockSteps: testMockSteps, actor, - logFile: utils.getLogFilePath('testBuild'), + logFile: utils.getLogFilePath('testBuild', expect.getState().currentTestName), }); assertions.assertValidateActorJobExecuted(result, actor, '1234'); @@ -913,7 +913,7 @@ describe('test workflow testBuild', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'testBuild.yml'), mockSteps: testMockSteps, actor, - logFile: utils.getLogFilePath('testBuild'), + logFile: utils.getLogFilePath('testBuild', expect.getState().currentTestName), }); assertions.assertValidateActorJobExecuted(result, actor, '1234'); @@ -957,7 +957,7 @@ describe('test workflow testBuild', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'testBuild.yml'), mockSteps: testMockSteps, actor, - logFile: utils.getLogFilePath('testBuild'), + logFile: utils.getLogFilePath('testBuild', expect.getState().currentTestName), }); assertions.assertValidateActorJobExecuted(result, actor, '1234'); @@ -1001,7 +1001,7 @@ describe('test workflow testBuild', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'testBuild.yml'), mockSteps: testMockSteps, actor, - logFile: utils.getLogFilePath('testBuild'), + logFile: utils.getLogFilePath('testBuild', expect.getState().currentTestName), }); assertions.assertValidateActorJobExecuted(result, actor, '1234'); diff --git a/workflow_tests/utils/utils.js b/workflow_tests/utils/utils.js index 0516e092cc63..21629e80603c 100644 --- a/workflow_tests/utils/utils.js +++ b/workflow_tests/utils/utils.js @@ -152,12 +152,16 @@ function deepCopy(originalObject) { return JSON.parse(JSON.stringify(originalObject)); } -function getLogFilePath(workflowName) { +function getLogFilePath(workflowName, testName) { const logsDir = path.resolve(__dirname, '..', 'logs'); if (!fs.existsSync(logsDir)) { fs.mkdirSync(logsDir); } - return path.resolve(logsDir, `${workflowName}.log`); + const workflowTestsLogDir = path.resolve(logsDir, workflowName); + if (!fs.existsSync(workflowTestsLogDir)) { + fs.mkdirSync(workflowTestsLogDir); + } + return path.resolve(workflowTestsLogDir, `${testName}.log`); } function removeMockRepoDir() { diff --git a/workflow_tests/validateGithubActions.test.js b/workflow_tests/validateGithubActions.test.js index 9f855377b034..89615f622ff9 100644 --- a/workflow_tests/validateGithubActions.test.js +++ b/workflow_tests/validateGithubActions.test.js @@ -65,7 +65,7 @@ describe('test workflow validateGithubActions', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'validateGithubActions.yml'), mockSteps: testMockSteps, actor, - logFile: utils.getLogFilePath('validateGithubActions'), + logFile: utils.getLogFilePath('validateGithubActions', expect.getState().currentTestName), }); assertions.assertVerifyJobExecuted(result); @@ -95,7 +95,7 @@ describe('test workflow validateGithubActions', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'validateGithubActions.yml'), mockSteps: testMockSteps, actor, - logFile: utils.getLogFilePath('validateGithubActions'), + logFile: utils.getLogFilePath('validateGithubActions', expect.getState().currentTestName), }); assertions.assertVerifyJobExecuted(result); diff --git a/workflow_tests/verifyPodfile.test.js b/workflow_tests/verifyPodfile.test.js index 393d089080cd..57ebb34124d8 100644 --- a/workflow_tests/verifyPodfile.test.js +++ b/workflow_tests/verifyPodfile.test.js @@ -71,7 +71,7 @@ describe('test workflow verifyPodfile', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'verifyPodfile.yml'), mockSteps: testMockSteps, actor, - logFile: utils.getLogFilePath('verifyPodfile'), + logFile: utils.getLogFilePath('verifyPodfile', expect.getState().currentTestName), }); assertions.assertVerifyJobExecuted(result); @@ -101,7 +101,7 @@ describe('test workflow verifyPodfile', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'verifyPodfile.yml'), mockSteps: testMockSteps, actor: osbotifyActor, - logFile: utils.getLogFilePath('verifyPodfile'), + logFile: utils.getLogFilePath('verifyPodfile', expect.getState().currentTestName), }); assertions.assertVerifyJobExecuted(result, false); @@ -137,7 +137,7 @@ describe('test workflow verifyPodfile', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'verifyPodfile.yml'), mockSteps: testMockSteps, actor, - logFile: utils.getLogFilePath('verifyPodfile'), + logFile: utils.getLogFilePath('verifyPodfile', expect.getState().currentTestName), }); assertions.assertVerifyJobExecuted(result); @@ -167,7 +167,7 @@ describe('test workflow verifyPodfile', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'verifyPodfile.yml'), mockSteps: testMockSteps, actor: osbotifyActor, - logFile: utils.getLogFilePath('verifyPodfile'), + logFile: utils.getLogFilePath('verifyPodfile', expect.getState().currentTestName), }); assertions.assertVerifyJobExecuted(result, false); diff --git a/workflow_tests/verifySignedCommits.test.js b/workflow_tests/verifySignedCommits.test.js index 322ca8813ebc..96ca6f0c6143 100644 --- a/workflow_tests/verifySignedCommits.test.js +++ b/workflow_tests/verifySignedCommits.test.js @@ -65,7 +65,7 @@ describe('test workflow verifySignedCommits', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'verifySignedCommits.yml'), mockSteps: testMockSteps, actor, - logFile: utils.getLogFilePath('verifySignedCommits'), + logFile: utils.getLogFilePath('verifySignedCommits', expect.getState().currentTestName), }); assertions.assertVerifySignedCommitsJobExecuted(result); @@ -95,7 +95,7 @@ describe('test workflow verifySignedCommits', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'verifySignedCommits.yml'), mockSteps: testMockSteps, actor, - logFile: utils.getLogFilePath('verifySignedCommits'), + logFile: utils.getLogFilePath('verifySignedCommits', expect.getState().currentTestName), }); assertions.assertVerifySignedCommitsJobExecuted(result); diff --git a/workflow_tests/warnCPLabel.test.js b/workflow_tests/warnCPLabel.test.js index 3b3325847ecc..311cda516d31 100644 --- a/workflow_tests/warnCPLabel.test.js +++ b/workflow_tests/warnCPLabel.test.js @@ -71,7 +71,7 @@ describe('test workflow warnCPLabel', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'warnCPLabel.yml'), mockSteps: testMockSteps, actor, - logFile: utils.getLogFilePath('warnCPLabel'), + logFile: utils.getLogFilePath('warnCPLabel', expect.getState().currentTestName), }); assertions.assertWarnCPLabelJobExecuted(result); @@ -106,7 +106,7 @@ describe('test workflow warnCPLabel', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'warnCPLabel.yml'), mockSteps: testMockSteps, actor, - logFile: utils.getLogFilePath('warnCPLabel'), + logFile: utils.getLogFilePath('warnCPLabel', expect.getState().currentTestName), }); assertions.assertWarnCPLabelJobExecuted(result, true, false); @@ -138,7 +138,7 @@ describe('test workflow warnCPLabel', () => { workflowFile: path.join(repoPath, '.github', 'workflows', 'warnCPLabel.yml'), mockSteps: testMockSteps, actor, - logFile: utils.getLogFilePath('warnCPLabel'), + logFile: utils.getLogFilePath('warnCPLabel', expect.getState().currentTestName), }); assertions.assertWarnCPLabelJobExecuted(result, false); From 7cbc67bd423815dc3f82d8f311468cb0daef96f6 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Thu, 25 May 2023 11:38:40 +0200 Subject: [PATCH 084/504] Add `workflow_tests` to `ignorePatterns` Workflow tests rely heavily on async functions and disallowing them in eslintrc is problematic See: https://github.com/Expensify/App/issues/13604 --- .eslintrc.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.eslintrc.js b/.eslintrc.js index 2f9a4167ae51..fc2b48e94308 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -2,7 +2,7 @@ module.exports = { extends: ['expensify', 'plugin:storybook/recommended', 'plugin:react-hooks/recommended', 'prettier'], plugins: ['react-hooks'], parser: 'babel-eslint', - ignorePatterns: ['!.*', 'src/vendor', '.github/actions/**/index.js', 'desktop/dist/*.js', 'dist/*.js', 'node_modules/.bin/**', '.git/**'], + ignorePatterns: ['!.*', 'src/vendor', '.github/actions/**/index.js', 'desktop/dist/*.js', 'dist/*.js', 'node_modules/.bin/**', '.git/**', 'workflow_tests/**/*.js'], env: { jest: true, }, From 2b308f94f7473dc6d8fbeca713c8935d45df6587 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Thu, 25 May 2023 15:03:18 +0200 Subject: [PATCH 085/504] Fix lint problems Tons of minor changes to conform with eslint See: https://github.com/Expensify/App/issues/13604 --- .eslintrc.js | 10 +- .../assertions/authorChecklistAssertions.js | 4 +- .../assertions/cherryPickAssertions.js | 36 ++--- workflow_tests/assertions/claAssertions.js | 12 +- .../assertions/createNewVersionAssertions.js | 12 +- workflow_tests/assertions/deployAssertions.js | 12 +- .../assertions/deployBlockerAssertions.js | 12 +- .../finishReleaseCycleAssertions.js | 28 ++-- workflow_tests/assertions/lintAssertions.js | 4 +- .../assertions/lockDeploysAssertions.js | 12 +- .../assertions/platformDeployAssertions.js | 69 ++++++---- .../assertions/preDeployAssertions.js | 75 ++++++++--- .../assertions/reviewerChecklistAssertions.js | 4 +- workflow_tests/assertions/testAssertions.js | 21 +-- .../assertions/testBuildAssertions.js | 47 ++++--- .../validateGithubActionsAssertions.js | 4 +- .../assertions/verifyPodfileAssertions.js | 4 +- .../verifySignedCommitsAssertions.js | 4 +- .../assertions/warnCPLabelAssertions.js | 8 +- workflow_tests/cla.test.js | 8 +- workflow_tests/mocks/createNewVersionMocks.js | 1 + workflow_tests/mocks/deployBlockerMocks.js | 3 + workflow_tests/mocks/preDeployMocks.js | 3 + workflow_tests/utils/ExtendedAct.js | 4 +- workflow_tests/utils/preGenerateTest.js | 123 +++++++++--------- workflow_tests/utils/utils.js | 40 +++--- 26 files changed, 325 insertions(+), 235 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index fc2b48e94308..5155cda3d2a6 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -2,7 +2,7 @@ module.exports = { extends: ['expensify', 'plugin:storybook/recommended', 'plugin:react-hooks/recommended', 'prettier'], plugins: ['react-hooks'], parser: 'babel-eslint', - ignorePatterns: ['!.*', 'src/vendor', '.github/actions/**/index.js', 'desktop/dist/*.js', 'dist/*.js', 'node_modules/.bin/**', '.git/**', 'workflow_tests/**/*.js'], + ignorePatterns: ['!.*', 'src/vendor', '.github/actions/**/index.js', 'desktop/dist/*.js', 'dist/*.js', 'node_modules/.bin/**', '.git/**'], env: { jest: true, }, @@ -13,6 +13,14 @@ module.exports = { }, }, }, + overrides: [ + { + files: ['workflow_tests/**/*.js'], + rules: { + '@lwc/lwc/no-async-await': 'off', + }, + }, + ], globals: { __DEV__: 'readonly', }, diff --git a/workflow_tests/assertions/authorChecklistAssertions.js b/workflow_tests/assertions/authorChecklistAssertions.js index 5eb687fdbb5d..1ad45b4cb3d9 100644 --- a/workflow_tests/assertions/authorChecklistAssertions.js +++ b/workflow_tests/assertions/authorChecklistAssertions.js @@ -13,13 +13,13 @@ const assertChecklistJobExecuted = (workflowResult, didExecute = true) => { ), ]; - for (const expectedStep of steps) { + steps.forEach((expectedStep) => { if (didExecute) { expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); } else { expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); } - } + }); }; module.exports = { diff --git a/workflow_tests/assertions/cherryPickAssertions.js b/workflow_tests/assertions/cherryPickAssertions.js index d9bce263d524..7bc4fb12be44 100644 --- a/workflow_tests/assertions/cherryPickAssertions.js +++ b/workflow_tests/assertions/cherryPickAssertions.js @@ -13,13 +13,13 @@ const assertValidateActorJobExecuted = (workflowResult, username = 'Dummy Author ), ]; - for (const expectedStep of steps) { + steps.forEach((expectedStep) => { if (didExecute) { expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); } else { expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); } - } + }); }; const assertCreateNewVersionJobExecuted = (workflowResult, didExecute = true) => { @@ -35,13 +35,13 @@ const assertCreateNewVersionJobExecuted = (workflowResult, didExecute = true) => ), ]; - for (const expectedStep of steps) { + steps.forEach((expectedStep) => { if (didExecute) { expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); } else { expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); } - } + }); }; const assertCherryPickJobExecuted = ( @@ -164,13 +164,13 @@ const assertCherryPickJobExecuted = ( ), ]; - for (const expectedStep of steps) { + steps.forEach((expectedStep) => { if (didExecute) { expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); } else { expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); } - } + }); const conflictsSteps = [ utils.createStepAssertion( @@ -184,13 +184,13 @@ const assertCherryPickJobExecuted = ( ), ]; - for (const step of conflictsSteps) { + conflictsSteps.forEach((step) => { if (didExecute && mergeConflictsOrVersionMismatch) { expect(workflowResult).toEqual(expect.arrayContaining([step])); } else { expect(workflowResult).not.toEqual(expect.arrayContaining([step])); } - } + }); const manualMergeSteps = [ utils.createStepAssertion( @@ -213,13 +213,13 @@ const assertCherryPickJobExecuted = ( ), ]; - for (const step of manualMergeSteps) { + manualMergeSteps.forEach((step) => { if (didExecute && !shouldAutomerge) { expect(workflowResult).toEqual(expect.arrayContaining([step])); } else { expect(workflowResult).not.toEqual(expect.arrayContaining([step])); } - } + }); const autoMergeSteps = [ utils.createStepAssertion( @@ -233,13 +233,13 @@ const assertCherryPickJobExecuted = ( ), ]; - for (const step of autoMergeSteps) { + autoMergeSteps.forEach((step) => { if (didExecute && shouldAutomerge) { expect(workflowResult).toEqual(expect.arrayContaining([step])); } else { expect(workflowResult).not.toEqual(expect.arrayContaining([step])); } - } + }); const versionMismatchSteps = [ utils.createStepAssertion( @@ -253,13 +253,13 @@ const assertCherryPickJobExecuted = ( ), ]; - for (const step of versionMismatchSteps) { + versionMismatchSteps.forEach((step) => { if (didExecute && !versionsMatch) { expect(workflowResult).toEqual(expect.arrayContaining([step])); } else { expect(workflowResult).not.toEqual(expect.arrayContaining([step])); } - } + }); const failedSteps = [ utils.createStepAssertion( @@ -273,13 +273,13 @@ const assertCherryPickJobExecuted = ( ), ]; - for (const step of failedSteps) { + failedSteps.forEach((step) => { if (didExecute && (!isSuccessful || !prIsMergeable)) { expect(workflowResult).toEqual(expect.arrayContaining([step])); } else { expect(workflowResult).not.toEqual(expect.arrayContaining([step])); } - } + }); const autoMergeableSteps = [ utils.createStepAssertion( @@ -293,13 +293,13 @@ const assertCherryPickJobExecuted = ( ), ]; - for (const step of autoMergeableSteps) { + autoMergeableSteps.forEach((step) => { if (didExecute && shouldAutomerge && prIsMergeable) { expect(workflowResult).toEqual(expect.arrayContaining([step])); } else { expect(workflowResult).not.toEqual(expect.arrayContaining([step])); } - } + }); }; module.exports = { diff --git a/workflow_tests/assertions/claAssertions.js b/workflow_tests/assertions/claAssertions.js index bc414134c572..0ab309c4b9c0 100644 --- a/workflow_tests/assertions/claAssertions.js +++ b/workflow_tests/assertions/claAssertions.js @@ -1,6 +1,6 @@ const utils = require('../utils/utils'); -const assertCLAJobExecuted = (workflowResult, commentBody = '', githubRepository = '', didExecute = true, runAssitant = true) => { +const assertCLAJobExecuted = (workflowResult, commentBody = '', githubRepository = '', didExecute = true) => { const steps = [ utils.createStepAssertion( 'CLA comment check', @@ -22,13 +22,13 @@ const assertCLAJobExecuted = (workflowResult, commentBody = '', githubRepository ), ]; - for (const expectedStep of steps) { + steps.forEach((expectedStep) => { if (didExecute) { expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); } else { expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); } - } + }); const assistantSteps = [ utils.createStepAssertion( @@ -50,13 +50,13 @@ const assertCLAJobExecuted = (workflowResult, commentBody = '', githubRepository ), ]; - for (const step of assistantSteps) { - if (didExecute && runAssitant) { + assistantSteps.forEach((step) => { + if (didExecute) { expect(workflowResult).toEqual(expect.arrayContaining([step])); } else { expect(workflowResult).not.toEqual(expect.arrayContaining([step])); } - } + }); }; module.exports = { diff --git a/workflow_tests/assertions/createNewVersionAssertions.js b/workflow_tests/assertions/createNewVersionAssertions.js index 08fad472eab1..e1e9bcdcf82a 100644 --- a/workflow_tests/assertions/createNewVersionAssertions.js +++ b/workflow_tests/assertions/createNewVersionAssertions.js @@ -13,13 +13,13 @@ const assertValidateActorJobExecuted = (workflowResult, didExecute = true) => { ), ]; - for (const expectedStep of steps) { + steps.forEach((expectedStep) => { if (didExecute) { expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); } else { expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); } - } + }); }; const assertCreateNewVersionJobExecuted = (workflowResult, semverLevel = 'BUILD', didExecute = true, isSuccessful = true) => { const steps = [ @@ -93,7 +93,7 @@ const assertCreateNewVersionJobExecuted = (workflowResult, semverLevel = 'BUILD' ), ]; - for (const expectedStep of steps) { + steps.forEach((expectedStep) => { if (didExecute) { if (isSuccessful) { expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); @@ -101,7 +101,7 @@ const assertCreateNewVersionJobExecuted = (workflowResult, semverLevel = 'BUILD' } else { expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); } - } + }); const failedSteps = [ utils.createStepAssertion( @@ -115,13 +115,13 @@ const assertCreateNewVersionJobExecuted = (workflowResult, semverLevel = 'BUILD' ), ]; - for (const step of failedSteps) { + failedSteps.forEach((step) => { if (didExecute && !isSuccessful) { expect(workflowResult).toEqual(expect.arrayContaining([step])); } else { expect(workflowResult).not.toEqual(expect.arrayContaining([step])); } - } + }); }; module.exports = { diff --git a/workflow_tests/assertions/deployAssertions.js b/workflow_tests/assertions/deployAssertions.js index 372c7c42a7fc..d7f8f4677d9f 100644 --- a/workflow_tests/assertions/deployAssertions.js +++ b/workflow_tests/assertions/deployAssertions.js @@ -17,13 +17,13 @@ const assertValidateJobExecuted = (workflowResult, didExecute = true) => { }, ]; - for (const expectedStep of steps) { + steps.forEach((expectedStep) => { if (didExecute) { expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); } else { expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); } - } + }); }; const assertDeployStagingJobExecuted = (workflowResult, didExecute = true) => { @@ -60,13 +60,13 @@ const assertDeployStagingJobExecuted = (workflowResult, didExecute = true) => { ), ]; - for (const expectedStep of steps) { + steps.forEach((expectedStep) => { if (didExecute) { expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); } else { expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); } - } + }); }; const assertDeployProductionJobExecuted = (workflowResult, didExecute = true) => { @@ -128,13 +128,13 @@ const assertDeployProductionJobExecuted = (workflowResult, didExecute = true) => ), ]; - for (const expectedStep of steps) { + steps.forEach((expectedStep) => { if (didExecute) { expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); } else { expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); } - } + }); }; module.exports = { diff --git a/workflow_tests/assertions/deployBlockerAssertions.js b/workflow_tests/assertions/deployBlockerAssertions.js index 13ef0bbb23a6..917950f9b0b0 100644 --- a/workflow_tests/assertions/deployBlockerAssertions.js +++ b/workflow_tests/assertions/deployBlockerAssertions.js @@ -49,7 +49,7 @@ const assertDeployBlockerJobExecuted = (workflowResult, issueTitle, issueNumber, ), ]; - for (const expectedStep of steps) { + steps.forEach((expectedStep) => { if (didExecute) { if (isSuccessful) { expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); @@ -57,7 +57,7 @@ const assertDeployBlockerJobExecuted = (workflowResult, issueTitle, issueNumber, } else { expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); } - } + }); const successSteps = [ utils.createStepAssertion( @@ -71,13 +71,13 @@ const assertDeployBlockerJobExecuted = (workflowResult, issueTitle, issueNumber, ), ]; - for (const step of successSteps) { + successSteps.forEach((step) => { if (didExecute && isSuccessful) { expect(workflowResult).toEqual(expect.arrayContaining([step])); } else { expect(workflowResult).not.toEqual(expect.arrayContaining([step])); } - } + }); const failedSteps = [ utils.createStepAssertion( @@ -91,13 +91,13 @@ const assertDeployBlockerJobExecuted = (workflowResult, issueTitle, issueNumber, ), ]; - for (const step of failedSteps) { + failedSteps.forEach((step) => { if (didExecute && !isSuccessful) { expect(workflowResult).toEqual(expect.arrayContaining([step])); } else { expect(workflowResult).not.toEqual(expect.arrayContaining([step])); } - } + }); }; module.exports = { diff --git a/workflow_tests/assertions/finishReleaseCycleAssertions.js b/workflow_tests/assertions/finishReleaseCycleAssertions.js index ff3ac8253da0..234189e9f736 100644 --- a/workflow_tests/assertions/finishReleaseCycleAssertions.js +++ b/workflow_tests/assertions/finishReleaseCycleAssertions.js @@ -33,13 +33,13 @@ const assertValidateJobExecuted = (workflowResult, username = 'Dummy Author', is ); } - for (const expectedStep of steps) { + steps.forEach((expectedStep) => { if (didExecute) { expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); } else { expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); } - } + }); // eslint-disable-next-line rulesdir/no-negated-variables const notTeamMemberSteps = [ @@ -58,13 +58,13 @@ const assertValidateJobExecuted = (workflowResult, username = 'Dummy Author', is ), ]; - for (const expectedStep of notTeamMemberSteps) { + notTeamMemberSteps.forEach((expectedStep) => { if (didExecute && !isTeamMember) { expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); } else { expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); } - } + }); const blockerSteps = [ utils.createStepAssertion( @@ -81,13 +81,13 @@ const assertValidateJobExecuted = (workflowResult, username = 'Dummy Author', is ), ]; - for (const expectedStep of blockerSteps) { + blockerSteps.forEach((expectedStep) => { if (didExecute && hasBlockers) { expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); } else { expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); } - } + }); }; const assertUpdateProductionJobExecuted = (workflowResult, didExecute = true) => { @@ -107,13 +107,13 @@ const assertUpdateProductionJobExecuted = (workflowResult, didExecute = true) => ), ]; - for (const expectedStep of steps) { + steps.forEach((expectedStep) => { if (didExecute) { expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); } else { expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); } - } + }); }; const assertCreateNewPatchVersionJobExecuted = (workflowResult, didExecute = true) => { @@ -129,13 +129,13 @@ const assertCreateNewPatchVersionJobExecuted = (workflowResult, didExecute = tru ), ]; - for (const expectedStep of steps) { + steps.forEach((expectedStep) => { if (didExecute) { expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); } else { expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); } - } + }); }; const assertCreateNewStagingDeployCashJobExecuted = (workflowResult, newVersion = '', didExecute = true, isSuccessful = true) => { @@ -180,13 +180,13 @@ const assertCreateNewStagingDeployCashJobExecuted = (workflowResult, newVersion steps[2].status = 1; } - for (const expectedStep of steps) { + steps.forEach((expectedStep) => { if (didExecute) { expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); } else { expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); } - } + }); const failProdSteps = [ utils.createStepAssertion( @@ -200,13 +200,13 @@ const assertCreateNewStagingDeployCashJobExecuted = (workflowResult, newVersion ), ]; - for (const expectedStep of failProdSteps) { + failProdSteps.forEach((expectedStep) => { if (didExecute && !isSuccessful) { expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); } else { expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); } - } + }); }; module.exports = { diff --git a/workflow_tests/assertions/lintAssertions.js b/workflow_tests/assertions/lintAssertions.js index 7b6371d30ab0..797d626ad40b 100644 --- a/workflow_tests/assertions/lintAssertions.js +++ b/workflow_tests/assertions/lintAssertions.js @@ -40,13 +40,13 @@ const assertLintJobExecuted = (workflowResult, didExecute = true) => { ), ]; - for (const expectedStep of steps) { + steps.forEach((expectedStep) => { if (didExecute) { expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); } else { expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); } - } + }); }; module.exports = { diff --git a/workflow_tests/assertions/lockDeploysAssertions.js b/workflow_tests/assertions/lockDeploysAssertions.js index e0e218ddf89a..16641b5a586f 100644 --- a/workflow_tests/assertions/lockDeploysAssertions.js +++ b/workflow_tests/assertions/lockDeploysAssertions.js @@ -31,13 +31,13 @@ const assertlockStagingDeploysJobExecuted = (workflowResult, didExecute = true, ), ]; - for (const expectedStep of steps) { + steps.forEach((expectedStep) => { if (didExecute) { expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); } else { expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); } - } + }); const failProdSteps = [ utils.createStepAssertion( @@ -51,13 +51,13 @@ const assertlockStagingDeploysJobExecuted = (workflowResult, didExecute = true, ), ]; - for (const expectedStep of failProdSteps) { + failProdSteps.forEach((expectedStep) => { if (didExecute && !isSuccessful) { expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); } else { expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); } - } + }); }; const assertlockStagingDeploysJobFailedAfterFirstStep = (workflowResult) => { @@ -91,9 +91,9 @@ const assertlockStagingDeploysJobFailedAfterFirstStep = (workflowResult) => { ), ]; - for (const expectedStep of steps) { + steps.forEach((expectedStep) => { expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); - } + }); }; module.exports = { diff --git a/workflow_tests/assertions/platformDeployAssertions.js b/workflow_tests/assertions/platformDeployAssertions.js index 711daf515b01..60a0def4a5c1 100644 --- a/workflow_tests/assertions/platformDeployAssertions.js +++ b/workflow_tests/assertions/platformDeployAssertions.js @@ -12,13 +12,13 @@ const assertVerifyActorJobExecuted = (workflowResult, username, didExecute = tru ), ]; - for (const expectedStep of steps) { + steps.forEach((expectedStep) => { if (didExecute) { expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); } else { expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); } - } + }); }; const assertAndroidJobExecuted = (workflowResult, didExecute = true, isProduction = true, isSuccessful = true) => { @@ -121,13 +121,13 @@ const assertAndroidJobExecuted = (workflowResult, didExecute = true, isProductio ); } - for (const expectedStep of steps) { + steps.forEach((expectedStep) => { if (didExecute) { expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); } else { expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); } - } + }); const failProdSteps = [ utils.createStepAssertion( @@ -141,13 +141,13 @@ const assertAndroidJobExecuted = (workflowResult, didExecute = true, isProductio ), ]; - for (const expectedStep of failProdSteps) { + failProdSteps.forEach((expectedStep) => { if (didExecute && isProduction && !isSuccessful) { expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); } else { expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); } - } + }); }; const assertDesktopJobExecuted = (workflowResult, didExecute = true, isProduction = true) => { @@ -186,7 +186,14 @@ const assertDesktopJobExecuted = (workflowResult, didExecute = true, isProductio 'DESKTOP', 'Building production desktop app', null, - [{key: 'CSC_LINK', value: '***'}, {key: 'CSC_KEY_PASSWORD', value: '***'}, {key: 'APPLE_ID', value: '***'}, {key: 'APPLE_ID_PASSWORD', value: '***'}, {key: 'AWS_ACCESS_KEY_ID', value: '***'}, {key: 'AWS_SECRET_ACCESS_KEY', value: '***'}], + [ + {key: 'CSC_LINK', value: '***'}, + {key: 'CSC_KEY_PASSWORD', value: '***'}, + {key: 'APPLE_ID', value: '***'}, + {key: 'APPLE_ID_PASSWORD', value: '***'}, + {key: 'AWS_ACCESS_KEY_ID', value: '***'}, + {key: 'AWS_SECRET_ACCESS_KEY', value: '***'}, + ], ), ); } else { @@ -198,18 +205,25 @@ const assertDesktopJobExecuted = (workflowResult, didExecute = true, isProductio 'DESKTOP', 'Building staging desktop app', null, - [{key: 'CSC_LINK', value: '***'}, {key: 'CSC_KEY_PASSWORD', value: '***'}, {key: 'APPLE_ID', value: '***'}, {key: 'APPLE_ID_PASSWORD', value: '***'}, {key: 'AWS_ACCESS_KEY_ID', value: '***'}, {key: 'AWS_SECRET_ACCESS_KEY', value: '***'}], + [ + {key: 'CSC_LINK', value: '***'}, + {key: 'CSC_KEY_PASSWORD', value: '***'}, + {key: 'APPLE_ID', value: '***'}, + {key: 'APPLE_ID_PASSWORD', value: '***'}, + {key: 'AWS_ACCESS_KEY_ID', value: '***'}, + {key: 'AWS_SECRET_ACCESS_KEY', value: '***'}, + ], ), ); } - for (const expectedStep of steps) { + steps.forEach((expectedStep) => { if (didExecute) { expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); } else { expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); } - } + }); }; const assertIOSJobExecuted = (workflowResult, didExecute = true, isProduction = true, isSuccessful = true) => { @@ -329,13 +343,13 @@ const assertIOSJobExecuted = (workflowResult, didExecute = true, isProduction = ); } - for (const expectedStep of steps) { + steps.forEach((expectedStep) => { if (didExecute) { expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); } else { expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); } - } + }); const failProdSteps = [ utils.createStepAssertion( @@ -349,13 +363,13 @@ const assertIOSJobExecuted = (workflowResult, didExecute = true, isProduction = ), ]; - for (const expectedStep of failProdSteps) { + failProdSteps.forEach((expectedStep) => { if (didExecute && isProduction && !isSuccessful) { expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); } else { expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); } - } + }); }; const assertWebJobExecuted = (workflowResult, didExecute = true, isProduction = true) => { @@ -461,13 +475,13 @@ const assertWebJobExecuted = (workflowResult, didExecute = true, isProduction = ); } - for (const expectedStep of steps) { + steps.forEach((expectedStep) => { if (didExecute) { expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); } else { expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); } - } + }); }; const assertPostSlackOnFailureJobExecuted = (workflowResult, didExecute = true) => { @@ -482,13 +496,13 @@ const assertPostSlackOnFailureJobExecuted = (workflowResult, didExecute = true) ), ]; - for (const expectedStep of steps) { + steps.forEach((expectedStep) => { if (didExecute) { expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); } else { expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); } - } + }); }; const assertPostSlackOnSuccessJobExecuted = (workflowResult, didExecute = true, isProduction = true) => { @@ -540,13 +554,13 @@ const assertPostSlackOnSuccessJobExecuted = (workflowResult, didExecute = true, ); } - for (const expectedStep of steps) { + steps.forEach((expectedStep) => { if (didExecute) { expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); } else { expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); } - } + }); }; const assertPostGithubCommentJobExecuted = (workflowResult, didExecute = true, isProduction = true, didDeploy = true) => { @@ -587,17 +601,26 @@ const assertPostGithubCommentJobExecuted = (workflowResult, didExecute = true, i null, 'POST_GITHUB_COMMENT', 'Commenting on issues', - [{key: 'PR_LIST', value: '[1.2.1, 1.2.2]'}, {key: 'IS_PRODUCTION_DEPLOY', value: isProduction ? 'true' : 'false'}, {key: 'DEPLOY_VERSION', value: '1.2.3'}, {key: 'GITHUB_TOKEN', value: '***'}, {key: 'ANDROID', value: didDeploy ? 'success' : ''}, {key: 'DESKTOP', value: didDeploy ? 'success' : ''}, {key: 'IOS', value: didDeploy ? 'success' : ''}, {key: 'WEB', value: didDeploy ? 'success' : ''}], + [ + {key: 'PR_LIST', value: '[1.2.1, 1.2.2]'}, + {key: 'IS_PRODUCTION_DEPLOY', value: isProduction ? 'true' : 'false'}, + {key: 'DEPLOY_VERSION', value: '1.2.3'}, + {key: 'GITHUB_TOKEN', value: '***'}, + {key: 'ANDROID', value: didDeploy ? 'success' : ''}, + {key: 'DESKTOP', value: didDeploy ? 'success' : ''}, + {key: 'IOS', value: didDeploy ? 'success' : ''}, + {key: 'WEB', value: didDeploy ? 'success' : ''}, + ], ), ]; - for (const expectedStep of steps) { + steps.forEach((expectedStep) => { if (didExecute) { expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); } else { expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); } - } + }); }; module.exports = { diff --git a/workflow_tests/assertions/preDeployAssertions.js b/workflow_tests/assertions/preDeployAssertions.js index 6fb387d7b4fe..0c4b04691366 100644 --- a/workflow_tests/assertions/preDeployAssertions.js +++ b/workflow_tests/assertions/preDeployAssertions.js @@ -11,13 +11,13 @@ const assertLintJobExecuted = (workflowResult, didExecute = true) => { ), ]; - for (const expectedStep of steps) { + steps.forEach((expectedStep) => { if (didExecute) { expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); } else { expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); } - } + }); }; const assertTestJobExecuted = (workflowResult, didExecute = true) => { @@ -31,13 +31,13 @@ const assertTestJobExecuted = (workflowResult, didExecute = true) => { ), ]; - for (const expectedStep of steps) { + steps.forEach((expectedStep) => { if (didExecute) { expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); } else { expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); } - } + }); }; const assertIsExpensifyEmployeeJobExecuted = (workflowResult, didExecute = true) => { @@ -60,13 +60,13 @@ const assertIsExpensifyEmployeeJobExecuted = (workflowResult, didExecute = true) ), ]; - for (const expectedStep of steps) { + steps.forEach((expectedStep) => { if (didExecute) { expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); } else { expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); } - } + }); }; const assertNewContributorWelcomeMessageJobExecuted = (workflowResult, didExecute = true, isOsBotify = false, isFirstPr = false) => { @@ -96,6 +96,32 @@ const assertNewContributorWelcomeMessageJobExecuted = (workflowResult, didExecut [{key: 'GITHUB_TOKEN', value: '***'}], ), ]; + const osBotifyBody = '@OSBotify, Great job getting your first Expensify/App pull request over the finish line! ' + + ':tada:\n\nI know there\'s a lot of information in our ' + + '[contributing guidelines](https://github.com/Expensify/App/blob/main/contributingGuides/CONTRIBUTING.md), ' + + 'so here are some points to take note of :memo::\n\n1. Now that your first PR has been merged, you can be ' + + 'hired for another issue. Once you\'ve completed a few issues, you may be eligible to work on more than one ' + + 'job at a time.\n2. Once your PR is deployed to our staging servers, it will undergo quality assurance (QA) ' + + 'testing. If we find that it doesn\'t work as expected or causes a regression, you\'ll be responsible for ' + + 'fixing it. Typically, we would revert this PR and give you another chance to create a similar PR without ' + + 'causing a regression.\n3. Once your PR is deployed to _production_, we start a 7-day timer :alarm_clock:. ' + + 'After it has been on production for 7 days without causing any regressions, then we pay out the Upwork job. ' + + ':moneybag:\n\nSo it might take a while before you\'re paid for your work, but we typically post multiple ' + + 'new jobs every day, so there\'s plenty of opportunity. I hope you\'ve had a positive experience ' + + 'contributing to this repo! :blush:'; + const userBody = '@Dummy Author, Great job getting your first Expensify/App pull request over the finish ' + + 'line! :tada:\n\nI know there\'s a lot of information in our ' + + '[contributing guidelines](https://github.com/Expensify/App/blob/main/contributingGuides/CONTRIBUTING.md), ' + + 'so here are some points to take note of :memo::\n\n1. Now that your first PR has been merged, you can be ' + + 'hired for another issue. Once you\'ve completed a few issues, you may be eligible to work on more than one ' + + 'job at a time.\n2. Once your PR is deployed to our staging servers, it will undergo quality assurance (QA) ' + + 'testing. If we find that it doesn\'t work as expected or causes a regression, you\'ll be responsible for ' + + 'fixing it. Typically, we would revert this PR and give you another chance to create a similar PR without ' + + 'causing a regression.\n3. Once your PR is deployed to _production_, we start a 7-day timer :alarm_clock:. ' + + 'After it has been on production for 7 days without causing any regressions, then we pay out the Upwork ' + + 'job. :moneybag:\n\nSo it might take a while before you\'re paid for your work, but we typically post ' + + 'multiple new jobs every day, so there\'s plenty of opportunity. I hope you\'ve had a positive experience ' + + 'contributing to this repo! :blush:'; if (isFirstPr) { steps.push( utils.createStepAssertion( @@ -104,18 +130,22 @@ const assertNewContributorWelcomeMessageJobExecuted = (workflowResult, didExecut null, 'NEW_CONTRIBUTOR_WELCOME_MESSAGE', 'Creating comment', - [{key: 'github_token', value: '***'}, {key: 'number', value: '12345'}, {key: 'body', value: isOsBotify ? '@OSBotify, Great job getting your first Expensify/App pull request over the finish line! :tada:\n\nI know there\'s a lot of information in our [contributing guidelines](https://github.com/Expensify/App/blob/main/contributingGuides/CONTRIBUTING.md), so here are some points to take note of :memo::\n\n1. Now that your first PR has been merged, you can be hired for another issue. Once you\'ve completed a few issues, you may be eligible to work on more than one job at a time.\n2. Once your PR is deployed to our staging servers, it will undergo quality assurance (QA) testing. If we find that it doesn\'t work as expected or causes a regression, you\'ll be responsible for fixing it. Typically, we would revert this PR and give you another chance to create a similar PR without causing a regression.\n3. Once your PR is deployed to _production_, we start a 7-day timer :alarm_clock:. After it has been on production for 7 days without causing any regressions, then we pay out the Upwork job. :moneybag:\n\nSo it might take a while before you\'re paid for your work, but we typically post multiple new jobs every day, so there\'s plenty of opportunity. I hope you\'ve had a positive experience contributing to this repo! :blush:' : '@Dummy Author, Great job getting your first Expensify/App pull request over the finish line! :tada:\n\nI know there\'s a lot of information in our [contributing guidelines](https://github.com/Expensify/App/blob/main/contributingGuides/CONTRIBUTING.md), so here are some points to take note of :memo::\n\n1. Now that your first PR has been merged, you can be hired for another issue. Once you\'ve completed a few issues, you may be eligible to work on more than one job at a time.\n2. Once your PR is deployed to our staging servers, it will undergo quality assurance (QA) testing. If we find that it doesn\'t work as expected or causes a regression, you\'ll be responsible for fixing it. Typically, we would revert this PR and give you another chance to create a similar PR without causing a regression.\n3. Once your PR is deployed to _production_, we start a 7-day timer :alarm_clock:. After it has been on production for 7 days without causing any regressions, then we pay out the Upwork job. :moneybag:\n\nSo it might take a while before you\'re paid for your work, but we typically post multiple new jobs every day, so there\'s plenty of opportunity. I hope you\'ve had a positive experience contributing to this repo! :blush:'}], + [ + {key: 'github_token', value: '***'}, + {key: 'number', value: '12345'}, + {key: 'body', value: isOsBotify ? osBotifyBody : userBody}, + ], ), ); } - for (const expectedStep of steps) { + steps.forEach((expectedStep) => { if (didExecute) { expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); } else { expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); } - } + }); }; const assertChooseDeployActionsJobExecuted = (workflowResult, didExecute = true) => { @@ -153,16 +183,18 @@ const assertChooseDeployActionsJobExecuted = (workflowResult, didExecute = true) ), ]; - for (const expectedStep of steps) { + steps.forEach((expectedStep) => { if (didExecute) { expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); } else { expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); } - } + }); }; const assertSkipDeployJobExecuted = (workflowResult, didExecute = true) => { + const body = ':hand: This PR was not deployed to staging yet because QA is ongoing. It will be automatically ' + + 'deployed to staging after the next production release.'; const steps = [ utils.createStepAssertion( 'Comment on deferred PR', @@ -170,17 +202,20 @@ const assertSkipDeployJobExecuted = (workflowResult, didExecute = true) => { null, 'SKIP_DEPLOY', 'Skipping deploy', - [{key: 'github_token', value: '***'}, {key: 'number', value: '123'}, {key: 'body', value: ':hand: This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.'}], + [ + {key: 'github_token', value: '***'}, + {key: 'number', value: '123'}, + {key: 'body', value: body}], ), ]; - for (const expectedStep of steps) { + steps.forEach((expectedStep) => { if (didExecute) { expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); } else { expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); } - } + }); }; const assertCreateNewVersionJobExecuted = (workflowResult, didExecute = true) => { @@ -194,13 +229,13 @@ const assertCreateNewVersionJobExecuted = (workflowResult, didExecute = true) => ), ]; - for (const expectedStep of steps) { + steps.forEach((expectedStep) => { if (didExecute) { expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); } else { expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); } - } + }); }; const assertUpdateStagingJobExecuted = (workflowResult, didExecute = true, shouldCp = false) => { @@ -302,13 +337,13 @@ const assertUpdateStagingJobExecuted = (workflowResult, didExecute = true, shoul ); } - for (const expectedStep of steps) { + steps.forEach((expectedStep) => { if (didExecute) { expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); } else { expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); } - } + }); }; const assertUpdateStagingJobFailed = (workflowResult, didFail = false) => { @@ -323,13 +358,13 @@ const assertUpdateStagingJobFailed = (workflowResult, didFail = false) => { ), ]; - for (const expectedStep of steps) { + steps.forEach((expectedStep) => { if (didFail) { expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); } else { expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); } - } + }); }; module.exports = { diff --git a/workflow_tests/assertions/reviewerChecklistAssertions.js b/workflow_tests/assertions/reviewerChecklistAssertions.js index a77790724f77..79d7e899d727 100644 --- a/workflow_tests/assertions/reviewerChecklistAssertions.js +++ b/workflow_tests/assertions/reviewerChecklistAssertions.js @@ -13,13 +13,13 @@ const assertChecklistJobExecuted = (workflowResult, didExecute = true) => { ), ]; - for (const expectedStep of steps) { + steps.forEach((expectedStep) => { if (didExecute) { expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); } else { expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); } - } + }); }; module.exports = { diff --git a/workflow_tests/assertions/testAssertions.js b/workflow_tests/assertions/testAssertions.js index 78c5b9f7509d..42439b377a86 100644 --- a/workflow_tests/assertions/testAssertions.js +++ b/workflow_tests/assertions/testAssertions.js @@ -49,24 +49,25 @@ const assertJestJobExecuted = (workflowResult, didExecute = true, timesExecuted ), ]; - for (const expectedStep of steps) { + steps.forEach((expectedStep) => { if (didExecute) { expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); let cnt = 0; - for (const executedStep of workflowResult) { + workflowResult.forEach((executedStep) => { if ( - executedStep.name === expectedStep.name - && executedStep.output === expectedStep.output - && executedStep.status === expectedStep.status + !executedStep.name === expectedStep.name + || !executedStep.output === expectedStep.output + || !executedStep.status === expectedStep.status ) { - cnt += 1; + return; } - } + cnt += 1; + }); expect(cnt).toEqual(timesExecuted); } else { expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); } - } + }); }; const assertShellTestsJobExecuted = (workflowResult, didExecute = true) => { const steps = [ @@ -99,13 +100,13 @@ const assertShellTestsJobExecuted = (workflowResult, didExecute = true) => { ), ]; - for (const expectedStep of steps) { + steps.forEach((expectedStep) => { if (didExecute) { expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); } else { expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); } - } + }); }; module.exports = { diff --git a/workflow_tests/assertions/testBuildAssertions.js b/workflow_tests/assertions/testBuildAssertions.js index 87d78f35e9dd..5f425c687952 100644 --- a/workflow_tests/assertions/testBuildAssertions.js +++ b/workflow_tests/assertions/testBuildAssertions.js @@ -22,13 +22,13 @@ const assertValidateActorJobExecuted = (workflowResult, actor = 'Dummy Actor', p ), ]; - for (const expectedStep of steps) { + steps.forEach((expectedStep) => { if (didExecute) { expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); } else { expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); } - } + }); }; const assertGetBranchRefJobExecuted = (workflowResult, didExecute = true) => { const steps = [ @@ -52,13 +52,13 @@ const assertGetBranchRefJobExecuted = (workflowResult, didExecute = true) => { ), ]; - for (const expectedStep of steps) { + steps.forEach((expectedStep) => { if (didExecute) { expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); } else { expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); } - } + }); }; const assertAndroidJobExecuted = (workflowResult, ref = '', didExecute = true, failsAt = -1) => { const steps = [ @@ -150,14 +150,14 @@ const assertAndroidJobExecuted = (workflowResult, ref = '', didExecute = true, f ), ]; - for (const [i, expectedStep] of steps.entries()) { + steps.entries.forEach(([i, expectedStep]) => { if (didExecute) { if (failsAt === -1 || i < failsAt) { // either whole job is successful, or steps up to this point are successful expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); } else if (i === failsAt) { // this is the failing step - expectedStep.status = 1; + steps[i].status = 1; expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); } else { // steps after failed one do not execute @@ -166,7 +166,7 @@ const assertAndroidJobExecuted = (workflowResult, ref = '', didExecute = true, f } else { expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); } - } + }); }; const assertIOSJobExecuted = (workflowResult, ref = '', didExecute = true, failsAt = -1) => { const steps = [ @@ -271,14 +271,14 @@ const assertIOSJobExecuted = (workflowResult, ref = '', didExecute = true, fails ), ]; - for (const [i, expectedStep] of steps.entries()) { + steps.entries().forEach(([i, expectedStep]) => { if (didExecute) { if (failsAt === -1 || i < failsAt) { // either whole job is successful, or steps up to this point are successful expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); } else if (i === failsAt) { // this is the failing step - expectedStep.status = 1; + steps[i].status = 1; expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); } else { // steps after failed one do not execute @@ -287,7 +287,7 @@ const assertIOSJobExecuted = (workflowResult, ref = '', didExecute = true, fails } else { expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); } - } + }); }; const assertDesktopJobExecuted = (workflowResult, ref = '', didExecute = true, failsAt = -1) => { const steps = [ @@ -354,14 +354,14 @@ const assertDesktopJobExecuted = (workflowResult, ref = '', didExecute = true, f ), ]; - for (const [i, expectedStep] of steps.entries()) { + steps.entries().forEach(([i, expectedStep]) => { if (didExecute) { if (failsAt === -1 || i < failsAt) { // either whole job is successful, or steps up to this point are successful expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); } else if (i === failsAt) { // this is the failing step - expectedStep.status = 1; + steps[i].status = 1; expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); } else { // steps after failed one do not execute @@ -370,7 +370,7 @@ const assertDesktopJobExecuted = (workflowResult, ref = '', didExecute = true, f } else { expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); } - } + }); }; const assertWebJobExecuted = (workflowResult, ref = '', didExecute = true, failsAt = -1) => { const steps = [ @@ -439,14 +439,14 @@ const assertWebJobExecuted = (workflowResult, ref = '', didExecute = true, fails ), ]; - for (const [i, expectedStep] of steps.entries()) { + steps.entries().forEach(([i, expectedStep]) => { if (didExecute) { if (failsAt === -1 || i < failsAt) { // either whole job is successful, or steps up to this point are successful expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); } else if (i === failsAt) { // this is the failing step - expectedStep.status = 1; + steps[i].status = 1; expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); } else { // steps after failed one do not execute @@ -455,9 +455,18 @@ const assertWebJobExecuted = (workflowResult, ref = '', didExecute = true, fails } else { expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); } - } + }); }; -const assertPostGithubCommentJobExecuted = (workflowResult, ref = '', pullRequestNumber = '1234', didExecute = true, androidStatus = 'success', iOSStatus = 'success', desktopStatus = 'success', webStatus = 'success') => { + +const assertPostGithubCommentJobExecuted = ( + workflowResult, ref = '', + pullRequestNumber = '1234', + didExecute = true, + androidStatus = 'success', + iOSStatus = 'success', + desktopStatus = 'success', + webStatus = 'success', +) => { const steps = [ utils.createStepAssertion( 'Checkout', @@ -541,13 +550,13 @@ const assertPostGithubCommentJobExecuted = (workflowResult, ref = '', pullReques ), ); - for (const expectedStep of steps) { + steps.forEach((expectedStep) => { if (didExecute) { expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); } else { expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); } - } + }); }; module.exports = { diff --git a/workflow_tests/assertions/validateGithubActionsAssertions.js b/workflow_tests/assertions/validateGithubActionsAssertions.js index 4bd990f9ac88..de7a699e2acc 100644 --- a/workflow_tests/assertions/validateGithubActionsAssertions.js +++ b/workflow_tests/assertions/validateGithubActionsAssertions.js @@ -40,13 +40,13 @@ const assertVerifyJobExecuted = (workflowResult, didExecute = true) => { ), ]; - for (const expectedStep of steps) { + steps.forEach((expectedStep) => { if (didExecute) { expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); } else { expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); } - } + }); }; module.exports = { diff --git a/workflow_tests/assertions/verifyPodfileAssertions.js b/workflow_tests/assertions/verifyPodfileAssertions.js index 502c78254661..8bce663eeb40 100644 --- a/workflow_tests/assertions/verifyPodfileAssertions.js +++ b/workflow_tests/assertions/verifyPodfileAssertions.js @@ -31,13 +31,13 @@ const assertVerifyJobExecuted = (workflowResult, didExecute = true) => { ), ]; - for (const expectedStep of steps) { + steps.forEach((expectedStep) => { if (didExecute) { expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); } else { expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); } - } + }); }; module.exports = { diff --git a/workflow_tests/assertions/verifySignedCommitsAssertions.js b/workflow_tests/assertions/verifySignedCommitsAssertions.js index 7ab98a3c1a6b..b85f30a7cfd0 100644 --- a/workflow_tests/assertions/verifySignedCommitsAssertions.js +++ b/workflow_tests/assertions/verifySignedCommitsAssertions.js @@ -13,13 +13,13 @@ const assertVerifySignedCommitsJobExecuted = (workflowResult, didExecute = true) ), ]; - for (const expectedStep of steps) { + steps.forEach((expectedStep) => { if (didExecute) { expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); } else { expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); } - } + }); }; module.exports = { diff --git a/workflow_tests/assertions/warnCPLabelAssertions.js b/workflow_tests/assertions/warnCPLabelAssertions.js index 5b2550e3eb3c..e547e1801db1 100644 --- a/workflow_tests/assertions/warnCPLabelAssertions.js +++ b/workflow_tests/assertions/warnCPLabelAssertions.js @@ -13,7 +13,7 @@ const assertWarnCPLabelJobExecuted = (workflowResult, didExecute = true, isSucce ), ]; - for (const expectedStep of steps) { + steps.forEach((expectedStep) => { if (didExecute) { if (isSuccessful) { expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); @@ -21,7 +21,7 @@ const assertWarnCPLabelJobExecuted = (workflowResult, didExecute = true, isSucce } else { expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); } - } + }); const failedSteps = [ utils.createStepAssertion( @@ -35,13 +35,13 @@ const assertWarnCPLabelJobExecuted = (workflowResult, didExecute = true, isSucce ), ]; - for (const step of failedSteps) { + failedSteps.forEach((step) => { if (didExecute && !isSuccessful) { expect(workflowResult).toEqual(expect.arrayContaining([step])); } else { expect(workflowResult).not.toEqual(expect.arrayContaining([step])); } - } + }); }; module.exports = { diff --git a/workflow_tests/cla.test.js b/workflow_tests/cla.test.js index 6ed6ce291395..61139fd7f7b5 100644 --- a/workflow_tests/cla.test.js +++ b/workflow_tests/cla.test.js @@ -81,7 +81,7 @@ describe('test workflow cla', () => { logFile: utils.getLogFilePath('cla', expect.getState().currentTestName), }); - assertions.assertCLAJobExecuted(result, commentBody, `${repoPath}/remote/origin`, true, false); + assertions.assertCLAJobExecuted(result, commentBody, `${repoPath}/remote/origin`, true); }); }); describe('check regex matches', () => { @@ -119,7 +119,7 @@ describe('test workflow cla', () => { logFile: utils.getLogFilePath('cla', expect.getState().currentTestName), }); - assertions.assertCLAJobExecuted(result, commentBody, `${repoPath}/remote/origin`, true, true); + assertions.assertCLAJobExecuted(result, commentBody, `${repoPath}/remote/origin`, true); }); }); describe('re-check regex matches', () => { @@ -157,7 +157,7 @@ describe('test workflow cla', () => { logFile: utils.getLogFilePath('cla', expect.getState().currentTestName), }); - assertions.assertCLAJobExecuted(result, commentBody, `${repoPath}/remote/origin`, true, true); + assertions.assertCLAJobExecuted(result, commentBody, `${repoPath}/remote/origin`, true); }); }); }); @@ -194,7 +194,7 @@ describe('test workflow cla', () => { logFile: utils.getLogFilePath('cla', expect.getState().currentTestName), }); - assertions.assertCLAJobExecuted(result, '', `${repoPath}/remote/origin`, true, true); + assertions.assertCLAJobExecuted(result, '', `${repoPath}/remote/origin`, true); }); }); }); diff --git a/workflow_tests/mocks/createNewVersionMocks.js b/workflow_tests/mocks/createNewVersionMocks.js index b69c79d9109d..e0c7703b0434 100644 --- a/workflow_tests/mocks/createNewVersionMocks.js +++ b/workflow_tests/mocks/createNewVersionMocks.js @@ -64,6 +64,7 @@ const CREATENEWVERSION__CREATENEWVERSION__CREATE_NEW_BRANCH__STEP_MOCK = utils.c [], [], [], + // eslint-disable-next-line no-template-curly-in-string {VERSION_BRANCH: 'version-${{ github.event.inputs.SEMVER_LEVEL }}-abcdef'}, ); const CREATENEWVERSION__CREATENEWVERSION__GENERATE_VERSION__STEP_MOCK = utils.createMockStep( diff --git a/workflow_tests/mocks/deployBlockerMocks.js b/workflow_tests/mocks/deployBlockerMocks.js index 549a34e2c295..e124eae5f173 100644 --- a/workflow_tests/mocks/deployBlockerMocks.js +++ b/workflow_tests/mocks/deployBlockerMocks.js @@ -16,8 +16,11 @@ const DEPLOYBLOCKER__DEPLOYBLOCKER__GET_URL_TITLE_AND_NUMBER_OF_NEW_DEPLOY_BLOCK ['TITLE'], {}, { + // eslint-disable-next-line no-template-curly-in-string DEPLOY_BLOCKER_URL: '${{ github.event.issue.html_url }}', + // eslint-disable-next-line no-template-curly-in-string DEPLOY_BLOCKER_NUMBER: '${{ github.event.issue.number }}', + // eslint-disable-next-line no-template-curly-in-string DEPLOY_BLOCKER_TITLE: '${{ github.event.issue.title }}', }, ); diff --git a/workflow_tests/mocks/preDeployMocks.js b/workflow_tests/mocks/preDeployMocks.js index 66c8eda9c336..02392e2261c9 100644 --- a/workflow_tests/mocks/preDeployMocks.js +++ b/workflow_tests/mocks/preDeployMocks.js @@ -268,6 +268,7 @@ const GET_MERGED_PULL_REQUEST_MOCK_STEP__WELCOME_MESSAGE__OSBOTIFY = utils.creat {number: '12345', author: 'OSBotify'}, ); const GET_PR_COUNT_MOCK_STEP__1 = utils.createMockStep( + // eslint-disable-next-line no-template-curly-in-string 'Get PR count for ${{ steps.getMergedPullRequest.outputs.author }}', 'Getting PR count', 'NEW_CONTRIBUTOR_WELCOME_MESSAGE', @@ -277,6 +278,7 @@ const GET_PR_COUNT_MOCK_STEP__1 = utils.createMockStep( {PR_COUNT: '1'}, ); const GET_PR_COUNT_MOCK_STEP__10 = utils.createMockStep( + // eslint-disable-next-line no-template-curly-in-string 'Get PR count for ${{ steps.getMergedPullRequest.outputs.author }}', 'Getting PR count', 'NEW_CONTRIBUTOR_WELCOME_MESSAGE', @@ -286,6 +288,7 @@ const GET_PR_COUNT_MOCK_STEP__10 = utils.createMockStep( {PR_COUNT: '10'}, ); const COMMENT_ON_FIRST_PULL_REQUEST_MOCK_STEP = utils.createMockStep( + // eslint-disable-next-line no-template-curly-in-string 'Comment on ${{ steps.getMergedPullRequest.outputs.author }}\\\'s first pull request!', 'Creating comment', 'NEW_CONTRIBUTOR_WELCOME_MESSAGE', diff --git a/workflow_tests/utils/ExtendedAct.js b/workflow_tests/utils/ExtendedAct.js index a9d887e2ab82..1cecd0976474 100644 --- a/workflow_tests/utils/ExtendedAct.js +++ b/workflow_tests/utils/ExtendedAct.js @@ -3,8 +3,8 @@ const kieActJs = require('@kie/act-js'); class ExtendedAct extends kieActJs.Act { async parseRunOpts(opts) { const {cwd, actArguments, proxy} = await super.parseRunOpts(opts); - if (opts?.actor) { - actArguments.push('--actor', opts?.actor); + if (opts && opts.actor) { + actArguments.push('--actor', opts.actor); } return {cwd, actArguments, proxy}; } diff --git a/workflow_tests/utils/preGenerateTest.js b/workflow_tests/utils/preGenerateTest.js index 80e701945ead..61d937119f6b 100644 --- a/workflow_tests/utils/preGenerateTest.js +++ b/workflow_tests/utils/preGenerateTest.js @@ -1,7 +1,9 @@ +/* eslint no-console: ["error", { allow: ["warn", "log"] }] */ const path = require('path'); -const {exit} = require("process"); +const {exit} = require('process'); const fs = require('fs'); const yaml = require('yaml'); +const _ = require('underscore'); const workflowsDirectory = path.resolve(__dirname, '..', '..', '.github', 'workflows'); const workflowTestsDirectory = path.resolve(__dirname, '..'); @@ -19,7 +21,7 @@ const assertionFileTemplate = (jobAssertions, exports) => `const utils = require ${jobAssertions} ${exports} `; -const testFileTemplate = (workflowName) => `const path = require('path'); +const testFileTemplate = workflowName => `const path = require('path'); const kieMockGithub = require('@kie/mock-github'); const utils = require('./utils/utils'); const assertions = require('./assertions/${workflowName}Assertions'); @@ -109,11 +111,11 @@ const stepAssertionTemplate = (step_name, job_id, step_message, inputs, envs) => null, '${job_id}', '${step_message}', - [${inputs.map((input) => `{key: '${input}', value: '[FILL_IN]'}`)}], - [${envs.map((env) => `{key: '${env}', value: '[FILL_IN]'}`)}], + [${_(inputs).map(input => `{key: '${input}', value: '[FILL_IN]'}`)}], + [${_(envs).map(env => `{key: '${env}', value: '[FILL_IN]'}`)}], ),`; const jobMocksTemplate = (jobMocksName, stepMocks) => ` -const ${jobMocksName} = [${stepMocks.map((stepMock) => ` +const ${jobMocksName} = [${_(stepMocks).map(stepMock => ` ${stepMock}`)} ];`; const jobAssertionTemplate = (jobAssertionName, stepAssertions) => ` @@ -129,108 +131,113 @@ const ${jobAssertionName} = (workflowResult, didExecute = true) => { } } };`; -const mocksExportsTemplate = (jobMocks) => ` +const mocksExportsTemplate = jobMocks => ` module.exports = { - ${jobMocks.map((jobMock) => `${jobMock}`)} + ${_(jobMocks).map(jobMock => `${jobMock}`)} };`; -const assertionsExportsTemplate = (jobAssertions) => ` +const assertionsExportsTemplate = jobAssertions => ` module.exports = { - ${jobAssertions.map((jobAssertion) => `${jobAssertion}`)} + ${_(jobAssertions).map(jobAssertion => `${jobAssertion}`)} };`; const checkArguments = (args) => { - if (args.length === 0 || !args[0]) { - console.warn('Please provide workflow file name'); - exit(1); + if (args.length > 0 && args[0]) { + return; } + console.warn('Please provide workflow file name'); + exit(1); }; const checkWorkflowFileName = (fileName) => { - if (!workflowFileRegex.test(fileName)) { - console.warn(`Please provide a valid workflow file name ([workflow].yml) instead of ${fileName}`); - exit(1); + if (workflowFileRegex.test(fileName)) { + return; } + console.warn(`Please provide a valid workflow file name ([workflow].yml) instead of ${fileName}`); + exit(1); }; const checkWorkflowFilePath = (filePath) => { - if (!fs.existsSync(filePath)) { - console.warn(`Provided workflow file does not exist: ${filePath}`); - exit(1); + if (fs.existsSync(filePath)) { + return; } + console.warn(`Provided workflow file does not exist: ${filePath}`); + exit(1); }; -const checkIfTestFileDoesNotExist = (testsDirectory, testFileName) => { - if (fs.existsSync(path.join(testsDirectory, testFileName))) { - console.warn(`The test file ${testFileName} already exists, exiting`); - exit(1); +const checkIfTestFileExists = (testsDirectory, testFileName) => { + if (!fs.existsSync(path.join(testsDirectory, testFileName))) { + return; } -} -const checkIfMocksFileDoesNotExist = (mocksDirectory, mocksFileName) => { - if (fs.existsSync(path.join(mocksDirectory, mocksFileName))) { - console.warn(`The mocks file ${mocksFileName} already exists, exiting`); - exit(1); + console.warn(`The test file ${testFileName} already exists, exiting`); + exit(1); +}; +const checkIfMocksFileExists = (mocksDirectory, mocksFileName) => { + if (!fs.existsSync(path.join(mocksDirectory, mocksFileName))) { + return; } -} -const checkIfAssertionsFileDoesNotExist = (assertionsDirectory, assertionsFileName) => { - if (fs.existsSync(path.join(assertionsDirectory, assertionsFileName))) { - console.warn(`The assertions file ${assertionsFileName} already exists, exiting`); - exit(1); + console.warn(`The mocks file ${mocksFileName} already exists, exiting`); + exit(1); +}; +const checkIfAssertionsFileExists = (assertionsDirectory, assertionsFileName) => { + if (!fs.existsSync(path.join(assertionsDirectory, assertionsFileName))) { + return; } -} + console.warn(`The assertions file ${assertionsFileName} already exists, exiting`); + exit(1); +}; const parseWorkflowFile = (workflow) => { const workflowJobs = {}; - for (const [jobId, job] of Object.entries(workflow.jobs)) { + Object.entries(workflow.jobs).forEach(([jobId, job]) => { workflowJobs[jobId] = { steps: [], }; - for (const step of job.steps) { + job.steps.forEach((step) => { const workflowStep = { name: step.name || '', - inputs: Object.keys(step.with || {}) || [], - envs: Object.keys(step.env || {}) || [], - } + inputs: _.keys(step.with || {}) || [], + envs: _.keys(step.env || {}) || [], + }; workflowJobs[jobId].steps.push(workflowStep); - } - } + }); + }); return workflowJobs; }; const getMockFileContent = (workflowName, jobs) => { let content = ''; const jobMocks = []; - for (const [jobId, job] of Object.entries(jobs)) { + Object.entries(jobs).forEach(([jobId, job]) => { let mockStepsContent = `\n// ${jobId.toLowerCase()}`; const stepMocks = []; - for (const step of job.steps) { - const stepMockName = `${workflowName.toUpperCase()}__${jobId.toUpperCase()}__${step.name.replaceAll(' ', '_').replaceAll('-', '_').replaceAll(',', '').replaceAll('#', '').toUpperCase()}__STEP_MOCK`; + job.steps.forEach((step) => { + const stepMockName = `${workflowName.toUpperCase()}__${jobId.toUpperCase()}__${step.name.replaceAll(' ', '_').replaceAll('-', '_').replaceAll(',', '').replaceAll('#', '') + .toUpperCase()}__STEP_MOCK`; stepMocks.push(stepMockName); mockStepsContent += mockStepTemplate(stepMockName, step, jobId); - } + }); const jobMocksName = `${workflowName.toUpperCase()}__${jobId.toUpperCase()}__STEP_MOCKS`; jobMocks.push(jobMocksName); mockStepsContent += jobMocksTemplate(jobMocksName, stepMocks); content += mockStepsContent; - } + }); return mockFileTemplate(content, mocksExportsTemplate(jobMocks)); }; const getAssertionsFileContent = (workflowName, jobs) => { let content = ''; const jobAssertions = []; - for (const [jobId, job] of Object.entries(jobs)) { + Object.entries(jobs).forEach(([jobId, job]) => { let stepAssertionsContent = ''; - for (const step of job.steps) { + job.steps.forEach((step) => { stepAssertionsContent += stepAssertionTemplate(step.name, jobId.toUpperCase(), step.name, step.inputs, step.envs); - } + }); const jobAssertionName = `assert${jobId.charAt(0).toUpperCase() + jobId.slice(1)}JobExecuted`; jobAssertions.push(jobAssertionName); content += jobAssertionTemplate(jobAssertionName, stepAssertionsContent); - } + }); return assertionFileTemplate(content, assertionsExportsTemplate(jobAssertions)); }; -const getTestFileContent = (workflowName) => { - return testFileTemplate(workflowName); -}; +const getTestFileContent = workflowName => testFileTemplate(workflowName); -const arguments = process.argv.slice(2); -checkArguments(arguments); +const call_args = process.argv.slice(2); +checkArguments(call_args); -const workflowFileName = arguments[0]; +const workflowFileName = call_args[0]; checkWorkflowFileName(workflowFileName); const workflowName = workflowFileName.slice(0, -4); @@ -238,13 +245,13 @@ const workflowFilePath = path.join(workflowsDirectory, workflowFileName); checkWorkflowFilePath(workflowFilePath); const workflowTestFileName = `${workflowName}.test.js`; -checkIfTestFileDoesNotExist(workflowTestsDirectory, workflowTestFileName); +checkIfTestFileExists(workflowTestsDirectory, workflowTestFileName); const workflowTestMocksFileName = `${workflowName}Mocks.js`; -checkIfMocksFileDoesNotExist(workflowTestMocksDirectory, workflowTestMocksFileName); +checkIfMocksFileExists(workflowTestMocksDirectory, workflowTestMocksFileName); const workflowTestAssertionsFileName = `${workflowName}Assertions.js`; -checkIfAssertionsFileDoesNotExist(workflowTestAssertionsDirectory, workflowTestAssertionsFileName); +checkIfAssertionsFileExists(workflowTestAssertionsDirectory, workflowTestAssertionsFileName); const workflow = yaml.parse(fs.readFileSync(workflowFilePath, 'utf8')); const workflowJobs = parseWorkflowFile(workflow); diff --git a/workflow_tests/utils/utils.js b/workflow_tests/utils/utils.js index 21629e80603c..432a8e83fa59 100644 --- a/workflow_tests/utils/utils.js +++ b/workflow_tests/utils/utils.js @@ -25,9 +25,9 @@ function setUpActParams( } if (secrets) { - for (const [key, value] of Object.entries(secrets)) { + Object.entries(secrets).forEach(([key, value]) => { updated_act = updated_act.setSecret(key, value); - } + }); } if (githubToken) { @@ -35,15 +35,15 @@ function setUpActParams( } if (envVars) { - for (const [key, value] of Object.entries(envVars)) { + Object.entries(envVars).forEach(([key, value]) => { updated_act = updated_act.setEnv(key, value); - } + }); } if (inputs) { - for (const [key, value] of Object.entries(inputs)) { + Object.entries(inputs).forEach(([key, value]) => { updated_act = updated_act.setInput(key, value); - } + }); } return updated_act; @@ -66,24 +66,24 @@ function createMockStep( } mockWithCommand += ` ${message}`; if (inputs) { - for (const input of inputs) { + Object.entries(inputs).forEach((input) => { mockWithCommand += `, ${input}="\${{ inputs.${input} && inputs.${input} || github.event.inputs.${input} }}"`; - } + }); } if (in_envs) { - for (const env of in_envs) { + Object.entries(in_envs).forEach((env) => { mockWithCommand += `, ${env}="\${{ env.${env} }}"`; - } + }); } if (outputs) { - for (const [key, value] of Object.entries(outputs)) { + Object.entries(outputs).forEach(([key, value]) => { mockWithCommand += `\necho "${key}=${value}" >> "$GITHUB_OUTPUT"`; - } + }); } if (out_envs) { - for (const [key, value] of Object.entries(out_envs)) { + Object.entries(out_envs).forEach(([key, value]) => { mockWithCommand += `\necho "${key}=${value}" >> "$GITHUB_ENV"`; - } + }); } if (!isSuccessful) { mockWithCommand += '\nexit 1'; @@ -117,14 +117,14 @@ function createStepAssertion( stepOutput += ` ${message}`; } if (inputs) { - for (const input of inputs) { + Object.entries(inputs).forEach((input) => { stepOutput += `, ${input.key}=${input.value}`; - } + }); } if (envs) { - for (const env of envs) { + Object.entries(envs).forEach((env) => { stepOutput += `, ${env.key}=${env.value}`; - } + }); } } return { @@ -140,10 +140,10 @@ function setJobRunners(act, jobs, workflowPath) { } const workflow = yaml.parse(fs.readFileSync(workflowPath, 'utf8')); - for (const [jobId, runner] of Object.entries(jobs)) { + Object.entries(jobs).forEach(([jobId, runner]) => { const job = workflow.jobs[jobId]; job['runs-on'] = runner; - } + }); fs.writeFileSync(workflowPath, yaml.stringify(workflow), 'utf8'); return act; } From 3dd9843813d42c73a2dde6904d9591b14d88b08c Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Thu, 25 May 2023 17:30:24 +0200 Subject: [PATCH 086/504] Fix failing tests Resolved issues with tests that started failing after syncing with main repo See: https://github.com/Expensify/App/issues/13604 --- workflow_tests/assertions/claAssertions.js | 4 ++-- .../assertions/platformDeployAssertions.js | 8 ++++++++ workflow_tests/assertions/testAssertions.js | 6 +++--- workflow_tests/assertions/testBuildAssertions.js | 16 ++++++++++++---- workflow_tests/cla.test.js | 8 ++++---- workflow_tests/mocks/platformDeployMocks.js | 7 +++++++ workflow_tests/mocks/testBuildMocks.js | 7 +++++++ workflow_tests/testBuild.test.js | 4 ++-- workflow_tests/utils/utils.js | 11 ++++++----- 9 files changed, 51 insertions(+), 20 deletions(-) diff --git a/workflow_tests/assertions/claAssertions.js b/workflow_tests/assertions/claAssertions.js index 0ab309c4b9c0..9cb6654b6450 100644 --- a/workflow_tests/assertions/claAssertions.js +++ b/workflow_tests/assertions/claAssertions.js @@ -1,6 +1,6 @@ const utils = require('../utils/utils'); -const assertCLAJobExecuted = (workflowResult, commentBody = '', githubRepository = '', didExecute = true) => { +const assertCLAJobExecuted = (workflowResult, commentBody = '', githubRepository = '', didExecute = true, runAssistant = true) => { const steps = [ utils.createStepAssertion( 'CLA comment check', @@ -51,7 +51,7 @@ const assertCLAJobExecuted = (workflowResult, commentBody = '', githubRepository ]; assistantSteps.forEach((step) => { - if (didExecute) { + if (didExecute && runAssistant) { expect(workflowResult).toEqual(expect.arrayContaining([step])); } else { expect(workflowResult).not.toEqual(expect.arrayContaining([step])); diff --git a/workflow_tests/assertions/platformDeployAssertions.js b/workflow_tests/assertions/platformDeployAssertions.js index 60a0def4a5c1..6ec74c9a96fa 100644 --- a/workflow_tests/assertions/platformDeployAssertions.js +++ b/workflow_tests/assertions/platformDeployAssertions.js @@ -251,6 +251,14 @@ const assertIOSJobExecuted = (workflowResult, didExecute = true, isProduction = 'Setting up Ruby', [{key: 'ruby-version', value: '2.7'}, {key: 'bundler-cache', value: 'true'}], ), + utils.createStepAssertion( + 'Cache', + true, + null, + 'IOS', + 'Caching', + [{key: 'path', value: 'ios/Pods'}, {key: 'key', value: 'Linux-pods-'}, {key: 'restore-keys', value: 'Linux-pods-'}], + ), utils.createStepAssertion( 'Install cocoapods', true, diff --git a/workflow_tests/assertions/testAssertions.js b/workflow_tests/assertions/testAssertions.js index 42439b377a86..de55eb990ae9 100644 --- a/workflow_tests/assertions/testAssertions.js +++ b/workflow_tests/assertions/testAssertions.js @@ -55,9 +55,9 @@ const assertJestJobExecuted = (workflowResult, didExecute = true, timesExecuted let cnt = 0; workflowResult.forEach((executedStep) => { if ( - !executedStep.name === expectedStep.name - || !executedStep.output === expectedStep.output - || !executedStep.status === expectedStep.status + executedStep.name !== expectedStep.name + || executedStep.output !== expectedStep.output + || executedStep.status !== expectedStep.status ) { return; } diff --git a/workflow_tests/assertions/testBuildAssertions.js b/workflow_tests/assertions/testBuildAssertions.js index 5f425c687952..186b6d6f6548 100644 --- a/workflow_tests/assertions/testBuildAssertions.js +++ b/workflow_tests/assertions/testBuildAssertions.js @@ -150,7 +150,7 @@ const assertAndroidJobExecuted = (workflowResult, ref = '', didExecute = true, f ), ]; - steps.entries.forEach(([i, expectedStep]) => { + steps.forEach((expectedStep, i) => { if (didExecute) { if (failsAt === -1 || i < failsAt) { // either whole job is successful, or steps up to this point are successful @@ -206,6 +206,14 @@ const assertIOSJobExecuted = (workflowResult, ref = '', didExecute = true, fails [{key: 'ruby-version', value: '2.7'}, {key: 'bundler-cache', value: true}], [], ), + utils.createStepAssertion( + 'Cache', + true, + null, + 'IOS', + 'Caching', + [{key: 'path', value: 'ios/Pods'}, {key: 'key', value: 'Linux-pods-'}, {key: 'restore-keys', value: 'Linux-pods-'}], + ), utils.createStepAssertion( 'Install cocoapods', true, @@ -271,7 +279,7 @@ const assertIOSJobExecuted = (workflowResult, ref = '', didExecute = true, fails ), ]; - steps.entries().forEach(([i, expectedStep]) => { + steps.forEach((expectedStep, i) => { if (didExecute) { if (failsAt === -1 || i < failsAt) { // either whole job is successful, or steps up to this point are successful @@ -354,7 +362,7 @@ const assertDesktopJobExecuted = (workflowResult, ref = '', didExecute = true, f ), ]; - steps.entries().forEach(([i, expectedStep]) => { + steps.forEach((expectedStep, i) => { if (didExecute) { if (failsAt === -1 || i < failsAt) { // either whole job is successful, or steps up to this point are successful @@ -439,7 +447,7 @@ const assertWebJobExecuted = (workflowResult, ref = '', didExecute = true, fails ), ]; - steps.entries().forEach(([i, expectedStep]) => { + steps.forEach((expectedStep, i) => { if (didExecute) { if (failsAt === -1 || i < failsAt) { // either whole job is successful, or steps up to this point are successful diff --git a/workflow_tests/cla.test.js b/workflow_tests/cla.test.js index 61139fd7f7b5..6ed6ce291395 100644 --- a/workflow_tests/cla.test.js +++ b/workflow_tests/cla.test.js @@ -81,7 +81,7 @@ describe('test workflow cla', () => { logFile: utils.getLogFilePath('cla', expect.getState().currentTestName), }); - assertions.assertCLAJobExecuted(result, commentBody, `${repoPath}/remote/origin`, true); + assertions.assertCLAJobExecuted(result, commentBody, `${repoPath}/remote/origin`, true, false); }); }); describe('check regex matches', () => { @@ -119,7 +119,7 @@ describe('test workflow cla', () => { logFile: utils.getLogFilePath('cla', expect.getState().currentTestName), }); - assertions.assertCLAJobExecuted(result, commentBody, `${repoPath}/remote/origin`, true); + assertions.assertCLAJobExecuted(result, commentBody, `${repoPath}/remote/origin`, true, true); }); }); describe('re-check regex matches', () => { @@ -157,7 +157,7 @@ describe('test workflow cla', () => { logFile: utils.getLogFilePath('cla', expect.getState().currentTestName), }); - assertions.assertCLAJobExecuted(result, commentBody, `${repoPath}/remote/origin`, true); + assertions.assertCLAJobExecuted(result, commentBody, `${repoPath}/remote/origin`, true, true); }); }); }); @@ -194,7 +194,7 @@ describe('test workflow cla', () => { logFile: utils.getLogFilePath('cla', expect.getState().currentTestName), }); - assertions.assertCLAJobExecuted(result, '', `${repoPath}/remote/origin`, true); + assertions.assertCLAJobExecuted(result, '', `${repoPath}/remote/origin`, true, true); }); }); }); diff --git a/workflow_tests/mocks/platformDeployMocks.js b/workflow_tests/mocks/platformDeployMocks.js index e03e91e5ee01..15b2c9b24f53 100644 --- a/workflow_tests/mocks/platformDeployMocks.js +++ b/workflow_tests/mocks/platformDeployMocks.js @@ -172,6 +172,12 @@ const PLATFORM_DEPLOY__IOS__SETUP_RUBY__STEP_MOCK = utils.createMockStep( 'IOS', ['ruby-version', 'bundler-cache'], ); +const PLATFORM_DEPLOY__IOS__CACHE__STEP_MOCK = utils.createMockStep( + 'Cache', + 'Caching', + 'IOS', + ['path', 'key', 'restore-keys'], +); const PLATFORM_DEPLOY__IOS__COCOAPODS__STEP_MOCK = utils.createMockStep( 'Install cocoapods', 'Installing cocoapods', @@ -246,6 +252,7 @@ const PLATFORM_DEPLOY__IOS__STEP_MOCKS = [ PLATFORM_DEPLOY__IOS__CHECKOUT__STEP_MOCK, PLATFORM_DEPLOY__IOS__SETUP_NODE__STEP_MOCK, PLATFORM_DEPLOY__IOS__SETUP_RUBY__STEP_MOCK, + PLATFORM_DEPLOY__IOS__CACHE__STEP_MOCK, PLATFORM_DEPLOY__IOS__COCOAPODS__STEP_MOCK, PLATFORM_DEPLOY__IOS__DECRYPT_PROFILE__STEP_MOCK, PLATFORM_DEPLOY__IOS__DECRYPT_CERTIFICATE__STEP_MOCK, diff --git a/workflow_tests/mocks/testBuildMocks.js b/workflow_tests/mocks/testBuildMocks.js index a8a3d77150b5..ba2cf04d5f95 100644 --- a/workflow_tests/mocks/testBuildMocks.js +++ b/workflow_tests/mocks/testBuildMocks.js @@ -176,6 +176,12 @@ const TESTBUILD__IOS__SETUP_RUBY__STEP_MOCK = utils.createMockStep( ['ruby-version', 'bundler-cache'], [], ); +const TESTBUILD__IOS__CACHE__STEP_MOCK = utils.createMockStep( + 'Cache', + 'Caching', + 'IOS', + ['path', 'key', 'restore-keys'], +); const TESTBUILD__IOS__INSTALL_COCOAPODS__STEP_MOCK = utils.createMockStep( 'Install cocoapods', 'Install cocoapods', @@ -223,6 +229,7 @@ const TESTBUILD__IOS__STEP_MOCKS = [ TESTBUILD__IOS__CREATE_ENV_ADHOC__STEP_MOCK, TESTBUILD__IOS__SETUP_NODE__STEP_MOCK, TESTBUILD__IOS__SETUP_RUBY__STEP_MOCK, + TESTBUILD__IOS__CACHE__STEP_MOCK, TESTBUILD__IOS__INSTALL_COCOAPODS__STEP_MOCK, TESTBUILD__IOS__DECRYPT_PROFILE__STEP_MOCK, TESTBUILD__IOS__DECRYPT_CERTIFICATE__STEP_MOCK, diff --git a/workflow_tests/testBuild.test.js b/workflow_tests/testBuild.test.js index 68153caae550..aca6f318252b 100644 --- a/workflow_tests/testBuild.test.js +++ b/workflow_tests/testBuild.test.js @@ -318,7 +318,7 @@ describe('test workflow testBuild', () => { web: mocks.TESTBUILD__WEB__STEP_MOCKS, postGithubComment: mocks.TESTBUILD__POSTGITHUBCOMMENT__STEP_MOCKS, }; - testMockSteps.iOS[4] = utils.createMockStep( + testMockSteps.iOS[5] = utils.createMockStep( 'Install cocoapods', 'Install cocoapods', 'IOS', @@ -339,7 +339,7 @@ describe('test workflow testBuild', () => { assertions.assertValidateActorJobExecuted(result, actor, '1234'); assertions.assertGetBranchRefJobExecuted(result); assertions.assertAndroidJobExecuted(result, 'test-ref'); - assertions.assertIOSJobExecuted(result, 'test-ref', true, 4); + assertions.assertIOSJobExecuted(result, 'test-ref', true, 5); assertions.assertDesktopJobExecuted(result, 'test-ref'); assertions.assertWebJobExecuted(result, 'test-ref'); assertions.assertPostGithubCommentJobExecuted(result, 'test-ref', '1234', true, 'success', 'failure', 'success', 'success'); diff --git a/workflow_tests/utils/utils.js b/workflow_tests/utils/utils.js index 432a8e83fa59..b099daae7595 100644 --- a/workflow_tests/utils/utils.js +++ b/workflow_tests/utils/utils.js @@ -66,12 +66,12 @@ function createMockStep( } mockWithCommand += ` ${message}`; if (inputs) { - Object.entries(inputs).forEach((input) => { + inputs.forEach((input) => { mockWithCommand += `, ${input}="\${{ inputs.${input} && inputs.${input} || github.event.inputs.${input} }}"`; }); } if (in_envs) { - Object.entries(in_envs).forEach((env) => { + in_envs.forEach((env) => { mockWithCommand += `, ${env}="\${{ env.${env} }}"`; }); } @@ -117,12 +117,12 @@ function createStepAssertion( stepOutput += ` ${message}`; } if (inputs) { - Object.entries(inputs).forEach((input) => { + inputs.forEach((input) => { stepOutput += `, ${input.key}=${input.value}`; }); } if (envs) { - Object.entries(envs).forEach((env) => { + envs.forEach((env) => { stepOutput += `, ${env.key}=${env.value}`; }); } @@ -161,7 +161,8 @@ function getLogFilePath(workflowName, testName) { if (!fs.existsSync(workflowTestsLogDir)) { fs.mkdirSync(workflowTestsLogDir); } - return path.resolve(workflowTestsLogDir, `${testName}.log`); + const cleanTestName = testName.replace(' ', '_').replace('-', '_').substr(0, 240); + return path.resolve(workflowTestsLogDir, `${cleanTestName}.log`); } function removeMockRepoDir() { From 079c05238fef0c9389f6d18036d56e5cfcf68f36 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Fri, 26 May 2023 11:22:07 +0200 Subject: [PATCH 087/504] Run prettier Run prettier command to reformat the code See: https://github.com/Expensify/App/issues/13604 --- .github/workflows/preDeploy.yml | 1 + .../assertions/authorChecklistAssertions.js | 12 +- .../assertions/cherryPickAssertions.js | 155 ++--- workflow_tests/assertions/claAssertions.js | 15 +- .../assertions/createNewVersionAssertions.js | 77 +-- workflow_tests/assertions/deployAssertions.js | 110 +--- .../assertions/deployBlockerAssertions.js | 30 +- .../finishReleaseCycleAssertions.js | 32 +- workflow_tests/assertions/lintAssertions.js | 40 +- .../assertions/lockDeploysAssertions.js | 42 +- .../assertions/platformDeployAssertions.js | 556 ++++------------- .../assertions/preDeployAssertions.js | 293 +++------ .../assertions/reviewerChecklistAssertions.js | 12 +- workflow_tests/assertions/testAssertions.js | 84 +-- .../assertions/testBuildAssertions.js | 291 +++------ .../validateGithubActionsAssertions.js | 40 +- .../assertions/verifyPodfileAssertions.js | 30 +- .../verifySignedCommitsAssertions.js | 12 +- .../assertions/warnCPLabelAssertions.js | 10 +- workflow_tests/authorChecklist.test.js | 126 ++-- workflow_tests/cherryPick.test.js | 260 ++++---- workflow_tests/cla.test.js | 107 ++-- workflow_tests/createNewVersion.test.js | 126 ++-- workflow_tests/deploy.test.js | 104 ++- workflow_tests/deployBlocker.test.js | 69 +- workflow_tests/finishReleaseCycle.test.js | 87 ++- workflow_tests/lint.test.js | 105 ++-- workflow_tests/lockDeploys.test.js | 161 ++--- workflow_tests/mocks/authorChecklistMocks.js | 12 +- workflow_tests/mocks/cherryPickMocks.js | 78 +-- workflow_tests/mocks/claMocks.js | 56 +- workflow_tests/mocks/createNewVersionMocks.js | 69 +- workflow_tests/mocks/deployBlockerMocks.js | 8 +- workflow_tests/mocks/deployMocks.js | 94 +-- .../mocks/finishReleaseCycleMocks.js | 16 +- workflow_tests/mocks/lintMocks.js | 32 +- workflow_tests/mocks/lockDeploysMocks.js | 8 +- workflow_tests/mocks/platformDeployMocks.js | 382 +++--------- workflow_tests/mocks/preDeployMocks.js | 176 ++---- .../mocks/reviewerChecklistMocks.js | 12 +- workflow_tests/mocks/testBuildMocks.js | 237 ++----- workflow_tests/mocks/testMocks.js | 74 +-- .../mocks/validateGithubActionsMocks.js | 24 +- workflow_tests/mocks/verifyPodfileMocks.js | 30 +- .../mocks/verifySignedCommitsMocks.js | 4 +- workflow_tests/platformDeploy.test.js | 39 +- workflow_tests/preDeploy.test.js | 407 +++++------- workflow_tests/reviewerChecklist.test.js | 42 +- workflow_tests/test.test.js | 126 ++-- workflow_tests/testBuild.test.js | 590 +++++------------- workflow_tests/utils/preGenerateTest.js | 30 +- workflow_tests/utils/utils.js | 31 +- workflow_tests/validateGithubActions.test.js | 42 +- workflow_tests/verifyPodfile.test.js | 108 +--- workflow_tests/verifySignedCommits.test.js | 42 +- workflow_tests/warnCPLabel.test.js | 63 +- 56 files changed, 1625 insertions(+), 4194 deletions(-) diff --git a/.github/workflows/preDeploy.yml b/.github/workflows/preDeploy.yml index 8678931b935e..95a404bda2da 100644 --- a/.github/workflows/preDeploy.yml +++ b/.github/workflows/preDeploy.yml @@ -243,6 +243,7 @@ jobs: e2ePerformanceTests: needs: [chooseDeployActions] + runs-on: ubuntu-20.04-64core if: ${{ needs.chooseDeployActions.outputs.SHOULD_DEPLOY }} steps: - name: Perform E2E tests diff --git a/workflow_tests/assertions/authorChecklistAssertions.js b/workflow_tests/assertions/authorChecklistAssertions.js index 1ad45b4cb3d9..c57fe922c754 100644 --- a/workflow_tests/assertions/authorChecklistAssertions.js +++ b/workflow_tests/assertions/authorChecklistAssertions.js @@ -1,17 +1,7 @@ const utils = require('../utils/utils'); const assertChecklistJobExecuted = (workflowResult, didExecute = true) => { - const steps = [ - utils.createStepAssertion( - 'authorChecklist.js', - true, - null, - 'CHECKLIST', - 'Running authorChecklist.js', - [{key: 'GITHUB_TOKEN', value: '***'}], - [], - ), - ]; + const steps = [utils.createStepAssertion('authorChecklist.js', true, null, 'CHECKLIST', 'Running authorChecklist.js', [{key: 'GITHUB_TOKEN', value: '***'}], [])]; steps.forEach((expectedStep) => { if (didExecute) { diff --git a/workflow_tests/assertions/cherryPickAssertions.js b/workflow_tests/assertions/cherryPickAssertions.js index 7bc4fb12be44..904732d9ebd6 100644 --- a/workflow_tests/assertions/cherryPickAssertions.js +++ b/workflow_tests/assertions/cherryPickAssertions.js @@ -8,7 +8,11 @@ const assertValidateActorJobExecuted = (workflowResult, username = 'Dummy Author null, 'VALIDATEACTOR', 'Checking if user is a deployer', - [{key: 'GITHUB_TOKEN', value: '***'}, {key: 'username', value: username}, {key: 'team', value: 'mobile-deployers'}], + [ + {key: 'GITHUB_TOKEN', value: '***'}, + {key: 'username', value: username}, + {key: 'team', value: 'mobile-deployers'}, + ], [], ), ]; @@ -23,17 +27,7 @@ const assertValidateActorJobExecuted = (workflowResult, username = 'Dummy Author }; const assertCreateNewVersionJobExecuted = (workflowResult, didExecute = true) => { - const steps = [ - utils.createStepAssertion( - 'Create new version', - true, - null, - 'CREATENEWVERSION', - 'Creating new version', - [], - [], - ), - ]; + const steps = [utils.createStepAssertion('Create new version', true, null, 'CREATENEWVERSION', 'Creating new version', [], [])]; steps.forEach((expectedStep) => { if (didExecute) { @@ -64,102 +58,56 @@ const assertCherryPickJobExecuted = ( null, 'CHERRYPICK', 'Checking out staging branch', - [{key: 'ref', value: 'staging'}, {key: 'token', value: '***'}], - [], - ), - utils.createStepAssertion( - 'Set up git for OSBotify', - true, - null, - 'CHERRYPICK', - 'Setting up git for OSBotify', - [{key: 'GPG_PASSPHRASE', value: '***'}], - [], - ), - utils.createStepAssertion( - 'Create branch for new pull request', - true, - null, - 'CHERRYPICK', - 'Creating branch for new pull request', - [], + [ + {key: 'ref', value: 'staging'}, + {key: 'token', value: '***'}, + ], [], ), + utils.createStepAssertion('Set up git for OSBotify', true, null, 'CHERRYPICK', 'Setting up git for OSBotify', [{key: 'GPG_PASSPHRASE', value: '***'}], []), + utils.createStepAssertion('Create branch for new pull request', true, null, 'CHERRYPICK', 'Creating branch for new pull request', [], []), utils.createStepAssertion( 'Get merge commit for CP pull request', true, null, 'CHERRYPICK', 'Getting merge commit for CP pull request', - [{key: 'GITHUB_TOKEN', value: '***'}, {key: 'USER', value: user}, {key: 'PULL_REQUEST_NUMBER', value: pullRequestNumber}], + [ + {key: 'GITHUB_TOKEN', value: '***'}, + {key: 'USER', value: user}, + {key: 'PULL_REQUEST_NUMBER', value: pullRequestNumber}, + ], [], ), - utils.createStepAssertion( - 'Save correct NEW_VERSION to env', - true, - inputNewVersion ? `New version is ${inputNewVersion}` : 'New version is', - ), + utils.createStepAssertion('Save correct NEW_VERSION to env', true, inputNewVersion ? `New version is ${inputNewVersion}` : 'New version is'), utils.createStepAssertion( 'Get merge commit for version-bump pull request', true, null, 'CHERRYPICK', 'Getting merge commit for version-bump pull request', - [{key: 'GITHUB_TOKEN', value: '***'}, {key: 'USER', value: 'OSBotify'}, {key: 'TITLE_REGEX', value: `Update version to ${newVersion}`}], - [], - ), - utils.createStepAssertion( - 'Cherry-pick the version-bump to new branch', - true, - null, - 'CHERRYPICK', - 'Cherry-picking the version-bump to new branch', - [], - [], - ), - utils.createStepAssertion( - 'Cherry-pick the merge commit of target PR to new branch', - true, - null, - 'CHERRYPICK', - 'Cherry-picking the merge commit of target PR to new branch', - [], - [], - ), - utils.createStepAssertion( - 'Push changes to CP branch', - true, - null, - 'CHERRYPICK', - 'Pushing changes to CP branch', - [], - [], - ), - utils.createStepAssertion( - 'Create Pull Request', - true, - null, - 'CHERRYPICK', - 'Creating Pull Request', - [], - [{key: 'GITHUB_TOKEN', value: '***'}], - ), - utils.createStepAssertion( - 'Check if ShortVersionString is up to date', - true, - null, - 'CHERRYPICK', - 'Checking if ShortVersionString is up to date', - [], + [ + {key: 'GITHUB_TOKEN', value: '***'}, + {key: 'USER', value: 'OSBotify'}, + {key: 'TITLE_REGEX', value: `Update version to ${newVersion}`}, + ], [], ), + utils.createStepAssertion('Cherry-pick the version-bump to new branch', true, null, 'CHERRYPICK', 'Cherry-picking the version-bump to new branch', [], []), + utils.createStepAssertion('Cherry-pick the merge commit of target PR to new branch', true, null, 'CHERRYPICK', 'Cherry-picking the merge commit of target PR to new branch', [], []), + utils.createStepAssertion('Push changes to CP branch', true, null, 'CHERRYPICK', 'Pushing changes to CP branch', [], []), + utils.createStepAssertion('Create Pull Request', true, null, 'CHERRYPICK', 'Creating Pull Request', [], [{key: 'GITHUB_TOKEN', value: '***'}]), + utils.createStepAssertion('Check if ShortVersionString is up to date', true, null, 'CHERRYPICK', 'Checking if ShortVersionString is up to date', [], []), utils.createStepAssertion( 'Check if pull request is mergeable', true, null, 'CHERRYPICK', 'Checking if pull request is mergeable', - [{key: 'GITHUB_TOKEN', value: '***'}, {key: 'PULL_REQUEST_NUMBER', value: pullRequestNumber}], + [ + {key: 'GITHUB_TOKEN', value: '***'}, + {key: 'PULL_REQUEST_NUMBER', value: pullRequestNumber}, + ], [], ), ]; @@ -193,15 +141,7 @@ const assertCherryPickJobExecuted = ( }); const manualMergeSteps = [ - utils.createStepAssertion( - 'Assign the PR to the deployer', - true, - null, - 'CHERRYPICK', - 'Assigning the PR to the deployer', - [], - [{key: 'GITHUB_TOKEN', value: '***'}], - ), + utils.createStepAssertion('Assign the PR to the deployer', true, null, 'CHERRYPICK', 'Assigning the PR to the deployer', [], [{key: 'GITHUB_TOKEN', value: '***'}]), utils.createStepAssertion( 'If PR has merge conflicts, comment with instructions for assignee', true, @@ -221,17 +161,7 @@ const assertCherryPickJobExecuted = ( } }); - const autoMergeSteps = [ - utils.createStepAssertion( - 'Auto-approve the PR', - true, - null, - 'CHERRYPICK', - 'Auto-approving the PR', - [], - [{key: 'GITHUB_TOKEN', value: '***'}], - ), - ]; + const autoMergeSteps = [utils.createStepAssertion('Auto-approve the PR', true, null, 'CHERRYPICK', 'Auto-approving the PR', [], [{key: 'GITHUB_TOKEN', value: '***'}])]; autoMergeSteps.forEach((step) => { if (didExecute && shouldAutomerge) { @@ -269,7 +199,10 @@ const assertCherryPickJobExecuted = ( 'CHERRYPICK', 'Announcing a CP failure', [{key: 'status', value: 'custom'}], - [{key: 'GITHUB_TOKEN', value: '***'}, {key: 'SLACK_WEBHOOK_URL', value: '***'}], + [ + {key: 'GITHUB_TOKEN', value: '***'}, + {key: 'SLACK_WEBHOOK_URL', value: '***'}, + ], ), ]; @@ -281,17 +214,7 @@ const assertCherryPickJobExecuted = ( } }); - const autoMergeableSteps = [ - utils.createStepAssertion( - 'Auto-merge the PR', - true, - null, - 'CHERRYPICK', - 'Auto-merging the PR', - [], - [{key: 'GITHUB_TOKEN', value: '***'}], - ), - ]; + const autoMergeableSteps = [utils.createStepAssertion('Auto-merge the PR', true, null, 'CHERRYPICK', 'Auto-merging the PR', [], [{key: 'GITHUB_TOKEN', value: '***'}])]; autoMergeableSteps.forEach((step) => { if (didExecute && shouldAutomerge && prIsMergeable) { diff --git a/workflow_tests/assertions/claAssertions.js b/workflow_tests/assertions/claAssertions.js index 9cb6654b6450..b85eb263d838 100644 --- a/workflow_tests/assertions/claAssertions.js +++ b/workflow_tests/assertions/claAssertions.js @@ -8,7 +8,10 @@ const assertCLAJobExecuted = (workflowResult, commentBody = '', githubRepository null, 'CLA', 'CLA comment check', - [{key: 'text', value: commentBody}, {key: 'regex', value: '\\s*I have read the CLA Document and I hereby sign the CLA\\s*'}], + [ + {key: 'text', value: commentBody}, + {key: 'regex', value: '\\s*I have read the CLA Document and I hereby sign the CLA\\s*'}, + ], [], ), utils.createStepAssertion( @@ -17,7 +20,10 @@ const assertCLAJobExecuted = (workflowResult, commentBody = '', githubRepository null, 'CLA', 'CLA comment re-check', - [{key: 'text', value: commentBody}, {key: 'regex', value: '\\s*recheck\\s*'}], + [ + {key: 'text', value: commentBody}, + {key: 'regex', value: '\\s*recheck\\s*'}, + ], [], ), ]; @@ -46,7 +52,10 @@ const assertCLAJobExecuted = (workflowResult, commentBody = '', githubRepository {key: 'lock-pullrequest-aftermerge', value: false}, {key: 'allowlist', value: 'OSBotify,snyk-bot'}, ], - [{key: 'GITHUB_TOKEN', value: '***'}, {key: 'PERSONAL_ACCESS_TOKEN', value: '***'}], + [ + {key: 'GITHUB_TOKEN', value: '***'}, + {key: 'PERSONAL_ACCESS_TOKEN', value: '***'}, + ], ), ]; diff --git a/workflow_tests/assertions/createNewVersionAssertions.js b/workflow_tests/assertions/createNewVersionAssertions.js index e1e9bcdcf82a..f32a447f0fff 100644 --- a/workflow_tests/assertions/createNewVersionAssertions.js +++ b/workflow_tests/assertions/createNewVersionAssertions.js @@ -1,17 +1,7 @@ const utils = require('../utils/utils'); const assertValidateActorJobExecuted = (workflowResult, didExecute = true) => { - const steps = [ - utils.createStepAssertion( - 'Get user permissions', - true, - null, - 'VALIDATEACTOR', - 'Get user permissions', - [], - [{key: 'GITHUB_TOKEN', value: '***'}], - ), - ]; + const steps = [utils.createStepAssertion('Get user permissions', true, null, 'VALIDATEACTOR', 'Get user permissions', [], [{key: 'GITHUB_TOKEN', value: '***'}])]; steps.forEach((expectedStep) => { if (didExecute) { @@ -23,60 +13,23 @@ const assertValidateActorJobExecuted = (workflowResult, didExecute = true) => { }; const assertCreateNewVersionJobExecuted = (workflowResult, semverLevel = 'BUILD', didExecute = true, isSuccessful = true) => { const steps = [ - utils.createStepAssertion( - 'Check out', - true, - null, - 'CREATENEWVERSION', - 'Check out', - [{key: 'fetch-depth', value: '0'}], - [], - ), - utils.createStepAssertion( - 'Setup git for OSBotify', - true, - null, - 'CREATENEWVERSION', - 'Setup git for OSBotify', - [{key: 'GPG_PASSPHRASE', value: '***'}], - [], - ), - utils.createStepAssertion( - 'Run turnstyle', - true, - null, - 'CREATENEWVERSION', - 'Run turnstyle', - [{key: 'poll-interval-seconds', value: '10'}], - [{key: 'GITHUB_TOKEN', value: '***'}], - ), - utils.createStepAssertion( - 'Create new branch', - true, - null, - 'CREATENEWVERSION', - 'Create new branch', - [], - [], - ), + utils.createStepAssertion('Check out', true, null, 'CREATENEWVERSION', 'Check out', [{key: 'fetch-depth', value: '0'}], []), + utils.createStepAssertion('Setup git for OSBotify', true, null, 'CREATENEWVERSION', 'Setup git for OSBotify', [{key: 'GPG_PASSPHRASE', value: '***'}], []), + utils.createStepAssertion('Run turnstyle', true, null, 'CREATENEWVERSION', 'Run turnstyle', [{key: 'poll-interval-seconds', value: '10'}], [{key: 'GITHUB_TOKEN', value: '***'}]), + utils.createStepAssertion('Create new branch', true, null, 'CREATENEWVERSION', 'Create new branch', [], []), utils.createStepAssertion( 'Generate version', true, null, 'CREATENEWVERSION', 'Generate version', - [{key: 'GITHUB_TOKEN', value: '***'}, {key: 'SEMVER_LEVEL', value: semverLevel}], - [], - ), - utils.createStepAssertion( - 'Commit new version', - true, - null, - 'CREATENEWVERSION', - 'Commit new version', - [], + [ + {key: 'GITHUB_TOKEN', value: '***'}, + {key: 'SEMVER_LEVEL', value: semverLevel}, + ], [], ), + utils.createStepAssertion('Commit new version', true, null, 'CREATENEWVERSION', 'Commit new version', [], []), utils.createStepAssertion( 'Update main branch', true, @@ -104,15 +57,7 @@ const assertCreateNewVersionJobExecuted = (workflowResult, semverLevel = 'BUILD' }); const failedSteps = [ - utils.createStepAssertion( - 'Announce failed workflow in Slack', - true, - null, - 'CREATENEWVERSION', - 'Announce failed workflow in Slack', - [{key: 'SLACK_WEBHOOK', value: '***'}], - [], - ), + utils.createStepAssertion('Announce failed workflow in Slack', true, null, 'CREATENEWVERSION', 'Announce failed workflow in Slack', [{key: 'SLACK_WEBHOOK', value: '***'}], []), ]; failedSteps.forEach((step) => { diff --git a/workflow_tests/assertions/deployAssertions.js b/workflow_tests/assertions/deployAssertions.js index d7f8f4677d9f..b6cac03b41ee 100644 --- a/workflow_tests/assertions/deployAssertions.js +++ b/workflow_tests/assertions/deployAssertions.js @@ -2,14 +2,7 @@ const utils = require('../utils/utils'); const assertValidateJobExecuted = (workflowResult, didExecute = true) => { const steps = [ - utils.createStepAssertion( - 'Get merged pull request', - true, - null, - 'VALIDATE', - 'Getting merged PR', - [{key: 'github_token', value: '***'}], - ), + utils.createStepAssertion('Get merged pull request', true, null, 'VALIDATE', 'Getting merged PR', [{key: 'github_token', value: '***'}]), { name: 'Main Check if merged pull request was an automatic version bump PR', status: 0, @@ -28,36 +21,13 @@ const assertValidateJobExecuted = (workflowResult, didExecute = true) => { const assertDeployStagingJobExecuted = (workflowResult, didExecute = true) => { const steps = [ - utils.createStepAssertion( - 'Checkout staging branch', - true, - null, - 'DEPLOY_STAGING', - 'Checking out staging branch', - [{key: 'ref', value: 'staging'}, {key: 'token', value: '***'}], - ), - utils.createStepAssertion( - 'Setup git for OSBotify', - true, - null, - 'DEPLOY_STAGING', - 'Setting up git for OSBotify', - [{key: 'GPG_PASSPHRASE', value: '***'}], - ), - utils.createStepAssertion( - 'Tag version', - true, - null, - 'DEPLOY_STAGING', - 'Tagging new version', - ), - utils.createStepAssertion( - '🚀 Push tags to trigger staging deploy 🚀', - true, - null, - 'DEPLOY_STAGING', - 'Pushing tag to trigger staging deploy', - ), + utils.createStepAssertion('Checkout staging branch', true, null, 'DEPLOY_STAGING', 'Checking out staging branch', [ + {key: 'ref', value: 'staging'}, + {key: 'token', value: '***'}, + ]), + utils.createStepAssertion('Setup git for OSBotify', true, null, 'DEPLOY_STAGING', 'Setting up git for OSBotify', [{key: 'GPG_PASSPHRASE', value: '***'}]), + utils.createStepAssertion('Tag version', true, null, 'DEPLOY_STAGING', 'Tagging new version'), + utils.createStepAssertion('🚀 Push tags to trigger staging deploy 🚀', true, null, 'DEPLOY_STAGING', 'Pushing tag to trigger staging deploy'), ]; steps.forEach((expectedStep) => { @@ -71,59 +41,29 @@ const assertDeployStagingJobExecuted = (workflowResult, didExecute = true) => { const assertDeployProductionJobExecuted = (workflowResult, didExecute = true) => { const steps = [ - utils.createStepAssertion( - 'Checkout', - true, - null, - 'DEPLOY_PRODUCTION', - 'Checking out', - [{key: 'fetch-depth', value: '0'}, {key: 'token', value: '***'}], - ), - utils.createStepAssertion( - 'Setup git for OSBotify', - true, - null, - 'DEPLOY_PRODUCTION', - 'Setting up git for OSBotify', - [{key: 'GPG_PASSPHRASE', value: '***'}], - ), - utils.createStepAssertion( - 'Checkout production branch', - true, - null, - 'DEPLOY_PRODUCTION', - 'Checking out production branch', - ), - utils.createStepAssertion( - 'Get current app version', - true, - null, - 'DEPLOY_PRODUCTION', - 'Getting current app version', - ), - utils.createStepAssertion( - 'Get Release Pull Request List', - true, - null, - 'DEPLOY_PRODUCTION', - 'Getting release PR list', - [{key: 'TAG', value: '1.2.3'}, {key: 'GITHUB_TOKEN', value: '***'}, {key: 'IS_PRODUCTION_DEPLOY', value: 'true'}], - ), - utils.createStepAssertion( - 'Generate Release Body', - true, - null, - 'DEPLOY_PRODUCTION', - 'Generating release body', - [{key: 'PR_LIST', value: '[1.2.1, 1.2.2]'}], - ), + utils.createStepAssertion('Checkout', true, null, 'DEPLOY_PRODUCTION', 'Checking out', [ + {key: 'fetch-depth', value: '0'}, + {key: 'token', value: '***'}, + ]), + utils.createStepAssertion('Setup git for OSBotify', true, null, 'DEPLOY_PRODUCTION', 'Setting up git for OSBotify', [{key: 'GPG_PASSPHRASE', value: '***'}]), + utils.createStepAssertion('Checkout production branch', true, null, 'DEPLOY_PRODUCTION', 'Checking out production branch'), + utils.createStepAssertion('Get current app version', true, null, 'DEPLOY_PRODUCTION', 'Getting current app version'), + utils.createStepAssertion('Get Release Pull Request List', true, null, 'DEPLOY_PRODUCTION', 'Getting release PR list', [ + {key: 'TAG', value: '1.2.3'}, + {key: 'GITHUB_TOKEN', value: '***'}, + {key: 'IS_PRODUCTION_DEPLOY', value: 'true'}, + ]), + utils.createStepAssertion('Generate Release Body', true, null, 'DEPLOY_PRODUCTION', 'Generating release body', [{key: 'PR_LIST', value: '[1.2.1, 1.2.2]'}]), utils.createStepAssertion( '🚀 Create release to trigger production deploy 🚀', true, null, 'DEPLOY_PRODUCTION', 'Creating release to trigger production deploy', - [{key: 'tag_name', value: '1.2.3'}, {key: 'body', value: 'Release body'}], + [ + {key: 'tag_name', value: '1.2.3'}, + {key: 'body', value: 'Release body'}, + ], [{key: 'GITHUB_TOKEN', value: '***'}], ), ]; diff --git a/workflow_tests/assertions/deployBlockerAssertions.js b/workflow_tests/assertions/deployBlockerAssertions.js index 917950f9b0b0..d3ca3e33209f 100644 --- a/workflow_tests/assertions/deployBlockerAssertions.js +++ b/workflow_tests/assertions/deployBlockerAssertions.js @@ -8,7 +8,10 @@ const assertDeployBlockerJobExecuted = (workflowResult, issueTitle, issueNumber, null, 'DEPLOYBLOCKER', 'Checkout', - [{key: 'fetch-depth', value: '0'}, {key: 'token', value: '***'}], + [ + {key: 'fetch-depth', value: '0'}, + {key: 'token', value: '***'}, + ], [], ), utils.createStepAssertion( @@ -35,7 +38,10 @@ const assertDeployBlockerJobExecuted = (workflowResult, issueTitle, issueNumber, null, 'DEPLOYBLOCKER', 'Give the issue/PR the Hourly, Engineering labels', - [{key: 'add-labels', value: 'Hourly, Engineering'}, {key: 'remove-labels', value: 'Daily, Weekly, Monthly'}], + [ + {key: 'add-labels', value: 'Hourly, Engineering'}, + {key: 'remove-labels', value: 'Daily, Weekly, Monthly'}, + ], [], ), utils.createStepAssertion( @@ -44,7 +50,10 @@ const assertDeployBlockerJobExecuted = (workflowResult, issueTitle, issueNumber, null, 'DEPLOYBLOCKER', 'Comment on deferred PR', - [{key: 'github_token', value: '***'}, {key: 'number', value: issueNumber}], + [ + {key: 'github_token', value: '***'}, + {key: 'number', value: issueNumber}, + ], [], ), ]; @@ -67,7 +76,10 @@ const assertDeployBlockerJobExecuted = (workflowResult, issueTitle, issueNumber, 'DEPLOYBLOCKER', 'Post the issue in the expensify-open-source slack room', [{key: 'status', value: 'custom'}], - [{key: 'GITHUB_TOKEN', value: '***'}, {key: 'SLACK_WEBHOOK_URL', value: '***'}], + [ + {key: 'GITHUB_TOKEN', value: '***'}, + {key: 'SLACK_WEBHOOK_URL', value: '***'}, + ], ), ]; @@ -80,15 +92,7 @@ const assertDeployBlockerJobExecuted = (workflowResult, issueTitle, issueNumber, }); const failedSteps = [ - utils.createStepAssertion( - 'Announce failed workflow in Slack', - true, - null, - 'DEPLOYBLOCKER', - 'Announce failed workflow in Slack', - [{key: 'SLACK_WEBHOOK', value: '***'}], - [], - ), + utils.createStepAssertion('Announce failed workflow in Slack', true, null, 'DEPLOYBLOCKER', 'Announce failed workflow in Slack', [{key: 'SLACK_WEBHOOK', value: '***'}], []), ]; failedSteps.forEach((step) => { diff --git a/workflow_tests/assertions/finishReleaseCycleAssertions.js b/workflow_tests/assertions/finishReleaseCycleAssertions.js index 234189e9f736..ca195297800c 100644 --- a/workflow_tests/assertions/finishReleaseCycleAssertions.js +++ b/workflow_tests/assertions/finishReleaseCycleAssertions.js @@ -117,17 +117,7 @@ const assertUpdateProductionJobExecuted = (workflowResult, didExecute = true) => }; const assertCreateNewPatchVersionJobExecuted = (workflowResult, didExecute = true) => { - const steps = [ - utils.createStepAssertion( - 'Create new version', - true, - null, - 'CREATENEWPATCHVERSION', - 'Creating new version', - [{key: 'SEMVER_LEVEL', value: 'PATCH'}], - [], - ), - ]; + const steps = [utils.createStepAssertion('Create new version', true, null, 'CREATENEWPATCHVERSION', 'Creating new version', [{key: 'SEMVER_LEVEL', value: 'PATCH'}], [])]; steps.forEach((expectedStep) => { if (didExecute) { @@ -153,15 +143,7 @@ const assertCreateNewStagingDeployCashJobExecuted = (workflowResult, newVersion ], [], ), - utils.createStepAssertion( - 'Tag version', - true, - null, - 'CREATENEWSTAGINGDEPLOYCASH', - 'Tagging version', - [], - [], - ), + utils.createStepAssertion('Tag version', true, null, 'CREATENEWSTAGINGDEPLOYCASH', 'Tagging version', [], []), utils.createStepAssertion( 'Create new StagingDeployCash', true, @@ -189,15 +171,7 @@ const assertCreateNewStagingDeployCashJobExecuted = (workflowResult, newVersion }); const failProdSteps = [ - utils.createStepAssertion( - 'Announce failed workflow in Slack', - true, - null, - 'CREATENEWSTAGINGDEPLOYCASH', - 'Announcing failed workflow', - [{key: 'SLACK_WEBHOOK', value: '***'}], - [], - ), + utils.createStepAssertion('Announce failed workflow in Slack', true, null, 'CREATENEWSTAGINGDEPLOYCASH', 'Announcing failed workflow', [{key: 'SLACK_WEBHOOK', value: '***'}], []), ]; failProdSteps.forEach((expectedStep) => { diff --git a/workflow_tests/assertions/lintAssertions.js b/workflow_tests/assertions/lintAssertions.js index 797d626ad40b..4282ddb81d24 100644 --- a/workflow_tests/assertions/lintAssertions.js +++ b/workflow_tests/assertions/lintAssertions.js @@ -2,42 +2,10 @@ const utils = require('../utils/utils'); const assertLintJobExecuted = (workflowResult, didExecute = true) => { const steps = [ - utils.createStepAssertion( - 'Checkout', - true, - null, - 'LINT', - 'Checkout', - [], - [], - ), - utils.createStepAssertion( - 'Setup Node', - true, - null, - 'LINT', - 'Setup Node', - [], - [], - ), - utils.createStepAssertion( - 'Lint JavaScript with ESLint', - true, - null, - 'LINT', - 'Lint JavaScript with ESLint', - [], - [{key: 'CI', value: 'true'}], - ), - utils.createStepAssertion( - 'Lint shell scripts with ShellCheck', - true, - null, - 'LINT', - 'Lint shell scripts with ShellCheck', - [], - [], - ), + utils.createStepAssertion('Checkout', true, null, 'LINT', 'Checkout', [], []), + utils.createStepAssertion('Setup Node', true, null, 'LINT', 'Setup Node', [], []), + utils.createStepAssertion('Lint JavaScript with ESLint', true, null, 'LINT', 'Lint JavaScript with ESLint', [], [{key: 'CI', value: 'true'}]), + utils.createStepAssertion('Lint shell scripts with ShellCheck', true, null, 'LINT', 'Lint shell scripts with ShellCheck', [], []), ]; steps.forEach((expectedStep) => { diff --git a/workflow_tests/assertions/lockDeploysAssertions.js b/workflow_tests/assertions/lockDeploysAssertions.js index 16641b5a586f..59ce833fa1e0 100644 --- a/workflow_tests/assertions/lockDeploysAssertions.js +++ b/workflow_tests/assertions/lockDeploysAssertions.js @@ -8,18 +8,14 @@ const assertlockStagingDeploysJobExecuted = (workflowResult, didExecute = true, null, 'LOCKSTAGINGDEPLOYS', 'Checking out', - [{key: 'ref', value: 'main'}, {key: 'fetch-depth', value: '0'}, {key: 'token', value: '***'}], - [], - ), - utils.createStepAssertion( - 'Wait for staging deploys to finish', - true, - null, - 'LOCKSTAGINGDEPLOYS', - 'Waiting for staging deploys to finish', - [{key: 'GITHUB_TOKEN', value: '***'}], + [ + {key: 'ref', value: 'main'}, + {key: 'fetch-depth', value: '0'}, + {key: 'token', value: '***'}, + ], [], ), + utils.createStepAssertion('Wait for staging deploys to finish', true, null, 'LOCKSTAGINGDEPLOYS', 'Waiting for staging deploys to finish', [{key: 'GITHUB_TOKEN', value: '***'}], []), utils.createStepAssertion( 'Comment in StagingDeployCash to give Applause the 🟢 to begin QA', true, @@ -40,15 +36,7 @@ const assertlockStagingDeploysJobExecuted = (workflowResult, didExecute = true, }); const failProdSteps = [ - utils.createStepAssertion( - 'Announce failed workflow', - true, - null, - 'LOCKSTAGINGDEPLOYS', - 'Announcing failed workflow in Slack', - [{key: 'SLACK_WEBHOOK', value: '***'}], - [], - ), + utils.createStepAssertion('Announce failed workflow', true, null, 'LOCKSTAGINGDEPLOYS', 'Announcing failed workflow in Slack', [{key: 'SLACK_WEBHOOK', value: '***'}], []), ]; failProdSteps.forEach((expectedStep) => { @@ -68,7 +56,11 @@ const assertlockStagingDeploysJobFailedAfterFirstStep = (workflowResult) => { null, 'LOCKSTAGINGDEPLOYS', 'Checking out', - [{key: 'ref', value: 'main'}, {key: 'fetch-depth', value: '0'}, {key: 'token', value: '***'}], + [ + {key: 'ref', value: 'main'}, + {key: 'fetch-depth', value: '0'}, + {key: 'token', value: '***'}, + ], [], ), utils.createStepAssertion( @@ -80,15 +72,7 @@ const assertlockStagingDeploysJobFailedAfterFirstStep = (workflowResult) => { [{key: 'GITHUB_TOKEN', value: '***'}], [], ), - utils.createStepAssertion( - 'Announce failed workflow', - true, - null, - 'LOCKSTAGINGDEPLOYS', - 'Announcing failed workflow in Slack', - [{key: 'SLACK_WEBHOOK', value: '***'}], - [], - ), + utils.createStepAssertion('Announce failed workflow', true, null, 'LOCKSTAGINGDEPLOYS', 'Announcing failed workflow in Slack', [{key: 'SLACK_WEBHOOK', value: '***'}], []), ]; steps.forEach((expectedStep) => { diff --git a/workflow_tests/assertions/platformDeployAssertions.js b/workflow_tests/assertions/platformDeployAssertions.js index 6ec74c9a96fa..c2bf885875a8 100644 --- a/workflow_tests/assertions/platformDeployAssertions.js +++ b/workflow_tests/assertions/platformDeployAssertions.js @@ -2,14 +2,11 @@ const utils = require('../utils/utils'); const assertVerifyActorJobExecuted = (workflowResult, username, didExecute = true) => { const steps = [ - utils.createStepAssertion( - 'Check if user is deployer', - true, - null, - 'VALIDATE_ACTOR', - 'Checking if the user is a deployer', - [{key: 'GITHUB_TOKEN', value: '***'}, {key: 'username', value: username}, {key: 'team', value: 'mobile-deployers'}], - ), + utils.createStepAssertion('Check if user is deployer', true, null, 'VALIDATE_ACTOR', 'Checking if the user is a deployer', [ + {key: 'GITHUB_TOKEN', value: '***'}, + {key: 'username', value: username}, + {key: 'team', value: 'mobile-deployers'}, + ]), ]; steps.forEach((expectedStep) => { @@ -23,101 +20,37 @@ const assertVerifyActorJobExecuted = (workflowResult, username, didExecute = tru const assertAndroidJobExecuted = (workflowResult, didExecute = true, isProduction = true, isSuccessful = true) => { const steps = [ - utils.createStepAssertion( - 'Checkout', - true, - null, - 'ANDROID', - 'Checking out', - [{key: 'fetch-depth', value: '0'}], - ), - utils.createStepAssertion( - 'Setup Node', - true, - null, - 'ANDROID', - 'Setting up Node', - ), - utils.createStepAssertion( - 'Setup Ruby', - true, - null, - 'ANDROID', - 'Setting up Ruby', - [{key: 'ruby-version', value: '2.7'}, {key: 'bundler-cache', value: 'true'}], - ), - utils.createStepAssertion( - 'Decrypt keystore', - true, - null, - 'ANDROID', - 'Decrypting keystore', - null, - [{key: 'LARGE_SECRET_PASSPHRASE', value: '***'}], - ), - utils.createStepAssertion( - 'Decrypt json key', - true, - null, - 'ANDROID', - 'Decrypting JSON key', - null, - [{key: 'LARGE_SECRET_PASSPHRASE', value: '***'}], - ), - utils.createStepAssertion( - 'Set version in ENV', - true, - null, - 'ANDROID', - 'Setting version in ENV', - ), + utils.createStepAssertion('Checkout', true, null, 'ANDROID', 'Checking out', [{key: 'fetch-depth', value: '0'}]), + utils.createStepAssertion('Setup Node', true, null, 'ANDROID', 'Setting up Node'), + utils.createStepAssertion('Setup Ruby', true, null, 'ANDROID', 'Setting up Ruby', [ + {key: 'ruby-version', value: '2.7'}, + {key: 'bundler-cache', value: 'true'}, + ]), + utils.createStepAssertion('Decrypt keystore', true, null, 'ANDROID', 'Decrypting keystore', null, [{key: 'LARGE_SECRET_PASSPHRASE', value: '***'}]), + utils.createStepAssertion('Decrypt json key', true, null, 'ANDROID', 'Decrypting JSON key', null, [{key: 'LARGE_SECRET_PASSPHRASE', value: '***'}]), + utils.createStepAssertion('Set version in ENV', true, null, 'ANDROID', 'Setting version in ENV'), ]; if (!isProduction) { steps.push( - utils.createStepAssertion( - 'Run Fastlane beta', - true, - null, - 'ANDROID', - 'Running Fastlane beta', - null, - [{key: 'MYAPP_UPLOAD_STORE_PASSWORD', value: '***'}, {key: 'MYAPP_UPLOAD_KEY_PASSWORD', value: '***'}], - ), + utils.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( - utils.createStepAssertion( - 'Run Fastlane production', - true, - null, - 'ANDROID', - 'Running Fastlane production', - null, - [{key: 'VERSION', value: '1.2.3'}], - ), - ); + steps.push(utils.createStepAssertion('Run Fastlane production', true, null, 'ANDROID', 'Running Fastlane production', null, [{key: 'VERSION', value: '1.2.3'}])); } steps.push( - utils.createStepAssertion( - 'Archive Android sourcemaps', - true, - null, - 'ANDROID', - 'Archiving Android sourcemaps', - [{key: 'name', value: 'android-sourcemap'}, {key: 'path', value: 'android/app/build/generated/sourcemaps/react/release/*.map'}], - ), + utils.createStepAssertion('Archive Android sourcemaps', true, null, 'ANDROID', 'Archiving Android sourcemaps', [ + {key: 'name', value: 'android-sourcemap'}, + {key: 'path', value: 'android/app/build/generated/sourcemaps/react/release/*.map'}, + ]), ); if (!isProduction) { steps.push( - utils.createStepAssertion( - 'Upload Android version to Browser Stack', - true, - null, - 'ANDROID', - 'Uploading Android version to Browser Stack', - null, - [{key: 'BROWSERSTACK', value: '***'}], - ), + utils.createStepAssertion('Upload Android version to Browser Stack', true, null, 'ANDROID', 'Uploading Android version to Browser Stack', null, [ + {key: 'BROWSERSTACK', value: '***'}, + ]), ); } @@ -137,7 +70,10 @@ const assertAndroidJobExecuted = (workflowResult, didExecute = true, isProductio 'ANDROID', 'Warning deployers of failed production deploy', [{key: 'status', value: 'custom'}], - [{key: 'GITHUB_TOKEN', value: '***'}, {key: 'SLACK_WEBHOOK_URL', value: '***'}], + [ + {key: 'GITHUB_TOKEN', value: '***'}, + {key: 'SLACK_WEBHOOK_URL', value: '***'}, + ], ), ]; @@ -152,68 +88,33 @@ const assertAndroidJobExecuted = (workflowResult, didExecute = true, isProductio const assertDesktopJobExecuted = (workflowResult, didExecute = true, isProduction = true) => { const steps = [ - utils.createStepAssertion( - 'Checkout', - true, - null, - 'DESKTOP', - 'Checking out', - [{key: 'fetch-depth', value: '0'}], - ), - utils.createStepAssertion( - 'Setup Node', - true, - null, - 'DESKTOP', - 'Setting up Node', - ), - utils.createStepAssertion( - 'Decrypt Developer ID Certificate', - true, - null, - 'DESKTOP', - 'Decrypting developer id certificate', - null, - [{key: 'DEVELOPER_ID_SECRET_PASSPHRASE', value: '***'}], - ), + utils.createStepAssertion('Checkout', true, null, 'DESKTOP', 'Checking out', [{key: 'fetch-depth', value: '0'}]), + utils.createStepAssertion('Setup Node', true, null, 'DESKTOP', 'Setting up Node'), + utils.createStepAssertion('Decrypt Developer ID Certificate', true, null, 'DESKTOP', 'Decrypting developer id certificate', null, [ + {key: 'DEVELOPER_ID_SECRET_PASSPHRASE', value: '***'}, + ]), ]; if (isProduction) { steps.push( - utils.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_ID_PASSWORD', value: '***'}, - {key: 'AWS_ACCESS_KEY_ID', value: '***'}, - {key: 'AWS_SECRET_ACCESS_KEY', value: '***'}, - ], - ), + utils.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_ID_PASSWORD', value: '***'}, + {key: 'AWS_ACCESS_KEY_ID', value: '***'}, + {key: 'AWS_SECRET_ACCESS_KEY', value: '***'}, + ]), ); } else { steps.push( - utils.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_ID_PASSWORD', value: '***'}, - {key: 'AWS_ACCESS_KEY_ID', value: '***'}, - {key: 'AWS_SECRET_ACCESS_KEY', value: '***'}, - ], - ), + utils.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_ID_PASSWORD', value: '***'}, + {key: 'AWS_ACCESS_KEY_ID', value: '***'}, + {key: 'AWS_SECRET_ACCESS_KEY', value: '***'}, + ]), ); } @@ -228,126 +129,48 @@ const assertDesktopJobExecuted = (workflowResult, didExecute = true, isProductio const assertIOSJobExecuted = (workflowResult, didExecute = true, isProduction = true, isSuccessful = true) => { const steps = [ - utils.createStepAssertion( - 'Checkout', - true, - null, - 'IOS', - 'Checking out', - [{key: 'fetch-depth', value: '0'}], - ), - utils.createStepAssertion( - 'Setup Node', - true, - null, - 'IOS', - 'Setting up Node', - ), - utils.createStepAssertion( - 'Setup Ruby', - true, - null, - 'IOS', - 'Setting up Ruby', - [{key: 'ruby-version', value: '2.7'}, {key: 'bundler-cache', value: 'true'}], - ), - utils.createStepAssertion( - 'Cache', - true, - null, - 'IOS', - 'Caching', - [{key: 'path', value: 'ios/Pods'}, {key: 'key', value: 'Linux-pods-'}, {key: 'restore-keys', value: 'Linux-pods-'}], - ), - utils.createStepAssertion( - 'Install cocoapods', - true, - null, - 'IOS', - 'Installing cocoapods', - [{key: 'timeout_minutes', value: '10'}, {key: 'max_attempts', value: '5'}, {key: 'command', value: 'cd ios && pod install'}], - ), - utils.createStepAssertion( - 'Decrypt profile', - true, - null, - 'IOS', - 'Decrypting profile', - null, - [{key: 'LARGE_SECRET_PASSPHRASE', value: '***'}], - ), - utils.createStepAssertion( - 'Decrypt certificate', - true, - null, - 'IOS', - 'Decrypting certificate', - null, - [{key: 'LARGE_SECRET_PASSPHRASE', value: '***'}], - ), - utils.createStepAssertion( - 'Decrypt App Store Connect API key', - true, - null, - 'IOS', - 'Decrypting App Store API key', - null, - [{key: 'LARGE_SECRET_PASSPHRASE', value: '***'}], - ), + utils.createStepAssertion('Checkout', true, null, 'IOS', 'Checking out', [{key: 'fetch-depth', value: '0'}]), + utils.createStepAssertion('Setup Node', true, null, 'IOS', 'Setting up Node'), + utils.createStepAssertion('Setup Ruby', true, null, 'IOS', 'Setting up Ruby', [ + {key: 'ruby-version', value: '2.7'}, + {key: 'bundler-cache', value: 'true'}, + ]), + utils.createStepAssertion('Cache', true, null, 'IOS', 'Caching', [ + {key: 'path', value: 'ios/Pods'}, + {key: 'key', value: 'Linux-pods-'}, + {key: 'restore-keys', value: 'Linux-pods-'}, + ]), + utils.createStepAssertion('Install cocoapods', true, null, 'IOS', 'Installing cocoapods', [ + {key: 'timeout_minutes', value: '10'}, + {key: 'max_attempts', value: '5'}, + {key: 'command', value: 'cd ios && pod install'}, + ]), + utils.createStepAssertion('Decrypt profile', true, null, 'IOS', 'Decrypting profile', null, [{key: 'LARGE_SECRET_PASSPHRASE', value: '***'}]), + utils.createStepAssertion('Decrypt certificate', true, null, 'IOS', 'Decrypting certificate', null, [{key: 'LARGE_SECRET_PASSPHRASE', value: '***'}]), + utils.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( - utils.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: '***'}], - ), + utils.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( - utils.createStepAssertion( - 'Archive iOS sourcemaps', - true, - null, - 'IOS', - 'Archiving sourcemaps', - [{key: 'name', value: 'ios-sourcemap'}, {key: 'path', value: 'main.jsbundle.map'}], - ), + utils.createStepAssertion('Archive iOS sourcemaps', true, null, 'IOS', 'Archiving sourcemaps', [ + {key: 'name', value: 'ios-sourcemap'}, + {key: 'path', value: 'main.jsbundle.map'}, + ]), ); if (!isProduction) { - steps.push( - utils.createStepAssertion( - 'Upload iOS version to Browser Stack', - true, - null, - 'IOS', - 'Uploading version to Browser Stack', - null, - [{key: 'BROWSERSTACK', value: '***'}], - ), - ); + steps.push(utils.createStepAssertion('Upload iOS version to Browser Stack', true, null, 'IOS', 'Uploading version to Browser Stack', null, [{key: 'BROWSERSTACK', value: '***'}])); } else { steps.push( - utils.createStepAssertion( - 'Set iOS version in ENV', - true, - null, - 'IOS', - 'Setting iOS version', - ), - utils.createStepAssertion( - 'Run Fastlane for App Store release', - true, - null, - 'IOS', - 'Running Fastlane for release', - null, - [{key: 'VERSION', value: '1.2.3'}], - ), + utils.createStepAssertion('Set iOS version in ENV', true, null, 'IOS', 'Setting iOS version'), + utils.createStepAssertion('Run Fastlane for App Store release', true, null, 'IOS', 'Running Fastlane for release', null, [{key: 'VERSION', value: '1.2.3'}]), ); } @@ -367,7 +190,10 @@ const assertIOSJobExecuted = (workflowResult, didExecute = true, isProduction = 'IOS', 'Warning developers of failed deploy', [{key: 'status', value: 'custom'}], - [{key: 'GITHUB_TOKEN', value: '***'}, {key: 'SLACK_WEBHOOK_URL', value: '***'}], + [ + {key: 'GITHUB_TOKEN', value: '***'}, + {key: 'SLACK_WEBHOOK_URL', value: '***'}, + ], ), ]; @@ -382,104 +208,29 @@ const assertIOSJobExecuted = (workflowResult, didExecute = true, isProduction = const assertWebJobExecuted = (workflowResult, didExecute = true, isProduction = true) => { const steps = [ - utils.createStepAssertion( - 'Checkout', - true, - null, - 'WEB', - 'Checking out', - [{key: 'fetch-depth', value: '0'}], - ), - utils.createStepAssertion( - 'Setup Node', - true, - null, - 'WEB', - 'Setting up Node', - ), - utils.createStepAssertion( - 'Setup Cloudflare CLI', - true, - null, - 'WEB', - 'Setting up Cloudflare CLI', - ), - utils.createStepAssertion( - 'Configure AWS Credentials', - true, - null, - 'WEB', - 'Configuring AWS credentials', - [{key: 'AWS_ACCESS_KEY_ID', value: '***'}, {key: 'AWS_SECRET_ACCESS_KEY', value: '***'}], - ), + utils.createStepAssertion('Checkout', true, null, 'WEB', 'Checking out', [{key: 'fetch-depth', value: '0'}]), + utils.createStepAssertion('Setup Node', true, null, 'WEB', 'Setting up Node'), + utils.createStepAssertion('Setup Cloudflare CLI', true, null, 'WEB', 'Setting up Cloudflare CLI'), + utils.createStepAssertion('Configure AWS Credentials', true, null, 'WEB', 'Configuring AWS credentials', [ + {key: 'AWS_ACCESS_KEY_ID', value: '***'}, + {key: 'AWS_SECRET_ACCESS_KEY', value: '***'}, + ]), ]; if (isProduction) { - steps.push( - utils.createStepAssertion( - 'Build web for production', - true, - null, - 'WEB', - 'Building web for production', - ), - ); + steps.push(utils.createStepAssertion('Build web for production', true, null, 'WEB', 'Building web for production')); } else { - steps.push( - utils.createStepAssertion( - 'Build web for staging', - true, - null, - 'WEB', - 'Building web for staging', - ), - ); + steps.push(utils.createStepAssertion('Build web for staging', true, null, 'WEB', 'Building web for staging')); } - steps.push( - utils.createStepAssertion( - 'Build docs', - true, - null, - 'WEB', - 'Building docs', - ), - ); + steps.push(utils.createStepAssertion('Build docs', true, null, 'WEB', 'Building docs')); if (isProduction) { steps.push( - utils.createStepAssertion( - 'Deploy production to S3', - true, - null, - 'WEB', - 'Deploying production to S3', - ), - utils.createStepAssertion( - 'Purge production Cloudflare cache', - true, - null, - 'WEB', - 'Purging production Cloudflare cache', - null, - [{key: 'CF_API_KEY', value: '***'}], - ), + utils.createStepAssertion('Deploy production to S3', true, null, 'WEB', 'Deploying production to S3'), + utils.createStepAssertion('Purge production Cloudflare cache', true, null, 'WEB', 'Purging production Cloudflare cache', null, [{key: 'CF_API_KEY', value: '***'}]), ); } else { steps.push( - utils.createStepAssertion( - 'Deploy staging to S3', - true, - null, - 'WEB', - 'Deploying staging to S3', - ), - utils.createStepAssertion( - 'Purge staging Cloudflare cache', - true, - null, - 'WEB', - 'Purging staging Cloudflare cache', - null, - [{key: 'CF_API_KEY', value: '***'}], - ), + utils.createStepAssertion('Deploy staging to S3', true, null, 'WEB', 'Deploying staging to S3'), + utils.createStepAssertion('Purge staging Cloudflare cache', true, null, 'WEB', 'Purging staging Cloudflare cache', null, [{key: 'CF_API_KEY', value: '***'}]), ); } @@ -494,14 +245,7 @@ const assertWebJobExecuted = (workflowResult, didExecute = true, isProduction = const assertPostSlackOnFailureJobExecuted = (workflowResult, didExecute = true) => { const steps = [ - utils.createStepAssertion( - 'Post Slack message on failure', - true, - null, - 'POST_SLACK_FAIL', - 'Posting Slack message on platform deploy failure', - [{key: 'SLACK_WEBHOOK', value: '***'}], - ), + utils.createStepAssertion('Post Slack message on failure', true, null, 'POST_SLACK_FAIL', 'Posting Slack message on platform deploy failure', [{key: 'SLACK_WEBHOOK', value: '***'}]), ]; steps.forEach((expectedStep) => { @@ -515,20 +259,8 @@ const assertPostSlackOnFailureJobExecuted = (workflowResult, didExecute = true) const assertPostSlackOnSuccessJobExecuted = (workflowResult, didExecute = true, isProduction = true) => { const steps = [ - utils.createStepAssertion( - 'Checkout', - true, - null, - 'POST_SLACK_SUCCESS', - 'Checking out', - ), - utils.createStepAssertion( - 'Set version', - true, - null, - 'POST_SLACK_SUCCESS', - 'Setting version', - ), + utils.createStepAssertion('Checkout', true, null, 'POST_SLACK_SUCCESS', 'Checking out'), + utils.createStepAssertion('Set version', true, null, 'POST_SLACK_SUCCESS', 'Setting version'), utils.createStepAssertion( 'Announces the deploy in the #announce Slack room', true, @@ -536,7 +268,10 @@ const assertPostSlackOnSuccessJobExecuted = (workflowResult, didExecute = true, 'POST_SLACK_SUCCESS', 'Posting message to #announce channel', [{key: 'status', value: 'custom'}], - [{key: 'GITHUB_TOKEN', value: '***'}, {key: 'SLACK_WEBHOOK_URL', value: '***'}], + [ + {key: 'GITHUB_TOKEN', value: '***'}, + {key: 'SLACK_WEBHOOK_URL', value: '***'}, + ], ), utils.createStepAssertion( 'Announces the deploy in the #deployer Slack room', @@ -545,7 +280,10 @@ const assertPostSlackOnSuccessJobExecuted = (workflowResult, didExecute = true, 'POST_SLACK_SUCCESS', 'Posting message to #deployer channel', [{key: 'status', value: 'custom'}], - [{key: 'GITHUB_TOKEN', value: '***'}, {key: 'SLACK_WEBHOOK_URL', value: '***'}], + [ + {key: 'GITHUB_TOKEN', value: '***'}, + {key: 'SLACK_WEBHOOK_URL', value: '***'}, + ], ), ]; if (isProduction) { @@ -557,7 +295,10 @@ const assertPostSlackOnSuccessJobExecuted = (workflowResult, didExecute = true, 'POST_SLACK_SUCCESS', 'Posting message to #expensify-open-source channel', [{key: 'status', value: 'custom'}], - [{key: 'GITHUB_TOKEN', value: '***'}, {key: 'SLACK_WEBHOOK_URL', value: '***'}], + [ + {key: 'GITHUB_TOKEN', value: '***'}, + {key: 'SLACK_WEBHOOK_URL', value: '***'}, + ], ), ); } @@ -573,53 +314,24 @@ const assertPostSlackOnSuccessJobExecuted = (workflowResult, didExecute = true, const assertPostGithubCommentJobExecuted = (workflowResult, didExecute = true, isProduction = true, didDeploy = true) => { const steps = [ - utils.createStepAssertion( - 'Checkout', - true, - null, - 'POST_GITHUB_COMMENT', - 'Checking out', - [{key: 'fetch-depth', value: '0'}], - ), - utils.createStepAssertion( - 'Setup Node', - true, - null, - 'POST_GITHUB_COMMENT', - 'Setting up Node', - ), - utils.createStepAssertion( - 'Set version', - true, - null, - 'POST_GITHUB_COMMENT', - 'Setting version', - ), - utils.createStepAssertion( - 'Get Release Pull Request List', - true, - null, - 'POST_GITHUB_COMMENT', - 'Getting release pull request list', - [{key: 'TAG', value: '1.2.3'}, {key: 'GITHUB_TOKEN', value: '***'}, {key: 'IS_PRODUCTION_DEPLOY', value: isProduction ? 'true' : 'false'}], - ), - utils.createStepAssertion( - 'Comment on issues', - true, - null, - 'POST_GITHUB_COMMENT', - 'Commenting on issues', - [ - {key: 'PR_LIST', value: '[1.2.1, 1.2.2]'}, - {key: 'IS_PRODUCTION_DEPLOY', value: isProduction ? 'true' : 'false'}, - {key: 'DEPLOY_VERSION', value: '1.2.3'}, - {key: 'GITHUB_TOKEN', value: '***'}, - {key: 'ANDROID', value: didDeploy ? 'success' : ''}, - {key: 'DESKTOP', value: didDeploy ? 'success' : ''}, - {key: 'IOS', value: didDeploy ? 'success' : ''}, - {key: 'WEB', value: didDeploy ? 'success' : ''}, - ], - ), + utils.createStepAssertion('Checkout', true, null, 'POST_GITHUB_COMMENT', 'Checking out', [{key: 'fetch-depth', value: '0'}]), + utils.createStepAssertion('Setup Node', true, null, 'POST_GITHUB_COMMENT', 'Setting up Node'), + utils.createStepAssertion('Set version', true, null, 'POST_GITHUB_COMMENT', 'Setting version'), + utils.createStepAssertion('Get Release Pull Request List', true, null, 'POST_GITHUB_COMMENT', 'Getting release pull request list', [ + {key: 'TAG', value: '1.2.3'}, + {key: 'GITHUB_TOKEN', value: '***'}, + {key: 'IS_PRODUCTION_DEPLOY', value: isProduction ? 'true' : 'false'}, + ]), + utils.createStepAssertion('Comment on issues', true, null, 'POST_GITHUB_COMMENT', 'Commenting on issues', [ + {key: 'PR_LIST', value: '[1.2.1, 1.2.2]'}, + {key: 'IS_PRODUCTION_DEPLOY', value: isProduction ? 'true' : 'false'}, + {key: 'DEPLOY_VERSION', value: '1.2.3'}, + {key: 'GITHUB_TOKEN', value: '***'}, + {key: 'ANDROID', value: didDeploy ? 'success' : ''}, + {key: 'DESKTOP', value: didDeploy ? 'success' : ''}, + {key: 'IOS', value: didDeploy ? 'success' : ''}, + {key: 'WEB', value: didDeploy ? 'success' : ''}, + ]), ]; steps.forEach((expectedStep) => { diff --git a/workflow_tests/assertions/preDeployAssertions.js b/workflow_tests/assertions/preDeployAssertions.js index 0c4b04691366..c280b6a005ac 100644 --- a/workflow_tests/assertions/preDeployAssertions.js +++ b/workflow_tests/assertions/preDeployAssertions.js @@ -1,15 +1,7 @@ const utils = require('../utils/utils'); const assertLintJobExecuted = (workflowResult, didExecute = true) => { - const steps = [ - utils.createStepAssertion( - 'Run lint workflow', - true, - null, - 'LINT', - 'Running lint workflow', - ), - ]; + const steps = [utils.createStepAssertion('Run lint workflow', true, null, 'LINT', 'Running lint workflow')]; steps.forEach((expectedStep) => { if (didExecute) { @@ -21,15 +13,7 @@ const assertLintJobExecuted = (workflowResult, didExecute = true) => { }; const assertTestJobExecuted = (workflowResult, didExecute = true) => { - const steps = [ - utils.createStepAssertion( - 'Run test workflow', - true, - null, - 'TEST', - 'Running test workflow', - ), - ]; + const steps = [utils.createStepAssertion('Run test workflow', true, null, 'TEST', 'Running test workflow')]; steps.forEach((expectedStep) => { if (didExecute) { @@ -42,22 +26,12 @@ const assertTestJobExecuted = (workflowResult, didExecute = true) => { const assertIsExpensifyEmployeeJobExecuted = (workflowResult, didExecute = true) => { const steps = [ - utils.createStepAssertion( - 'Get merged pull request', - true, - null, - 'IS_EXPENSIFY_EMPLOYEE', - 'Getting merged pull request', - [{key: 'github_token', value: '***'}], - ), - utils.createStepAssertion( - 'Check whether the actor is member of Expensify/expensify team', - true, - null, - 'IS_EXPENSIFY_EMPLOYEE', - 'Checking actors Expensify membership', - [{key: 'GITHUB_TOKEN', value: '***'}, {key: 'username', value: 'Dummy Author'}, {key: 'team', value: 'Expensify/expensify'}], - ), + utils.createStepAssertion('Get merged pull request', true, null, 'IS_EXPENSIFY_EMPLOYEE', 'Getting merged pull request', [{key: 'github_token', value: '***'}]), + utils.createStepAssertion('Check whether the actor is member of Expensify/expensify team', true, null, 'IS_EXPENSIFY_EMPLOYEE', 'Checking actors Expensify membership', [ + {key: 'GITHUB_TOKEN', value: '***'}, + {key: 'username', value: 'Dummy Author'}, + {key: 'team', value: 'Expensify/expensify'}, + ]), ]; steps.forEach((expectedStep) => { @@ -71,61 +45,44 @@ const assertIsExpensifyEmployeeJobExecuted = (workflowResult, didExecute = true) const assertNewContributorWelcomeMessageJobExecuted = (workflowResult, didExecute = true, isOsBotify = false, isFirstPr = false) => { const steps = [ - utils.createStepAssertion( - 'Checkout', - true, - null, - 'NEW_CONTRIBUTOR_WELCOME_MESSAGE', - 'Checking out', - [{key: 'token', value: '***'}], - ), - utils.createStepAssertion( - 'Get merged pull request', - true, - null, - 'NEW_CONTRIBUTOR_WELCOME_MESSAGE', - 'Getting merged pull request', - [{key: 'github_token', value: '***'}], - ), - utils.createStepAssertion( - isOsBotify ? 'Get PR count for OSBotify' : 'Get PR count for Dummy Author', - true, - null, - 'NEW_CONTRIBUTOR_WELCOME_MESSAGE', - 'Getting PR count', - [{key: 'GITHUB_TOKEN', value: '***'}], - ), + utils.createStepAssertion('Checkout', true, null, 'NEW_CONTRIBUTOR_WELCOME_MESSAGE', 'Checking out', [{key: 'token', value: '***'}]), + utils.createStepAssertion('Get merged pull request', true, null, 'NEW_CONTRIBUTOR_WELCOME_MESSAGE', 'Getting merged pull request', [{key: 'github_token', value: '***'}]), + utils.createStepAssertion(isOsBotify ? 'Get PR count for OSBotify' : 'Get PR count for Dummy Author', true, null, 'NEW_CONTRIBUTOR_WELCOME_MESSAGE', 'Getting PR count', [ + {key: 'GITHUB_TOKEN', value: '***'}, + ]), ]; - const osBotifyBody = '@OSBotify, Great job getting your first Expensify/App pull request over the finish line! ' - + ':tada:\n\nI know there\'s a lot of information in our ' - + '[contributing guidelines](https://github.com/Expensify/App/blob/main/contributingGuides/CONTRIBUTING.md), ' - + 'so here are some points to take note of :memo::\n\n1. Now that your first PR has been merged, you can be ' - + 'hired for another issue. Once you\'ve completed a few issues, you may be eligible to work on more than one ' - + 'job at a time.\n2. Once your PR is deployed to our staging servers, it will undergo quality assurance (QA) ' - + 'testing. If we find that it doesn\'t work as expected or causes a regression, you\'ll be responsible for ' - + 'fixing it. Typically, we would revert this PR and give you another chance to create a similar PR without ' - + 'causing a regression.\n3. Once your PR is deployed to _production_, we start a 7-day timer :alarm_clock:. ' - + 'After it has been on production for 7 days without causing any regressions, then we pay out the Upwork job. ' - + ':moneybag:\n\nSo it might take a while before you\'re paid for your work, but we typically post multiple ' - + 'new jobs every day, so there\'s plenty of opportunity. I hope you\'ve had a positive experience ' - + 'contributing to this repo! :blush:'; - const userBody = '@Dummy Author, Great job getting your first Expensify/App pull request over the finish ' - + 'line! :tada:\n\nI know there\'s a lot of information in our ' - + '[contributing guidelines](https://github.com/Expensify/App/blob/main/contributingGuides/CONTRIBUTING.md), ' - + 'so here are some points to take note of :memo::\n\n1. Now that your first PR has been merged, you can be ' - + 'hired for another issue. Once you\'ve completed a few issues, you may be eligible to work on more than one ' - + 'job at a time.\n2. Once your PR is deployed to our staging servers, it will undergo quality assurance (QA) ' - + 'testing. If we find that it doesn\'t work as expected or causes a regression, you\'ll be responsible for ' - + 'fixing it. Typically, we would revert this PR and give you another chance to create a similar PR without ' - + 'causing a regression.\n3. Once your PR is deployed to _production_, we start a 7-day timer :alarm_clock:. ' - + 'After it has been on production for 7 days without causing any regressions, then we pay out the Upwork ' - + 'job. :moneybag:\n\nSo it might take a while before you\'re paid for your work, but we typically post ' - + 'multiple new jobs every day, so there\'s plenty of opportunity. I hope you\'ve had a positive experience ' - + 'contributing to this repo! :blush:'; + const osBotifyBody = + '@OSBotify, Great job getting your first Expensify/App pull request over the finish line! ' + + ":tada:\n\nI know there's a lot of information in our " + + '[contributing guidelines](https://github.com/Expensify/App/blob/main/contributingGuides/CONTRIBUTING.md), ' + + 'so here are some points to take note of :memo::\n\n1. Now that your first PR has been merged, you can be ' + + "hired for another issue. Once you've completed a few issues, you may be eligible to work on more than one " + + 'job at a time.\n2. Once your PR is deployed to our staging servers, it will undergo quality assurance (QA) ' + + "testing. If we find that it doesn't work as expected or causes a regression, you'll be responsible for " + + 'fixing it. Typically, we would revert this PR and give you another chance to create a similar PR without ' + + 'causing a regression.\n3. Once your PR is deployed to _production_, we start a 7-day timer :alarm_clock:. ' + + 'After it has been on production for 7 days without causing any regressions, then we pay out the Upwork job. ' + + ":moneybag:\n\nSo it might take a while before you're paid for your work, but we typically post multiple " + + "new jobs every day, so there's plenty of opportunity. I hope you've had a positive experience " + + 'contributing to this repo! :blush:'; + const userBody = + '@Dummy Author, Great job getting your first Expensify/App pull request over the finish ' + + "line! :tada:\n\nI know there's a lot of information in our " + + '[contributing guidelines](https://github.com/Expensify/App/blob/main/contributingGuides/CONTRIBUTING.md), ' + + 'so here are some points to take note of :memo::\n\n1. Now that your first PR has been merged, you can be ' + + "hired for another issue. Once you've completed a few issues, you may be eligible to work on more than one " + + 'job at a time.\n2. Once your PR is deployed to our staging servers, it will undergo quality assurance (QA) ' + + "testing. If we find that it doesn't work as expected or causes a regression, you'll be responsible for " + + 'fixing it. Typically, we would revert this PR and give you another chance to create a similar PR without ' + + 'causing a regression.\n3. Once your PR is deployed to _production_, we start a 7-day timer :alarm_clock:. ' + + 'After it has been on production for 7 days without causing any regressions, then we pay out the Upwork ' + + "job. :moneybag:\n\nSo it might take a while before you're paid for your work, but we typically post " + + "multiple new jobs every day, so there's plenty of opportunity. I hope you've had a positive experience " + + 'contributing to this repo! :blush:'; if (isFirstPr) { steps.push( utils.createStepAssertion( - isOsBotify ? 'Comment on OSBotify\\\'s first pull request!' : 'Comment on Dummy Author\\\'s first pull request!', + isOsBotify ? "Comment on OSBotify\\'s first pull request!" : "Comment on Dummy Author\\'s first pull request!", true, null, 'NEW_CONTRIBUTOR_WELCOME_MESSAGE', @@ -150,37 +107,11 @@ const assertNewContributorWelcomeMessageJobExecuted = (workflowResult, didExecut const assertChooseDeployActionsJobExecuted = (workflowResult, didExecute = true) => { const steps = [ - utils.createStepAssertion( - 'Get merged pull request', - true, - null, - 'CHOOSE_DEPLOY_ACTIONS', - 'Getting merged pull request', - [{key: 'github_token', value: '***'}], - ), - utils.createStepAssertion( - 'Check if StagingDeployCash is locked', - true, - null, - 'CHOOSE_DEPLOY_ACTIONS', - 'Checking StagingDeployCash', - [{key: 'GITHUB_TOKEN', value: '***'}], - ), - utils.createStepAssertion( - 'Check if merged pull request was an automated PR', - true, - '', - ), - utils.createStepAssertion( - 'Check if merged pull request has `CP Staging` label', - true, - '', - ), - utils.createStepAssertion( - 'Check if merged pull request should trigger a deploy', - true, - '', - ), + utils.createStepAssertion('Get merged pull request', true, null, 'CHOOSE_DEPLOY_ACTIONS', 'Getting merged pull request', [{key: 'github_token', value: '***'}]), + utils.createStepAssertion('Check if StagingDeployCash is locked', true, null, 'CHOOSE_DEPLOY_ACTIONS', 'Checking StagingDeployCash', [{key: 'GITHUB_TOKEN', value: '***'}]), + utils.createStepAssertion('Check if merged pull request was an automated PR', true, ''), + utils.createStepAssertion('Check if merged pull request has `CP Staging` label', true, ''), + utils.createStepAssertion('Check if merged pull request should trigger a deploy', true, ''), ]; steps.forEach((expectedStep) => { @@ -193,20 +124,13 @@ const assertChooseDeployActionsJobExecuted = (workflowResult, didExecute = true) }; const assertSkipDeployJobExecuted = (workflowResult, didExecute = true) => { - const body = ':hand: This PR was not deployed to staging yet because QA is ongoing. It will be automatically ' - + 'deployed to staging after the next production release.'; + const body = ':hand: This PR was not deployed to staging yet because QA is ongoing. It will be automatically ' + 'deployed to staging after the next production release.'; const steps = [ - utils.createStepAssertion( - 'Comment on deferred PR', - true, - null, - 'SKIP_DEPLOY', - 'Skipping deploy', - [ - {key: 'github_token', value: '***'}, - {key: 'number', value: '123'}, - {key: 'body', value: body}], - ), + utils.createStepAssertion('Comment on deferred PR', true, null, 'SKIP_DEPLOY', 'Skipping deploy', [ + {key: 'github_token', value: '***'}, + {key: 'number', value: '123'}, + {key: 'body', value: body}, + ]), ]; steps.forEach((expectedStep) => { @@ -219,15 +143,7 @@ const assertSkipDeployJobExecuted = (workflowResult, didExecute = true) => { }; const assertCreateNewVersionJobExecuted = (workflowResult, didExecute = true) => { - const steps = [ - utils.createStepAssertion( - 'Create new version', - true, - null, - 'CREATE_NEW_VERSION', - 'Creating new version', - ), - ]; + const steps = [utils.createStepAssertion('Create new version', true, null, 'CREATE_NEW_VERSION', 'Creating new version')]; steps.forEach((expectedStep) => { if (didExecute) { @@ -240,71 +156,39 @@ const assertCreateNewVersionJobExecuted = (workflowResult, didExecute = true) => const assertUpdateStagingJobExecuted = (workflowResult, didExecute = true, shouldCp = false) => { const steps = [ - utils.createStepAssertion( - 'Run turnstyle', - true, - null, - 'UPDATE_STAGING', - 'Running turnstyle', - [{key: 'poll-interval-seconds', value: '10'}, {key: 'GITHUB_TOKEN', value: '***'}], - ), + utils.createStepAssertion('Run turnstyle', true, null, 'UPDATE_STAGING', 'Running turnstyle', [ + {key: 'poll-interval-seconds', value: '10'}, + {key: 'GITHUB_TOKEN', value: '***'}, + ]), ]; if (shouldCp) { steps.push( - utils.createStepAssertion( - 'Cherry-pick PR to staging', - true, - null, - 'UPDATE_STAGING', - 'Cherry picking', - [{key: 'GITHUB_TOKEN', value: '***'}, {key: 'WORKFLOW', value: 'cherryPick.yml'}, {key: 'INPUTS', value: '{ PULL_REQUEST_NUMBER: 123, NEW_VERSION: 1.2.3 }'}], - ), + utils.createStepAssertion('Cherry-pick PR to staging', true, null, 'UPDATE_STAGING', 'Cherry picking', [ + {key: 'GITHUB_TOKEN', value: '***'}, + {key: 'WORKFLOW', value: 'cherryPick.yml'}, + {key: 'INPUTS', value: '{ PULL_REQUEST_NUMBER: 123, NEW_VERSION: 1.2.3 }'}, + ]), ); } else { steps.push( - utils.createStepAssertion( - 'Update staging branch from main', - true, - null, - 'UPDATE_STAGING', - 'Updating staging branch', - [{key: 'TARGET_BRANCH', value: 'staging'}, {key: 'OS_BOTIFY_TOKEN', value: '***'}, {key: 'GPG_PASSPHRASE', value: '***'}], - ), + utils.createStepAssertion('Update staging branch from main', true, null, 'UPDATE_STAGING', 'Updating staging branch', [ + {key: 'TARGET_BRANCH', value: 'staging'}, + {key: 'OS_BOTIFY_TOKEN', value: '***'}, + {key: 'GPG_PASSPHRASE', value: '***'}, + ]), ); } steps.push( - utils.createStepAssertion( - 'Checkout staging', - true, - null, - 'UPDATE_STAGING', - 'Checking out staging', - [{key: 'ref', value: 'staging'}, {key: 'fetch-depth', value: '0'}], - ), - utils.createStepAssertion( - 'Tag staging', - true, - null, - 'UPDATE_STAGING', - 'Tagging staging', - ), - utils.createStepAssertion( - 'Update StagingDeployCash', - true, - null, - 'UPDATE_STAGING', - 'Updating StagingDeployCash', - [{key: 'GITHUB_TOKEN', value: '***'}, {key: 'NPM_VERSION', value: '1.2.3'}], - ), - utils.createStepAssertion( - 'Find open StagingDeployCash', - true, - null, - 'UPDATE_STAGING', - 'Finding open StagingDeployCash', - null, - [{key: 'GITHUB_TOKEN', value: '***'}], - ), + utils.createStepAssertion('Checkout staging', true, null, 'UPDATE_STAGING', 'Checking out staging', [ + {key: 'ref', value: 'staging'}, + {key: 'fetch-depth', value: '0'}, + ]), + utils.createStepAssertion('Tag staging', true, null, 'UPDATE_STAGING', 'Tagging staging'), + utils.createStepAssertion('Update StagingDeployCash', true, null, 'UPDATE_STAGING', 'Updating StagingDeployCash', [ + {key: 'GITHUB_TOKEN', value: '***'}, + {key: 'NPM_VERSION', value: '1.2.3'}, + ]), + utils.createStepAssertion('Find open StagingDeployCash', true, null, 'UPDATE_STAGING', 'Finding open StagingDeployCash', null, [{key: 'GITHUB_TOKEN', value: '***'}]), ); if (shouldCp) { steps.push( @@ -317,14 +201,10 @@ const assertUpdateStagingJobExecuted = (workflowResult, didExecute = true, shoul null, [{key: 'GITHUB_TOKEN', value: '***'}], ), - utils.createStepAssertion( - 'Wait for staging deploys to finish', - true, - null, - 'UPDATE_STAGING', - 'Waiting for staging deploy to finish', - [{key: 'GITHUB_TOKEN', value: '***'}, {key: 'TAG', value: '1.2.3'}], - ), + utils.createStepAssertion('Wait for staging deploys to finish', true, null, 'UPDATE_STAGING', 'Waiting for staging deploy to finish', [ + {key: 'GITHUB_TOKEN', value: '***'}, + {key: 'TAG', value: '1.2.3'}, + ]), utils.createStepAssertion( 'Comment in StagingDeployCash to alert Applause that cherry-picked pull request has been deployed.', true, @@ -348,14 +228,7 @@ const assertUpdateStagingJobExecuted = (workflowResult, didExecute = true, shoul const assertUpdateStagingJobFailed = (workflowResult, didFail = false) => { const steps = [ - utils.createStepAssertion( - 'Announce failed workflow in Slack', - true, - null, - 'UPDATE_STAGING', - 'Announcing failed workflow in Slack', - [{key: 'SLACK_WEBHOOK', value: '***'}], - ), + utils.createStepAssertion('Announce failed workflow in Slack', true, null, 'UPDATE_STAGING', 'Announcing failed workflow in Slack', [{key: 'SLACK_WEBHOOK', value: '***'}]), ]; steps.forEach((expectedStep) => { diff --git a/workflow_tests/assertions/reviewerChecklistAssertions.js b/workflow_tests/assertions/reviewerChecklistAssertions.js index 79d7e899d727..6154b1cd28ca 100644 --- a/workflow_tests/assertions/reviewerChecklistAssertions.js +++ b/workflow_tests/assertions/reviewerChecklistAssertions.js @@ -1,17 +1,7 @@ const utils = require('../utils/utils'); const assertChecklistJobExecuted = (workflowResult, didExecute = true) => { - const steps = [ - utils.createStepAssertion( - 'reviewerChecklist.js', - true, - null, - 'CHECKLIST', - 'reviewerChecklist.js', - [{key: 'GITHUB_TOKEN', value: '***'}], - [], - ), - ]; + const steps = [utils.createStepAssertion('reviewerChecklist.js', true, null, 'CHECKLIST', 'reviewerChecklist.js', [{key: 'GITHUB_TOKEN', value: '***'}], [])]; steps.forEach((expectedStep) => { if (didExecute) { diff --git a/workflow_tests/assertions/testAssertions.js b/workflow_tests/assertions/testAssertions.js index de55eb990ae9..d2d42ff80dd8 100644 --- a/workflow_tests/assertions/testAssertions.js +++ b/workflow_tests/assertions/testAssertions.js @@ -2,51 +2,22 @@ const utils = require('../utils/utils'); const assertJestJobExecuted = (workflowResult, didExecute = true, timesExecuted = 3) => { const steps = [ - utils.createStepAssertion( - 'Checkout', - true, - null, - 'JEST', - 'Checkout', - [], - [], - ), - utils.createStepAssertion( - 'Setup Node', - true, - null, - 'JEST', - 'Setup Node', - [], - [], - ), - utils.createStepAssertion( - 'Get number of CPU cores', - true, - null, - 'JEST', - 'Get number of CPU cores', - [], - [], - ), + utils.createStepAssertion('Checkout', true, null, 'JEST', 'Checkout', [], []), + utils.createStepAssertion('Setup Node', true, null, 'JEST', 'Setup Node', [], []), + utils.createStepAssertion('Get number of CPU cores', true, null, 'JEST', 'Get number of CPU cores', [], []), utils.createStepAssertion( 'Cache Jest cache', true, null, 'JEST', 'Cache Jest cache', - [{key: 'path', value: '.jest-cache'}, {key: 'key', value: 'Linux-jest'}], - [], - ), - utils.createStepAssertion( - 'Jest tests', - true, - null, - 'JEST', - 'Jest tests', - [], + [ + {key: 'path', value: '.jest-cache'}, + {key: 'key', value: 'Linux-jest'}, + ], [], ), + utils.createStepAssertion('Jest tests', true, null, 'JEST', 'Jest tests', [], []), ]; steps.forEach((expectedStep) => { @@ -54,11 +25,7 @@ const assertJestJobExecuted = (workflowResult, didExecute = true, timesExecuted expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); let cnt = 0; workflowResult.forEach((executedStep) => { - if ( - executedStep.name !== expectedStep.name - || executedStep.output !== expectedStep.output - || executedStep.status !== expectedStep.status - ) { + if (executedStep.name !== expectedStep.name || executedStep.output !== expectedStep.output || executedStep.status !== expectedStep.status) { return; } cnt += 1; @@ -71,33 +38,9 @@ const assertJestJobExecuted = (workflowResult, didExecute = true, timesExecuted }; const assertShellTestsJobExecuted = (workflowResult, didExecute = true) => { const steps = [ - utils.createStepAssertion( - 'Checkout', - true, - null, - 'SHELLTESTS', - 'Checkout', - [], - [], - ), - utils.createStepAssertion( - 'Setup Node', - true, - null, - 'SHELLTESTS', - 'Setup Node', - [], - [], - ), - utils.createStepAssertion( - 'getPullRequestsMergedBetween', - true, - null, - 'SHELLTESTS', - 'getPullRequestsMergedBetween', - [], - [], - ), + utils.createStepAssertion('Checkout', true, null, 'SHELLTESTS', 'Checkout', [], []), + utils.createStepAssertion('Setup Node', true, null, 'SHELLTESTS', 'Setup Node', [], []), + utils.createStepAssertion('getPullRequestsMergedBetween', true, null, 'SHELLTESTS', 'getPullRequestsMergedBetween', [], []), ]; steps.forEach((expectedStep) => { @@ -110,5 +53,6 @@ const assertShellTestsJobExecuted = (workflowResult, didExecute = true) => { }; module.exports = { - assertJestJobExecuted, assertShellTestsJobExecuted, + assertJestJobExecuted, + assertShellTestsJobExecuted, }; diff --git a/workflow_tests/assertions/testBuildAssertions.js b/workflow_tests/assertions/testBuildAssertions.js index 186b6d6f6548..fd4aa5c8c412 100644 --- a/workflow_tests/assertions/testBuildAssertions.js +++ b/workflow_tests/assertions/testBuildAssertions.js @@ -8,7 +8,11 @@ const assertValidateActorJobExecuted = (workflowResult, actor = 'Dummy Actor', p null, 'VALIDATEACTOR', 'Is team member', - [{key: 'GITHUB_TOKEN', value: '***'}, {key: 'username', value: actor}, {key: 'team', value: 'Expensify/expensify'}], + [ + {key: 'GITHUB_TOKEN', value: '***'}, + {key: 'username', value: actor}, + {key: 'team', value: 'Expensify/expensify'}, + ], [], ), utils.createStepAssertion( @@ -18,7 +22,10 @@ const assertValidateActorJobExecuted = (workflowResult, actor = 'Dummy Actor', p 'VALIDATEACTOR', 'Set HAS_READY_TO_BUILD_LABEL flag', [], - [{key: 'PULL_REQUEST_NUMBER', value: pullRequestNumber}, {key: 'GITHUB_TOKEN', value: '***'}], + [ + {key: 'PULL_REQUEST_NUMBER', value: pullRequestNumber}, + {key: 'GITHUB_TOKEN', value: '***'}, + ], ), ]; @@ -32,15 +39,7 @@ const assertValidateActorJobExecuted = (workflowResult, actor = 'Dummy Actor', p }; const assertGetBranchRefJobExecuted = (workflowResult, didExecute = true) => { const steps = [ - utils.createStepAssertion( - 'Checkout', - true, - null, - 'GETBRANCHREF', - 'Checkout', - [], - [], - ), + utils.createStepAssertion('Checkout', true, null, 'GETBRANCHREF', 'Checkout', [], []), utils.createStepAssertion( 'Check if pull request number is correct', true, @@ -62,15 +61,7 @@ const assertGetBranchRefJobExecuted = (workflowResult, didExecute = true) => { }; const assertAndroidJobExecuted = (workflowResult, ref = '', didExecute = true, failsAt = -1) => { const steps = [ - utils.createStepAssertion( - 'Checkout', - true, - null, - 'ANDROID', - 'Checkout', - [{key: 'ref', value: ref}], - [], - ), + utils.createStepAssertion('Checkout', true, null, 'ANDROID', 'Checkout', [{key: 'ref', value: ref}], []), utils.createStepAssertion( 'Create .env.adhoc file based on staging and add PULL_REQUEST_NUMBER env to it', true, @@ -80,49 +71,31 @@ const assertAndroidJobExecuted = (workflowResult, ref = '', didExecute = true, f [], [], ), - utils.createStepAssertion( - 'Setup Node', - true, - null, - 'ANDROID', - 'Setup Node', - [], - [], - ), + utils.createStepAssertion('Setup Node', true, null, 'ANDROID', 'Setup Node', [], []), utils.createStepAssertion( 'Setup Ruby', true, null, 'ANDROID', 'Setup Ruby', - [{key: 'ruby-version', value: '2.7'}, {key: 'bundler-cache', value: true}], - [], - ), - utils.createStepAssertion( - 'Decrypt keystore', - true, - null, - 'ANDROID', - 'Decrypt keystore', - [], - [{key: 'LARGE_SECRET_PASSPHRASE', value: '***'}], - ), - utils.createStepAssertion( - 'Decrypt json key', - true, - null, - 'ANDROID', - 'Decrypt json key', + [ + {key: 'ruby-version', value: '2.7'}, + {key: 'bundler-cache', value: true}, + ], [], - [{key: 'LARGE_SECRET_PASSPHRASE', value: '***'}], ), + utils.createStepAssertion('Decrypt keystore', true, null, 'ANDROID', 'Decrypt keystore', [], [{key: 'LARGE_SECRET_PASSPHRASE', value: '***'}]), + utils.createStepAssertion('Decrypt json key', true, null, 'ANDROID', 'Decrypt json key', [], [{key: 'LARGE_SECRET_PASSPHRASE', value: '***'}]), utils.createStepAssertion( 'Configure AWS Credentials', true, null, 'ANDROID', 'Configure AWS Credentials', - [{key: 'AWS_ACCESS_KEY_ID', value: '***'}, {key: 'AWS_SECRET_ACCESS_KEY', value: '***'}], + [ + {key: 'AWS_ACCESS_KEY_ID', value: '***'}, + {key: 'AWS_SECRET_ACCESS_KEY', value: '***'}, + ], [], ), utils.createStepAssertion( @@ -145,7 +118,10 @@ const assertAndroidJobExecuted = (workflowResult, ref = '', didExecute = true, f null, 'ANDROID', 'Upload Artifact', - [{key: 'name', value: 'android'}, {key: 'path', value: './android_paths.json'}], + [ + {key: 'name', value: 'android'}, + {key: 'path', value: './android_paths.json'}, + ], [], ), ]; @@ -170,50 +146,26 @@ const assertAndroidJobExecuted = (workflowResult, ref = '', didExecute = true, f }; const assertIOSJobExecuted = (workflowResult, ref = '', didExecute = true, failsAt = -1) => { const steps = [ - utils.createStepAssertion( - 'Checkout', - true, - null, - 'IOS', - 'Checkout', - [{key: 'ref', value: ref}], - [], - ), - utils.createStepAssertion( - 'Create .env.adhoc file based on staging and add PULL_REQUEST_NUMBER env to it', - true, - null, - 'IOS', - 'Creating .env.adhoc file based on staging', - [], - [], - ), - utils.createStepAssertion( - 'Setup Node', - true, - null, - 'IOS', - 'Setup Node', - [], - [], - ), + utils.createStepAssertion('Checkout', true, null, 'IOS', 'Checkout', [{key: 'ref', value: ref}], []), + utils.createStepAssertion('Create .env.adhoc file based on staging and add PULL_REQUEST_NUMBER env to it', true, null, 'IOS', 'Creating .env.adhoc file based on staging', [], []), + utils.createStepAssertion('Setup Node', true, null, 'IOS', 'Setup Node', [], []), utils.createStepAssertion( 'Setup Ruby', true, null, 'IOS', 'Setup Ruby', - [{key: 'ruby-version', value: '2.7'}, {key: 'bundler-cache', value: true}], + [ + {key: 'ruby-version', value: '2.7'}, + {key: 'bundler-cache', value: true}, + ], [], ), - utils.createStepAssertion( - 'Cache', - true, - null, - 'IOS', - 'Caching', - [{key: 'path', value: 'ios/Pods'}, {key: 'key', value: 'Linux-pods-'}, {key: 'restore-keys', value: 'Linux-pods-'}], - ), + utils.createStepAssertion('Cache', true, null, 'IOS', 'Caching', [ + {key: 'path', value: 'ios/Pods'}, + {key: 'key', value: 'Linux-pods-'}, + {key: 'restore-keys', value: 'Linux-pods-'}, + ]), utils.createStepAssertion( 'Install cocoapods', true, @@ -227,31 +179,18 @@ const assertIOSJobExecuted = (workflowResult, ref = '', didExecute = true, fails ], [], ), - utils.createStepAssertion( - 'Decrypt profile', - true, - null, - 'IOS', - 'Decrypt profile', - [], - [{key: 'LARGE_SECRET_PASSPHRASE', value: '***'}], - ), - utils.createStepAssertion( - 'Decrypt certificate', - true, - null, - 'IOS', - 'Decrypt certificate', - [], - [{key: 'LARGE_SECRET_PASSPHRASE', value: '***'}], - ), + utils.createStepAssertion('Decrypt profile', true, null, 'IOS', 'Decrypt profile', [], [{key: 'LARGE_SECRET_PASSPHRASE', value: '***'}]), + utils.createStepAssertion('Decrypt certificate', true, null, 'IOS', 'Decrypt certificate', [], [{key: 'LARGE_SECRET_PASSPHRASE', value: '***'}]), utils.createStepAssertion( 'Configure AWS Credentials', true, null, 'IOS', 'Configure AWS Credentials', - [{key: 'AWS_ACCESS_KEY_ID', value: '***'}, {key: 'AWS_SECRET_ACCESS_KEY', value: '***'}], + [ + {key: 'AWS_ACCESS_KEY_ID', value: '***'}, + {key: 'AWS_SECRET_ACCESS_KEY', value: '***'}, + ], [], ), utils.createStepAssertion( @@ -274,7 +213,10 @@ const assertIOSJobExecuted = (workflowResult, ref = '', didExecute = true, fails null, 'IOS', 'Upload Artifact', - [{key: 'name', value: 'ios'}, {key: 'path', value: './ios_paths.json'}], + [ + {key: 'name', value: 'ios'}, + {key: 'path', value: './ios_paths.json'}, + ], [], ), ]; @@ -305,7 +247,10 @@ const assertDesktopJobExecuted = (workflowResult, ref = '', didExecute = true, f null, 'DESKTOP', 'Checkout', - [{key: 'ref', value: ref}, {key: 'fetch-depth', value: '0'}], + [ + {key: 'ref', value: ref}, + {key: 'fetch-depth', value: '0'}, + ], [], ), utils.createStepAssertion( @@ -317,31 +262,18 @@ const assertDesktopJobExecuted = (workflowResult, ref = '', didExecute = true, f [], [], ), - utils.createStepAssertion( - 'Setup Node', - true, - null, - 'DESKTOP', - 'Setup Node', - [], - [], - ), - utils.createStepAssertion( - 'Decrypt Developer ID Certificate', - true, - null, - 'DESKTOP', - 'Decrypt Developer ID Certificate', - [], - [{key: 'DEVELOPER_ID_SECRET_PASSPHRASE', value: '***'}], - ), + utils.createStepAssertion('Setup Node', true, null, 'DESKTOP', 'Setup Node', [], []), + utils.createStepAssertion('Decrypt Developer ID Certificate', true, null, 'DESKTOP', 'Decrypt Developer ID Certificate', [], [{key: 'DEVELOPER_ID_SECRET_PASSPHRASE', value: '***'}]), utils.createStepAssertion( 'Configure AWS Credentials', true, null, 'DESKTOP', 'Configure AWS Credentials', - [{key: 'AWS_ACCESS_KEY_ID', value: '***'}, {key: 'AWS_SECRET_ACCESS_KEY', value: '***'}], + [ + {key: 'AWS_ACCESS_KEY_ID', value: '***'}, + {key: 'AWS_SECRET_ACCESS_KEY', value: '***'}, + ], [], ), utils.createStepAssertion( @@ -388,63 +320,29 @@ const assertWebJobExecuted = (workflowResult, ref = '', didExecute = true, fails null, 'WEB', 'Checkout', - [{key: 'fetch-depth', value: '0'}, {key: 'ref', value: ref}], - [], - ), - utils.createStepAssertion( - 'Create .env.adhoc file based on staging and add PULL_REQUEST_NUMBER env to it', - true, - null, - 'WEB', - 'Creating .env.adhoc file based on staging', - [], - [], - ), - utils.createStepAssertion( - 'Setup Node', - true, - null, - 'WEB', - 'Setup Node', - [], + [ + {key: 'fetch-depth', value: '0'}, + {key: 'ref', value: ref}, + ], [], ), + utils.createStepAssertion('Create .env.adhoc file based on staging and add PULL_REQUEST_NUMBER env to it', true, null, 'WEB', 'Creating .env.adhoc file based on staging', [], []), + utils.createStepAssertion('Setup Node', true, null, 'WEB', 'Setup Node', [], []), utils.createStepAssertion( 'Configure AWS Credentials', true, null, 'WEB', 'Configure AWS Credentials', - [{key: 'AWS_ACCESS_KEY_ID', value: '***'}, {key: 'AWS_SECRET_ACCESS_KEY', value: '***'}], - [], - ), - utils.createStepAssertion( - 'Build web for testing', - true, - null, - 'WEB', - 'Build web for testing', - [], - [], - ), - utils.createStepAssertion( - 'Build docs', - true, - null, - 'WEB', - 'Build docs', - [], - [], - ), - utils.createStepAssertion( - 'Deploy to S3 for internal testing', - true, - null, - 'WEB', - 'Deploy to S3 for internal testing', - [], + [ + {key: 'AWS_ACCESS_KEY_ID', value: '***'}, + {key: 'AWS_SECRET_ACCESS_KEY', value: '***'}, + ], [], ), + utils.createStepAssertion('Build web for testing', true, null, 'WEB', 'Build web for testing', [], []), + utils.createStepAssertion('Build docs', true, null, 'WEB', 'Build docs', [], []), + utils.createStepAssertion('Deploy to S3 for internal testing', true, null, 'WEB', 'Deploy to S3 for internal testing', [], []), ]; steps.forEach((expectedStep, i) => { @@ -467,7 +365,8 @@ const assertWebJobExecuted = (workflowResult, ref = '', didExecute = true, fails }; const assertPostGithubCommentJobExecuted = ( - workflowResult, ref = '', + workflowResult, + ref = '', pullRequestNumber = '1234', didExecute = true, androidStatus = 'success', @@ -476,50 +375,14 @@ const assertPostGithubCommentJobExecuted = ( webStatus = 'success', ) => { const steps = [ - utils.createStepAssertion( - 'Checkout', - true, - null, - 'POSTGITHUBCOMMENT', - 'Checkout', - [{key: 'ref', value: ref}], - [], - ), - utils.createStepAssertion( - 'Download Artifact', - true, - null, - 'POSTGITHUBCOMMENT', - 'Download Artifact', - [], - [], - ), + utils.createStepAssertion('Checkout', true, null, 'POSTGITHUBCOMMENT', 'Checkout', [{key: 'ref', value: ref}], []), + utils.createStepAssertion('Download Artifact', true, null, 'POSTGITHUBCOMMENT', 'Download Artifact', [], []), ]; if (androidStatus === 'success') { - steps.push( - utils.createStepAssertion( - 'Read JSONs with android paths', - true, - null, - 'POSTGITHUBCOMMENT', - 'Read JSONs with android paths', - [], - [], - ), - ); + steps.push(utils.createStepAssertion('Read JSONs with android paths', true, null, 'POSTGITHUBCOMMENT', 'Read JSONs with android paths', [], [])); } if (iOSStatus === 'success') { - steps.push( - utils.createStepAssertion( - 'Read JSONs with iOS paths', - true, - null, - 'POSTGITHUBCOMMENT', - 'Read JSONs with iOS paths', - [], - [], - ), - ); + steps.push(utils.createStepAssertion('Read JSONs with iOS paths', true, null, 'POSTGITHUBCOMMENT', 'Read JSONs with iOS paths', [], [])); } steps.push( utils.createStepAssertion( diff --git a/workflow_tests/assertions/validateGithubActionsAssertions.js b/workflow_tests/assertions/validateGithubActionsAssertions.js index de7a699e2acc..f63923402cc7 100644 --- a/workflow_tests/assertions/validateGithubActionsAssertions.js +++ b/workflow_tests/assertions/validateGithubActionsAssertions.js @@ -2,42 +2,10 @@ const utils = require('../utils/utils'); const assertVerifyJobExecuted = (workflowResult, didExecute = true) => { const steps = [ - utils.createStepAssertion( - 'Checkout', - true, - null, - 'VERIFY', - 'Checkout', - [{key: 'fetch-depth', value: '0'}], - [], - ), - utils.createStepAssertion( - 'Setup Node', - true, - null, - 'VERIFY', - 'Setup Node', - [], - [], - ), - utils.createStepAssertion( - 'Verify Javascript Action Builds', - true, - null, - 'VERIFY', - 'Verify Javascript Action Builds', - [], - [], - ), - utils.createStepAssertion( - 'Validate actions and workflows', - true, - null, - 'VERIFY', - 'Validate actions and workflows', - [], - [], - ), + utils.createStepAssertion('Checkout', true, null, 'VERIFY', 'Checkout', [{key: 'fetch-depth', value: '0'}], []), + utils.createStepAssertion('Setup Node', true, null, 'VERIFY', 'Setup Node', [], []), + utils.createStepAssertion('Verify Javascript Action Builds', true, null, 'VERIFY', 'Verify Javascript Action Builds', [], []), + utils.createStepAssertion('Validate actions and workflows', true, null, 'VERIFY', 'Validate actions and workflows', [], []), ]; steps.forEach((expectedStep) => { diff --git a/workflow_tests/assertions/verifyPodfileAssertions.js b/workflow_tests/assertions/verifyPodfileAssertions.js index 8bce663eeb40..c9b24348c868 100644 --- a/workflow_tests/assertions/verifyPodfileAssertions.js +++ b/workflow_tests/assertions/verifyPodfileAssertions.js @@ -2,33 +2,9 @@ const utils = require('../utils/utils'); const assertVerifyJobExecuted = (workflowResult, didExecute = true) => { const steps = [ - utils.createStepAssertion( - 'Checkout', - true, - null, - 'VERIFY', - 'Checkout', - [{key: 'fetch-depth', value: '0'}], - [], - ), - utils.createStepAssertion( - 'Setup Node', - true, - null, - 'VERIFY', - 'Setup Node', - [], - [], - ), - utils.createStepAssertion( - 'Verify podfile', - true, - null, - 'VERIFY', - 'Verify podfile', - [], - [], - ), + utils.createStepAssertion('Checkout', true, null, 'VERIFY', 'Checkout', [{key: 'fetch-depth', value: '0'}], []), + utils.createStepAssertion('Setup Node', true, null, 'VERIFY', 'Setup Node', [], []), + utils.createStepAssertion('Verify podfile', true, null, 'VERIFY', 'Verify podfile', [], []), ]; steps.forEach((expectedStep) => { diff --git a/workflow_tests/assertions/verifySignedCommitsAssertions.js b/workflow_tests/assertions/verifySignedCommitsAssertions.js index b85f30a7cfd0..458bc684363f 100644 --- a/workflow_tests/assertions/verifySignedCommitsAssertions.js +++ b/workflow_tests/assertions/verifySignedCommitsAssertions.js @@ -1,17 +1,7 @@ const utils = require('../utils/utils'); const assertVerifySignedCommitsJobExecuted = (workflowResult, didExecute = true) => { - const steps = [ - utils.createStepAssertion( - 'Verify signed commits', - true, - null, - 'VERIFYSIGNEDCOMMITS', - 'Verify signed commits', - [{key: 'GITHUB_TOKEN', value: '***'}], - [], - ), - ]; + const steps = [utils.createStepAssertion('Verify signed commits', true, null, 'VERIFYSIGNEDCOMMITS', 'Verify signed commits', [{key: 'GITHUB_TOKEN', value: '***'}], [])]; steps.forEach((expectedStep) => { if (didExecute) { diff --git a/workflow_tests/assertions/warnCPLabelAssertions.js b/workflow_tests/assertions/warnCPLabelAssertions.js index e547e1801db1..a8eb34080815 100644 --- a/workflow_tests/assertions/warnCPLabelAssertions.js +++ b/workflow_tests/assertions/warnCPLabelAssertions.js @@ -24,15 +24,7 @@ const assertWarnCPLabelJobExecuted = (workflowResult, didExecute = true, isSucce }); const failedSteps = [ - utils.createStepAssertion( - 'Announce failed workflow in Slack', - true, - null, - 'WARNCPLABEL', - 'Announce failed workflow in Slack', - [{key: 'SLACK_WEBHOOK', value: '***'}], - [], - ), + utils.createStepAssertion('Announce failed workflow in Slack', true, null, 'WARNCPLABEL', 'Announce failed workflow in Slack', [{key: 'SLACK_WEBHOOK', value: '***'}], []), ]; failedSteps.forEach((step) => { diff --git a/workflow_tests/authorChecklist.test.js b/workflow_tests/authorChecklist.test.js index 59a048896a0b..688ff83f48bb 100644 --- a/workflow_tests/authorChecklist.test.js +++ b/workflow_tests/authorChecklist.test.js @@ -51,23 +51,16 @@ describe('test workflow authorChecklist', () => { const repoPath = mockGithub.repo.getPath('testAuthorChecklistWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'authorChecklist.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); - act = utils.setUpActParams( - act, - event, - eventOptions, - {}, - githubToken, - ); + act = utils.setUpActParams(act, event, eventOptions, {}, githubToken); const testMockSteps = { checklist: mocks.AUTHORCHECKLIST__CHECKLIST__STEP_MOCKS, }; - const result = await act - .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'authorChecklist.yml'), - mockSteps: testMockSteps, - actor, - logFile: utils.getLogFilePath('authorChecklist', expect.getState().currentTestName), - }); + const result = await act.runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows', 'authorChecklist.yml'), + mockSteps: testMockSteps, + actor, + logFile: utils.getLogFilePath('authorChecklist', expect.getState().currentTestName), + }); assertions.assertChecklistJobExecuted(result); }); @@ -78,23 +71,16 @@ describe('test workflow authorChecklist', () => { const repoPath = mockGithub.repo.getPath('testAuthorChecklistWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'authorChecklist.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); - act = utils.setUpActParams( - act, - event, - eventOptions, - {}, - githubToken, - ); + act = utils.setUpActParams(act, event, eventOptions, {}, githubToken); const testMockSteps = { checklist: mocks.AUTHORCHECKLIST__CHECKLIST__STEP_MOCKS, }; - const result = await act - .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'authorChecklist.yml'), - mockSteps: testMockSteps, - actor, - logFile: utils.getLogFilePath('authorChecklist', expect.getState().currentTestName), - }); + const result = await act.runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows', 'authorChecklist.yml'), + mockSteps: testMockSteps, + actor, + logFile: utils.getLogFilePath('authorChecklist', expect.getState().currentTestName), + }); assertions.assertChecklistJobExecuted(result, false); }); @@ -111,23 +97,16 @@ describe('test workflow authorChecklist', () => { const repoPath = mockGithub.repo.getPath('testAuthorChecklistWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'authorChecklist.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); - act = utils.setUpActParams( - act, - event, - eventOptions, - {}, - githubToken, - ); + act = utils.setUpActParams(act, event, eventOptions, {}, githubToken); const testMockSteps = { checklist: mocks.AUTHORCHECKLIST__CHECKLIST__STEP_MOCKS, }; - const result = await act - .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'authorChecklist.yml'), - mockSteps: testMockSteps, - actor, - logFile: utils.getLogFilePath('authorChecklist', expect.getState().currentTestName), - }); + const result = await act.runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows', 'authorChecklist.yml'), + mockSteps: testMockSteps, + actor, + logFile: utils.getLogFilePath('authorChecklist', expect.getState().currentTestName), + }); assertions.assertChecklistJobExecuted(result); }); @@ -138,23 +117,16 @@ describe('test workflow authorChecklist', () => { const repoPath = mockGithub.repo.getPath('testAuthorChecklistWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'authorChecklist.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); - act = utils.setUpActParams( - act, - event, - eventOptions, - {}, - githubToken, - ); + act = utils.setUpActParams(act, event, eventOptions, {}, githubToken); const testMockSteps = { checklist: mocks.AUTHORCHECKLIST__CHECKLIST__STEP_MOCKS, }; - const result = await act - .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'authorChecklist.yml'), - mockSteps: testMockSteps, - actor, - logFile: utils.getLogFilePath('authorChecklist', expect.getState().currentTestName), - }); + const result = await act.runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows', 'authorChecklist.yml'), + mockSteps: testMockSteps, + actor, + logFile: utils.getLogFilePath('authorChecklist', expect.getState().currentTestName), + }); assertions.assertChecklistJobExecuted(result, false); }); @@ -171,23 +143,16 @@ describe('test workflow authorChecklist', () => { const repoPath = mockGithub.repo.getPath('testAuthorChecklistWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'authorChecklist.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); - act = utils.setUpActParams( - act, - event, - eventOptions, - {}, - githubToken, - ); + act = utils.setUpActParams(act, event, eventOptions, {}, githubToken); const testMockSteps = { checklist: mocks.AUTHORCHECKLIST__CHECKLIST__STEP_MOCKS, }; - const result = await act - .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'authorChecklist.yml'), - mockSteps: testMockSteps, - actor, - logFile: utils.getLogFilePath('authorChecklist', expect.getState().currentTestName), - }); + const result = await act.runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows', 'authorChecklist.yml'), + mockSteps: testMockSteps, + actor, + logFile: utils.getLogFilePath('authorChecklist', expect.getState().currentTestName), + }); assertions.assertChecklistJobExecuted(result); }); @@ -198,23 +163,16 @@ describe('test workflow authorChecklist', () => { const repoPath = mockGithub.repo.getPath('testAuthorChecklistWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'authorChecklist.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); - act = utils.setUpActParams( - act, - event, - eventOptions, - {}, - githubToken, - ); + act = utils.setUpActParams(act, event, eventOptions, {}, githubToken); const testMockSteps = { checklist: mocks.AUTHORCHECKLIST__CHECKLIST__STEP_MOCKS, }; - const result = await act - .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'authorChecklist.yml'), - mockSteps: testMockSteps, - actor, - logFile: utils.getLogFilePath('authorChecklist', expect.getState().currentTestName), - }); + const result = await act.runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows', 'authorChecklist.yml'), + mockSteps: testMockSteps, + actor, + logFile: utils.getLogFilePath('authorChecklist', expect.getState().currentTestName), + }); assertions.assertChecklistJobExecuted(result, false); }); diff --git a/workflow_tests/cherryPick.test.js b/workflow_tests/cherryPick.test.js index db8a8fbd4f6e..14de1c0b9fb8 100644 --- a/workflow_tests/cherryPick.test.js +++ b/workflow_tests/cherryPick.test.js @@ -67,13 +67,12 @@ describe('test workflow cherryPick', () => { createNewVersion: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, cherryPick: mocks.getCherryPickMockSteps(true, true, true), }; - const result = await act - .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), - mockSteps: testMockSteps, - actor, - logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), - }); + const result = await act.runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), + mockSteps: testMockSteps, + actor, + logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), + }); assertions.assertValidateActorJobExecuted(result, actor); assertions.assertCreateNewVersionJobExecuted(result, false); @@ -111,28 +110,16 @@ describe('test workflow cherryPick', () => { NEW_VERSION: newVersion, }, ); - const result = await act - .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), - mockSteps: testMockSteps, - actor, - logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), - }); + const result = await act.runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), + mockSteps: testMockSteps, + actor, + logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), + }); assertions.assertValidateActorJobExecuted(result, actor); assertions.assertCreateNewVersionJobExecuted(result); - assertions.assertCherryPickJobExecuted( - result, - actor, - '1234', - '1.2.3', - true, - mergeConflicts || !versionsMatch, - !mergeConflicts, - versionsMatch, - prIsMergeable, - newVersion, - ); + assertions.assertCherryPickJobExecuted(result, actor, '1234', '1.2.3', true, mergeConflicts || !versionsMatch, !mergeConflicts, versionsMatch, prIsMergeable, newVersion); }); }); describe('actor is a deployer', () => { @@ -170,13 +157,12 @@ describe('test workflow cherryPick', () => { NEW_VERSION: newVersion, }, ); - const result = await act - .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), - mockSteps: testMockSteps, - actor, - logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), - }); + const result = await act.runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), + mockSteps: testMockSteps, + actor, + logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), + }); assertions.assertValidateActorJobExecuted(result, actor); assertions.assertCreateNewVersionJobExecuted(result); @@ -221,13 +207,12 @@ describe('test workflow cherryPick', () => { NEW_VERSION: newVersion, }, ); - const result = await act - .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), - mockSteps: testMockSteps, - actor, - logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), - }); + const result = await act.runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), + mockSteps: testMockSteps, + actor, + logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), + }); assertions.assertValidateActorJobExecuted(result, actor); assertions.assertCreateNewVersionJobExecuted(result); @@ -275,13 +260,12 @@ describe('test workflow cherryPick', () => { NEW_VERSION: newVersion, }, ); - const result = await act - .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), - mockSteps: testMockSteps, - actor, - logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), - }); + const result = await act.runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), + mockSteps: testMockSteps, + actor, + logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), + }); assertions.assertValidateActorJobExecuted(result, actor); assertions.assertCreateNewVersionJobExecuted(result); @@ -326,13 +310,12 @@ describe('test workflow cherryPick', () => { NEW_VERSION: newVersion, }, ); - const result = await act - .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), - mockSteps: testMockSteps, - actor, - logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), - }); + const result = await act.runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), + mockSteps: testMockSteps, + actor, + logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), + }); assertions.assertValidateActorJobExecuted(result, actor); assertions.assertCreateNewVersionJobExecuted(result); @@ -383,13 +366,12 @@ describe('test workflow cherryPick', () => { NEW_VERSION: newVersion, }, ); - const result = await act - .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), - mockSteps: testMockSteps, - actor, - logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), - }); + const result = await act.runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), + mockSteps: testMockSteps, + actor, + logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), + }); assertions.assertValidateActorJobExecuted(result, actor); assertions.assertCreateNewVersionJobExecuted(result); @@ -434,13 +416,12 @@ describe('test workflow cherryPick', () => { NEW_VERSION: newVersion, }, ); - const result = await act - .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), - mockSteps: testMockSteps, - actor, - logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), - }); + const result = await act.runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), + mockSteps: testMockSteps, + actor, + logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), + }); assertions.assertValidateActorJobExecuted(result, actor); assertions.assertCreateNewVersionJobExecuted(result); @@ -488,13 +469,12 @@ describe('test workflow cherryPick', () => { NEW_VERSION: newVersion, }, ); - const result = await act - .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), - mockSteps: testMockSteps, - actor, - logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), - }); + const result = await act.runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), + mockSteps: testMockSteps, + actor, + logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), + }); assertions.assertValidateActorJobExecuted(result, actor); assertions.assertCreateNewVersionJobExecuted(result); @@ -539,13 +519,12 @@ describe('test workflow cherryPick', () => { NEW_VERSION: newVersion, }, ); - const result = await act - .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), - mockSteps: testMockSteps, - actor, - logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), - }); + const result = await act.runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), + mockSteps: testMockSteps, + actor, + logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), + }); assertions.assertValidateActorJobExecuted(result, actor); assertions.assertCreateNewVersionJobExecuted(result); @@ -600,13 +579,12 @@ describe('test workflow cherryPick', () => { NEW_VERSION: newVersion, }, ); - const result = await act - .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), - mockSteps: testMockSteps, - actor, - logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), - }); + const result = await act.runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), + mockSteps: testMockSteps, + actor, + logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), + }); assertions.assertValidateActorJobExecuted(result, actor); assertions.assertCreateNewVersionJobExecuted(result, false); @@ -651,13 +629,12 @@ describe('test workflow cherryPick', () => { NEW_VERSION: newVersion, }, ); - const result = await act - .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), - mockSteps: testMockSteps, - actor, - logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), - }); + const result = await act.runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), + mockSteps: testMockSteps, + actor, + logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), + }); assertions.assertValidateActorJobExecuted(result, actor); assertions.assertCreateNewVersionJobExecuted(result, false); @@ -705,13 +682,12 @@ describe('test workflow cherryPick', () => { NEW_VERSION: newVersion, }, ); - const result = await act - .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), - mockSteps: testMockSteps, - actor, - logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), - }); + const result = await act.runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), + mockSteps: testMockSteps, + actor, + logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), + }); assertions.assertValidateActorJobExecuted(result, actor); assertions.assertCreateNewVersionJobExecuted(result, false); @@ -756,13 +732,12 @@ describe('test workflow cherryPick', () => { NEW_VERSION: newVersion, }, ); - const result = await act - .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), - mockSteps: testMockSteps, - actor, - logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), - }); + const result = await act.runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), + mockSteps: testMockSteps, + actor, + logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), + }); assertions.assertValidateActorJobExecuted(result, actor); assertions.assertCreateNewVersionJobExecuted(result, false); @@ -813,13 +788,12 @@ describe('test workflow cherryPick', () => { NEW_VERSION: newVersion, }, ); - const result = await act - .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), - mockSteps: testMockSteps, - actor, - logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), - }); + const result = await act.runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), + mockSteps: testMockSteps, + actor, + logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), + }); assertions.assertValidateActorJobExecuted(result, actor); assertions.assertCreateNewVersionJobExecuted(result, false); @@ -864,13 +838,12 @@ describe('test workflow cherryPick', () => { NEW_VERSION: newVersion, }, ); - const result = await act - .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), - mockSteps: testMockSteps, - actor, - logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), - }); + const result = await act.runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), + mockSteps: testMockSteps, + actor, + logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), + }); assertions.assertValidateActorJobExecuted(result, actor); assertions.assertCreateNewVersionJobExecuted(result, false); @@ -918,13 +891,12 @@ describe('test workflow cherryPick', () => { NEW_VERSION: newVersion, }, ); - const result = await act - .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), - mockSteps: testMockSteps, - actor, - logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), - }); + const result = await act.runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), + mockSteps: testMockSteps, + actor, + logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), + }); assertions.assertValidateActorJobExecuted(result, actor); assertions.assertCreateNewVersionJobExecuted(result, false); @@ -969,13 +941,12 @@ describe('test workflow cherryPick', () => { NEW_VERSION: newVersion, }, ); - const result = await act - .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), - mockSteps: testMockSteps, - actor, - logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), - }); + const result = await act.runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), + mockSteps: testMockSteps, + actor, + logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), + }); assertions.assertValidateActorJobExecuted(result, actor); assertions.assertCreateNewVersionJobExecuted(result, false); @@ -1025,13 +996,12 @@ describe('test workflow cherryPick', () => { createNewVersion: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, cherryPick: mocks.getCherryPickMockSteps(true, true, true), }; - const result = await act - .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), - mockSteps: testMockSteps, - actor: 'Dummy Author', - logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), - }); + const result = await act.runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), + mockSteps: testMockSteps, + actor: 'Dummy Author', + logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), + }); assertions.assertValidateActorJobExecuted(result, 'Dummy Author', false); assertions.assertCreateNewVersionJobExecuted(result, false); diff --git a/workflow_tests/cla.test.js b/workflow_tests/cla.test.js index 6ed6ce291395..bd75a18a919a 100644 --- a/workflow_tests/cla.test.js +++ b/workflow_tests/cla.test.js @@ -63,23 +63,16 @@ describe('test workflow cla', () => { const repoPath = mockGithub.repo.getPath('testClaWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'cla.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); - act = utils.setUpActParams( - act, - event, - eventData, - secrets, - githubToken, - ); + act = utils.setUpActParams(act, event, eventData, secrets, githubToken); const testMockSteps = { CLA: mocks.CLA__CLA__NO_MATCHES__STEP_MOCKS, }; - const result = await act - .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'cla.yml'), - mockSteps: testMockSteps, - actor, - logFile: utils.getLogFilePath('cla', expect.getState().currentTestName), - }); + const result = await act.runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows', 'cla.yml'), + mockSteps: testMockSteps, + actor, + logFile: utils.getLogFilePath('cla', expect.getState().currentTestName), + }); assertions.assertCLAJobExecuted(result, commentBody, `${repoPath}/remote/origin`, true, false); }); @@ -101,23 +94,16 @@ describe('test workflow cla', () => { const repoPath = mockGithub.repo.getPath('testClaWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'cla.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); - act = utils.setUpActParams( - act, - event, - eventData, - secrets, - githubToken, - ); + act = utils.setUpActParams(act, event, eventData, secrets, githubToken); const testMockSteps = { CLA: mocks.CLA__CLA__CHECK_MATCH__STEP_MOCKS, }; - const result = await act - .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'cla.yml'), - mockSteps: testMockSteps, - actor, - logFile: utils.getLogFilePath('cla', expect.getState().currentTestName), - }); + const result = await act.runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows', 'cla.yml'), + mockSteps: testMockSteps, + actor, + logFile: utils.getLogFilePath('cla', expect.getState().currentTestName), + }); assertions.assertCLAJobExecuted(result, commentBody, `${repoPath}/remote/origin`, true, true); }); @@ -139,23 +125,16 @@ describe('test workflow cla', () => { const repoPath = mockGithub.repo.getPath('testClaWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'cla.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); - act = utils.setUpActParams( - act, - event, - eventData, - secrets, - githubToken, - ); + act = utils.setUpActParams(act, event, eventData, secrets, githubToken); const testMockSteps = { CLA: mocks.CLA__CLA__RECHECK_MATCH__STEP_MOCKS, }; - const result = await act - .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'cla.yml'), - mockSteps: testMockSteps, - actor, - logFile: utils.getLogFilePath('cla', expect.getState().currentTestName), - }); + const result = await act.runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows', 'cla.yml'), + mockSteps: testMockSteps, + actor, + logFile: utils.getLogFilePath('cla', expect.getState().currentTestName), + }); assertions.assertCLAJobExecuted(result, commentBody, `${repoPath}/remote/origin`, true, true); }); @@ -163,7 +142,7 @@ describe('test workflow cla', () => { }); describe('event is pull_request_target', () => { const event = 'pull_request_target'; - describe('no regex matches - there\'s no comment', () => { + describe("no regex matches - there's no comment", () => { const eventData = { action: 'opened', issue: { @@ -176,23 +155,16 @@ describe('test workflow cla', () => { const repoPath = mockGithub.repo.getPath('testClaWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'cla.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); - act = utils.setUpActParams( - act, - event, - eventData, - secrets, - githubToken, - ); + act = utils.setUpActParams(act, event, eventData, secrets, githubToken); const testMockSteps = { CLA: mocks.CLA__CLA__NO_MATCHES__STEP_MOCKS, }; - const result = await act - .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'cla.yml'), - mockSteps: testMockSteps, - actor, - logFile: utils.getLogFilePath('cla', expect.getState().currentTestName), - }); + const result = await act.runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows', 'cla.yml'), + mockSteps: testMockSteps, + actor, + logFile: utils.getLogFilePath('cla', expect.getState().currentTestName), + }); assertions.assertCLAJobExecuted(result, '', `${repoPath}/remote/origin`, true, true); }); @@ -207,23 +179,16 @@ describe('test workflow cla', () => { const repoPath = mockGithub.repo.getPath('testClaWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'cla.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); - act = utils.setUpActParams( - act, - event, - eventData, - secrets, - githubToken, - ); + act = utils.setUpActParams(act, event, eventData, secrets, githubToken); const testMockSteps = { CLA: mocks.CLA__CLA__NO_MATCHES__STEP_MOCKS, }; - const result = await act - .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'cla.yml'), - mockSteps: testMockSteps, - actor, - logFile: utils.getLogFilePath('cla', expect.getState().currentTestName), - }); + const result = await act.runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows', 'cla.yml'), + mockSteps: testMockSteps, + actor, + logFile: utils.getLogFilePath('cla', expect.getState().currentTestName), + }); assertions.assertCLAJobExecuted(result, '', `${repoPath}/remote/origin`, false); }); diff --git a/workflow_tests/createNewVersion.test.js b/workflow_tests/createNewVersion.test.js index 890af650f9ad..8a0b06d339b0 100644 --- a/workflow_tests/createNewVersion.test.js +++ b/workflow_tests/createNewVersion.test.js @@ -57,27 +57,18 @@ describe('test workflow createNewVersion', () => { const repoPath = mockGithub.repo.getPath('testCreateNewVersionWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'createNewVersion.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); - act = utils.setUpActParams( - act, - event, - {}, - secrets, - githubToken, - {}, - inputs, - ); + act = utils.setUpActParams(act, event, {}, secrets, githubToken, {}, inputs); act = utils.setJobRunners(act, {createNewVersion: 'ubuntu-latest'}, workflowPath); const testMockSteps = { validateActor: validateActorMockSteps, createNewVersion: mocks.CREATENEWVERSION__CREATENEWVERSION__STEP_MOCKS, }; - const result = await act - .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'createNewVersion.yml'), - mockSteps: testMockSteps, - actor: 'Dummy Author', - logFile: utils.getLogFilePath('createNewVersion', expect.getState().currentTestName), - }); + const result = await act.runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows', 'createNewVersion.yml'), + mockSteps: testMockSteps, + actor: 'Dummy Author', + logFile: utils.getLogFilePath('createNewVersion', expect.getState().currentTestName), + }); assertions.assertValidateActorJobExecuted(result); assertions.assertCreateNewVersionJobExecuted(result); }); @@ -89,27 +80,18 @@ describe('test workflow createNewVersion', () => { const repoPath = mockGithub.repo.getPath('testCreateNewVersionWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'createNewVersion.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); - act = utils.setUpActParams( - act, - event, - {}, - secrets, - githubToken, - {}, - inputs, - ); + act = utils.setUpActParams(act, event, {}, secrets, githubToken, {}, inputs); act = utils.setJobRunners(act, {createNewVersion: 'ubuntu-latest'}, workflowPath); const testMockSteps = { validateActor: validateActorMockSteps, createNewVersion: mocks.CREATENEWVERSION__CREATENEWVERSION__STEP_MOCKS, }; - const result = await act - .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'createNewVersion.yml'), - mockSteps: testMockSteps, - actor: 'Dummy Author', - logFile: utils.getLogFilePath('createNewVersion', expect.getState().currentTestName), - }); + const result = await act.runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows', 'createNewVersion.yml'), + mockSteps: testMockSteps, + actor: 'Dummy Author', + logFile: utils.getLogFilePath('createNewVersion', expect.getState().currentTestName), + }); assertions.assertValidateActorJobExecuted(result); assertions.assertCreateNewVersionJobExecuted(result); }); @@ -121,27 +103,18 @@ describe('test workflow createNewVersion', () => { const repoPath = mockGithub.repo.getPath('testCreateNewVersionWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'createNewVersion.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); - act = utils.setUpActParams( - act, - event, - {}, - secrets, - githubToken, - {}, - inputs, - ); + act = utils.setUpActParams(act, event, {}, secrets, githubToken, {}, inputs); act = utils.setJobRunners(act, {createNewVersion: 'ubuntu-latest'}, workflowPath); const testMockSteps = { validateActor: validateActorMockSteps, createNewVersion: mocks.CREATENEWVERSION__CREATENEWVERSION__STEP_MOCKS, }; - const result = await act - .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'createNewVersion.yml'), - mockSteps: testMockSteps, - actor: 'Dummy Author', - logFile: utils.getLogFilePath('createNewVersion', expect.getState().currentTestName), - }); + const result = await act.runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows', 'createNewVersion.yml'), + mockSteps: testMockSteps, + actor: 'Dummy Author', + logFile: utils.getLogFilePath('createNewVersion', expect.getState().currentTestName), + }); assertions.assertValidateActorJobExecuted(result); assertions.assertCreateNewVersionJobExecuted(result, 'BUILD', false); }); @@ -152,37 +125,19 @@ describe('test workflow createNewVersion', () => { const repoPath = mockGithub.repo.getPath('testCreateNewVersionWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'createNewVersion.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); - act = utils.setUpActParams( - act, - event, - {}, - secrets, - githubToken, - {}, - inputs, - ); + act = utils.setUpActParams(act, event, {}, secrets, githubToken, {}, inputs); act = utils.setJobRunners(act, {createNewVersion: 'ubuntu-latest'}, workflowPath); const testMockSteps = { validateActor: mocks.CREATENEWVERSION__VALIDATEACTOR__ADMIN__STEP_MOCKS, createNewVersion: utils.deepCopy(mocks.CREATENEWVERSION__CREATENEWVERSION__STEP_MOCKS), }; - testMockSteps.createNewVersion[5] = utils.createMockStep( - 'Commit new version', - 'Commit new version', - 'CREATENEWVERSION', - [], - [], - [], - [], - false, - ); - const result = await act - .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'createNewVersion.yml'), - mockSteps: testMockSteps, - actor: 'Dummy Author', - logFile: utils.getLogFilePath('createNewVersion', expect.getState().currentTestName), - }); + testMockSteps.createNewVersion[5] = utils.createMockStep('Commit new version', 'Commit new version', 'CREATENEWVERSION', [], [], [], [], false); + const result = await act.runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows', 'createNewVersion.yml'), + mockSteps: testMockSteps, + actor: 'Dummy Author', + logFile: utils.getLogFilePath('createNewVersion', expect.getState().currentTestName), + }); assertions.assertValidateActorJobExecuted(result); assertions.assertCreateNewVersionJobExecuted(result, 'BUILD', true, false); }); @@ -192,27 +147,18 @@ describe('test workflow createNewVersion', () => { const repoPath = mockGithub.repo.getPath('testCreateNewVersionWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'createNewVersion.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); - act = utils.setUpActParams( - act, - event, - {}, - secrets, - githubToken, - {}, - {SEMVER_LEVEL: 'MAJOR'}, - ); + act = utils.setUpActParams(act, event, {}, secrets, githubToken, {}, {SEMVER_LEVEL: 'MAJOR'}); act = utils.setJobRunners(act, {createNewVersion: 'ubuntu-latest'}, workflowPath); const testMockSteps = { validateActor: mocks.CREATENEWVERSION__VALIDATEACTOR__ADMIN__STEP_MOCKS, createNewVersion: mocks.CREATENEWVERSION__CREATENEWVERSION__STEP_MOCKS, }; - const result = await act - .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'createNewVersion.yml'), - mockSteps: testMockSteps, - actor: 'Dummy Author', - logFile: utils.getLogFilePath('createNewVersion', expect.getState().currentTestName), - }); + const result = await act.runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows', 'createNewVersion.yml'), + mockSteps: testMockSteps, + actor: 'Dummy Author', + logFile: utils.getLogFilePath('createNewVersion', expect.getState().currentTestName), + }); assertions.assertValidateActorJobExecuted(result); assertions.assertCreateNewVersionJobExecuted(result, 'MAJOR'); }); diff --git a/workflow_tests/deploy.test.js b/workflow_tests/deploy.test.js index 7d6797b54fba..4d672b93d36e 100644 --- a/workflow_tests/deploy.test.js +++ b/workflow_tests/deploy.test.js @@ -61,13 +61,12 @@ describe('test workflow deploy', () => { deployStaging: mocks.DEPLOY_STAGING_STEP_MOCKS, deployProduction: mocks.DEPLOY_PRODUCTION_STEP_MOCKS, }; - const result = await act - .runEvent('push', { - workflowFile: path.join(repoPath, '.github', 'workflows', 'deploy.yml'), - mockSteps: testMockSteps, - actor: 'OSBotify', - logFile: utils.getLogFilePath('deploy', expect.getState().currentTestName), - }); + const result = await act.runEvent('push', { + workflowFile: path.join(repoPath, '.github', 'workflows', 'deploy.yml'), + mockSteps: testMockSteps, + actor: 'OSBotify', + logFile: utils.getLogFilePath('deploy', expect.getState().currentTestName), + }); assertions.assertValidateJobExecuted(result); assertions.assertDeployStagingJobExecuted(result, false); assertions.assertDeployProductionJobExecuted(result, false); @@ -94,13 +93,12 @@ describe('test workflow deploy', () => { deployStaging: mocks.DEPLOY_STAGING_STEP_MOCKS, deployProduction: mocks.DEPLOY_PRODUCTION_STEP_MOCKS, }; - const result = await act - .runEvent('push', { - workflowFile: path.join(repoPath, '.github', 'workflows', 'deploy.yml'), - mockSteps: testMockSteps, - actor: 'OSBotify', - logFile: utils.getLogFilePath('deploy', expect.getState().currentTestName), - }); + const result = await act.runEvent('push', { + workflowFile: path.join(repoPath, '.github', 'workflows', 'deploy.yml'), + mockSteps: testMockSteps, + actor: 'OSBotify', + logFile: utils.getLogFilePath('deploy', expect.getState().currentTestName), + }); assertions.assertValidateJobExecuted(result); assertions.assertDeployStagingJobExecuted(result); assertions.assertDeployProductionJobExecuted(result, false); @@ -127,13 +125,12 @@ describe('test workflow deploy', () => { deployStaging: mocks.DEPLOY_STAGING_STEP_MOCKS, deployProduction: mocks.DEPLOY_PRODUCTION_STEP_MOCKS, }; - const result = await act - .runEvent('push', { - workflowFile: path.join(repoPath, '.github', 'workflows', 'deploy.yml'), - mockSteps: testMockSteps, - actor: 'OSBotify', - logFile: utils.getLogFilePath('deploy', expect.getState().currentTestName), - }); + const result = await act.runEvent('push', { + workflowFile: path.join(repoPath, '.github', 'workflows', 'deploy.yml'), + mockSteps: testMockSteps, + actor: 'OSBotify', + logFile: utils.getLogFilePath('deploy', expect.getState().currentTestName), + }); assertions.assertValidateJobExecuted(result); assertions.assertDeployStagingJobExecuted(result, false); assertions.assertDeployProductionJobExecuted(result); @@ -161,13 +158,12 @@ describe('test workflow deploy', () => { deployStaging: mocks.DEPLOY_STAGING_STEP_MOCKS, deployProduction: mocks.DEPLOY_PRODUCTION_STEP_MOCKS, }; - const result = await act - .runEvent('push', { - workflowFile: path.join(repoPath, '.github', 'workflows', 'deploy.yml'), - mockSteps: testMockSteps, - actor: 'Dummy Author', - logFile: utils.getLogFilePath('deploy', expect.getState().currentTestName), - }); + const result = await act.runEvent('push', { + workflowFile: path.join(repoPath, '.github', 'workflows', 'deploy.yml'), + mockSteps: testMockSteps, + actor: 'Dummy Author', + logFile: utils.getLogFilePath('deploy', expect.getState().currentTestName), + }); assertions.assertValidateJobExecuted(result); assertions.assertDeployStagingJobExecuted(result, false); assertions.assertDeployProductionJobExecuted(result, false); @@ -194,13 +190,12 @@ describe('test workflow deploy', () => { deployStaging: mocks.DEPLOY_STAGING_STEP_MOCKS, deployProduction: mocks.DEPLOY_PRODUCTION_STEP_MOCKS, }; - const result = await act - .runEvent('push', { - workflowFile: path.join(repoPath, '.github', 'workflows', 'deploy.yml'), - mockSteps: testMockSteps, - actor: 'Dummy Author', - logFile: utils.getLogFilePath('deploy', expect.getState().currentTestName), - }); + const result = await act.runEvent('push', { + workflowFile: path.join(repoPath, '.github', 'workflows', 'deploy.yml'), + mockSteps: testMockSteps, + actor: 'Dummy Author', + logFile: utils.getLogFilePath('deploy', expect.getState().currentTestName), + }); assertions.assertValidateJobExecuted(result); assertions.assertDeployStagingJobExecuted(result, false); assertions.assertDeployProductionJobExecuted(result, false); @@ -227,13 +222,12 @@ describe('test workflow deploy', () => { deployStaging: mocks.DEPLOY_STAGING_STEP_MOCKS, deployProduction: mocks.DEPLOY_PRODUCTION_STEP_MOCKS, }; - const result = await act - .runEvent('push', { - workflowFile: path.join(repoPath, '.github', 'workflows', 'deploy.yml'), - mockSteps: testMockSteps, - actor: 'Dummy Author', - logFile: utils.getLogFilePath('deploy', expect.getState().currentTestName), - }); + const result = await act.runEvent('push', { + workflowFile: path.join(repoPath, '.github', 'workflows', 'deploy.yml'), + mockSteps: testMockSteps, + actor: 'Dummy Author', + logFile: utils.getLogFilePath('deploy', expect.getState().currentTestName), + }); assertions.assertValidateJobExecuted(result); assertions.assertDeployStagingJobExecuted(result, false); assertions.assertDeployProductionJobExecuted(result, false); @@ -261,13 +255,12 @@ describe('test workflow deploy', () => { }, 'dummy_github_token', ); - let result = await act - .runEvent('pull_request', { - workflowFile: path.join(repoPath, '.github', 'workflows', 'deploy.yml'), - mockSteps: testMockSteps, - actor: 'Dummy Author', - logFile: utils.getLogFilePath('deploy', expect.getState().currentTestName), - }); + let result = await act.runEvent('pull_request', { + workflowFile: path.join(repoPath, '.github', 'workflows', 'deploy.yml'), + mockSteps: testMockSteps, + actor: 'Dummy Author', + logFile: utils.getLogFilePath('deploy', expect.getState().currentTestName), + }); assertions.assertValidateJobExecuted(result, false); assertions.assertDeployStagingJobExecuted(result, false); assertions.assertDeployProductionJobExecuted(result, false); @@ -283,13 +276,12 @@ describe('test workflow deploy', () => { }, 'dummy_github_token', ); - result = await act - .runEvent('workflow_dispatch', { - workflowFile: path.join(repoPath, '.github', 'workflows', 'deploy.yml'), - mockSteps: testMockSteps, - actor: 'Dummy Author', - logFile: utils.getLogFilePath('deploy', expect.getState().currentTestName), - }); + result = await act.runEvent('workflow_dispatch', { + workflowFile: path.join(repoPath, '.github', 'workflows', 'deploy.yml'), + mockSteps: testMockSteps, + actor: 'Dummy Author', + logFile: utils.getLogFilePath('deploy', expect.getState().currentTestName), + }); assertions.assertValidateJobExecuted(result, false); assertions.assertDeployStagingJobExecuted(result, false); assertions.assertDeployProductionJobExecuted(result, false); diff --git a/workflow_tests/deployBlocker.test.js b/workflow_tests/deployBlocker.test.js index 1b3582228310..f279ddaa2933 100644 --- a/workflow_tests/deployBlocker.test.js +++ b/workflow_tests/deployBlocker.test.js @@ -67,25 +67,16 @@ describe('test workflow deployBlocker', () => { const repoPath = mockGithub.repo.getPath('testDeployBlockerWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'deployBlocker.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); - act = utils.setUpActParams( - act, - event, - testEventOptions, - secrets, - githubToken, - {}, - {}, - ); + act = utils.setUpActParams(act, event, testEventOptions, secrets, githubToken, {}, {}); const testMockSteps = { deployBlocker: mocks.DEPLOYBLOCKER__DEPLOYBLOCKER__STEP_MOCKS, }; - const result = await act - .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'deployBlocker.yml'), - mockSteps: testMockSteps, - actor, - logFile: utils.getLogFilePath('deployBlocker', expect.getState().currentTestName), - }); + const result = await act.runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows', 'deployBlocker.yml'), + mockSteps: testMockSteps, + actor, + logFile: utils.getLogFilePath('deployBlocker', expect.getState().currentTestName), + }); assertions.assertDeployBlockerJobExecuted(result, 'Labeled issue title', '1234'); }); @@ -94,15 +85,7 @@ describe('test workflow deployBlocker', () => { const repoPath = mockGithub.repo.getPath('testDeployBlockerWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'deployBlocker.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); - act = utils.setUpActParams( - act, - event, - testEventOptions, - secrets, - githubToken, - {}, - {}, - ); + act = utils.setUpActParams(act, event, testEventOptions, secrets, githubToken, {}, {}); const testMockSteps = { deployBlocker: utils.deepCopy(mocks.DEPLOYBLOCKER__DEPLOYBLOCKER__STEP_MOCKS), }; @@ -116,13 +99,12 @@ describe('test workflow deployBlocker', () => { {}, false, ); - const result = await act - .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'deployBlocker.yml'), - mockSteps: testMockSteps, - actor, - logFile: utils.getLogFilePath('deployBlocker', expect.getState().currentTestName), - }); + const result = await act.runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows', 'deployBlocker.yml'), + mockSteps: testMockSteps, + actor, + logFile: utils.getLogFilePath('deployBlocker', expect.getState().currentTestName), + }); assertions.assertDeployBlockerJobExecuted(result, 'Labeled issue title', '1234', true, false); }); @@ -135,25 +117,16 @@ describe('test workflow deployBlocker', () => { const repoPath = mockGithub.repo.getPath('testDeployBlockerWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'deployBlocker.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); - act = utils.setUpActParams( - act, - event, - testEventOptions, - secrets, - githubToken, - {}, - {}, - ); + act = utils.setUpActParams(act, event, testEventOptions, secrets, githubToken, {}, {}); const testMockSteps = { deployBlocker: mocks.DEPLOYBLOCKER__DEPLOYBLOCKER__STEP_MOCKS, }; - const result = await act - .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'deployBlocker.yml'), - mockSteps: testMockSteps, - actor, - logFile: utils.getLogFilePath('deployBlocker', expect.getState().currentTestName), - }); + const result = await act.runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows', 'deployBlocker.yml'), + mockSteps: testMockSteps, + actor, + logFile: utils.getLogFilePath('deployBlocker', expect.getState().currentTestName), + }); assertions.assertDeployBlockerJobExecuted(result, '', '', false); }); diff --git a/workflow_tests/finishReleaseCycle.test.js b/workflow_tests/finishReleaseCycle.test.js index a7ea208c66de..7ec26a24fefd 100644 --- a/workflow_tests/finishReleaseCycle.test.js +++ b/workflow_tests/finishReleaseCycle.test.js @@ -53,9 +53,7 @@ describe('test workflow finishReleaseCycle', () => { action: 'closed', type: 'closed', issue: { - labels: [ - {name: 'StagingDeployCash'}, - ], + labels: [{name: 'StagingDeployCash'}], number: '1234', }, }, @@ -71,13 +69,12 @@ describe('test workflow finishReleaseCycle', () => { createNewPatchVersion: mocks.FINISHRELEASECYCLE__CREATENEWPATCHVERSION__STEP_MOCKS, createNewStagingDeployCash: mocks.FINISHRELEASECYCLE__CREATENEWSTAGINGDEPLOYCASH__STEP_MOCKS, }; - const result = await act - .runEvent('issues', { - workflowFile: path.join(repoPath, '.github', 'workflows', 'finishReleaseCycle.yml'), - mockSteps: testMockSteps, - actor: 'Dummy Author', - logFile: utils.getLogFilePath('finishReleaseCycle', expect.getState().currentTestName), - }); + const result = await act.runEvent('issues', { + workflowFile: path.join(repoPath, '.github', 'workflows', 'finishReleaseCycle.yml'), + mockSteps: testMockSteps, + actor: 'Dummy Author', + logFile: utils.getLogFilePath('finishReleaseCycle', expect.getState().currentTestName), + }); assertions.assertValidateJobExecuted(result, 'Dummy Author', '1234'); assertions.assertUpdateProductionJobExecuted(result); assertions.assertCreateNewPatchVersionJobExecuted(result); @@ -95,9 +92,7 @@ describe('test workflow finishReleaseCycle', () => { action: 'closed', type: 'closed', issue: { - labels: [ - {name: 'StagingDeployCash'}, - ], + labels: [{name: 'StagingDeployCash'}], number: '1234', }, }, @@ -123,13 +118,12 @@ describe('test workflow finishReleaseCycle', () => { null, false, ); - const result = await act - .runEvent('issues', { - workflowFile: path.join(repoPath, '.github', 'workflows', 'finishReleaseCycle.yml'), - mockSteps: testMockSteps, - actor: 'Dummy Author', - logFile: utils.getLogFilePath('finishReleaseCycle', expect.getState().currentTestName), - }); + const result = await act.runEvent('issues', { + workflowFile: path.join(repoPath, '.github', 'workflows', 'finishReleaseCycle.yml'), + mockSteps: testMockSteps, + actor: 'Dummy Author', + logFile: utils.getLogFilePath('finishReleaseCycle', expect.getState().currentTestName), + }); assertions.assertValidateJobExecuted(result, 'Dummy Author', '1234'); assertions.assertUpdateProductionJobExecuted(result); assertions.assertCreateNewPatchVersionJobExecuted(result); @@ -149,9 +143,7 @@ describe('test workflow finishReleaseCycle', () => { action: 'closed', type: 'closed', issue: { - labels: [ - {name: 'StagingDeployCash'}, - ], + labels: [{name: 'StagingDeployCash'}], number: '1234', }, }, @@ -167,13 +159,12 @@ describe('test workflow finishReleaseCycle', () => { createNewPatchVersion: mocks.FINISHRELEASECYCLE__CREATENEWPATCHVERSION__STEP_MOCKS, createNewStagingDeployCash: mocks.FINISHRELEASECYCLE__CREATENEWSTAGINGDEPLOYCASH__STEP_MOCKS, }; - const result = await act - .runEvent('issues', { - workflowFile: path.join(repoPath, '.github', 'workflows', 'finishReleaseCycle.yml'), - mockSteps: testMockSteps, - actor: 'Dummy Author', - logFile: utils.getLogFilePath('finishReleaseCycle', expect.getState().currentTestName), - }); + const result = await act.runEvent('issues', { + workflowFile: path.join(repoPath, '.github', 'workflows', 'finishReleaseCycle.yml'), + mockSteps: testMockSteps, + actor: 'Dummy Author', + logFile: utils.getLogFilePath('finishReleaseCycle', expect.getState().currentTestName), + }); assertions.assertValidateJobExecuted(result, 'Dummy Author', '1234', true, true, true); assertions.assertUpdateProductionJobExecuted(result, false); assertions.assertCreateNewPatchVersionJobExecuted(result, false); @@ -193,9 +184,7 @@ describe('test workflow finishReleaseCycle', () => { action: 'closed', type: 'closed', issue: { - labels: [ - {name: 'StagingDeployCash'}, - ], + labels: [{name: 'StagingDeployCash'}], number: '1234', }, }, @@ -211,13 +200,12 @@ describe('test workflow finishReleaseCycle', () => { createNewPatchVersion: mocks.FINISHRELEASECYCLE__CREATENEWPATCHVERSION__STEP_MOCKS, createNewStagingDeployCash: mocks.FINISHRELEASECYCLE__CREATENEWSTAGINGDEPLOYCASH__STEP_MOCKS, }; - const result = await act - .runEvent('issues', { - workflowFile: path.join(repoPath, '.github', 'workflows', 'finishReleaseCycle.yml'), - mockSteps: testMockSteps, - actor: 'Dummy Author', - logFile: utils.getLogFilePath('finishReleaseCycle', expect.getState().currentTestName), - }); + const result = await act.runEvent('issues', { + workflowFile: path.join(repoPath, '.github', 'workflows', 'finishReleaseCycle.yml'), + mockSteps: testMockSteps, + actor: 'Dummy Author', + logFile: utils.getLogFilePath('finishReleaseCycle', expect.getState().currentTestName), + }); assertions.assertValidateJobExecuted(result, 'Dummy Author', '1234', true, false, false); assertions.assertUpdateProductionJobExecuted(result, false); assertions.assertCreateNewPatchVersionJobExecuted(result, false); @@ -237,11 +225,7 @@ describe('test workflow finishReleaseCycle', () => { action: 'closed', type: 'closed', issue: { - labels: [ - {name: 'Some'}, - {name: 'Other'}, - {name: 'Labels'}, - ], + labels: [{name: 'Some'}, {name: 'Other'}, {name: 'Labels'}], number: '1234', }, }, @@ -257,13 +241,12 @@ describe('test workflow finishReleaseCycle', () => { createNewPatchVersion: mocks.FINISHRELEASECYCLE__CREATENEWPATCHVERSION__STEP_MOCKS, createNewStagingDeployCash: mocks.FINISHRELEASECYCLE__CREATENEWSTAGINGDEPLOYCASH__STEP_MOCKS, }; - const result = await act - .runEvent('issues', { - workflowFile: path.join(repoPath, '.github', 'workflows', 'finishReleaseCycle.yml'), - mockSteps: testMockSteps, - actor: 'Dummy Author', - logFile: utils.getLogFilePath('finishReleaseCycle', expect.getState().currentTestName), - }); + const result = await act.runEvent('issues', { + workflowFile: path.join(repoPath, '.github', 'workflows', 'finishReleaseCycle.yml'), + mockSteps: testMockSteps, + actor: 'Dummy Author', + logFile: utils.getLogFilePath('finishReleaseCycle', expect.getState().currentTestName), + }); assertions.assertValidateJobExecuted(result, 'Dummy Author', '1234', false); assertions.assertUpdateProductionJobExecuted(result, false); assertions.assertCreateNewPatchVersionJobExecuted(result, false); diff --git a/workflow_tests/lint.test.js b/workflow_tests/lint.test.js index 16de3ace83ef..878b081f14e4 100644 --- a/workflow_tests/lint.test.js +++ b/workflow_tests/lint.test.js @@ -50,23 +50,16 @@ describe('test workflow lint', () => { const repoPath = mockGithub.repo.getPath('testLintWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'lint.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); - act = utils.setUpActParams( - act, - event, - eventOptions, - {}, - githubToken, - ); + act = utils.setUpActParams(act, event, eventOptions, {}, githubToken); const testMockSteps = { lint: mocks.LINT__LINT__STEP_MOCKS, }; - const result = await act - .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'lint.yml'), - mockSteps: testMockSteps, - actor, - logFile: utils.getLogFilePath('lint', expect.getState().currentTestName), - }); + const result = await act.runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows', 'lint.yml'), + mockSteps: testMockSteps, + actor, + logFile: utils.getLogFilePath('lint', expect.getState().currentTestName), + }); assertions.assertLintJobExecuted(result); }); @@ -76,23 +69,16 @@ describe('test workflow lint', () => { const repoPath = mockGithub.repo.getPath('testLintWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'lint.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); - act = utils.setUpActParams( - act, - event, - eventOptions, - {}, - githubToken, - ); + act = utils.setUpActParams(act, event, eventOptions, {}, githubToken); const testMockSteps = { lint: mocks.LINT__LINT__STEP_MOCKS, }; - const result = await act - .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'lint.yml'), - mockSteps: testMockSteps, - actor: testActor, - logFile: utils.getLogFilePath('lint', expect.getState().currentTestName), - }); + const result = await act.runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows', 'lint.yml'), + mockSteps: testMockSteps, + actor: testActor, + logFile: utils.getLogFilePath('lint', expect.getState().currentTestName), + }); assertions.assertLintJobExecuted(result); }); @@ -108,23 +94,16 @@ describe('test workflow lint', () => { const repoPath = mockGithub.repo.getPath('testLintWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'lint.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); - act = utils.setUpActParams( - act, - event, - eventOptions, - {}, - githubToken, - ); + act = utils.setUpActParams(act, event, eventOptions, {}, githubToken); const testMockSteps = { lint: mocks.LINT__LINT__STEP_MOCKS, }; - const result = await act - .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'lint.yml'), - mockSteps: testMockSteps, - actor, - logFile: utils.getLogFilePath('lint', expect.getState().currentTestName), - }); + const result = await act.runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows', 'lint.yml'), + mockSteps: testMockSteps, + actor, + logFile: utils.getLogFilePath('lint', expect.getState().currentTestName), + }); assertions.assertLintJobExecuted(result); }); @@ -134,23 +113,16 @@ describe('test workflow lint', () => { const repoPath = mockGithub.repo.getPath('testLintWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'lint.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); - act = utils.setUpActParams( - act, - event, - eventOptions, - {}, - githubToken, - ); + act = utils.setUpActParams(act, event, eventOptions, {}, githubToken); const testMockSteps = { lint: mocks.LINT__LINT__STEP_MOCKS, }; - const result = await act - .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'lint.yml'), - mockSteps: testMockSteps, - actor: testActor, - logFile: utils.getLogFilePath('lint', expect.getState().currentTestName), - }); + const result = await act.runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows', 'lint.yml'), + mockSteps: testMockSteps, + actor: testActor, + logFile: utils.getLogFilePath('lint', expect.getState().currentTestName), + }); assertions.assertLintJobExecuted(result, false); }); @@ -164,23 +136,16 @@ describe('test workflow lint', () => { const repoPath = mockGithub.repo.getPath('testLintWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'lint.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); - act = utils.setUpActParams( - act, - event, - eventOptions, - {}, - githubToken, - ); + act = utils.setUpActParams(act, event, eventOptions, {}, githubToken); const testMockSteps = { lint: mocks.LINT__LINT__STEP_MOCKS, }; - const result = await act - .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'lint.yml'), - mockSteps: testMockSteps, - actor, - logFile: utils.getLogFilePath('lint', expect.getState().currentTestName), - }); + const result = await act.runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows', 'lint.yml'), + mockSteps: testMockSteps, + actor, + logFile: utils.getLogFilePath('lint', expect.getState().currentTestName), + }); assertions.assertLintJobExecuted(result); }); diff --git a/workflow_tests/lockDeploys.test.js b/workflow_tests/lockDeploys.test.js index 81850395e79a..8af555242987 100644 --- a/workflow_tests/lockDeploys.test.js +++ b/workflow_tests/lockDeploys.test.js @@ -56,9 +56,7 @@ describe('test workflow lockDeploys', () => { name: '🔐 LockCashDeploys 🔐', }, issue: { - labels: [ - {name: 'StagingDeployCash'}, - ], + labels: [{name: 'StagingDeployCash'}], }, }, { @@ -76,13 +74,12 @@ describe('test workflow lockDeploys', () => { const testMockSteps = { lockStagingDeploys: mocks.LOCKDEPLOYS__LOCKSTAGINGDEPLOYS__STEP_MOCKS, }; - const result = await act - .runEvent('issues', { - workflowFile: path.join(repoPath, '.github', 'workflows', 'lockDeploys.yml'), - mockSteps: testMockSteps, - actor: 'Dummy Author', - logFile: utils.getLogFilePath('lockDeploys', expect.getState().currentTestName), - }); + const result = await act.runEvent('issues', { + workflowFile: path.join(repoPath, '.github', 'workflows', 'lockDeploys.yml'), + mockSteps: testMockSteps, + actor: 'Dummy Author', + logFile: utils.getLogFilePath('lockDeploys', expect.getState().currentTestName), + }); assertions.assertlockStagingDeploysJobExecuted(result); }); @@ -101,9 +98,7 @@ describe('test workflow lockDeploys', () => { name: '🔐 LockCashDeploys 🔐', }, issue: { - labels: [ - {name: 'StagingDeployCash'}, - ], + labels: [{name: 'StagingDeployCash'}], }, }, { @@ -131,13 +126,12 @@ describe('test workflow lockDeploys', () => { null, false, ); - const result = await act - .runEvent('issues', { - workflowFile: path.join(repoPath, '.github', 'workflows', 'lockDeploys.yml'), - mockSteps: testMockSteps, - actor: 'Dummy Author', - logFile: utils.getLogFilePath('lockDeploys', expect.getState().currentTestName), - }); + const result = await act.runEvent('issues', { + workflowFile: path.join(repoPath, '.github', 'workflows', 'lockDeploys.yml'), + mockSteps: testMockSteps, + actor: 'Dummy Author', + logFile: utils.getLogFilePath('lockDeploys', expect.getState().currentTestName), + }); assertions.assertlockStagingDeploysJobFailedAfterFirstStep(result); }); @@ -158,9 +152,7 @@ describe('test workflow lockDeploys', () => { name: '🔐 LockCashDeploys 🔐', }, issue: { - labels: [ - {name: 'StagingDeployCash'}, - ], + labels: [{name: 'StagingDeployCash'}], }, }, { @@ -178,13 +170,12 @@ describe('test workflow lockDeploys', () => { const testMockSteps = { lockStagingDeploys: mocks.LOCKDEPLOYS__LOCKSTAGINGDEPLOYS__STEP_MOCKS, }; - const result = await act - .runEvent('issues', { - workflowFile: path.join(repoPath, '.github', 'workflows', 'lockDeploys.yml'), - mockSteps: testMockSteps, - actor: 'OSBotify', - logFile: utils.getLogFilePath('lockDeploys', expect.getState().currentTestName), - }); + const result = await act.runEvent('issues', { + workflowFile: path.join(repoPath, '.github', 'workflows', 'lockDeploys.yml'), + mockSteps: testMockSteps, + actor: 'OSBotify', + logFile: utils.getLogFilePath('lockDeploys', expect.getState().currentTestName), + }); assertions.assertlockStagingDeploysJobExecuted(result, false); }); @@ -207,11 +198,7 @@ describe('test workflow lockDeploys', () => { name: '🔐 LockCashDeploys 🔐', }, issue: { - labels: [ - {name: 'Some'}, - {name: 'Other'}, - {name: 'Labels'}, - ], + labels: [{name: 'Some'}, {name: 'Other'}, {name: 'Labels'}], }, }, { @@ -229,13 +216,12 @@ describe('test workflow lockDeploys', () => { const testMockSteps = { lockStagingDeploys: mocks.LOCKDEPLOYS__LOCKSTAGINGDEPLOYS__STEP_MOCKS, }; - const result = await act - .runEvent('issues', { - workflowFile: path.join(repoPath, '.github', 'workflows', 'lockDeploys.yml'), - mockSteps: testMockSteps, - actor: 'Dummy Author', - logFile: utils.getLogFilePath('lockDeploys', expect.getState().currentTestName), - }); + const result = await act.runEvent('issues', { + workflowFile: path.join(repoPath, '.github', 'workflows', 'lockDeploys.yml'), + mockSteps: testMockSteps, + actor: 'Dummy Author', + logFile: utils.getLogFilePath('lockDeploys', expect.getState().currentTestName), + }); assertions.assertlockStagingDeploysJobExecuted(result, false); }); @@ -256,11 +242,7 @@ describe('test workflow lockDeploys', () => { name: '🔐 LockCashDeploys 🔐', }, issue: { - labels: [ - {name: 'Some'}, - {name: 'Other'}, - {name: 'Labels'}, - ], + labels: [{name: 'Some'}, {name: 'Other'}, {name: 'Labels'}], }, }, { @@ -278,13 +260,12 @@ describe('test workflow lockDeploys', () => { const testMockSteps = { lockStagingDeploys: mocks.LOCKDEPLOYS__LOCKSTAGINGDEPLOYS__STEP_MOCKS, }; - const result = await act - .runEvent('issues', { - workflowFile: path.join(repoPath, '.github', 'workflows', 'lockDeploys.yml'), - mockSteps: testMockSteps, - actor: 'OSBotify', - logFile: utils.getLogFilePath('lockDeploys', expect.getState().currentTestName), - }); + const result = await act.runEvent('issues', { + workflowFile: path.join(repoPath, '.github', 'workflows', 'lockDeploys.yml'), + mockSteps: testMockSteps, + actor: 'OSBotify', + logFile: utils.getLogFilePath('lockDeploys', expect.getState().currentTestName), + }); assertions.assertlockStagingDeploysJobExecuted(result, false); }); @@ -309,9 +290,7 @@ describe('test workflow lockDeploys', () => { name: 'Some different label', }, issue: { - labels: [ - {name: 'StagingDeployCash'}, - ], + labels: [{name: 'StagingDeployCash'}], }, }, { @@ -329,13 +308,12 @@ describe('test workflow lockDeploys', () => { const testMockSteps = { lockStagingDeploys: mocks.LOCKDEPLOYS__LOCKSTAGINGDEPLOYS__STEP_MOCKS, }; - const result = await act - .runEvent('issues', { - workflowFile: path.join(repoPath, '.github', 'workflows', 'lockDeploys.yml'), - mockSteps: testMockSteps, - actor: 'Dummy Author', - logFile: utils.getLogFilePath('lockDeploys', expect.getState().currentTestName), - }); + const result = await act.runEvent('issues', { + workflowFile: path.join(repoPath, '.github', 'workflows', 'lockDeploys.yml'), + mockSteps: testMockSteps, + actor: 'Dummy Author', + logFile: utils.getLogFilePath('lockDeploys', expect.getState().currentTestName), + }); assertions.assertlockStagingDeploysJobExecuted(result, false); }); @@ -356,9 +334,7 @@ describe('test workflow lockDeploys', () => { name: 'Some different label', }, issue: { - labels: [ - {name: 'StagingDeployCash'}, - ], + labels: [{name: 'StagingDeployCash'}], }, }, { @@ -376,13 +352,12 @@ describe('test workflow lockDeploys', () => { const testMockSteps = { lockStagingDeploys: mocks.LOCKDEPLOYS__LOCKSTAGINGDEPLOYS__STEP_MOCKS, }; - const result = await act - .runEvent('issues', { - workflowFile: path.join(repoPath, '.github', 'workflows', 'lockDeploys.yml'), - mockSteps: testMockSteps, - actor: 'OSBotify', - logFile: utils.getLogFilePath('lockDeploys', expect.getState().currentTestName), - }); + const result = await act.runEvent('issues', { + workflowFile: path.join(repoPath, '.github', 'workflows', 'lockDeploys.yml'), + mockSteps: testMockSteps, + actor: 'OSBotify', + logFile: utils.getLogFilePath('lockDeploys', expect.getState().currentTestName), + }); assertions.assertlockStagingDeploysJobExecuted(result, false); }); @@ -405,11 +380,7 @@ describe('test workflow lockDeploys', () => { name: 'Some other label', }, issue: { - labels: [ - {name: 'Some'}, - {name: 'Other'}, - {name: 'Labels'}, - ], + labels: [{name: 'Some'}, {name: 'Other'}, {name: 'Labels'}], }, }, { @@ -427,13 +398,12 @@ describe('test workflow lockDeploys', () => { const testMockSteps = { lockStagingDeploys: mocks.LOCKDEPLOYS__LOCKSTAGINGDEPLOYS__STEP_MOCKS, }; - const result = await act - .runEvent('issues', { - workflowFile: path.join(repoPath, '.github', 'workflows', 'lockDeploys.yml'), - mockSteps: testMockSteps, - actor: 'Dummy Author', - logFile: utils.getLogFilePath('lockDeploys', expect.getState().currentTestName), - }); + const result = await act.runEvent('issues', { + workflowFile: path.join(repoPath, '.github', 'workflows', 'lockDeploys.yml'), + mockSteps: testMockSteps, + actor: 'Dummy Author', + logFile: utils.getLogFilePath('lockDeploys', expect.getState().currentTestName), + }); assertions.assertlockStagingDeploysJobExecuted(result, false); }); @@ -454,11 +424,7 @@ describe('test workflow lockDeploys', () => { name: 'Some other label', }, issue: { - labels: [ - {name: 'Some'}, - {name: 'Other'}, - {name: 'Labels'}, - ], + labels: [{name: 'Some'}, {name: 'Other'}, {name: 'Labels'}], }, }, { @@ -476,13 +442,12 @@ describe('test workflow lockDeploys', () => { const testMockSteps = { lockStagingDeploys: mocks.LOCKDEPLOYS__LOCKSTAGINGDEPLOYS__STEP_MOCKS, }; - const result = await act - .runEvent('issues', { - workflowFile: path.join(repoPath, '.github', 'workflows', 'lockDeploys.yml'), - mockSteps: testMockSteps, - actor: 'OSBotify', - logFile: utils.getLogFilePath('lockDeploys', expect.getState().currentTestName), - }); + const result = await act.runEvent('issues', { + workflowFile: path.join(repoPath, '.github', 'workflows', 'lockDeploys.yml'), + mockSteps: testMockSteps, + actor: 'OSBotify', + logFile: utils.getLogFilePath('lockDeploys', expect.getState().currentTestName), + }); assertions.assertlockStagingDeploysJobExecuted(result, false); }); diff --git a/workflow_tests/mocks/authorChecklistMocks.js b/workflow_tests/mocks/authorChecklistMocks.js index 4c6ae43045ff..db211f5ec1e6 100644 --- a/workflow_tests/mocks/authorChecklistMocks.js +++ b/workflow_tests/mocks/authorChecklistMocks.js @@ -1,16 +1,8 @@ const utils = require('../utils/utils'); // checklist -const AUTHORCHECKLIST__CHECKLIST__AUTHORCHECKLIST_JS__STEP_MOCK = utils.createMockStep( - 'authorChecklist.js', - 'Running authorChecklist.js', - 'CHECKLIST', - ['GITHUB_TOKEN'], - [], -); -const AUTHORCHECKLIST__CHECKLIST__STEP_MOCKS = [ - AUTHORCHECKLIST__CHECKLIST__AUTHORCHECKLIST_JS__STEP_MOCK, -]; +const AUTHORCHECKLIST__CHECKLIST__AUTHORCHECKLIST_JS__STEP_MOCK = utils.createMockStep('authorChecklist.js', 'Running authorChecklist.js', 'CHECKLIST', ['GITHUB_TOKEN'], []); +const AUTHORCHECKLIST__CHECKLIST__STEP_MOCKS = [AUTHORCHECKLIST__CHECKLIST__AUTHORCHECKLIST_JS__STEP_MOCK]; module.exports = { AUTHORCHECKLIST__CHECKLIST__STEP_MOCKS, diff --git a/workflow_tests/mocks/cherryPickMocks.js b/workflow_tests/mocks/cherryPickMocks.js index c2c5db950f0f..91cfb0e6b544 100644 --- a/workflow_tests/mocks/cherryPickMocks.js +++ b/workflow_tests/mocks/cherryPickMocks.js @@ -17,41 +17,16 @@ const CHERRYPICK__VALIDATEACTOR__CHECK_IF_USER_IS_DEPLOYER_FALSE__STEP_MOCK = ut [], {isTeamMember: false}, ); -const CHERRYPICK__VALIDATEACTOR__TRUE__STEP_MOCKS = [ - CHERRYPICK__VALIDATEACTOR__CHECK_IF_USER_IS_DEPLOYER_TRUE__STEP_MOCK, -]; -const CHERRYPICK__VALIDATEACTOR__FALSE__STEP_MOCKS = [ - CHERRYPICK__VALIDATEACTOR__CHECK_IF_USER_IS_DEPLOYER_FALSE__STEP_MOCK, -]; +const CHERRYPICK__VALIDATEACTOR__TRUE__STEP_MOCKS = [CHERRYPICK__VALIDATEACTOR__CHECK_IF_USER_IS_DEPLOYER_TRUE__STEP_MOCK]; +const CHERRYPICK__VALIDATEACTOR__FALSE__STEP_MOCKS = [CHERRYPICK__VALIDATEACTOR__CHECK_IF_USER_IS_DEPLOYER_FALSE__STEP_MOCK]; // createnewversion -const CHERRYPICK__CREATENEWVERSION__CREATE_NEW_VERSION__STEP_MOCK = utils.createMockStep( - 'Create new version', - 'Creating new version', - 'CREATENEWVERSION', - [], - [], - {NEW_VERSION: '1.2.3'}, -); -const CHERRYPICK__CREATENEWVERSION__STEP_MOCKS = [ - CHERRYPICK__CREATENEWVERSION__CREATE_NEW_VERSION__STEP_MOCK, -]; +const CHERRYPICK__CREATENEWVERSION__CREATE_NEW_VERSION__STEP_MOCK = utils.createMockStep('Create new version', 'Creating new version', 'CREATENEWVERSION', [], [], {NEW_VERSION: '1.2.3'}); +const CHERRYPICK__CREATENEWVERSION__STEP_MOCKS = [CHERRYPICK__CREATENEWVERSION__CREATE_NEW_VERSION__STEP_MOCK]; // cherrypick -const CHERRYPICK__CHERRYPICK__CHECKOUT_STAGING_BRANCH__STEP_MOCK = utils.createMockStep( - 'Checkout staging branch', - 'Checking out staging branch', - 'CHERRYPICK', - ['ref', 'token'], - [], -); -const CHERRYPICK__CHERRYPICK__SET_UP_GIT_FOR_OSBOTIFY__STEP_MOCK = utils.createMockStep( - 'Set up git for OSBotify', - 'Setting up git for OSBotify', - 'CHERRYPICK', - ['GPG_PASSPHRASE'], - [], -); +const CHERRYPICK__CHERRYPICK__CHECKOUT_STAGING_BRANCH__STEP_MOCK = utils.createMockStep('Checkout staging branch', 'Checking out staging branch', 'CHERRYPICK', ['ref', 'token'], []); +const CHERRYPICK__CHERRYPICK__SET_UP_GIT_FOR_OSBOTIFY__STEP_MOCK = utils.createMockStep('Set up git for OSBotify', 'Setting up git for OSBotify', 'CHERRYPICK', ['GPG_PASSPHRASE'], []); const CHERRYPICK__CHERRYPICK__CREATE_BRANCH_FOR_NEW_PULL_REQUEST__STEP_MOCK = utils.createMockStep( 'Create branch for new pull request', 'Creating branch for new pull request', @@ -99,21 +74,8 @@ const CHERRYPICK__CHERRYPICK__CHERRY_PICK_THE_MERGE_COMMIT_OF_TARGET_PR_TO_NEW_B [], {SHOULD_AUTOMERGE: false}, ); -const CHERRYPICK__CHERRYPICK__PUSH_CHANGES_TO_CP_BRANCH__STEP_MOCK = utils.createMockStep( - 'Push changes to CP branch', - 'Pushing changes to CP branch', - 'CHERRYPICK', - [], - [], -); -const CHERRYPICK__CHERRYPICK__CREATE_PULL_REQUEST__STEP_MOCK = utils.createMockStep( - 'Create Pull Request', - 'Creating Pull Request', - 'CHERRYPICK', - [], - ['GITHUB_TOKEN'], - {PR_NUMBER: '1234'}, -); +const CHERRYPICK__CHERRYPICK__PUSH_CHANGES_TO_CP_BRANCH__STEP_MOCK = utils.createMockStep('Push changes to CP branch', 'Pushing changes to CP branch', 'CHERRYPICK', [], []); +const CHERRYPICK__CHERRYPICK__CREATE_PULL_REQUEST__STEP_MOCK = utils.createMockStep('Create Pull Request', 'Creating Pull Request', 'CHERRYPICK', [], ['GITHUB_TOKEN'], {PR_NUMBER: '1234'}); const CHERRYPICK__CHERRYPICK__CHECK_IF_SHORTVERSIONSTRING_IS_UP_TO_DATE_TRUE__STEP_MOCK = utils.createMockStep( 'Check if ShortVersionString is up to date', 'Checking if ShortVersionString is up to date', @@ -158,13 +120,7 @@ const CHERRYPICK__CHERRYPICK__IF_PR_HAS_A_BUNDLE_VERSION_MISMATCH_COMMENT_WITH_T [], ['GITHUB_TOKEN'], ); -const CHERRYPICK__CHERRYPICK__AUTO_APPROVE_THE_PR__STEP_MOCK = utils.createMockStep( - 'Auto-approve the PR', - 'Auto-approving the PR', - 'CHERRYPICK', - [], - ['GITHUB_TOKEN'], -); +const CHERRYPICK__CHERRYPICK__AUTO_APPROVE_THE_PR__STEP_MOCK = utils.createMockStep('Auto-approve the PR', 'Auto-approving the PR', 'CHERRYPICK', [], ['GITHUB_TOKEN']); const CHERRYPICK__CHERRYPICK__CHECK_IF_PULL_REQUEST_IS_MERGEABLE_TRUE__STEP_MOCK = utils.createMockStep( 'Check if pull request is mergeable', 'Checking if pull request is mergeable', @@ -181,13 +137,7 @@ const CHERRYPICK__CHERRYPICK__CHECK_IF_PULL_REQUEST_IS_MERGEABLE_FALSE__STEP_MOC [], {IS_MERGEABLE: false}, ); -const CHERRYPICK__CHERRYPICK__AUTO_MERGE_THE_PR__STEP_MOCK = utils.createMockStep( - 'Auto-merge the PR', - 'Auto-merging the PR', - 'CHERRYPICK', - [], - ['GITHUB_TOKEN'], -); +const CHERRYPICK__CHERRYPICK__AUTO_MERGE_THE_PR__STEP_MOCK = utils.createMockStep('Auto-merge the PR', 'Auto-merging the PR', 'CHERRYPICK', [], ['GITHUB_TOKEN']); const CHERRYPICK__CHERRYPICK__ANNOUNCES_A_CP_FAILURE_IN_THE_ANNOUNCE_SLACK_ROOM__STEP_MOCK = utils.createMockStep( 'Announces a CP failure in the #announce Slack room', 'Announcing a CP failure', @@ -208,17 +158,13 @@ const getCherryPickMockSteps = (upToDate, isMergeable, shouldMerge) => [ : CHERRYPICK__CHERRYPICK__CHERRY_PICK_THE_MERGE_COMMIT_OF_TARGET_PR_TO_NEW_BRANCH__SHOULD_NOT_MERGE__STEP_MOCK, CHERRYPICK__CHERRYPICK__PUSH_CHANGES_TO_CP_BRANCH__STEP_MOCK, CHERRYPICK__CHERRYPICK__CREATE_PULL_REQUEST__STEP_MOCK, - upToDate - ? CHERRYPICK__CHERRYPICK__CHECK_IF_SHORTVERSIONSTRING_IS_UP_TO_DATE_TRUE__STEP_MOCK - : CHERRYPICK__CHERRYPICK__CHECK_IF_SHORTVERSIONSTRING_IS_UP_TO_DATE_FALSE__STEP_MOCK, + upToDate ? CHERRYPICK__CHERRYPICK__CHECK_IF_SHORTVERSIONSTRING_IS_UP_TO_DATE_TRUE__STEP_MOCK : CHERRYPICK__CHERRYPICK__CHECK_IF_SHORTVERSIONSTRING_IS_UP_TO_DATE_FALSE__STEP_MOCK, CHERRYPICK__CHERRYPICK__AUTO_ASSIGN_PR_IF_THERE_ARE_MERGE_CONFLICTS_OR_IF_THE_BUNDLE_VERSIONS_ARE_MISMATCHED__STEP_MOCK, CHERRYPICK__CHERRYPICK__ASSIGN_THE_PR_TO_THE_DEPLOYER__STEP_MOCK, CHERRYPICK__CHERRYPICK__IF_PR_HAS_MERGE_CONFLICTS_COMMENT_WITH_INSTRUCTIONS_FOR_ASSIGNEE__STEP_MOCK, CHERRYPICK__CHERRYPICK__IF_PR_HAS_A_BUNDLE_VERSION_MISMATCH_COMMENT_WITH_THE_INSTRUCTIONS_FOR_ASSIGNEE__STEP_MOCK, CHERRYPICK__CHERRYPICK__AUTO_APPROVE_THE_PR__STEP_MOCK, - isMergeable - ? CHERRYPICK__CHERRYPICK__CHECK_IF_PULL_REQUEST_IS_MERGEABLE_TRUE__STEP_MOCK - : CHERRYPICK__CHERRYPICK__CHECK_IF_PULL_REQUEST_IS_MERGEABLE_FALSE__STEP_MOCK, + isMergeable ? CHERRYPICK__CHERRYPICK__CHECK_IF_PULL_REQUEST_IS_MERGEABLE_TRUE__STEP_MOCK : CHERRYPICK__CHERRYPICK__CHECK_IF_PULL_REQUEST_IS_MERGEABLE_FALSE__STEP_MOCK, CHERRYPICK__CHERRYPICK__AUTO_MERGE_THE_PR__STEP_MOCK, CHERRYPICK__CHERRYPICK__ANNOUNCES_A_CP_FAILURE_IN_THE_ANNOUNCE_SLACK_ROOM__STEP_MOCK, ]; diff --git a/workflow_tests/mocks/claMocks.js b/workflow_tests/mocks/claMocks.js index 115085526c49..d0a6793b93e6 100644 --- a/workflow_tests/mocks/claMocks.js +++ b/workflow_tests/mocks/claMocks.js @@ -1,38 +1,12 @@ const utils = require('../utils/utils'); // cla -const CLA__CLA__CLA_COMMENT_CHECK__NO_MATCH__STEP_MOCK = utils.createMockStep( - 'CLA comment check', - 'CLA comment check', - 'CLA', - ['text', 'regex'], - [], - {match: ''}, -); -const CLA__CLA__CLA_COMMENT_CHECK__MATCH__STEP_MOCK = utils.createMockStep( - 'CLA comment check', - 'CLA comment check', - 'CLA', - ['text', 'regex'], - [], - {match: 'I have read the CLA Document and I hereby sign the CLA'}, -); -const CLA__CLA__CLA_COMMENT_RE_CHECK__NO_MATCH__STEP_MOCK = utils.createMockStep( - 'CLA comment re-check', - 'CLA comment re-check', - 'CLA', - ['text', 'regex'], - [], - {match: ''}, -); -const CLA__CLA__CLA_COMMENT_RE_CHECK__MATCH__STEP_MOCK = utils.createMockStep( - 'CLA comment re-check', - 'CLA comment re-check', - 'CLA', - ['text', 'regex'], - [], - {match: 'recheck'}, -); +const CLA__CLA__CLA_COMMENT_CHECK__NO_MATCH__STEP_MOCK = utils.createMockStep('CLA comment check', 'CLA comment check', 'CLA', ['text', 'regex'], [], {match: ''}); +const CLA__CLA__CLA_COMMENT_CHECK__MATCH__STEP_MOCK = utils.createMockStep('CLA comment check', 'CLA comment check', 'CLA', ['text', 'regex'], [], { + match: 'I have read the CLA Document and I hereby sign the CLA', +}); +const CLA__CLA__CLA_COMMENT_RE_CHECK__NO_MATCH__STEP_MOCK = utils.createMockStep('CLA comment re-check', 'CLA comment re-check', 'CLA', ['text', 'regex'], [], {match: ''}); +const CLA__CLA__CLA_COMMENT_RE_CHECK__MATCH__STEP_MOCK = utils.createMockStep('CLA comment re-check', 'CLA comment re-check', 'CLA', ['text', 'regex'], [], {match: 'recheck'}); const CLA__CLA__CLA_ASSISTANT__STEP_MOCK = utils.createMockStep( 'CLA Assistant', 'CLA Assistant', @@ -40,21 +14,9 @@ const CLA__CLA__CLA_ASSISTANT__STEP_MOCK = utils.createMockStep( ['path-to-signatures', 'path-to-document', 'branch', 'remote-organization-name', 'remote-repository-name', 'lock-pullrequest-aftermerge', 'allowlist'], ['GITHUB_TOKEN', 'PERSONAL_ACCESS_TOKEN'], ); -const CLA__CLA__NO_MATCHES__STEP_MOCKS = [ - CLA__CLA__CLA_COMMENT_CHECK__NO_MATCH__STEP_MOCK, - CLA__CLA__CLA_COMMENT_RE_CHECK__NO_MATCH__STEP_MOCK, - CLA__CLA__CLA_ASSISTANT__STEP_MOCK, -]; -const CLA__CLA__CHECK_MATCH__STEP_MOCKS = [ - CLA__CLA__CLA_COMMENT_CHECK__MATCH__STEP_MOCK, - CLA__CLA__CLA_COMMENT_RE_CHECK__NO_MATCH__STEP_MOCK, - CLA__CLA__CLA_ASSISTANT__STEP_MOCK, -]; -const CLA__CLA__RECHECK_MATCH__STEP_MOCKS = [ - CLA__CLA__CLA_COMMENT_CHECK__NO_MATCH__STEP_MOCK, - CLA__CLA__CLA_COMMENT_RE_CHECK__MATCH__STEP_MOCK, - CLA__CLA__CLA_ASSISTANT__STEP_MOCK, -]; +const CLA__CLA__NO_MATCHES__STEP_MOCKS = [CLA__CLA__CLA_COMMENT_CHECK__NO_MATCH__STEP_MOCK, CLA__CLA__CLA_COMMENT_RE_CHECK__NO_MATCH__STEP_MOCK, CLA__CLA__CLA_ASSISTANT__STEP_MOCK]; +const CLA__CLA__CHECK_MATCH__STEP_MOCKS = [CLA__CLA__CLA_COMMENT_CHECK__MATCH__STEP_MOCK, CLA__CLA__CLA_COMMENT_RE_CHECK__NO_MATCH__STEP_MOCK, CLA__CLA__CLA_ASSISTANT__STEP_MOCK]; +const CLA__CLA__RECHECK_MATCH__STEP_MOCKS = [CLA__CLA__CLA_COMMENT_CHECK__NO_MATCH__STEP_MOCK, CLA__CLA__CLA_COMMENT_RE_CHECK__MATCH__STEP_MOCK, CLA__CLA__CLA_ASSISTANT__STEP_MOCK]; module.exports = { CLA__CLA__NO_MATCHES__STEP_MOCKS, diff --git a/workflow_tests/mocks/createNewVersionMocks.js b/workflow_tests/mocks/createNewVersionMocks.js index e0c7703b0434..cd0db0b52c0d 100644 --- a/workflow_tests/mocks/createNewVersionMocks.js +++ b/workflow_tests/mocks/createNewVersionMocks.js @@ -1,48 +1,21 @@ const utils = require('../utils/utils'); // validateactor -const CREATENEWVERSION__VALIDATEACTOR__GET_USER_PERMISSIONS__ADMIN__STEP_MOCK = utils.createMockStep( - 'Get user permissions', - 'Get user permissions', - 'VALIDATEACTOR', - [], - ['GITHUB_TOKEN'], - {PERMISSION: 'admin'}, -); -const CREATENEWVERSION__VALIDATEACTOR__GET_USER_PERMISSIONS__WRITE__STEP_MOCK = utils.createMockStep( - 'Get user permissions', - 'Get user permissions', - 'VALIDATEACTOR', - [], - ['GITHUB_TOKEN'], - {PERMISSION: 'write'}, -); -const CREATENEWVERSION__VALIDATEACTOR__GET_USER_PERMISSIONS__NONE__STEP_MOCK = utils.createMockStep( - 'Get user permissions', - 'Get user permissions', - 'VALIDATEACTOR', - [], - ['GITHUB_TOKEN'], - {PERMISSION: 'read'}, -); -const CREATENEWVERSION__VALIDATEACTOR__ADMIN__STEP_MOCKS = [ - CREATENEWVERSION__VALIDATEACTOR__GET_USER_PERMISSIONS__ADMIN__STEP_MOCK, -]; -const CREATENEWVERSION__VALIDATEACTOR__WRITER__STEP_MOCKS = [ - CREATENEWVERSION__VALIDATEACTOR__GET_USER_PERMISSIONS__WRITE__STEP_MOCK, -]; -const CREATENEWVERSION__VALIDATEACTOR__NO_PERMISSION__STEP_MOCKS = [ - CREATENEWVERSION__VALIDATEACTOR__GET_USER_PERMISSIONS__NONE__STEP_MOCK, -]; +const CREATENEWVERSION__VALIDATEACTOR__GET_USER_PERMISSIONS__ADMIN__STEP_MOCK = utils.createMockStep('Get user permissions', 'Get user permissions', 'VALIDATEACTOR', [], ['GITHUB_TOKEN'], { + PERMISSION: 'admin', +}); +const CREATENEWVERSION__VALIDATEACTOR__GET_USER_PERMISSIONS__WRITE__STEP_MOCK = utils.createMockStep('Get user permissions', 'Get user permissions', 'VALIDATEACTOR', [], ['GITHUB_TOKEN'], { + PERMISSION: 'write', +}); +const CREATENEWVERSION__VALIDATEACTOR__GET_USER_PERMISSIONS__NONE__STEP_MOCK = utils.createMockStep('Get user permissions', 'Get user permissions', 'VALIDATEACTOR', [], ['GITHUB_TOKEN'], { + PERMISSION: 'read', +}); +const CREATENEWVERSION__VALIDATEACTOR__ADMIN__STEP_MOCKS = [CREATENEWVERSION__VALIDATEACTOR__GET_USER_PERMISSIONS__ADMIN__STEP_MOCK]; +const CREATENEWVERSION__VALIDATEACTOR__WRITER__STEP_MOCKS = [CREATENEWVERSION__VALIDATEACTOR__GET_USER_PERMISSIONS__WRITE__STEP_MOCK]; +const CREATENEWVERSION__VALIDATEACTOR__NO_PERMISSION__STEP_MOCKS = [CREATENEWVERSION__VALIDATEACTOR__GET_USER_PERMISSIONS__NONE__STEP_MOCK]; // createnewversion -const CREATENEWVERSION__CREATENEWVERSION__CHECK_OUT__STEP_MOCK = utils.createMockStep( - 'Check out', - 'Check out', - 'CREATENEWVERSION', - ['fetch-depth'], - [], -); +const CREATENEWVERSION__CREATENEWVERSION__CHECK_OUT__STEP_MOCK = utils.createMockStep('Check out', 'Check out', 'CREATENEWVERSION', ['fetch-depth'], []); const CREATENEWVERSION__CREATENEWVERSION__SETUP_GIT_FOR_OSBOTIFY__STEP_MOCK = utils.createMockStep( 'Setup git for OSBotify', 'Setup git for OSBotify', @@ -50,13 +23,7 @@ const CREATENEWVERSION__CREATENEWVERSION__SETUP_GIT_FOR_OSBOTIFY__STEP_MOCK = ut ['GPG_PASSPHRASE'], [], ); -const CREATENEWVERSION__CREATENEWVERSION__RUN_TURNSTYLE__STEP_MOCK = utils.createMockStep( - 'Run turnstyle', - 'Run turnstyle', - 'CREATENEWVERSION', - ['poll-interval-seconds'], - ['GITHUB_TOKEN'], -); +const CREATENEWVERSION__CREATENEWVERSION__RUN_TURNSTYLE__STEP_MOCK = utils.createMockStep('Run turnstyle', 'Run turnstyle', 'CREATENEWVERSION', ['poll-interval-seconds'], ['GITHUB_TOKEN']); const CREATENEWVERSION__CREATENEWVERSION__CREATE_NEW_BRANCH__STEP_MOCK = utils.createMockStep( 'Create new branch', 'Create new branch', @@ -74,13 +41,7 @@ const CREATENEWVERSION__CREATENEWVERSION__GENERATE_VERSION__STEP_MOCK = utils.cr ['GITHUB_TOKEN', 'SEMVER_LEVEL'], [], ); -const CREATENEWVERSION__CREATENEWVERSION__COMMIT_NEW_VERSION__STEP_MOCK = utils.createMockStep( - 'Commit new version', - 'Commit new version', - 'CREATENEWVERSION', - [], - [], -); +const CREATENEWVERSION__CREATENEWVERSION__COMMIT_NEW_VERSION__STEP_MOCK = utils.createMockStep('Commit new version', 'Commit new version', 'CREATENEWVERSION', [], []); const CREATENEWVERSION__CREATENEWVERSION__UPDATE_MAIN_BRANCH__STEP_MOCK = utils.createMockStep( 'Update main branch', 'Update main branch', diff --git a/workflow_tests/mocks/deployBlockerMocks.js b/workflow_tests/mocks/deployBlockerMocks.js index e124eae5f173..820e441a00dc 100644 --- a/workflow_tests/mocks/deployBlockerMocks.js +++ b/workflow_tests/mocks/deployBlockerMocks.js @@ -1,13 +1,7 @@ const utils = require('../utils/utils'); // deployblocker -const DEPLOYBLOCKER__DEPLOYBLOCKER__CHECKOUT__STEP_MOCK = utils.createMockStep( - 'Checkout', - 'Checkout', - 'DEPLOYBLOCKER', - ['fetch-depth', 'token'], - [], -); +const DEPLOYBLOCKER__DEPLOYBLOCKER__CHECKOUT__STEP_MOCK = utils.createMockStep('Checkout', 'Checkout', 'DEPLOYBLOCKER', ['fetch-depth', 'token'], []); const DEPLOYBLOCKER__DEPLOYBLOCKER__GET_URL_TITLE_AND_NUMBER_OF_NEW_DEPLOY_BLOCKER_ISSUE__STEP_MOCK = utils.createMockStep( 'Get URL, title, & number of new deploy blocker (issue)', 'Get URL, title and number of new deploy blocker - issue', diff --git a/workflow_tests/mocks/deployMocks.js b/workflow_tests/mocks/deployMocks.js index de6e73c3d268..f4284215437d 100644 --- a/workflow_tests/mocks/deployMocks.js +++ b/workflow_tests/mocks/deployMocks.js @@ -1,21 +1,7 @@ const utils = require('../utils/utils'); -const VALIDATE__GET_MERGED_PR__STEP_MOCK = utils.createMockStep( - 'Get merged pull request', - 'Getting merged PR', - 'VALIDATE', - ['github_token'], - [], - {author: 'Dummy Author'}, -); -const VALIDATE__GET_MERGED_PR__OSBOTIFY__STEP_MOCK = utils.createMockStep( - 'Get merged pull request', - 'Getting merged PR', - 'VALIDATE', - ['github_token'], - [], - {author: 'OSBotify'}, -); +const VALIDATE__GET_MERGED_PR__STEP_MOCK = utils.createMockStep('Get merged pull request', 'Getting merged PR', 'VALIDATE', ['github_token'], [], {author: 'Dummy Author'}); +const VALIDATE__GET_MERGED_PR__OSBOTIFY__STEP_MOCK = utils.createMockStep('Get merged pull request', 'Getting merged PR', 'VALIDATE', ['github_token'], [], {author: 'OSBotify'}); const VALIDATE_STEP_MOCKS = [ VALIDATE__GET_MERGED_PR__STEP_MOCK, @@ -28,61 +14,18 @@ const VALIDATE__OSBOTIFY__STEP_MOCKS = [ // 2nd step normal ]; -const DEPLOY_STAGING__CHECKOUT__STEP_MOCK = utils.createMockStep( - 'Checkout staging branch', - 'Checking out staging branch', - 'DEPLOY_STAGING', - ['ref', 'token'], -); -const DEPLOY_STAGING__SETUP_GIT__STEP_MOCK = utils.createMockStep( - 'Setup git for OSBotify', - 'Setting up git for OSBotify', - 'DEPLOY_STAGING', - ['GPG_PASSPHRASE'], -); -const DEPLOY_STAGING__TAG_VERSION__STEP_MOCK = utils.createMockStep( - 'Tag version', - 'Tagging new version', - 'DEPLOY_STAGING', -); -const DEPLOY_STAGING__PUSH_TAG__STEP_MOCK = utils.createMockStep( - '🚀 Push tags to trigger staging deploy 🚀', - 'Pushing tag to trigger staging deploy', - 'DEPLOY_STAGING', -); -const DEPLOY_STAGING_STEP_MOCKS = [ - DEPLOY_STAGING__CHECKOUT__STEP_MOCK, - DEPLOY_STAGING__SETUP_GIT__STEP_MOCK, - DEPLOY_STAGING__TAG_VERSION__STEP_MOCK, - DEPLOY_STAGING__PUSH_TAG__STEP_MOCK, -]; +const DEPLOY_STAGING__CHECKOUT__STEP_MOCK = utils.createMockStep('Checkout staging branch', 'Checking out staging branch', 'DEPLOY_STAGING', ['ref', 'token']); +const DEPLOY_STAGING__SETUP_GIT__STEP_MOCK = utils.createMockStep('Setup git for OSBotify', 'Setting up git for OSBotify', 'DEPLOY_STAGING', ['GPG_PASSPHRASE']); +const DEPLOY_STAGING__TAG_VERSION__STEP_MOCK = utils.createMockStep('Tag version', 'Tagging new version', 'DEPLOY_STAGING'); +const DEPLOY_STAGING__PUSH_TAG__STEP_MOCK = utils.createMockStep('🚀 Push tags to trigger staging deploy 🚀', 'Pushing tag to trigger staging deploy', 'DEPLOY_STAGING'); +const DEPLOY_STAGING_STEP_MOCKS = [DEPLOY_STAGING__CHECKOUT__STEP_MOCK, DEPLOY_STAGING__SETUP_GIT__STEP_MOCK, DEPLOY_STAGING__TAG_VERSION__STEP_MOCK, DEPLOY_STAGING__PUSH_TAG__STEP_MOCK]; -const DEPLOY_PRODUCTION__CHECKOUT__STEP_MOCK = utils.createMockStep( - 'Checkout', - 'Checking out', - 'DEPLOY_PRODUCTION', - ['fetch-depth', 'token'], -); -const DEPLOY_PRODUCTION__SETUP_GIT__STEP_MOCK = utils.createMockStep( - 'Setup git for OSBotify', - 'Setting up git for OSBotify', - 'DEPLOY_PRODUCTION', - ['GPG_PASSPHRASE'], -); -const DEPLOY_PRODUCTION__CHECKOUT_PRODUCTION__STEP_MOCK = utils.createMockStep( - 'Checkout production branch', - 'Checking out production branch', - 'DEPLOY_PRODUCTION', -); -const DEPLOY_PRODUCTION__CURRENT_APP_VERSION__STEP_MOCK = utils.createMockStep( - 'Get current app version', - 'Getting current app version', - 'DEPLOY_PRODUCTION', - null, - null, - null, - {PRODUCTION_VERSION: '1.2.3'}, -); +const DEPLOY_PRODUCTION__CHECKOUT__STEP_MOCK = utils.createMockStep('Checkout', 'Checking out', 'DEPLOY_PRODUCTION', ['fetch-depth', 'token']); +const DEPLOY_PRODUCTION__SETUP_GIT__STEP_MOCK = utils.createMockStep('Setup git for OSBotify', 'Setting up git for OSBotify', 'DEPLOY_PRODUCTION', ['GPG_PASSPHRASE']); +const DEPLOY_PRODUCTION__CHECKOUT_PRODUCTION__STEP_MOCK = utils.createMockStep('Checkout production branch', 'Checking out production branch', 'DEPLOY_PRODUCTION'); +const DEPLOY_PRODUCTION__CURRENT_APP_VERSION__STEP_MOCK = utils.createMockStep('Get current app version', 'Getting current app version', 'DEPLOY_PRODUCTION', null, null, null, { + PRODUCTION_VERSION: '1.2.3', +}); const DEPLOY_PRODUCTION__RELEASE_PR_LIST__STEP_MOCK = utils.createMockStep( 'Get Release Pull Request List', 'Getting release PR list', @@ -91,14 +34,9 @@ const DEPLOY_PRODUCTION__RELEASE_PR_LIST__STEP_MOCK = utils.createMockStep( null, {PR_LIST: '["1.2.1", "1.2.2"]'}, ); -const DEPLOY_PRODUCTION__GENERATE_RELEASE_BODY__STEP_MOCK = utils.createMockStep( - 'Generate Release Body', - 'Generating release body', - 'DEPLOY_PRODUCTION', - ['PR_LIST'], - null, - {RELEASE_BODY: 'Release body'}, -); +const DEPLOY_PRODUCTION__GENERATE_RELEASE_BODY__STEP_MOCK = utils.createMockStep('Generate Release Body', 'Generating release body', 'DEPLOY_PRODUCTION', ['PR_LIST'], null, { + RELEASE_BODY: 'Release body', +}); const DEPLOY_PRODUCTION__CREATE_RELEASE__STEP_MOCK = utils.createMockStep( '🚀 Create release to trigger production deploy 🚀', 'Creating release to trigger production deploy', diff --git a/workflow_tests/mocks/finishReleaseCycleMocks.js b/workflow_tests/mocks/finishReleaseCycleMocks.js index 54eb66fa539c..695a5ba731c6 100644 --- a/workflow_tests/mocks/finishReleaseCycleMocks.js +++ b/workflow_tests/mocks/finishReleaseCycleMocks.js @@ -83,9 +83,7 @@ const FINISHRELEASECYCLE__UPDATEPRODUCTION__UPDATE_PRODUCTION_BRANCH__STEP_MOCK ['TARGET_BRANCH', 'OS_BOTIFY_TOKEN', 'GPG_PASSPHRASE'], [], ); -const FINISHRELEASECYCLE__UPDATEPRODUCTION__STEP_MOCKS = [ - FINISHRELEASECYCLE__UPDATEPRODUCTION__UPDATE_PRODUCTION_BRANCH__STEP_MOCK, -]; +const FINISHRELEASECYCLE__UPDATEPRODUCTION__STEP_MOCKS = [FINISHRELEASECYCLE__UPDATEPRODUCTION__UPDATE_PRODUCTION_BRANCH__STEP_MOCK]; // createnewpatchversion const FINISHRELEASECYCLE__CREATENEWPATCHVERSION__CREATE_NEW_VERSION__STEP_MOCK = utils.createMockStep( @@ -96,9 +94,7 @@ const FINISHRELEASECYCLE__CREATENEWPATCHVERSION__CREATE_NEW_VERSION__STEP_MOCK = [], {NEW_VERSION: '1.2.3'}, ); -const FINISHRELEASECYCLE__CREATENEWPATCHVERSION__STEP_MOCKS = [ - FINISHRELEASECYCLE__CREATENEWPATCHVERSION__CREATE_NEW_VERSION__STEP_MOCK, -]; +const FINISHRELEASECYCLE__CREATENEWPATCHVERSION__STEP_MOCKS = [FINISHRELEASECYCLE__CREATENEWPATCHVERSION__CREATE_NEW_VERSION__STEP_MOCK]; // createnewstagingdeploycash const FINISHRELEASECYCLE__CREATENEWSTAGINGDEPLOYCASH__UPDATE_STAGING_BRANCH_TO_TRIGGER_STAGING_DEPLOY__STEP_MOCK = utils.createMockStep( @@ -108,13 +104,7 @@ const FINISHRELEASECYCLE__CREATENEWSTAGINGDEPLOYCASH__UPDATE_STAGING_BRANCH_TO_T ['TARGET_BRANCH', 'OS_BOTIFY_TOKEN', 'GPG_PASSPHRASE'], [], ); -const FINISHRELEASECYCLE__CREATENEWSTAGINGDEPLOYCASH__TAG_VERSION__STEP_MOCK = utils.createMockStep( - 'Tag version', - 'Tagging version', - 'CREATENEWSTAGINGDEPLOYCASH', - [], - [], -); +const FINISHRELEASECYCLE__CREATENEWSTAGINGDEPLOYCASH__TAG_VERSION__STEP_MOCK = utils.createMockStep('Tag version', 'Tagging version', 'CREATENEWSTAGINGDEPLOYCASH', [], []); const FINISHRELEASECYCLE__CREATENEWSTAGINGDEPLOYCASH__CREATE_NEW_STAGINGDEPLOYCASH__STEP_MOCK = utils.createMockStep( 'Create new StagingDeployCash', 'Creating new StagingDeployCash', diff --git a/workflow_tests/mocks/lintMocks.js b/workflow_tests/mocks/lintMocks.js index 2349c3ef4f03..169503ea8f3d 100644 --- a/workflow_tests/mocks/lintMocks.js +++ b/workflow_tests/mocks/lintMocks.js @@ -1,34 +1,10 @@ const utils = require('../utils/utils'); // lint -const LINT__LINT__CHECKOUT__STEP_MOCK = utils.createMockStep( - 'Checkout', - 'Checkout', - 'LINT', - [], - [], -); -const LINT__LINT__SETUP_NODE__STEP_MOCK = utils.createMockStep( - 'Setup Node', - 'Setup Node', - 'LINT', - [], - [], -); -const LINT__LINT__LINT_JAVASCRIPT_WITH_ESLINT__STEP_MOCK = utils.createMockStep( - 'Lint JavaScript with ESLint', - 'Lint JavaScript with ESLint', - 'LINT', - [], - ['CI'], -); -const LINT__LINT__LINT_SHELL_SCRIPTS_WITH_SHELLCHECK__STEP_MOCK = utils.createMockStep( - 'Lint shell scripts with ShellCheck', - 'Lint shell scripts with ShellCheck', - 'LINT', - [], - [], -); +const LINT__LINT__CHECKOUT__STEP_MOCK = utils.createMockStep('Checkout', 'Checkout', 'LINT', [], []); +const LINT__LINT__SETUP_NODE__STEP_MOCK = utils.createMockStep('Setup Node', 'Setup Node', 'LINT', [], []); +const LINT__LINT__LINT_JAVASCRIPT_WITH_ESLINT__STEP_MOCK = utils.createMockStep('Lint JavaScript with ESLint', 'Lint JavaScript with ESLint', 'LINT', [], ['CI']); +const LINT__LINT__LINT_SHELL_SCRIPTS_WITH_SHELLCHECK__STEP_MOCK = utils.createMockStep('Lint shell scripts with ShellCheck', 'Lint shell scripts with ShellCheck', 'LINT', [], []); const LINT__LINT__STEP_MOCKS = [ LINT__LINT__CHECKOUT__STEP_MOCK, LINT__LINT__SETUP_NODE__STEP_MOCK, diff --git a/workflow_tests/mocks/lockDeploysMocks.js b/workflow_tests/mocks/lockDeploysMocks.js index 09d44e92a21a..0dd5c11f58ed 100644 --- a/workflow_tests/mocks/lockDeploysMocks.js +++ b/workflow_tests/mocks/lockDeploysMocks.js @@ -1,13 +1,7 @@ const utils = require('../utils/utils'); // lockstagingdeploys -const LOCKDEPLOYS__LOCKSTAGINGDEPLOYS__CHECKOUT__STEP_MOCK = utils.createMockStep( - 'Checkout', - 'Checking out', - 'LOCKSTAGINGDEPLOYS', - ['ref', 'fetch-depth', 'token'], - [], -); +const LOCKDEPLOYS__LOCKSTAGINGDEPLOYS__CHECKOUT__STEP_MOCK = utils.createMockStep('Checkout', 'Checking out', 'LOCKSTAGINGDEPLOYS', ['ref', 'fetch-depth', 'token'], []); const LOCKDEPLOYS__LOCKSTAGINGDEPLOYS__WAIT_FOR_STAGING_DEPLOYS_TO_FINISH__STEP_MOCK = utils.createMockStep( 'Wait for staging deploys to finish', 'Waiting for staging deploys to finish', diff --git a/workflow_tests/mocks/platformDeployMocks.js b/workflow_tests/mocks/platformDeployMocks.js index 15b2c9b24f53..c062fd0ad2a4 100644 --- a/workflow_tests/mocks/platformDeployMocks.js +++ b/workflow_tests/mocks/platformDeployMocks.js @@ -17,74 +17,22 @@ const PLATFORM_DEPLOY__VALIDATE_ACTOR__CHECK_USER_DEPLOYER__OUTSIDER__STEP_MOCK null, {isTeamMember: false}, ); -const PLATFORM_DEPLOY__VALIDATE_ACTOR__TEAM_MEMBER__STEP_MOCKS = [ - PLATFORM_DEPLOY__VALIDATE_ACTOR__CHECK_USER_DEPLOYER__TEAM_MEMBER__STEP_MOCK, -]; -const PLATFORM_DEPLOY__VALIDATE_ACTOR__OUTSIDER__STEP_MOCKS = [ - PLATFORM_DEPLOY__VALIDATE_ACTOR__CHECK_USER_DEPLOYER__OUTSIDER__STEP_MOCK, -]; +const PLATFORM_DEPLOY__VALIDATE_ACTOR__TEAM_MEMBER__STEP_MOCKS = [PLATFORM_DEPLOY__VALIDATE_ACTOR__CHECK_USER_DEPLOYER__TEAM_MEMBER__STEP_MOCK]; +const PLATFORM_DEPLOY__VALIDATE_ACTOR__OUTSIDER__STEP_MOCKS = [PLATFORM_DEPLOY__VALIDATE_ACTOR__CHECK_USER_DEPLOYER__OUTSIDER__STEP_MOCK]; // android -const PLATFORM_DEPLOY__ANDROID__CHECKOUT__STEP_MOCK = utils.createMockStep( - 'Checkout', - 'Checking out', - 'ANDROID', - ['fetch-depth'], -); -const PLATFORM_DEPLOY__ANDROID__SETUP_NODE__STEP_MOCK = utils.createMockStep( - 'Setup Node', - 'Setting up Node', - 'ANDROID', -); -const PLATFORM_DEPLOY__ANDROID__SETUP_RUBY__STEP_MOCK = utils.createMockStep( - 'Setup Ruby', - 'Setting up Ruby', - 'ANDROID', - ['ruby-version', 'bundler-cache'], -); -const PLATFORM_DEPLOY__ANDROID__DECRYPT_KEYSTORE__STEP_MOCK = utils.createMockStep( - 'Decrypt keystore', - 'Decrypting keystore', - 'ANDROID', - null, - ['LARGE_SECRET_PASSPHRASE'], -); -const PLATFORM_DEPLOY__ANDROID__DECRYPT_JSON_KEY__STEP_MOCK = utils.createMockStep( - 'Decrypt json key', - 'Decrypting JSON key', - 'ANDROID', - null, - ['LARGE_SECRET_PASSPHRASE'], -); -const PLATFORM_DEPLOY__ANDROID__SET_VERSION__STEP_MOCK = utils.createMockStep( - 'Set version in ENV', - 'Setting version in ENV', - 'ANDROID', - null, - null, - null, - {VERSION_CODE: '1.2.3'}, -); -const PLATFORM_DEPLOY__ANDROID__FASTLANE_BETA__STEP_MOCK = utils.createMockStep( - 'Run Fastlane beta', - 'Running Fastlane beta', - 'ANDROID', - null, - ['MYAPP_UPLOAD_STORE_PASSWORD', 'MYAPP_UPLOAD_KEY_PASSWORD'], -); -const PLATFORM_DEPLOY__ANDROID__FASTLANE_PRODUCTION__STEP_MOCK = utils.createMockStep( - 'Run Fastlane production', - 'Running Fastlane production', - 'ANDROID', - null, - ['VERSION'], -); -const PLATFORM_DEPLOY__ANDROID__ARCHIVE_SOURCEMAPS__STEP_MOCK = utils.createMockStep( - 'Archive Android sourcemaps', - 'Archiving Android sourcemaps', - 'ANDROID', - ['name', 'path'], -); +const PLATFORM_DEPLOY__ANDROID__CHECKOUT__STEP_MOCK = utils.createMockStep('Checkout', 'Checking out', 'ANDROID', ['fetch-depth']); +const PLATFORM_DEPLOY__ANDROID__SETUP_NODE__STEP_MOCK = utils.createMockStep('Setup Node', 'Setting up Node', 'ANDROID'); +const PLATFORM_DEPLOY__ANDROID__SETUP_RUBY__STEP_MOCK = utils.createMockStep('Setup Ruby', 'Setting up Ruby', 'ANDROID', ['ruby-version', 'bundler-cache']); +const PLATFORM_DEPLOY__ANDROID__DECRYPT_KEYSTORE__STEP_MOCK = utils.createMockStep('Decrypt keystore', 'Decrypting keystore', 'ANDROID', null, ['LARGE_SECRET_PASSPHRASE']); +const PLATFORM_DEPLOY__ANDROID__DECRYPT_JSON_KEY__STEP_MOCK = utils.createMockStep('Decrypt json key', 'Decrypting JSON key', 'ANDROID', null, ['LARGE_SECRET_PASSPHRASE']); +const PLATFORM_DEPLOY__ANDROID__SET_VERSION__STEP_MOCK = utils.createMockStep('Set version in ENV', 'Setting version in ENV', 'ANDROID', null, null, null, {VERSION_CODE: '1.2.3'}); +const PLATFORM_DEPLOY__ANDROID__FASTLANE_BETA__STEP_MOCK = utils.createMockStep('Run Fastlane beta', 'Running Fastlane beta', 'ANDROID', null, [ + 'MYAPP_UPLOAD_STORE_PASSWORD', + 'MYAPP_UPLOAD_KEY_PASSWORD', +]); +const PLATFORM_DEPLOY__ANDROID__FASTLANE_PRODUCTION__STEP_MOCK = utils.createMockStep('Run Fastlane production', 'Running Fastlane production', 'ANDROID', null, ['VERSION']); +const PLATFORM_DEPLOY__ANDROID__ARCHIVE_SOURCEMAPS__STEP_MOCK = utils.createMockStep('Archive Android sourcemaps', 'Archiving Android sourcemaps', 'ANDROID', ['name', 'path']); const PLATFORM_DEPLOY__ANDROID__UPLOAD_TO_BROWSER_STACK__STEP_MOCK = utils.createMockStep( 'Upload Android version to Browser Stack', 'Uploading Android version to Browser Stack', @@ -114,38 +62,27 @@ const PLATFORM_DEPLOY__ANDROID__STEP_MOCKS = [ ]; // desktop -const PLATFORM_DEPLOY__DESKTOP__CHECKOUT__STEP_MOCK = utils.createMockStep( - 'Checkout', - 'Checking out', - 'DESKTOP', - ['fetch-depth'], -); -const PLATFORM_DEPLOY__DESKTOP__SETUP_NODE__STEP_MOCK = utils.createMockStep( - 'Setup Node', - 'Setting up Node', - 'DESKTOP', -); -const PLATFORM_DEPLOY__DESKTOP__DECRYPT_ID__STEP_MOCK = utils.createMockStep( - 'Decrypt Developer ID Certificate', - 'Decrypting developer id certificate', - 'DESKTOP', - null, - ['DEVELOPER_ID_SECRET_PASSPHRASE'], -); -const PLATFORM_DEPLOY__DESKTOP__BUILD_PRODUCTION__STEP_MOCK = utils.createMockStep( - 'Build production desktop app', - 'Building production desktop app', - 'DESKTOP', - null, - ['CSC_LINK', 'CSC_KEY_PASSWORD', 'APPLE_ID', 'APPLE_ID_PASSWORD', 'AWS_ACCESS_KEY_ID', 'AWS_SECRET_ACCESS_KEY'], -); -const PLATFORM_DEPLOY__DESKTOP__BUILD_STAGING__STEP_MOCK = utils.createMockStep( - 'Build staging desktop app', - 'Building staging desktop app', - 'DESKTOP', - null, - ['CSC_LINK', 'CSC_KEY_PASSWORD', 'APPLE_ID', 'APPLE_ID_PASSWORD', 'AWS_ACCESS_KEY_ID', 'AWS_SECRET_ACCESS_KEY'], -); +const PLATFORM_DEPLOY__DESKTOP__CHECKOUT__STEP_MOCK = utils.createMockStep('Checkout', 'Checking out', 'DESKTOP', ['fetch-depth']); +const PLATFORM_DEPLOY__DESKTOP__SETUP_NODE__STEP_MOCK = utils.createMockStep('Setup Node', 'Setting up Node', 'DESKTOP'); +const PLATFORM_DEPLOY__DESKTOP__DECRYPT_ID__STEP_MOCK = utils.createMockStep('Decrypt Developer ID Certificate', 'Decrypting developer id certificate', 'DESKTOP', null, [ + 'DEVELOPER_ID_SECRET_PASSPHRASE', +]); +const PLATFORM_DEPLOY__DESKTOP__BUILD_PRODUCTION__STEP_MOCK = utils.createMockStep('Build production desktop app', 'Building production desktop app', 'DESKTOP', null, [ + 'CSC_LINK', + 'CSC_KEY_PASSWORD', + 'APPLE_ID', + 'APPLE_ID_PASSWORD', + 'AWS_ACCESS_KEY_ID', + 'AWS_SECRET_ACCESS_KEY', +]); +const PLATFORM_DEPLOY__DESKTOP__BUILD_STAGING__STEP_MOCK = utils.createMockStep('Build staging desktop app', 'Building staging desktop app', 'DESKTOP', null, [ + 'CSC_LINK', + 'CSC_KEY_PASSWORD', + 'APPLE_ID', + 'APPLE_ID_PASSWORD', + 'AWS_ACCESS_KEY_ID', + 'AWS_SECRET_ACCESS_KEY', +]); const PLATFORM_DEPLOY__DESKTOP__STEP_MOCKS = [ PLATFORM_DEPLOY__DESKTOP__CHECKOUT__STEP_MOCK, PLATFORM_DEPLOY__DESKTOP__SETUP_NODE__STEP_MOCK, @@ -155,92 +92,26 @@ const PLATFORM_DEPLOY__DESKTOP__STEP_MOCKS = [ ]; // ios -const PLATFORM_DEPLOY__IOS__CHECKOUT__STEP_MOCK = utils.createMockStep( - 'Checkout', - 'Checking out', - 'IOS', - ['fetch-depth'], -); -const PLATFORM_DEPLOY__IOS__SETUP_NODE__STEP_MOCK = utils.createMockStep( - 'Setup Node', - 'Setting up Node', - 'IOS', -); -const PLATFORM_DEPLOY__IOS__SETUP_RUBY__STEP_MOCK = utils.createMockStep( - 'Setup Ruby', - 'Setting up Ruby', - 'IOS', - ['ruby-version', 'bundler-cache'], -); -const PLATFORM_DEPLOY__IOS__CACHE__STEP_MOCK = utils.createMockStep( - 'Cache', - 'Caching', - 'IOS', - ['path', 'key', 'restore-keys'], -); -const PLATFORM_DEPLOY__IOS__COCOAPODS__STEP_MOCK = utils.createMockStep( - 'Install cocoapods', - 'Installing cocoapods', - 'IOS', - ['timeout_minutes', 'max_attempts', 'command'], -); -const PLATFORM_DEPLOY__IOS__DECRYPT_PROFILE__STEP_MOCK = utils.createMockStep( - 'Decrypt profile', - 'Decrypting profile', - 'IOS', - null, - ['LARGE_SECRET_PASSPHRASE'], -); -const PLATFORM_DEPLOY__IOS__DECRYPT_CERTIFICATE__STEP_MOCK = utils.createMockStep( - 'Decrypt certificate', - 'Decrypting certificate', - 'IOS', - null, - ['LARGE_SECRET_PASSPHRASE'], -); -const PLATFORM_DEPLOY__IOS__DECRYPT_APP_STORE_API_KEY__STEP_MOCK = utils.createMockStep( - 'Decrypt App Store Connect API key', - 'Decrypting App Store API key', - 'IOS', - null, - ['LARGE_SECRET_PASSPHRASE'], -); -const PLATFORM_DEPLOY__IOS__FASTLANE__STEP_MOCK = utils.createMockStep( - 'Run Fastlane', - 'Running Fastlane', - 'IOS', - null, - ['APPLE_CONTACT_EMAIL', 'APPLE_CONTACT_PHONE', 'APPLE_DEMO_EMAIL', 'APPLE_DEMO_PASSWORD'], -); -const PLATFORM_DEPLOY__IOS__ARCHIVE_SOURCEMAPS__STEP_MOCK = utils.createMockStep( - 'Archive iOS sourcemaps', - 'Archiving sourcemaps', - 'IOS', - ['name', 'path'], -); -const PLATFORM_DEPLOY__IOS__UPLOAD_BROWSERSTACK__STEP_MOCK = utils.createMockStep( - 'Upload iOS version to Browser Stack', - 'Uploading version to Browser Stack', - 'IOS', - null, - ['BROWSERSTACK'], -); -const PLATFORM_DEPLOY__IOS__SET_VERSION__STEP_MOCK = utils.createMockStep( - 'Set iOS version in ENV', - 'Setting iOS version', - 'IOS', - null, - null, - null, - {IOS_VERSION: '1.2.3'}, -); -const PLATFORM_DEPLOY__IOS__RELEASE_FASTLANE__STEP_MOCK = utils.createMockStep( - 'Run Fastlane for App Store release', - 'Running Fastlane for release', - 'IOS', - null, - ['VERSION'], -); +const PLATFORM_DEPLOY__IOS__CHECKOUT__STEP_MOCK = utils.createMockStep('Checkout', 'Checking out', 'IOS', ['fetch-depth']); +const PLATFORM_DEPLOY__IOS__SETUP_NODE__STEP_MOCK = utils.createMockStep('Setup Node', 'Setting up Node', 'IOS'); +const PLATFORM_DEPLOY__IOS__SETUP_RUBY__STEP_MOCK = utils.createMockStep('Setup Ruby', 'Setting up Ruby', 'IOS', ['ruby-version', 'bundler-cache']); +const PLATFORM_DEPLOY__IOS__CACHE__STEP_MOCK = utils.createMockStep('Cache', 'Caching', 'IOS', ['path', 'key', 'restore-keys']); +const PLATFORM_DEPLOY__IOS__COCOAPODS__STEP_MOCK = utils.createMockStep('Install cocoapods', 'Installing cocoapods', 'IOS', ['timeout_minutes', 'max_attempts', 'command']); +const PLATFORM_DEPLOY__IOS__DECRYPT_PROFILE__STEP_MOCK = utils.createMockStep('Decrypt profile', 'Decrypting profile', 'IOS', null, ['LARGE_SECRET_PASSPHRASE']); +const PLATFORM_DEPLOY__IOS__DECRYPT_CERTIFICATE__STEP_MOCK = utils.createMockStep('Decrypt certificate', 'Decrypting certificate', 'IOS', null, ['LARGE_SECRET_PASSPHRASE']); +const PLATFORM_DEPLOY__IOS__DECRYPT_APP_STORE_API_KEY__STEP_MOCK = utils.createMockStep('Decrypt App Store Connect API key', 'Decrypting App Store API key', 'IOS', null, [ + 'LARGE_SECRET_PASSPHRASE', +]); +const PLATFORM_DEPLOY__IOS__FASTLANE__STEP_MOCK = utils.createMockStep('Run Fastlane', 'Running Fastlane', 'IOS', null, [ + 'APPLE_CONTACT_EMAIL', + 'APPLE_CONTACT_PHONE', + 'APPLE_DEMO_EMAIL', + 'APPLE_DEMO_PASSWORD', +]); +const PLATFORM_DEPLOY__IOS__ARCHIVE_SOURCEMAPS__STEP_MOCK = utils.createMockStep('Archive iOS sourcemaps', 'Archiving sourcemaps', 'IOS', ['name', 'path']); +const PLATFORM_DEPLOY__IOS__UPLOAD_BROWSERSTACK__STEP_MOCK = utils.createMockStep('Upload iOS version to Browser Stack', 'Uploading version to Browser Stack', 'IOS', null, ['BROWSERSTACK']); +const PLATFORM_DEPLOY__IOS__SET_VERSION__STEP_MOCK = utils.createMockStep('Set iOS version in ENV', 'Setting iOS version', 'IOS', null, null, null, {IOS_VERSION: '1.2.3'}); +const PLATFORM_DEPLOY__IOS__RELEASE_FASTLANE__STEP_MOCK = utils.createMockStep('Run Fastlane for App Store release', 'Running Fastlane for release', 'IOS', null, ['VERSION']); const PLATFORM_DEPLOY__IOS__WARN_FAIL__STEP_MOCK = utils.createMockStep( 'Warn deployers if iOS production deploy failed', 'Warning developers of failed deploy', @@ -266,67 +137,20 @@ const PLATFORM_DEPLOY__IOS__STEP_MOCKS = [ ]; // web -const PLATFORM_DEPLOY__WEB__CHECKOUT__STEP_MOCK = utils.createMockStep( - 'Checkout', - 'Checking out', - 'WEB', - ['fetch-depth'], -); -const PLATFORM_DEPLOY__WEB__SETUP_NODE__STEP_MOCK = utils.createMockStep( - 'Setup Node', - 'Setting up Node', - 'WEB', -); -const PLATFORM_DEPLOY__WEB__CLOUDFLARE__STEP_MOCK = utils.createMockStep( - 'Setup Cloudflare CLI', - 'Setting up Cloudflare CLI', - 'WEB', -); -const PLATFORM_DEPLOY__WEB__AWS_CREDENTIALS__STEP_MOCK = utils.createMockStep( - 'Configure AWS Credentials', - 'Configuring AWS credentials', - 'WEB', - ['AWS_ACCESS_KEY_ID', 'AWS_SECRET_ACCESS_KEY'], -); -const PLATFORM_DEPLOY__WEB__BUILD_PRODUCTION__STEP_MOCK = utils.createMockStep( - 'Build web for production', - 'Building web for production', - 'WEB', -); -const PLATFORM_DEPLOY__WEB__BUILD_STAGING__STEP_MOCK = utils.createMockStep( - 'Build web for staging', - 'Building web for staging', - 'WEB', -); -const PLATFORM_DEPLOY__WEB__BUILD_DOCS__STEP_MOCK = utils.createMockStep( - 'Build docs', - 'Building docs', - 'WEB', -); -const PLATFORM_DEPLOY__WEB__DEPLOY_PRODUCTION_S3__STEP_MOCK = utils.createMockStep( - 'Deploy production to S3', - 'Deploying production to S3', - 'WEB', -); -const PLATFORM_DEPLOY__WEB__DEPLOY_STAGING_S3__STEP_MOCK = utils.createMockStep( - 'Deploy staging to S3', - 'Deploying staging to S3', - 'WEB', -); -const PLATFORM_DEPLOY__WEB__PURGE_PRODUCTION_CACHE__STEP_MOCK = utils.createMockStep( - 'Purge production Cloudflare cache', - 'Purging production Cloudflare cache', - 'WEB', - null, - ['CF_API_KEY'], -); -const PLATFORM_DEPLOY__WEB__PURGE_STAGING_CACHE__STEP_MOCK = utils.createMockStep( - 'Purge staging Cloudflare cache', - 'Purging staging Cloudflare cache', - 'WEB', - null, - ['CF_API_KEY'], -); +const PLATFORM_DEPLOY__WEB__CHECKOUT__STEP_MOCK = utils.createMockStep('Checkout', 'Checking out', 'WEB', ['fetch-depth']); +const PLATFORM_DEPLOY__WEB__SETUP_NODE__STEP_MOCK = utils.createMockStep('Setup Node', 'Setting up Node', 'WEB'); +const PLATFORM_DEPLOY__WEB__CLOUDFLARE__STEP_MOCK = utils.createMockStep('Setup Cloudflare CLI', 'Setting up Cloudflare CLI', 'WEB'); +const PLATFORM_DEPLOY__WEB__AWS_CREDENTIALS__STEP_MOCK = utils.createMockStep('Configure AWS Credentials', 'Configuring AWS credentials', 'WEB', [ + 'AWS_ACCESS_KEY_ID', + 'AWS_SECRET_ACCESS_KEY', +]); +const PLATFORM_DEPLOY__WEB__BUILD_PRODUCTION__STEP_MOCK = utils.createMockStep('Build web for production', 'Building web for production', 'WEB'); +const PLATFORM_DEPLOY__WEB__BUILD_STAGING__STEP_MOCK = utils.createMockStep('Build web for staging', 'Building web for staging', 'WEB'); +const PLATFORM_DEPLOY__WEB__BUILD_DOCS__STEP_MOCK = utils.createMockStep('Build docs', 'Building docs', 'WEB'); +const PLATFORM_DEPLOY__WEB__DEPLOY_PRODUCTION_S3__STEP_MOCK = utils.createMockStep('Deploy production to S3', 'Deploying production to S3', 'WEB'); +const PLATFORM_DEPLOY__WEB__DEPLOY_STAGING_S3__STEP_MOCK = utils.createMockStep('Deploy staging to S3', 'Deploying staging to S3', 'WEB'); +const PLATFORM_DEPLOY__WEB__PURGE_PRODUCTION_CACHE__STEP_MOCK = utils.createMockStep('Purge production Cloudflare cache', 'Purging production Cloudflare cache', 'WEB', null, ['CF_API_KEY']); +const PLATFORM_DEPLOY__WEB__PURGE_STAGING_CACHE__STEP_MOCK = utils.createMockStep('Purge staging Cloudflare cache', 'Purging staging Cloudflare cache', 'WEB', null, ['CF_API_KEY']); const PLATFORM_DEPLOY__WEB__STEP_MOCKS = [ PLATFORM_DEPLOY__WEB__CHECKOUT__STEP_MOCK, PLATFORM_DEPLOY__WEB__SETUP_NODE__STEP_MOCK, @@ -342,31 +166,14 @@ const PLATFORM_DEPLOY__WEB__STEP_MOCKS = [ ]; // post slack message on failure -const PLATFORM_DEPLOY__POST_SLACK_FAIL__POST_SLACK__STEP_MOCK = utils.createMockStep( - 'Post Slack message on failure', - 'Posting Slack message on platform deploy failure', - 'POST_SLACK_FAIL', - ['SLACK_WEBHOOK'], -); -const PLATFORM_DEPLOY__POST_SLACK_FAIL__STEP_MOCKS = [ - PLATFORM_DEPLOY__POST_SLACK_FAIL__POST_SLACK__STEP_MOCK, -]; +const PLATFORM_DEPLOY__POST_SLACK_FAIL__POST_SLACK__STEP_MOCK = utils.createMockStep('Post Slack message on failure', 'Posting Slack message on platform deploy failure', 'POST_SLACK_FAIL', [ + 'SLACK_WEBHOOK', +]); +const PLATFORM_DEPLOY__POST_SLACK_FAIL__STEP_MOCKS = [PLATFORM_DEPLOY__POST_SLACK_FAIL__POST_SLACK__STEP_MOCK]; // post slack message on success -const PLATFORM_DEPLOY__POST_SLACK_SUCCESS__CHECKOUT__STEP_MOCK = utils.createMockStep( - 'Checkout', - 'Checking out', - 'POST_SLACK_SUCCESS', -); -const PLATFORM_DEPLOY__POST_SLACK_SUCCESS__SET_VERSION__STEP_MOCK = utils.createMockStep( - 'Set version', - 'Setting version', - 'POST_SLACK_SUCCESS', - null, - null, - null, - {VERSION: '1.2.3'}, -); +const PLATFORM_DEPLOY__POST_SLACK_SUCCESS__CHECKOUT__STEP_MOCK = utils.createMockStep('Checkout', 'Checking out', 'POST_SLACK_SUCCESS'); +const PLATFORM_DEPLOY__POST_SLACK_SUCCESS__SET_VERSION__STEP_MOCK = utils.createMockStep('Set version', 'Setting version', 'POST_SLACK_SUCCESS', null, null, null, {VERSION: '1.2.3'}); const PLATFORM_DEPLOY__POST_SLACK_SUCCESS__ANNOUNCE_CHANNEL__STEP_MOCK = utils.createMockStep( 'Announces the deploy in the #announce Slack room', 'Posting message to \\#announce channel', @@ -397,26 +204,9 @@ const PLATFORM_DEPLOY__POST_SLACK_SUCCESS__STEP_MOCKS = [ ]; // post github comment -const PLATFORM_DEPLOY__POST_GIHUB_COMMENT__CHECKOUT__STEP_MOCK = utils.createMockStep( - 'Checkout', - 'Checking out', - 'POST_GITHUB_COMMENT', - ['fetch-depth'], -); -const PLATFORM_DEPLOY__POST_GIHUB_COMMENT__SETUP_NODE__STEP_MOCK = utils.createMockStep( - 'Setup Node', - 'Setting up Node', - 'POST_GITHUB_COMMENT', -); -const PLATFORM_DEPLOY__POST_GIHUB_COMMENT__SET_VERSION__STEP_MOCK = utils.createMockStep( - 'Set version', - 'Setting version', - 'POST_GITHUB_COMMENT', - null, - null, - null, - {VERSION: '1.2.3'}, -); +const PLATFORM_DEPLOY__POST_GIHUB_COMMENT__CHECKOUT__STEP_MOCK = utils.createMockStep('Checkout', 'Checking out', 'POST_GITHUB_COMMENT', ['fetch-depth']); +const PLATFORM_DEPLOY__POST_GIHUB_COMMENT__SETUP_NODE__STEP_MOCK = utils.createMockStep('Setup Node', 'Setting up Node', 'POST_GITHUB_COMMENT'); +const PLATFORM_DEPLOY__POST_GIHUB_COMMENT__SET_VERSION__STEP_MOCK = utils.createMockStep('Set version', 'Setting version', 'POST_GITHUB_COMMENT', null, null, null, {VERSION: '1.2.3'}); const PLATFORM_DEPLOY__POST_GIHUB_COMMENT__GET_PR_LIST__STEP_MOCK = utils.createMockStep( 'Get Release Pull Request List', 'Getting release pull request list', @@ -425,12 +215,16 @@ const PLATFORM_DEPLOY__POST_GIHUB_COMMENT__GET_PR_LIST__STEP_MOCK = utils.create null, {PR_LIST: '[1.2.1, 1.2.2]'}, ); -const PLATFORM_DEPLOY__POST_GIHUB_COMMENT__COMMENT__STEP_MOCK = utils.createMockStep( - 'Comment on issues', - 'Commenting on issues', - 'POST_GITHUB_COMMENT', - ['PR_LIST', 'IS_PRODUCTION_DEPLOY', 'DEPLOY_VERSION', 'GITHUB_TOKEN', 'ANDROID', 'DESKTOP', 'IOS', 'WEB'], -); +const PLATFORM_DEPLOY__POST_GIHUB_COMMENT__COMMENT__STEP_MOCK = utils.createMockStep('Comment on issues', 'Commenting on issues', 'POST_GITHUB_COMMENT', [ + 'PR_LIST', + 'IS_PRODUCTION_DEPLOY', + 'DEPLOY_VERSION', + 'GITHUB_TOKEN', + 'ANDROID', + 'DESKTOP', + 'IOS', + 'WEB', +]); const PLATFORM_DEPLOY__POST_GITHUB_COMMENT__STEP_MOCKS = [ PLATFORM_DEPLOY__POST_GIHUB_COMMENT__CHECKOUT__STEP_MOCK, PLATFORM_DEPLOY__POST_GIHUB_COMMENT__SETUP_NODE__STEP_MOCK, diff --git a/workflow_tests/mocks/preDeployMocks.js b/workflow_tests/mocks/preDeployMocks.js index 02392e2261c9..9b476eb77aef 100644 --- a/workflow_tests/mocks/preDeployMocks.js +++ b/workflow_tests/mocks/preDeployMocks.js @@ -1,32 +1,15 @@ const utils = require('../utils/utils'); // lint -const LINT_WORKFLOW_MOCK_STEP = utils.createMockStep( - 'Run lint workflow', - 'Running lint workflow', - 'LINT', -); -const LINT_JOB_MOCK_STEPS = [ - LINT_WORKFLOW_MOCK_STEP, -]; +const LINT_WORKFLOW_MOCK_STEP = utils.createMockStep('Run lint workflow', 'Running lint workflow', 'LINT'); +const LINT_JOB_MOCK_STEPS = [LINT_WORKFLOW_MOCK_STEP]; // test -const TEST_WORKFLOW_MOCK_STEP = utils.createMockStep( - 'Run test workflow', - 'Running test workflow', - 'TEST', -); -const TEST_JOB_MOCK_STEPS = [ - TEST_WORKFLOW_MOCK_STEP, -]; +const TEST_WORKFLOW_MOCK_STEP = utils.createMockStep('Run test workflow', 'Running test workflow', 'TEST'); +const TEST_JOB_MOCK_STEPS = [TEST_WORKFLOW_MOCK_STEP]; // confirm_passing_build -const ANNOUNCE_IN_SLACK_MOCK_STEP = utils.createMockStep( - 'Announce failed workflow in Slack', - 'Announcing failed workflow in slack', - 'CONFIRM_PASSING_BUILD', - ['SLACK_WEBHOOK'], -); +const ANNOUNCE_IN_SLACK_MOCK_STEP = utils.createMockStep('Announce failed workflow in Slack', 'Announcing failed workflow in slack', 'CONFIRM_PASSING_BUILD', ['SLACK_WEBHOOK']); const CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS = [ ANNOUNCE_IN_SLACK_MOCK_STEP, @@ -40,16 +23,12 @@ const GET_MERGED_PULL_REQUEST_MOCK_STEP__CHOOSE_DEPLOY__CP_LABEL = utils.createM 'CHOOSE_DEPLOY_ACTIONS', ['github_token'], null, - {number: '123', labels: '[\'CP Staging\']'}, -); -const GET_MERGED_PULL_REQUEST_MOCK_STEP__CHOOSE_DEPLOY = utils.createMockStep( - 'Get merged pull request', - 'Getting merged pull request', - 'CHOOSE_DEPLOY_ACTIONS', - ['github_token'], - null, - {number: '123', labels: '[]'}, + {number: '123', labels: "['CP Staging']"}, ); +const GET_MERGED_PULL_REQUEST_MOCK_STEP__CHOOSE_DEPLOY = utils.createMockStep('Get merged pull request', 'Getting merged pull request', 'CHOOSE_DEPLOY_ACTIONS', ['github_token'], null, { + number: '123', + labels: '[]', +}); const CHECK_IF_STAGINGDEPLOYCASH_IS_LOCKED_MOCK_STEP__LOCKED = utils.createMockStep( 'Check if StagingDeployCash is locked', 'Checking StagingDeployCash', @@ -92,74 +71,27 @@ const CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__CP_LABEL__STAGING_UNLOCKED = [ ]; // skip_deploy -const COMMENT_ON_DEFERRED_PR_MOCK_STEP = utils.createMockStep( - 'Comment on deferred PR', - 'Skipping deploy', - 'SKIP_DEPLOY', - ['github_token', 'number', 'body'], -); -const SKIP_DEPLOY_JOB_MOCK_STEPS = [ - COMMENT_ON_DEFERRED_PR_MOCK_STEP, -]; +const COMMENT_ON_DEFERRED_PR_MOCK_STEP = utils.createMockStep('Comment on deferred PR', 'Skipping deploy', 'SKIP_DEPLOY', ['github_token', 'number', 'body']); +const SKIP_DEPLOY_JOB_MOCK_STEPS = [COMMENT_ON_DEFERRED_PR_MOCK_STEP]; // create_new_version -const CREATE_NEW_VERSION_MOCK_STEP = utils.createMockStep( - 'Create new version', - 'Creating new version', - 'CREATE_NEW_VERSION', - null, - null, - {NEW_VERSION: '1.2.3'}, -); -const CREATE_NEW_VERSION_JOB_MOCK_STEPS = [ - CREATE_NEW_VERSION_MOCK_STEP, -]; +const CREATE_NEW_VERSION_MOCK_STEP = utils.createMockStep('Create new version', 'Creating new version', 'CREATE_NEW_VERSION', null, null, {NEW_VERSION: '1.2.3'}); +const CREATE_NEW_VERSION_JOB_MOCK_STEPS = [CREATE_NEW_VERSION_MOCK_STEP]; // update_staging -const RUN_TURNSTYLE_MOCK_STEP = utils.createMockStep( - 'Run turnstyle', - 'Running turnstyle', - 'UPDATE_STAGING', - ['poll-interval-seconds'], - ['GITHUB_TOKEN'], -); -const UPDATE_STAGING_BRANCH_MOCK_STEP = utils.createMockStep( - 'Update staging branch from main', - 'Updating staging branch', - 'UPDATE_STAGING', - ['TARGET_BRANCH', 'OS_BOTIFY_TOKEN', 'GPG_PASSPHRASE'], -); -const CHERRYPICK_PR_MOCK_STEP = utils.createMockStep( - 'Cherry-pick PR to staging', - 'Cherry picking', - 'UPDATE_STAGING', - ['GITHUB_TOKEN', 'WORKFLOW', 'INPUTS'], -); -const CHECKOUT_STAGING_MOCK_STEP = utils.createMockStep( - 'Checkout staging', - 'Checking out staging', - 'UPDATE_STAGING', - ['ref', 'fetch-depth'], -); -const TAG_STAGING_MOCK_STEP = utils.createMockStep( - 'Tag staging', - 'Tagging staging', - 'UPDATE_STAGING', -); -const UPDATE_STAGINGDEPLOYCASH_MOCK_STEP = utils.createMockStep( - 'Update StagingDeployCash', - 'Updating StagingDeployCash', - 'UPDATE_STAGING', - ['GITHUB_TOKEN', 'NPM_VERSION'], -); -const FIND_OPEN_STAGINGDEPLOYCASH_MOCK_STEP = utils.createMockStep( - 'Find open StagingDeployCash', - 'Finding open StagingDeployCash', - 'UPDATE_STAGING', - null, - ['GITHUB_TOKEN'], - {STAGING_DEPLOY_CASH: '1234'}, -); +const RUN_TURNSTYLE_MOCK_STEP = utils.createMockStep('Run turnstyle', 'Running turnstyle', 'UPDATE_STAGING', ['poll-interval-seconds'], ['GITHUB_TOKEN']); +const UPDATE_STAGING_BRANCH_MOCK_STEP = utils.createMockStep('Update staging branch from main', 'Updating staging branch', 'UPDATE_STAGING', [ + 'TARGET_BRANCH', + 'OS_BOTIFY_TOKEN', + 'GPG_PASSPHRASE', +]); +const CHERRYPICK_PR_MOCK_STEP = utils.createMockStep('Cherry-pick PR to staging', 'Cherry picking', 'UPDATE_STAGING', ['GITHUB_TOKEN', 'WORKFLOW', 'INPUTS']); +const CHECKOUT_STAGING_MOCK_STEP = utils.createMockStep('Checkout staging', 'Checking out staging', 'UPDATE_STAGING', ['ref', 'fetch-depth']); +const TAG_STAGING_MOCK_STEP = utils.createMockStep('Tag staging', 'Tagging staging', 'UPDATE_STAGING'); +const UPDATE_STAGINGDEPLOYCASH_MOCK_STEP = utils.createMockStep('Update StagingDeployCash', 'Updating StagingDeployCash', 'UPDATE_STAGING', ['GITHUB_TOKEN', 'NPM_VERSION']); +const FIND_OPEN_STAGINGDEPLOYCASH_MOCK_STEP = utils.createMockStep('Find open StagingDeployCash', 'Finding open StagingDeployCash', 'UPDATE_STAGING', null, ['GITHUB_TOKEN'], { + STAGING_DEPLOY_CASH: '1234', +}); const COMMENT_TO_ALERT_APPLAUSE_CHERRYPICK_MOCK_STEP = utils.createMockStep( 'Comment in StagingDeployCash to alert Applause that a new pull request has been cherry-picked', 'Commenting in StagingDeployCash', @@ -167,12 +99,7 @@ const COMMENT_TO_ALERT_APPLAUSE_CHERRYPICK_MOCK_STEP = utils.createMockStep( null, ['GITHUB_TOKEN'], ); -const WAIT_FOR_STAGING_DEPLOYS_MOCK_STEP = utils.createMockStep( - 'Wait for staging deploys to finish', - 'Waiting for staging deploy to finish', - 'UPDATE_STAGING', - ['GITHUB_TOKEN', 'TAG'], -); +const WAIT_FOR_STAGING_DEPLOYS_MOCK_STEP = utils.createMockStep('Wait for staging deploys to finish', 'Waiting for staging deploy to finish', 'UPDATE_STAGING', ['GITHUB_TOKEN', 'TAG']); const COMMENT_TO_ALERT_APPLAUSE_DEPLOY_MOCK_STEP = utils.createMockStep( 'Comment in StagingDeployCash to alert Applause that cherry-picked pull request has been deployed.', 'Commenting in StagingDeployCash', @@ -180,12 +107,7 @@ const COMMENT_TO_ALERT_APPLAUSE_DEPLOY_MOCK_STEP = utils.createMockStep( null, ['GITHUB_TOKEN'], ); -const ANNOUNCE_FAILED_WORKFLOW_IN_SLACK_MOCK_STEP = utils.createMockStep( - 'Announce failed workflow in Slack', - 'Announcing failed workflow in Slack', - 'UPDATE_STAGING', - ['SLACK_WEBHOOK'], -); +const ANNOUNCE_FAILED_WORKFLOW_IN_SLACK_MOCK_STEP = utils.createMockStep('Announce failed workflow in Slack', 'Announcing failed workflow in Slack', 'UPDATE_STAGING', ['SLACK_WEBHOOK']); const UPDATE_STAGING_JOB_MOCK_STEPS = [ RUN_TURNSTYLE_MOCK_STEP, UPDATE_STAGING_BRANCH_MOCK_STEP, @@ -217,10 +139,7 @@ const CHECK_TEAM_MEMBERSHIP_MOCK_STEP__TRUE = utils.createMockStep( null, {isTeamMember: true}, ); -const IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE = [ - GET_MERGED_PULL_REQUEST_MOCK_STEP__IS_EXPENSIFY_EMPLOYEE, - CHECK_TEAM_MEMBERSHIP_MOCK_STEP__TRUE, -]; +const IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE = [GET_MERGED_PULL_REQUEST_MOCK_STEP__IS_EXPENSIFY_EMPLOYEE, CHECK_TEAM_MEMBERSHIP_MOCK_STEP__TRUE]; const CHECK_TEAM_MEMBERSHIP_MOCK_STEP__FALSE = utils.createMockStep( 'Check whether the actor is member of Expensify/expensify team', 'Checking actors Expensify membership', @@ -229,28 +148,11 @@ const CHECK_TEAM_MEMBERSHIP_MOCK_STEP__FALSE = utils.createMockStep( null, {isTeamMember: false}, ); -const IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__FALSE = [ - GET_MERGED_PULL_REQUEST_MOCK_STEP__IS_EXPENSIFY_EMPLOYEE, - CHECK_TEAM_MEMBERSHIP_MOCK_STEP__FALSE, -]; +const IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__FALSE = [GET_MERGED_PULL_REQUEST_MOCK_STEP__IS_EXPENSIFY_EMPLOYEE, CHECK_TEAM_MEMBERSHIP_MOCK_STEP__FALSE]; // new_contributor_welcome_message -const CHECKOUT_MOCK_STEP = utils.createMockStep( - 'Checkout', - 'Checking out', - 'NEW_CONTRIBUTOR_WELCOME_MESSAGE', - ['token'], - null, - {author: 'Dummy Author'}, -); -const CHECKOUT_MOCK_STEP__OSBOTIFY = utils.createMockStep( - 'Checkout', - 'Checking out', - 'NEW_CONTRIBUTOR_WELCOME_MESSAGE', - ['token'], - null, - {author: 'OSBotify'}, -); +const CHECKOUT_MOCK_STEP = utils.createMockStep('Checkout', 'Checking out', 'NEW_CONTRIBUTOR_WELCOME_MESSAGE', ['token'], null, {author: 'Dummy Author'}); +const CHECKOUT_MOCK_STEP__OSBOTIFY = utils.createMockStep('Checkout', 'Checking out', 'NEW_CONTRIBUTOR_WELCOME_MESSAGE', ['token'], null, {author: 'OSBotify'}); const GET_MERGED_PULL_REQUEST_MOCK_STEP__WELCOME_MESSAGE = utils.createMockStep( 'Get merged pull request', 'Getting merged pull request', @@ -289,7 +191,7 @@ const GET_PR_COUNT_MOCK_STEP__10 = utils.createMockStep( ); const COMMENT_ON_FIRST_PULL_REQUEST_MOCK_STEP = utils.createMockStep( // eslint-disable-next-line no-template-curly-in-string - 'Comment on ${{ steps.getMergedPullRequest.outputs.author }}\\\'s first pull request!', + "Comment on ${{ steps.getMergedPullRequest.outputs.author }}\\'s first pull request!", 'Creating comment', 'NEW_CONTRIBUTOR_WELCOME_MESSAGE', ['github_token', 'number', 'body'], @@ -313,14 +215,8 @@ const NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__OSBOTIFY = [ COMMENT_ON_FIRST_PULL_REQUEST_MOCK_STEP, ]; -const PREDEPLOY__E2EPERFORMANCETESTS__PERFORM_E2E_TESTS__MOCK_STEP = utils.createMockStep( - 'Perform E2E tests', - 'Perform E2E tests', - 'E2EPERFORMANCETESTS', -); -const PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS = [ - PREDEPLOY__E2EPERFORMANCETESTS__PERFORM_E2E_TESTS__MOCK_STEP, -]; +const PREDEPLOY__E2EPERFORMANCETESTS__PERFORM_E2E_TESTS__MOCK_STEP = utils.createMockStep('Perform E2E tests', 'Perform E2E tests', 'E2EPERFORMANCETESTS'); +const PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS = [PREDEPLOY__E2EPERFORMANCETESTS__PERFORM_E2E_TESTS__MOCK_STEP]; module.exports = { LINT_JOB_MOCK_STEPS, diff --git a/workflow_tests/mocks/reviewerChecklistMocks.js b/workflow_tests/mocks/reviewerChecklistMocks.js index 4315d2fdb1ae..5f9ef67198a8 100644 --- a/workflow_tests/mocks/reviewerChecklistMocks.js +++ b/workflow_tests/mocks/reviewerChecklistMocks.js @@ -1,16 +1,8 @@ const utils = require('../utils/utils'); // checklist -const REVIEWERCHECKLIST__CHECKLIST__REVIEWERCHECKLIST_JS__STEP_MOCK = utils.createMockStep( - 'reviewerChecklist.js', - 'reviewerChecklist.js', - 'CHECKLIST', - ['GITHUB_TOKEN'], - [], -); -const REVIEWERCHECKLIST__CHECKLIST__STEP_MOCKS = [ - REVIEWERCHECKLIST__CHECKLIST__REVIEWERCHECKLIST_JS__STEP_MOCK, -]; +const REVIEWERCHECKLIST__CHECKLIST__REVIEWERCHECKLIST_JS__STEP_MOCK = utils.createMockStep('reviewerChecklist.js', 'reviewerChecklist.js', 'CHECKLIST', ['GITHUB_TOKEN'], []); +const REVIEWERCHECKLIST__CHECKLIST__STEP_MOCKS = [REVIEWERCHECKLIST__CHECKLIST__REVIEWERCHECKLIST_JS__STEP_MOCK]; module.exports = { REVIEWERCHECKLIST__CHECKLIST__STEP_MOCKS, diff --git a/workflow_tests/mocks/testBuildMocks.js b/workflow_tests/mocks/testBuildMocks.js index ba2cf04d5f95..cb60bb6aaaa7 100644 --- a/workflow_tests/mocks/testBuildMocks.js +++ b/workflow_tests/mocks/testBuildMocks.js @@ -1,22 +1,12 @@ const utils = require('../utils/utils'); // validateactor -const TESTBUILD__VALIDATEACTOR__IS_TEAM_MEMBER__TRUE__STEP_MOCK = utils.createMockStep( - 'Is team member', - 'Is team member', - 'VALIDATEACTOR', - ['GITHUB_TOKEN', 'username', 'team'], - [], - {isTeamMember: true}, -); -const TESTBUILD__VALIDATEACTOR__IS_TEAM_MEMBER__FALSE__STEP_MOCK = utils.createMockStep( - 'Is team member', - 'Is team member', - 'VALIDATEACTOR', - ['GITHUB_TOKEN', 'username', 'team'], - [], - {isTeamMember: false}, -); +const TESTBUILD__VALIDATEACTOR__IS_TEAM_MEMBER__TRUE__STEP_MOCK = utils.createMockStep('Is team member', 'Is team member', 'VALIDATEACTOR', ['GITHUB_TOKEN', 'username', 'team'], [], { + isTeamMember: true, +}); +const TESTBUILD__VALIDATEACTOR__IS_TEAM_MEMBER__FALSE__STEP_MOCK = utils.createMockStep('Is team member', 'Is team member', 'VALIDATEACTOR', ['GITHUB_TOKEN', 'username', 'team'], [], { + isTeamMember: false, +}); const TESTBUILD__VALIDATEACTOR__SET_HAS_READY_TO_BUILD_LABEL_FLAG__TRUE__STEP_MOCK = utils.createMockStep( 'Set HAS_READY_TO_BUILD_LABEL flag', 'Set HAS_READY_TO_BUILD_LABEL flag', @@ -51,13 +41,7 @@ const TESTBUILD__VALIDATEACTOR__NO_TEAM_MEMBER_NO_FLAG__STEP_MOCKS = [ ]; // getbranchref -const TESTBUILD__GETBRANCHREF__CHECKOUT__STEP_MOCK = utils.createMockStep( - 'Checkout', - 'Checkout', - 'GETBRANCHREF', - [], - [], -); +const TESTBUILD__GETBRANCHREF__CHECKOUT__STEP_MOCK = utils.createMockStep('Checkout', 'Checkout', 'GETBRANCHREF', [], []); const TESTBUILD__GETBRANCHREF__CHECK_IF_PULL_REQUEST_NUMBER_IS_CORRECT__STEP_MOCK = utils.createMockStep( 'Check if pull request number is correct', 'Check if pull request number is correct', @@ -66,19 +50,10 @@ const TESTBUILD__GETBRANCHREF__CHECK_IF_PULL_REQUEST_NUMBER_IS_CORRECT__STEP_MOC ['GITHUB_TOKEN'], {REF: 'test-ref'}, ); -const TESTBUILD__GETBRANCHREF__STEP_MOCKS = [ - TESTBUILD__GETBRANCHREF__CHECKOUT__STEP_MOCK, - TESTBUILD__GETBRANCHREF__CHECK_IF_PULL_REQUEST_NUMBER_IS_CORRECT__STEP_MOCK, -]; +const TESTBUILD__GETBRANCHREF__STEP_MOCKS = [TESTBUILD__GETBRANCHREF__CHECKOUT__STEP_MOCK, TESTBUILD__GETBRANCHREF__CHECK_IF_PULL_REQUEST_NUMBER_IS_CORRECT__STEP_MOCK]; // android -const TESTBUILD__ANDROID__CHECKOUT__STEP_MOCK = utils.createMockStep( - 'Checkout', - 'Checkout', - 'ANDROID', - ['ref'], - [], -); +const TESTBUILD__ANDROID__CHECKOUT__STEP_MOCK = utils.createMockStep('Checkout', 'Checkout', 'ANDROID', ['ref'], []); const TESTBUILD__ANDROID__CREATE_ENV_ADHOC__STEP_MOCK = utils.createMockStep( 'Create .env.adhoc file based on staging and add PULL_REQUEST_NUMBER env to it', 'Creating .env.adhoc file based on staging', @@ -86,34 +61,10 @@ const TESTBUILD__ANDROID__CREATE_ENV_ADHOC__STEP_MOCK = utils.createMockStep( [], [], ); -const TESTBUILD__ANDROID__SETUP_NODE__STEP_MOCK = utils.createMockStep( - 'Setup Node', - 'Setup Node', - 'ANDROID', - [], - [], -); -const TESTBUILD__ANDROID__SETUP_RUBY__STEP_MOCK = utils.createMockStep( - 'Setup Ruby', - 'Setup Ruby', - 'ANDROID', - ['ruby-version', 'bundler-cache'], - [], -); -const TESTBUILD__ANDROID__DECRYPT_KEYSTORE__STEP_MOCK = utils.createMockStep( - 'Decrypt keystore', - 'Decrypt keystore', - 'ANDROID', - [], - ['LARGE_SECRET_PASSPHRASE'], -); -const TESTBUILD__ANDROID__DECRYPT_JSON_KEY__STEP_MOCK = utils.createMockStep( - 'Decrypt json key', - 'Decrypt json key', - 'ANDROID', - [], - ['LARGE_SECRET_PASSPHRASE'], -); +const TESTBUILD__ANDROID__SETUP_NODE__STEP_MOCK = utils.createMockStep('Setup Node', 'Setup Node', 'ANDROID', [], []); +const TESTBUILD__ANDROID__SETUP_RUBY__STEP_MOCK = utils.createMockStep('Setup Ruby', 'Setup Ruby', 'ANDROID', ['ruby-version', 'bundler-cache'], []); +const TESTBUILD__ANDROID__DECRYPT_KEYSTORE__STEP_MOCK = utils.createMockStep('Decrypt keystore', 'Decrypt keystore', 'ANDROID', [], ['LARGE_SECRET_PASSPHRASE']); +const TESTBUILD__ANDROID__DECRYPT_JSON_KEY__STEP_MOCK = utils.createMockStep('Decrypt json key', 'Decrypt json key', 'ANDROID', [], ['LARGE_SECRET_PASSPHRASE']); const TESTBUILD__ANDROID__CONFIGURE_AWS_CREDENTIALS__STEP_MOCK = utils.createMockStep( 'Configure AWS Credentials', 'Configure AWS Credentials', @@ -128,13 +79,7 @@ const TESTBUILD__ANDROID__RUN_FASTLANE_BETA_TEST__STEP_MOCK = utils.createMockSt [], ['S3_ACCESS_KEY', 'S3_SECRET_ACCESS_KEY', 'S3_BUCKET', 'S3_REGION'], ); -const TESTBUILD__ANDROID__UPLOAD_ARTIFACT__STEP_MOCK = utils.createMockStep( - 'Upload Artifact', - 'Upload Artifact', - 'ANDROID', - ['name', 'path'], - [], -); +const TESTBUILD__ANDROID__UPLOAD_ARTIFACT__STEP_MOCK = utils.createMockStep('Upload Artifact', 'Upload Artifact', 'ANDROID', ['name', 'path'], []); const TESTBUILD__ANDROID__STEP_MOCKS = [ TESTBUILD__ANDROID__CHECKOUT__STEP_MOCK, TESTBUILD__ANDROID__CREATE_ENV_ADHOC__STEP_MOCK, @@ -148,13 +93,7 @@ const TESTBUILD__ANDROID__STEP_MOCKS = [ ]; // ios -const TESTBUILD__IOS__CHECKOUT__STEP_MOCK = utils.createMockStep( - 'Checkout', - 'Checkout', - 'IOS', - ['ref'], - [], -); +const TESTBUILD__IOS__CHECKOUT__STEP_MOCK = utils.createMockStep('Checkout', 'Checkout', 'IOS', ['ref'], []); const TESTBUILD__IOS__CREATE_ENV_ADHOC__STEP_MOCK = utils.createMockStep( 'Create .env.adhoc file based on staging and add PULL_REQUEST_NUMBER env to it', 'Creating .env.adhoc file based on staging', @@ -162,47 +101,12 @@ const TESTBUILD__IOS__CREATE_ENV_ADHOC__STEP_MOCK = utils.createMockStep( [], [], ); -const TESTBUILD__IOS__SETUP_NODE__STEP_MOCK = utils.createMockStep( - 'Setup Node', - 'Setup Node', - 'IOS', - [], - [], -); -const TESTBUILD__IOS__SETUP_RUBY__STEP_MOCK = utils.createMockStep( - 'Setup Ruby', - 'Setup Ruby', - 'IOS', - ['ruby-version', 'bundler-cache'], - [], -); -const TESTBUILD__IOS__CACHE__STEP_MOCK = utils.createMockStep( - 'Cache', - 'Caching', - 'IOS', - ['path', 'key', 'restore-keys'], -); -const TESTBUILD__IOS__INSTALL_COCOAPODS__STEP_MOCK = utils.createMockStep( - 'Install cocoapods', - 'Install cocoapods', - 'IOS', - ['timeout_minutes', 'max_attempts', 'command'], - [], -); -const TESTBUILD__IOS__DECRYPT_PROFILE__STEP_MOCK = utils.createMockStep( - 'Decrypt profile', - 'Decrypt profile', - 'IOS', - [], - ['LARGE_SECRET_PASSPHRASE'], -); -const TESTBUILD__IOS__DECRYPT_CERTIFICATE__STEP_MOCK = utils.createMockStep( - 'Decrypt certificate', - 'Decrypt certificate', - 'IOS', - [], - ['LARGE_SECRET_PASSPHRASE'], -); +const TESTBUILD__IOS__SETUP_NODE__STEP_MOCK = utils.createMockStep('Setup Node', 'Setup Node', 'IOS', [], []); +const TESTBUILD__IOS__SETUP_RUBY__STEP_MOCK = utils.createMockStep('Setup Ruby', 'Setup Ruby', 'IOS', ['ruby-version', 'bundler-cache'], []); +const TESTBUILD__IOS__CACHE__STEP_MOCK = utils.createMockStep('Cache', 'Caching', 'IOS', ['path', 'key', 'restore-keys']); +const TESTBUILD__IOS__INSTALL_COCOAPODS__STEP_MOCK = utils.createMockStep('Install cocoapods', 'Install cocoapods', 'IOS', ['timeout_minutes', 'max_attempts', 'command'], []); +const TESTBUILD__IOS__DECRYPT_PROFILE__STEP_MOCK = utils.createMockStep('Decrypt profile', 'Decrypt profile', 'IOS', [], ['LARGE_SECRET_PASSPHRASE']); +const TESTBUILD__IOS__DECRYPT_CERTIFICATE__STEP_MOCK = utils.createMockStep('Decrypt certificate', 'Decrypt certificate', 'IOS', [], ['LARGE_SECRET_PASSPHRASE']); const TESTBUILD__IOS__CONFIGURE_AWS_CREDENTIALS__STEP_MOCK = utils.createMockStep( 'Configure AWS Credentials', 'Configure AWS Credentials', @@ -210,20 +114,8 @@ const TESTBUILD__IOS__CONFIGURE_AWS_CREDENTIALS__STEP_MOCK = utils.createMockSte ['AWS_ACCESS_KEY_ID', 'AWS_SECRET_ACCESS_KEY'], [], ); -const TESTBUILD__IOS__RUN_FASTLANE__STEP_MOCK = utils.createMockStep( - 'Run Fastlane', - 'Run Fastlane', - 'IOS', - [], - ['S3_ACCESS_KEY', 'S3_SECRET_ACCESS_KEY', 'S3_BUCKET', 'S3_REGION'], -); -const TESTBUILD__IOS__UPLOAD_ARTIFACT__STEP_MOCK = utils.createMockStep( - 'Upload Artifact', - 'Upload Artifact', - 'IOS', - ['name', 'path'], - [], -); +const TESTBUILD__IOS__RUN_FASTLANE__STEP_MOCK = utils.createMockStep('Run Fastlane', 'Run Fastlane', 'IOS', [], ['S3_ACCESS_KEY', 'S3_SECRET_ACCESS_KEY', 'S3_BUCKET', 'S3_REGION']); +const TESTBUILD__IOS__UPLOAD_ARTIFACT__STEP_MOCK = utils.createMockStep('Upload Artifact', 'Upload Artifact', 'IOS', ['name', 'path'], []); const TESTBUILD__IOS__STEP_MOCKS = [ TESTBUILD__IOS__CHECKOUT__STEP_MOCK, TESTBUILD__IOS__CREATE_ENV_ADHOC__STEP_MOCK, @@ -239,13 +131,7 @@ const TESTBUILD__IOS__STEP_MOCKS = [ ]; // desktop -const TESTBUILD__DESKTOP__CHECKOUT__STEP_MOCK = utils.createMockStep( - 'Checkout', - 'Checkout', - 'DESKTOP', - ['ref', 'fetch-depth'], - [], -); +const TESTBUILD__DESKTOP__CHECKOUT__STEP_MOCK = utils.createMockStep('Checkout', 'Checkout', 'DESKTOP', ['ref', 'fetch-depth'], []); const TESTBUILD__DESKTOP__CREATE_ENV_ADHOC__STEP_MOCK = utils.createMockStep( 'Create .env.adhoc file based on staging and add PULL_REQUEST_NUMBER env to it', 'Creating .env.adhoc file based on staging', @@ -253,13 +139,7 @@ const TESTBUILD__DESKTOP__CREATE_ENV_ADHOC__STEP_MOCK = utils.createMockStep( [], [], ); -const TESTBUILD__DESKTOP__SETUP_NODE__STEP_MOCK = utils.createMockStep( - 'Setup Node', - 'Setup Node', - 'DESKTOP', - [], - [], -); +const TESTBUILD__DESKTOP__SETUP_NODE__STEP_MOCK = utils.createMockStep('Setup Node', 'Setup Node', 'DESKTOP', [], []); const TESTBUILD__DESKTOP__DECRYPT_DEVELOPER_ID_CERTIFICATE__STEP_MOCK = utils.createMockStep( 'Decrypt Developer ID Certificate', 'Decrypt Developer ID Certificate', @@ -291,13 +171,7 @@ const TESTBUILD__DESKTOP__STEP_MOCKS = [ ]; // web -const TESTBUILD__WEB__CHECKOUT__STEP_MOCK = utils.createMockStep( - 'Checkout', - 'Checkout', - 'WEB', - ['fetch-depth', 'ref'], - [], -); +const TESTBUILD__WEB__CHECKOUT__STEP_MOCK = utils.createMockStep('Checkout', 'Checkout', 'WEB', ['fetch-depth', 'ref'], []); const TESTBUILD__WEB__CREATE_ENV_ADHOC__STEP_MOCK = utils.createMockStep( 'Create .env.adhoc file based on staging and add PULL_REQUEST_NUMBER env to it', 'Creating .env.adhoc file based on staging', @@ -305,13 +179,7 @@ const TESTBUILD__WEB__CREATE_ENV_ADHOC__STEP_MOCK = utils.createMockStep( [], [], ); -const TESTBUILD__WEB__SETUP_NODE__STEP_MOCK = utils.createMockStep( - 'Setup Node', - 'Setup Node', - 'WEB', - [], - [], -); +const TESTBUILD__WEB__SETUP_NODE__STEP_MOCK = utils.createMockStep('Setup Node', 'Setup Node', 'WEB', [], []); const TESTBUILD__WEB__CONFIGURE_AWS_CREDENTIALS__STEP_MOCK = utils.createMockStep( 'Configure AWS Credentials', 'Configure AWS Credentials', @@ -319,27 +187,9 @@ const TESTBUILD__WEB__CONFIGURE_AWS_CREDENTIALS__STEP_MOCK = utils.createMockSte ['AWS_ACCESS_KEY_ID', 'AWS_SECRET_ACCESS_KEY'], [], ); -const TESTBUILD__WEB__BUILD_WEB_FOR_TESTING__STEP_MOCK = utils.createMockStep( - 'Build web for testing', - 'Build web for testing', - 'WEB', - [], - [], -); -const TESTBUILD__WEB__BUILD_DOCS__STEP_MOCK = utils.createMockStep( - 'Build docs', - 'Build docs', - 'WEB', - [], - [], -); -const TESTBUILD__WEB__DEPLOY_TO_S3_FOR_INTERNAL_TESTING__STEP_MOCK = utils.createMockStep( - 'Deploy to S3 for internal testing', - 'Deploy to S3 for internal testing', - 'WEB', - [], - [], -); +const TESTBUILD__WEB__BUILD_WEB_FOR_TESTING__STEP_MOCK = utils.createMockStep('Build web for testing', 'Build web for testing', 'WEB', [], []); +const TESTBUILD__WEB__BUILD_DOCS__STEP_MOCK = utils.createMockStep('Build docs', 'Build docs', 'WEB', [], []); +const TESTBUILD__WEB__DEPLOY_TO_S3_FOR_INTERNAL_TESTING__STEP_MOCK = utils.createMockStep('Deploy to S3 for internal testing', 'Deploy to S3 for internal testing', 'WEB', [], []); const TESTBUILD__WEB__STEP_MOCKS = [ TESTBUILD__WEB__CHECKOUT__STEP_MOCK, TESTBUILD__WEB__CREATE_ENV_ADHOC__STEP_MOCK, @@ -351,20 +201,8 @@ const TESTBUILD__WEB__STEP_MOCKS = [ ]; // postgithubcomment -const TESTBUILD__POSTGITHUBCOMMENT__CHECKOUT__STEP_MOCK = utils.createMockStep( - 'Checkout', - 'Checkout', - 'POSTGITHUBCOMMENT', - ['ref'], - [], -); -const TESTBUILD__POSTGITHUBCOMMENT__DOWNLOAD_ARTIFACT__STEP_MOCK = utils.createMockStep( - 'Download Artifact', - 'Download Artifact', - 'POSTGITHUBCOMMENT', - [], - [], -); +const TESTBUILD__POSTGITHUBCOMMENT__CHECKOUT__STEP_MOCK = utils.createMockStep('Checkout', 'Checkout', 'POSTGITHUBCOMMENT', ['ref'], []); +const TESTBUILD__POSTGITHUBCOMMENT__DOWNLOAD_ARTIFACT__STEP_MOCK = utils.createMockStep('Download Artifact', 'Download Artifact', 'POSTGITHUBCOMMENT', [], []); const TESTBUILD__POSTGITHUBCOMMENT__READ_JSONS_WITH_ANDROID_PATHS__STEP_MOCK = utils.createMockStep( 'Read JSONs with android paths', 'Read JSONs with android paths', @@ -373,14 +211,9 @@ const TESTBUILD__POSTGITHUBCOMMENT__READ_JSONS_WITH_ANDROID_PATHS__STEP_MOCK = u [], {android_path: 'http://dummy.android.link'}, ); -const TESTBUILD__POSTGITHUBCOMMENT__READ_JSONS_WITH_IOS_PATHS__STEP_MOCK = utils.createMockStep( - 'Read JSONs with iOS paths', - 'Read JSONs with iOS paths', - 'POSTGITHUBCOMMENT', - [], - [], - {ios_path: 'http://dummy.ios.link'}, -); +const TESTBUILD__POSTGITHUBCOMMENT__READ_JSONS_WITH_IOS_PATHS__STEP_MOCK = utils.createMockStep('Read JSONs with iOS paths', 'Read JSONs with iOS paths', 'POSTGITHUBCOMMENT', [], [], { + ios_path: 'http://dummy.ios.link', +}); const TESTBUILD__POSTGITHUBCOMMENT__MAINTAIN_COMMENT__STEP_MOCK = utils.createMockStep( 'maintain-comment', 'maintain-comment', diff --git a/workflow_tests/mocks/testMocks.js b/workflow_tests/mocks/testMocks.js index 4e43aa182d3b..002325292de6 100644 --- a/workflow_tests/mocks/testMocks.js +++ b/workflow_tests/mocks/testMocks.js @@ -1,42 +1,11 @@ const utils = require('../utils/utils'); // jest -const TEST__JEST__CHECKOUT__STEP_MOCK = utils.createMockStep( - 'Checkout', - 'Checkout', - 'JEST', - [], - [], -); -const TEST__JEST__SETUP_NODE__STEP_MOCK = utils.createMockStep( - 'Setup Node', - 'Setup Node', - 'JEST', - [], - [], -); -const TEST__JEST__GET_NUMBER_OF_CPU_CORES__STEP_MOCK = utils.createMockStep( - 'Get number of CPU cores', - 'Get number of CPU cores', - 'JEST', - [], - [], - {count: 8}, -); -const TEST__JEST__CACHE_JEST_CACHE__STEP_MOCK = utils.createMockStep( - 'Cache Jest cache', - 'Cache Jest cache', - 'JEST', - ['path', 'key'], - [], -); -const TEST__JEST__JEST_TESTS__STEP_MOCK = utils.createMockStep( - 'Jest tests', - 'Jest tests', - 'JEST', - [], - [], -); +const TEST__JEST__CHECKOUT__STEP_MOCK = utils.createMockStep('Checkout', 'Checkout', 'JEST', [], []); +const TEST__JEST__SETUP_NODE__STEP_MOCK = utils.createMockStep('Setup Node', 'Setup Node', 'JEST', [], []); +const TEST__JEST__GET_NUMBER_OF_CPU_CORES__STEP_MOCK = utils.createMockStep('Get number of CPU cores', 'Get number of CPU cores', 'JEST', [], [], {count: 8}); +const TEST__JEST__CACHE_JEST_CACHE__STEP_MOCK = utils.createMockStep('Cache Jest cache', 'Cache Jest cache', 'JEST', ['path', 'key'], []); +const TEST__JEST__JEST_TESTS__STEP_MOCK = utils.createMockStep('Jest tests', 'Jest tests', 'JEST', [], []); const TEST__JEST__STEP_MOCKS = [ TEST__JEST__CHECKOUT__STEP_MOCK, TEST__JEST__SETUP_NODE__STEP_MOCK, @@ -46,33 +15,12 @@ const TEST__JEST__STEP_MOCKS = [ ]; // shelltests -const TEST__SHELLTESTS__CHECKOUT__STEP_MOCK = utils.createMockStep( - 'Checkout', - 'Checkout', - 'SHELLTESTS', - [], - [], -); -const TEST__SHELLTESTS__SETUP_NODE__STEP_MOCK = utils.createMockStep( - 'Setup Node', - 'Setup Node', - 'SHELLTESTS', - [], - [], -); -const TEST__SHELLTESTS__GETPULLREQUESTSMERGEDBETWEEN__STEP_MOCK = utils.createMockStep( - 'getPullRequestsMergedBetween', - 'getPullRequestsMergedBetween', - 'SHELLTESTS', - [], - [], -); -const TEST__SHELLTESTS__STEP_MOCKS = [ - TEST__SHELLTESTS__CHECKOUT__STEP_MOCK, - TEST__SHELLTESTS__SETUP_NODE__STEP_MOCK, - TEST__SHELLTESTS__GETPULLREQUESTSMERGEDBETWEEN__STEP_MOCK, -]; +const TEST__SHELLTESTS__CHECKOUT__STEP_MOCK = utils.createMockStep('Checkout', 'Checkout', 'SHELLTESTS', [], []); +const TEST__SHELLTESTS__SETUP_NODE__STEP_MOCK = utils.createMockStep('Setup Node', 'Setup Node', 'SHELLTESTS', [], []); +const TEST__SHELLTESTS__GETPULLREQUESTSMERGEDBETWEEN__STEP_MOCK = utils.createMockStep('getPullRequestsMergedBetween', 'getPullRequestsMergedBetween', 'SHELLTESTS', [], []); +const TEST__SHELLTESTS__STEP_MOCKS = [TEST__SHELLTESTS__CHECKOUT__STEP_MOCK, TEST__SHELLTESTS__SETUP_NODE__STEP_MOCK, TEST__SHELLTESTS__GETPULLREQUESTSMERGEDBETWEEN__STEP_MOCK]; module.exports = { - TEST__JEST__STEP_MOCKS, TEST__SHELLTESTS__STEP_MOCKS, + TEST__JEST__STEP_MOCKS, + TEST__SHELLTESTS__STEP_MOCKS, }; diff --git a/workflow_tests/mocks/validateGithubActionsMocks.js b/workflow_tests/mocks/validateGithubActionsMocks.js index 4be1596966ba..53dcd1276078 100644 --- a/workflow_tests/mocks/validateGithubActionsMocks.js +++ b/workflow_tests/mocks/validateGithubActionsMocks.js @@ -1,20 +1,8 @@ const utils = require('../utils/utils'); // verify -const VALIDATEGITHUBACTIONS__VERIFY__CHECKOUT__STEP_MOCK = utils.createMockStep( - 'Checkout', - 'Checkout', - 'VERIFY', - ['fetch-depth'], - [], -); -const VALIDATEGITHUBACTIONS__VERIFY__SETUP_NODE__STEP_MOCK = utils.createMockStep( - 'Setup Node', - 'Setup Node', - 'VERIFY', - [], - [], -); +const VALIDATEGITHUBACTIONS__VERIFY__CHECKOUT__STEP_MOCK = utils.createMockStep('Checkout', 'Checkout', 'VERIFY', ['fetch-depth'], []); +const VALIDATEGITHUBACTIONS__VERIFY__SETUP_NODE__STEP_MOCK = utils.createMockStep('Setup Node', 'Setup Node', 'VERIFY', [], []); const VALIDATEGITHUBACTIONS__VERIFY__VERIFY_JAVASCRIPT_ACTION_BUILDS__STEP_MOCK = utils.createMockStep( 'Verify Javascript Action Builds', 'Verify Javascript Action Builds', @@ -22,13 +10,7 @@ const VALIDATEGITHUBACTIONS__VERIFY__VERIFY_JAVASCRIPT_ACTION_BUILDS__STEP_MOCK [], [], ); -const VALIDATEGITHUBACTIONS__VERIFY__VALIDATE_ACTIONS_AND_WORKFLOWS__STEP_MOCK = utils.createMockStep( - 'Validate actions and workflows', - 'Validate actions and workflows', - 'VERIFY', - [], - [], -); +const VALIDATEGITHUBACTIONS__VERIFY__VALIDATE_ACTIONS_AND_WORKFLOWS__STEP_MOCK = utils.createMockStep('Validate actions and workflows', 'Validate actions and workflows', 'VERIFY', [], []); const VALIDATEGITHUBACTIONS__VERIFY__STEP_MOCKS = [ VALIDATEGITHUBACTIONS__VERIFY__CHECKOUT__STEP_MOCK, VALIDATEGITHUBACTIONS__VERIFY__SETUP_NODE__STEP_MOCK, diff --git a/workflow_tests/mocks/verifyPodfileMocks.js b/workflow_tests/mocks/verifyPodfileMocks.js index df9889a0e718..a26f0d16609a 100644 --- a/workflow_tests/mocks/verifyPodfileMocks.js +++ b/workflow_tests/mocks/verifyPodfileMocks.js @@ -1,32 +1,10 @@ const utils = require('../utils/utils'); // verify -const VERIFYPODFILE__VERIFY__CHECKOUT__STEP_MOCK = utils.createMockStep( - 'Checkout', - 'Checkout', - 'VERIFY', - ['fetch-depth'], - [], -); -const VERIFYPODFILE__VERIFY__SETUP_NODE__STEP_MOCK = utils.createMockStep( - 'Setup Node', - 'Setup Node', - 'VERIFY', - [], - [], -); -const VERIFYPODFILE__VERIFY__VERIFY_PODFILE__STEP_MOCK = utils.createMockStep( - 'Verify podfile', - 'Verify podfile', - 'VERIFY', - [], - [], -); -const VERIFYPODFILE__VERIFY__STEP_MOCKS = [ - VERIFYPODFILE__VERIFY__CHECKOUT__STEP_MOCK, - VERIFYPODFILE__VERIFY__SETUP_NODE__STEP_MOCK, - VERIFYPODFILE__VERIFY__VERIFY_PODFILE__STEP_MOCK, -]; +const VERIFYPODFILE__VERIFY__CHECKOUT__STEP_MOCK = utils.createMockStep('Checkout', 'Checkout', 'VERIFY', ['fetch-depth'], []); +const VERIFYPODFILE__VERIFY__SETUP_NODE__STEP_MOCK = utils.createMockStep('Setup Node', 'Setup Node', 'VERIFY', [], []); +const VERIFYPODFILE__VERIFY__VERIFY_PODFILE__STEP_MOCK = utils.createMockStep('Verify podfile', 'Verify podfile', 'VERIFY', [], []); +const VERIFYPODFILE__VERIFY__STEP_MOCKS = [VERIFYPODFILE__VERIFY__CHECKOUT__STEP_MOCK, VERIFYPODFILE__VERIFY__SETUP_NODE__STEP_MOCK, VERIFYPODFILE__VERIFY__VERIFY_PODFILE__STEP_MOCK]; module.exports = { VERIFYPODFILE__VERIFY__STEP_MOCKS, diff --git a/workflow_tests/mocks/verifySignedCommitsMocks.js b/workflow_tests/mocks/verifySignedCommitsMocks.js index 18f71f09ee69..a19fac809e55 100644 --- a/workflow_tests/mocks/verifySignedCommitsMocks.js +++ b/workflow_tests/mocks/verifySignedCommitsMocks.js @@ -8,9 +8,7 @@ const VERIFYSIGNEDCOMMITS__VERIFYSIGNEDCOMMITS__VERIFY_SIGNED_COMMITS__STEP_MOCK ['GITHUB_TOKEN'], [], ); -const VERIFYSIGNEDCOMMITS__VERIFYSIGNEDCOMMITS__STEP_MOCKS = [ - VERIFYSIGNEDCOMMITS__VERIFYSIGNEDCOMMITS__VERIFY_SIGNED_COMMITS__STEP_MOCK, -]; +const VERIFYSIGNEDCOMMITS__VERIFYSIGNEDCOMMITS__STEP_MOCKS = [VERIFYSIGNEDCOMMITS__VERIFYSIGNEDCOMMITS__VERIFY_SIGNED_COMMITS__STEP_MOCK]; module.exports = { VERIFYSIGNEDCOMMITS__VERIFYSIGNEDCOMMITS__STEP_MOCKS, diff --git a/workflow_tests/platformDeploy.test.js b/workflow_tests/platformDeploy.test.js index 1bdffa89fa4a..6bbca9653a95 100644 --- a/workflow_tests/platformDeploy.test.js +++ b/workflow_tests/platformDeploy.test.js @@ -96,13 +96,12 @@ describe('test workflow platformDeploy', () => { postSlackMessageOnSuccess: mocks.PLATFORM_DEPLOY__POST_SLACK_SUCCESS__STEP_MOCKS, postGithubComment: mocks.PLATFORM_DEPLOY__POST_GITHUB_COMMENT__STEP_MOCKS, }; - const result = await act - .runEvent('push', { - workflowFile: path.join(repoPath, '.github', 'workflows', 'platformDeploy.yml'), - mockSteps: testMockSteps, - actor: 'Dummy Author', - logFile: utils.getLogFilePath('platformDeploy', expect.getState().currentTestName), - }); + const result = await act.runEvent('push', { + workflowFile: path.join(repoPath, '.github', 'workflows', 'platformDeploy.yml'), + mockSteps: testMockSteps, + actor: 'Dummy Author', + logFile: utils.getLogFilePath('platformDeploy', expect.getState().currentTestName), + }); assertions.assertVerifyActorJobExecuted(result, 'Dummy Author'); assertions.assertAndroidJobExecuted(result, true, false, true); @@ -169,13 +168,12 @@ describe('test workflow platformDeploy', () => { postSlackMessageOnSuccess: mocks.PLATFORM_DEPLOY__POST_SLACK_SUCCESS__STEP_MOCKS, postGithubComment: mocks.PLATFORM_DEPLOY__POST_GITHUB_COMMENT__STEP_MOCKS, }; - const result = await act - .runEvent('push', { - workflowFile: path.join(repoPath, '.github', 'workflows', 'platformDeploy.yml'), - mockSteps: testMockSteps, - actor: 'OSBotify', - logFile: utils.getLogFilePath('platformDeploy', expect.getState().currentTestName), - }); + const result = await act.runEvent('push', { + workflowFile: path.join(repoPath, '.github', 'workflows', 'platformDeploy.yml'), + mockSteps: testMockSteps, + actor: 'OSBotify', + logFile: utils.getLogFilePath('platformDeploy', expect.getState().currentTestName), + }); assertions.assertVerifyActorJobExecuted(result, 'OSBotify'); assertions.assertAndroidJobExecuted(result, true, false, true); @@ -242,13 +240,12 @@ describe('test workflow platformDeploy', () => { postSlackMessageOnSuccess: mocks.PLATFORM_DEPLOY__POST_SLACK_SUCCESS__STEP_MOCKS, postGithubComment: mocks.PLATFORM_DEPLOY__POST_GITHUB_COMMENT__STEP_MOCKS, }; - const result = await act - .runEvent('push', { - workflowFile: path.join(repoPath, '.github', 'workflows', 'platformDeploy.yml'), - mockSteps: testMockSteps, - actor: 'Dummy Author', - logFile: utils.getLogFilePath('platformDeploy', expect.getState().currentTestName), - }); + const result = await act.runEvent('push', { + workflowFile: path.join(repoPath, '.github', 'workflows', 'platformDeploy.yml'), + mockSteps: testMockSteps, + actor: 'Dummy Author', + logFile: utils.getLogFilePath('platformDeploy', expect.getState().currentTestName), + }); assertions.assertVerifyActorJobExecuted(result, 'Dummy Author'); assertions.assertAndroidJobExecuted(result, false); diff --git a/workflow_tests/preDeploy.test.js b/workflow_tests/preDeploy.test.js index 542883deb00e..3af13ce7db5e 100644 --- a/workflow_tests/preDeploy.test.js +++ b/workflow_tests/preDeploy.test.js @@ -55,7 +55,9 @@ describe('test workflow preDeploy', () => { 'push', {ref: 'refs/heads/main'}, { - OS_BOTIFY_TOKEN: 'dummy_token', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', + OS_BOTIFY_TOKEN: 'dummy_token', + SLACK_WEBHOOK: 'dummy_slack_webhook', + LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', }, 'dummy_github_token', ); @@ -75,13 +77,12 @@ describe('test workflow preDeploy', () => { }; // run an event and get the result - const result = await act - .runEvent('push', { - workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), - mockSteps: testMockSteps, - actor: 'Dummy Tester', - logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), - }); + const result = await act.runEvent('push', { + workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), + mockSteps: testMockSteps, + actor: 'Dummy Tester', + logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), + }); // assert results (some steps can run in parallel to each other so the order is not assured // therefore we can check which steps have been executed, but not the set job order @@ -117,17 +118,18 @@ describe('test workflow preDeploy', () => { 'pull_request', {head: {ref: 'main'}}, { - OS_BOTIFY_TOKEN: 'dummy_token', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', + OS_BOTIFY_TOKEN: 'dummy_token', + SLACK_WEBHOOK: 'dummy_slack_webhook', + LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', }, 'dummy_github_token', ); - let result = await act - .runEvent('pull_request', { - workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), - mockSteps: testMockSteps, - actor: 'Dummy Tester', - logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), - }); + let result = await act.runEvent('pull_request', { + workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), + mockSteps: testMockSteps, + actor: 'Dummy Tester', + logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), + }); assertions.assertLintJobExecuted(result, false); assertions.assertTestJobExecuted(result, false); assertions.assertIsExpensifyEmployeeJobExecuted(result, false); @@ -142,17 +144,18 @@ describe('test workflow preDeploy', () => { 'workflow_dispatch', {}, { - OS_BOTIFY_TOKEN: 'dummy_token', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', + OS_BOTIFY_TOKEN: 'dummy_token', + SLACK_WEBHOOK: 'dummy_slack_webhook', + LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', }, 'dummy_github_token', ); - result = await act - .runEvent('workflow_dispatch', { - workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), - mockSteps: testMockSteps, - actor: 'Dummy Tester', - logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), - }); + result = await act.runEvent('workflow_dispatch', { + workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), + mockSteps: testMockSteps, + actor: 'Dummy Tester', + logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), + }); assertions.assertLintJobExecuted(result, false); assertions.assertTestJobExecuted(result, false); assertions.assertIsExpensifyEmployeeJobExecuted(result, false); @@ -172,23 +175,14 @@ describe('test workflow preDeploy', () => { 'push', {ref: 'refs/heads/main'}, { - OS_BOTIFY_TOKEN: 'dummy_token', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', + OS_BOTIFY_TOKEN: 'dummy_token', + SLACK_WEBHOOK: 'dummy_slack_webhook', + LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', }, 'dummy_github_token', ); const testMockSteps = { - lint: [ - utils.createMockStep( - 'Run lint workflow', - 'Running lint workflow - Lint workflow failed', - 'LINT', - null, - null, - null, - null, - false, - ), - ], + lint: [utils.createMockStep('Run lint workflow', 'Running lint workflow - Lint workflow failed', 'LINT', null, null, null, null, false)], test: mocks.TEST_JOB_MOCK_STEPS, confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__CP_LABEL__STAGING_UNLOCKED, @@ -199,43 +193,23 @@ describe('test workflow preDeploy', () => { newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, e2ePerformanceTests: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, }; - const result = await act - .runEvent('push', { - workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), - mockSteps: testMockSteps, - actor: 'Dummy Tester', - logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), - }); - expect(result).toEqual(expect.arrayContaining( - [ - utils.createStepAssertion( - 'Run lint workflow', - false, - null, - 'LINT', - 'Running lint workflow - Lint workflow failed', - ), - ], - )); + const result = await act.runEvent('push', { + workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), + mockSteps: testMockSteps, + actor: 'Dummy Tester', + logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), + }); + expect(result).toEqual(expect.arrayContaining([utils.createStepAssertion('Run lint workflow', false, null, 'LINT', 'Running lint workflow - Lint workflow failed')])); assertions.assertTestJobExecuted(result); assertions.assertIsExpensifyEmployeeJobExecuted(result); - expect(result).toEqual(expect.arrayContaining( - [ - utils.createStepAssertion( - 'Announce failed workflow in Slack', - true, - null, - 'CONFIRM_PASSING_BUILD', - 'Announcing failed workflow in slack', - [{key: 'SLACK_WEBHOOK', value: '***'}], - ), - utils.createStepAssertion( - 'Exit failed workflow', - false, - '', - ), - ], - )); + expect(result).toEqual( + expect.arrayContaining([ + utils.createStepAssertion('Announce failed workflow in Slack', true, null, 'CONFIRM_PASSING_BUILD', 'Announcing failed workflow in slack', [ + {key: 'SLACK_WEBHOOK', value: '***'}, + ]), + utils.createStepAssertion('Exit failed workflow', false, ''), + ]), + ); assertions.assertChooseDeployActionsJobExecuted(result, false); assertions.assertSkipDeployJobExecuted(result, false); assertions.assertCreateNewVersionJobExecuted(result, false); @@ -251,24 +225,15 @@ describe('test workflow preDeploy', () => { 'push', {ref: 'refs/heads/main'}, { - OS_BOTIFY_TOKEN: 'dummy_token', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', + OS_BOTIFY_TOKEN: 'dummy_token', + SLACK_WEBHOOK: 'dummy_slack_webhook', + LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', }, 'dummy_github_token', ); const testMockSteps = { lint: mocks.LINT_JOB_MOCK_STEPS, - test: [ - utils.createMockStep( - 'Run test workflow', - 'Running test workflow - Test workflow failed', - 'TEST', - null, - null, - null, - null, - false, - ), - ], + test: [utils.createMockStep('Run test workflow', 'Running test workflow - Test workflow failed', 'TEST', null, null, null, null, false)], confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__CP_LABEL__STAGING_UNLOCKED, skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, @@ -278,43 +243,23 @@ describe('test workflow preDeploy', () => { newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, e2ePerformanceTests: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, }; - const result = await act - .runEvent('push', { - workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), - mockSteps: testMockSteps, - actor: 'Dummy Tester', - logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), - }); + const result = await act.runEvent('push', { + workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), + mockSteps: testMockSteps, + actor: 'Dummy Tester', + logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), + }); assertions.assertLintJobExecuted(result); - expect(result).toEqual(expect.arrayContaining( - [ - utils.createStepAssertion( - 'Run test workflow', - false, - null, - 'TEST', - 'Running test workflow - Test workflow failed', - ), - ], - )); + expect(result).toEqual(expect.arrayContaining([utils.createStepAssertion('Run test workflow', false, null, 'TEST', 'Running test workflow - Test workflow failed')])); assertions.assertIsExpensifyEmployeeJobExecuted(result); - expect(result).toEqual(expect.arrayContaining( - [ - utils.createStepAssertion( - 'Announce failed workflow in Slack', - true, - null, - 'CONFIRM_PASSING_BUILD', - 'Announcing failed workflow in slack', - [{key: 'SLACK_WEBHOOK', value: '***'}], - ), - utils.createStepAssertion( - 'Exit failed workflow', - false, - '', - ), - ], - )); + expect(result).toEqual( + expect.arrayContaining([ + utils.createStepAssertion('Announce failed workflow in Slack', true, null, 'CONFIRM_PASSING_BUILD', 'Announcing failed workflow in slack', [ + {key: 'SLACK_WEBHOOK', value: '***'}, + ]), + utils.createStepAssertion('Exit failed workflow', false, ''), + ]), + ); assertions.assertChooseDeployActionsJobExecuted(result, false); assertions.assertSkipDeployJobExecuted(result, false); assertions.assertCreateNewVersionJobExecuted(result, false); @@ -330,7 +275,9 @@ describe('test workflow preDeploy', () => { 'push', {ref: 'refs/heads/main'}, { - OS_BOTIFY_TOKEN: 'dummy_token', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', + OS_BOTIFY_TOKEN: 'dummy_token', + SLACK_WEBHOOK: 'dummy_slack_webhook', + LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', }, 'dummy_github_token', ); @@ -346,13 +293,12 @@ describe('test workflow preDeploy', () => { newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, e2ePerformanceTests: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, }; - const result = await act - .runEvent('push', { - workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), - mockSteps: testMockSteps, - actor: 'Dummy Tester', - logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), - }); + const result = await act.runEvent('push', { + workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), + mockSteps: testMockSteps, + actor: 'Dummy Tester', + logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), + }); assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); assertions.assertIsExpensifyEmployeeJobExecuted(result); @@ -373,7 +319,9 @@ describe('test workflow preDeploy', () => { 'push', {ref: 'refs/heads/main'}, { - OS_BOTIFY_TOKEN: 'dummy_token', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', + OS_BOTIFY_TOKEN: 'dummy_token', + SLACK_WEBHOOK: 'dummy_slack_webhook', + LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', }, 'dummy_github_token', ); @@ -389,13 +337,12 @@ describe('test workflow preDeploy', () => { newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__OSBOTIFY, e2ePerformanceTests: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, }; - const result = await act - .runEvent('push', { - workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), - mockSteps: testMockSteps, - actor: 'OSBotify', - logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), - }); + const result = await act.runEvent('push', { + workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), + mockSteps: testMockSteps, + actor: 'OSBotify', + logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), + }); assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); assertions.assertIsExpensifyEmployeeJobExecuted(result); @@ -412,7 +359,9 @@ describe('test workflow preDeploy', () => { 'push', {ref: 'refs/heads/main'}, { - OS_BOTIFY_TOKEN: 'dummy_token', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', + OS_BOTIFY_TOKEN: 'dummy_token', + SLACK_WEBHOOK: 'dummy_slack_webhook', + LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', }, 'dummy_github_token', ); @@ -428,13 +377,12 @@ describe('test workflow preDeploy', () => { newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, e2ePerformanceTests: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, }; - const result = await act - .runEvent('push', { - workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), - mockSteps: testMockSteps, - actor: 'Dummy Tester', - logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), - }); + const result = await act.runEvent('push', { + workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), + mockSteps: testMockSteps, + actor: 'Dummy Tester', + logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), + }); assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); assertions.assertIsExpensifyEmployeeJobExecuted(result); @@ -451,7 +399,9 @@ describe('test workflow preDeploy', () => { 'push', {ref: 'refs/heads/main'}, { - OS_BOTIFY_TOKEN: 'dummy_token', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', + OS_BOTIFY_TOKEN: 'dummy_token', + SLACK_WEBHOOK: 'dummy_slack_webhook', + LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', }, 'dummy_github_token', ); @@ -467,13 +417,12 @@ describe('test workflow preDeploy', () => { newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, e2ePerformanceTests: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, }; - const result = await act - .runEvent('push', { - workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), - mockSteps: testMockSteps, - actor: 'Dummy Tester', - logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), - }); + const result = await act.runEvent('push', { + workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), + mockSteps: testMockSteps, + actor: 'Dummy Tester', + logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), + }); assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); assertions.assertIsExpensifyEmployeeJobExecuted(result); @@ -490,7 +439,9 @@ describe('test workflow preDeploy', () => { 'push', {ref: 'refs/heads/main'}, { - OS_BOTIFY_TOKEN: 'dummy_token', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', + OS_BOTIFY_TOKEN: 'dummy_token', + SLACK_WEBHOOK: 'dummy_slack_webhook', + LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', }, 'dummy_github_token', ); @@ -506,13 +457,12 @@ describe('test workflow preDeploy', () => { newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__ONE_PR, e2ePerformanceTests: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, }; - const result = await act - .runEvent('push', { - workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), - mockSteps: testMockSteps, - actor: 'Dummy Tester', - logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), - }); + const result = await act.runEvent('push', { + workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), + mockSteps: testMockSteps, + actor: 'Dummy Tester', + logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), + }); assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); assertions.assertIsExpensifyEmployeeJobExecuted(result); @@ -528,13 +478,7 @@ describe('test workflow preDeploy', () => { const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); - act = utils.setUpActParams( - act, - 'push', - {ref: 'refs/heads/main'}, - {OS_BOTIFY_TOKEN: 'dummy_token', SLACK_WEBHOOK: 'dummy_slack_webhook'}, - 'dummy_github_token', - ); + act = utils.setUpActParams(act, 'push', {ref: 'refs/heads/main'}, {OS_BOTIFY_TOKEN: 'dummy_token', SLACK_WEBHOOK: 'dummy_slack_webhook'}, 'dummy_github_token'); const testMockSteps = { lint: mocks.LINT_JOB_MOCK_STEPS, test: mocks.TEST_JOB_MOCK_STEPS, @@ -547,13 +491,12 @@ describe('test workflow preDeploy', () => { newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, e2ePerformanceTests: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, }; - const result = await act - .runEvent('push', { - workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), - mockSteps: testMockSteps, - actor: 'Dummy Tester', - logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), - }); + const result = await act.runEvent('push', { + workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), + mockSteps: testMockSteps, + actor: 'Dummy Tester', + logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), + }); assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); assertions.assertIsExpensifyEmployeeJobExecuted(result); @@ -568,13 +511,7 @@ describe('test workflow preDeploy', () => { const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); - act = utils.setUpActParams( - act, - 'push', - {ref: 'refs/heads/main'}, - {OS_BOTIFY_TOKEN: 'dummy_token', SLACK_WEBHOOK: 'dummy_slack_webhook'}, - 'dummy_github_token', - ); + act = utils.setUpActParams(act, 'push', {ref: 'refs/heads/main'}, {OS_BOTIFY_TOKEN: 'dummy_token', SLACK_WEBHOOK: 'dummy_slack_webhook'}, 'dummy_github_token'); const testMockSteps = { lint: mocks.LINT_JOB_MOCK_STEPS, test: mocks.TEST_JOB_MOCK_STEPS, @@ -587,13 +524,12 @@ describe('test workflow preDeploy', () => { newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__OSBOTIFY, e2ePerformanceTests: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, }; - const result = await act - .runEvent('push', { - workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), - mockSteps: testMockSteps, - actor: 'OSBotify', - logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), - }); + const result = await act.runEvent('push', { + workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), + mockSteps: testMockSteps, + actor: 'OSBotify', + logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), + }); assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); assertions.assertIsExpensifyEmployeeJobExecuted(result); @@ -633,13 +569,12 @@ describe('test workflow preDeploy', () => { newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, e2ePerformanceTests: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, }; - const result = await act - .runEvent('push', { - workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), - mockSteps: testMockSteps, - actor: 'Dummy Tester', - logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), - }); + const result = await act.runEvent('push', { + workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), + mockSteps: testMockSteps, + actor: 'Dummy Tester', + logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), + }); assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); assertions.assertIsExpensifyEmployeeJobExecuted(result); @@ -676,13 +611,12 @@ describe('test workflow preDeploy', () => { newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__OSBOTIFY, e2ePerformanceTests: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, }; - const result = await act - .runEvent('push', { - workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), - mockSteps: testMockSteps, - actor: 'OSBotify', - logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), - }); + const result = await act.runEvent('push', { + workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), + mockSteps: testMockSteps, + actor: 'OSBotify', + logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), + }); assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); assertions.assertIsExpensifyEmployeeJobExecuted(result); @@ -724,13 +658,12 @@ describe('test workflow preDeploy', () => { newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, e2ePerformanceTests: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, }; - const result = await act - .runEvent('push', { - workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), - mockSteps: testMockSteps, - actor: 'Dummy Tester', - logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), - }); + const result = await act.runEvent('push', { + workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), + mockSteps: testMockSteps, + actor: 'Dummy Tester', + logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), + }); assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); assertions.assertIsExpensifyEmployeeJobExecuted(result); @@ -768,13 +701,12 @@ describe('test workflow preDeploy', () => { newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, e2ePerformanceTests: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, }; - const result = await act - .runEvent('push', { - workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), - mockSteps: testMockSteps, - actor: 'OSBotify', - logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), - }); + const result = await act.runEvent('push', { + workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), + mockSteps: testMockSteps, + actor: 'OSBotify', + logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), + }); assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); assertions.assertIsExpensifyEmployeeJobExecuted(result); @@ -814,13 +746,12 @@ describe('test workflow preDeploy', () => { newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, e2ePerformanceTests: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, }; - const result = await act - .runEvent('push', { - workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), - mockSteps: testMockSteps, - actor: 'Dummy Tester', - logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), - }); + const result = await act.runEvent('push', { + workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), + mockSteps: testMockSteps, + actor: 'Dummy Tester', + logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), + }); assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); assertions.assertIsExpensifyEmployeeJobExecuted(result); @@ -858,13 +789,12 @@ describe('test workflow preDeploy', () => { newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, e2ePerformanceTests: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, }; - const result = await act - .runEvent('push', { - workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), - mockSteps: testMockSteps, - actor: 'OSBotify', - logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), - }); + const result = await act.runEvent('push', { + workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), + mockSteps: testMockSteps, + actor: 'OSBotify', + logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), + }); assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); assertions.assertIsExpensifyEmployeeJobExecuted(result); @@ -886,7 +816,9 @@ describe('test workflow preDeploy', () => { 'push', {ref: 'refs/heads/main'}, { - OS_BOTIFY_TOKEN: 'dummy_token', SLACK_WEBHOOK: 'dummy_slack_webhook', LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', + OS_BOTIFY_TOKEN: 'dummy_token', + SLACK_WEBHOOK: 'dummy_slack_webhook', + LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', }, 'dummy_github_token', ); @@ -903,13 +835,12 @@ describe('test workflow preDeploy', () => { e2ePerformanceTests: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, }; testMockSteps.updateStaging[3].mockWith = 'exit 1'; - const result = await act - .runEvent('push', { - workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), - mockSteps: testMockSteps, - actor: 'OSBotify', - logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), - }); + const result = await act.runEvent('push', { + workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), + mockSteps: testMockSteps, + actor: 'OSBotify', + logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), + }); assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); assertions.assertIsExpensifyEmployeeJobExecuted(result); diff --git a/workflow_tests/reviewerChecklist.test.js b/workflow_tests/reviewerChecklist.test.js index 261842be282a..0136d80b5402 100644 --- a/workflow_tests/reviewerChecklist.test.js +++ b/workflow_tests/reviewerChecklist.test.js @@ -47,23 +47,16 @@ describe('test workflow reviewerChecklist', () => { const repoPath = mockGithub.repo.getPath('testReviewerChecklistWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'reviewerChecklist.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); - act = utils.setUpActParams( - act, - event, - eventOptions, - {}, - githubToken, - ); + act = utils.setUpActParams(act, event, eventOptions, {}, githubToken); const testMockSteps = { checklist: mocks.REVIEWERCHECKLIST__CHECKLIST__STEP_MOCKS, }; - const result = await act - .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'reviewerChecklist.yml'), - mockSteps: testMockSteps, - actor, - logFile: utils.getLogFilePath('reviewerChecklist', expect.getState().currentTestName), - }); + const result = await act.runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows', 'reviewerChecklist.yml'), + mockSteps: testMockSteps, + actor, + logFile: utils.getLogFilePath('reviewerChecklist', expect.getState().currentTestName), + }); assertions.assertChecklistJobExecuted(result); }); @@ -73,23 +66,16 @@ describe('test workflow reviewerChecklist', () => { const repoPath = mockGithub.repo.getPath('testReviewerChecklistWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'reviewerChecklist.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); - act = utils.setUpActParams( - act, - event, - eventOptions, - {}, - githubToken, - ); + act = utils.setUpActParams(act, event, eventOptions, {}, githubToken); const testMockSteps = { checklist: mocks.REVIEWERCHECKLIST__CHECKLIST__STEP_MOCKS, }; - const result = await act - .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'reviewerChecklist.yml'), - mockSteps: testMockSteps, - actor: osbotifyActor, - logFile: utils.getLogFilePath('reviewerChecklist', expect.getState().currentTestName), - }); + const result = await act.runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows', 'reviewerChecklist.yml'), + mockSteps: testMockSteps, + actor: osbotifyActor, + logFile: utils.getLogFilePath('reviewerChecklist', expect.getState().currentTestName), + }); assertions.assertChecklistJobExecuted(result, false); }); diff --git a/workflow_tests/test.test.js b/workflow_tests/test.test.js index f266ffa5e8d6..714c22d3f96a 100644 --- a/workflow_tests/test.test.js +++ b/workflow_tests/test.test.js @@ -52,24 +52,17 @@ describe('test workflow test', () => { const repoPath = mockGithub.repo.getPath('testTestWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'test.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); - act = utils.setUpActParams( - act, - event, - eventOptions, - {}, - githubToken, - ); + act = utils.setUpActParams(act, event, eventOptions, {}, githubToken); const testMockSteps = { jest: mocks.TEST__JEST__STEP_MOCKS, shellTests: mocks.TEST__SHELLTESTS__STEP_MOCKS, }; - const result = await act - .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'test.yml'), - mockSteps: testMockSteps, - actor, - logFile: utils.getLogFilePath('test', expect.getState().currentTestName), - }); + const result = await act.runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows', 'test.yml'), + mockSteps: testMockSteps, + actor, + logFile: utils.getLogFilePath('test', expect.getState().currentTestName), + }); assertions.assertJestJobExecuted(result); assertions.assertShellTestsJobExecuted(result); @@ -79,24 +72,17 @@ describe('test workflow test', () => { const repoPath = mockGithub.repo.getPath('testTestWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'test.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); - act = utils.setUpActParams( - act, - event, - eventOptions, - {}, - githubToken, - ); + act = utils.setUpActParams(act, event, eventOptions, {}, githubToken); const testMockSteps = { jest: mocks.TEST__JEST__STEP_MOCKS, shellTests: mocks.TEST__SHELLTESTS__STEP_MOCKS, }; - const result = await act - .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'test.yml'), - mockSteps: testMockSteps, - actor: osbotifyActor, - logFile: utils.getLogFilePath('test', expect.getState().currentTestName), - }); + const result = await act.runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows', 'test.yml'), + mockSteps: testMockSteps, + actor: osbotifyActor, + logFile: utils.getLogFilePath('test', expect.getState().currentTestName), + }); assertions.assertJestJobExecuted(result, false); assertions.assertShellTestsJobExecuted(result, false); @@ -113,24 +99,17 @@ describe('test workflow test', () => { const repoPath = mockGithub.repo.getPath('testTestWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'test.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); - act = utils.setUpActParams( - act, - event, - eventOptions, - {}, - githubToken, - ); + act = utils.setUpActParams(act, event, eventOptions, {}, githubToken); const testMockSteps = { jest: mocks.TEST__JEST__STEP_MOCKS, shellTests: mocks.TEST__SHELLTESTS__STEP_MOCKS, }; - const result = await act - .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'test.yml'), - mockSteps: testMockSteps, - actor, - logFile: utils.getLogFilePath('test', expect.getState().currentTestName), - }); + const result = await act.runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows', 'test.yml'), + mockSteps: testMockSteps, + actor, + logFile: utils.getLogFilePath('test', expect.getState().currentTestName), + }); assertions.assertJestJobExecuted(result); assertions.assertShellTestsJobExecuted(result); @@ -140,24 +119,17 @@ describe('test workflow test', () => { const repoPath = mockGithub.repo.getPath('testTestWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'test.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); - act = utils.setUpActParams( - act, - event, - eventOptions, - {}, - githubToken, - ); + act = utils.setUpActParams(act, event, eventOptions, {}, githubToken); const testMockSteps = { jest: mocks.TEST__JEST__STEP_MOCKS, shellTests: mocks.TEST__SHELLTESTS__STEP_MOCKS, }; - const result = await act - .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'test.yml'), - mockSteps: testMockSteps, - actor: osbotifyActor, - logFile: utils.getLogFilePath('test', expect.getState().currentTestName), - }); + const result = await act.runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows', 'test.yml'), + mockSteps: testMockSteps, + actor: osbotifyActor, + logFile: utils.getLogFilePath('test', expect.getState().currentTestName), + }); assertions.assertJestJobExecuted(result, false); assertions.assertShellTestsJobExecuted(result, false); @@ -172,24 +144,17 @@ describe('test workflow test', () => { const repoPath = mockGithub.repo.getPath('testTestWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'test.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); - act = utils.setUpActParams( - act, - event, - eventOptions, - {}, - githubToken, - ); + act = utils.setUpActParams(act, event, eventOptions, {}, githubToken); const testMockSteps = { jest: mocks.TEST__JEST__STEP_MOCKS, shellTests: mocks.TEST__SHELLTESTS__STEP_MOCKS, }; - const result = await act - .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'test.yml'), - mockSteps: testMockSteps, - actor, - logFile: utils.getLogFilePath('test', expect.getState().currentTestName), - }); + const result = await act.runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows', 'test.yml'), + mockSteps: testMockSteps, + actor, + logFile: utils.getLogFilePath('test', expect.getState().currentTestName), + }); assertions.assertJestJobExecuted(result); assertions.assertShellTestsJobExecuted(result); @@ -199,24 +164,17 @@ describe('test workflow test', () => { const repoPath = mockGithub.repo.getPath('testTestWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'test.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); - act = utils.setUpActParams( - act, - event, - eventOptions, - {}, - githubToken, - ); + act = utils.setUpActParams(act, event, eventOptions, {}, githubToken); const testMockSteps = { jest: mocks.TEST__JEST__STEP_MOCKS, shellTests: mocks.TEST__SHELLTESTS__STEP_MOCKS, }; - const result = await act - .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'test.yml'), - mockSteps: testMockSteps, - actor: osbotifyActor, - logFile: utils.getLogFilePath('test', expect.getState().currentTestName), - }); + const result = await act.runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows', 'test.yml'), + mockSteps: testMockSteps, + actor: osbotifyActor, + logFile: utils.getLogFilePath('test', expect.getState().currentTestName), + }); assertions.assertJestJobExecuted(result); assertions.assertShellTestsJobExecuted(result); diff --git a/workflow_tests/testBuild.test.js b/workflow_tests/testBuild.test.js index aca6f318252b..4caad7716427 100644 --- a/workflow_tests/testBuild.test.js +++ b/workflow_tests/testBuild.test.js @@ -61,20 +61,8 @@ describe('test workflow testBuild', () => { const repoPath = mockGithub.repo.getPath('testTestBuildWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'testBuild.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); - act = utils.setUpActParams( - act, - event, - {}, - secrets, - githubToken, - {}, - inputs, - ); - act = utils.setJobRunners( - act, - {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest'}, - workflowPath, - ); + act = utils.setUpActParams(act, event, {}, secrets, githubToken, {}, inputs); + act = utils.setJobRunners(act, {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest'}, workflowPath); const testMockSteps = { validateActor: mocks.TESTBUILD__VALIDATEACTOR__TEAM_MEMBER_HAS_FLAG__STEP_MOCKS, getBranchRef: mocks.TESTBUILD__GETBRANCHREF__STEP_MOCKS, @@ -84,13 +72,12 @@ describe('test workflow testBuild', () => { web: mocks.TESTBUILD__WEB__STEP_MOCKS, postGithubComment: mocks.TESTBUILD__POSTGITHUBCOMMENT__STEP_MOCKS, }; - const result = await act - .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'testBuild.yml'), - mockSteps: testMockSteps, - actor, - logFile: utils.getLogFilePath('testBuild', expect.getState().currentTestName), - }); + const result = await act.runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows', 'testBuild.yml'), + mockSteps: testMockSteps, + actor, + logFile: utils.getLogFilePath('testBuild', expect.getState().currentTestName), + }); assertions.assertValidateActorJobExecuted(result, actor, '1234'); assertions.assertGetBranchRefJobExecuted(result); @@ -105,20 +92,8 @@ describe('test workflow testBuild', () => { const repoPath = mockGithub.repo.getPath('testTestBuildWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'testBuild.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); - act = utils.setUpActParams( - act, - event, - {}, - secrets, - githubToken, - {}, - inputs, - ); - act = utils.setJobRunners( - act, - {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest'}, - workflowPath, - ); + act = utils.setUpActParams(act, event, {}, secrets, githubToken, {}, inputs); + act = utils.setJobRunners(act, {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest'}, workflowPath); const testMockSteps = { validateActor: mocks.TESTBUILD__VALIDATEACTOR__NO_TEAM_MEMBER_HAS_FLAG__STEP_MOCKS, getBranchRef: mocks.TESTBUILD__GETBRANCHREF__STEP_MOCKS, @@ -128,13 +103,12 @@ describe('test workflow testBuild', () => { web: mocks.TESTBUILD__WEB__STEP_MOCKS, postGithubComment: mocks.TESTBUILD__POSTGITHUBCOMMENT__STEP_MOCKS, }; - const result = await act - .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'testBuild.yml'), - mockSteps: testMockSteps, - actor, - logFile: utils.getLogFilePath('testBuild', expect.getState().currentTestName), - }); + const result = await act.runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows', 'testBuild.yml'), + mockSteps: testMockSteps, + actor, + logFile: utils.getLogFilePath('testBuild', expect.getState().currentTestName), + }); assertions.assertValidateActorJobExecuted(result, actor, '1234'); assertions.assertGetBranchRefJobExecuted(result, false); @@ -150,20 +124,8 @@ describe('test workflow testBuild', () => { const repoPath = mockGithub.repo.getPath('testTestBuildWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'testBuild.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); - act = utils.setUpActParams( - act, - event, - {}, - secrets, - githubToken, - {}, - inputs, - ); - act = utils.setJobRunners( - act, - {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest'}, - workflowPath, - ); + act = utils.setUpActParams(act, event, {}, secrets, githubToken, {}, inputs); + act = utils.setJobRunners(act, {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest'}, workflowPath); const testMockSteps = { validateActor: mocks.TESTBUILD__VALIDATEACTOR__TEAM_MEMBER_NO_FLAG__STEP_MOCKS, getBranchRef: mocks.TESTBUILD__GETBRANCHREF__STEP_MOCKS, @@ -173,13 +135,12 @@ describe('test workflow testBuild', () => { web: mocks.TESTBUILD__WEB__STEP_MOCKS, postGithubComment: mocks.TESTBUILD__POSTGITHUBCOMMENT__STEP_MOCKS, }; - const result = await act - .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'testBuild.yml'), - mockSteps: testMockSteps, - actor, - logFile: utils.getLogFilePath('testBuild', expect.getState().currentTestName), - }); + const result = await act.runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows', 'testBuild.yml'), + mockSteps: testMockSteps, + actor, + logFile: utils.getLogFilePath('testBuild', expect.getState().currentTestName), + }); assertions.assertValidateActorJobExecuted(result, actor, '1234'); assertions.assertGetBranchRefJobExecuted(result, false); @@ -195,20 +156,8 @@ describe('test workflow testBuild', () => { const repoPath = mockGithub.repo.getPath('testTestBuildWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'testBuild.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); - act = utils.setUpActParams( - act, - event, - {}, - secrets, - githubToken, - {}, - inputs, - ); - act = utils.setJobRunners( - act, - {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest'}, - workflowPath, - ); + act = utils.setUpActParams(act, event, {}, secrets, githubToken, {}, inputs); + act = utils.setJobRunners(act, {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest'}, workflowPath); const testMockSteps = { validateActor: mocks.TESTBUILD__VALIDATEACTOR__NO_TEAM_MEMBER_NO_FLAG__STEP_MOCKS, getBranchRef: mocks.TESTBUILD__GETBRANCHREF__STEP_MOCKS, @@ -218,13 +167,12 @@ describe('test workflow testBuild', () => { web: mocks.TESTBUILD__WEB__STEP_MOCKS, postGithubComment: mocks.TESTBUILD__POSTGITHUBCOMMENT__STEP_MOCKS, }; - const result = await act - .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'testBuild.yml'), - mockSteps: testMockSteps, - actor, - logFile: utils.getLogFilePath('testBuild', expect.getState().currentTestName), - }); + const result = await act.runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows', 'testBuild.yml'), + mockSteps: testMockSteps, + actor, + logFile: utils.getLogFilePath('testBuild', expect.getState().currentTestName), + }); assertions.assertValidateActorJobExecuted(result, actor, '1234'); assertions.assertGetBranchRefJobExecuted(result, false); @@ -240,20 +188,8 @@ describe('test workflow testBuild', () => { const repoPath = mockGithub.repo.getPath('testTestBuildWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'testBuild.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); - act = utils.setUpActParams( - act, - event, - {}, - secrets, - githubToken, - {}, - inputs, - ); - act = utils.setJobRunners( - act, - {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest'}, - workflowPath, - ); + act = utils.setUpActParams(act, event, {}, secrets, githubToken, {}, inputs); + act = utils.setJobRunners(act, {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest'}, workflowPath); const testMockSteps = { validateActor: mocks.TESTBUILD__VALIDATEACTOR__TEAM_MEMBER_HAS_FLAG__STEP_MOCKS, getBranchRef: mocks.TESTBUILD__GETBRANCHREF__STEP_MOCKS, @@ -263,23 +199,13 @@ describe('test workflow testBuild', () => { web: mocks.TESTBUILD__WEB__STEP_MOCKS, postGithubComment: mocks.TESTBUILD__POSTGITHUBCOMMENT__STEP_MOCKS, }; - testMockSteps.android[4] = utils.createMockStep( - 'Decrypt keystore', - 'Decrypt keystore', - 'ANDROID', - [], - ['LARGE_SECRET_PASSPHRASE'], - {}, - {}, - false, - ); - const result = await act - .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'testBuild.yml'), - mockSteps: testMockSteps, - actor, - logFile: utils.getLogFilePath('testBuild', expect.getState().currentTestName), - }); + testMockSteps.android[4] = utils.createMockStep('Decrypt keystore', 'Decrypt keystore', 'ANDROID', [], ['LARGE_SECRET_PASSPHRASE'], {}, {}, false); + const result = await act.runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows', 'testBuild.yml'), + mockSteps: testMockSteps, + actor, + logFile: utils.getLogFilePath('testBuild', expect.getState().currentTestName), + }); assertions.assertValidateActorJobExecuted(result, actor, '1234'); assertions.assertGetBranchRefJobExecuted(result); @@ -295,20 +221,8 @@ describe('test workflow testBuild', () => { const repoPath = mockGithub.repo.getPath('testTestBuildWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'testBuild.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); - act = utils.setUpActParams( - act, - event, - {}, - secrets, - githubToken, - {}, - inputs, - ); - act = utils.setJobRunners( - act, - {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest'}, - workflowPath, - ); + act = utils.setUpActParams(act, event, {}, secrets, githubToken, {}, inputs); + act = utils.setJobRunners(act, {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest'}, workflowPath); const testMockSteps = { validateActor: mocks.TESTBUILD__VALIDATEACTOR__TEAM_MEMBER_HAS_FLAG__STEP_MOCKS, getBranchRef: mocks.TESTBUILD__GETBRANCHREF__STEP_MOCKS, @@ -318,23 +232,13 @@ describe('test workflow testBuild', () => { web: mocks.TESTBUILD__WEB__STEP_MOCKS, postGithubComment: mocks.TESTBUILD__POSTGITHUBCOMMENT__STEP_MOCKS, }; - testMockSteps.iOS[5] = utils.createMockStep( - 'Install cocoapods', - 'Install cocoapods', - 'IOS', - ['timeout_minutes', 'max_attempts', 'command'], - [], - {}, - {}, - false, - ); - const result = await act - .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'testBuild.yml'), - mockSteps: testMockSteps, - actor, - logFile: utils.getLogFilePath('testBuild', expect.getState().currentTestName), - }); + testMockSteps.iOS[5] = utils.createMockStep('Install cocoapods', 'Install cocoapods', 'IOS', ['timeout_minutes', 'max_attempts', 'command'], [], {}, {}, false); + const result = await act.runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows', 'testBuild.yml'), + mockSteps: testMockSteps, + actor, + logFile: utils.getLogFilePath('testBuild', expect.getState().currentTestName), + }); assertions.assertValidateActorJobExecuted(result, actor, '1234'); assertions.assertGetBranchRefJobExecuted(result); @@ -350,20 +254,8 @@ describe('test workflow testBuild', () => { const repoPath = mockGithub.repo.getPath('testTestBuildWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'testBuild.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); - act = utils.setUpActParams( - act, - event, - {}, - secrets, - githubToken, - {}, - inputs, - ); - act = utils.setJobRunners( - act, - {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest'}, - workflowPath, - ); + act = utils.setUpActParams(act, event, {}, secrets, githubToken, {}, inputs); + act = utils.setJobRunners(act, {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest'}, workflowPath); const testMockSteps = { validateActor: mocks.TESTBUILD__VALIDATEACTOR__TEAM_MEMBER_HAS_FLAG__STEP_MOCKS, getBranchRef: mocks.TESTBUILD__GETBRANCHREF__STEP_MOCKS, @@ -383,13 +275,12 @@ describe('test workflow testBuild', () => { {}, false, ); - const result = await act - .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'testBuild.yml'), - mockSteps: testMockSteps, - actor, - logFile: utils.getLogFilePath('testBuild', expect.getState().currentTestName), - }); + const result = await act.runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows', 'testBuild.yml'), + mockSteps: testMockSteps, + actor, + logFile: utils.getLogFilePath('testBuild', expect.getState().currentTestName), + }); assertions.assertValidateActorJobExecuted(result, actor, '1234'); assertions.assertGetBranchRefJobExecuted(result); @@ -405,20 +296,8 @@ describe('test workflow testBuild', () => { const repoPath = mockGithub.repo.getPath('testTestBuildWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'testBuild.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); - act = utils.setUpActParams( - act, - event, - {}, - secrets, - githubToken, - {}, - inputs, - ); - act = utils.setJobRunners( - act, - {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest'}, - workflowPath, - ); + act = utils.setUpActParams(act, event, {}, secrets, githubToken, {}, inputs); + act = utils.setJobRunners(act, {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest'}, workflowPath); const testMockSteps = { validateActor: mocks.TESTBUILD__VALIDATEACTOR__TEAM_MEMBER_HAS_FLAG__STEP_MOCKS, getBranchRef: mocks.TESTBUILD__GETBRANCHREF__STEP_MOCKS, @@ -438,13 +317,12 @@ describe('test workflow testBuild', () => { {}, false, ); - const result = await act - .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'testBuild.yml'), - mockSteps: testMockSteps, - actor, - logFile: utils.getLogFilePath('testBuild', expect.getState().currentTestName), - }); + const result = await act.runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows', 'testBuild.yml'), + mockSteps: testMockSteps, + actor, + logFile: utils.getLogFilePath('testBuild', expect.getState().currentTestName), + }); assertions.assertValidateActorJobExecuted(result, actor, '1234'); assertions.assertGetBranchRefJobExecuted(result); @@ -471,19 +349,8 @@ describe('test workflow testBuild', () => { const repoPath = mockGithub.repo.getPath('testTestBuildWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'testBuild.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); - act = utils.setUpActParams( - act, - event, - eventOptions, - secrets, - githubToken, - {}, - ); - act = utils.setJobRunners( - act, - {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest'}, - workflowPath, - ); + act = utils.setUpActParams(act, event, eventOptions, secrets, githubToken, {}); + act = utils.setJobRunners(act, {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest'}, workflowPath); const testMockSteps = { validateActor: mocks.TESTBUILD__VALIDATEACTOR__TEAM_MEMBER_HAS_FLAG__STEP_MOCKS, getBranchRef: mocks.TESTBUILD__GETBRANCHREF__STEP_MOCKS, @@ -493,13 +360,12 @@ describe('test workflow testBuild', () => { web: mocks.TESTBUILD__WEB__STEP_MOCKS, postGithubComment: mocks.TESTBUILD__POSTGITHUBCOMMENT__STEP_MOCKS, }; - const result = await act - .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'testBuild.yml'), - mockSteps: testMockSteps, - actor, - logFile: utils.getLogFilePath('testBuild', expect.getState().currentTestName), - }); + const result = await act.runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows', 'testBuild.yml'), + mockSteps: testMockSteps, + actor, + logFile: utils.getLogFilePath('testBuild', expect.getState().currentTestName), + }); assertions.assertValidateActorJobExecuted(result, actor, '1234'); assertions.assertGetBranchRefJobExecuted(result, false); @@ -514,19 +380,8 @@ describe('test workflow testBuild', () => { const repoPath = mockGithub.repo.getPath('testTestBuildWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'testBuild.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); - act = utils.setUpActParams( - act, - event, - eventOptions, - secrets, - githubToken, - {}, - ); - act = utils.setJobRunners( - act, - {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest'}, - workflowPath, - ); + act = utils.setUpActParams(act, event, eventOptions, secrets, githubToken, {}); + act = utils.setJobRunners(act, {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest'}, workflowPath); const testMockSteps = { validateActor: mocks.TESTBUILD__VALIDATEACTOR__NO_TEAM_MEMBER_HAS_FLAG__STEP_MOCKS, getBranchRef: mocks.TESTBUILD__GETBRANCHREF__STEP_MOCKS, @@ -536,13 +391,12 @@ describe('test workflow testBuild', () => { web: mocks.TESTBUILD__WEB__STEP_MOCKS, postGithubComment: mocks.TESTBUILD__POSTGITHUBCOMMENT__STEP_MOCKS, }; - const result = await act - .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'testBuild.yml'), - mockSteps: testMockSteps, - actor, - logFile: utils.getLogFilePath('testBuild', expect.getState().currentTestName), - }); + const result = await act.runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows', 'testBuild.yml'), + mockSteps: testMockSteps, + actor, + logFile: utils.getLogFilePath('testBuild', expect.getState().currentTestName), + }); assertions.assertValidateActorJobExecuted(result, actor, '1234'); assertions.assertGetBranchRefJobExecuted(result, false); @@ -558,19 +412,8 @@ describe('test workflow testBuild', () => { const repoPath = mockGithub.repo.getPath('testTestBuildWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'testBuild.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); - act = utils.setUpActParams( - act, - event, - eventOptions, - secrets, - githubToken, - {}, - ); - act = utils.setJobRunners( - act, - {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest'}, - workflowPath, - ); + act = utils.setUpActParams(act, event, eventOptions, secrets, githubToken, {}); + act = utils.setJobRunners(act, {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest'}, workflowPath); const testMockSteps = { validateActor: mocks.TESTBUILD__VALIDATEACTOR__TEAM_MEMBER_NO_FLAG__STEP_MOCKS, getBranchRef: mocks.TESTBUILD__GETBRANCHREF__STEP_MOCKS, @@ -580,13 +423,12 @@ describe('test workflow testBuild', () => { web: mocks.TESTBUILD__WEB__STEP_MOCKS, postGithubComment: mocks.TESTBUILD__POSTGITHUBCOMMENT__STEP_MOCKS, }; - const result = await act - .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'testBuild.yml'), - mockSteps: testMockSteps, - actor, - logFile: utils.getLogFilePath('testBuild', expect.getState().currentTestName), - }); + const result = await act.runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows', 'testBuild.yml'), + mockSteps: testMockSteps, + actor, + logFile: utils.getLogFilePath('testBuild', expect.getState().currentTestName), + }); assertions.assertValidateActorJobExecuted(result, actor, '1234'); assertions.assertGetBranchRefJobExecuted(result, false); @@ -602,19 +444,8 @@ describe('test workflow testBuild', () => { const repoPath = mockGithub.repo.getPath('testTestBuildWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'testBuild.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); - act = utils.setUpActParams( - act, - event, - eventOptions, - secrets, - githubToken, - {}, - ); - act = utils.setJobRunners( - act, - {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest'}, - workflowPath, - ); + act = utils.setUpActParams(act, event, eventOptions, secrets, githubToken, {}); + act = utils.setJobRunners(act, {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest'}, workflowPath); const testMockSteps = { validateActor: mocks.TESTBUILD__VALIDATEACTOR__NO_TEAM_MEMBER_NO_FLAG__STEP_MOCKS, getBranchRef: mocks.TESTBUILD__GETBRANCHREF__STEP_MOCKS, @@ -624,13 +455,12 @@ describe('test workflow testBuild', () => { web: mocks.TESTBUILD__WEB__STEP_MOCKS, postGithubComment: mocks.TESTBUILD__POSTGITHUBCOMMENT__STEP_MOCKS, }; - const result = await act - .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'testBuild.yml'), - mockSteps: testMockSteps, - actor, - logFile: utils.getLogFilePath('testBuild', expect.getState().currentTestName), - }); + const result = await act.runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows', 'testBuild.yml'), + mockSteps: testMockSteps, + actor, + logFile: utils.getLogFilePath('testBuild', expect.getState().currentTestName), + }); assertions.assertValidateActorJobExecuted(result, actor, '1234'); assertions.assertGetBranchRefJobExecuted(result, false); @@ -657,19 +487,8 @@ describe('test workflow testBuild', () => { const repoPath = mockGithub.repo.getPath('testTestBuildWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'testBuild.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); - act = utils.setUpActParams( - act, - event, - eventOptions, - secrets, - githubToken, - {}, - ); - act = utils.setJobRunners( - act, - {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest'}, - workflowPath, - ); + act = utils.setUpActParams(act, event, eventOptions, secrets, githubToken, {}); + act = utils.setJobRunners(act, {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest'}, workflowPath); const testMockSteps = { validateActor: mocks.TESTBUILD__VALIDATEACTOR__TEAM_MEMBER_HAS_FLAG__STEP_MOCKS, getBranchRef: mocks.TESTBUILD__GETBRANCHREF__STEP_MOCKS, @@ -679,13 +498,12 @@ describe('test workflow testBuild', () => { web: mocks.TESTBUILD__WEB__STEP_MOCKS, postGithubComment: mocks.TESTBUILD__POSTGITHUBCOMMENT__STEP_MOCKS, }; - const result = await act - .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'testBuild.yml'), - mockSteps: testMockSteps, - actor, - logFile: utils.getLogFilePath('testBuild', expect.getState().currentTestName), - }); + const result = await act.runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows', 'testBuild.yml'), + mockSteps: testMockSteps, + actor, + logFile: utils.getLogFilePath('testBuild', expect.getState().currentTestName), + }); assertions.assertValidateActorJobExecuted(result, actor, '1234'); assertions.assertGetBranchRefJobExecuted(result, false); @@ -700,19 +518,8 @@ describe('test workflow testBuild', () => { const repoPath = mockGithub.repo.getPath('testTestBuildWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'testBuild.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); - act = utils.setUpActParams( - act, - event, - eventOptions, - secrets, - githubToken, - {}, - ); - act = utils.setJobRunners( - act, - {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest'}, - workflowPath, - ); + act = utils.setUpActParams(act, event, eventOptions, secrets, githubToken, {}); + act = utils.setJobRunners(act, {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest'}, workflowPath); const testMockSteps = { validateActor: mocks.TESTBUILD__VALIDATEACTOR__NO_TEAM_MEMBER_HAS_FLAG__STEP_MOCKS, getBranchRef: mocks.TESTBUILD__GETBRANCHREF__STEP_MOCKS, @@ -722,13 +529,12 @@ describe('test workflow testBuild', () => { web: mocks.TESTBUILD__WEB__STEP_MOCKS, postGithubComment: mocks.TESTBUILD__POSTGITHUBCOMMENT__STEP_MOCKS, }; - const result = await act - .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'testBuild.yml'), - mockSteps: testMockSteps, - actor, - logFile: utils.getLogFilePath('testBuild', expect.getState().currentTestName), - }); + const result = await act.runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows', 'testBuild.yml'), + mockSteps: testMockSteps, + actor, + logFile: utils.getLogFilePath('testBuild', expect.getState().currentTestName), + }); assertions.assertValidateActorJobExecuted(result, actor, '1234'); assertions.assertGetBranchRefJobExecuted(result, false); @@ -744,19 +550,8 @@ describe('test workflow testBuild', () => { const repoPath = mockGithub.repo.getPath('testTestBuildWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'testBuild.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); - act = utils.setUpActParams( - act, - event, - eventOptions, - secrets, - githubToken, - {}, - ); - act = utils.setJobRunners( - act, - {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest'}, - workflowPath, - ); + act = utils.setUpActParams(act, event, eventOptions, secrets, githubToken, {}); + act = utils.setJobRunners(act, {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest'}, workflowPath); const testMockSteps = { validateActor: mocks.TESTBUILD__VALIDATEACTOR__TEAM_MEMBER_NO_FLAG__STEP_MOCKS, getBranchRef: mocks.TESTBUILD__GETBRANCHREF__STEP_MOCKS, @@ -766,13 +561,12 @@ describe('test workflow testBuild', () => { web: mocks.TESTBUILD__WEB__STEP_MOCKS, postGithubComment: mocks.TESTBUILD__POSTGITHUBCOMMENT__STEP_MOCKS, }; - const result = await act - .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'testBuild.yml'), - mockSteps: testMockSteps, - actor, - logFile: utils.getLogFilePath('testBuild', expect.getState().currentTestName), - }); + const result = await act.runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows', 'testBuild.yml'), + mockSteps: testMockSteps, + actor, + logFile: utils.getLogFilePath('testBuild', expect.getState().currentTestName), + }); assertions.assertValidateActorJobExecuted(result, actor, '1234'); assertions.assertGetBranchRefJobExecuted(result, false); @@ -788,19 +582,8 @@ describe('test workflow testBuild', () => { const repoPath = mockGithub.repo.getPath('testTestBuildWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'testBuild.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); - act = utils.setUpActParams( - act, - event, - eventOptions, - secrets, - githubToken, - {}, - ); - act = utils.setJobRunners( - act, - {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest'}, - workflowPath, - ); + act = utils.setUpActParams(act, event, eventOptions, secrets, githubToken, {}); + act = utils.setJobRunners(act, {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest'}, workflowPath); const testMockSteps = { validateActor: mocks.TESTBUILD__VALIDATEACTOR__NO_TEAM_MEMBER_NO_FLAG__STEP_MOCKS, getBranchRef: mocks.TESTBUILD__GETBRANCHREF__STEP_MOCKS, @@ -810,13 +593,12 @@ describe('test workflow testBuild', () => { web: mocks.TESTBUILD__WEB__STEP_MOCKS, postGithubComment: mocks.TESTBUILD__POSTGITHUBCOMMENT__STEP_MOCKS, }; - const result = await act - .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'testBuild.yml'), - mockSteps: testMockSteps, - actor, - logFile: utils.getLogFilePath('testBuild', expect.getState().currentTestName), - }); + const result = await act.runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows', 'testBuild.yml'), + mockSteps: testMockSteps, + actor, + logFile: utils.getLogFilePath('testBuild', expect.getState().currentTestName), + }); assertions.assertValidateActorJobExecuted(result, actor, '1234'); assertions.assertGetBranchRefJobExecuted(result, false); @@ -843,19 +625,8 @@ describe('test workflow testBuild', () => { const repoPath = mockGithub.repo.getPath('testTestBuildWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'testBuild.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); - act = utils.setUpActParams( - act, - event, - eventOptions, - secrets, - githubToken, - {}, - ); - act = utils.setJobRunners( - act, - {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest'}, - workflowPath, - ); + act = utils.setUpActParams(act, event, eventOptions, secrets, githubToken, {}); + act = utils.setJobRunners(act, {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest'}, workflowPath); const testMockSteps = { validateActor: mocks.TESTBUILD__VALIDATEACTOR__TEAM_MEMBER_HAS_FLAG__STEP_MOCKS, getBranchRef: mocks.TESTBUILD__GETBRANCHREF__STEP_MOCKS, @@ -865,13 +636,12 @@ describe('test workflow testBuild', () => { web: mocks.TESTBUILD__WEB__STEP_MOCKS, postGithubComment: mocks.TESTBUILD__POSTGITHUBCOMMENT__STEP_MOCKS, }; - const result = await act - .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'testBuild.yml'), - mockSteps: testMockSteps, - actor, - logFile: utils.getLogFilePath('testBuild', expect.getState().currentTestName), - }); + const result = await act.runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows', 'testBuild.yml'), + mockSteps: testMockSteps, + actor, + logFile: utils.getLogFilePath('testBuild', expect.getState().currentTestName), + }); assertions.assertValidateActorJobExecuted(result, actor, '1234'); assertions.assertGetBranchRefJobExecuted(result, false); @@ -886,19 +656,8 @@ describe('test workflow testBuild', () => { const repoPath = mockGithub.repo.getPath('testTestBuildWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'testBuild.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); - act = utils.setUpActParams( - act, - event, - eventOptions, - secrets, - githubToken, - {}, - ); - act = utils.setJobRunners( - act, - {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest'}, - workflowPath, - ); + act = utils.setUpActParams(act, event, eventOptions, secrets, githubToken, {}); + act = utils.setJobRunners(act, {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest'}, workflowPath); const testMockSteps = { validateActor: mocks.TESTBUILD__VALIDATEACTOR__NO_TEAM_MEMBER_HAS_FLAG__STEP_MOCKS, getBranchRef: mocks.TESTBUILD__GETBRANCHREF__STEP_MOCKS, @@ -908,13 +667,12 @@ describe('test workflow testBuild', () => { web: mocks.TESTBUILD__WEB__STEP_MOCKS, postGithubComment: mocks.TESTBUILD__POSTGITHUBCOMMENT__STEP_MOCKS, }; - const result = await act - .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'testBuild.yml'), - mockSteps: testMockSteps, - actor, - logFile: utils.getLogFilePath('testBuild', expect.getState().currentTestName), - }); + const result = await act.runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows', 'testBuild.yml'), + mockSteps: testMockSteps, + actor, + logFile: utils.getLogFilePath('testBuild', expect.getState().currentTestName), + }); assertions.assertValidateActorJobExecuted(result, actor, '1234'); assertions.assertGetBranchRefJobExecuted(result, false); @@ -930,19 +688,8 @@ describe('test workflow testBuild', () => { const repoPath = mockGithub.repo.getPath('testTestBuildWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'testBuild.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); - act = utils.setUpActParams( - act, - event, - eventOptions, - secrets, - githubToken, - {}, - ); - act = utils.setJobRunners( - act, - {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest'}, - workflowPath, - ); + act = utils.setUpActParams(act, event, eventOptions, secrets, githubToken, {}); + act = utils.setJobRunners(act, {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest'}, workflowPath); const testMockSteps = { validateActor: mocks.TESTBUILD__VALIDATEACTOR__TEAM_MEMBER_NO_FLAG__STEP_MOCKS, getBranchRef: mocks.TESTBUILD__GETBRANCHREF__STEP_MOCKS, @@ -952,13 +699,12 @@ describe('test workflow testBuild', () => { web: mocks.TESTBUILD__WEB__STEP_MOCKS, postGithubComment: mocks.TESTBUILD__POSTGITHUBCOMMENT__STEP_MOCKS, }; - const result = await act - .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'testBuild.yml'), - mockSteps: testMockSteps, - actor, - logFile: utils.getLogFilePath('testBuild', expect.getState().currentTestName), - }); + const result = await act.runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows', 'testBuild.yml'), + mockSteps: testMockSteps, + actor, + logFile: utils.getLogFilePath('testBuild', expect.getState().currentTestName), + }); assertions.assertValidateActorJobExecuted(result, actor, '1234'); assertions.assertGetBranchRefJobExecuted(result, false); @@ -974,19 +720,8 @@ describe('test workflow testBuild', () => { const repoPath = mockGithub.repo.getPath('testTestBuildWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'testBuild.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); - act = utils.setUpActParams( - act, - event, - eventOptions, - secrets, - githubToken, - {}, - ); - act = utils.setJobRunners( - act, - {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest'}, - workflowPath, - ); + act = utils.setUpActParams(act, event, eventOptions, secrets, githubToken, {}); + act = utils.setJobRunners(act, {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest'}, workflowPath); const testMockSteps = { validateActor: mocks.TESTBUILD__VALIDATEACTOR__NO_TEAM_MEMBER_NO_FLAG__STEP_MOCKS, getBranchRef: mocks.TESTBUILD__GETBRANCHREF__STEP_MOCKS, @@ -996,13 +731,12 @@ describe('test workflow testBuild', () => { web: mocks.TESTBUILD__WEB__STEP_MOCKS, postGithubComment: mocks.TESTBUILD__POSTGITHUBCOMMENT__STEP_MOCKS, }; - const result = await act - .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'testBuild.yml'), - mockSteps: testMockSteps, - actor, - logFile: utils.getLogFilePath('testBuild', expect.getState().currentTestName), - }); + const result = await act.runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows', 'testBuild.yml'), + mockSteps: testMockSteps, + actor, + logFile: utils.getLogFilePath('testBuild', expect.getState().currentTestName), + }); assertions.assertValidateActorJobExecuted(result, actor, '1234'); assertions.assertGetBranchRefJobExecuted(result, false); diff --git a/workflow_tests/utils/preGenerateTest.js b/workflow_tests/utils/preGenerateTest.js index 61d937119f6b..7bfd5b382267 100644 --- a/workflow_tests/utils/preGenerateTest.js +++ b/workflow_tests/utils/preGenerateTest.js @@ -12,7 +12,7 @@ const workflowTestAssertionsDirectory = path.join(workflowTestsDirectory, 'asser const workflowFilePattern = '\\w+\\.yml'; const workflowFileRegex = new RegExp(workflowFilePattern, 'g'); -const capitalize = s => (s && s.charAt(0).toUpperCase() + s.slice(1)) || ''; +const capitalize = (s) => (s && s.charAt(0).toUpperCase() + s.slice(1)) || ''; const mockFileTemplate = (mockSteps, exports) => `const utils = require('../utils/utils'); ${mockSteps} ${exports} @@ -21,7 +21,7 @@ const assertionFileTemplate = (jobAssertions, exports) => `const utils = require ${jobAssertions} ${exports} `; -const testFileTemplate = workflowName => `const path = require('path'); +const testFileTemplate = (workflowName) => `const path = require('path'); const kieMockGithub = require('@kie/mock-github'); const utils = require('./utils/utils'); const assertions = require('./assertions/${workflowName}Assertions'); @@ -111,12 +111,14 @@ const stepAssertionTemplate = (step_name, job_id, step_message, inputs, envs) => null, '${job_id}', '${step_message}', - [${_(inputs).map(input => `{key: '${input}', value: '[FILL_IN]'}`)}], - [${_(envs).map(env => `{key: '${env}', value: '[FILL_IN]'}`)}], + [${_(inputs).map((input) => `{key: '${input}', value: '[FILL_IN]'}`)}], + [${_(envs).map((env) => `{key: '${env}', value: '[FILL_IN]'}`)}], ),`; const jobMocksTemplate = (jobMocksName, stepMocks) => ` -const ${jobMocksName} = [${_(stepMocks).map(stepMock => ` - ${stepMock}`)} +const ${jobMocksName} = [${_(stepMocks).map( + (stepMock) => ` + ${stepMock}`, +)} ];`; const jobAssertionTemplate = (jobAssertionName, stepAssertions) => ` const ${jobAssertionName} = (workflowResult, didExecute = true) => { @@ -131,13 +133,13 @@ const ${jobAssertionName} = (workflowResult, didExecute = true) => { } } };`; -const mocksExportsTemplate = jobMocks => ` +const mocksExportsTemplate = (jobMocks) => ` module.exports = { - ${_(jobMocks).map(jobMock => `${jobMock}`)} + ${_(jobMocks).map((jobMock) => `${jobMock}`)} };`; -const assertionsExportsTemplate = jobAssertions => ` +const assertionsExportsTemplate = (jobAssertions) => ` module.exports = { - ${_(jobAssertions).map(jobAssertion => `${jobAssertion}`)} + ${_(jobAssertions).map((jobAssertion) => `${jobAssertion}`)} };`; const checkArguments = (args) => { @@ -206,7 +208,11 @@ const getMockFileContent = (workflowName, jobs) => { let mockStepsContent = `\n// ${jobId.toLowerCase()}`; const stepMocks = []; job.steps.forEach((step) => { - const stepMockName = `${workflowName.toUpperCase()}__${jobId.toUpperCase()}__${step.name.replaceAll(' ', '_').replaceAll('-', '_').replaceAll(',', '').replaceAll('#', '') + const stepMockName = `${workflowName.toUpperCase()}__${jobId.toUpperCase()}__${step.name + .replaceAll(' ', '_') + .replaceAll('-', '_') + .replaceAll(',', '') + .replaceAll('#', '') .toUpperCase()}__STEP_MOCK`; stepMocks.push(stepMockName); mockStepsContent += mockStepTemplate(stepMockName, step, jobId); @@ -232,7 +238,7 @@ const getAssertionsFileContent = (workflowName, jobs) => { }); return assertionFileTemplate(content, assertionsExportsTemplate(jobAssertions)); }; -const getTestFileContent = workflowName => testFileTemplate(workflowName); +const getTestFileContent = (workflowName) => testFileTemplate(workflowName); const call_args = process.argv.slice(2); checkArguments(call_args); diff --git a/workflow_tests/utils/utils.js b/workflow_tests/utils/utils.js index b099daae7595..6dddd5da3a96 100644 --- a/workflow_tests/utils/utils.js +++ b/workflow_tests/utils/utils.js @@ -2,15 +2,7 @@ const yaml = require('yaml'); const fs = require('fs'); const path = require('path'); -function setUpActParams( - act, - event = null, - eventOptions = null, - secrets = null, - githubToken = null, - envVars = null, - inputs = null, -) { +function setUpActParams(act, event = null, eventOptions = null, secrets = null, githubToken = null, envVars = null, inputs = null) { let updated_act = act; if (event && eventOptions) { @@ -49,16 +41,7 @@ function setUpActParams( return updated_act; } -function createMockStep( - name, - message, - job_id = null, - inputs = null, - in_envs = null, - outputs = null, - out_envs = null, - isSuccessful = true, -) { +function createMockStep(name, message, job_id = null, inputs = null, in_envs = null, outputs = null, out_envs = null, isSuccessful = true) { const mockStepName = name; let mockWithCommand = 'echo [MOCK]'; if (job_id) { @@ -94,15 +77,7 @@ function createMockStep( }; } -function createStepAssertion( - name, - isSuccessful = true, - expectedOutput = null, - jobId = null, - message = null, - inputs = null, - envs = null, -) { +function createStepAssertion(name, isSuccessful = true, expectedOutput = null, jobId = null, message = null, inputs = null, envs = null) { const stepName = `Main ${name}`; const stepStatus = isSuccessful ? 0 : 1; let stepOutput; diff --git a/workflow_tests/validateGithubActions.test.js b/workflow_tests/validateGithubActions.test.js index 89615f622ff9..a24d2a779077 100644 --- a/workflow_tests/validateGithubActions.test.js +++ b/workflow_tests/validateGithubActions.test.js @@ -50,23 +50,16 @@ describe('test workflow validateGithubActions', () => { const repoPath = mockGithub.repo.getPath('testValidateGithubActionsWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'validateGithubActions.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); - act = utils.setUpActParams( - act, - event, - eventOptions, - {}, - githubToken, - ); + act = utils.setUpActParams(act, event, eventOptions, {}, githubToken); const testMockSteps = { verify: mocks.VALIDATEGITHUBACTIONS__VERIFY__STEP_MOCKS, }; - const result = await act - .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'validateGithubActions.yml'), - mockSteps: testMockSteps, - actor, - logFile: utils.getLogFilePath('validateGithubActions', expect.getState().currentTestName), - }); + const result = await act.runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows', 'validateGithubActions.yml'), + mockSteps: testMockSteps, + actor, + logFile: utils.getLogFilePath('validateGithubActions', expect.getState().currentTestName), + }); assertions.assertVerifyJobExecuted(result); }); @@ -80,23 +73,16 @@ describe('test workflow validateGithubActions', () => { const repoPath = mockGithub.repo.getPath('testValidateGithubActionsWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'validateGithubActions.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); - act = utils.setUpActParams( - act, - event, - eventOptions, - {}, - githubToken, - ); + act = utils.setUpActParams(act, event, eventOptions, {}, githubToken); const testMockSteps = { verify: mocks.VALIDATEGITHUBACTIONS__VERIFY__STEP_MOCKS, }; - const result = await act - .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'validateGithubActions.yml'), - mockSteps: testMockSteps, - actor, - logFile: utils.getLogFilePath('validateGithubActions', expect.getState().currentTestName), - }); + const result = await act.runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows', 'validateGithubActions.yml'), + mockSteps: testMockSteps, + actor, + logFile: utils.getLogFilePath('validateGithubActions', expect.getState().currentTestName), + }); assertions.assertVerifyJobExecuted(result); }); diff --git a/workflow_tests/verifyPodfile.test.js b/workflow_tests/verifyPodfile.test.js index 57ebb34124d8..38174511821c 100644 --- a/workflow_tests/verifyPodfile.test.js +++ b/workflow_tests/verifyPodfile.test.js @@ -51,28 +51,17 @@ describe('test workflow verifyPodfile', () => { const repoPath = mockGithub.repo.getPath('testVerifyPodfileWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'verifyPodfile.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); - act = utils.setUpActParams( - act, - event, - eventOptions, - {}, - githubToken, - ); - act = utils.setJobRunners( - act, - {verify: 'ubuntu-latest'}, - workflowPath, - ); + act = utils.setUpActParams(act, event, eventOptions, {}, githubToken); + act = utils.setJobRunners(act, {verify: 'ubuntu-latest'}, workflowPath); const testMockSteps = { verify: mocks.VERIFYPODFILE__VERIFY__STEP_MOCKS, }; - const result = await act - .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'verifyPodfile.yml'), - mockSteps: testMockSteps, - actor, - logFile: utils.getLogFilePath('verifyPodfile', expect.getState().currentTestName), - }); + const result = await act.runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows', 'verifyPodfile.yml'), + mockSteps: testMockSteps, + actor, + logFile: utils.getLogFilePath('verifyPodfile', expect.getState().currentTestName), + }); assertions.assertVerifyJobExecuted(result); }); @@ -81,28 +70,17 @@ describe('test workflow verifyPodfile', () => { const repoPath = mockGithub.repo.getPath('testVerifyPodfileWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'verifyPodfile.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); - act = utils.setUpActParams( - act, - event, - eventOptions, - {}, - githubToken, - ); - act = utils.setJobRunners( - act, - {verify: 'ubuntu-latest'}, - workflowPath, - ); + act = utils.setUpActParams(act, event, eventOptions, {}, githubToken); + act = utils.setJobRunners(act, {verify: 'ubuntu-latest'}, workflowPath); const testMockSteps = { verify: mocks.VERIFYPODFILE__VERIFY__STEP_MOCKS, }; - const result = await act - .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'verifyPodfile.yml'), - mockSteps: testMockSteps, - actor: osbotifyActor, - logFile: utils.getLogFilePath('verifyPodfile', expect.getState().currentTestName), - }); + const result = await act.runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows', 'verifyPodfile.yml'), + mockSteps: testMockSteps, + actor: osbotifyActor, + logFile: utils.getLogFilePath('verifyPodfile', expect.getState().currentTestName), + }); assertions.assertVerifyJobExecuted(result, false); }); @@ -117,28 +95,17 @@ describe('test workflow verifyPodfile', () => { const repoPath = mockGithub.repo.getPath('testVerifyPodfileWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'verifyPodfile.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); - act = utils.setUpActParams( - act, - event, - eventOptions, - {}, - githubToken, - ); - act = utils.setJobRunners( - act, - {verify: 'ubuntu-latest'}, - workflowPath, - ); + act = utils.setUpActParams(act, event, eventOptions, {}, githubToken); + act = utils.setJobRunners(act, {verify: 'ubuntu-latest'}, workflowPath); const testMockSteps = { verify: mocks.VERIFYPODFILE__VERIFY__STEP_MOCKS, }; - const result = await act - .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'verifyPodfile.yml'), - mockSteps: testMockSteps, - actor, - logFile: utils.getLogFilePath('verifyPodfile', expect.getState().currentTestName), - }); + const result = await act.runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows', 'verifyPodfile.yml'), + mockSteps: testMockSteps, + actor, + logFile: utils.getLogFilePath('verifyPodfile', expect.getState().currentTestName), + }); assertions.assertVerifyJobExecuted(result); }); @@ -147,28 +114,17 @@ describe('test workflow verifyPodfile', () => { const repoPath = mockGithub.repo.getPath('testVerifyPodfileWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'verifyPodfile.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); - act = utils.setUpActParams( - act, - event, - eventOptions, - {}, - githubToken, - ); - act = utils.setJobRunners( - act, - {verify: 'ubuntu-latest'}, - workflowPath, - ); + act = utils.setUpActParams(act, event, eventOptions, {}, githubToken); + act = utils.setJobRunners(act, {verify: 'ubuntu-latest'}, workflowPath); const testMockSteps = { verify: mocks.VERIFYPODFILE__VERIFY__STEP_MOCKS, }; - const result = await act - .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'verifyPodfile.yml'), - mockSteps: testMockSteps, - actor: osbotifyActor, - logFile: utils.getLogFilePath('verifyPodfile', expect.getState().currentTestName), - }); + const result = await act.runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows', 'verifyPodfile.yml'), + mockSteps: testMockSteps, + actor: osbotifyActor, + logFile: utils.getLogFilePath('verifyPodfile', expect.getState().currentTestName), + }); assertions.assertVerifyJobExecuted(result, false); }); diff --git a/workflow_tests/verifySignedCommits.test.js b/workflow_tests/verifySignedCommits.test.js index 96ca6f0c6143..6973ed14033d 100644 --- a/workflow_tests/verifySignedCommits.test.js +++ b/workflow_tests/verifySignedCommits.test.js @@ -50,23 +50,16 @@ describe('test workflow verifySignedCommits', () => { const repoPath = mockGithub.repo.getPath('testVerifySignedCommitsWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'verifySignedCommits.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); - act = utils.setUpActParams( - act, - event, - eventOptions, - {}, - githubToken, - ); + act = utils.setUpActParams(act, event, eventOptions, {}, githubToken); const testMockSteps = { verifySignedCommits: mocks.VERIFYSIGNEDCOMMITS__VERIFYSIGNEDCOMMITS__STEP_MOCKS, }; - const result = await act - .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'verifySignedCommits.yml'), - mockSteps: testMockSteps, - actor, - logFile: utils.getLogFilePath('verifySignedCommits', expect.getState().currentTestName), - }); + const result = await act.runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows', 'verifySignedCommits.yml'), + mockSteps: testMockSteps, + actor, + logFile: utils.getLogFilePath('verifySignedCommits', expect.getState().currentTestName), + }); assertions.assertVerifySignedCommitsJobExecuted(result); }); @@ -80,23 +73,16 @@ describe('test workflow verifySignedCommits', () => { const repoPath = mockGithub.repo.getPath('testVerifySignedCommitsWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'verifySignedCommits.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); - act = utils.setUpActParams( - act, - event, - eventOptions, - {}, - githubToken, - ); + act = utils.setUpActParams(act, event, eventOptions, {}, githubToken); const testMockSteps = { verifySignedCommits: mocks.VERIFYSIGNEDCOMMITS__VERIFYSIGNEDCOMMITS__STEP_MOCKS, }; - const result = await act - .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'verifySignedCommits.yml'), - mockSteps: testMockSteps, - actor, - logFile: utils.getLogFilePath('verifySignedCommits', expect.getState().currentTestName), - }); + const result = await act.runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows', 'verifySignedCommits.yml'), + mockSteps: testMockSteps, + actor, + logFile: utils.getLogFilePath('verifySignedCommits', expect.getState().currentTestName), + }); assertions.assertVerifySignedCommitsJobExecuted(result); }); diff --git a/workflow_tests/warnCPLabel.test.js b/workflow_tests/warnCPLabel.test.js index 311cda516d31..3dac7c60c334 100644 --- a/workflow_tests/warnCPLabel.test.js +++ b/workflow_tests/warnCPLabel.test.js @@ -56,23 +56,16 @@ describe('test workflow warnCPLabel', () => { const repoPath = mockGithub.repo.getPath('testWarnCPLabelWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'warnCPLabel.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); - act = utils.setUpActParams( - act, - event, - eventOptions, - secrets, - githubToken, - ); + act = utils.setUpActParams(act, event, eventOptions, secrets, githubToken); const testMockSteps = { warnCPLabel: mocks.WARNCPLABEL__WARNCPLABEL__STEP_MOCKS, }; - const result = await act - .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'warnCPLabel.yml'), - mockSteps: testMockSteps, - actor, - logFile: utils.getLogFilePath('warnCPLabel', expect.getState().currentTestName), - }); + const result = await act.runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows', 'warnCPLabel.yml'), + mockSteps: testMockSteps, + actor, + logFile: utils.getLogFilePath('warnCPLabel', expect.getState().currentTestName), + }); assertions.assertWarnCPLabelJobExecuted(result); }); @@ -81,13 +74,7 @@ describe('test workflow warnCPLabel', () => { const repoPath = mockGithub.repo.getPath('testWarnCPLabelWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'warnCPLabel.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); - act = utils.setUpActParams( - act, - event, - eventOptions, - secrets, - githubToken, - ); + act = utils.setUpActParams(act, event, eventOptions, secrets, githubToken); const testMockSteps = { warnCPLabel: utils.deepCopy(mocks.WARNCPLABEL__WARNCPLABEL__STEP_MOCKS), }; @@ -101,13 +88,12 @@ describe('test workflow warnCPLabel', () => { {}, false, ); - const result = await act - .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'warnCPLabel.yml'), - mockSteps: testMockSteps, - actor, - logFile: utils.getLogFilePath('warnCPLabel', expect.getState().currentTestName), - }); + const result = await act.runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows', 'warnCPLabel.yml'), + mockSteps: testMockSteps, + actor, + logFile: utils.getLogFilePath('warnCPLabel', expect.getState().currentTestName), + }); assertions.assertWarnCPLabelJobExecuted(result, true, false); }); @@ -123,23 +109,16 @@ describe('test workflow warnCPLabel', () => { const repoPath = mockGithub.repo.getPath('testWarnCPLabelWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'warnCPLabel.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); - act = utils.setUpActParams( - act, - event, - differentEventOptions, - secrets, - githubToken, - ); + act = utils.setUpActParams(act, event, differentEventOptions, secrets, githubToken); const testMockSteps = { warnCPLabel: mocks.WARNCPLABEL__WARNCPLABEL__STEP_MOCKS, }; - const result = await act - .runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'warnCPLabel.yml'), - mockSteps: testMockSteps, - actor, - logFile: utils.getLogFilePath('warnCPLabel', expect.getState().currentTestName), - }); + const result = await act.runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows', 'warnCPLabel.yml'), + mockSteps: testMockSteps, + actor, + logFile: utils.getLogFilePath('warnCPLabel', expect.getState().currentTestName), + }); assertions.assertWarnCPLabelJobExecuted(result, false); }); From d6521cb6e09b5115674a2b818cd580cc890a7997 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Fri, 26 May 2023 11:25:16 +0200 Subject: [PATCH 088/504] Tiny reformat To conform with eslint See: https://github.com/Expensify/App/issues/13604 --- workflow_tests/assertions/preDeployAssertions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/workflow_tests/assertions/preDeployAssertions.js b/workflow_tests/assertions/preDeployAssertions.js index c280b6a005ac..34169bf157e1 100644 --- a/workflow_tests/assertions/preDeployAssertions.js +++ b/workflow_tests/assertions/preDeployAssertions.js @@ -124,7 +124,7 @@ const assertChooseDeployActionsJobExecuted = (workflowResult, didExecute = true) }; const assertSkipDeployJobExecuted = (workflowResult, didExecute = true) => { - const body = ':hand: This PR was not deployed to staging yet because QA is ongoing. It will be automatically ' + 'deployed to staging after the next production release.'; + const body = ':hand: This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.'; const steps = [ utils.createStepAssertion('Comment on deferred PR', true, null, 'SKIP_DEPLOY', 'Skipping deploy', [ {key: 'github_token', value: '***'}, From 97402202f3bde0fa81f63cd006c3943f3e5d84d5 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Wed, 14 Jun 2023 12:21:28 +0200 Subject: [PATCH 089/504] Job mocking Added support for mocking entire jobs due to GH Actions reusable workflows not being able to be executed as steps See: https://github.com/Expensify/App/issues/13604 --- workflow_tests/utils/ExtendedAct.js | 29 ++++++++++++ workflow_tests/utils/JobMocker.js | 72 +++++++++++++++++++++++++++++ workflow_tests/utils/utils.js | 8 +++- 3 files changed, 107 insertions(+), 2 deletions(-) create mode 100644 workflow_tests/utils/JobMocker.js diff --git a/workflow_tests/utils/ExtendedAct.js b/workflow_tests/utils/ExtendedAct.js index 1cecd0976474..9b4ab1bebda2 100644 --- a/workflow_tests/utils/ExtendedAct.js +++ b/workflow_tests/utils/ExtendedAct.js @@ -1,4 +1,7 @@ const kieActJs = require('@kie/act-js'); +const path = require('path'); +const _ = require('underscore'); +const JobMocker = require('./JobMocker'); class ExtendedAct extends kieActJs.Act { async parseRunOpts(opts) { @@ -8,6 +11,32 @@ class ExtendedAct extends kieActJs.Act { } return {cwd, actArguments, proxy}; } + + async runEvent(event, opts) { + const {mockJobs, ...vanillaOpts} = opts; + if (mockJobs) { + await this.handleJobMocking((workflow) => workflow.events.includes(event), {mockJobs, workflowFile: opts.workflowFile, cwd: opts.cwd}); + } + return super.runEvent(event, vanillaOpts); + } + + async handleJobMocking(filter, opts) { + let workflowFiles; + if (opts.workflowFile) { + workflowFiles = [path.basename(opts.workflowFile)]; + } else if (this.workflowFile !== this.cwd) { + workflowFiles = [path.basename(this.workflowFile)]; + } else { + workflowFiles = _(_(await this.list(undefined, opts.cwd, opts.workflowFile)).filter(filter)).map((l) => l.workflowFile); + } + return Promise.all( + _(workflowFiles).map((workflowFile) => { + // eslint-disable-next-line es/no-nullish-coalescing-operators + const jobMocker = new JobMocker.JobMocker(workflowFile, opts.cwd ?? this.cwd); + return jobMocker.mock(opts.mockJobs); + }), + ); + } } module.exports = { diff --git a/workflow_tests/utils/JobMocker.js b/workflow_tests/utils/JobMocker.js new file mode 100644 index 000000000000..d537dd622cb7 --- /dev/null +++ b/workflow_tests/utils/JobMocker.js @@ -0,0 +1,72 @@ +const fs = require('fs'); +const path = require('path'); +const yaml = require('yaml'); +const _ = require('underscore'); + +class JobMocker { + constructor(workflowFile, cwd) { + this.workflowFile = workflowFile; + this.cwd = cwd; + } + + async mock(mockJobs) { + const filePath = this.getWorkflowPath(); + const workflow = await this.readWorkflowFile(filePath); + Object.entries(mockJobs).forEach(([jobId, mockJob]) => { + const job = this.locateJob(workflow, jobId); + if (job) { + if (job.uses) { + delete job.uses; + } + if (job.secrets) { + delete job.secrets; + } + job.steps = _(mockJob.steps).map((step) => { + const mockStep = { + name: step.name, + run: step.mockWith, + }; + if (step.id) { + mockStep.id = step.id; + } + return mockStep; + }); + if (mockJob.outputs) { + job.outputs = mockJob.outputs; + } + } else { + throw new Error('Could not find job'); + } + }); + return this.writeWorkflowFile(filePath, workflow); + } + + locateJob(workflow, jobId) { + return workflow.jobs[jobId]; + } + + getWorkflowPath() { + if (fs.existsSync(path.join(this.cwd, this.workflowFile))) { + return path.join(this.cwd, this.workflowFile); + } + if (this.cwd.endsWith('.github')) { + return path.join(this.cwd, 'workflows', this.workflowFile); + } + if (fs.existsSync(path.join(this.cwd, '.github', 'workflows', this.workflowFile))) { + return path.join(this.cwd, '.github', 'workflows', this.workflowFile); + } + throw new Error(`Could not locate ${this.workflowFile}`); + } + + async readWorkflowFile(location) { + return yaml.parse(fs.readFileSync(location, 'utf8')); + } + + async writeWorkflowFile(location, data) { + return fs.writeFileSync(location, yaml.stringify(data), 'utf8'); + } +} + +module.exports = { + JobMocker, +}; diff --git a/workflow_tests/utils/utils.js b/workflow_tests/utils/utils.js index 6dddd5da3a96..32e106cfb1de 100644 --- a/workflow_tests/utils/utils.js +++ b/workflow_tests/utils/utils.js @@ -41,7 +41,7 @@ function setUpActParams(act, event = null, eventOptions = null, secrets = null, return updated_act; } -function createMockStep(name, message, job_id = null, inputs = null, in_envs = null, outputs = null, out_envs = null, isSuccessful = true) { +function createMockStep(name, message, job_id = null, inputs = null, in_envs = null, outputs = null, out_envs = null, isSuccessful = true, id = null) { const mockStepName = name; let mockWithCommand = 'echo [MOCK]'; if (job_id) { @@ -71,10 +71,14 @@ function createMockStep(name, message, job_id = null, inputs = null, in_envs = n if (!isSuccessful) { mockWithCommand += '\nexit 1'; } - return { + const mockStep = { name: mockStepName, mockWith: mockWithCommand, }; + if (id) { + mockStep.id = id; + } + return mockStep; } function createStepAssertion(name, isSuccessful = true, expectedOutput = null, jobId = null, message = null, inputs = null, envs = null) { From 0d53de0752aa898df287db4cc0dbc6da1389d495 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Wed, 14 Jun 2023 12:22:49 +0200 Subject: [PATCH 090/504] Revert reusable workflow as step Reverted change to cherryPick workflow using reusable workflow as step and adjusted tests See: https://github.com/Expensify/App/issues/13604 --- .github/workflows/cherryPick.yml | 9 +- workflow_tests/cherryPick.test.js | 209 +++++++++++++++++++++--- workflow_tests/mocks/cherryPickMocks.js | 12 +- 3 files changed, 203 insertions(+), 27 deletions(-) diff --git a/.github/workflows/cherryPick.yml b/.github/workflows/cherryPick.yml index 6944ad03d44f..30dda3fae63b 100644 --- a/.github/workflows/cherryPick.yml +++ b/.github/workflows/cherryPick.yml @@ -29,13 +29,8 @@ jobs: needs: validateActor runs-on: ubuntu-latest if: ${{ fromJSON(needs.validateActor.outputs.IS_DEPLOYER) && github.event.inputs.NEW_VERSION == '' }} - outputs: - NEW_VERSION: ${{ steps.createNewVersion.outputs.NEW_VERSION }} - steps: - - name: Create new version - id: createNewVersion - uses: Expensify/App/.github/workflows/createNewVersion.yml@main - secrets: inherit + uses: Expensify/App/.github/workflows/createNewVersion.yml@main + secrets: inherit cherryPick: needs: [validateActor, createNewVersion] diff --git a/workflow_tests/cherryPick.test.js b/workflow_tests/cherryPick.test.js index 14de1c0b9fb8..cdcd8b9f0947 100644 --- a/workflow_tests/cherryPick.test.js +++ b/workflow_tests/cherryPick.test.js @@ -64,14 +64,23 @@ describe('test workflow cherryPick', () => { ); const testMockSteps = { validateActor: mocks.CHERRYPICK__VALIDATEACTOR__FALSE__STEP_MOCKS, - createNewVersion: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, cherryPick: mocks.getCherryPickMockSteps(true, true, true), }; + const testMockJobs = { + createNewVersion: { + steps: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, + outputs: { + // eslint-disable-next-line no-template-curly-in-string + NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', + }, + }, + }; const result = await act.runEvent(event, { workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), mockSteps: testMockSteps, actor, logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), + mockJobs: testMockJobs, }); assertions.assertValidateActorJobExecuted(result, actor); @@ -91,9 +100,17 @@ describe('test workflow cherryPick', () => { let act = new eAct.ExtendedAct(repoPath, workflowPath); const testMockSteps = { validateActor: mocks.CHERRYPICK__VALIDATEACTOR__FALSE__STEP_MOCKS, - createNewVersion: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, cherryPick: mocks.getCherryPickMockSteps(versionsMatch, prIsMergeable, !mergeConflicts), }; + const testMockJobs = { + createNewVersion: { + steps: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, + outputs: { + // eslint-disable-next-line no-template-curly-in-string + NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', + }, + }, + }; act = utils.setUpActParams( act, event, @@ -115,6 +132,7 @@ describe('test workflow cherryPick', () => { mockSteps: testMockSteps, actor, logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), + mockJobs: testMockJobs, }); assertions.assertValidateActorJobExecuted(result, actor); @@ -138,9 +156,17 @@ describe('test workflow cherryPick', () => { let act = new eAct.ExtendedAct(repoPath, workflowPath); const testMockSteps = { validateActor: mocks.CHERRYPICK__VALIDATEACTOR__TRUE__STEP_MOCKS, - createNewVersion: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, }; testMockSteps.cherryPick = mocks.getCherryPickMockSteps(versionsMatch, prIsMergeable, !mergeConflicts); + const testMockJobs = { + createNewVersion: { + steps: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, + outputs: { + // eslint-disable-next-line no-template-curly-in-string + NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', + }, + }, + }; act = utils.setUpActParams( act, event, @@ -162,6 +188,7 @@ describe('test workflow cherryPick', () => { mockSteps: testMockSteps, actor, logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), + mockJobs: testMockJobs, }); assertions.assertValidateActorJobExecuted(result, actor); @@ -188,9 +215,17 @@ describe('test workflow cherryPick', () => { let act = new eAct.ExtendedAct(repoPath, workflowPath); const testMockSteps = { validateActor: mocks.CHERRYPICK__VALIDATEACTOR__TRUE__STEP_MOCKS, - createNewVersion: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, }; testMockSteps.cherryPick = mocks.getCherryPickMockSteps(versionsMatch, prIsMergeable, !mergeConflicts); + const testMockJobs = { + createNewVersion: { + steps: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, + outputs: { + // eslint-disable-next-line no-template-curly-in-string + NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', + }, + }, + }; act = utils.setUpActParams( act, event, @@ -212,6 +247,7 @@ describe('test workflow cherryPick', () => { mockSteps: testMockSteps, actor, logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), + mockJobs: testMockJobs, }); assertions.assertValidateActorJobExecuted(result, actor); @@ -241,9 +277,17 @@ describe('test workflow cherryPick', () => { let act = new eAct.ExtendedAct(repoPath, workflowPath); const testMockSteps = { validateActor: mocks.CHERRYPICK__VALIDATEACTOR__TRUE__STEP_MOCKS, - createNewVersion: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, }; testMockSteps.cherryPick = mocks.getCherryPickMockSteps(versionsMatch, prIsMergeable, !mergeConflicts); + const testMockJobs = { + createNewVersion: { + steps: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, + outputs: { + // eslint-disable-next-line no-template-curly-in-string + NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', + }, + }, + }; act = utils.setUpActParams( act, event, @@ -265,6 +309,7 @@ describe('test workflow cherryPick', () => { mockSteps: testMockSteps, actor, logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), + mockJobs: testMockJobs, }); assertions.assertValidateActorJobExecuted(result, actor); @@ -291,9 +336,17 @@ describe('test workflow cherryPick', () => { let act = new eAct.ExtendedAct(repoPath, workflowPath); const testMockSteps = { validateActor: mocks.CHERRYPICK__VALIDATEACTOR__TRUE__STEP_MOCKS, - createNewVersion: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, }; testMockSteps.cherryPick = mocks.getCherryPickMockSteps(versionsMatch, prIsMergeable, !mergeConflicts); + const testMockJobs = { + createNewVersion: { + steps: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, + outputs: { + // eslint-disable-next-line no-template-curly-in-string + NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', + }, + }, + }; act = utils.setUpActParams( act, event, @@ -315,6 +368,7 @@ describe('test workflow cherryPick', () => { mockSteps: testMockSteps, actor, logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), + mockJobs: testMockJobs, }); assertions.assertValidateActorJobExecuted(result, actor); @@ -347,9 +401,17 @@ describe('test workflow cherryPick', () => { let act = new eAct.ExtendedAct(repoPath, workflowPath); const testMockSteps = { validateActor: mocks.CHERRYPICK__VALIDATEACTOR__TRUE__STEP_MOCKS, - createNewVersion: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, }; testMockSteps.cherryPick = mocks.getCherryPickMockSteps(versionsMatch, prIsMergeable, !mergeConflicts); + const testMockJobs = { + createNewVersion: { + steps: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, + outputs: { + // eslint-disable-next-line no-template-curly-in-string + NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', + }, + }, + }; act = utils.setUpActParams( act, event, @@ -371,6 +433,7 @@ describe('test workflow cherryPick', () => { mockSteps: testMockSteps, actor, logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), + mockJobs: testMockJobs, }); assertions.assertValidateActorJobExecuted(result, actor); @@ -397,9 +460,17 @@ describe('test workflow cherryPick', () => { let act = new eAct.ExtendedAct(repoPath, workflowPath); const testMockSteps = { validateActor: mocks.CHERRYPICK__VALIDATEACTOR__TRUE__STEP_MOCKS, - createNewVersion: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, }; testMockSteps.cherryPick = mocks.getCherryPickMockSteps(versionsMatch, prIsMergeable, !mergeConflicts); + const testMockJobs = { + createNewVersion: { + steps: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, + outputs: { + // eslint-disable-next-line no-template-curly-in-string + NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', + }, + }, + }; act = utils.setUpActParams( act, event, @@ -421,6 +492,7 @@ describe('test workflow cherryPick', () => { mockSteps: testMockSteps, actor, logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), + mockJobs: testMockJobs, }); assertions.assertValidateActorJobExecuted(result, actor); @@ -450,9 +522,17 @@ describe('test workflow cherryPick', () => { let act = new eAct.ExtendedAct(repoPath, workflowPath); const testMockSteps = { validateActor: mocks.CHERRYPICK__VALIDATEACTOR__TRUE__STEP_MOCKS, - createNewVersion: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, }; testMockSteps.cherryPick = mocks.getCherryPickMockSteps(versionsMatch, prIsMergeable, !mergeConflicts); + const testMockJobs = { + createNewVersion: { + steps: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, + outputs: { + // eslint-disable-next-line no-template-curly-in-string + NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', + }, + }, + }; act = utils.setUpActParams( act, event, @@ -474,6 +554,7 @@ describe('test workflow cherryPick', () => { mockSteps: testMockSteps, actor, logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), + mockJobs: testMockJobs, }); assertions.assertValidateActorJobExecuted(result, actor); @@ -500,9 +581,17 @@ describe('test workflow cherryPick', () => { let act = new eAct.ExtendedAct(repoPath, workflowPath); const testMockSteps = { validateActor: mocks.CHERRYPICK__VALIDATEACTOR__TRUE__STEP_MOCKS, - createNewVersion: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, }; testMockSteps.cherryPick = mocks.getCherryPickMockSteps(versionsMatch, prIsMergeable, !mergeConflicts); + const testMockJobs = { + createNewVersion: { + steps: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, + outputs: { + // eslint-disable-next-line no-template-curly-in-string + NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', + }, + }, + }; act = utils.setUpActParams( act, event, @@ -524,6 +613,7 @@ describe('test workflow cherryPick', () => { mockSteps: testMockSteps, actor, logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), + mockJobs: testMockJobs, }); assertions.assertValidateActorJobExecuted(result, actor); @@ -560,9 +650,17 @@ describe('test workflow cherryPick', () => { let act = new eAct.ExtendedAct(repoPath, workflowPath); const testMockSteps = { validateActor: mocks.CHERRYPICK__VALIDATEACTOR__TRUE__STEP_MOCKS, - createNewVersion: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, }; testMockSteps.cherryPick = mocks.getCherryPickMockSteps(versionsMatch, prIsMergeable, !mergeConflicts); + const testMockJobs = { + createNewVersion: { + steps: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, + outputs: { + // eslint-disable-next-line no-template-curly-in-string + NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', + }, + }, + }; act = utils.setUpActParams( act, event, @@ -584,6 +682,7 @@ describe('test workflow cherryPick', () => { mockSteps: testMockSteps, actor, logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), + mockJobs: testMockJobs, }); assertions.assertValidateActorJobExecuted(result, actor); @@ -610,9 +709,17 @@ describe('test workflow cherryPick', () => { let act = new eAct.ExtendedAct(repoPath, workflowPath); const testMockSteps = { validateActor: mocks.CHERRYPICK__VALIDATEACTOR__TRUE__STEP_MOCKS, - createNewVersion: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, }; testMockSteps.cherryPick = mocks.getCherryPickMockSteps(versionsMatch, prIsMergeable, !mergeConflicts); + const testMockJobs = { + createNewVersion: { + steps: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, + outputs: { + // eslint-disable-next-line no-template-curly-in-string + NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', + }, + }, + }; act = utils.setUpActParams( act, event, @@ -634,6 +741,7 @@ describe('test workflow cherryPick', () => { mockSteps: testMockSteps, actor, logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), + mockJobs: testMockJobs, }); assertions.assertValidateActorJobExecuted(result, actor); @@ -663,9 +771,17 @@ describe('test workflow cherryPick', () => { let act = new eAct.ExtendedAct(repoPath, workflowPath); const testMockSteps = { validateActor: mocks.CHERRYPICK__VALIDATEACTOR__TRUE__STEP_MOCKS, - createNewVersion: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, }; testMockSteps.cherryPick = mocks.getCherryPickMockSteps(versionsMatch, prIsMergeable, !mergeConflicts); + const testMockJobs = { + createNewVersion: { + steps: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, + outputs: { + // eslint-disable-next-line no-template-curly-in-string + NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', + }, + }, + }; act = utils.setUpActParams( act, event, @@ -687,6 +803,7 @@ describe('test workflow cherryPick', () => { mockSteps: testMockSteps, actor, logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), + mockJobs: testMockJobs, }); assertions.assertValidateActorJobExecuted(result, actor); @@ -713,9 +830,17 @@ describe('test workflow cherryPick', () => { let act = new eAct.ExtendedAct(repoPath, workflowPath); const testMockSteps = { validateActor: mocks.CHERRYPICK__VALIDATEACTOR__TRUE__STEP_MOCKS, - createNewVersion: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, }; testMockSteps.cherryPick = mocks.getCherryPickMockSteps(versionsMatch, prIsMergeable, !mergeConflicts); + const testMockJobs = { + createNewVersion: { + steps: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, + outputs: { + // eslint-disable-next-line no-template-curly-in-string + NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', + }, + }, + }; act = utils.setUpActParams( act, event, @@ -737,6 +862,7 @@ describe('test workflow cherryPick', () => { mockSteps: testMockSteps, actor, logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), + mockJobs: testMockJobs, }); assertions.assertValidateActorJobExecuted(result, actor); @@ -769,9 +895,17 @@ describe('test workflow cherryPick', () => { let act = new eAct.ExtendedAct(repoPath, workflowPath); const testMockSteps = { validateActor: mocks.CHERRYPICK__VALIDATEACTOR__TRUE__STEP_MOCKS, - createNewVersion: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, }; testMockSteps.cherryPick = mocks.getCherryPickMockSteps(versionsMatch, prIsMergeable, !mergeConflicts); + const testMockJobs = { + createNewVersion: { + steps: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, + outputs: { + // eslint-disable-next-line no-template-curly-in-string + NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', + }, + }, + }; act = utils.setUpActParams( act, event, @@ -793,6 +927,7 @@ describe('test workflow cherryPick', () => { mockSteps: testMockSteps, actor, logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), + mockJobs: testMockJobs, }); assertions.assertValidateActorJobExecuted(result, actor); @@ -819,9 +954,17 @@ describe('test workflow cherryPick', () => { let act = new eAct.ExtendedAct(repoPath, workflowPath); const testMockSteps = { validateActor: mocks.CHERRYPICK__VALIDATEACTOR__TRUE__STEP_MOCKS, - createNewVersion: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, }; testMockSteps.cherryPick = mocks.getCherryPickMockSteps(versionsMatch, prIsMergeable, !mergeConflicts); + const testMockJobs = { + createNewVersion: { + steps: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, + outputs: { + // eslint-disable-next-line no-template-curly-in-string + NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', + }, + }, + }; act = utils.setUpActParams( act, event, @@ -843,6 +986,7 @@ describe('test workflow cherryPick', () => { mockSteps: testMockSteps, actor, logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), + mockJobs: testMockJobs, }); assertions.assertValidateActorJobExecuted(result, actor); @@ -872,9 +1016,17 @@ describe('test workflow cherryPick', () => { let act = new eAct.ExtendedAct(repoPath, workflowPath); const testMockSteps = { validateActor: mocks.CHERRYPICK__VALIDATEACTOR__TRUE__STEP_MOCKS, - createNewVersion: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, }; testMockSteps.cherryPick = mocks.getCherryPickMockSteps(versionsMatch, prIsMergeable, !mergeConflicts); + const testMockJobs = { + createNewVersion: { + steps: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, + outputs: { + // eslint-disable-next-line no-template-curly-in-string + NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', + }, + }, + }; act = utils.setUpActParams( act, event, @@ -896,6 +1048,7 @@ describe('test workflow cherryPick', () => { mockSteps: testMockSteps, actor, logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), + mockJobs: testMockJobs, }); assertions.assertValidateActorJobExecuted(result, actor); @@ -922,9 +1075,17 @@ describe('test workflow cherryPick', () => { let act = new eAct.ExtendedAct(repoPath, workflowPath); const testMockSteps = { validateActor: mocks.CHERRYPICK__VALIDATEACTOR__TRUE__STEP_MOCKS, - createNewVersion: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, }; testMockSteps.cherryPick = mocks.getCherryPickMockSteps(versionsMatch, prIsMergeable, !mergeConflicts); + const testMockJobs = { + createNewVersion: { + steps: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, + outputs: { + // eslint-disable-next-line no-template-curly-in-string + NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', + }, + }, + }; act = utils.setUpActParams( act, event, @@ -946,6 +1107,7 @@ describe('test workflow cherryPick', () => { mockSteps: testMockSteps, actor, logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), + mockJobs: testMockJobs, }); assertions.assertValidateActorJobExecuted(result, actor); @@ -993,14 +1155,23 @@ describe('test workflow cherryPick', () => { ); const testMockSteps = { validateActor: mocks.CHERRYPICK__VALIDATEACTOR__TRUE__STEP_MOCKS, - createNewVersion: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, cherryPick: mocks.getCherryPickMockSteps(true, true, true), }; + const testMockJobs = { + createNewVersion: { + steps: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, + outputs: { + // eslint-disable-next-line no-template-curly-in-string + NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', + }, + }, + }; const result = await act.runEvent(event, { workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), mockSteps: testMockSteps, actor: 'Dummy Author', logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), + mockJobs: testMockJobs, }); assertions.assertValidateActorJobExecuted(result, 'Dummy Author', false); diff --git a/workflow_tests/mocks/cherryPickMocks.js b/workflow_tests/mocks/cherryPickMocks.js index 91cfb0e6b544..9f0736a3463b 100644 --- a/workflow_tests/mocks/cherryPickMocks.js +++ b/workflow_tests/mocks/cherryPickMocks.js @@ -21,7 +21,17 @@ const CHERRYPICK__VALIDATEACTOR__TRUE__STEP_MOCKS = [CHERRYPICK__VALIDATEACTOR__ const CHERRYPICK__VALIDATEACTOR__FALSE__STEP_MOCKS = [CHERRYPICK__VALIDATEACTOR__CHECK_IF_USER_IS_DEPLOYER_FALSE__STEP_MOCK]; // createnewversion -const CHERRYPICK__CREATENEWVERSION__CREATE_NEW_VERSION__STEP_MOCK = utils.createMockStep('Create new version', 'Creating new version', 'CREATENEWVERSION', [], [], {NEW_VERSION: '1.2.3'}); +const CHERRYPICK__CREATENEWVERSION__CREATE_NEW_VERSION__STEP_MOCK = utils.createMockStep( + 'Create new version', + 'Creating new version', + 'CREATENEWVERSION', + [], + [], + {NEW_VERSION: '1.2.3'}, + null, + true, + 'createNewVersion', +); const CHERRYPICK__CREATENEWVERSION__STEP_MOCKS = [CHERRYPICK__CREATENEWVERSION__CREATE_NEW_VERSION__STEP_MOCK]; // cherrypick From ad3bae33031a64ba16d9a1560ad0561ca85becff Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Wed, 14 Jun 2023 12:42:14 +0200 Subject: [PATCH 091/504] Remove runs-on Removed runs-on from cherryPick reusable workflow and allowed for setting it in the test See: https://github.com/Expensify/App/issues/13604 --- .github/workflows/cherryPick.yml | 1 - workflow_tests/cherryPick.test.js | 19 +++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cherryPick.yml b/.github/workflows/cherryPick.yml index 30dda3fae63b..5584bbadab0c 100644 --- a/.github/workflows/cherryPick.yml +++ b/.github/workflows/cherryPick.yml @@ -27,7 +27,6 @@ jobs: createNewVersion: needs: validateActor - runs-on: ubuntu-latest if: ${{ fromJSON(needs.validateActor.outputs.IS_DEPLOYER) && github.event.inputs.NEW_VERSION == '' }} uses: Expensify/App/.github/workflows/createNewVersion.yml@main secrets: inherit diff --git a/workflow_tests/cherryPick.test.js b/workflow_tests/cherryPick.test.js index cdcd8b9f0947..c76ed16371ee 100644 --- a/workflow_tests/cherryPick.test.js +++ b/workflow_tests/cherryPick.test.js @@ -73,6 +73,7 @@ describe('test workflow cherryPick', () => { // eslint-disable-next-line no-template-curly-in-string NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', }, + runsOn: 'ubuntu-latest', }, }; const result = await act.runEvent(event, { @@ -109,6 +110,7 @@ describe('test workflow cherryPick', () => { // eslint-disable-next-line no-template-curly-in-string NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', }, + runsOn: 'ubuntu-latest', }, }; act = utils.setUpActParams( @@ -165,6 +167,7 @@ describe('test workflow cherryPick', () => { // eslint-disable-next-line no-template-curly-in-string NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', }, + runsOn: 'ubuntu-latest', }, }; act = utils.setUpActParams( @@ -224,6 +227,7 @@ describe('test workflow cherryPick', () => { // eslint-disable-next-line no-template-curly-in-string NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', }, + runsOn: 'ubuntu-latest', }, }; act = utils.setUpActParams( @@ -286,6 +290,7 @@ describe('test workflow cherryPick', () => { // eslint-disable-next-line no-template-curly-in-string NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', }, + runsOn: 'ubuntu-latest', }, }; act = utils.setUpActParams( @@ -345,6 +350,7 @@ describe('test workflow cherryPick', () => { // eslint-disable-next-line no-template-curly-in-string NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', }, + runsOn: 'ubuntu-latest', }, }; act = utils.setUpActParams( @@ -410,6 +416,7 @@ describe('test workflow cherryPick', () => { // eslint-disable-next-line no-template-curly-in-string NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', }, + runsOn: 'ubuntu-latest', }, }; act = utils.setUpActParams( @@ -469,6 +476,7 @@ describe('test workflow cherryPick', () => { // eslint-disable-next-line no-template-curly-in-string NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', }, + runsOn: 'ubuntu-latest', }, }; act = utils.setUpActParams( @@ -531,6 +539,7 @@ describe('test workflow cherryPick', () => { // eslint-disable-next-line no-template-curly-in-string NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', }, + runsOn: 'ubuntu-latest', }, }; act = utils.setUpActParams( @@ -590,6 +599,7 @@ describe('test workflow cherryPick', () => { // eslint-disable-next-line no-template-curly-in-string NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', }, + runsOn: 'ubuntu-latest', }, }; act = utils.setUpActParams( @@ -659,6 +669,7 @@ describe('test workflow cherryPick', () => { // eslint-disable-next-line no-template-curly-in-string NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', }, + runsOn: 'ubuntu-latest', }, }; act = utils.setUpActParams( @@ -718,6 +729,7 @@ describe('test workflow cherryPick', () => { // eslint-disable-next-line no-template-curly-in-string NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', }, + runsOn: 'ubuntu-latest', }, }; act = utils.setUpActParams( @@ -780,6 +792,7 @@ describe('test workflow cherryPick', () => { // eslint-disable-next-line no-template-curly-in-string NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', }, + runsOn: 'ubuntu-latest', }, }; act = utils.setUpActParams( @@ -839,6 +852,7 @@ describe('test workflow cherryPick', () => { // eslint-disable-next-line no-template-curly-in-string NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', }, + runsOn: 'ubuntu-latest', }, }; act = utils.setUpActParams( @@ -904,6 +918,7 @@ describe('test workflow cherryPick', () => { // eslint-disable-next-line no-template-curly-in-string NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', }, + runsOn: 'ubuntu-latest', }, }; act = utils.setUpActParams( @@ -963,6 +978,7 @@ describe('test workflow cherryPick', () => { // eslint-disable-next-line no-template-curly-in-string NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', }, + runsOn: 'ubuntu-latest', }, }; act = utils.setUpActParams( @@ -1025,6 +1041,7 @@ describe('test workflow cherryPick', () => { // eslint-disable-next-line no-template-curly-in-string NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', }, + runsOn: 'ubuntu-latest', }, }; act = utils.setUpActParams( @@ -1084,6 +1101,7 @@ describe('test workflow cherryPick', () => { // eslint-disable-next-line no-template-curly-in-string NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', }, + runsOn: 'ubuntu-latest', }, }; act = utils.setUpActParams( @@ -1164,6 +1182,7 @@ describe('test workflow cherryPick', () => { // eslint-disable-next-line no-template-curly-in-string NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', }, + runsOn: 'ubuntu-latest', }, }; const result = await act.runEvent(event, { From c69319c3108c4abbb21b0d702006007939c581b3 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Wed, 14 Jun 2023 12:42:50 +0200 Subject: [PATCH 092/504] Pass with to steps When mocking a job, if the job has with clause it will be passed to all the mock steps See: https://github.com/Expensify/App/issues/13604 --- workflow_tests/utils/JobMocker.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/workflow_tests/utils/JobMocker.js b/workflow_tests/utils/JobMocker.js index d537dd622cb7..a2682a657380 100644 --- a/workflow_tests/utils/JobMocker.js +++ b/workflow_tests/utils/JobMocker.js @@ -21,6 +21,11 @@ class JobMocker { if (job.secrets) { delete job.secrets; } + let jobWith; + if (job.with) { + jobWith = job.with; + delete job.with; + } job.steps = _(mockJob.steps).map((step) => { const mockStep = { name: step.name, @@ -29,11 +34,17 @@ class JobMocker { if (step.id) { mockStep.id = step.id; } + if (jobWith) { + mockStep.with = jobWith; + } return mockStep; }); if (mockJob.outputs) { job.outputs = mockJob.outputs; } + if (mockJob.runsOn) { + job['runs-on'] = mockJob.runsOn; + } } else { throw new Error('Could not find job'); } From 50159e4aeeb839c73374f128d2f25f1e93a9e24b Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Wed, 14 Jun 2023 12:43:51 +0200 Subject: [PATCH 093/504] Revert workflow change in finishReleaseCycle Reverted the change in the finishReleaseCycle workflow reusable workflow to be executed again as a job and adjusted tests See: https://github.com/Expensify/App/issues/13604 --- .github/workflows/finishReleaseCycle.yml | 14 ++--- workflow_tests/finishReleaseCycle.test.js | 60 +++++++++++++++++-- .../mocks/finishReleaseCycleMocks.js | 3 + 3 files changed, 62 insertions(+), 15 deletions(-) diff --git a/.github/workflows/finishReleaseCycle.yml b/.github/workflows/finishReleaseCycle.yml index 570594334b0f..67ff9bc329dc 100644 --- a/.github/workflows/finishReleaseCycle.yml +++ b/.github/workflows/finishReleaseCycle.yml @@ -65,18 +65,12 @@ jobs: # Create a new patch version to prep for next release cycle createNewPatchVersion: - runs-on: ubuntu-latest needs: validate if: ${{ fromJSON(needs.validate.outputs.isValid) }} - outputs: - NEW_VERSION: ${{ steps.createNewVersion.outputs.NEW_VERSION }} - steps: - - name: Create new version - id: createNewVersion - uses: Expensify/App/.github/workflows/createNewVersion.yml@main - with: - SEMVER_LEVEL: PATCH - secrets: inherit + uses: Expensify/App/.github/workflows/createNewVersion.yml@main + secrets: inherit + with: + SEMVER_LEVEL: PATCH # Deploy deferred PRs to staging and create a new StagingDeployCash for the next release cycle. createNewStagingDeployCash: diff --git a/workflow_tests/finishReleaseCycle.test.js b/workflow_tests/finishReleaseCycle.test.js index 7ec26a24fefd..ae826443583e 100644 --- a/workflow_tests/finishReleaseCycle.test.js +++ b/workflow_tests/finishReleaseCycle.test.js @@ -66,14 +66,24 @@ describe('test workflow finishReleaseCycle', () => { const testMockSteps = { validate: mocks.FINISHRELEASECYCLE__VALIDATE__TEAM_MEMBER_NO_BLOCKERS__STEP_MOCKS, updateProduction: mocks.FINISHRELEASECYCLE__UPDATEPRODUCTION__STEP_MOCKS, - createNewPatchVersion: mocks.FINISHRELEASECYCLE__CREATENEWPATCHVERSION__STEP_MOCKS, createNewStagingDeployCash: mocks.FINISHRELEASECYCLE__CREATENEWSTAGINGDEPLOYCASH__STEP_MOCKS, }; + const testMockJobs = { + createNewPatchVersion: { + steps: mocks.FINISHRELEASECYCLE__CREATENEWPATCHVERSION__STEP_MOCKS, + outputs: { + // eslint-disable-next-line no-template-curly-in-string + NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', + }, + runsOn: 'ubuntu-latest', + }, + }; const result = await act.runEvent('issues', { workflowFile: path.join(repoPath, '.github', 'workflows', 'finishReleaseCycle.yml'), mockSteps: testMockSteps, actor: 'Dummy Author', logFile: utils.getLogFilePath('finishReleaseCycle', expect.getState().currentTestName), + mockJobs: testMockJobs, }); assertions.assertValidateJobExecuted(result, 'Dummy Author', '1234'); assertions.assertUpdateProductionJobExecuted(result); @@ -105,7 +115,6 @@ describe('test workflow finishReleaseCycle', () => { const testMockSteps = { validate: mocks.FINISHRELEASECYCLE__VALIDATE__TEAM_MEMBER_NO_BLOCKERS__STEP_MOCKS, updateProduction: mocks.FINISHRELEASECYCLE__UPDATEPRODUCTION__STEP_MOCKS, - createNewPatchVersion: mocks.FINISHRELEASECYCLE__CREATENEWPATCHVERSION__STEP_MOCKS, createNewStagingDeployCash: mocks.FINISHRELEASECYCLE__CREATENEWSTAGINGDEPLOYCASH__STEP_MOCKS, }; testMockSteps.createNewStagingDeployCash[2] = utils.createMockStep( @@ -118,11 +127,22 @@ describe('test workflow finishReleaseCycle', () => { null, false, ); + const testMockJobs = { + createNewPatchVersion: { + steps: mocks.FINISHRELEASECYCLE__CREATENEWPATCHVERSION__STEP_MOCKS, + outputs: { + // eslint-disable-next-line no-template-curly-in-string + NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', + }, + runsOn: 'ubuntu-latest', + }, + }; const result = await act.runEvent('issues', { workflowFile: path.join(repoPath, '.github', 'workflows', 'finishReleaseCycle.yml'), mockSteps: testMockSteps, actor: 'Dummy Author', logFile: utils.getLogFilePath('finishReleaseCycle', expect.getState().currentTestName), + mockJobs: testMockJobs, }); assertions.assertValidateJobExecuted(result, 'Dummy Author', '1234'); assertions.assertUpdateProductionJobExecuted(result); @@ -156,14 +176,24 @@ describe('test workflow finishReleaseCycle', () => { const testMockSteps = { validate: mocks.FINISHRELEASECYCLE__VALIDATE__TEAM_MEMBER_BLOCKERS__STEP_MOCKS, updateProduction: mocks.FINISHRELEASECYCLE__UPDATEPRODUCTION__STEP_MOCKS, - createNewPatchVersion: mocks.FINISHRELEASECYCLE__CREATENEWPATCHVERSION__STEP_MOCKS, createNewStagingDeployCash: mocks.FINISHRELEASECYCLE__CREATENEWSTAGINGDEPLOYCASH__STEP_MOCKS, }; + const testMockJobs = { + createNewPatchVersion: { + steps: mocks.FINISHRELEASECYCLE__CREATENEWPATCHVERSION__STEP_MOCKS, + outputs: { + // eslint-disable-next-line no-template-curly-in-string + NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', + }, + runsOn: 'ubuntu-latest', + }, + }; const result = await act.runEvent('issues', { workflowFile: path.join(repoPath, '.github', 'workflows', 'finishReleaseCycle.yml'), mockSteps: testMockSteps, actor: 'Dummy Author', logFile: utils.getLogFilePath('finishReleaseCycle', expect.getState().currentTestName), + mockJobs: testMockJobs, }); assertions.assertValidateJobExecuted(result, 'Dummy Author', '1234', true, true, true); assertions.assertUpdateProductionJobExecuted(result, false); @@ -197,14 +227,24 @@ describe('test workflow finishReleaseCycle', () => { const testMockSteps = { validate: mocks.FINISHRELEASECYCLE__VALIDATE__NOT_TEAM_MEMBER_NO_BLOCKERS__STEP_MOCKS, updateProduction: mocks.FINISHRELEASECYCLE__UPDATEPRODUCTION__STEP_MOCKS, - createNewPatchVersion: mocks.FINISHRELEASECYCLE__CREATENEWPATCHVERSION__STEP_MOCKS, createNewStagingDeployCash: mocks.FINISHRELEASECYCLE__CREATENEWSTAGINGDEPLOYCASH__STEP_MOCKS, }; + const testMockJobs = { + createNewPatchVersion: { + steps: mocks.FINISHRELEASECYCLE__CREATENEWPATCHVERSION__STEP_MOCKS, + outputs: { + // eslint-disable-next-line no-template-curly-in-string + NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', + }, + runsOn: 'ubuntu-latest', + }, + }; const result = await act.runEvent('issues', { workflowFile: path.join(repoPath, '.github', 'workflows', 'finishReleaseCycle.yml'), mockSteps: testMockSteps, actor: 'Dummy Author', logFile: utils.getLogFilePath('finishReleaseCycle', expect.getState().currentTestName), + mockJobs: testMockJobs, }); assertions.assertValidateJobExecuted(result, 'Dummy Author', '1234', true, false, false); assertions.assertUpdateProductionJobExecuted(result, false); @@ -238,14 +278,24 @@ describe('test workflow finishReleaseCycle', () => { const testMockSteps = { validate: mocks.FINISHRELEASECYCLE__VALIDATE__TEAM_MEMBER_NO_BLOCKERS__STEP_MOCKS, updateProduction: mocks.FINISHRELEASECYCLE__UPDATEPRODUCTION__STEP_MOCKS, - createNewPatchVersion: mocks.FINISHRELEASECYCLE__CREATENEWPATCHVERSION__STEP_MOCKS, createNewStagingDeployCash: mocks.FINISHRELEASECYCLE__CREATENEWSTAGINGDEPLOYCASH__STEP_MOCKS, }; + const testMockJobs = { + createNewPatchVersion: { + steps: mocks.FINISHRELEASECYCLE__CREATENEWPATCHVERSION__STEP_MOCKS, + outputs: { + // eslint-disable-next-line no-template-curly-in-string + NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', + }, + runsOn: 'ubuntu-latest', + }, + }; const result = await act.runEvent('issues', { workflowFile: path.join(repoPath, '.github', 'workflows', 'finishReleaseCycle.yml'), mockSteps: testMockSteps, actor: 'Dummy Author', logFile: utils.getLogFilePath('finishReleaseCycle', expect.getState().currentTestName), + mockJobs: testMockJobs, }); assertions.assertValidateJobExecuted(result, 'Dummy Author', '1234', false); assertions.assertUpdateProductionJobExecuted(result, false); diff --git a/workflow_tests/mocks/finishReleaseCycleMocks.js b/workflow_tests/mocks/finishReleaseCycleMocks.js index 695a5ba731c6..d22f30752cc8 100644 --- a/workflow_tests/mocks/finishReleaseCycleMocks.js +++ b/workflow_tests/mocks/finishReleaseCycleMocks.js @@ -93,6 +93,9 @@ const FINISHRELEASECYCLE__CREATENEWPATCHVERSION__CREATE_NEW_VERSION__STEP_MOCK = ['SEMVER_LEVEL'], [], {NEW_VERSION: '1.2.3'}, + null, + true, + 'createNewVersion', ); const FINISHRELEASECYCLE__CREATENEWPATCHVERSION__STEP_MOCKS = [FINISHRELEASECYCLE__CREATENEWPATCHVERSION__CREATE_NEW_VERSION__STEP_MOCK]; From 52d7edabd1ba54622bebfa3114c854f96e558956 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Wed, 14 Jun 2023 13:03:06 +0200 Subject: [PATCH 094/504] Revert workflow change in preDeploy Reverted the change in the preDeploy workflow reusable workflow to be executed again as a job and adjusted tests See: https://github.com/Expensify/App/issues/13604 --- .github/workflows/preDeploy.yml | 19 +- workflow_tests/mocks/preDeployMocks.js | 12 +- workflow_tests/preDeploy.test.js | 307 ++++++++++++++++++++++--- 3 files changed, 287 insertions(+), 51 deletions(-) diff --git a/.github/workflows/preDeploy.yml b/.github/workflows/preDeploy.yml index 95a404bda2da..6a062d9bdd97 100644 --- a/.github/workflows/preDeploy.yml +++ b/.github/workflows/preDeploy.yml @@ -82,16 +82,10 @@ jobs: :hand: This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. createNewVersion: - runs-on: ubuntu-latest needs: chooseDeployActions if: ${{ fromJSON(needs.chooseDeployActions.outputs.SHOULD_DEPLOY) }} + uses: Expensify/App/.github/workflows/createNewVersion.yml@main secrets: inherit - outputs: - NEW_VERSION: ${{ steps.createNewVersion.outputs.NEW_VERSION }} - steps: - - name: Create new version - id: createNewVersion - uses: Expensify/App/.github/workflows/createNewVersion.yml@main updateStaging: needs: [chooseDeployActions, createNewVersion] @@ -243,11 +237,8 @@ jobs: e2ePerformanceTests: needs: [chooseDeployActions] - runs-on: ubuntu-20.04-64core if: ${{ needs.chooseDeployActions.outputs.SHOULD_DEPLOY }} - steps: - - name: Perform E2E tests - uses: Expensify/App/.github/workflows/e2ePerformanceTests.yml@main - secrets: inherit - with: - PR_NUMBER: ${{ needs.chooseDeployActions.outputs.MERGED_PR }} + uses: Expensify/App/.github/workflows/e2ePerformanceTests.yml@main + secrets: inherit + with: + PR_NUMBER: ${{ needs.chooseDeployActions.outputs.MERGED_PR }} diff --git a/workflow_tests/mocks/preDeployMocks.js b/workflow_tests/mocks/preDeployMocks.js index 9b476eb77aef..d76cad3af8ed 100644 --- a/workflow_tests/mocks/preDeployMocks.js +++ b/workflow_tests/mocks/preDeployMocks.js @@ -75,7 +75,17 @@ const COMMENT_ON_DEFERRED_PR_MOCK_STEP = utils.createMockStep('Comment on deferr const SKIP_DEPLOY_JOB_MOCK_STEPS = [COMMENT_ON_DEFERRED_PR_MOCK_STEP]; // create_new_version -const CREATE_NEW_VERSION_MOCK_STEP = utils.createMockStep('Create new version', 'Creating new version', 'CREATE_NEW_VERSION', null, null, {NEW_VERSION: '1.2.3'}); +const CREATE_NEW_VERSION_MOCK_STEP = utils.createMockStep( + 'Create new version', + 'Creating new version', + 'CREATE_NEW_VERSION', + null, + null, + {NEW_VERSION: '1.2.3'}, + null, + true, + 'createNewVersion', +); const CREATE_NEW_VERSION_JOB_MOCK_STEPS = [CREATE_NEW_VERSION_MOCK_STEP]; // update_staging diff --git a/workflow_tests/preDeploy.test.js b/workflow_tests/preDeploy.test.js index 3af13ce7db5e..61964d8ede09 100644 --- a/workflow_tests/preDeploy.test.js +++ b/workflow_tests/preDeploy.test.js @@ -69,11 +69,23 @@ describe('test workflow preDeploy', () => { confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__CP_LABEL__STAGING_UNLOCKED, skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, - createNewVersion: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, - e2ePerformanceTests: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, + }; + const testMockJobs = { + createNewVersion: { + steps: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, + outputs: { + // eslint-disable-next-line no-template-curly-in-string + NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', + }, + runsOn: 'ubuntu-latest', + }, + e2ePerformanceTests: { + steps: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, + runsOn: 'ubuntu-20.04-64core', + }, }; // run an event and get the result @@ -82,6 +94,7 @@ describe('test workflow preDeploy', () => { mockSteps: testMockSteps, actor: 'Dummy Tester', logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), + mockJobs: testMockJobs, }); // assert results (some steps can run in parallel to each other so the order is not assured @@ -105,11 +118,23 @@ describe('test workflow preDeploy', () => { confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__CP_LABEL__STAGING_UNLOCKED, skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, - createNewVersion: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, - e2ePerformanceTests: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, + }; + const testMockJobs = { + createNewVersion: { + steps: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, + outputs: { + // eslint-disable-next-line no-template-curly-in-string + NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', + }, + runsOn: 'ubuntu-latest', + }, + e2ePerformanceTests: { + steps: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, + runsOn: 'ubuntu-20.04-64core', + }, }; // pull_request @@ -129,6 +154,7 @@ describe('test workflow preDeploy', () => { mockSteps: testMockSteps, actor: 'Dummy Tester', logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), + mockJobs: testMockJobs, }); assertions.assertLintJobExecuted(result, false); assertions.assertTestJobExecuted(result, false); @@ -155,6 +181,7 @@ describe('test workflow preDeploy', () => { mockSteps: testMockSteps, actor: 'Dummy Tester', logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), + mockJobs: testMockJobs, }); assertions.assertLintJobExecuted(result, false); assertions.assertTestJobExecuted(result, false); @@ -187,17 +214,30 @@ describe('test workflow preDeploy', () => { confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__CP_LABEL__STAGING_UNLOCKED, skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, - createNewVersion: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, - e2ePerformanceTests: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, + }; + const testMockJobs = { + createNewVersion: { + steps: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, + outputs: { + // eslint-disable-next-line no-template-curly-in-string + NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', + }, + runsOn: 'ubuntu-latest', + }, + e2ePerformanceTests: { + steps: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, + runsOn: 'ubuntu-20.04-64core', + }, }; const result = await act.runEvent('push', { workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), mockSteps: testMockSteps, actor: 'Dummy Tester', logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), + mockJobs: testMockJobs, }); expect(result).toEqual(expect.arrayContaining([utils.createStepAssertion('Run lint workflow', false, null, 'LINT', 'Running lint workflow - Lint workflow failed')])); assertions.assertTestJobExecuted(result); @@ -237,17 +277,30 @@ describe('test workflow preDeploy', () => { confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__CP_LABEL__STAGING_UNLOCKED, skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, - createNewVersion: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, - e2ePerformanceTests: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, + }; + const testMockJobs = { + createNewVersion: { + steps: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, + outputs: { + // eslint-disable-next-line no-template-curly-in-string + NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', + }, + runsOn: 'ubuntu-latest', + }, + e2ePerformanceTests: { + steps: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, + runsOn: 'ubuntu-20.04-64core', + }, }; const result = await act.runEvent('push', { workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), mockSteps: testMockSteps, actor: 'Dummy Tester', logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), + mockJobs: testMockJobs, }); assertions.assertLintJobExecuted(result); expect(result).toEqual(expect.arrayContaining([utils.createStepAssertion('Run test workflow', false, null, 'TEST', 'Running test workflow - Test workflow failed')])); @@ -287,17 +340,30 @@ describe('test workflow preDeploy', () => { confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__CP_LABEL__STAGING_UNLOCKED, skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, - createNewVersion: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, - e2ePerformanceTests: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, + }; + const testMockJobs = { + createNewVersion: { + steps: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, + outputs: { + // eslint-disable-next-line no-template-curly-in-string + NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', + }, + runsOn: 'ubuntu-latest', + }, + e2ePerformanceTests: { + steps: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, + runsOn: 'ubuntu-20.04-64core', + }, }; const result = await act.runEvent('push', { workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), mockSteps: testMockSteps, actor: 'Dummy Tester', logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), + mockJobs: testMockJobs, }); assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); @@ -331,17 +397,30 @@ describe('test workflow preDeploy', () => { confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__CP_LABEL__STAGING_UNLOCKED, skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, - createNewVersion: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__FALSE, newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__OSBOTIFY, - e2ePerformanceTests: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, + }; + const testMockJobs = { + createNewVersion: { + steps: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, + outputs: { + // eslint-disable-next-line no-template-curly-in-string + NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', + }, + runsOn: 'ubuntu-latest', + }, + e2ePerformanceTests: { + steps: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, + runsOn: 'ubuntu-20.04-64core', + }, }; const result = await act.runEvent('push', { workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), mockSteps: testMockSteps, actor: 'OSBotify', logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), + mockJobs: testMockJobs, }); assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); @@ -371,17 +450,30 @@ describe('test workflow preDeploy', () => { confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__CP_LABEL__STAGING_UNLOCKED, skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, - createNewVersion: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, - e2ePerformanceTests: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, + }; + const testMockJobs = { + createNewVersion: { + steps: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, + outputs: { + // eslint-disable-next-line no-template-curly-in-string + NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', + }, + runsOn: 'ubuntu-latest', + }, + e2ePerformanceTests: { + steps: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, + runsOn: 'ubuntu-20.04-64core', + }, }; const result = await act.runEvent('push', { workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), mockSteps: testMockSteps, actor: 'Dummy Tester', logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), + mockJobs: testMockJobs, }); assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); @@ -411,17 +503,30 @@ describe('test workflow preDeploy', () => { confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__CP_LABEL__STAGING_UNLOCKED, skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, - createNewVersion: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__FALSE, newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, - e2ePerformanceTests: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, + }; + const testMockJobs = { + createNewVersion: { + steps: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, + outputs: { + // eslint-disable-next-line no-template-curly-in-string + NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', + }, + runsOn: 'ubuntu-latest', + }, + e2ePerformanceTests: { + steps: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, + runsOn: 'ubuntu-20.04-64core', + }, }; const result = await act.runEvent('push', { workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), mockSteps: testMockSteps, actor: 'Dummy Tester', logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), + mockJobs: testMockJobs, }); assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); @@ -451,17 +556,30 @@ describe('test workflow preDeploy', () => { confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__CP_LABEL__STAGING_UNLOCKED, skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, - createNewVersion: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__FALSE, newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__ONE_PR, - e2ePerformanceTests: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, + }; + const testMockJobs = { + createNewVersion: { + steps: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, + outputs: { + // eslint-disable-next-line no-template-curly-in-string + NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', + }, + runsOn: 'ubuntu-latest', + }, + e2ePerformanceTests: { + steps: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, + runsOn: 'ubuntu-20.04-64core', + }, }; const result = await act.runEvent('push', { workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), mockSteps: testMockSteps, actor: 'Dummy Tester', logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), + mockJobs: testMockJobs, }); assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); @@ -485,17 +603,30 @@ describe('test workflow preDeploy', () => { confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__STAGING_LOCKED, skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, - createNewVersion: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, - e2ePerformanceTests: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, + }; + const testMockJobs = { + createNewVersion: { + steps: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, + outputs: { + // eslint-disable-next-line no-template-curly-in-string + NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', + }, + runsOn: 'ubuntu-latest', + }, + e2ePerformanceTests: { + steps: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, + runsOn: 'ubuntu-20.04-64core', + }, }; const result = await act.runEvent('push', { workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), mockSteps: testMockSteps, actor: 'Dummy Tester', logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), + mockJobs: testMockJobs, }); assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); @@ -518,17 +649,30 @@ describe('test workflow preDeploy', () => { confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__STAGING_LOCKED, skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, - createNewVersion: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__OSBOTIFY, - e2ePerformanceTests: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, + }; + const testMockJobs = { + createNewVersion: { + steps: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, + outputs: { + // eslint-disable-next-line no-template-curly-in-string + NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', + }, + runsOn: 'ubuntu-latest', + }, + e2ePerformanceTests: { + steps: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, + runsOn: 'ubuntu-20.04-64core', + }, }; const result = await act.runEvent('push', { workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), mockSteps: testMockSteps, actor: 'OSBotify', logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), + mockJobs: testMockJobs, }); assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); @@ -563,17 +707,30 @@ describe('test workflow preDeploy', () => { confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__STAGING_UNLOCKED, skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, - createNewVersion: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, - e2ePerformanceTests: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, + }; + const testMockJobs = { + createNewVersion: { + steps: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, + outputs: { + // eslint-disable-next-line no-template-curly-in-string + NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', + }, + runsOn: 'ubuntu-latest', + }, + e2ePerformanceTests: { + steps: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, + runsOn: 'ubuntu-20.04-64core', + }, }; const result = await act.runEvent('push', { workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), mockSteps: testMockSteps, actor: 'Dummy Tester', logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), + mockJobs: testMockJobs, }); assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); @@ -605,17 +762,30 @@ describe('test workflow preDeploy', () => { confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__STAGING_UNLOCKED, skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, - createNewVersion: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__OSBOTIFY, - e2ePerformanceTests: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, + }; + const testMockJobs = { + createNewVersion: { + steps: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, + outputs: { + // eslint-disable-next-line no-template-curly-in-string + NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', + }, + runsOn: 'ubuntu-latest', + }, + e2ePerformanceTests: { + steps: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, + runsOn: 'ubuntu-20.04-64core', + }, }; const result = await act.runEvent('push', { workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), mockSteps: testMockSteps, actor: 'OSBotify', logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), + mockJobs: testMockJobs, }); assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); @@ -652,17 +822,30 @@ describe('test workflow preDeploy', () => { confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__CP_LABEL__STAGING_LOCKED, skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, - createNewVersion: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, - e2ePerformanceTests: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, + }; + const testMockJobs = { + createNewVersion: { + steps: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, + outputs: { + // eslint-disable-next-line no-template-curly-in-string + NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', + }, + runsOn: 'ubuntu-latest', + }, + e2ePerformanceTests: { + steps: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, + runsOn: 'ubuntu-20.04-64core', + }, }; const result = await act.runEvent('push', { workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), mockSteps: testMockSteps, actor: 'Dummy Tester', logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), + mockJobs: testMockJobs, }); assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); @@ -695,17 +878,30 @@ describe('test workflow preDeploy', () => { confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__CP_LABEL__STAGING_LOCKED, skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, - createNewVersion: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, - e2ePerformanceTests: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, + }; + const testMockJobs = { + createNewVersion: { + steps: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, + outputs: { + // eslint-disable-next-line no-template-curly-in-string + NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', + }, + runsOn: 'ubuntu-latest', + }, + e2ePerformanceTests: { + steps: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, + runsOn: 'ubuntu-20.04-64core', + }, }; const result = await act.runEvent('push', { workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), mockSteps: testMockSteps, actor: 'OSBotify', logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), + mockJobs: testMockJobs, }); assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); @@ -740,17 +936,30 @@ describe('test workflow preDeploy', () => { confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__CP_LABEL__STAGING_UNLOCKED, skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, - createNewVersion: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, - e2ePerformanceTests: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, + }; + const testMockJobs = { + createNewVersion: { + steps: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, + outputs: { + // eslint-disable-next-line no-template-curly-in-string + NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', + }, + runsOn: 'ubuntu-latest', + }, + e2ePerformanceTests: { + steps: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, + runsOn: 'ubuntu-20.04-64core', + }, }; const result = await act.runEvent('push', { workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), mockSteps: testMockSteps, actor: 'Dummy Tester', logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), + mockJobs: testMockJobs, }); assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); @@ -783,17 +992,30 @@ describe('test workflow preDeploy', () => { confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__CP_LABEL__STAGING_UNLOCKED, skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, - createNewVersion: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, - e2ePerformanceTests: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, + }; + const testMockJobs = { + createNewVersion: { + steps: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, + outputs: { + // eslint-disable-next-line no-template-curly-in-string + NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', + }, + runsOn: 'ubuntu-latest', + }, + e2ePerformanceTests: { + steps: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, + runsOn: 'ubuntu-20.04-64core', + }, }; const result = await act.runEvent('push', { workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), mockSteps: testMockSteps, actor: 'OSBotify', logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), + mockJobs: testMockJobs, }); assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); @@ -828,18 +1050,31 @@ describe('test workflow preDeploy', () => { confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__CP_LABEL__STAGING_UNLOCKED, skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, - createNewVersion: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, - e2ePerformanceTests: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, }; testMockSteps.updateStaging[3].mockWith = 'exit 1'; + const testMockJobs = { + createNewVersion: { + steps: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, + outputs: { + // eslint-disable-next-line no-template-curly-in-string + NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', + }, + runsOn: 'ubuntu-latest', + }, + e2ePerformanceTests: { + steps: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, + runsOn: 'ubuntu-20.04-64core', + }, + }; const result = await act.runEvent('push', { workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), mockSteps: testMockSteps, actor: 'OSBotify', logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), + mockJobs: testMockJobs, }); assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); From 0249907be6670dad5d6dddccfb816d2a93ab33c3 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Wed, 14 Jun 2023 14:31:56 +0200 Subject: [PATCH 095/504] Resolve conflicts Merged in main branch and resolved conflicts See: https://github.com/Expensify/App/issues/13604 --- package-lock.json | 384 +++++++++++++++++- .../assertions/platformDeployAssertions.js | 4 +- .../assertions/testBuildAssertions.js | 2 +- workflow_tests/mocks/platformDeployMocks.js | 4 +- workflow_tests/mocks/testBuildMocks.js | 2 +- workflow_tests/platformDeploy.test.js | 6 +- workflow_tests/testBuild.test.js | 2 +- 7 files changed, 380 insertions(+), 24 deletions(-) diff --git a/package-lock.json b/package-lock.json index 7d460c18d812..00da6e17bb93 100644 --- a/package-lock.json +++ b/package-lock.json @@ -112,6 +112,8 @@ "@babel/preset-react": "^7.10.4", "@babel/runtime": "^7.11.2", "@electron/notarize": "^1.2.3", + "@kie/act-js": "^2.0.1", + "@kie/mock-github": "^1.0.0", "@octokit/core": "4.0.4", "@octokit/plugin-paginate-rest": "3.1.0", "@octokit/plugin-throttling": "4.1.0", @@ -181,7 +183,8 @@ "webpack-cli": "^4.10.0", "webpack-dev-server": "^4.9.3", "webpack-font-preload-plugin": "^1.5.0", - "webpack-merge": "^5.8.0" + "webpack-merge": "^5.8.0", + "yaml": "^2.2.1" }, "engines": { "node": "16.15.1", @@ -4752,6 +4755,65 @@ "react-native": "*" } }, + "node_modules/@kie/act-js": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@kie/act-js/-/act-js-2.2.0.tgz", + "integrity": "sha512-AIh+M6UqPteJo6QMVBJO0QO5Q8LU7mBMth+X1hLUpZ54jPvOPovmZL96mmbtCQX9a8R1eKRnPBtms+Dloxp7SA==", + "dev": true, + "hasInstallScript": true, + "dependencies": { + "@kie/mock-github": "^1.0.3", + "adm-zip": "^0.5.10", + "ajv": "^8.12.0", + "bin-links": "^4.0.1", + "express": "^4.18.1", + "follow-redirects": "^1.15.2", + "tar": "^6.1.13", + "yaml": "^2.1.3" + }, + "bin": { + "act-js": "bin/act" + } + }, + "node_modules/@kie/mock-github": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@kie/mock-github/-/mock-github-1.1.0.tgz", + "integrity": "sha512-fD+utlOiyZSOutOcXL0G9jfjbtvOO44PLUyTfgfkrm1+575R/dbvU6AcJfjc1DtHeRv7FC7f4ebyU+a1wgL6CA==", + "dev": true, + "dependencies": { + "@octokit/openapi-types-ghec": "^14.0.0", + "ajv": "^8.11.0", + "express": "^4.18.1", + "fast-glob": "^3.2.12", + "fs-extra": "^10.1.0", + "nock": "^13.2.7", + "simple-git": "^3.8.0", + "totalist": "^3.0.0" + } + }, + "node_modules/@kie/mock-github/node_modules/fs-extra": { + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz", + "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==", + "dev": true, + "dependencies": { + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^2.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/@kie/mock-github/node_modules/totalist": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/totalist/-/totalist-3.0.1.tgz", + "integrity": "sha512-sf4i37nQ2LBx4m3wB74y+ubopq6W/dIzXg0FDGjsYnZHVa1Da8FH853wlL2gtUhg+xJXjfk3kUZS3BRoQeoQBQ==", + "dev": true, + "engines": { + "node": ">=6" + } + }, "node_modules/@kwsites/file-exists": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/@kwsites/file-exists/-/file-exists-1.1.1.tgz", @@ -5110,6 +5172,12 @@ "dev": true, "license": "MIT" }, + "node_modules/@octokit/openapi-types-ghec": { + "version": "14.0.0", + "resolved": "https://registry.npmjs.org/@octokit/openapi-types-ghec/-/openapi-types-ghec-14.0.0.tgz", + "integrity": "sha512-xhd9oEvn2aroGn+sk09Ptx/76Y7aKU0EIgHukHPCU1+rGJreO36baEEk6k8ZPblieHNM39FcykJQmtDrETm0KA==", + "dev": true + }, "node_modules/@octokit/plugin-paginate-rest": { "version": "3.1.0", "dev": true, @@ -16565,6 +16633,15 @@ "node": ">= 10.0.0" } }, + "node_modules/adm-zip": { + "version": "0.5.10", + "resolved": "https://registry.npmjs.org/adm-zip/-/adm-zip-0.5.10.tgz", + "integrity": "sha512-x0HvcHqVJNTPk/Bw8JbLWlWoo6Wwnsug0fnYYro1HBrjxZ3G7/AZk7Ahv8JwDe1uIcz8eBqvu86FuF1POiG7vQ==", + "dev": true, + "engines": { + "node": ">=6.0" + } + }, "node_modules/agent-base": { "version": "6.0.2", "dev": true, @@ -16627,8 +16704,9 @@ } }, "node_modules/ajv": { - "version": "8.11.0", - "license": "MIT", + "version": "8.12.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.12.0.tgz", + "integrity": "sha512-sRu1kpcO9yLtYxBKvqfTeh9KzZEwO3STyX1HT+4CaDzC6HpTGYhIhPIzj9XuKU7KYDwnaeh5hcOwjy1QuJzBPA==", "dependencies": { "fast-deep-equal": "^3.1.1", "json-schema-traverse": "^1.0.0", @@ -18419,6 +18497,46 @@ "node": "*" } }, + "node_modules/bin-links": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/bin-links/-/bin-links-4.0.1.tgz", + "integrity": "sha512-bmFEM39CyX336ZGGRsGPlc6jZHriIoHacOQcTt72MktIjpPhZoP4te2jOyUXF3BLILmJ8aNLncoPVeIIFlrDeA==", + "dev": true, + "dependencies": { + "cmd-shim": "^6.0.0", + "npm-normalize-package-bin": "^3.0.0", + "read-cmd-shim": "^4.0.0", + "write-file-atomic": "^5.0.0" + }, + "engines": { + "node": "^14.17.0 || ^16.13.0 || >=18.0.0" + } + }, + "node_modules/bin-links/node_modules/signal-exit": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.0.2.tgz", + "integrity": "sha512-MY2/qGx4enyjprQnFaZsHib3Yadh3IXyV2C321GY0pjGfVBu4un0uDJkwgdxqO+Rdx8JMT8IfJIRwbYVz3Ob3Q==", + "dev": true, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/bin-links/node_modules/write-file-atomic": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-5.0.1.tgz", + "integrity": "sha512-+QU2zd6OTD8XWIJCbffaiQeH9U73qIqafo1x6V1snCWYGJf6cVE0cDR4D8xRzcEnfI21IFrUPzPGtcPf8AC+Rw==", + "dev": true, + "dependencies": { + "imurmurhash": "^0.1.4", + "signal-exit": "^4.0.1" + }, + "engines": { + "node": "^14.17.0 || ^16.13.0 || >=18.0.0" + } + }, "node_modules/binary-extensions": { "version": "2.2.0", "devOptional": true, @@ -19773,6 +19891,15 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/cmd-shim": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/cmd-shim/-/cmd-shim-6.0.1.tgz", + "integrity": "sha512-S9iI9y0nKR4hwEQsVWpyxld/6kRfGepGfzff83FcaiEBpmvlbA2nnGe7Cylgrx2f/p1P5S5wpRm9oL8z1PbS3Q==", + "dev": true, + "engines": { + "node": "^14.17.0 || ^16.13.0 || >=18.0.0" + } + }, "node_modules/co": { "version": "4.6.0", "license": "MIT", @@ -20403,6 +20530,15 @@ "node": ">=10" } }, + "node_modules/cosmiconfig/node_modules/yaml": { + "version": "1.10.2", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-1.10.2.tgz", + "integrity": "sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==", + "dev": true, + "engines": { + "node": ">= 6" + } + }, "node_modules/cp-file": { "version": "7.0.0", "dev": true, @@ -24372,9 +24508,10 @@ "license": "MIT" }, "node_modules/fast-glob": { - "version": "3.2.11", + "version": "3.2.12", + "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.12.tgz", + "integrity": "sha512-DVj4CQIYYow0BlaelwK1pHl5n5cRSJfM60UA0zK891sVInoPri2Ekj7+e1CT3/3qxXenpI+nBBmQAcJPJgaj4w==", "dev": true, - "license": "MIT", "dependencies": { "@nodelib/fs.stat": "^2.0.2", "@nodelib/fs.walk": "^1.2.3", @@ -24818,7 +24955,9 @@ } }, "node_modules/follow-redirects": { - "version": "1.15.1", + "version": "1.15.2", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.2.tgz", + "integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==", "dev": true, "funding": [ { @@ -24826,7 +24965,6 @@ "url": "https://github.com/sponsors/RubenVerborgh" } ], - "license": "MIT", "engines": { "node": ">=4.0" }, @@ -25025,6 +25163,15 @@ "node": ">=8" } }, + "node_modules/fork-ts-checker-webpack-plugin/node_modules/yaml": { + "version": "1.10.2", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-1.10.2.tgz", + "integrity": "sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==", + "dev": true, + "engines": { + "node": ">= 6" + } + }, "node_modules/form-data": { "version": "3.0.1", "dev": true, @@ -33520,6 +33667,21 @@ "node": ">=12.0.0" } }, + "node_modules/nock": { + "version": "13.3.1", + "resolved": "https://registry.npmjs.org/nock/-/nock-13.3.1.tgz", + "integrity": "sha512-vHnopocZuI93p2ccivFyGuUfzjq2fxNyNurp7816mlT5V5HF4SzXu8lvLrVzBbNqzs+ODooZ6OksuSUNM7Njkw==", + "dev": true, + "dependencies": { + "debug": "^4.1.0", + "json-stringify-safe": "^5.0.1", + "lodash": "^4.17.21", + "propagate": "^2.0.0" + }, + "engines": { + "node": ">= 10.13" + } + }, "node_modules/node-abi": { "version": "3.43.0", "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.43.0.tgz", @@ -33817,6 +33979,15 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/npm-normalize-package-bin": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/npm-normalize-package-bin/-/npm-normalize-package-bin-3.0.1.tgz", + "integrity": "sha512-dMxCf+zZ+3zeQZXKxmyuCKlIDPGuv8EF940xbkC4kQVDTtqoh6rJFO+JTKSA6/Rwi0getWmtuy4Itup0AMcaDQ==", + "dev": true, + "engines": { + "node": "^14.17.0 || ^16.13.0 || >=18.0.0" + } + }, "node_modules/npm-run-path": { "version": "4.0.1", "license": "MIT", @@ -34852,6 +35023,14 @@ "which": "bin/which" } }, + "node_modules/patch-package/node_modules/yaml": { + "version": "1.10.2", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-1.10.2.tgz", + "integrity": "sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==", + "engines": { + "node": ">= 6" + } + }, "node_modules/path-browserify": { "version": "0.0.1", "license": "MIT" @@ -35478,6 +35657,15 @@ "react-is": "^16.13.1" } }, + "node_modules/propagate": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/propagate/-/propagate-2.0.1.tgz", + "integrity": "sha512-vGrhOavPSTz4QVNuBNdcNXePNdNMaO1xj9yBeH1ScQPjk/rhg9sSlCXPhMkFuaNNW/syTvYqsnbIJxMBfRbbag==", + "dev": true, + "engines": { + "node": ">= 8" + } + }, "node_modules/property-information": { "version": "5.6.0", "dev": true, @@ -37290,6 +37478,15 @@ "react-dom": ">=16.2.0" } }, + "node_modules/read-cmd-shim": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/read-cmd-shim/-/read-cmd-shim-4.0.0.tgz", + "integrity": "sha512-yILWifhaSEEytfXI76kB9xEEiG1AiozaCJZ83A87ytjRiN+jVibXjedjCRNjoZviinhG+4UkalO3mWTd8u5O0Q==", + "dev": true, + "engines": { + "node": "^14.17.0 || ^16.13.0 || >=18.0.0" + } + }, "node_modules/read-config-file": { "version": "6.3.2", "resolved": "https://registry.npmjs.org/read-config-file/-/read-config-file-6.3.2.tgz", @@ -42968,10 +43165,12 @@ "license": "ISC" }, "node_modules/yaml": { - "version": "1.10.2", - "license": "ISC", + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.3.1.tgz", + "integrity": "sha512-2eHWfjaoXgTBC2jNM1LRef62VQa0umtvRiDSk6HSzW7RvS5YtkabJrwYLLEKWBc8a5U2PTSCs+dJjUTJdlHsWQ==", + "dev": true, "engines": { - "node": ">= 6" + "node": ">= 14" } }, "node_modules/yargs": { @@ -46126,6 +46325,57 @@ "version": "2.3.1", "requires": {} }, + "@kie/act-js": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@kie/act-js/-/act-js-2.2.0.tgz", + "integrity": "sha512-AIh+M6UqPteJo6QMVBJO0QO5Q8LU7mBMth+X1hLUpZ54jPvOPovmZL96mmbtCQX9a8R1eKRnPBtms+Dloxp7SA==", + "dev": true, + "requires": { + "@kie/mock-github": "^1.0.3", + "adm-zip": "^0.5.10", + "ajv": "^8.12.0", + "bin-links": "^4.0.1", + "express": "^4.18.1", + "follow-redirects": "^1.15.2", + "tar": "^6.1.13", + "yaml": "^2.1.3" + } + }, + "@kie/mock-github": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@kie/mock-github/-/mock-github-1.1.0.tgz", + "integrity": "sha512-fD+utlOiyZSOutOcXL0G9jfjbtvOO44PLUyTfgfkrm1+575R/dbvU6AcJfjc1DtHeRv7FC7f4ebyU+a1wgL6CA==", + "dev": true, + "requires": { + "@octokit/openapi-types-ghec": "^14.0.0", + "ajv": "^8.11.0", + "express": "^4.18.1", + "fast-glob": "^3.2.12", + "fs-extra": "^10.1.0", + "nock": "^13.2.7", + "simple-git": "^3.8.0", + "totalist": "^3.0.0" + }, + "dependencies": { + "fs-extra": { + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz", + "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==", + "dev": true, + "requires": { + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^2.0.0" + } + }, + "totalist": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/totalist/-/totalist-3.0.1.tgz", + "integrity": "sha512-sf4i37nQ2LBx4m3wB74y+ubopq6W/dIzXg0FDGjsYnZHVa1Da8FH853wlL2gtUhg+xJXjfk3kUZS3BRoQeoQBQ==", + "dev": true + } + } + }, "@kwsites/file-exists": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/@kwsites/file-exists/-/file-exists-1.1.1.tgz", @@ -46389,6 +46639,12 @@ "version": "12.11.0", "dev": true }, + "@octokit/openapi-types-ghec": { + "version": "14.0.0", + "resolved": "https://registry.npmjs.org/@octokit/openapi-types-ghec/-/openapi-types-ghec-14.0.0.tgz", + "integrity": "sha512-xhd9oEvn2aroGn+sk09Ptx/76Y7aKU0EIgHukHPCU1+rGJreO36baEEk6k8ZPblieHNM39FcykJQmtDrETm0KA==", + "dev": true + }, "@octokit/plugin-paginate-rest": { "version": "3.1.0", "dev": true, @@ -54233,6 +54489,12 @@ "version": "1.2.1", "dev": true }, + "adm-zip": { + "version": "0.5.10", + "resolved": "https://registry.npmjs.org/adm-zip/-/adm-zip-0.5.10.tgz", + "integrity": "sha512-x0HvcHqVJNTPk/Bw8JbLWlWoo6Wwnsug0fnYYro1HBrjxZ3G7/AZk7Ahv8JwDe1uIcz8eBqvu86FuF1POiG7vQ==", + "dev": true + }, "agent-base": { "version": "6.0.2", "dev": true, @@ -54283,7 +54545,9 @@ } }, "ajv": { - "version": "8.11.0", + "version": "8.12.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.12.0.tgz", + "integrity": "sha512-sRu1kpcO9yLtYxBKvqfTeh9KzZEwO3STyX1HT+4CaDzC6HpTGYhIhPIzj9XuKU7KYDwnaeh5hcOwjy1QuJzBPA==", "requires": { "fast-deep-equal": "^3.1.1", "json-schema-traverse": "^1.0.0", @@ -55517,6 +55781,36 @@ "big.js": { "version": "5.2.2" }, + "bin-links": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/bin-links/-/bin-links-4.0.1.tgz", + "integrity": "sha512-bmFEM39CyX336ZGGRsGPlc6jZHriIoHacOQcTt72MktIjpPhZoP4te2jOyUXF3BLILmJ8aNLncoPVeIIFlrDeA==", + "dev": true, + "requires": { + "cmd-shim": "^6.0.0", + "npm-normalize-package-bin": "^3.0.0", + "read-cmd-shim": "^4.0.0", + "write-file-atomic": "^5.0.0" + }, + "dependencies": { + "signal-exit": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.0.2.tgz", + "integrity": "sha512-MY2/qGx4enyjprQnFaZsHib3Yadh3IXyV2C321GY0pjGfVBu4un0uDJkwgdxqO+Rdx8JMT8IfJIRwbYVz3Ob3Q==", + "dev": true + }, + "write-file-atomic": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-5.0.1.tgz", + "integrity": "sha512-+QU2zd6OTD8XWIJCbffaiQeH9U73qIqafo1x6V1snCWYGJf6cVE0cDR4D8xRzcEnfI21IFrUPzPGtcPf8AC+Rw==", + "dev": true, + "requires": { + "imurmurhash": "^0.1.4", + "signal-exit": "^4.0.1" + } + } + } + }, "binary-extensions": { "version": "2.2.0", "devOptional": true @@ -56433,6 +56727,12 @@ "mimic-response": "^1.0.0" } }, + "cmd-shim": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/cmd-shim/-/cmd-shim-6.0.1.tgz", + "integrity": "sha512-S9iI9y0nKR4hwEQsVWpyxld/6kRfGepGfzff83FcaiEBpmvlbA2nnGe7Cylgrx2f/p1P5S5wpRm9oL8z1PbS3Q==", + "dev": true + }, "co": { "version": "4.6.0" }, @@ -56843,6 +57143,14 @@ "parse-json": "^5.0.0", "path-type": "^4.0.0", "yaml": "^1.10.0" + }, + "dependencies": { + "yaml": { + "version": "1.10.2", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-1.10.2.tgz", + "integrity": "sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==", + "dev": true + } } }, "cp-file": { @@ -59517,7 +59825,9 @@ "version": "4.0.3" }, "fast-glob": { - "version": "3.2.11", + "version": "3.2.12", + "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.12.tgz", + "integrity": "sha512-DVj4CQIYYow0BlaelwK1pHl5n5cRSJfM60UA0zK891sVInoPri2Ekj7+e1CT3/3qxXenpI+nBBmQAcJPJgaj4w==", "dev": true, "requires": { "@nodelib/fs.stat": "^2.0.2", @@ -59835,7 +60145,9 @@ } }, "follow-redirects": { - "version": "1.15.1", + "version": "1.15.2", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.2.tgz", + "integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==", "dev": true }, "for-each": { @@ -59950,6 +60262,12 @@ "requires": { "has-flag": "^4.0.0" } + }, + "yaml": { + "version": "1.10.2", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-1.10.2.tgz", + "integrity": "sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==", + "dev": true } } }, @@ -65595,6 +65913,18 @@ "resolved": "https://registry.npmjs.org/nocache/-/nocache-3.0.4.tgz", "integrity": "sha512-WDD0bdg9mbq6F4mRxEYcPWwfA1vxd0mrvKOyxI7Xj/atfRHVeutzuWByG//jfm4uPzp0y4Kj051EORCBSQMycw==" }, + "nock": { + "version": "13.3.1", + "resolved": "https://registry.npmjs.org/nock/-/nock-13.3.1.tgz", + "integrity": "sha512-vHnopocZuI93p2ccivFyGuUfzjq2fxNyNurp7816mlT5V5HF4SzXu8lvLrVzBbNqzs+ODooZ6OksuSUNM7Njkw==", + "dev": true, + "requires": { + "debug": "^4.1.0", + "json-stringify-safe": "^5.0.1", + "lodash": "^4.17.21", + "propagate": "^2.0.0" + } + }, "node-abi": { "version": "3.43.0", "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.43.0.tgz", @@ -65815,6 +66145,12 @@ "version": "6.1.0", "dev": true }, + "npm-normalize-package-bin": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/npm-normalize-package-bin/-/npm-normalize-package-bin-3.0.1.tgz", + "integrity": "sha512-dMxCf+zZ+3zeQZXKxmyuCKlIDPGuv8EF940xbkC4kQVDTtqoh6rJFO+JTKSA6/Rwi0getWmtuy4Itup0AMcaDQ==", + "dev": true + }, "npm-run-path": { "version": "4.0.1", "requires": { @@ -66497,6 +66833,11 @@ "requires": { "isexe": "^2.0.0" } + }, + "yaml": { + "version": "1.10.2", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-1.10.2.tgz", + "integrity": "sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==" } } }, @@ -66899,6 +67240,12 @@ "react-is": "^16.13.1" } }, + "propagate": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/propagate/-/propagate-2.0.1.tgz", + "integrity": "sha512-vGrhOavPSTz4QVNuBNdcNXePNdNMaO1xj9yBeH1ScQPjk/rhg9sSlCXPhMkFuaNNW/syTvYqsnbIJxMBfRbbag==", + "dev": true + }, "property-information": { "version": "5.6.0", "dev": true, @@ -68098,6 +68445,12 @@ "integrity": "sha512-8E/Eb/7ksKwn5QdLn67tOR7+TdP9BZdu6E5/DSt20v8yfW/s0VGBigE6VA7R4278mBuBUowovAB3DkCfVmSPvA==", "requires": {} }, + "read-cmd-shim": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/read-cmd-shim/-/read-cmd-shim-4.0.0.tgz", + "integrity": "sha512-yILWifhaSEEytfXI76kB9xEEiG1AiozaCJZ83A87ytjRiN+jVibXjedjCRNjoZviinhG+4UkalO3mWTd8u5O0Q==", + "dev": true + }, "read-config-file": { "version": "6.3.2", "resolved": "https://registry.npmjs.org/read-config-file/-/read-config-file-6.3.2.tgz", @@ -71889,7 +72242,10 @@ "version": "4.0.0" }, "yaml": { - "version": "1.10.2" + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.3.1.tgz", + "integrity": "sha512-2eHWfjaoXgTBC2jNM1LRef62VQa0umtvRiDSk6HSzW7RvS5YtkabJrwYLLEKWBc8a5U2PTSCs+dJjUTJdlHsWQ==", + "dev": true }, "yargs": { "version": "13.3.2", diff --git a/workflow_tests/assertions/platformDeployAssertions.js b/workflow_tests/assertions/platformDeployAssertions.js index c2bf885875a8..d7991fbcad31 100644 --- a/workflow_tests/assertions/platformDeployAssertions.js +++ b/workflow_tests/assertions/platformDeployAssertions.js @@ -100,7 +100,7 @@ const assertDesktopJobExecuted = (workflowResult, didExecute = true, isProductio {key: 'CSC_LINK', value: '***'}, {key: 'CSC_KEY_PASSWORD', value: '***'}, {key: 'APPLE_ID', value: '***'}, - {key: 'APPLE_ID_PASSWORD', value: '***'}, + {key: 'APPLE_APP_SPECIFIC_PASSWORD', value: '***'}, {key: 'AWS_ACCESS_KEY_ID', value: '***'}, {key: 'AWS_SECRET_ACCESS_KEY', value: '***'}, ]), @@ -111,7 +111,7 @@ const assertDesktopJobExecuted = (workflowResult, didExecute = true, isProductio {key: 'CSC_LINK', value: '***'}, {key: 'CSC_KEY_PASSWORD', value: '***'}, {key: 'APPLE_ID', value: '***'}, - {key: 'APPLE_ID_PASSWORD', value: '***'}, + {key: 'APPLE_APP_SPECIFIC_PASSWORD', value: '***'}, {key: 'AWS_ACCESS_KEY_ID', value: '***'}, {key: 'AWS_SECRET_ACCESS_KEY', value: '***'}, ]), diff --git a/workflow_tests/assertions/testBuildAssertions.js b/workflow_tests/assertions/testBuildAssertions.js index fd4aa5c8c412..18dbf4debdc6 100644 --- a/workflow_tests/assertions/testBuildAssertions.js +++ b/workflow_tests/assertions/testBuildAssertions.js @@ -287,7 +287,7 @@ const assertDesktopJobExecuted = (workflowResult, ref = '', didExecute = true, f {key: 'CSC_LINK', value: '***'}, {key: 'CSC_KEY_PASSWORD', value: '***'}, {key: 'APPLE_ID', value: '***'}, - {key: 'APPLE_ID_PASSWORD', value: '***'}, + {key: 'APPLE_APP_SPECIFIC_PASSWORD', value: '***'}, {key: 'AWS_ACCESS_KEY_ID', value: '***'}, {key: 'AWS_SECRET_ACCESS_KEY', value: '***'}, ], diff --git a/workflow_tests/mocks/platformDeployMocks.js b/workflow_tests/mocks/platformDeployMocks.js index c062fd0ad2a4..587948bfa8ed 100644 --- a/workflow_tests/mocks/platformDeployMocks.js +++ b/workflow_tests/mocks/platformDeployMocks.js @@ -71,7 +71,7 @@ const PLATFORM_DEPLOY__DESKTOP__BUILD_PRODUCTION__STEP_MOCK = utils.createMockSt 'CSC_LINK', 'CSC_KEY_PASSWORD', 'APPLE_ID', - 'APPLE_ID_PASSWORD', + 'APPLE_APP_SPECIFIC_PASSWORD', 'AWS_ACCESS_KEY_ID', 'AWS_SECRET_ACCESS_KEY', ]); @@ -79,7 +79,7 @@ const PLATFORM_DEPLOY__DESKTOP__BUILD_STAGING__STEP_MOCK = utils.createMockStep( 'CSC_LINK', 'CSC_KEY_PASSWORD', 'APPLE_ID', - 'APPLE_ID_PASSWORD', + 'APPLE_APP_SPECIFIC_PASSWORD', 'AWS_ACCESS_KEY_ID', 'AWS_SECRET_ACCESS_KEY', ]); diff --git a/workflow_tests/mocks/testBuildMocks.js b/workflow_tests/mocks/testBuildMocks.js index cb60bb6aaaa7..d1e321541a9a 100644 --- a/workflow_tests/mocks/testBuildMocks.js +++ b/workflow_tests/mocks/testBuildMocks.js @@ -159,7 +159,7 @@ const TESTBUILD__DESKTOP__BUILD_DESKTOP_APP_FOR_TESTING__STEP_MOCK = utils.creat 'Build desktop app for testing', 'DESKTOP', [], - ['CSC_LINK', 'CSC_KEY_PASSWORD', 'APPLE_ID', 'APPLE_ID_PASSWORD', 'AWS_ACCESS_KEY_ID', 'AWS_SECRET_ACCESS_KEY'], + ['CSC_LINK', 'CSC_KEY_PASSWORD', 'APPLE_ID', 'APPLE_APP_SPECIFIC_PASSWORD', 'AWS_ACCESS_KEY_ID', 'AWS_SECRET_ACCESS_KEY'], ); const TESTBUILD__DESKTOP__STEP_MOCKS = [ TESTBUILD__DESKTOP__CHECKOUT__STEP_MOCK, diff --git a/workflow_tests/platformDeploy.test.js b/workflow_tests/platformDeploy.test.js index 6bbca9653a95..9eeadd10c6a3 100644 --- a/workflow_tests/platformDeploy.test.js +++ b/workflow_tests/platformDeploy.test.js @@ -64,7 +64,7 @@ describe('test workflow platformDeploy', () => { CSC_LINK: 'dummy_csc_link', CSC_KEY_PASSWORD: 'dummy_csc_key_pass', APPLE_ID: 'dummy_apple_id', - APPLE_ID_PASSWORD: 'dummy_apple_pass', + APPLE_APP_SPECIFIC_PASSWORD: 'dummy_apple_pass', AWS_ACCESS_KEY_ID: 'dummy_aws_access_key_id', AWS_SECRET_ACCESS_KEY: 'dummy_aws_secret_access_key', APPLE_CONTACT_EMAIL: 'dummy@email.com', @@ -136,7 +136,7 @@ describe('test workflow platformDeploy', () => { CSC_LINK: 'dummy_csc_link', CSC_KEY_PASSWORD: 'dummy_csc_key_pass', APPLE_ID: 'dummy_apple_id', - APPLE_ID_PASSWORD: 'dummy_apple_pass', + APPLE_APP_SPECIFIC_PASSWORD: 'dummy_apple_pass', AWS_ACCESS_KEY_ID: 'dummy_aws_access_key_id', AWS_SECRET_ACCESS_KEY: 'dummy_aws_secret_access_key', APPLE_CONTACT_EMAIL: 'dummy@email.com', @@ -208,7 +208,7 @@ describe('test workflow platformDeploy', () => { CSC_LINK: 'dummy_csc_link', CSC_KEY_PASSWORD: 'dummy_csc_key_pass', APPLE_ID: 'dummy_apple_id', - APPLE_ID_PASSWORD: 'dummy_apple_pass', + APPLE_APP_SPECIFIC_PASSWORD: 'dummy_apple_pass', AWS_ACCESS_KEY_ID: 'dummy_aws_access_key_id', AWS_SECRET_ACCESS_KEY: 'dummy_aws_secret_access_key', APPLE_CONTACT_EMAIL: 'dummy@email.com', diff --git a/workflow_tests/testBuild.test.js b/workflow_tests/testBuild.test.js index 4caad7716427..870738055c91 100644 --- a/workflow_tests/testBuild.test.js +++ b/workflow_tests/testBuild.test.js @@ -26,7 +26,7 @@ describe('test workflow testBuild', () => { DEVELOPER_ID_SECRET_PASSPHRASE: 'dummy_developer_id_secret_passphrase', CSC_LINK: 'dummy_csc_link', CSC_KEY_PASSWORD: 'dummy_csc_key_password', - APPLE_ID_PASSWORD: 'dummy_apple_id_password', + APPLE_APP_SPECIFIC_PASSWORD: 'dummy_apple_id_password', APPLE_ID: 'dummy_apple_id_value', }; From 25ab35f54d6596b9515b349e974090934d1f83f6 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Wed, 14 Jun 2023 18:12:43 +0200 Subject: [PATCH 096/504] Fix test Fixed platformDeploy test which was failing after merge from main See: https://github.com/Expensify/App/issues/13604 --- workflow_tests/assertions/platformDeployAssertions.js | 1 - workflow_tests/mocks/platformDeployMocks.js | 2 +- workflow_tests/platformDeploy.test.js | 6 +++--- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/workflow_tests/assertions/platformDeployAssertions.js b/workflow_tests/assertions/platformDeployAssertions.js index d7991fbcad31..b66a378ee55c 100644 --- a/workflow_tests/assertions/platformDeployAssertions.js +++ b/workflow_tests/assertions/platformDeployAssertions.js @@ -138,7 +138,6 @@ const assertIOSJobExecuted = (workflowResult, didExecute = true, isProduction = utils.createStepAssertion('Cache', true, null, 'IOS', 'Caching', [ {key: 'path', value: 'ios/Pods'}, {key: 'key', value: 'Linux-pods-'}, - {key: 'restore-keys', value: 'Linux-pods-'}, ]), utils.createStepAssertion('Install cocoapods', true, null, 'IOS', 'Installing cocoapods', [ {key: 'timeout_minutes', value: '10'}, diff --git a/workflow_tests/mocks/platformDeployMocks.js b/workflow_tests/mocks/platformDeployMocks.js index 587948bfa8ed..43b46640efe3 100644 --- a/workflow_tests/mocks/platformDeployMocks.js +++ b/workflow_tests/mocks/platformDeployMocks.js @@ -95,7 +95,7 @@ const PLATFORM_DEPLOY__DESKTOP__STEP_MOCKS = [ const PLATFORM_DEPLOY__IOS__CHECKOUT__STEP_MOCK = utils.createMockStep('Checkout', 'Checking out', 'IOS', ['fetch-depth']); const PLATFORM_DEPLOY__IOS__SETUP_NODE__STEP_MOCK = utils.createMockStep('Setup Node', 'Setting up Node', 'IOS'); const PLATFORM_DEPLOY__IOS__SETUP_RUBY__STEP_MOCK = utils.createMockStep('Setup Ruby', 'Setting up Ruby', 'IOS', ['ruby-version', 'bundler-cache']); -const PLATFORM_DEPLOY__IOS__CACHE__STEP_MOCK = utils.createMockStep('Cache', 'Caching', 'IOS', ['path', 'key', 'restore-keys']); +const PLATFORM_DEPLOY__IOS__CACHE__STEP_MOCK = utils.createMockStep('Cache', 'Caching', 'IOS', ['path', 'key']); const PLATFORM_DEPLOY__IOS__COCOAPODS__STEP_MOCK = utils.createMockStep('Install cocoapods', 'Installing cocoapods', 'IOS', ['timeout_minutes', 'max_attempts', 'command']); const PLATFORM_DEPLOY__IOS__DECRYPT_PROFILE__STEP_MOCK = utils.createMockStep('Decrypt profile', 'Decrypting profile', 'IOS', null, ['LARGE_SECRET_PASSPHRASE']); const PLATFORM_DEPLOY__IOS__DECRYPT_CERTIFICATE__STEP_MOCK = utils.createMockStep('Decrypt certificate', 'Decrypting certificate', 'IOS', null, ['LARGE_SECRET_PASSPHRASE']); diff --git a/workflow_tests/platformDeploy.test.js b/workflow_tests/platformDeploy.test.js index 9eeadd10c6a3..6bbca9653a95 100644 --- a/workflow_tests/platformDeploy.test.js +++ b/workflow_tests/platformDeploy.test.js @@ -64,7 +64,7 @@ describe('test workflow platformDeploy', () => { CSC_LINK: 'dummy_csc_link', CSC_KEY_PASSWORD: 'dummy_csc_key_pass', APPLE_ID: 'dummy_apple_id', - APPLE_APP_SPECIFIC_PASSWORD: 'dummy_apple_pass', + APPLE_ID_PASSWORD: 'dummy_apple_pass', AWS_ACCESS_KEY_ID: 'dummy_aws_access_key_id', AWS_SECRET_ACCESS_KEY: 'dummy_aws_secret_access_key', APPLE_CONTACT_EMAIL: 'dummy@email.com', @@ -136,7 +136,7 @@ describe('test workflow platformDeploy', () => { CSC_LINK: 'dummy_csc_link', CSC_KEY_PASSWORD: 'dummy_csc_key_pass', APPLE_ID: 'dummy_apple_id', - APPLE_APP_SPECIFIC_PASSWORD: 'dummy_apple_pass', + APPLE_ID_PASSWORD: 'dummy_apple_pass', AWS_ACCESS_KEY_ID: 'dummy_aws_access_key_id', AWS_SECRET_ACCESS_KEY: 'dummy_aws_secret_access_key', APPLE_CONTACT_EMAIL: 'dummy@email.com', @@ -208,7 +208,7 @@ describe('test workflow platformDeploy', () => { CSC_LINK: 'dummy_csc_link', CSC_KEY_PASSWORD: 'dummy_csc_key_pass', APPLE_ID: 'dummy_apple_id', - APPLE_APP_SPECIFIC_PASSWORD: 'dummy_apple_pass', + APPLE_ID_PASSWORD: 'dummy_apple_pass', AWS_ACCESS_KEY_ID: 'dummy_aws_access_key_id', AWS_SECRET_ACCESS_KEY: 'dummy_aws_secret_access_key', APPLE_CONTACT_EMAIL: 'dummy@email.com', From c8b4b8727124b64f6906ed6e31279229ca3fc775 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Wed, 14 Jun 2023 18:15:16 +0200 Subject: [PATCH 097/504] Fix test Fixed testBuild test which was failing after merge from main See: https://github.com/Expensify/App/issues/13604 --- workflow_tests/assertions/testBuildAssertions.js | 1 - workflow_tests/mocks/testBuildMocks.js | 2 +- workflow_tests/testBuild.test.js | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/workflow_tests/assertions/testBuildAssertions.js b/workflow_tests/assertions/testBuildAssertions.js index 18dbf4debdc6..b23347586fe3 100644 --- a/workflow_tests/assertions/testBuildAssertions.js +++ b/workflow_tests/assertions/testBuildAssertions.js @@ -164,7 +164,6 @@ const assertIOSJobExecuted = (workflowResult, ref = '', didExecute = true, fails utils.createStepAssertion('Cache', true, null, 'IOS', 'Caching', [ {key: 'path', value: 'ios/Pods'}, {key: 'key', value: 'Linux-pods-'}, - {key: 'restore-keys', value: 'Linux-pods-'}, ]), utils.createStepAssertion( 'Install cocoapods', diff --git a/workflow_tests/mocks/testBuildMocks.js b/workflow_tests/mocks/testBuildMocks.js index d1e321541a9a..45e25659318d 100644 --- a/workflow_tests/mocks/testBuildMocks.js +++ b/workflow_tests/mocks/testBuildMocks.js @@ -103,7 +103,7 @@ const TESTBUILD__IOS__CREATE_ENV_ADHOC__STEP_MOCK = utils.createMockStep( ); const TESTBUILD__IOS__SETUP_NODE__STEP_MOCK = utils.createMockStep('Setup Node', 'Setup Node', 'IOS', [], []); const TESTBUILD__IOS__SETUP_RUBY__STEP_MOCK = utils.createMockStep('Setup Ruby', 'Setup Ruby', 'IOS', ['ruby-version', 'bundler-cache'], []); -const TESTBUILD__IOS__CACHE__STEP_MOCK = utils.createMockStep('Cache', 'Caching', 'IOS', ['path', 'key', 'restore-keys']); +const TESTBUILD__IOS__CACHE__STEP_MOCK = utils.createMockStep('Cache', 'Caching', 'IOS', ['path', 'key']); const TESTBUILD__IOS__INSTALL_COCOAPODS__STEP_MOCK = utils.createMockStep('Install cocoapods', 'Install cocoapods', 'IOS', ['timeout_minutes', 'max_attempts', 'command'], []); const TESTBUILD__IOS__DECRYPT_PROFILE__STEP_MOCK = utils.createMockStep('Decrypt profile', 'Decrypt profile', 'IOS', [], ['LARGE_SECRET_PASSPHRASE']); const TESTBUILD__IOS__DECRYPT_CERTIFICATE__STEP_MOCK = utils.createMockStep('Decrypt certificate', 'Decrypt certificate', 'IOS', [], ['LARGE_SECRET_PASSPHRASE']); diff --git a/workflow_tests/testBuild.test.js b/workflow_tests/testBuild.test.js index 870738055c91..4caad7716427 100644 --- a/workflow_tests/testBuild.test.js +++ b/workflow_tests/testBuild.test.js @@ -26,7 +26,7 @@ describe('test workflow testBuild', () => { DEVELOPER_ID_SECRET_PASSPHRASE: 'dummy_developer_id_secret_passphrase', CSC_LINK: 'dummy_csc_link', CSC_KEY_PASSWORD: 'dummy_csc_key_password', - APPLE_APP_SPECIFIC_PASSWORD: 'dummy_apple_id_password', + APPLE_ID_PASSWORD: 'dummy_apple_id_password', APPLE_ID: 'dummy_apple_id_value', }; From 1c486c35fe72ad7bdd7661fbc27e532f0914f689 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Thu, 15 Jun 2023 10:40:34 +0200 Subject: [PATCH 098/504] Fix tests Fixed platformDeploy and testBuild tests which were failing after another merge from main See: https://github.com/Expensify/App/issues/13604 --- workflow_tests/assertions/platformDeployAssertions.js | 4 ---- workflow_tests/assertions/testBuildAssertions.js | 4 ---- workflow_tests/mocks/platformDeployMocks.js | 2 -- workflow_tests/mocks/testBuildMocks.js | 2 -- workflow_tests/testBuild.test.js | 4 ++-- 5 files changed, 2 insertions(+), 14 deletions(-) diff --git a/workflow_tests/assertions/platformDeployAssertions.js b/workflow_tests/assertions/platformDeployAssertions.js index b66a378ee55c..a848178d581b 100644 --- a/workflow_tests/assertions/platformDeployAssertions.js +++ b/workflow_tests/assertions/platformDeployAssertions.js @@ -135,10 +135,6 @@ const assertIOSJobExecuted = (workflowResult, didExecute = true, isProduction = {key: 'ruby-version', value: '2.7'}, {key: 'bundler-cache', value: 'true'}, ]), - utils.createStepAssertion('Cache', true, null, 'IOS', 'Caching', [ - {key: 'path', value: 'ios/Pods'}, - {key: 'key', value: 'Linux-pods-'}, - ]), utils.createStepAssertion('Install cocoapods', true, null, 'IOS', 'Installing cocoapods', [ {key: 'timeout_minutes', value: '10'}, {key: 'max_attempts', value: '5'}, diff --git a/workflow_tests/assertions/testBuildAssertions.js b/workflow_tests/assertions/testBuildAssertions.js index b23347586fe3..bf0936182da5 100644 --- a/workflow_tests/assertions/testBuildAssertions.js +++ b/workflow_tests/assertions/testBuildAssertions.js @@ -161,10 +161,6 @@ const assertIOSJobExecuted = (workflowResult, ref = '', didExecute = true, fails ], [], ), - utils.createStepAssertion('Cache', true, null, 'IOS', 'Caching', [ - {key: 'path', value: 'ios/Pods'}, - {key: 'key', value: 'Linux-pods-'}, - ]), utils.createStepAssertion( 'Install cocoapods', true, diff --git a/workflow_tests/mocks/platformDeployMocks.js b/workflow_tests/mocks/platformDeployMocks.js index 43b46640efe3..5811eba35681 100644 --- a/workflow_tests/mocks/platformDeployMocks.js +++ b/workflow_tests/mocks/platformDeployMocks.js @@ -95,7 +95,6 @@ const PLATFORM_DEPLOY__DESKTOP__STEP_MOCKS = [ const PLATFORM_DEPLOY__IOS__CHECKOUT__STEP_MOCK = utils.createMockStep('Checkout', 'Checking out', 'IOS', ['fetch-depth']); const PLATFORM_DEPLOY__IOS__SETUP_NODE__STEP_MOCK = utils.createMockStep('Setup Node', 'Setting up Node', 'IOS'); const PLATFORM_DEPLOY__IOS__SETUP_RUBY__STEP_MOCK = utils.createMockStep('Setup Ruby', 'Setting up Ruby', 'IOS', ['ruby-version', 'bundler-cache']); -const PLATFORM_DEPLOY__IOS__CACHE__STEP_MOCK = utils.createMockStep('Cache', 'Caching', 'IOS', ['path', 'key']); const PLATFORM_DEPLOY__IOS__COCOAPODS__STEP_MOCK = utils.createMockStep('Install cocoapods', 'Installing cocoapods', 'IOS', ['timeout_minutes', 'max_attempts', 'command']); const PLATFORM_DEPLOY__IOS__DECRYPT_PROFILE__STEP_MOCK = utils.createMockStep('Decrypt profile', 'Decrypting profile', 'IOS', null, ['LARGE_SECRET_PASSPHRASE']); const PLATFORM_DEPLOY__IOS__DECRYPT_CERTIFICATE__STEP_MOCK = utils.createMockStep('Decrypt certificate', 'Decrypting certificate', 'IOS', null, ['LARGE_SECRET_PASSPHRASE']); @@ -123,7 +122,6 @@ const PLATFORM_DEPLOY__IOS__STEP_MOCKS = [ PLATFORM_DEPLOY__IOS__CHECKOUT__STEP_MOCK, PLATFORM_DEPLOY__IOS__SETUP_NODE__STEP_MOCK, PLATFORM_DEPLOY__IOS__SETUP_RUBY__STEP_MOCK, - PLATFORM_DEPLOY__IOS__CACHE__STEP_MOCK, PLATFORM_DEPLOY__IOS__COCOAPODS__STEP_MOCK, PLATFORM_DEPLOY__IOS__DECRYPT_PROFILE__STEP_MOCK, PLATFORM_DEPLOY__IOS__DECRYPT_CERTIFICATE__STEP_MOCK, diff --git a/workflow_tests/mocks/testBuildMocks.js b/workflow_tests/mocks/testBuildMocks.js index 45e25659318d..b20afbe2aa83 100644 --- a/workflow_tests/mocks/testBuildMocks.js +++ b/workflow_tests/mocks/testBuildMocks.js @@ -103,7 +103,6 @@ const TESTBUILD__IOS__CREATE_ENV_ADHOC__STEP_MOCK = utils.createMockStep( ); const TESTBUILD__IOS__SETUP_NODE__STEP_MOCK = utils.createMockStep('Setup Node', 'Setup Node', 'IOS', [], []); const TESTBUILD__IOS__SETUP_RUBY__STEP_MOCK = utils.createMockStep('Setup Ruby', 'Setup Ruby', 'IOS', ['ruby-version', 'bundler-cache'], []); -const TESTBUILD__IOS__CACHE__STEP_MOCK = utils.createMockStep('Cache', 'Caching', 'IOS', ['path', 'key']); const TESTBUILD__IOS__INSTALL_COCOAPODS__STEP_MOCK = utils.createMockStep('Install cocoapods', 'Install cocoapods', 'IOS', ['timeout_minutes', 'max_attempts', 'command'], []); const TESTBUILD__IOS__DECRYPT_PROFILE__STEP_MOCK = utils.createMockStep('Decrypt profile', 'Decrypt profile', 'IOS', [], ['LARGE_SECRET_PASSPHRASE']); const TESTBUILD__IOS__DECRYPT_CERTIFICATE__STEP_MOCK = utils.createMockStep('Decrypt certificate', 'Decrypt certificate', 'IOS', [], ['LARGE_SECRET_PASSPHRASE']); @@ -121,7 +120,6 @@ const TESTBUILD__IOS__STEP_MOCKS = [ TESTBUILD__IOS__CREATE_ENV_ADHOC__STEP_MOCK, TESTBUILD__IOS__SETUP_NODE__STEP_MOCK, TESTBUILD__IOS__SETUP_RUBY__STEP_MOCK, - TESTBUILD__IOS__CACHE__STEP_MOCK, TESTBUILD__IOS__INSTALL_COCOAPODS__STEP_MOCK, TESTBUILD__IOS__DECRYPT_PROFILE__STEP_MOCK, TESTBUILD__IOS__DECRYPT_CERTIFICATE__STEP_MOCK, diff --git a/workflow_tests/testBuild.test.js b/workflow_tests/testBuild.test.js index 4caad7716427..713ec4a91c31 100644 --- a/workflow_tests/testBuild.test.js +++ b/workflow_tests/testBuild.test.js @@ -232,7 +232,7 @@ describe('test workflow testBuild', () => { web: mocks.TESTBUILD__WEB__STEP_MOCKS, postGithubComment: mocks.TESTBUILD__POSTGITHUBCOMMENT__STEP_MOCKS, }; - testMockSteps.iOS[5] = utils.createMockStep('Install cocoapods', 'Install cocoapods', 'IOS', ['timeout_minutes', 'max_attempts', 'command'], [], {}, {}, false); + testMockSteps.iOS[4] = utils.createMockStep('Install cocoapods', 'Install cocoapods', 'IOS', ['timeout_minutes', 'max_attempts', 'command'], [], {}, {}, false); const result = await act.runEvent(event, { workflowFile: path.join(repoPath, '.github', 'workflows', 'testBuild.yml'), mockSteps: testMockSteps, @@ -243,7 +243,7 @@ describe('test workflow testBuild', () => { assertions.assertValidateActorJobExecuted(result, actor, '1234'); assertions.assertGetBranchRefJobExecuted(result); assertions.assertAndroidJobExecuted(result, 'test-ref'); - assertions.assertIOSJobExecuted(result, 'test-ref', true, 5); + assertions.assertIOSJobExecuted(result, 'test-ref', true, 4); assertions.assertDesktopJobExecuted(result, 'test-ref'); assertions.assertWebJobExecuted(result, 'test-ref'); assertions.assertPostGithubCommentJobExecuted(result, 'test-ref', '1234', true, 'success', 'failure', 'success', 'success'); From bc9cc479b38f014d02a59a10c614e5d8f883bcc4 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Fri, 30 Jun 2023 11:32:30 +0200 Subject: [PATCH 099/504] Update package-lock Updated dependencies after creating a new branch and cherry-picking and signing commits See: https://github.com/Expensify/App/issues/13604 --- package-lock.json | 109 +++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 99 insertions(+), 10 deletions(-) diff --git a/package-lock.json b/package-lock.json index 00da6e17bb93..90ae0e38d186 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,7 +17,9 @@ "@formatjs/intl-numberformat": "^8.5.0", "@formatjs/intl-pluralrules": "^5.2.2", "@gorhom/portal": "^1.0.14", - "@oguzhnatly/react-native-image-manipulator": "github:Expensify/react-native-image-manipulator#5cdae3d4455b03a04c57f50be3863e2fe6c92c52", + "@kie/act-js": "^2.0.1", + "@kie/mock-github": "^1.0.0", + "@oguzhnatly/react-native-image-manipulator": "github:Expensify/react-native-image-manipulator#c5f654fc9d0ad7cc5b89d50b34ecf8b0e3f4d050", "@onfido/react-native-sdk": "7.4.0", "@react-native-async-storage/async-storage": "^1.17.10", "@react-native-camera-roll/camera-roll": "5.4.0", @@ -31,9 +33,12 @@ "@react-native-firebase/crashlytics": "^12.3.0", "@react-native-firebase/perf": "^12.3.0", "@react-native-picker/picker": "^2.4.3", + "@react-navigation/drawer": "github:Expensify/react-navigation#react-navigation-drawer-v6.5.0-alpha1-gitpkg", "@react-navigation/native": "6.1.6", "@react-navigation/stack": "6.3.16", "@react-ng/bounds-observer": "^0.2.1", + "@types/jest": "^29.4.0", + "@types/node": "^18.14.0", "@ua/react-native-airship": "^15.2.6", "awesome-phonenumber": "^5.4.0", "babel-plugin-transform-remove-console": "^6.9.4", @@ -99,7 +104,8 @@ "save": "^2.4.0", "semver": "^7.3.8", "shim-keyboard-event-key": "^1.0.3", - "underscore": "^1.13.1" + "underscore": "^1.13.1", + "urbanairship-react-native": "^14.6.1" }, "devDependencies": { "@actions/core": "1.10.0", @@ -5284,8 +5290,8 @@ }, "node_modules/@oguzhnatly/react-native-image-manipulator": { "version": "1.0.5", - "resolved": "git+ssh://git@github.com/Expensify/react-native-image-manipulator.git#5cdae3d4455b03a04c57f50be3863e2fe6c92c52", - "integrity": "sha512-C9Br1BQqm6io6lvYHptlLcOHbzlaqxp9tS35P8Qj3pdiiYRTzU3KPvZ61rQ+ZnZ4FOQ6MwPsKsmB8+6WHkAY6Q==", + "resolved": "git+ssh://git@github.com/Expensify/react-native-image-manipulator.git#c5f654fc9d0ad7cc5b89d50b34ecf8b0e3f4d050", + "integrity": "sha512-PvrSoCq5PS1MA5ZWUpB0khfzH6sM8SI6YiVl4i2SItPr7IeRxiWfI4n45VhBCCElc1z5GhAwTZOBaIzXTX7/og==", "license": "MIT" }, "node_modules/@onfido/active-video-capture": { @@ -7808,6 +7814,36 @@ "react": "*" } }, + "node_modules/@react-navigation/drawer": { + "version": "6.5.0-alpha1", + "resolved": "git+ssh://git@github.com/Expensify/react-navigation.git#bee9dc3f6bd03bb24f529efcb9f0d5d5832df6d6", + "license": "MIT", + "dependencies": { + "@react-navigation/elements": "^1.3.6", + "color": "^4.2.3", + "warn-once": "^0.1.0" + }, + "peerDependencies": { + "@react-navigation/native": "^6.0.0", + "react": "*", + "react-native": "*", + "react-native-gesture-handler": ">= 2.0.0", + "react-native-reanimated": "*", + "react-native-safe-area-context": ">= 3.0.0", + "react-native-screens": ">= 3.0.0" + } + }, + "node_modules/@react-navigation/drawer/node_modules/@react-navigation/elements": { + "version": "1.3.18", + "resolved": "https://registry.npmjs.org/@react-navigation/elements/-/elements-1.3.18.tgz", + "integrity": "sha512-/0hwnJkrr415yP0Hf4PjUKgGyfshrvNUKFXN85Mrt1gY49hy9IwxZgrrxlh0THXkPeq8q4VWw44eHDfAcQf20Q==", + "peerDependencies": { + "@react-navigation/native": "^6.0.0", + "react": "*", + "react-native": "*", + "react-native-safe-area-context": ">= 3.0.0" + } + }, "node_modules/@react-navigation/native": { "version": "6.1.6", "resolved": "https://registry.npmjs.org/@react-navigation/native/-/native-6.1.6.tgz", @@ -15623,6 +15659,15 @@ "@types/istanbul-lib-report": "*" } }, + "node_modules/@types/jest": { + "version": "29.5.2", + "resolved": "https://registry.npmjs.org/@types/jest/-/jest-29.5.2.tgz", + "integrity": "sha512-mSoZVJF5YzGVCk+FsDxzDuH7s+SCkzrgKZzf0Z0T2WudhBUPoF6ktoTPC4R0ZoCPCV5xUvuU6ias5NvxcBcMMg==", + "dependencies": { + "expect": "^29.0.0", + "pretty-format": "^29.0.0" + } + }, "node_modules/@types/jsdom": { "version": "20.0.1", "dev": true, @@ -15707,8 +15752,9 @@ "dev": true }, "node_modules/@types/node": { - "version": "18.7.6", - "license": "MIT" + "version": "18.16.18", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.16.18.tgz", + "integrity": "sha512-/aNaQZD0+iSBAGnvvN2Cx92HqE5sZCPZtx2TsK+4nvV23fFe09jVDvpArXr2j9DnYlzuU9WuoykDDc6wqvpNcw==" }, "node_modules/@types/node-fetch": { "version": "2.6.2", @@ -41512,6 +41558,15 @@ "version": "1.0.0", "license": "ISC" }, + "node_modules/urbanairship-react-native": { + "version": "14.6.1", + "resolved": "https://registry.npmjs.org/urbanairship-react-native/-/urbanairship-react-native-14.6.1.tgz", + "integrity": "sha512-ddL3ZWZnhwCja9oMpq7YHEyuqca1IH34MtMm24w1SePzGRhcVAvKOe/lncIB1FAK6QyjG0pkPT5mu3vE/DsPEw==", + "peerDependencies": { + "react": "*", + "react-native": "*" + } + }, "node_modules/uri-js": { "version": "4.4.1", "license": "BSD-2-Clause", @@ -46723,9 +46778,9 @@ } }, "@oguzhnatly/react-native-image-manipulator": { - "version": "git+ssh://git@github.com/Expensify/react-native-image-manipulator.git#5cdae3d4455b03a04c57f50be3863e2fe6c92c52", - "integrity": "sha512-C9Br1BQqm6io6lvYHptlLcOHbzlaqxp9tS35P8Qj3pdiiYRTzU3KPvZ61rQ+ZnZ4FOQ6MwPsKsmB8+6WHkAY6Q==", - "from": "@oguzhnatly/react-native-image-manipulator@github:Expensify/react-native-image-manipulator#5cdae3d4455b03a04c57f50be3863e2fe6c92c52" + "version": "git+ssh://git@github.com/Expensify/react-native-image-manipulator.git#c5f654fc9d0ad7cc5b89d50b34ecf8b0e3f4d050", + "integrity": "sha512-PvrSoCq5PS1MA5ZWUpB0khfzH6sM8SI6YiVl4i2SItPr7IeRxiWfI4n45VhBCCElc1z5GhAwTZOBaIzXTX7/og==", + "from": "@oguzhnatly/react-native-image-manipulator@github:Expensify/react-native-image-manipulator#c5f654fc9d0ad7cc5b89d50b34ecf8b0e3f4d050" }, "@onfido/active-video-capture": { "version": "0.25.2", @@ -48605,6 +48660,23 @@ "stacktrace-parser": "^0.1.10" } }, + "@react-navigation/drawer": { + "version": "git+ssh://git@github.com/Expensify/react-navigation.git#bee9dc3f6bd03bb24f529efcb9f0d5d5832df6d6", + "from": "@react-navigation/drawer@github:Expensify/react-navigation#react-navigation-drawer-v6.5.0-alpha1-gitpkg", + "requires": { + "@react-navigation/elements": "^1.3.6", + "color": "^4.2.3", + "warn-once": "^0.1.0" + }, + "dependencies": { + "@react-navigation/elements": { + "version": "1.3.18", + "resolved": "https://registry.npmjs.org/@react-navigation/elements/-/elements-1.3.18.tgz", + "integrity": "sha512-/0hwnJkrr415yP0Hf4PjUKgGyfshrvNUKFXN85Mrt1gY49hy9IwxZgrrxlh0THXkPeq8q4VWw44eHDfAcQf20Q==", + "requires": {} + } + } + }, "@react-navigation/native": { "version": "6.1.6", "resolved": "https://registry.npmjs.org/@react-navigation/native/-/native-6.1.6.tgz", @@ -53755,6 +53827,15 @@ "@types/istanbul-lib-report": "*" } }, + "@types/jest": { + "version": "29.5.2", + "resolved": "https://registry.npmjs.org/@types/jest/-/jest-29.5.2.tgz", + "integrity": "sha512-mSoZVJF5YzGVCk+FsDxzDuH7s+SCkzrgKZzf0Z0T2WudhBUPoF6ktoTPC4R0ZoCPCV5xUvuU6ias5NvxcBcMMg==", + "requires": { + "expect": "^29.0.0", + "pretty-format": "^29.0.0" + } + }, "@types/jsdom": { "version": "20.0.1", "dev": true, @@ -53822,7 +53903,9 @@ "dev": true }, "@types/node": { - "version": "18.7.6" + "version": "18.16.18", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.16.18.tgz", + "integrity": "sha512-/aNaQZD0+iSBAGnvvN2Cx92HqE5sZCPZtx2TsK+4nvV23fFe09jVDvpArXr2j9DnYlzuU9WuoykDDc6wqvpNcw==" }, "@types/node-fetch": { "version": "2.6.2", @@ -71162,6 +71245,12 @@ } } }, + "urbanairship-react-native": { + "version": "14.6.1", + "resolved": "https://registry.npmjs.org/urbanairship-react-native/-/urbanairship-react-native-14.6.1.tgz", + "integrity": "sha512-ddL3ZWZnhwCja9oMpq7YHEyuqca1IH34MtMm24w1SePzGRhcVAvKOe/lncIB1FAK6QyjG0pkPT5mu3vE/DsPEw==", + "requires": {} + }, "uri-js": { "version": "4.4.1", "requires": { From 9f74565e00b227a6ed375ec0e2a20db1272b4d48 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Fri, 30 Jun 2023 14:25:49 +0200 Subject: [PATCH 100/504] Update package-lock Updated dependencies after after merging in changes from main repo See: https://github.com/Expensify/App/issues/13604 --- package-lock.json | 493 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 469 insertions(+), 24 deletions(-) diff --git a/package-lock.json b/package-lock.json index 26d228989f42..b1414ce2b9c3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,7 +17,9 @@ "@formatjs/intl-numberformat": "^8.5.0", "@formatjs/intl-pluralrules": "^5.2.2", "@gorhom/portal": "^1.0.14", - "@oguzhnatly/react-native-image-manipulator": "github:Expensify/react-native-image-manipulator#5cdae3d4455b03a04c57f50be3863e2fe6c92c52", + "@kie/act-js": "^2.0.1", + "@kie/mock-github": "^1.0.0", + "@oguzhnatly/react-native-image-manipulator": "github:Expensify/react-native-image-manipulator#c5f654fc9d0ad7cc5b89d50b34ecf8b0e3f4d050", "@onfido/react-native-sdk": "7.4.0", "@react-native-async-storage/async-storage": "^1.17.10", "@react-native-camera-roll/camera-roll": "5.4.0", @@ -31,9 +33,12 @@ "@react-native-firebase/crashlytics": "^12.3.0", "@react-native-firebase/perf": "^12.3.0", "@react-native-picker/picker": "^2.4.3", + "@react-navigation/drawer": "github:Expensify/react-navigation#react-navigation-drawer-v6.5.0-alpha1-gitpkg", "@react-navigation/native": "6.1.6", "@react-navigation/stack": "6.3.16", "@react-ng/bounds-observer": "^0.2.1", + "@types/jest": "^29.4.0", + "@types/node": "^18.14.0", "@ua/react-native-airship": "^15.2.6", "awesome-phonenumber": "^5.4.0", "babel-plugin-transform-remove-console": "^6.9.4", @@ -99,7 +104,8 @@ "save": "^2.4.0", "semver": "^7.3.8", "shim-keyboard-event-key": "^1.0.3", - "underscore": "^1.13.1" + "underscore": "^1.13.1", + "urbanairship-react-native": "^14.6.1" }, "devDependencies": { "@actions/core": "1.10.0", @@ -112,6 +118,8 @@ "@babel/preset-react": "^7.10.4", "@babel/runtime": "^7.11.2", "@electron/notarize": "^1.2.3", + "@kie/act-js": "^2.0.1", + "@kie/mock-github": "^1.0.0", "@octokit/core": "4.0.4", "@octokit/plugin-paginate-rest": "3.1.0", "@octokit/plugin-throttling": "4.1.0", @@ -181,7 +189,8 @@ "webpack-cli": "^4.10.0", "webpack-dev-server": "^4.9.3", "webpack-font-preload-plugin": "^1.5.0", - "webpack-merge": "^5.8.0" + "webpack-merge": "^5.8.0", + "yaml": "^2.2.1" }, "engines": { "node": "16.15.1", @@ -4848,6 +4857,65 @@ "react-native": "*" } }, + "node_modules/@kie/act-js": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@kie/act-js/-/act-js-2.2.0.tgz", + "integrity": "sha512-AIh+M6UqPteJo6QMVBJO0QO5Q8LU7mBMth+X1hLUpZ54jPvOPovmZL96mmbtCQX9a8R1eKRnPBtms+Dloxp7SA==", + "dev": true, + "hasInstallScript": true, + "dependencies": { + "@kie/mock-github": "^1.0.3", + "adm-zip": "^0.5.10", + "ajv": "^8.12.0", + "bin-links": "^4.0.1", + "express": "^4.18.1", + "follow-redirects": "^1.15.2", + "tar": "^6.1.13", + "yaml": "^2.1.3" + }, + "bin": { + "act-js": "bin/act" + } + }, + "node_modules/@kie/mock-github": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@kie/mock-github/-/mock-github-1.1.0.tgz", + "integrity": "sha512-fD+utlOiyZSOutOcXL0G9jfjbtvOO44PLUyTfgfkrm1+575R/dbvU6AcJfjc1DtHeRv7FC7f4ebyU+a1wgL6CA==", + "dev": true, + "dependencies": { + "@octokit/openapi-types-ghec": "^14.0.0", + "ajv": "^8.11.0", + "express": "^4.18.1", + "fast-glob": "^3.2.12", + "fs-extra": "^10.1.0", + "nock": "^13.2.7", + "simple-git": "^3.8.0", + "totalist": "^3.0.0" + } + }, + "node_modules/@kie/mock-github/node_modules/fs-extra": { + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz", + "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==", + "dev": true, + "dependencies": { + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^2.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/@kie/mock-github/node_modules/totalist": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/totalist/-/totalist-3.0.1.tgz", + "integrity": "sha512-sf4i37nQ2LBx4m3wB74y+ubopq6W/dIzXg0FDGjsYnZHVa1Da8FH853wlL2gtUhg+xJXjfk3kUZS3BRoQeoQBQ==", + "dev": true, + "engines": { + "node": ">=6" + } + }, "node_modules/@kwsites/file-exists": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/@kwsites/file-exists/-/file-exists-1.1.1.tgz", @@ -5273,6 +5341,12 @@ "dev": true, "license": "MIT" }, + "node_modules/@octokit/openapi-types-ghec": { + "version": "14.0.0", + "resolved": "https://registry.npmjs.org/@octokit/openapi-types-ghec/-/openapi-types-ghec-14.0.0.tgz", + "integrity": "sha512-xhd9oEvn2aroGn+sk09Ptx/76Y7aKU0EIgHukHPCU1+rGJreO36baEEk6k8ZPblieHNM39FcykJQmtDrETm0KA==", + "dev": true + }, "node_modules/@octokit/plugin-paginate-rest": { "version": "3.1.0", "dev": true, @@ -5379,8 +5453,8 @@ }, "node_modules/@oguzhnatly/react-native-image-manipulator": { "version": "1.0.5", - "resolved": "git+ssh://git@github.com/Expensify/react-native-image-manipulator.git#5cdae3d4455b03a04c57f50be3863e2fe6c92c52", - "integrity": "sha512-C9Br1BQqm6io6lvYHptlLcOHbzlaqxp9tS35P8Qj3pdiiYRTzU3KPvZ61rQ+ZnZ4FOQ6MwPsKsmB8+6WHkAY6Q==", + "resolved": "git+ssh://git@github.com/Expensify/react-native-image-manipulator.git#c5f654fc9d0ad7cc5b89d50b34ecf8b0e3f4d050", + "integrity": "sha512-PvrSoCq5PS1MA5ZWUpB0khfzH6sM8SI6YiVl4i2SItPr7IeRxiWfI4n45VhBCCElc1z5GhAwTZOBaIzXTX7/og==", "license": "MIT" }, "node_modules/@onfido/active-video-capture": { @@ -8005,6 +8079,36 @@ "react": "*" } }, + "node_modules/@react-navigation/drawer": { + "version": "6.5.0-alpha1", + "resolved": "git+ssh://git@github.com/Expensify/react-navigation.git#bee9dc3f6bd03bb24f529efcb9f0d5d5832df6d6", + "license": "MIT", + "dependencies": { + "@react-navigation/elements": "^1.3.6", + "color": "^4.2.3", + "warn-once": "^0.1.0" + }, + "peerDependencies": { + "@react-navigation/native": "^6.0.0", + "react": "*", + "react-native": "*", + "react-native-gesture-handler": ">= 2.0.0", + "react-native-reanimated": "*", + "react-native-safe-area-context": ">= 3.0.0", + "react-native-screens": ">= 3.0.0" + } + }, + "node_modules/@react-navigation/drawer/node_modules/@react-navigation/elements": { + "version": "1.3.18", + "resolved": "https://registry.npmjs.org/@react-navigation/elements/-/elements-1.3.18.tgz", + "integrity": "sha512-/0hwnJkrr415yP0Hf4PjUKgGyfshrvNUKFXN85Mrt1gY49hy9IwxZgrrxlh0THXkPeq8q4VWw44eHDfAcQf20Q==", + "peerDependencies": { + "@react-navigation/native": "^6.0.0", + "react": "*", + "react-native": "*", + "react-native-safe-area-context": ">= 3.0.0" + } + }, "node_modules/@react-navigation/native": { "version": "6.1.6", "resolved": "https://registry.npmjs.org/@react-navigation/native/-/native-6.1.6.tgz", @@ -15806,6 +15910,15 @@ "@types/istanbul-lib-report": "*" } }, + "node_modules/@types/jest": { + "version": "29.5.2", + "resolved": "https://registry.npmjs.org/@types/jest/-/jest-29.5.2.tgz", + "integrity": "sha512-mSoZVJF5YzGVCk+FsDxzDuH7s+SCkzrgKZzf0Z0T2WudhBUPoF6ktoTPC4R0ZoCPCV5xUvuU6ias5NvxcBcMMg==", + "dependencies": { + "expect": "^29.0.0", + "pretty-format": "^29.0.0" + } + }, "node_modules/@types/jsdom": { "version": "20.0.1", "dev": true, @@ -15891,8 +16004,9 @@ "dev": true }, "node_modules/@types/node": { - "version": "18.7.6", - "license": "MIT" + "version": "18.16.18", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.16.18.tgz", + "integrity": "sha512-/aNaQZD0+iSBAGnvvN2Cx92HqE5sZCPZtx2TsK+4nvV23fFe09jVDvpArXr2j9DnYlzuU9WuoykDDc6wqvpNcw==" }, "node_modules/@types/node-fetch": { "version": "2.6.2", @@ -16835,6 +16949,15 @@ "node": ">= 10.0.0" } }, + "node_modules/adm-zip": { + "version": "0.5.10", + "resolved": "https://registry.npmjs.org/adm-zip/-/adm-zip-0.5.10.tgz", + "integrity": "sha512-x0HvcHqVJNTPk/Bw8JbLWlWoo6Wwnsug0fnYYro1HBrjxZ3G7/AZk7Ahv8JwDe1uIcz8eBqvu86FuF1POiG7vQ==", + "dev": true, + "engines": { + "node": ">=6.0" + } + }, "node_modules/agent-base": { "version": "6.0.2", "dev": true, @@ -16897,8 +17020,9 @@ } }, "node_modules/ajv": { - "version": "8.11.0", - "license": "MIT", + "version": "8.12.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.12.0.tgz", + "integrity": "sha512-sRu1kpcO9yLtYxBKvqfTeh9KzZEwO3STyX1HT+4CaDzC6HpTGYhIhPIzj9XuKU7KYDwnaeh5hcOwjy1QuJzBPA==", "dependencies": { "fast-deep-equal": "^3.1.1", "json-schema-traverse": "^1.0.0", @@ -18690,6 +18814,46 @@ "node": "*" } }, + "node_modules/bin-links": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/bin-links/-/bin-links-4.0.1.tgz", + "integrity": "sha512-bmFEM39CyX336ZGGRsGPlc6jZHriIoHacOQcTt72MktIjpPhZoP4te2jOyUXF3BLILmJ8aNLncoPVeIIFlrDeA==", + "dev": true, + "dependencies": { + "cmd-shim": "^6.0.0", + "npm-normalize-package-bin": "^3.0.0", + "read-cmd-shim": "^4.0.0", + "write-file-atomic": "^5.0.0" + }, + "engines": { + "node": "^14.17.0 || ^16.13.0 || >=18.0.0" + } + }, + "node_modules/bin-links/node_modules/signal-exit": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.0.2.tgz", + "integrity": "sha512-MY2/qGx4enyjprQnFaZsHib3Yadh3IXyV2C321GY0pjGfVBu4un0uDJkwgdxqO+Rdx8JMT8IfJIRwbYVz3Ob3Q==", + "dev": true, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/bin-links/node_modules/write-file-atomic": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-5.0.1.tgz", + "integrity": "sha512-+QU2zd6OTD8XWIJCbffaiQeH9U73qIqafo1x6V1snCWYGJf6cVE0cDR4D8xRzcEnfI21IFrUPzPGtcPf8AC+Rw==", + "dev": true, + "dependencies": { + "imurmurhash": "^0.1.4", + "signal-exit": "^4.0.1" + }, + "engines": { + "node": "^14.17.0 || ^16.13.0 || >=18.0.0" + } + }, "node_modules/binary-extensions": { "version": "2.2.0", "devOptional": true, @@ -20070,6 +20234,15 @@ "node": ">=6" } }, + "node_modules/cmd-shim": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/cmd-shim/-/cmd-shim-6.0.1.tgz", + "integrity": "sha512-S9iI9y0nKR4hwEQsVWpyxld/6kRfGepGfzff83FcaiEBpmvlbA2nnGe7Cylgrx2f/p1P5S5wpRm9oL8z1PbS3Q==", + "dev": true, + "engines": { + "node": "^14.17.0 || ^16.13.0 || >=18.0.0" + } + }, "node_modules/co": { "version": "4.6.0", "license": "MIT", @@ -20700,6 +20873,15 @@ "node": ">=10" } }, + "node_modules/cosmiconfig/node_modules/yaml": { + "version": "1.10.2", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-1.10.2.tgz", + "integrity": "sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==", + "dev": true, + "engines": { + "node": ">= 6" + } + }, "node_modules/cp-file": { "version": "7.0.0", "dev": true, @@ -24695,9 +24877,10 @@ "license": "MIT" }, "node_modules/fast-glob": { - "version": "3.2.11", + "version": "3.2.12", + "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.12.tgz", + "integrity": "sha512-DVj4CQIYYow0BlaelwK1pHl5n5cRSJfM60UA0zK891sVInoPri2Ekj7+e1CT3/3qxXenpI+nBBmQAcJPJgaj4w==", "dev": true, - "license": "MIT", "dependencies": { "@nodelib/fs.stat": "^2.0.2", "@nodelib/fs.walk": "^1.2.3", @@ -25142,7 +25325,9 @@ } }, "node_modules/follow-redirects": { - "version": "1.15.1", + "version": "1.15.2", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.2.tgz", + "integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==", "dev": true, "funding": [ { @@ -25150,7 +25335,6 @@ "url": "https://github.com/sponsors/RubenVerborgh" } ], - "license": "MIT", "engines": { "node": ">=4.0" }, @@ -25349,6 +25533,15 @@ "node": ">=8" } }, + "node_modules/fork-ts-checker-webpack-plugin/node_modules/yaml": { + "version": "1.10.2", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-1.10.2.tgz", + "integrity": "sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==", + "dev": true, + "engines": { + "node": ">= 6" + } + }, "node_modules/form-data": { "version": "3.0.1", "dev": true, @@ -33908,6 +34101,21 @@ "node": ">=12.0.0" } }, + "node_modules/nock": { + "version": "13.3.1", + "resolved": "https://registry.npmjs.org/nock/-/nock-13.3.1.tgz", + "integrity": "sha512-vHnopocZuI93p2ccivFyGuUfzjq2fxNyNurp7816mlT5V5HF4SzXu8lvLrVzBbNqzs+ODooZ6OksuSUNM7Njkw==", + "dev": true, + "dependencies": { + "debug": "^4.1.0", + "json-stringify-safe": "^5.0.1", + "lodash": "^4.17.21", + "propagate": "^2.0.0" + }, + "engines": { + "node": ">= 10.13" + } + }, "node_modules/node-abi": { "version": "3.45.0", "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.45.0.tgz", @@ -34206,6 +34414,15 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/npm-normalize-package-bin": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/npm-normalize-package-bin/-/npm-normalize-package-bin-3.0.1.tgz", + "integrity": "sha512-dMxCf+zZ+3zeQZXKxmyuCKlIDPGuv8EF940xbkC4kQVDTtqoh6rJFO+JTKSA6/Rwi0getWmtuy4Itup0AMcaDQ==", + "dev": true, + "engines": { + "node": "^14.17.0 || ^16.13.0 || >=18.0.0" + } + }, "node_modules/npm-run-path": { "version": "4.0.1", "license": "MIT", @@ -35241,6 +35458,14 @@ "which": "bin/which" } }, + "node_modules/patch-package/node_modules/yaml": { + "version": "1.10.2", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-1.10.2.tgz", + "integrity": "sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==", + "engines": { + "node": ">= 6" + } + }, "node_modules/path-browserify": { "version": "0.0.1", "license": "MIT" @@ -35906,6 +36131,15 @@ "react-is": "^16.13.1" } }, + "node_modules/propagate": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/propagate/-/propagate-2.0.1.tgz", + "integrity": "sha512-vGrhOavPSTz4QVNuBNdcNXePNdNMaO1xj9yBeH1ScQPjk/rhg9sSlCXPhMkFuaNNW/syTvYqsnbIJxMBfRbbag==", + "dev": true, + "engines": { + "node": ">= 8" + } + }, "node_modules/property-information": { "version": "5.6.0", "dev": true, @@ -37724,6 +37958,15 @@ "react-dom": ">=16.2.0" } }, + "node_modules/read-cmd-shim": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/read-cmd-shim/-/read-cmd-shim-4.0.0.tgz", + "integrity": "sha512-yILWifhaSEEytfXI76kB9xEEiG1AiozaCJZ83A87ytjRiN+jVibXjedjCRNjoZviinhG+4UkalO3mWTd8u5O0Q==", + "dev": true, + "engines": { + "node": "^14.17.0 || ^16.13.0 || >=18.0.0" + } + }, "node_modules/read-config-file": { "version": "6.3.2", "resolved": "https://registry.npmjs.org/read-config-file/-/read-config-file-6.3.2.tgz", @@ -41853,6 +42096,15 @@ "version": "1.0.0", "license": "ISC" }, + "node_modules/urbanairship-react-native": { + "version": "14.6.1", + "resolved": "https://registry.npmjs.org/urbanairship-react-native/-/urbanairship-react-native-14.6.1.tgz", + "integrity": "sha512-ddL3ZWZnhwCja9oMpq7YHEyuqca1IH34MtMm24w1SePzGRhcVAvKOe/lncIB1FAK6QyjG0pkPT5mu3vE/DsPEw==", + "peerDependencies": { + "react": "*", + "react-native": "*" + } + }, "node_modules/uri-js": { "version": "4.4.1", "license": "BSD-2-Clause", @@ -43577,10 +43829,12 @@ "license": "ISC" }, "node_modules/yaml": { - "version": "1.10.2", - "license": "ISC", + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.3.1.tgz", + "integrity": "sha512-2eHWfjaoXgTBC2jNM1LRef62VQa0umtvRiDSk6HSzW7RvS5YtkabJrwYLLEKWBc8a5U2PTSCs+dJjUTJdlHsWQ==", + "dev": true, "engines": { - "node": ">= 6" + "node": ">= 14" } }, "node_modules/yargs": { @@ -46800,6 +47054,57 @@ "version": "2.3.1", "requires": {} }, + "@kie/act-js": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@kie/act-js/-/act-js-2.2.0.tgz", + "integrity": "sha512-AIh+M6UqPteJo6QMVBJO0QO5Q8LU7mBMth+X1hLUpZ54jPvOPovmZL96mmbtCQX9a8R1eKRnPBtms+Dloxp7SA==", + "dev": true, + "requires": { + "@kie/mock-github": "^1.0.3", + "adm-zip": "^0.5.10", + "ajv": "^8.12.0", + "bin-links": "^4.0.1", + "express": "^4.18.1", + "follow-redirects": "^1.15.2", + "tar": "^6.1.13", + "yaml": "^2.1.3" + } + }, + "@kie/mock-github": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@kie/mock-github/-/mock-github-1.1.0.tgz", + "integrity": "sha512-fD+utlOiyZSOutOcXL0G9jfjbtvOO44PLUyTfgfkrm1+575R/dbvU6AcJfjc1DtHeRv7FC7f4ebyU+a1wgL6CA==", + "dev": true, + "requires": { + "@octokit/openapi-types-ghec": "^14.0.0", + "ajv": "^8.11.0", + "express": "^4.18.1", + "fast-glob": "^3.2.12", + "fs-extra": "^10.1.0", + "nock": "^13.2.7", + "simple-git": "^3.8.0", + "totalist": "^3.0.0" + }, + "dependencies": { + "fs-extra": { + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz", + "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==", + "dev": true, + "requires": { + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^2.0.0" + } + }, + "totalist": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/totalist/-/totalist-3.0.1.tgz", + "integrity": "sha512-sf4i37nQ2LBx4m3wB74y+ubopq6W/dIzXg0FDGjsYnZHVa1Da8FH853wlL2gtUhg+xJXjfk3kUZS3BRoQeoQBQ==", + "dev": true + } + } + }, "@kwsites/file-exists": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/@kwsites/file-exists/-/file-exists-1.1.1.tgz", @@ -47116,6 +47421,12 @@ "version": "12.11.0", "dev": true }, + "@octokit/openapi-types-ghec": { + "version": "14.0.0", + "resolved": "https://registry.npmjs.org/@octokit/openapi-types-ghec/-/openapi-types-ghec-14.0.0.tgz", + "integrity": "sha512-xhd9oEvn2aroGn+sk09Ptx/76Y7aKU0EIgHukHPCU1+rGJreO36baEEk6k8ZPblieHNM39FcykJQmtDrETm0KA==", + "dev": true + }, "@octokit/plugin-paginate-rest": { "version": "3.1.0", "dev": true, @@ -47194,9 +47505,9 @@ } }, "@oguzhnatly/react-native-image-manipulator": { - "version": "git+ssh://git@github.com/Expensify/react-native-image-manipulator.git#5cdae3d4455b03a04c57f50be3863e2fe6c92c52", - "integrity": "sha512-C9Br1BQqm6io6lvYHptlLcOHbzlaqxp9tS35P8Qj3pdiiYRTzU3KPvZ61rQ+ZnZ4FOQ6MwPsKsmB8+6WHkAY6Q==", - "from": "@oguzhnatly/react-native-image-manipulator@github:Expensify/react-native-image-manipulator#5cdae3d4455b03a04c57f50be3863e2fe6c92c52" + "version": "git+ssh://git@github.com/Expensify/react-native-image-manipulator.git#c5f654fc9d0ad7cc5b89d50b34ecf8b0e3f4d050", + "integrity": "sha512-PvrSoCq5PS1MA5ZWUpB0khfzH6sM8SI6YiVl4i2SItPr7IeRxiWfI4n45VhBCCElc1z5GhAwTZOBaIzXTX7/og==", + "from": "@oguzhnatly/react-native-image-manipulator@github:Expensify/react-native-image-manipulator#c5f654fc9d0ad7cc5b89d50b34ecf8b0e3f4d050" }, "@onfido/active-video-capture": { "version": "0.27.3", @@ -49150,6 +49461,23 @@ "stacktrace-parser": "^0.1.10" } }, + "@react-navigation/drawer": { + "version": "git+ssh://git@github.com/Expensify/react-navigation.git#bee9dc3f6bd03bb24f529efcb9f0d5d5832df6d6", + "from": "@react-navigation/drawer@github:Expensify/react-navigation#react-navigation-drawer-v6.5.0-alpha1-gitpkg", + "requires": { + "@react-navigation/elements": "^1.3.6", + "color": "^4.2.3", + "warn-once": "^0.1.0" + }, + "dependencies": { + "@react-navigation/elements": { + "version": "1.3.18", + "resolved": "https://registry.npmjs.org/@react-navigation/elements/-/elements-1.3.18.tgz", + "integrity": "sha512-/0hwnJkrr415yP0Hf4PjUKgGyfshrvNUKFXN85Mrt1gY49hy9IwxZgrrxlh0THXkPeq8q4VWw44eHDfAcQf20Q==", + "requires": {} + } + } + }, "@react-navigation/native": { "version": "6.1.6", "resolved": "https://registry.npmjs.org/@react-navigation/native/-/native-6.1.6.tgz", @@ -54298,6 +54626,15 @@ "@types/istanbul-lib-report": "*" } }, + "@types/jest": { + "version": "29.5.2", + "resolved": "https://registry.npmjs.org/@types/jest/-/jest-29.5.2.tgz", + "integrity": "sha512-mSoZVJF5YzGVCk+FsDxzDuH7s+SCkzrgKZzf0Z0T2WudhBUPoF6ktoTPC4R0ZoCPCV5xUvuU6ias5NvxcBcMMg==", + "requires": { + "expect": "^29.0.0", + "pretty-format": "^29.0.0" + } + }, "@types/jsdom": { "version": "20.0.1", "dev": true, @@ -54366,7 +54703,9 @@ "dev": true }, "@types/node": { - "version": "18.7.6" + "version": "18.16.18", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.16.18.tgz", + "integrity": "sha512-/aNaQZD0+iSBAGnvvN2Cx92HqE5sZCPZtx2TsK+4nvV23fFe09jVDvpArXr2j9DnYlzuU9WuoykDDc6wqvpNcw==" }, "@types/node-fetch": { "version": "2.6.2", @@ -55051,6 +55390,12 @@ "version": "1.2.1", "dev": true }, + "adm-zip": { + "version": "0.5.10", + "resolved": "https://registry.npmjs.org/adm-zip/-/adm-zip-0.5.10.tgz", + "integrity": "sha512-x0HvcHqVJNTPk/Bw8JbLWlWoo6Wwnsug0fnYYro1HBrjxZ3G7/AZk7Ahv8JwDe1uIcz8eBqvu86FuF1POiG7vQ==", + "dev": true + }, "agent-base": { "version": "6.0.2", "dev": true, @@ -55101,7 +55446,9 @@ } }, "ajv": { - "version": "8.11.0", + "version": "8.12.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.12.0.tgz", + "integrity": "sha512-sRu1kpcO9yLtYxBKvqfTeh9KzZEwO3STyX1HT+4CaDzC6HpTGYhIhPIzj9XuKU7KYDwnaeh5hcOwjy1QuJzBPA==", "requires": { "fast-deep-equal": "^3.1.1", "json-schema-traverse": "^1.0.0", @@ -56336,6 +56683,36 @@ "version": "5.2.2", "devOptional": true }, + "bin-links": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/bin-links/-/bin-links-4.0.1.tgz", + "integrity": "sha512-bmFEM39CyX336ZGGRsGPlc6jZHriIoHacOQcTt72MktIjpPhZoP4te2jOyUXF3BLILmJ8aNLncoPVeIIFlrDeA==", + "dev": true, + "requires": { + "cmd-shim": "^6.0.0", + "npm-normalize-package-bin": "^3.0.0", + "read-cmd-shim": "^4.0.0", + "write-file-atomic": "^5.0.0" + }, + "dependencies": { + "signal-exit": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.0.2.tgz", + "integrity": "sha512-MY2/qGx4enyjprQnFaZsHib3Yadh3IXyV2C321GY0pjGfVBu4un0uDJkwgdxqO+Rdx8JMT8IfJIRwbYVz3Ob3Q==", + "dev": true + }, + "write-file-atomic": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-5.0.1.tgz", + "integrity": "sha512-+QU2zd6OTD8XWIJCbffaiQeH9U73qIqafo1x6V1snCWYGJf6cVE0cDR4D8xRzcEnfI21IFrUPzPGtcPf8AC+Rw==", + "dev": true, + "requires": { + "imurmurhash": "^0.1.4", + "signal-exit": "^4.0.1" + } + } + } + }, "binary-extensions": { "version": "2.2.0", "devOptional": true @@ -57271,6 +57648,12 @@ "resolved": "https://registry.npmjs.org/clsx/-/clsx-1.2.1.tgz", "integrity": "sha512-EcR6r5a8bj6pu3ycsa/E/cKVGuTgZJZdsyUYHOksG/UHIiKfjxzRxYJpyVBwYaQeOvghal9fcc4PidlgzugAQg==" }, + "cmd-shim": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/cmd-shim/-/cmd-shim-6.0.1.tgz", + "integrity": "sha512-S9iI9y0nKR4hwEQsVWpyxld/6kRfGepGfzff83FcaiEBpmvlbA2nnGe7Cylgrx2f/p1P5S5wpRm9oL8z1PbS3Q==", + "dev": true + }, "co": { "version": "4.6.0" }, @@ -57681,6 +58064,14 @@ "parse-json": "^5.0.0", "path-type": "^4.0.0", "yaml": "^1.10.0" + }, + "dependencies": { + "yaml": { + "version": "1.10.2", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-1.10.2.tgz", + "integrity": "sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==", + "dev": true + } } }, "cp-file": { @@ -60380,7 +60771,9 @@ "version": "4.0.3" }, "fast-glob": { - "version": "3.2.11", + "version": "3.2.12", + "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.12.tgz", + "integrity": "sha512-DVj4CQIYYow0BlaelwK1pHl5n5cRSJfM60UA0zK891sVInoPri2Ekj7+e1CT3/3qxXenpI+nBBmQAcJPJgaj4w==", "dev": true, "requires": { "@nodelib/fs.stat": "^2.0.2", @@ -60699,7 +61092,9 @@ } }, "follow-redirects": { - "version": "1.15.1", + "version": "1.15.2", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.2.tgz", + "integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==", "dev": true }, "for-each": { @@ -60814,6 +61209,12 @@ "requires": { "has-flag": "^4.0.0" } + }, + "yaml": { + "version": "1.10.2", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-1.10.2.tgz", + "integrity": "sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==", + "dev": true } } }, @@ -66498,6 +66899,18 @@ "resolved": "https://registry.npmjs.org/nocache/-/nocache-3.0.4.tgz", "integrity": "sha512-WDD0bdg9mbq6F4mRxEYcPWwfA1vxd0mrvKOyxI7Xj/atfRHVeutzuWByG//jfm4uPzp0y4Kj051EORCBSQMycw==" }, + "nock": { + "version": "13.3.1", + "resolved": "https://registry.npmjs.org/nock/-/nock-13.3.1.tgz", + "integrity": "sha512-vHnopocZuI93p2ccivFyGuUfzjq2fxNyNurp7816mlT5V5HF4SzXu8lvLrVzBbNqzs+ODooZ6OksuSUNM7Njkw==", + "dev": true, + "requires": { + "debug": "^4.1.0", + "json-stringify-safe": "^5.0.1", + "lodash": "^4.17.21", + "propagate": "^2.0.0" + } + }, "node-abi": { "version": "3.45.0", "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.45.0.tgz", @@ -66719,6 +67132,12 @@ "version": "6.1.0", "dev": true }, + "npm-normalize-package-bin": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/npm-normalize-package-bin/-/npm-normalize-package-bin-3.0.1.tgz", + "integrity": "sha512-dMxCf+zZ+3zeQZXKxmyuCKlIDPGuv8EF940xbkC4kQVDTtqoh6rJFO+JTKSA6/Rwi0getWmtuy4Itup0AMcaDQ==", + "dev": true + }, "npm-run-path": { "version": "4.0.1", "requires": { @@ -67401,6 +67820,11 @@ "requires": { "isexe": "^2.0.0" } + }, + "yaml": { + "version": "1.10.2", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-1.10.2.tgz", + "integrity": "sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==" } } }, @@ -67832,6 +68256,12 @@ "react-is": "^16.13.1" } }, + "propagate": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/propagate/-/propagate-2.0.1.tgz", + "integrity": "sha512-vGrhOavPSTz4QVNuBNdcNXePNdNMaO1xj9yBeH1ScQPjk/rhg9sSlCXPhMkFuaNNW/syTvYqsnbIJxMBfRbbag==", + "dev": true + }, "property-information": { "version": "5.6.0", "dev": true, @@ -69032,6 +69462,12 @@ "integrity": "sha512-2W5WN8wmEv8ZlxvyAlOxVuw6new8Bi7+KSPqoq5oa7z1KSKZ72ucaKqCFRtHSuFjZ5sh5ioS9lp4BGwnaZ6lDg==", "requires": {} }, + "read-cmd-shim": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/read-cmd-shim/-/read-cmd-shim-4.0.0.tgz", + "integrity": "sha512-yILWifhaSEEytfXI76kB9xEEiG1AiozaCJZ83A87ytjRiN+jVibXjedjCRNjoZviinhG+4UkalO3mWTd8u5O0Q==", + "dev": true + }, "read-config-file": { "version": "6.3.2", "resolved": "https://registry.npmjs.org/read-config-file/-/read-config-file-6.3.2.tgz", @@ -71817,6 +72253,12 @@ } } }, + "urbanairship-react-native": { + "version": "14.6.1", + "resolved": "https://registry.npmjs.org/urbanairship-react-native/-/urbanairship-react-native-14.6.1.tgz", + "integrity": "sha512-ddL3ZWZnhwCja9oMpq7YHEyuqca1IH34MtMm24w1SePzGRhcVAvKOe/lncIB1FAK6QyjG0pkPT5mu3vE/DsPEw==", + "requires": {} + }, "uri-js": { "version": "4.4.1", "requires": { @@ -72951,7 +73393,10 @@ "version": "4.0.0" }, "yaml": { - "version": "1.10.2" + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.3.1.tgz", + "integrity": "sha512-2eHWfjaoXgTBC2jNM1LRef62VQa0umtvRiDSk6HSzW7RvS5YtkabJrwYLLEKWBc8a5U2PTSCs+dJjUTJdlHsWQ==", + "dev": true }, "yargs": { "version": "13.3.2", From bc1487c27afa50cd805d780864808ecc60f1b956 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Fri, 30 Jun 2023 16:15:21 +0200 Subject: [PATCH 101/504] Fix cherryPick tests Tests were failing after recent changes in main See: https://github.com/Expensify/App/issues/13604 --- .github/workflows/warnCPLabel.yml | 0 .../assertions/cherryPickAssertions.js | 131 +- .../assertions/warnCPLabelAssertions.js | 41 - workflow_tests/cherryPick.test.js | 1299 +++++------------ workflow_tests/mocks/cherryPickMocks.js | 133 +- workflow_tests/mocks/warnCPLabelMocks.js | 25 - workflow_tests/warnCPLabel.test.js | 127 -- 7 files changed, 391 insertions(+), 1365 deletions(-) delete mode 100644 .github/workflows/warnCPLabel.yml delete mode 100644 workflow_tests/assertions/warnCPLabelAssertions.js delete mode 100644 workflow_tests/mocks/warnCPLabelMocks.js delete mode 100644 workflow_tests/warnCPLabel.test.js diff --git a/.github/workflows/warnCPLabel.yml b/.github/workflows/warnCPLabel.yml deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/workflow_tests/assertions/cherryPickAssertions.js b/workflow_tests/assertions/cherryPickAssertions.js index 904732d9ebd6..7360858d8fed 100644 --- a/workflow_tests/assertions/cherryPickAssertions.js +++ b/workflow_tests/assertions/cherryPickAssertions.js @@ -1,21 +1,7 @@ const utils = require('../utils/utils'); -const assertValidateActorJobExecuted = (workflowResult, username = 'Dummy Author', didExecute = true) => { - const steps = [ - utils.createStepAssertion( - 'Check if user is deployer', - true, - null, - 'VALIDATEACTOR', - 'Checking if user is a deployer', - [ - {key: 'GITHUB_TOKEN', value: '***'}, - {key: 'username', value: username}, - {key: 'team', value: 'mobile-deployers'}, - ], - [], - ), - ]; +const assertValidateActorJobExecuted = (workflowResult, didExecute = true) => { + const steps = [utils.createStepAssertion('Check if user is deployer', true, null, 'VALIDATEACTOR', 'Checking if user is a deployer', [], [{key: 'GITHUB_TOKEN', value: '***'}])]; steps.forEach((expectedStep) => { if (didExecute) { @@ -42,13 +28,9 @@ const assertCherryPickJobExecuted = ( workflowResult, user = 'Dummy Author', pullRequestNumber = '1234', - newVersion = '1.2.3', didExecute = true, - mergeConflictsOrVersionMismatch = false, - shouldAutomerge = true, - versionsMatch = true, - prIsMergeable = true, inputNewVersion = '', + hasConflicts = false, isSuccessful = true, ) => { const steps = [ @@ -65,7 +47,6 @@ const assertCherryPickJobExecuted = ( [], ), utils.createStepAssertion('Set up git for OSBotify', true, null, 'CHERRYPICK', 'Setting up git for OSBotify', [{key: 'GPG_PASSPHRASE', value: '***'}], []), - utils.createStepAssertion('Create branch for new pull request', true, null, 'CHERRYPICK', 'Creating branch for new pull request', [], []), utils.createStepAssertion( 'Get merge commit for CP pull request', true, @@ -80,36 +61,9 @@ const assertCherryPickJobExecuted = ( [], ), utils.createStepAssertion('Save correct NEW_VERSION to env', true, inputNewVersion ? `New version is ${inputNewVersion}` : 'New version is'), - utils.createStepAssertion( - 'Get merge commit for version-bump pull request', - true, - null, - 'CHERRYPICK', - 'Getting merge commit for version-bump pull request', - [ - {key: 'GITHUB_TOKEN', value: '***'}, - {key: 'USER', value: 'OSBotify'}, - {key: 'TITLE_REGEX', value: `Update version to ${newVersion}`}, - ], - [], - ), - utils.createStepAssertion('Cherry-pick the version-bump to new branch', true, null, 'CHERRYPICK', 'Cherry-picking the version-bump to new branch', [], []), - utils.createStepAssertion('Cherry-pick the merge commit of target PR to new branch', true, null, 'CHERRYPICK', 'Cherry-picking the merge commit of target PR to new branch', [], []), - utils.createStepAssertion('Push changes to CP branch', true, null, 'CHERRYPICK', 'Pushing changes to CP branch', [], []), - utils.createStepAssertion('Create Pull Request', true, null, 'CHERRYPICK', 'Creating Pull Request', [], [{key: 'GITHUB_TOKEN', value: '***'}]), - utils.createStepAssertion('Check if ShortVersionString is up to date', true, null, 'CHERRYPICK', 'Checking if ShortVersionString is up to date', [], []), - utils.createStepAssertion( - 'Check if pull request is mergeable', - true, - null, - 'CHERRYPICK', - 'Checking if pull request is mergeable', - [ - {key: 'GITHUB_TOKEN', value: '***'}, - {key: 'PULL_REQUEST_NUMBER', value: pullRequestNumber}, - ], - [], - ), + utils.createStepAssertion('Cherry-pick the version-bump to staging', true, null, 'CHERRYPICK', 'Cherry-picking the version-bump to staging', [], []), + utils.createStepAssertion('Cherry-pick the merge commit of target PR', true, null, 'CHERRYPICK', 'Cherry-picking the merge commit of target PR', [], []), + utils.createStepAssertion('Push changes', true, null, 'CHERRYPICK', 'Pushing changes', [], []), ]; steps.forEach((expectedStep) => { @@ -120,71 +74,20 @@ const assertCherryPickJobExecuted = ( } }); - const conflictsSteps = [ + const conflictSteps = [ utils.createStepAssertion( - 'Auto-assign PR if there are merge conflicts or if the bundle versions are mismatched', + 'Create Pull Request to manually finish CP', true, null, 'CHERRYPICK', - 'Auto-assigning PR', + 'Creating Pull Request to manually finish CP', [], [{key: 'GITHUB_TOKEN', value: '***'}], ), ]; - conflictsSteps.forEach((step) => { - if (didExecute && mergeConflictsOrVersionMismatch) { - expect(workflowResult).toEqual(expect.arrayContaining([step])); - } else { - expect(workflowResult).not.toEqual(expect.arrayContaining([step])); - } - }); - - const manualMergeSteps = [ - utils.createStepAssertion('Assign the PR to the deployer', true, null, 'CHERRYPICK', 'Assigning the PR to the deployer', [], [{key: 'GITHUB_TOKEN', value: '***'}]), - utils.createStepAssertion( - 'If PR has merge conflicts, comment with instructions for assignee', - true, - null, - 'CHERRYPICK', - 'Commenting with instructions for assignee', - [], - [{key: 'GITHUB_TOKEN', value: '***'}], - ), - ]; - - manualMergeSteps.forEach((step) => { - if (didExecute && !shouldAutomerge) { - expect(workflowResult).toEqual(expect.arrayContaining([step])); - } else { - expect(workflowResult).not.toEqual(expect.arrayContaining([step])); - } - }); - - const autoMergeSteps = [utils.createStepAssertion('Auto-approve the PR', true, null, 'CHERRYPICK', 'Auto-approving the PR', [], [{key: 'GITHUB_TOKEN', value: '***'}])]; - - autoMergeSteps.forEach((step) => { - if (didExecute && shouldAutomerge) { - expect(workflowResult).toEqual(expect.arrayContaining([step])); - } else { - expect(workflowResult).not.toEqual(expect.arrayContaining([step])); - } - }); - - const versionMismatchSteps = [ - utils.createStepAssertion( - 'If PR has a bundle version mismatch, comment with the instructions for assignee', - true, - null, - 'CHERRYPICK', - 'Commenting with the instructions for assignee', - [], - [{key: 'GITHUB_TOKEN', value: '***'}], - ), - ]; - - versionMismatchSteps.forEach((step) => { - if (didExecute && !versionsMatch) { + conflictSteps.forEach((step) => { + if (didExecute && hasConflicts) { expect(workflowResult).toEqual(expect.arrayContaining([step])); } else { expect(workflowResult).not.toEqual(expect.arrayContaining([step])); @@ -207,17 +110,7 @@ const assertCherryPickJobExecuted = ( ]; failedSteps.forEach((step) => { - if (didExecute && (!isSuccessful || !prIsMergeable)) { - expect(workflowResult).toEqual(expect.arrayContaining([step])); - } else { - expect(workflowResult).not.toEqual(expect.arrayContaining([step])); - } - }); - - const autoMergeableSteps = [utils.createStepAssertion('Auto-merge the PR', true, null, 'CHERRYPICK', 'Auto-merging the PR', [], [{key: 'GITHUB_TOKEN', value: '***'}])]; - - autoMergeableSteps.forEach((step) => { - if (didExecute && shouldAutomerge && prIsMergeable) { + if (didExecute && !isSuccessful) { expect(workflowResult).toEqual(expect.arrayContaining([step])); } else { expect(workflowResult).not.toEqual(expect.arrayContaining([step])); diff --git a/workflow_tests/assertions/warnCPLabelAssertions.js b/workflow_tests/assertions/warnCPLabelAssertions.js deleted file mode 100644 index a8eb34080815..000000000000 --- a/workflow_tests/assertions/warnCPLabelAssertions.js +++ /dev/null @@ -1,41 +0,0 @@ -const utils = require('../utils/utils'); - -const assertWarnCPLabelJobExecuted = (workflowResult, didExecute = true, isSuccessful = true) => { - const steps = [ - utils.createStepAssertion( - 'Comment on PR to explain the CP Staging label', - true, - null, - 'WARNCPLABEL', - 'Comment on PR to explain the CP Staging label', - [{key: 'github_token', value: '***'}], - [], - ), - ]; - - steps.forEach((expectedStep) => { - if (didExecute) { - if (isSuccessful) { - expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); - } - } else { - expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); - } - }); - - const failedSteps = [ - utils.createStepAssertion('Announce failed workflow in Slack', true, null, 'WARNCPLABEL', 'Announce failed workflow in Slack', [{key: 'SLACK_WEBHOOK', value: '***'}], []), - ]; - - failedSteps.forEach((step) => { - if (didExecute && !isSuccessful) { - expect(workflowResult).toEqual(expect.arrayContaining([step])); - } else { - expect(workflowResult).not.toEqual(expect.arrayContaining([step])); - } - }); -}; - -module.exports = { - assertWarnCPLabelJobExecuted, -}; diff --git a/workflow_tests/cherryPick.test.js b/workflow_tests/cherryPick.test.js index c76ed16371ee..bfc9beee5b96 100644 --- a/workflow_tests/cherryPick.test.js +++ b/workflow_tests/cherryPick.test.js @@ -64,7 +64,7 @@ describe('test workflow cherryPick', () => { ); const testMockSteps = { validateActor: mocks.CHERRYPICK__VALIDATEACTOR__FALSE__STEP_MOCKS, - cherryPick: mocks.getCherryPickMockSteps(true, true, true), + cherryPick: mocks.getCherryPickMockSteps(true, false), }; const testMockJobs = { createNewVersion: { @@ -84,9 +84,9 @@ describe('test workflow cherryPick', () => { mockJobs: testMockJobs, }); - assertions.assertValidateActorJobExecuted(result, actor); + assertions.assertValidateActorJobExecuted(result); assertions.assertCreateNewVersionJobExecuted(result, false); - assertions.assertCherryPickJobExecuted(result, actor, '1234', '1.2.3', false); + assertions.assertCherryPickJobExecuted(result, actor, '1234', false); }); }); describe('actor is OSBotify', () => { @@ -94,14 +94,13 @@ describe('test workflow cherryPick', () => { const newVersion = ''; const mergeConflicts = false; const versionsMatch = true; - const prIsMergeable = true; it('behaviour is the same as with actor being the deployer', async () => { const repoPath = mockGithub.repo.getPath('testCherryPickWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); const testMockSteps = { validateActor: mocks.CHERRYPICK__VALIDATEACTOR__FALSE__STEP_MOCKS, - cherryPick: mocks.getCherryPickMockSteps(versionsMatch, prIsMergeable, !mergeConflicts), + cherryPick: mocks.getCherryPickMockSteps(versionsMatch, mergeConflicts), }; const testMockJobs = { createNewVersion: { @@ -137,9 +136,9 @@ describe('test workflow cherryPick', () => { mockJobs: testMockJobs, }); - assertions.assertValidateActorJobExecuted(result, actor); + assertions.assertValidateActorJobExecuted(result); assertions.assertCreateNewVersionJobExecuted(result); - assertions.assertCherryPickJobExecuted(result, actor, '1234', '1.2.3', true, mergeConflicts || !versionsMatch, !mergeConflicts, versionsMatch, prIsMergeable, newVersion); + assertions.assertCherryPickJobExecuted(result, actor, '1234', true, newVersion); }); }); describe('actor is a deployer', () => { @@ -150,248 +149,100 @@ describe('test workflow cherryPick', () => { const mergeConflicts = false; describe('version match', () => { const versionsMatch = true; - describe('PR is mergeable', () => { - const prIsMergeable = true; - it('workflow executes, new version created, PR approved and merged automatically', async () => { - const repoPath = mockGithub.repo.getPath('testCherryPickWorkflowRepo') || ''; - const workflowPath = path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'); - let act = new eAct.ExtendedAct(repoPath, workflowPath); - const testMockSteps = { - validateActor: mocks.CHERRYPICK__VALIDATEACTOR__TRUE__STEP_MOCKS, - }; - testMockSteps.cherryPick = mocks.getCherryPickMockSteps(versionsMatch, prIsMergeable, !mergeConflicts); - const testMockJobs = { - createNewVersion: { - steps: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, - outputs: { - // eslint-disable-next-line no-template-curly-in-string - NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', - }, - runsOn: 'ubuntu-latest', - }, - }; - act = utils.setUpActParams( - act, - event, - null, - { - OS_BOTIFY_TOKEN: 'dummy_token', - LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', - SLACK_WEBHOOK: 'dummy_slack_webhook', - }, - 'dummy_github_token', - null, - { - PULL_REQUEST_NUMBER: '1234', - NEW_VERSION: newVersion, - }, - ); - const result = await act.runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), - mockSteps: testMockSteps, - actor, - logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), - mockJobs: testMockJobs, - }); - - assertions.assertValidateActorJobExecuted(result, actor); - assertions.assertCreateNewVersionJobExecuted(result); - assertions.assertCherryPickJobExecuted( - result, - actor, - '1234', - '1.2.3', - true, - mergeConflicts || !versionsMatch, - !mergeConflicts, - versionsMatch, - prIsMergeable, - newVersion, - ); + it('workflow executes, new version created, PR approved and merged automatically', async () => { + const repoPath = mockGithub.repo.getPath('testCherryPickWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + const testMockSteps = { + validateActor: mocks.CHERRYPICK__VALIDATEACTOR__TRUE__STEP_MOCKS, + }; + testMockSteps.cherryPick = mocks.getCherryPickMockSteps(versionsMatch, mergeConflicts); + const testMockJobs = { + createNewVersion: { + steps: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, + outputs: { + // eslint-disable-next-line no-template-curly-in-string + NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', + }, + runsOn: 'ubuntu-latest', + }, + }; + act = utils.setUpActParams( + act, + event, + null, + { + OS_BOTIFY_TOKEN: 'dummy_token', + LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', + SLACK_WEBHOOK: 'dummy_slack_webhook', + }, + 'dummy_github_token', + null, + { + PULL_REQUEST_NUMBER: '1234', + NEW_VERSION: newVersion, + }, + ); + const result = await act.runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), + mockSteps: testMockSteps, + actor, + logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), + mockJobs: testMockJobs, }); - }); - describe('PR is not mergeable', () => { - const prIsMergeable = false; - it('workflow executes, new version created, PR is not merged automatically', async () => { - const repoPath = mockGithub.repo.getPath('testCherryPickWorkflowRepo') || ''; - const workflowPath = path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'); - let act = new eAct.ExtendedAct(repoPath, workflowPath); - const testMockSteps = { - validateActor: mocks.CHERRYPICK__VALIDATEACTOR__TRUE__STEP_MOCKS, - }; - testMockSteps.cherryPick = mocks.getCherryPickMockSteps(versionsMatch, prIsMergeable, !mergeConflicts); - const testMockJobs = { - createNewVersion: { - steps: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, - outputs: { - // eslint-disable-next-line no-template-curly-in-string - NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', - }, - runsOn: 'ubuntu-latest', - }, - }; - act = utils.setUpActParams( - act, - event, - null, - { - OS_BOTIFY_TOKEN: 'dummy_token', - LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', - SLACK_WEBHOOK: 'dummy_slack_webhook', - }, - 'dummy_github_token', - null, - { - PULL_REQUEST_NUMBER: '1234', - NEW_VERSION: newVersion, - }, - ); - const result = await act.runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), - mockSteps: testMockSteps, - actor, - logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), - mockJobs: testMockJobs, - }); - assertions.assertValidateActorJobExecuted(result, actor); - assertions.assertCreateNewVersionJobExecuted(result); - assertions.assertCherryPickJobExecuted( - result, - actor, - '1234', - '1.2.3', - true, - mergeConflicts || !versionsMatch, - !mergeConflicts, - versionsMatch, - prIsMergeable, - newVersion, - ); - }); + assertions.assertValidateActorJobExecuted(result); + assertions.assertCreateNewVersionJobExecuted(result); + assertions.assertCherryPickJobExecuted(result, actor, '1234', true, newVersion); }); }); describe('version do not match', () => { const versionsMatch = false; - describe('PR is mergeable', () => { - const prIsMergeable = true; - it('workflow executes, new version created, PR auto-assigned and commented, approved and merged automatically', async () => { - const repoPath = mockGithub.repo.getPath('testCherryPickWorkflowRepo') || ''; - const workflowPath = path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'); - let act = new eAct.ExtendedAct(repoPath, workflowPath); - const testMockSteps = { - validateActor: mocks.CHERRYPICK__VALIDATEACTOR__TRUE__STEP_MOCKS, - }; - testMockSteps.cherryPick = mocks.getCherryPickMockSteps(versionsMatch, prIsMergeable, !mergeConflicts); - const testMockJobs = { - createNewVersion: { - steps: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, - outputs: { - // eslint-disable-next-line no-template-curly-in-string - NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', - }, - runsOn: 'ubuntu-latest', - }, - }; - act = utils.setUpActParams( - act, - event, - null, - { - OS_BOTIFY_TOKEN: 'dummy_token', - LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', - SLACK_WEBHOOK: 'dummy_slack_webhook', - }, - 'dummy_github_token', - null, - { - PULL_REQUEST_NUMBER: '1234', - NEW_VERSION: newVersion, - }, - ); - const result = await act.runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), - mockSteps: testMockSteps, - actor, - logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), - mockJobs: testMockJobs, - }); - - assertions.assertValidateActorJobExecuted(result, actor); - assertions.assertCreateNewVersionJobExecuted(result); - assertions.assertCherryPickJobExecuted( - result, - actor, - '1234', - '1.2.3', - true, - mergeConflicts || !versionsMatch, - !mergeConflicts, - versionsMatch, - prIsMergeable, - newVersion, - ); + it('workflow executes, new version created, PR auto-assigned and commented, approved and merged automatically', async () => { + const repoPath = mockGithub.repo.getPath('testCherryPickWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + const testMockSteps = { + validateActor: mocks.CHERRYPICK__VALIDATEACTOR__TRUE__STEP_MOCKS, + }; + testMockSteps.cherryPick = mocks.getCherryPickMockSteps(versionsMatch, mergeConflicts); + const testMockJobs = { + createNewVersion: { + steps: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, + outputs: { + // eslint-disable-next-line no-template-curly-in-string + NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', + }, + runsOn: 'ubuntu-latest', + }, + }; + act = utils.setUpActParams( + act, + event, + null, + { + OS_BOTIFY_TOKEN: 'dummy_token', + LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', + SLACK_WEBHOOK: 'dummy_slack_webhook', + }, + 'dummy_github_token', + null, + { + PULL_REQUEST_NUMBER: '1234', + NEW_VERSION: newVersion, + }, + ); + const result = await act.runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), + mockSteps: testMockSteps, + actor, + logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), + mockJobs: testMockJobs, }); - }); - describe('PR is not mergeable', () => { - const prIsMergeable = false; - it('workflow executes, new version created, PR auto-assigned and commented, not merged automatically', async () => { - const repoPath = mockGithub.repo.getPath('testCherryPickWorkflowRepo') || ''; - const workflowPath = path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'); - let act = new eAct.ExtendedAct(repoPath, workflowPath); - const testMockSteps = { - validateActor: mocks.CHERRYPICK__VALIDATEACTOR__TRUE__STEP_MOCKS, - }; - testMockSteps.cherryPick = mocks.getCherryPickMockSteps(versionsMatch, prIsMergeable, !mergeConflicts); - const testMockJobs = { - createNewVersion: { - steps: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, - outputs: { - // eslint-disable-next-line no-template-curly-in-string - NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', - }, - runsOn: 'ubuntu-latest', - }, - }; - act = utils.setUpActParams( - act, - event, - null, - { - OS_BOTIFY_TOKEN: 'dummy_token', - LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', - SLACK_WEBHOOK: 'dummy_slack_webhook', - }, - 'dummy_github_token', - null, - { - PULL_REQUEST_NUMBER: '1234', - NEW_VERSION: newVersion, - }, - ); - const result = await act.runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), - mockSteps: testMockSteps, - actor, - logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), - mockJobs: testMockJobs, - }); - assertions.assertValidateActorJobExecuted(result, actor); - assertions.assertCreateNewVersionJobExecuted(result); - assertions.assertCherryPickJobExecuted( - result, - actor, - '1234', - '1.2.3', - true, - mergeConflicts || !versionsMatch, - !mergeConflicts, - versionsMatch, - prIsMergeable, - newVersion, - ); - }); + assertions.assertValidateActorJobExecuted(result); + assertions.assertCreateNewVersionJobExecuted(result); + assertions.assertCherryPickJobExecuted(result, actor, '1234', true, newVersion); }); }); }); @@ -399,248 +250,100 @@ describe('test workflow cherryPick', () => { const mergeConflicts = true; describe('version match', () => { const versionsMatch = true; - describe('PR is mergeable', () => { - const prIsMergeable = true; - it('workflow executes, new version created, PR auto-assigned and commented, not merged automatically', async () => { - const repoPath = mockGithub.repo.getPath('testCherryPickWorkflowRepo') || ''; - const workflowPath = path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'); - let act = new eAct.ExtendedAct(repoPath, workflowPath); - const testMockSteps = { - validateActor: mocks.CHERRYPICK__VALIDATEACTOR__TRUE__STEP_MOCKS, - }; - testMockSteps.cherryPick = mocks.getCherryPickMockSteps(versionsMatch, prIsMergeable, !mergeConflicts); - const testMockJobs = { - createNewVersion: { - steps: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, - outputs: { - // eslint-disable-next-line no-template-curly-in-string - NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', - }, - runsOn: 'ubuntu-latest', - }, - }; - act = utils.setUpActParams( - act, - event, - null, - { - OS_BOTIFY_TOKEN: 'dummy_token', - LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', - SLACK_WEBHOOK: 'dummy_slack_webhook', - }, - 'dummy_github_token', - null, - { - PULL_REQUEST_NUMBER: '1234', - NEW_VERSION: newVersion, - }, - ); - const result = await act.runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), - mockSteps: testMockSteps, - actor, - logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), - mockJobs: testMockJobs, - }); - - assertions.assertValidateActorJobExecuted(result, actor); - assertions.assertCreateNewVersionJobExecuted(result); - assertions.assertCherryPickJobExecuted( - result, - actor, - '1234', - '1.2.3', - true, - mergeConflicts || !versionsMatch, - !mergeConflicts, - versionsMatch, - prIsMergeable, - newVersion, - ); + it('workflow executes, new version created, PR auto-assigned and commented, not merged automatically', async () => { + const repoPath = mockGithub.repo.getPath('testCherryPickWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + const testMockSteps = { + validateActor: mocks.CHERRYPICK__VALIDATEACTOR__TRUE__STEP_MOCKS, + }; + testMockSteps.cherryPick = mocks.getCherryPickMockSteps(versionsMatch, mergeConflicts); + const testMockJobs = { + createNewVersion: { + steps: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, + outputs: { + // eslint-disable-next-line no-template-curly-in-string + NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', + }, + runsOn: 'ubuntu-latest', + }, + }; + act = utils.setUpActParams( + act, + event, + null, + { + OS_BOTIFY_TOKEN: 'dummy_token', + LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', + SLACK_WEBHOOK: 'dummy_slack_webhook', + }, + 'dummy_github_token', + null, + { + PULL_REQUEST_NUMBER: '1234', + NEW_VERSION: newVersion, + }, + ); + const result = await act.runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), + mockSteps: testMockSteps, + actor, + logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), + mockJobs: testMockJobs, }); - }); - describe('PR is not mergeable', () => { - const prIsMergeable = false; - it('workflow executes, new version created, PR auto-assigned and commented, not merged automatically', async () => { - const repoPath = mockGithub.repo.getPath('testCherryPickWorkflowRepo') || ''; - const workflowPath = path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'); - let act = new eAct.ExtendedAct(repoPath, workflowPath); - const testMockSteps = { - validateActor: mocks.CHERRYPICK__VALIDATEACTOR__TRUE__STEP_MOCKS, - }; - testMockSteps.cherryPick = mocks.getCherryPickMockSteps(versionsMatch, prIsMergeable, !mergeConflicts); - const testMockJobs = { - createNewVersion: { - steps: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, - outputs: { - // eslint-disable-next-line no-template-curly-in-string - NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', - }, - runsOn: 'ubuntu-latest', - }, - }; - act = utils.setUpActParams( - act, - event, - null, - { - OS_BOTIFY_TOKEN: 'dummy_token', - LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', - SLACK_WEBHOOK: 'dummy_slack_webhook', - }, - 'dummy_github_token', - null, - { - PULL_REQUEST_NUMBER: '1234', - NEW_VERSION: newVersion, - }, - ); - const result = await act.runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), - mockSteps: testMockSteps, - actor, - logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), - mockJobs: testMockJobs, - }); - assertions.assertValidateActorJobExecuted(result, actor); - assertions.assertCreateNewVersionJobExecuted(result); - assertions.assertCherryPickJobExecuted( - result, - actor, - '1234', - '1.2.3', - true, - mergeConflicts || !versionsMatch, - !mergeConflicts, - versionsMatch, - prIsMergeable, - newVersion, - ); - }); + assertions.assertValidateActorJobExecuted(result); + assertions.assertCreateNewVersionJobExecuted(result); + assertions.assertCherryPickJobExecuted(result, actor, '1234', true, newVersion, true); }); }); describe('version do not match', () => { const versionsMatch = false; - describe('PR is mergeable', () => { - const prIsMergeable = true; - it('workflow executes, new version created, PR auto-assigned and commented, not merged automatically', async () => { - const repoPath = mockGithub.repo.getPath('testCherryPickWorkflowRepo') || ''; - const workflowPath = path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'); - let act = new eAct.ExtendedAct(repoPath, workflowPath); - const testMockSteps = { - validateActor: mocks.CHERRYPICK__VALIDATEACTOR__TRUE__STEP_MOCKS, - }; - testMockSteps.cherryPick = mocks.getCherryPickMockSteps(versionsMatch, prIsMergeable, !mergeConflicts); - const testMockJobs = { - createNewVersion: { - steps: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, - outputs: { - // eslint-disable-next-line no-template-curly-in-string - NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', - }, - runsOn: 'ubuntu-latest', - }, - }; - act = utils.setUpActParams( - act, - event, - null, - { - OS_BOTIFY_TOKEN: 'dummy_token', - LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', - SLACK_WEBHOOK: 'dummy_slack_webhook', - }, - 'dummy_github_token', - null, - { - PULL_REQUEST_NUMBER: '1234', - NEW_VERSION: newVersion, - }, - ); - const result = await act.runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), - mockSteps: testMockSteps, - actor, - logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), - mockJobs: testMockJobs, - }); - - assertions.assertValidateActorJobExecuted(result, actor); - assertions.assertCreateNewVersionJobExecuted(result); - assertions.assertCherryPickJobExecuted( - result, - actor, - '1234', - '1.2.3', - true, - mergeConflicts || !versionsMatch, - !mergeConflicts, - versionsMatch, - prIsMergeable, - newVersion, - ); + it('workflow executes, new version created, PR auto-assigned and commented, not merged automatically', async () => { + const repoPath = mockGithub.repo.getPath('testCherryPickWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + const testMockSteps = { + validateActor: mocks.CHERRYPICK__VALIDATEACTOR__TRUE__STEP_MOCKS, + }; + testMockSteps.cherryPick = mocks.getCherryPickMockSteps(versionsMatch, mergeConflicts); + const testMockJobs = { + createNewVersion: { + steps: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, + outputs: { + // eslint-disable-next-line no-template-curly-in-string + NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', + }, + runsOn: 'ubuntu-latest', + }, + }; + act = utils.setUpActParams( + act, + event, + null, + { + OS_BOTIFY_TOKEN: 'dummy_token', + LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', + SLACK_WEBHOOK: 'dummy_slack_webhook', + }, + 'dummy_github_token', + null, + { + PULL_REQUEST_NUMBER: '1234', + NEW_VERSION: newVersion, + }, + ); + const result = await act.runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), + mockSteps: testMockSteps, + actor, + logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), + mockJobs: testMockJobs, }); - }); - describe('PR is not mergeable', () => { - const prIsMergeable = false; - it('workflow executes, new version created, PR auto-assigned and commented, not merged automatically', async () => { - const repoPath = mockGithub.repo.getPath('testCherryPickWorkflowRepo') || ''; - const workflowPath = path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'); - let act = new eAct.ExtendedAct(repoPath, workflowPath); - const testMockSteps = { - validateActor: mocks.CHERRYPICK__VALIDATEACTOR__TRUE__STEP_MOCKS, - }; - testMockSteps.cherryPick = mocks.getCherryPickMockSteps(versionsMatch, prIsMergeable, !mergeConflicts); - const testMockJobs = { - createNewVersion: { - steps: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, - outputs: { - // eslint-disable-next-line no-template-curly-in-string - NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', - }, - runsOn: 'ubuntu-latest', - }, - }; - act = utils.setUpActParams( - act, - event, - null, - { - OS_BOTIFY_TOKEN: 'dummy_token', - LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', - SLACK_WEBHOOK: 'dummy_slack_webhook', - }, - 'dummy_github_token', - null, - { - PULL_REQUEST_NUMBER: '1234', - NEW_VERSION: newVersion, - }, - ); - const result = await act.runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), - mockSteps: testMockSteps, - actor, - logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), - mockJobs: testMockJobs, - }); - assertions.assertValidateActorJobExecuted(result, actor); - assertions.assertCreateNewVersionJobExecuted(result); - assertions.assertCherryPickJobExecuted( - result, - actor, - '1234', - '1.2.3', - true, - mergeConflicts || !versionsMatch, - !mergeConflicts, - versionsMatch, - prIsMergeable, - newVersion, - ); - }); + assertions.assertValidateActorJobExecuted(result); + assertions.assertCreateNewVersionJobExecuted(result); + assertions.assertCherryPickJobExecuted(result, actor, '1234', true, newVersion, true); }); }); }); @@ -652,248 +355,100 @@ describe('test workflow cherryPick', () => { const mergeConflicts = false; describe('version match', () => { const versionsMatch = true; - describe('PR is mergeable', () => { - const prIsMergeable = true; - it('workflow executes, PR approved and merged automatically', async () => { - const repoPath = mockGithub.repo.getPath('testCherryPickWorkflowRepo') || ''; - const workflowPath = path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'); - let act = new eAct.ExtendedAct(repoPath, workflowPath); - const testMockSteps = { - validateActor: mocks.CHERRYPICK__VALIDATEACTOR__TRUE__STEP_MOCKS, - }; - testMockSteps.cherryPick = mocks.getCherryPickMockSteps(versionsMatch, prIsMergeable, !mergeConflicts); - const testMockJobs = { - createNewVersion: { - steps: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, - outputs: { - // eslint-disable-next-line no-template-curly-in-string - NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', - }, - runsOn: 'ubuntu-latest', - }, - }; - act = utils.setUpActParams( - act, - event, - null, - { - OS_BOTIFY_TOKEN: 'dummy_token', - LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', - SLACK_WEBHOOK: 'dummy_slack_webhook', - }, - 'dummy_github_token', - null, - { - PULL_REQUEST_NUMBER: '1234', - NEW_VERSION: newVersion, - }, - ); - const result = await act.runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), - mockSteps: testMockSteps, - actor, - logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), - mockJobs: testMockJobs, - }); - - assertions.assertValidateActorJobExecuted(result, actor); - assertions.assertCreateNewVersionJobExecuted(result, false); - assertions.assertCherryPickJobExecuted( - result, - actor, - '1234', - '1.2.3', - true, - mergeConflicts || !versionsMatch, - !mergeConflicts, - versionsMatch, - prIsMergeable, - newVersion, - ); + it('workflow executes, PR approved and merged automatically', async () => { + const repoPath = mockGithub.repo.getPath('testCherryPickWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + const testMockSteps = { + validateActor: mocks.CHERRYPICK__VALIDATEACTOR__TRUE__STEP_MOCKS, + }; + testMockSteps.cherryPick = mocks.getCherryPickMockSteps(versionsMatch, mergeConflicts); + const testMockJobs = { + createNewVersion: { + steps: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, + outputs: { + // eslint-disable-next-line no-template-curly-in-string + NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', + }, + runsOn: 'ubuntu-latest', + }, + }; + act = utils.setUpActParams( + act, + event, + null, + { + OS_BOTIFY_TOKEN: 'dummy_token', + LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', + SLACK_WEBHOOK: 'dummy_slack_webhook', + }, + 'dummy_github_token', + null, + { + PULL_REQUEST_NUMBER: '1234', + NEW_VERSION: newVersion, + }, + ); + const result = await act.runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), + mockSteps: testMockSteps, + actor, + logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), + mockJobs: testMockJobs, }); - }); - describe('PR is not mergeable', () => { - const prIsMergeable = false; - it('workflow executes, PR is not merged automatically', async () => { - const repoPath = mockGithub.repo.getPath('testCherryPickWorkflowRepo') || ''; - const workflowPath = path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'); - let act = new eAct.ExtendedAct(repoPath, workflowPath); - const testMockSteps = { - validateActor: mocks.CHERRYPICK__VALIDATEACTOR__TRUE__STEP_MOCKS, - }; - testMockSteps.cherryPick = mocks.getCherryPickMockSteps(versionsMatch, prIsMergeable, !mergeConflicts); - const testMockJobs = { - createNewVersion: { - steps: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, - outputs: { - // eslint-disable-next-line no-template-curly-in-string - NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', - }, - runsOn: 'ubuntu-latest', - }, - }; - act = utils.setUpActParams( - act, - event, - null, - { - OS_BOTIFY_TOKEN: 'dummy_token', - LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', - SLACK_WEBHOOK: 'dummy_slack_webhook', - }, - 'dummy_github_token', - null, - { - PULL_REQUEST_NUMBER: '1234', - NEW_VERSION: newVersion, - }, - ); - const result = await act.runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), - mockSteps: testMockSteps, - actor, - logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), - mockJobs: testMockJobs, - }); - assertions.assertValidateActorJobExecuted(result, actor); - assertions.assertCreateNewVersionJobExecuted(result, false); - assertions.assertCherryPickJobExecuted( - result, - actor, - '1234', - '1.2.3', - true, - mergeConflicts || !versionsMatch, - !mergeConflicts, - versionsMatch, - prIsMergeable, - newVersion, - ); - }); + assertions.assertValidateActorJobExecuted(result); + assertions.assertCreateNewVersionJobExecuted(result, false); + assertions.assertCherryPickJobExecuted(result, actor, '1234', true, newVersion); }); }); describe('version do not match', () => { const versionsMatch = false; - describe('PR is mergeable', () => { - const prIsMergeable = true; - it('workflow executes, PR auto-assigned and commented, approved and merged automatically', async () => { - const repoPath = mockGithub.repo.getPath('testCherryPickWorkflowRepo') || ''; - const workflowPath = path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'); - let act = new eAct.ExtendedAct(repoPath, workflowPath); - const testMockSteps = { - validateActor: mocks.CHERRYPICK__VALIDATEACTOR__TRUE__STEP_MOCKS, - }; - testMockSteps.cherryPick = mocks.getCherryPickMockSteps(versionsMatch, prIsMergeable, !mergeConflicts); - const testMockJobs = { - createNewVersion: { - steps: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, - outputs: { - // eslint-disable-next-line no-template-curly-in-string - NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', - }, - runsOn: 'ubuntu-latest', - }, - }; - act = utils.setUpActParams( - act, - event, - null, - { - OS_BOTIFY_TOKEN: 'dummy_token', - LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', - SLACK_WEBHOOK: 'dummy_slack_webhook', - }, - 'dummy_github_token', - null, - { - PULL_REQUEST_NUMBER: '1234', - NEW_VERSION: newVersion, - }, - ); - const result = await act.runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), - mockSteps: testMockSteps, - actor, - logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), - mockJobs: testMockJobs, - }); - - assertions.assertValidateActorJobExecuted(result, actor); - assertions.assertCreateNewVersionJobExecuted(result, false); - assertions.assertCherryPickJobExecuted( - result, - actor, - '1234', - '1.2.3', - true, - mergeConflicts || !versionsMatch, - !mergeConflicts, - versionsMatch, - prIsMergeable, - newVersion, - ); + it('workflow executes, PR auto-assigned and commented, approved and merged automatically', async () => { + const repoPath = mockGithub.repo.getPath('testCherryPickWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + const testMockSteps = { + validateActor: mocks.CHERRYPICK__VALIDATEACTOR__TRUE__STEP_MOCKS, + }; + testMockSteps.cherryPick = mocks.getCherryPickMockSteps(versionsMatch, mergeConflicts); + const testMockJobs = { + createNewVersion: { + steps: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, + outputs: { + // eslint-disable-next-line no-template-curly-in-string + NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', + }, + runsOn: 'ubuntu-latest', + }, + }; + act = utils.setUpActParams( + act, + event, + null, + { + OS_BOTIFY_TOKEN: 'dummy_token', + LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', + SLACK_WEBHOOK: 'dummy_slack_webhook', + }, + 'dummy_github_token', + null, + { + PULL_REQUEST_NUMBER: '1234', + NEW_VERSION: newVersion, + }, + ); + const result = await act.runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), + mockSteps: testMockSteps, + actor, + logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), + mockJobs: testMockJobs, }); - }); - describe('PR is not mergeable', () => { - const prIsMergeable = false; - it('workflow executes, PR auto-assigned and commented, not merged automatically', async () => { - const repoPath = mockGithub.repo.getPath('testCherryPickWorkflowRepo') || ''; - const workflowPath = path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'); - let act = new eAct.ExtendedAct(repoPath, workflowPath); - const testMockSteps = { - validateActor: mocks.CHERRYPICK__VALIDATEACTOR__TRUE__STEP_MOCKS, - }; - testMockSteps.cherryPick = mocks.getCherryPickMockSteps(versionsMatch, prIsMergeable, !mergeConflicts); - const testMockJobs = { - createNewVersion: { - steps: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, - outputs: { - // eslint-disable-next-line no-template-curly-in-string - NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', - }, - runsOn: 'ubuntu-latest', - }, - }; - act = utils.setUpActParams( - act, - event, - null, - { - OS_BOTIFY_TOKEN: 'dummy_token', - LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', - SLACK_WEBHOOK: 'dummy_slack_webhook', - }, - 'dummy_github_token', - null, - { - PULL_REQUEST_NUMBER: '1234', - NEW_VERSION: newVersion, - }, - ); - const result = await act.runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), - mockSteps: testMockSteps, - actor, - logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), - mockJobs: testMockJobs, - }); - assertions.assertValidateActorJobExecuted(result, actor); - assertions.assertCreateNewVersionJobExecuted(result, false); - assertions.assertCherryPickJobExecuted( - result, - actor, - '1234', - '1.2.3', - true, - mergeConflicts || !versionsMatch, - !mergeConflicts, - versionsMatch, - prIsMergeable, - newVersion, - ); - }); + assertions.assertValidateActorJobExecuted(result); + assertions.assertCreateNewVersionJobExecuted(result, false); + assertions.assertCherryPickJobExecuted(result, actor, '1234', true, newVersion); }); }); }); @@ -901,248 +456,100 @@ describe('test workflow cherryPick', () => { const mergeConflicts = true; describe('version match', () => { const versionsMatch = true; - describe('PR is mergeable', () => { - const prIsMergeable = true; - it('workflow executes, PR auto-assigned and commented, not merged automatically', async () => { - const repoPath = mockGithub.repo.getPath('testCherryPickWorkflowRepo') || ''; - const workflowPath = path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'); - let act = new eAct.ExtendedAct(repoPath, workflowPath); - const testMockSteps = { - validateActor: mocks.CHERRYPICK__VALIDATEACTOR__TRUE__STEP_MOCKS, - }; - testMockSteps.cherryPick = mocks.getCherryPickMockSteps(versionsMatch, prIsMergeable, !mergeConflicts); - const testMockJobs = { - createNewVersion: { - steps: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, - outputs: { - // eslint-disable-next-line no-template-curly-in-string - NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', - }, - runsOn: 'ubuntu-latest', - }, - }; - act = utils.setUpActParams( - act, - event, - null, - { - OS_BOTIFY_TOKEN: 'dummy_token', - LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', - SLACK_WEBHOOK: 'dummy_slack_webhook', - }, - 'dummy_github_token', - null, - { - PULL_REQUEST_NUMBER: '1234', - NEW_VERSION: newVersion, - }, - ); - const result = await act.runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), - mockSteps: testMockSteps, - actor, - logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), - mockJobs: testMockJobs, - }); - - assertions.assertValidateActorJobExecuted(result, actor); - assertions.assertCreateNewVersionJobExecuted(result, false); - assertions.assertCherryPickJobExecuted( - result, - actor, - '1234', - '1.2.3', - true, - mergeConflicts || !versionsMatch, - !mergeConflicts, - versionsMatch, - prIsMergeable, - newVersion, - ); + it('workflow executes, PR auto-assigned and commented, not merged automatically', async () => { + const repoPath = mockGithub.repo.getPath('testCherryPickWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + const testMockSteps = { + validateActor: mocks.CHERRYPICK__VALIDATEACTOR__TRUE__STEP_MOCKS, + }; + testMockSteps.cherryPick = mocks.getCherryPickMockSteps(versionsMatch, mergeConflicts); + const testMockJobs = { + createNewVersion: { + steps: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, + outputs: { + // eslint-disable-next-line no-template-curly-in-string + NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', + }, + runsOn: 'ubuntu-latest', + }, + }; + act = utils.setUpActParams( + act, + event, + null, + { + OS_BOTIFY_TOKEN: 'dummy_token', + LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', + SLACK_WEBHOOK: 'dummy_slack_webhook', + }, + 'dummy_github_token', + null, + { + PULL_REQUEST_NUMBER: '1234', + NEW_VERSION: newVersion, + }, + ); + const result = await act.runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), + mockSteps: testMockSteps, + actor, + logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), + mockJobs: testMockJobs, }); - }); - describe('PR is not mergeable', () => { - const prIsMergeable = false; - it('workflow executes, PR auto-assigned and commented, not merged automatically', async () => { - const repoPath = mockGithub.repo.getPath('testCherryPickWorkflowRepo') || ''; - const workflowPath = path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'); - let act = new eAct.ExtendedAct(repoPath, workflowPath); - const testMockSteps = { - validateActor: mocks.CHERRYPICK__VALIDATEACTOR__TRUE__STEP_MOCKS, - }; - testMockSteps.cherryPick = mocks.getCherryPickMockSteps(versionsMatch, prIsMergeable, !mergeConflicts); - const testMockJobs = { - createNewVersion: { - steps: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, - outputs: { - // eslint-disable-next-line no-template-curly-in-string - NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', - }, - runsOn: 'ubuntu-latest', - }, - }; - act = utils.setUpActParams( - act, - event, - null, - { - OS_BOTIFY_TOKEN: 'dummy_token', - LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', - SLACK_WEBHOOK: 'dummy_slack_webhook', - }, - 'dummy_github_token', - null, - { - PULL_REQUEST_NUMBER: '1234', - NEW_VERSION: newVersion, - }, - ); - const result = await act.runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), - mockSteps: testMockSteps, - actor, - logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), - mockJobs: testMockJobs, - }); - assertions.assertValidateActorJobExecuted(result, actor); - assertions.assertCreateNewVersionJobExecuted(result, false); - assertions.assertCherryPickJobExecuted( - result, - actor, - '1234', - '1.2.3', - true, - mergeConflicts || !versionsMatch, - !mergeConflicts, - versionsMatch, - prIsMergeable, - newVersion, - ); - }); + assertions.assertValidateActorJobExecuted(result); + assertions.assertCreateNewVersionJobExecuted(result, false); + assertions.assertCherryPickJobExecuted(result, actor, '1234', true, newVersion, true); }); }); describe('version do not match', () => { const versionsMatch = false; - describe('PR is mergeable', () => { - const prIsMergeable = true; - it('workflow executes, PR auto-assigned and commented, not merged automatically', async () => { - const repoPath = mockGithub.repo.getPath('testCherryPickWorkflowRepo') || ''; - const workflowPath = path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'); - let act = new eAct.ExtendedAct(repoPath, workflowPath); - const testMockSteps = { - validateActor: mocks.CHERRYPICK__VALIDATEACTOR__TRUE__STEP_MOCKS, - }; - testMockSteps.cherryPick = mocks.getCherryPickMockSteps(versionsMatch, prIsMergeable, !mergeConflicts); - const testMockJobs = { - createNewVersion: { - steps: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, - outputs: { - // eslint-disable-next-line no-template-curly-in-string - NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', - }, - runsOn: 'ubuntu-latest', - }, - }; - act = utils.setUpActParams( - act, - event, - null, - { - OS_BOTIFY_TOKEN: 'dummy_token', - LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', - SLACK_WEBHOOK: 'dummy_slack_webhook', - }, - 'dummy_github_token', - null, - { - PULL_REQUEST_NUMBER: '1234', - NEW_VERSION: newVersion, - }, - ); - const result = await act.runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), - mockSteps: testMockSteps, - actor, - logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), - mockJobs: testMockJobs, - }); - - assertions.assertValidateActorJobExecuted(result, actor); - assertions.assertCreateNewVersionJobExecuted(result, false); - assertions.assertCherryPickJobExecuted( - result, - actor, - '1234', - '1.2.3', - true, - mergeConflicts || !versionsMatch, - !mergeConflicts, - versionsMatch, - prIsMergeable, - newVersion, - ); + it('workflow executes, PR auto-assigned and commented, not merged automatically', async () => { + const repoPath = mockGithub.repo.getPath('testCherryPickWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + const testMockSteps = { + validateActor: mocks.CHERRYPICK__VALIDATEACTOR__TRUE__STEP_MOCKS, + }; + testMockSteps.cherryPick = mocks.getCherryPickMockSteps(versionsMatch, mergeConflicts); + const testMockJobs = { + createNewVersion: { + steps: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, + outputs: { + // eslint-disable-next-line no-template-curly-in-string + NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', + }, + runsOn: 'ubuntu-latest', + }, + }; + act = utils.setUpActParams( + act, + event, + null, + { + OS_BOTIFY_TOKEN: 'dummy_token', + LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', + SLACK_WEBHOOK: 'dummy_slack_webhook', + }, + 'dummy_github_token', + null, + { + PULL_REQUEST_NUMBER: '1234', + NEW_VERSION: newVersion, + }, + ); + const result = await act.runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), + mockSteps: testMockSteps, + actor, + logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), + mockJobs: testMockJobs, }); - }); - describe('PR is not mergeable', () => { - const prIsMergeable = false; - it('workflow executes, PR auto-assigned and commented, not merged automatically', async () => { - const repoPath = mockGithub.repo.getPath('testCherryPickWorkflowRepo') || ''; - const workflowPath = path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'); - let act = new eAct.ExtendedAct(repoPath, workflowPath); - const testMockSteps = { - validateActor: mocks.CHERRYPICK__VALIDATEACTOR__TRUE__STEP_MOCKS, - }; - testMockSteps.cherryPick = mocks.getCherryPickMockSteps(versionsMatch, prIsMergeable, !mergeConflicts); - const testMockJobs = { - createNewVersion: { - steps: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, - outputs: { - // eslint-disable-next-line no-template-curly-in-string - NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', - }, - runsOn: 'ubuntu-latest', - }, - }; - act = utils.setUpActParams( - act, - event, - null, - { - OS_BOTIFY_TOKEN: 'dummy_token', - LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', - SLACK_WEBHOOK: 'dummy_slack_webhook', - }, - 'dummy_github_token', - null, - { - PULL_REQUEST_NUMBER: '1234', - NEW_VERSION: newVersion, - }, - ); - const result = await act.runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), - mockSteps: testMockSteps, - actor, - logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), - mockJobs: testMockJobs, - }); - assertions.assertValidateActorJobExecuted(result, actor); - assertions.assertCreateNewVersionJobExecuted(result, false); - assertions.assertCherryPickJobExecuted( - result, - actor, - '1234', - '1.2.3', - true, - mergeConflicts || !versionsMatch, - !mergeConflicts, - versionsMatch, - prIsMergeable, - newVersion, - ); - }); + assertions.assertValidateActorJobExecuted(result); + assertions.assertCreateNewVersionJobExecuted(result, false); + assertions.assertCherryPickJobExecuted(result, actor, '1234', true, newVersion, true); }); }); }); @@ -1173,7 +580,7 @@ describe('test workflow cherryPick', () => { ); const testMockSteps = { validateActor: mocks.CHERRYPICK__VALIDATEACTOR__TRUE__STEP_MOCKS, - cherryPick: mocks.getCherryPickMockSteps(true, true, true), + cherryPick: mocks.getCherryPickMockSteps(true, false), }; const testMockJobs = { createNewVersion: { @@ -1193,9 +600,9 @@ describe('test workflow cherryPick', () => { mockJobs: testMockJobs, }); - assertions.assertValidateActorJobExecuted(result, 'Dummy Author', false); + assertions.assertValidateActorJobExecuted(result, false); assertions.assertCreateNewVersionJobExecuted(result, false); - assertions.assertCherryPickJobExecuted(result, 'Dummy Author', '1234', '1.2.3', false); + assertions.assertCherryPickJobExecuted(result, 'Dummy Author', '1234', false); }); }); }); diff --git a/workflow_tests/mocks/cherryPickMocks.js b/workflow_tests/mocks/cherryPickMocks.js index 9f0736a3463b..3f9242c806aa 100644 --- a/workflow_tests/mocks/cherryPickMocks.js +++ b/workflow_tests/mocks/cherryPickMocks.js @@ -5,17 +5,17 @@ const CHERRYPICK__VALIDATEACTOR__CHECK_IF_USER_IS_DEPLOYER_TRUE__STEP_MOCK = uti 'Check if user is deployer', 'Checking if user is a deployer', 'VALIDATEACTOR', - ['GITHUB_TOKEN', 'username', 'team'], [], - {isTeamMember: true}, + ['GITHUB_TOKEN'], + {IS_DEPLOYER: true}, ); const CHERRYPICK__VALIDATEACTOR__CHECK_IF_USER_IS_DEPLOYER_FALSE__STEP_MOCK = utils.createMockStep( 'Check if user is deployer', 'Checking if user is a deployer', 'VALIDATEACTOR', - ['GITHUB_TOKEN', 'username', 'team'], [], - {isTeamMember: false}, + ['GITHUB_TOKEN'], + {IS_DEPLOYER: false}, ); const CHERRYPICK__VALIDATEACTOR__TRUE__STEP_MOCKS = [CHERRYPICK__VALIDATEACTOR__CHECK_IF_USER_IS_DEPLOYER_TRUE__STEP_MOCK]; const CHERRYPICK__VALIDATEACTOR__FALSE__STEP_MOCKS = [CHERRYPICK__VALIDATEACTOR__CHECK_IF_USER_IS_DEPLOYER_FALSE__STEP_MOCK]; @@ -37,13 +37,6 @@ const CHERRYPICK__CREATENEWVERSION__STEP_MOCKS = [CHERRYPICK__CREATENEWVERSION__ // cherrypick const CHERRYPICK__CHERRYPICK__CHECKOUT_STAGING_BRANCH__STEP_MOCK = utils.createMockStep('Checkout staging branch', 'Checking out staging branch', 'CHERRYPICK', ['ref', 'token'], []); const CHERRYPICK__CHERRYPICK__SET_UP_GIT_FOR_OSBOTIFY__STEP_MOCK = utils.createMockStep('Set up git for OSBotify', 'Setting up git for OSBotify', 'CHERRYPICK', ['GPG_PASSPHRASE'], []); -const CHERRYPICK__CHERRYPICK__CREATE_BRANCH_FOR_NEW_PULL_REQUEST__STEP_MOCK = utils.createMockStep( - 'Create branch for new pull request', - 'Creating branch for new pull request', - 'CHERRYPICK', - [], - [], -); const CHERRYPICK__CHERRYPICK__GET_MERGE_COMMIT_FOR_CP_PULL_REQUEST__STEP_MOCK = utils.createMockStep( 'Get merge commit for CP pull request', 'Getting merge commit for CP pull request', @@ -52,102 +45,38 @@ const CHERRYPICK__CHERRYPICK__GET_MERGE_COMMIT_FOR_CP_PULL_REQUEST__STEP_MOCK = [], {MERGE_ACTOR: '@dummyauthor'}, ); -const CHERRYPICK__CHERRYPICK__GET_MERGE_COMMIT_FOR_VERSION_BUMP_PULL_REQUEST__STEP_MOCK = utils.createMockStep( - 'Get merge commit for version-bump pull request', - 'Getting merge commit for version-bump pull request', - 'CHERRYPICK', - ['GITHUB_TOKEN', 'USER', 'TITLE_REGEX'], - [], - {MERGE_COMMIT_SHA: '0123456789abcdef'}, -); -const CHERRYPICK__CHERRYPICK__CHERRY_PICK_THE_VERSION_BUMP_TO_NEW_BRANCH__STEP_MOCK = utils.createMockStep( - 'Cherry-pick the version-bump to new branch', - 'Cherry-picking the version-bump to new branch', +const CHERRYPICK__CHERRYPICK__CHERRY_PICK_THE_VERSION_BUMP_TO_STAGING__STEP_MOCK = utils.createMockStep( + 'Cherry-pick the version-bump to staging', + 'Cherry-picking the version-bump to staging', 'CHERRYPICK', [], [], ); -const CHERRYPICK__CHERRYPICK__CHERRY_PICK_THE_MERGE_COMMIT_OF_TARGET_PR_TO_NEW_BRANCH__SHOULD_MERGE__STEP_MOCK = utils.createMockStep( - 'Cherry-pick the merge commit of target PR to new branch', - 'Cherry-picking the merge commit of target PR to new branch', +const CHERRYPICK__CHERRYPICK__CHERRY_PICK_THE_MERGE_COMMIT_OF_TARGET_PR_TO_NEW_BRANCH__HAS_NO_CONFLICTS__STEP_MOCK = utils.createMockStep( + 'Cherry-pick the merge commit of target PR', + 'Cherry-picking the merge commit of target PR', 'CHERRYPICK', [], [], - {SHOULD_AUTOMERGE: true}, + {HAS_CONFLICTS: false}, ); // eslint-disable-next-line rulesdir/no-negated-variables -const CHERRYPICK__CHERRYPICK__CHERRY_PICK_THE_MERGE_COMMIT_OF_TARGET_PR_TO_NEW_BRANCH__SHOULD_NOT_MERGE__STEP_MOCK = utils.createMockStep( - 'Cherry-pick the merge commit of target PR to new branch', - 'Cherry-picking the merge commit of target PR to new branch', +const CHERRYPICK__CHERRYPICK__CHERRY_PICK_THE_MERGE_COMMIT_OF_TARGET_PR_TO_NEW_BRANCH__HAS_CONFLICTS__STEP_MOCK = utils.createMockStep( + 'Cherry-pick the merge commit of target PR', + 'Cherry-picking the merge commit of target PR', 'CHERRYPICK', [], [], - {SHOULD_AUTOMERGE: false}, + {HAS_CONFLICTS: true}, ); -const CHERRYPICK__CHERRYPICK__PUSH_CHANGES_TO_CP_BRANCH__STEP_MOCK = utils.createMockStep('Push changes to CP branch', 'Pushing changes to CP branch', 'CHERRYPICK', [], []); -const CHERRYPICK__CHERRYPICK__CREATE_PULL_REQUEST__STEP_MOCK = utils.createMockStep('Create Pull Request', 'Creating Pull Request', 'CHERRYPICK', [], ['GITHUB_TOKEN'], {PR_NUMBER: '1234'}); -const CHERRYPICK__CHERRYPICK__CHECK_IF_SHORTVERSIONSTRING_IS_UP_TO_DATE_TRUE__STEP_MOCK = utils.createMockStep( - 'Check if ShortVersionString is up to date', - 'Checking if ShortVersionString is up to date', - 'CHERRYPICK', - [], - [], - {BUNDLE_VERSIONS_MATCH: true}, -); -const CHERRYPICK__CHERRYPICK__CHECK_IF_SHORTVERSIONSTRING_IS_UP_TO_DATE_FALSE__STEP_MOCK = utils.createMockStep( - 'Check if ShortVersionString is up to date', - 'Checking if ShortVersionString is up to date', - 'CHERRYPICK', - [], - [], - {BUNDLE_VERSIONS_MATCH: false}, -); -const CHERRYPICK__CHERRYPICK__AUTO_ASSIGN_PR_IF_THERE_ARE_MERGE_CONFLICTS_OR_IF_THE_BUNDLE_VERSIONS_ARE_MISMATCHED__STEP_MOCK = utils.createMockStep( - 'Auto-assign PR if there are merge conflicts or if the bundle versions are mismatched', - 'Auto-assigning PR', +const CHERRYPICK__CHERRYPICK__PUSH_CHANGES__STEP_MOCK = utils.createMockStep('Push changes', 'Pushing changes', 'CHERRYPICK', [], []); +const CHERRYPICK__CHERRYPICK__CREATE_PULL_REQUEST_TO_MANUALLY_FINISH_CP__STEP_MOCK = utils.createMockStep( + 'Create Pull Request to manually finish CP', + 'Creating Pull Request to manually finish CP', 'CHERRYPICK', [], ['GITHUB_TOKEN'], ); -const CHERRYPICK__CHERRYPICK__ASSIGN_THE_PR_TO_THE_DEPLOYER__STEP_MOCK = utils.createMockStep( - 'Assign the PR to the deployer', - 'Assigning the PR to the deployer', - 'CHERRYPICK', - [], - ['GITHUB_TOKEN'], -); -const CHERRYPICK__CHERRYPICK__IF_PR_HAS_MERGE_CONFLICTS_COMMENT_WITH_INSTRUCTIONS_FOR_ASSIGNEE__STEP_MOCK = utils.createMockStep( - 'If PR has merge conflicts, comment with instructions for assignee', - 'Commenting with instructions for assignee', - 'CHERRYPICK', - [], - ['GITHUB_TOKEN'], -); -const CHERRYPICK__CHERRYPICK__IF_PR_HAS_A_BUNDLE_VERSION_MISMATCH_COMMENT_WITH_THE_INSTRUCTIONS_FOR_ASSIGNEE__STEP_MOCK = utils.createMockStep( - 'If PR has a bundle version mismatch, comment with the instructions for assignee', - 'Commenting with the instructions for assignee', - 'CHERRYPICK', - [], - ['GITHUB_TOKEN'], -); -const CHERRYPICK__CHERRYPICK__AUTO_APPROVE_THE_PR__STEP_MOCK = utils.createMockStep('Auto-approve the PR', 'Auto-approving the PR', 'CHERRYPICK', [], ['GITHUB_TOKEN']); -const CHERRYPICK__CHERRYPICK__CHECK_IF_PULL_REQUEST_IS_MERGEABLE_TRUE__STEP_MOCK = utils.createMockStep( - 'Check if pull request is mergeable', - 'Checking if pull request is mergeable', - 'CHERRYPICK', - ['GITHUB_TOKEN', 'PULL_REQUEST_NUMBER'], - [], - {IS_MERGEABLE: true}, -); -const CHERRYPICK__CHERRYPICK__CHECK_IF_PULL_REQUEST_IS_MERGEABLE_FALSE__STEP_MOCK = utils.createMockStep( - 'Check if pull request is mergeable', - 'Checking if pull request is mergeable', - 'CHERRYPICK', - ['GITHUB_TOKEN', 'PULL_REQUEST_NUMBER'], - [], - {IS_MERGEABLE: false}, -); -const CHERRYPICK__CHERRYPICK__AUTO_MERGE_THE_PR__STEP_MOCK = utils.createMockStep('Auto-merge the PR', 'Auto-merging the PR', 'CHERRYPICK', [], ['GITHUB_TOKEN']); const CHERRYPICK__CHERRYPICK__ANNOUNCES_A_CP_FAILURE_IN_THE_ANNOUNCE_SLACK_ROOM__STEP_MOCK = utils.createMockStep( 'Announces a CP failure in the #announce Slack room', 'Announcing a CP failure', @@ -156,26 +85,16 @@ const CHERRYPICK__CHERRYPICK__ANNOUNCES_A_CP_FAILURE_IN_THE_ANNOUNCE_SLACK_ROOM_ ['GITHUB_TOKEN', 'SLACK_WEBHOOK_URL'], ); -const getCherryPickMockSteps = (upToDate, isMergeable, shouldMerge) => [ +const getCherryPickMockSteps = (upToDate, hasConflicts) => [ CHERRYPICK__CHERRYPICK__CHECKOUT_STAGING_BRANCH__STEP_MOCK, CHERRYPICK__CHERRYPICK__SET_UP_GIT_FOR_OSBOTIFY__STEP_MOCK, - CHERRYPICK__CHERRYPICK__CREATE_BRANCH_FOR_NEW_PULL_REQUEST__STEP_MOCK, CHERRYPICK__CHERRYPICK__GET_MERGE_COMMIT_FOR_CP_PULL_REQUEST__STEP_MOCK, - CHERRYPICK__CHERRYPICK__GET_MERGE_COMMIT_FOR_VERSION_BUMP_PULL_REQUEST__STEP_MOCK, - CHERRYPICK__CHERRYPICK__CHERRY_PICK_THE_VERSION_BUMP_TO_NEW_BRANCH__STEP_MOCK, - shouldMerge - ? CHERRYPICK__CHERRYPICK__CHERRY_PICK_THE_MERGE_COMMIT_OF_TARGET_PR_TO_NEW_BRANCH__SHOULD_MERGE__STEP_MOCK - : CHERRYPICK__CHERRYPICK__CHERRY_PICK_THE_MERGE_COMMIT_OF_TARGET_PR_TO_NEW_BRANCH__SHOULD_NOT_MERGE__STEP_MOCK, - CHERRYPICK__CHERRYPICK__PUSH_CHANGES_TO_CP_BRANCH__STEP_MOCK, - CHERRYPICK__CHERRYPICK__CREATE_PULL_REQUEST__STEP_MOCK, - upToDate ? CHERRYPICK__CHERRYPICK__CHECK_IF_SHORTVERSIONSTRING_IS_UP_TO_DATE_TRUE__STEP_MOCK : CHERRYPICK__CHERRYPICK__CHECK_IF_SHORTVERSIONSTRING_IS_UP_TO_DATE_FALSE__STEP_MOCK, - CHERRYPICK__CHERRYPICK__AUTO_ASSIGN_PR_IF_THERE_ARE_MERGE_CONFLICTS_OR_IF_THE_BUNDLE_VERSIONS_ARE_MISMATCHED__STEP_MOCK, - CHERRYPICK__CHERRYPICK__ASSIGN_THE_PR_TO_THE_DEPLOYER__STEP_MOCK, - CHERRYPICK__CHERRYPICK__IF_PR_HAS_MERGE_CONFLICTS_COMMENT_WITH_INSTRUCTIONS_FOR_ASSIGNEE__STEP_MOCK, - CHERRYPICK__CHERRYPICK__IF_PR_HAS_A_BUNDLE_VERSION_MISMATCH_COMMENT_WITH_THE_INSTRUCTIONS_FOR_ASSIGNEE__STEP_MOCK, - CHERRYPICK__CHERRYPICK__AUTO_APPROVE_THE_PR__STEP_MOCK, - isMergeable ? CHERRYPICK__CHERRYPICK__CHECK_IF_PULL_REQUEST_IS_MERGEABLE_TRUE__STEP_MOCK : CHERRYPICK__CHERRYPICK__CHECK_IF_PULL_REQUEST_IS_MERGEABLE_FALSE__STEP_MOCK, - CHERRYPICK__CHERRYPICK__AUTO_MERGE_THE_PR__STEP_MOCK, + CHERRYPICK__CHERRYPICK__CHERRY_PICK_THE_VERSION_BUMP_TO_STAGING__STEP_MOCK, + hasConflicts + ? CHERRYPICK__CHERRYPICK__CHERRY_PICK_THE_MERGE_COMMIT_OF_TARGET_PR_TO_NEW_BRANCH__HAS_CONFLICTS__STEP_MOCK + : CHERRYPICK__CHERRYPICK__CHERRY_PICK_THE_MERGE_COMMIT_OF_TARGET_PR_TO_NEW_BRANCH__HAS_NO_CONFLICTS__STEP_MOCK, + CHERRYPICK__CHERRYPICK__PUSH_CHANGES__STEP_MOCK, + CHERRYPICK__CHERRYPICK__CREATE_PULL_REQUEST_TO_MANUALLY_FINISH_CP__STEP_MOCK, CHERRYPICK__CHERRYPICK__ANNOUNCES_A_CP_FAILURE_IN_THE_ANNOUNCE_SLACK_ROOM__STEP_MOCK, ]; diff --git a/workflow_tests/mocks/warnCPLabelMocks.js b/workflow_tests/mocks/warnCPLabelMocks.js deleted file mode 100644 index cf77ef23a6ef..000000000000 --- a/workflow_tests/mocks/warnCPLabelMocks.js +++ /dev/null @@ -1,25 +0,0 @@ -const utils = require('../utils/utils'); - -// warncplabel -const WARNCPLABEL__WARNCPLABEL__COMMENT_ON_PR_TO_EXPLAIN_THE_CP_STAGING_LABEL__STEP_MOCK = utils.createMockStep( - 'Comment on PR to explain the CP Staging label', - 'Comment on PR to explain the CP Staging label', - 'WARNCPLABEL', - ['github_token'], - [], -); -const WARNCPLABEL__WARNCPLABEL__ANNOUNCE_FAILED_WORKFLOW_IN_SLACK__STEP_MOCK = utils.createMockStep( - 'Announce failed workflow in Slack', - 'Announce failed workflow in Slack', - 'WARNCPLABEL', - ['SLACK_WEBHOOK'], - [], -); -const WARNCPLABEL__WARNCPLABEL__STEP_MOCKS = [ - WARNCPLABEL__WARNCPLABEL__COMMENT_ON_PR_TO_EXPLAIN_THE_CP_STAGING_LABEL__STEP_MOCK, - WARNCPLABEL__WARNCPLABEL__ANNOUNCE_FAILED_WORKFLOW_IN_SLACK__STEP_MOCK, -]; - -module.exports = { - WARNCPLABEL__WARNCPLABEL__STEP_MOCKS, -}; diff --git a/workflow_tests/warnCPLabel.test.js b/workflow_tests/warnCPLabel.test.js deleted file mode 100644 index 3dac7c60c334..000000000000 --- a/workflow_tests/warnCPLabel.test.js +++ /dev/null @@ -1,127 +0,0 @@ -const path = require('path'); -const kieMockGithub = require('@kie/mock-github'); -const utils = require('./utils/utils'); -const assertions = require('./assertions/warnCPLabelAssertions'); -const mocks = require('./mocks/warnCPLabelMocks'); -const eAct = require('./utils/ExtendedAct'); - -jest.setTimeout(60 * 1000); -let mockGithub; -const FILES_TO_COPY_INTO_TEST_REPO = [ - ...utils.deepCopy(utils.FILES_TO_COPY_INTO_TEST_REPO), - { - src: path.resolve(__dirname, '..', '.github', 'workflows', 'warnCPLabel.yml'), - dest: '.github/workflows/warnCPLabel.yml', - }, -]; - -describe('test workflow warnCPLabel', () => { - const githubToken = 'dummy_github_token'; - const actor = 'Dummy Actor'; - - beforeAll(async () => { - // in case of the tests being interrupted without cleanup the mock repo directory may be left behind - // which breaks the next test run, this removes any possible leftovers - utils.removeMockRepoDir(); - }); - - beforeEach(async () => { - // create a local repository and copy required files - mockGithub = new kieMockGithub.MockGithub({ - repo: { - testWarnCPLabelWorkflowRepo: { - files: FILES_TO_COPY_INTO_TEST_REPO, - }, - }, - }); - - await mockGithub.setup(); - }); - - afterEach(async () => { - await mockGithub.teardown(); - }); - describe('pull request target labeled', () => { - const event = 'pull_request_target'; - const eventOptions = { - action: 'labeled', - label: { - name: 'CP Staging', - }, - }; - const secrets = { - SLACK_WEBHOOK: 'dummy_slack_webhook', - }; - it('executes workflow', async () => { - const repoPath = mockGithub.repo.getPath('testWarnCPLabelWorkflowRepo') || ''; - const workflowPath = path.join(repoPath, '.github', 'workflows', 'warnCPLabel.yml'); - let act = new eAct.ExtendedAct(repoPath, workflowPath); - act = utils.setUpActParams(act, event, eventOptions, secrets, githubToken); - const testMockSteps = { - warnCPLabel: mocks.WARNCPLABEL__WARNCPLABEL__STEP_MOCKS, - }; - const result = await act.runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'warnCPLabel.yml'), - mockSteps: testMockSteps, - actor, - logFile: utils.getLogFilePath('warnCPLabel', expect.getState().currentTestName), - }); - - assertions.assertWarnCPLabelJobExecuted(result); - }); - describe('first step fails', () => { - it('executes workflow, announces failure on Slack', async () => { - const repoPath = mockGithub.repo.getPath('testWarnCPLabelWorkflowRepo') || ''; - const workflowPath = path.join(repoPath, '.github', 'workflows', 'warnCPLabel.yml'); - let act = new eAct.ExtendedAct(repoPath, workflowPath); - act = utils.setUpActParams(act, event, eventOptions, secrets, githubToken); - const testMockSteps = { - warnCPLabel: utils.deepCopy(mocks.WARNCPLABEL__WARNCPLABEL__STEP_MOCKS), - }; - testMockSteps.warnCPLabel[0] = utils.createMockStep( - 'Comment on PR to explain the CP Staging label', - 'Comment on PR to explain the CP Staging label', - 'WARNCPLABEL', - ['github_token'], - [], - {}, - {}, - false, - ); - const result = await act.runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'warnCPLabel.yml'), - mockSteps: testMockSteps, - actor, - logFile: utils.getLogFilePath('warnCPLabel', expect.getState().currentTestName), - }); - - assertions.assertWarnCPLabelJobExecuted(result, true, false); - }); - }); - describe('label different than CP Staging', () => { - const differentEventOptions = { - action: 'labeled', - label: { - name: 'Some Different Label', - }, - }; - it('does not execute workflow', async () => { - const repoPath = mockGithub.repo.getPath('testWarnCPLabelWorkflowRepo') || ''; - const workflowPath = path.join(repoPath, '.github', 'workflows', 'warnCPLabel.yml'); - let act = new eAct.ExtendedAct(repoPath, workflowPath); - act = utils.setUpActParams(act, event, differentEventOptions, secrets, githubToken); - const testMockSteps = { - warnCPLabel: mocks.WARNCPLABEL__WARNCPLABEL__STEP_MOCKS, - }; - const result = await act.runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'warnCPLabel.yml'), - mockSteps: testMockSteps, - actor, - logFile: utils.getLogFilePath('warnCPLabel', expect.getState().currentTestName), - }); - - assertions.assertWarnCPLabelJobExecuted(result, false); - }); - }); - }); -}); From 4e926add8cac52a489aad03ef6434da7dbf5bb37 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Fri, 30 Jun 2023 16:34:24 +0200 Subject: [PATCH 102/504] Fix createNewVersion tests Tests were failing after recent changes in main See: https://github.com/Expensify/App/issues/13604 --- .github/workflows/createNewVersion.yml | 9 ++++--- .../assertions/createNewVersionAssertions.js | 25 ++++++++----------- workflow_tests/mocks/createNewVersionMocks.js | 25 +++---------------- 3 files changed, 21 insertions(+), 38 deletions(-) diff --git a/.github/workflows/createNewVersion.yml b/.github/workflows/createNewVersion.yml index 8be7d5cb1c23..7e277e9cb566 100644 --- a/.github/workflows/createNewVersion.yml +++ b/.github/workflows/createNewVersion.yml @@ -46,18 +46,21 @@ jobs: NEW_VERSION: ${{ steps.bumpVersion.outputs.NEW_VERSION }} steps: - - uses: softprops/turnstyle@ca99add00ff0c9cbc697d22631d2992f377e5bd5 + - name: Run turnstyle + uses: softprops/turnstyle@ca99add00ff0c9cbc697d22631d2992f377e5bd5 with: poll-interval-seconds: 10 env: GITHUB_TOKEN: ${{ github.token }} - - uses: actions/checkout@v3 + - name: Check out + uses: actions/checkout@v3 with: ref: main token: ${{ secrets.OS_BOTIFY_TOKEN }} - - uses: Expensify/App/.github/actions/composite/setupGitForOSBotify@main + - name: Setup git for OSBotify + uses: Expensify/App/.github/actions/composite/setupGitForOSBotify@main with: GPG_PASSPHRASE: ${{ secrets.LARGE_SECRET_PASSPHRASE }} diff --git a/workflow_tests/assertions/createNewVersionAssertions.js b/workflow_tests/assertions/createNewVersionAssertions.js index f32a447f0fff..e4526ae59be2 100644 --- a/workflow_tests/assertions/createNewVersionAssertions.js +++ b/workflow_tests/assertions/createNewVersionAssertions.js @@ -13,37 +13,34 @@ const assertValidateActorJobExecuted = (workflowResult, didExecute = true) => { }; const assertCreateNewVersionJobExecuted = (workflowResult, semverLevel = 'BUILD', didExecute = true, isSuccessful = true) => { const steps = [ - utils.createStepAssertion('Check out', true, null, 'CREATENEWVERSION', 'Check out', [{key: 'fetch-depth', value: '0'}], []), - utils.createStepAssertion('Setup git for OSBotify', true, null, 'CREATENEWVERSION', 'Setup git for OSBotify', [{key: 'GPG_PASSPHRASE', value: '***'}], []), utils.createStepAssertion('Run turnstyle', true, null, 'CREATENEWVERSION', 'Run turnstyle', [{key: 'poll-interval-seconds', value: '10'}], [{key: 'GITHUB_TOKEN', value: '***'}]), - utils.createStepAssertion('Create new branch', true, null, 'CREATENEWVERSION', 'Create new branch', [], []), utils.createStepAssertion( - 'Generate version', + 'Check out', true, null, 'CREATENEWVERSION', - 'Generate version', + 'Check out', [ - {key: 'GITHUB_TOKEN', value: '***'}, - {key: 'SEMVER_LEVEL', value: semverLevel}, + {key: 'ref', value: 'main'}, + {key: 'token', value: '***'}, ], [], ), - utils.createStepAssertion('Commit new version', true, null, 'CREATENEWVERSION', 'Commit new version', [], []), + utils.createStepAssertion('Setup git for OSBotify', true, null, 'CREATENEWVERSION', 'Setup git for OSBotify', [{key: 'GPG_PASSPHRASE', value: '***'}], []), utils.createStepAssertion( - 'Update main branch', + 'Generate version', true, null, 'CREATENEWVERSION', - 'Update main branch', + 'Generate version', [ - {key: 'TARGET_BRANCH', value: 'main'}, - {key: 'SOURCE_BRANCH', value: `version-${semverLevel}-abcdef`}, - {key: 'OS_BOTIFY_TOKEN', value: '***'}, - {key: 'GPG_PASSPHRASE', value: '***'}, + {key: 'GITHUB_TOKEN', value: '***'}, + {key: 'SEMVER_LEVEL', value: semverLevel}, ], [], ), + utils.createStepAssertion('Commit new version', true, null, 'CREATENEWVERSION', 'Commit new version', [], []), + utils.createStepAssertion('Update main branch', true, null, 'CREATENEWVERSION', 'Update main branch', [], []), ]; steps.forEach((expectedStep) => { diff --git a/workflow_tests/mocks/createNewVersionMocks.js b/workflow_tests/mocks/createNewVersionMocks.js index cd0db0b52c0d..a1f601aef47f 100644 --- a/workflow_tests/mocks/createNewVersionMocks.js +++ b/workflow_tests/mocks/createNewVersionMocks.js @@ -15,7 +15,8 @@ const CREATENEWVERSION__VALIDATEACTOR__WRITER__STEP_MOCKS = [CREATENEWVERSION__V const CREATENEWVERSION__VALIDATEACTOR__NO_PERMISSION__STEP_MOCKS = [CREATENEWVERSION__VALIDATEACTOR__GET_USER_PERMISSIONS__NONE__STEP_MOCK]; // createnewversion -const CREATENEWVERSION__CREATENEWVERSION__CHECK_OUT__STEP_MOCK = utils.createMockStep('Check out', 'Check out', 'CREATENEWVERSION', ['fetch-depth'], []); +const CREATENEWVERSION__CREATENEWVERSION__RUN_TURNSTYLE__STEP_MOCK = utils.createMockStep('Run turnstyle', 'Run turnstyle', 'CREATENEWVERSION', ['poll-interval-seconds'], ['GITHUB_TOKEN']); +const CREATENEWVERSION__CREATENEWVERSION__CHECK_OUT__STEP_MOCK = utils.createMockStep('Check out', 'Check out', 'CREATENEWVERSION', ['ref', 'token'], []); const CREATENEWVERSION__CREATENEWVERSION__SETUP_GIT_FOR_OSBOTIFY__STEP_MOCK = utils.createMockStep( 'Setup git for OSBotify', 'Setup git for OSBotify', @@ -23,17 +24,6 @@ const CREATENEWVERSION__CREATENEWVERSION__SETUP_GIT_FOR_OSBOTIFY__STEP_MOCK = ut ['GPG_PASSPHRASE'], [], ); -const CREATENEWVERSION__CREATENEWVERSION__RUN_TURNSTYLE__STEP_MOCK = utils.createMockStep('Run turnstyle', 'Run turnstyle', 'CREATENEWVERSION', ['poll-interval-seconds'], ['GITHUB_TOKEN']); -const CREATENEWVERSION__CREATENEWVERSION__CREATE_NEW_BRANCH__STEP_MOCK = utils.createMockStep( - 'Create new branch', - 'Create new branch', - 'CREATENEWVERSION', - [], - [], - [], - // eslint-disable-next-line no-template-curly-in-string - {VERSION_BRANCH: 'version-${{ github.event.inputs.SEMVER_LEVEL }}-abcdef'}, -); const CREATENEWVERSION__CREATENEWVERSION__GENERATE_VERSION__STEP_MOCK = utils.createMockStep( 'Generate version', 'Generate version', @@ -42,13 +32,7 @@ const CREATENEWVERSION__CREATENEWVERSION__GENERATE_VERSION__STEP_MOCK = utils.cr [], ); const CREATENEWVERSION__CREATENEWVERSION__COMMIT_NEW_VERSION__STEP_MOCK = utils.createMockStep('Commit new version', 'Commit new version', 'CREATENEWVERSION', [], []); -const CREATENEWVERSION__CREATENEWVERSION__UPDATE_MAIN_BRANCH__STEP_MOCK = utils.createMockStep( - 'Update main branch', - 'Update main branch', - 'CREATENEWVERSION', - ['TARGET_BRANCH', 'SOURCE_BRANCH', 'OS_BOTIFY_TOKEN', 'GPG_PASSPHRASE'], - [], -); +const CREATENEWVERSION__CREATENEWVERSION__UPDATE_MAIN_BRANCH__STEP_MOCK = utils.createMockStep('Update main branch', 'Update main branch', 'CREATENEWVERSION', [], []); const CREATENEWVERSION__CREATENEWVERSION__ANNOUNCE_FAILED_WORKFLOW_IN_SLACK__STEP_MOCK = utils.createMockStep( 'Announce failed workflow in Slack', 'Announce failed workflow in Slack', @@ -57,10 +41,9 @@ const CREATENEWVERSION__CREATENEWVERSION__ANNOUNCE_FAILED_WORKFLOW_IN_SLACK__STE [], ); const CREATENEWVERSION__CREATENEWVERSION__STEP_MOCKS = [ + CREATENEWVERSION__CREATENEWVERSION__RUN_TURNSTYLE__STEP_MOCK, CREATENEWVERSION__CREATENEWVERSION__CHECK_OUT__STEP_MOCK, CREATENEWVERSION__CREATENEWVERSION__SETUP_GIT_FOR_OSBOTIFY__STEP_MOCK, - CREATENEWVERSION__CREATENEWVERSION__RUN_TURNSTYLE__STEP_MOCK, - CREATENEWVERSION__CREATENEWVERSION__CREATE_NEW_BRANCH__STEP_MOCK, CREATENEWVERSION__CREATENEWVERSION__GENERATE_VERSION__STEP_MOCK, CREATENEWVERSION__CREATENEWVERSION__COMMIT_NEW_VERSION__STEP_MOCK, CREATENEWVERSION__CREATENEWVERSION__UPDATE_MAIN_BRANCH__STEP_MOCK, From a8a6900033c0d282c0b3f1362eed45c1e79b0526 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Fri, 30 Jun 2023 16:41:50 +0200 Subject: [PATCH 103/504] Fix deploy tests Tests were failing after recent changes in main See: https://github.com/Expensify/App/issues/13604 --- workflow_tests/assertions/deployAssertions.js | 20 ---- workflow_tests/deploy.test.js | 108 +----------------- workflow_tests/mocks/deployMocks.js | 16 --- 3 files changed, 1 insertion(+), 143 deletions(-) diff --git a/workflow_tests/assertions/deployAssertions.js b/workflow_tests/assertions/deployAssertions.js index b6cac03b41ee..7931f20db7cb 100644 --- a/workflow_tests/assertions/deployAssertions.js +++ b/workflow_tests/assertions/deployAssertions.js @@ -1,24 +1,5 @@ const utils = require('../utils/utils'); -const assertValidateJobExecuted = (workflowResult, didExecute = true) => { - const steps = [ - utils.createStepAssertion('Get merged pull request', true, null, 'VALIDATE', 'Getting merged PR', [{key: 'github_token', value: '***'}]), - { - name: 'Main Check if merged pull request was an automatic version bump PR', - status: 0, - output: '', - }, - ]; - - steps.forEach((expectedStep) => { - if (didExecute) { - expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); - } else { - expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); - } - }); -}; - const assertDeployStagingJobExecuted = (workflowResult, didExecute = true) => { const steps = [ utils.createStepAssertion('Checkout staging branch', true, null, 'DEPLOY_STAGING', 'Checking out staging branch', [ @@ -78,7 +59,6 @@ const assertDeployProductionJobExecuted = (workflowResult, didExecute = true) => }; module.exports = { - assertValidateJobExecuted, assertDeployStagingJobExecuted, assertDeployProductionJobExecuted, }; diff --git a/workflow_tests/deploy.test.js b/workflow_tests/deploy.test.js index 4d672b93d36e..13bd2c969bdd 100644 --- a/workflow_tests/deploy.test.js +++ b/workflow_tests/deploy.test.js @@ -39,7 +39,7 @@ describe('test workflow deploy', () => { afterEach(async () => { await mockGithub.teardown(); }); - describe('push as OSBotify', () => { + describe('push', () => { it('to main - nothing triggered', async () => { const repoPath = mockGithub.repo.getPath('testDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'deploy.yml'); @@ -57,7 +57,6 @@ describe('test workflow deploy', () => { 'dummy_github_token', ); const testMockSteps = { - validate: mocks.VALIDATE__OSBOTIFY__STEP_MOCKS, deployStaging: mocks.DEPLOY_STAGING_STEP_MOCKS, deployProduction: mocks.DEPLOY_PRODUCTION_STEP_MOCKS, }; @@ -67,7 +66,6 @@ describe('test workflow deploy', () => { actor: 'OSBotify', logFile: utils.getLogFilePath('deploy', expect.getState().currentTestName), }); - assertions.assertValidateJobExecuted(result); assertions.assertDeployStagingJobExecuted(result, false); assertions.assertDeployProductionJobExecuted(result, false); }); @@ -89,7 +87,6 @@ describe('test workflow deploy', () => { 'dummy_github_token', ); const testMockSteps = { - validate: mocks.VALIDATE__OSBOTIFY__STEP_MOCKS, deployStaging: mocks.DEPLOY_STAGING_STEP_MOCKS, deployProduction: mocks.DEPLOY_PRODUCTION_STEP_MOCKS, }; @@ -99,7 +96,6 @@ describe('test workflow deploy', () => { actor: 'OSBotify', logFile: utils.getLogFilePath('deploy', expect.getState().currentTestName), }); - assertions.assertValidateJobExecuted(result); assertions.assertDeployStagingJobExecuted(result); assertions.assertDeployProductionJobExecuted(result, false); }); @@ -121,7 +117,6 @@ describe('test workflow deploy', () => { 'dummy_github_token', ); const testMockSteps = { - validate: mocks.VALIDATE__OSBOTIFY__STEP_MOCKS, deployStaging: mocks.DEPLOY_STAGING_STEP_MOCKS, deployProduction: mocks.DEPLOY_PRODUCTION_STEP_MOCKS, }; @@ -131,115 +126,16 @@ describe('test workflow deploy', () => { actor: 'OSBotify', logFile: utils.getLogFilePath('deploy', expect.getState().currentTestName), }); - assertions.assertValidateJobExecuted(result); assertions.assertDeployStagingJobExecuted(result, false); assertions.assertDeployProductionJobExecuted(result); }); }); - describe('push as user', () => { - it('to main - nothing triggered', async () => { - const repoPath = mockGithub.repo.getPath('testDeployWorkflowRepo') || ''; - const workflowPath = path.join(repoPath, '.github', 'workflows', 'deploy.yml'); - let act = new eAct.ExtendedAct(repoPath, workflowPath); - act = utils.setUpActParams( - act, - 'push', - { - ref: 'refs/heads/main', - }, - { - OS_BOTIFY_TOKEN: 'dummy_token', - LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', - }, - 'dummy_github_token', - ); - const testMockSteps = { - validate: mocks.VALIDATE_STEP_MOCKS, - deployStaging: mocks.DEPLOY_STAGING_STEP_MOCKS, - deployProduction: mocks.DEPLOY_PRODUCTION_STEP_MOCKS, - }; - const result = await act.runEvent('push', { - workflowFile: path.join(repoPath, '.github', 'workflows', 'deploy.yml'), - mockSteps: testMockSteps, - actor: 'Dummy Author', - logFile: utils.getLogFilePath('deploy', expect.getState().currentTestName), - }); - assertions.assertValidateJobExecuted(result); - assertions.assertDeployStagingJobExecuted(result, false); - assertions.assertDeployProductionJobExecuted(result, false); - }); - - it('to staging - nothing triggered', async () => { - const repoPath = mockGithub.repo.getPath('testDeployWorkflowRepo') || ''; - const workflowPath = path.join(repoPath, '.github', 'workflows', 'deploy.yml'); - let act = new eAct.ExtendedAct(repoPath, workflowPath); - act = utils.setUpActParams( - act, - 'push', - { - ref: 'refs/heads/staging', - }, - { - OS_BOTIFY_TOKEN: 'dummy_token', - LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', - }, - 'dummy_github_token', - ); - const testMockSteps = { - validate: mocks.VALIDATE_STEP_MOCKS, - deployStaging: mocks.DEPLOY_STAGING_STEP_MOCKS, - deployProduction: mocks.DEPLOY_PRODUCTION_STEP_MOCKS, - }; - const result = await act.runEvent('push', { - workflowFile: path.join(repoPath, '.github', 'workflows', 'deploy.yml'), - mockSteps: testMockSteps, - actor: 'Dummy Author', - logFile: utils.getLogFilePath('deploy', expect.getState().currentTestName), - }); - assertions.assertValidateJobExecuted(result); - assertions.assertDeployStagingJobExecuted(result, false); - assertions.assertDeployProductionJobExecuted(result, false); - }); - - it('to production - nothing triggered', async () => { - const repoPath = mockGithub.repo.getPath('testDeployWorkflowRepo') || ''; - const workflowPath = path.join(repoPath, '.github', 'workflows', 'deploy.yml'); - let act = new eAct.ExtendedAct(repoPath, workflowPath); - act = utils.setUpActParams( - act, - 'push', - { - ref: 'refs/heads/production', - }, - { - OS_BOTIFY_TOKEN: 'dummy_token', - LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', - }, - 'dummy_github_token', - ); - const testMockSteps = { - validate: mocks.VALIDATE_STEP_MOCKS, - deployStaging: mocks.DEPLOY_STAGING_STEP_MOCKS, - deployProduction: mocks.DEPLOY_PRODUCTION_STEP_MOCKS, - }; - const result = await act.runEvent('push', { - workflowFile: path.join(repoPath, '.github', 'workflows', 'deploy.yml'), - mockSteps: testMockSteps, - actor: 'Dummy Author', - logFile: utils.getLogFilePath('deploy', expect.getState().currentTestName), - }); - assertions.assertValidateJobExecuted(result); - assertions.assertDeployStagingJobExecuted(result, false); - assertions.assertDeployProductionJobExecuted(result, false); - }); - }); it('different event than push - workflow does not execute', async () => { const repoPath = mockGithub.repo.getPath('testDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'deploy.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); const testMockSteps = { - validate: mocks.VALIDATE__OSBOTIFY__STEP_MOCKS, deployStaging: mocks.DEPLOY_STAGING_STEP_MOCKS, deployProduction: mocks.DEPLOY_PRODUCTION_STEP_MOCKS, }; @@ -261,7 +157,6 @@ describe('test workflow deploy', () => { actor: 'Dummy Author', logFile: utils.getLogFilePath('deploy', expect.getState().currentTestName), }); - assertions.assertValidateJobExecuted(result, false); assertions.assertDeployStagingJobExecuted(result, false); assertions.assertDeployProductionJobExecuted(result, false); @@ -282,7 +177,6 @@ describe('test workflow deploy', () => { actor: 'Dummy Author', logFile: utils.getLogFilePath('deploy', expect.getState().currentTestName), }); - assertions.assertValidateJobExecuted(result, false); assertions.assertDeployStagingJobExecuted(result, false); assertions.assertDeployProductionJobExecuted(result, false); }); diff --git a/workflow_tests/mocks/deployMocks.js b/workflow_tests/mocks/deployMocks.js index f4284215437d..997918fe9d91 100644 --- a/workflow_tests/mocks/deployMocks.js +++ b/workflow_tests/mocks/deployMocks.js @@ -1,19 +1,5 @@ const utils = require('../utils/utils'); -const VALIDATE__GET_MERGED_PR__STEP_MOCK = utils.createMockStep('Get merged pull request', 'Getting merged PR', 'VALIDATE', ['github_token'], [], {author: 'Dummy Author'}); -const VALIDATE__GET_MERGED_PR__OSBOTIFY__STEP_MOCK = utils.createMockStep('Get merged pull request', 'Getting merged PR', 'VALIDATE', ['github_token'], [], {author: 'OSBotify'}); - -const VALIDATE_STEP_MOCKS = [ - VALIDATE__GET_MERGED_PR__STEP_MOCK, - - // 2nd step normal -]; -const VALIDATE__OSBOTIFY__STEP_MOCKS = [ - VALIDATE__GET_MERGED_PR__OSBOTIFY__STEP_MOCK, - - // 2nd step normal -]; - const DEPLOY_STAGING__CHECKOUT__STEP_MOCK = utils.createMockStep('Checkout staging branch', 'Checking out staging branch', 'DEPLOY_STAGING', ['ref', 'token']); const DEPLOY_STAGING__SETUP_GIT__STEP_MOCK = utils.createMockStep('Setup git for OSBotify', 'Setting up git for OSBotify', 'DEPLOY_STAGING', ['GPG_PASSPHRASE']); const DEPLOY_STAGING__TAG_VERSION__STEP_MOCK = utils.createMockStep('Tag version', 'Tagging new version', 'DEPLOY_STAGING'); @@ -55,8 +41,6 @@ const DEPLOY_PRODUCTION_STEP_MOCKS = [ ]; module.exports = { - VALIDATE_STEP_MOCKS, - VALIDATE__OSBOTIFY__STEP_MOCKS, DEPLOY_STAGING_STEP_MOCKS, DEPLOY_PRODUCTION_STEP_MOCKS, }; From 34b6ff59e909088d37f85c6880522d965f54a153 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Fri, 30 Jun 2023 18:22:57 +0200 Subject: [PATCH 104/504] Fix finishReleaseCycle tests Tests were failing after recent changes in main See: https://github.com/Expensify/App/issues/13604 --- .github/workflows/finishReleaseCycle.yml | 30 +++-- .../finishReleaseCycleAssertions.js | 104 +++++++++++++----- workflow_tests/finishReleaseCycle.test.js | 20 +++- .../mocks/finishReleaseCycleMocks.js | 78 ++++++++++--- 4 files changed, 175 insertions(+), 57 deletions(-) diff --git a/.github/workflows/finishReleaseCycle.yml b/.github/workflows/finishReleaseCycle.yml index cb7fb58b4d20..740dcb7e1bd0 100644 --- a/.github/workflows/finishReleaseCycle.yml +++ b/.github/workflows/finishReleaseCycle.yml @@ -23,7 +23,7 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.OS_BOTIFY_TOKEN }} - - name: Reopen and comment on issue + - name: Reopen and comment on issue (not a team member) if: ${{ !fromJSON(steps.isDeployer.outputs.IS_DEPLOYER) }} uses: Expensify/App/.github/actions/javascript/reopenIssueWithComment@main with: @@ -41,8 +41,8 @@ jobs: GITHUB_TOKEN: ${{ secrets.OS_BOTIFY_TOKEN }} ISSUE_NUMBER: ${{ github.event.issue.number }} - - name: Reopen and comment on issue - if: ${{ fromJSON(steps.isDeployer.outputs.IS_DEPLOYER) && fromJSON(steps.checkDeployBlockers.outputs.HAS_DEPLOY_BLOCKERS) }} + - name: Reopen and comment on issue (has blockers) + if: ${{ fromJSON(steps.isDeployer.outputs.IS_DEPLOYER) && fromJSON(steps.checkDeployBlockers.outputs.HAS_DEPLOY_BLOCKERS || 'false') }} uses: Expensify/App/.github/actions/javascript/reopenIssueWithComment@main with: GITHUB_TOKEN: ${{ secrets.OS_BOTIFY_TOKEN }} @@ -51,7 +51,8 @@ jobs: This issue either has unchecked items or has not yet been marked with the `:shipit:` emoji of approval. Reopening! - - if: ${{ failure() }} + - name: Announce failed workflow in Slack + if: ${{ failure() }} uses: Expensify/App/.github/actions/composite/announceFailedWorkflowInSlack@main with: SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} @@ -62,12 +63,14 @@ jobs: needs: validate if: ${{ fromJSON(needs.validate.outputs.isValid) }} steps: - - uses: actions/checkout@v3 + - name: Checkout + uses: actions/checkout@v3 with: ref: staging token: ${{ secrets.OS_BOTIFY_TOKEN }} - - uses: Expensify/App/.github/actions/composite/setupGitForOSBotify@main + - name: Setup Git for OSBotify + uses: Expensify/App/.github/actions/composite/setupGitForOSBotify@main with: GPG_PASSPHRASE: ${{ secrets.LARGE_SECRET_PASSPHRASE }} @@ -79,7 +82,8 @@ jobs: # Force-update the remote production branch. git push --force origin production - - if: ${{ failure() }} + - name: Announce failed workflow in Slack + if: ${{ failure() }} uses: Expensify/App/.github/actions/composite/announceFailedWorkflowInSlack@main with: SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} @@ -98,12 +102,14 @@ jobs: runs-on: ubuntu-latest needs: [updateProduction, createNewPatchVersion] steps: - - uses: actions/checkout@v3 + - name: Checkout + uses: actions/checkout@v3 with: ref: main token: ${{ secrets.OS_BOTIFY_TOKEN }} - - uses: Expensify/App/.github/actions/composite/setupGitForOSBotify@main + - name: Setup Git for OSBotify + uses: Expensify/App/.github/actions/composite/setupGitForOSBotify@main with: GPG_PASSPHRASE: ${{ secrets.LARGE_SECRET_PASSPHRASE }} @@ -115,7 +121,8 @@ jobs: # Force-update the remote staging branch git push --force origin staging - - if: ${{ failure() }} + - name: Announce failed workflow in Slack + if: ${{ failure() }} uses: Expensify/App/.github/actions/composite/announceFailedWorkflowInSlack@main with: SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} @@ -125,7 +132,8 @@ jobs: runs-on: ubuntu-latest needs: [updateStaging, createNewPatchVersion] steps: - - uses: actions/checkout@v3 + - name: Checkout + uses: actions/checkout@v3 with: ref: staging token: ${{ secrets.OS_BOTIFY_TOKEN }} diff --git a/workflow_tests/assertions/finishReleaseCycleAssertions.js b/workflow_tests/assertions/finishReleaseCycleAssertions.js index ca195297800c..5d2e9c66555f 100644 --- a/workflow_tests/assertions/finishReleaseCycleAssertions.js +++ b/workflow_tests/assertions/finishReleaseCycleAssertions.js @@ -1,21 +1,7 @@ const utils = require('../utils/utils'); -const assertValidateJobExecuted = (workflowResult, username = 'Dummy Author', issueNumber = '', didExecute = true, isTeamMember = true, hasBlockers = false) => { - const steps = [ - utils.createStepAssertion( - 'Validate actor is deployer', - true, - null, - 'VALIDATE', - 'Validating if actor is deployer', - [ - {key: 'GITHUB_TOKEN', value: '***'}, - {key: 'username', value: username}, - {key: 'team', value: 'mobile-deployers'}, - ], - [], - ), - ]; +const assertValidateJobExecuted = (workflowResult, issueNumber = '', didExecute = true, isTeamMember = true, hasBlockers = false, isSuccessful = true) => { + const steps = [utils.createStepAssertion('Validate actor is deployer', true, null, 'VALIDATE', 'Validating if actor is deployer', [], [{key: 'GITHUB_TOKEN', value: '***'}])]; if (isTeamMember) { steps.push( utils.createStepAssertion( @@ -88,23 +74,36 @@ const assertValidateJobExecuted = (workflowResult, username = 'Dummy Author', is expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); } }); + + const failedSteps = [ + utils.createStepAssertion('Announce failed workflow in Slack', true, null, 'VALIDATE', 'Announce failed workflow in Slack', [{key: 'SLACK_WEBHOOK', value: '***'}], []), + ]; + + failedSteps.forEach((expectedStep) => { + if (didExecute && !isSuccessful) { + expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); + } else { + expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); + } + }); }; -const assertUpdateProductionJobExecuted = (workflowResult, didExecute = true) => { +const assertUpdateProductionJobExecuted = (workflowResult, didExecute = true, isSuccessful = true) => { const steps = [ utils.createStepAssertion( - 'Update production branch', + 'Checkout', true, null, 'UPDATEPRODUCTION', - 'Updating production branch', + 'Checkout', [ - {key: 'TARGET_BRANCH', value: 'production'}, - {key: 'OS_BOTIFY_TOKEN', value: '***'}, - {key: 'GPG_PASSPHRASE', value: '***'}, + {key: 'ref', value: 'staging'}, + {key: 'token', value: '***'}, ], [], ), + utils.createStepAssertion('Setup Git for OSBotify', true, null, 'UPDATEPRODUCTION', 'Setup Git for OSBotify', [{key: 'GPG_PASSPHRASE', value: '***'}], []), + utils.createStepAssertion('Update production branch', true, null, 'UPDATEPRODUCTION', 'Updating production branch', [], []), ]; steps.forEach((expectedStep) => { @@ -114,6 +113,18 @@ const assertUpdateProductionJobExecuted = (workflowResult, didExecute = true) => expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); } }); + + const failedSteps = [ + utils.createStepAssertion('Announce failed workflow in Slack', true, null, 'UPDATEPRODUCTION', 'Announce failed workflow in Slack', [{key: 'SLACK_WEBHOOK', value: '***'}], []), + ]; + + failedSteps.forEach((expectedStep) => { + if (didExecute && !isSuccessful) { + expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); + } else { + expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); + } + }); }; const assertCreateNewPatchVersionJobExecuted = (workflowResult, didExecute = true) => { @@ -128,18 +139,56 @@ const assertCreateNewPatchVersionJobExecuted = (workflowResult, didExecute = tru }); }; +const assertUpdateStagingJobExecuted = (workflowResult, didExecute = true, isSuccessful = true) => { + const steps = [ + utils.createStepAssertion( + 'Checkout', + true, + null, + 'UPDATESTAGING', + 'Checkout', + [ + {key: 'ref', value: 'main'}, + {key: 'token', value: '***'}, + ], + [], + ), + utils.createStepAssertion('Setup Git for OSBotify', true, null, 'UPDATESTAGING', 'Setup Git for OSBotify', [{key: 'GPG_PASSPHRASE', value: '***'}], []), + utils.createStepAssertion('Update staging branch to trigger staging deploy', true, null, 'UPDATESTAGING', 'Updating staging branch', [], []), + ]; + + steps.forEach((expectedStep) => { + if (didExecute) { + expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); + } else { + expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); + } + }); + + const failedSteps = [ + utils.createStepAssertion('Announce failed workflow in Slack', true, null, 'UPDATESTAGING', 'Announce failed workflow in Slack', [{key: 'SLACK_WEBHOOK', value: '***'}], []), + ]; + + failedSteps.forEach((expectedStep) => { + if (didExecute && !isSuccessful) { + expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); + } else { + expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); + } + }); +}; + const assertCreateNewStagingDeployCashJobExecuted = (workflowResult, newVersion = '', didExecute = true, isSuccessful = true) => { const steps = [ utils.createStepAssertion( - 'Update staging branch to trigger staging deploy', + 'Checkout', true, null, 'CREATENEWSTAGINGDEPLOYCASH', - 'Updating staging branch', + 'Checkout', [ - {key: 'TARGET_BRANCH', value: 'staging'}, - {key: 'OS_BOTIFY_TOKEN', value: '***'}, - {key: 'GPG_PASSPHRASE', value: '***'}, + {key: 'ref', value: 'staging'}, + {key: 'token', value: '***'}, ], [], ), @@ -187,5 +236,6 @@ module.exports = { assertValidateJobExecuted, assertUpdateProductionJobExecuted, assertCreateNewPatchVersionJobExecuted, + assertUpdateStagingJobExecuted, assertCreateNewStagingDeployCashJobExecuted, }; diff --git a/workflow_tests/finishReleaseCycle.test.js b/workflow_tests/finishReleaseCycle.test.js index ae826443583e..20c6340c9087 100644 --- a/workflow_tests/finishReleaseCycle.test.js +++ b/workflow_tests/finishReleaseCycle.test.js @@ -66,6 +66,7 @@ describe('test workflow finishReleaseCycle', () => { const testMockSteps = { validate: mocks.FINISHRELEASECYCLE__VALIDATE__TEAM_MEMBER_NO_BLOCKERS__STEP_MOCKS, updateProduction: mocks.FINISHRELEASECYCLE__UPDATEPRODUCTION__STEP_MOCKS, + updateStaging: mocks.FINISHRELEASECYCLE__UPDATESTAGING__STEP_MOCKS, createNewStagingDeployCash: mocks.FINISHRELEASECYCLE__CREATENEWSTAGINGDEPLOYCASH__STEP_MOCKS, }; const testMockJobs = { @@ -85,9 +86,10 @@ describe('test workflow finishReleaseCycle', () => { logFile: utils.getLogFilePath('finishReleaseCycle', expect.getState().currentTestName), mockJobs: testMockJobs, }); - assertions.assertValidateJobExecuted(result, 'Dummy Author', '1234'); + assertions.assertValidateJobExecuted(result, '1234'); assertions.assertUpdateProductionJobExecuted(result); assertions.assertCreateNewPatchVersionJobExecuted(result); + assertions.assertUpdateStagingJobExecuted(result); assertions.assertCreateNewStagingDeployCashJobExecuted(result, '1.2.3'); }); describe('createNewStagingDeployCash fails', () => { @@ -115,6 +117,7 @@ describe('test workflow finishReleaseCycle', () => { const testMockSteps = { validate: mocks.FINISHRELEASECYCLE__VALIDATE__TEAM_MEMBER_NO_BLOCKERS__STEP_MOCKS, updateProduction: mocks.FINISHRELEASECYCLE__UPDATEPRODUCTION__STEP_MOCKS, + updateStaging: mocks.FINISHRELEASECYCLE__UPDATESTAGING__STEP_MOCKS, createNewStagingDeployCash: mocks.FINISHRELEASECYCLE__CREATENEWSTAGINGDEPLOYCASH__STEP_MOCKS, }; testMockSteps.createNewStagingDeployCash[2] = utils.createMockStep( @@ -144,9 +147,10 @@ describe('test workflow finishReleaseCycle', () => { logFile: utils.getLogFilePath('finishReleaseCycle', expect.getState().currentTestName), mockJobs: testMockJobs, }); - assertions.assertValidateJobExecuted(result, 'Dummy Author', '1234'); + assertions.assertValidateJobExecuted(result, '1234'); assertions.assertUpdateProductionJobExecuted(result); assertions.assertCreateNewPatchVersionJobExecuted(result); + assertions.assertUpdateStagingJobExecuted(result); assertions.assertCreateNewStagingDeployCashJobExecuted(result, '1.2.3', true, false); }); }); @@ -176,6 +180,7 @@ describe('test workflow finishReleaseCycle', () => { const testMockSteps = { validate: mocks.FINISHRELEASECYCLE__VALIDATE__TEAM_MEMBER_BLOCKERS__STEP_MOCKS, updateProduction: mocks.FINISHRELEASECYCLE__UPDATEPRODUCTION__STEP_MOCKS, + updateStaging: mocks.FINISHRELEASECYCLE__UPDATESTAGING__STEP_MOCKS, createNewStagingDeployCash: mocks.FINISHRELEASECYCLE__CREATENEWSTAGINGDEPLOYCASH__STEP_MOCKS, }; const testMockJobs = { @@ -195,9 +200,10 @@ describe('test workflow finishReleaseCycle', () => { logFile: utils.getLogFilePath('finishReleaseCycle', expect.getState().currentTestName), mockJobs: testMockJobs, }); - assertions.assertValidateJobExecuted(result, 'Dummy Author', '1234', true, true, true); + assertions.assertValidateJobExecuted(result, '1234', true, true, true); assertions.assertUpdateProductionJobExecuted(result, false); assertions.assertCreateNewPatchVersionJobExecuted(result, false); + assertions.assertUpdateStagingJobExecuted(result, false); assertions.assertCreateNewStagingDeployCashJobExecuted(result, '1.2.3', false); }); }); @@ -227,6 +233,7 @@ describe('test workflow finishReleaseCycle', () => { const testMockSteps = { validate: mocks.FINISHRELEASECYCLE__VALIDATE__NOT_TEAM_MEMBER_NO_BLOCKERS__STEP_MOCKS, updateProduction: mocks.FINISHRELEASECYCLE__UPDATEPRODUCTION__STEP_MOCKS, + updateStaging: mocks.FINISHRELEASECYCLE__UPDATESTAGING__STEP_MOCKS, createNewStagingDeployCash: mocks.FINISHRELEASECYCLE__CREATENEWSTAGINGDEPLOYCASH__STEP_MOCKS, }; const testMockJobs = { @@ -246,9 +253,10 @@ describe('test workflow finishReleaseCycle', () => { logFile: utils.getLogFilePath('finishReleaseCycle', expect.getState().currentTestName), mockJobs: testMockJobs, }); - assertions.assertValidateJobExecuted(result, 'Dummy Author', '1234', true, false, false); + assertions.assertValidateJobExecuted(result, '1234', true, false, false); assertions.assertUpdateProductionJobExecuted(result, false); assertions.assertCreateNewPatchVersionJobExecuted(result, false); + assertions.assertUpdateStagingJobExecuted(result, false); assertions.assertCreateNewStagingDeployCashJobExecuted(result, '1.2.3', false); }); }); @@ -278,6 +286,7 @@ describe('test workflow finishReleaseCycle', () => { const testMockSteps = { validate: mocks.FINISHRELEASECYCLE__VALIDATE__TEAM_MEMBER_NO_BLOCKERS__STEP_MOCKS, updateProduction: mocks.FINISHRELEASECYCLE__UPDATEPRODUCTION__STEP_MOCKS, + updateStaging: mocks.FINISHRELEASECYCLE__UPDATESTAGING__STEP_MOCKS, createNewStagingDeployCash: mocks.FINISHRELEASECYCLE__CREATENEWSTAGINGDEPLOYCASH__STEP_MOCKS, }; const testMockJobs = { @@ -297,9 +306,10 @@ describe('test workflow finishReleaseCycle', () => { logFile: utils.getLogFilePath('finishReleaseCycle', expect.getState().currentTestName), mockJobs: testMockJobs, }); - assertions.assertValidateJobExecuted(result, 'Dummy Author', '1234', false); + assertions.assertValidateJobExecuted(result, '1234', false); assertions.assertUpdateProductionJobExecuted(result, false); assertions.assertCreateNewPatchVersionJobExecuted(result, false); + assertions.assertUpdateStagingJobExecuted(result, false); assertions.assertCreateNewStagingDeployCashJobExecuted(result, '1.2.3', false); }); }); diff --git a/workflow_tests/mocks/finishReleaseCycleMocks.js b/workflow_tests/mocks/finishReleaseCycleMocks.js index d22f30752cc8..82b1b44e1ed9 100644 --- a/workflow_tests/mocks/finishReleaseCycleMocks.js +++ b/workflow_tests/mocks/finishReleaseCycleMocks.js @@ -5,17 +5,17 @@ const FINISHRELEASECYCLE__VALIDATE__VALIDATE_ACTOR_IS_DEPLOYER_TRUE__STEP_MOCK = 'Validate actor is deployer', 'Validating if actor is deployer', 'VALIDATE', - ['GITHUB_TOKEN', 'username', 'team'], [], - {isTeamMember: true}, + ['GITHUB_TOKEN'], + {IS_DEPLOYER: true}, ); const FINISHRELEASECYCLE__VALIDATE__VALIDATE_ACTOR_IS_DEPLOYER_FALSE__STEP_MOCK = utils.createMockStep( 'Validate actor is deployer', 'Validating if actor is deployer', 'VALIDATE', - ['GITHUB_TOKEN', 'username', 'team'], [], - {isTeamMember: false}, + ['GITHUB_TOKEN'], + {IS_DEPLOYER: false}, ); // eslint-disable-next-line rulesdir/no-negated-variables const FINISHRELEASECYCLE__VALIDATE__REOPEN_AND_COMMENT_ON_ISSUE_NOT_A_TEAM_MEMBER__STEP_MOCK = utils.createMockStep( @@ -48,17 +48,26 @@ const FINISHRELEASECYCLE__VALIDATE__REOPEN_AND_COMMENT_ON_ISSUE_HAS_BLOCKERS__ST ['GITHUB_TOKEN', 'ISSUE_NUMBER'], [], ); +const FINISHRELEASECYCLE__VALIDATE__ANNOUNCE_FAILED_WORKFLOW_IN_SLACK__STEP_MOCK = utils.createMockStep( + 'Announce failed workflow in Slack', + 'Announce failed workflow in Slack', + 'VALIDATE', + ['SLACK_WEBHOOK'], + [], +); const FINISHRELEASECYCLE__VALIDATE__TEAM_MEMBER_NO_BLOCKERS__STEP_MOCKS = [ FINISHRELEASECYCLE__VALIDATE__VALIDATE_ACTOR_IS_DEPLOYER_TRUE__STEP_MOCK, FINISHRELEASECYCLE__VALIDATE__REOPEN_AND_COMMENT_ON_ISSUE_NOT_A_TEAM_MEMBER__STEP_MOCK, FINISHRELEASECYCLE__VALIDATE__CHECK_FOR_ANY_DEPLOY_BLOCKERS_FALSE__STEP_MOCK, FINISHRELEASECYCLE__VALIDATE__REOPEN_AND_COMMENT_ON_ISSUE_HAS_BLOCKERS__STEP_MOCK, + FINISHRELEASECYCLE__VALIDATE__ANNOUNCE_FAILED_WORKFLOW_IN_SLACK__STEP_MOCK, ]; const FINISHRELEASECYCLE__VALIDATE__TEAM_MEMBER_BLOCKERS__STEP_MOCKS = [ FINISHRELEASECYCLE__VALIDATE__VALIDATE_ACTOR_IS_DEPLOYER_TRUE__STEP_MOCK, FINISHRELEASECYCLE__VALIDATE__REOPEN_AND_COMMENT_ON_ISSUE_NOT_A_TEAM_MEMBER__STEP_MOCK, FINISHRELEASECYCLE__VALIDATE__CHECK_FOR_ANY_DEPLOY_BLOCKERS_TRUE__STEP_MOCK, FINISHRELEASECYCLE__VALIDATE__REOPEN_AND_COMMENT_ON_ISSUE_HAS_BLOCKERS__STEP_MOCK, + FINISHRELEASECYCLE__VALIDATE__ANNOUNCE_FAILED_WORKFLOW_IN_SLACK__STEP_MOCK, ]; // eslint-disable-next-line rulesdir/no-negated-variables const FINISHRELEASECYCLE__VALIDATE__NOT_TEAM_MEMBER_NO_BLOCKERS__STEP_MOCKS = [ @@ -66,6 +75,7 @@ const FINISHRELEASECYCLE__VALIDATE__NOT_TEAM_MEMBER_NO_BLOCKERS__STEP_MOCKS = [ FINISHRELEASECYCLE__VALIDATE__REOPEN_AND_COMMENT_ON_ISSUE_NOT_A_TEAM_MEMBER__STEP_MOCK, FINISHRELEASECYCLE__VALIDATE__CHECK_FOR_ANY_DEPLOY_BLOCKERS_FALSE__STEP_MOCK, FINISHRELEASECYCLE__VALIDATE__REOPEN_AND_COMMENT_ON_ISSUE_HAS_BLOCKERS__STEP_MOCK, + FINISHRELEASECYCLE__VALIDATE__ANNOUNCE_FAILED_WORKFLOW_IN_SLACK__STEP_MOCK, ]; // eslint-disable-next-line rulesdir/no-negated-variables const FINISHRELEASECYCLE__VALIDATE__NOT_TEAM_MEMBER_BLOCKERS__STEP_MOCKS = [ @@ -73,17 +83,32 @@ const FINISHRELEASECYCLE__VALIDATE__NOT_TEAM_MEMBER_BLOCKERS__STEP_MOCKS = [ FINISHRELEASECYCLE__VALIDATE__REOPEN_AND_COMMENT_ON_ISSUE_NOT_A_TEAM_MEMBER__STEP_MOCK, FINISHRELEASECYCLE__VALIDATE__CHECK_FOR_ANY_DEPLOY_BLOCKERS_TRUE__STEP_MOCK, FINISHRELEASECYCLE__VALIDATE__REOPEN_AND_COMMENT_ON_ISSUE_HAS_BLOCKERS__STEP_MOCK, + FINISHRELEASECYCLE__VALIDATE__ANNOUNCE_FAILED_WORKFLOW_IN_SLACK__STEP_MOCK, ]; // updateproduction -const FINISHRELEASECYCLE__UPDATEPRODUCTION__UPDATE_PRODUCTION_BRANCH__STEP_MOCK = utils.createMockStep( - 'Update production branch', - 'Updating production branch', +const FINISHRELEASECYCLE__UPDATEPRODUCTION__CHECKOUT__STEP_MOCK = utils.createMockStep('Checkout', 'Checkout', 'UPDATEPRODUCTION', ['ref', 'token'], []); +const FINISHRELEASECYCLE__UPDATEPRODUCTION__SETUP_GIT_FOR_OSBOTIFY__STEP_MOCK = utils.createMockStep( + 'Setup Git for OSBotify', + 'Setup Git for OSBotify', 'UPDATEPRODUCTION', - ['TARGET_BRANCH', 'OS_BOTIFY_TOKEN', 'GPG_PASSPHRASE'], + ['GPG_PASSPHRASE'], [], ); -const FINISHRELEASECYCLE__UPDATEPRODUCTION__STEP_MOCKS = [FINISHRELEASECYCLE__UPDATEPRODUCTION__UPDATE_PRODUCTION_BRANCH__STEP_MOCK]; +const FINISHRELEASECYCLE__UPDATEPRODUCTION__UPDATE_PRODUCTION_BRANCH__STEP_MOCK = utils.createMockStep('Update production branch', 'Updating production branch', 'UPDATEPRODUCTION', [], []); +const FINISHRELEASECYCLE__UPDATEPRODUCTION__ANNOUNCE_FAILED_WORKFLOW_IN_SLACK__STEP_MOCK = utils.createMockStep( + 'Announce failed workflow in Slack', + 'Announce failed workflow in Slack', + 'UPDATEPRODUCTION', + ['SLACK_WEBHOOK'], + [], +); +const FINISHRELEASECYCLE__UPDATEPRODUCTION__STEP_MOCKS = [ + FINISHRELEASECYCLE__UPDATEPRODUCTION__CHECKOUT__STEP_MOCK, + FINISHRELEASECYCLE__UPDATEPRODUCTION__SETUP_GIT_FOR_OSBOTIFY__STEP_MOCK, + FINISHRELEASECYCLE__UPDATEPRODUCTION__UPDATE_PRODUCTION_BRANCH__STEP_MOCK, + FINISHRELEASECYCLE__UPDATEPRODUCTION__ANNOUNCE_FAILED_WORKFLOW_IN_SLACK__STEP_MOCK, +]; // createnewpatchversion const FINISHRELEASECYCLE__CREATENEWPATCHVERSION__CREATE_NEW_VERSION__STEP_MOCK = utils.createMockStep( @@ -99,14 +124,38 @@ const FINISHRELEASECYCLE__CREATENEWPATCHVERSION__CREATE_NEW_VERSION__STEP_MOCK = ); const FINISHRELEASECYCLE__CREATENEWPATCHVERSION__STEP_MOCKS = [FINISHRELEASECYCLE__CREATENEWPATCHVERSION__CREATE_NEW_VERSION__STEP_MOCK]; -// createnewstagingdeploycash -const FINISHRELEASECYCLE__CREATENEWSTAGINGDEPLOYCASH__UPDATE_STAGING_BRANCH_TO_TRIGGER_STAGING_DEPLOY__STEP_MOCK = utils.createMockStep( +// updatestaging +const FINISHRELEASECYCLE__UPDATESTAGING__CHECKOUT__STEP_MOCK = utils.createMockStep('Checkout', 'Checkout', 'UPDATESTAGING', ['ref', 'token'], []); +const FINISHRELEASECYCLE__UPDATESTAGING__SETUP_GIT_FOR_OSBOTIFY__STEP_MOCK = utils.createMockStep( + 'Setup Git for OSBotify', + 'Setup Git for OSBotify', + 'UPDATESTAGING', + ['GPG_PASSPHRASE'], + [], +); +const FINISHRELEASECYCLE__UPDATESTAGING__UPDATE_STAGING_BRANCH_TO_TRIGGER_STAGING_DEPLOY__STEP_MOCK = utils.createMockStep( 'Update staging branch to trigger staging deploy', 'Updating staging branch', - 'CREATENEWSTAGINGDEPLOYCASH', - ['TARGET_BRANCH', 'OS_BOTIFY_TOKEN', 'GPG_PASSPHRASE'], + 'UPDATESTAGING', + [], [], ); +const FINISHRELEASECYCLE__UPDATESTAGING__ANNOUNCE_FAILED_WORKFLOW_IN_SLACK__STEP_MOCK = utils.createMockStep( + 'Announce failed workflow in Slack', + 'Announce failed workflow in Slack', + 'UPDATESTAGING', + ['SLACK_WEBHOOK'], + [], +); +const FINISHRELEASECYCLE__UPDATESTAGING__STEP_MOCKS = [ + FINISHRELEASECYCLE__UPDATESTAGING__CHECKOUT__STEP_MOCK, + FINISHRELEASECYCLE__UPDATESTAGING__SETUP_GIT_FOR_OSBOTIFY__STEP_MOCK, + FINISHRELEASECYCLE__UPDATESTAGING__UPDATE_STAGING_BRANCH_TO_TRIGGER_STAGING_DEPLOY__STEP_MOCK, + FINISHRELEASECYCLE__UPDATESTAGING__ANNOUNCE_FAILED_WORKFLOW_IN_SLACK__STEP_MOCK, +]; + +// createnewstagingdeploycash +const FINISHRELEASECYCLE__CREATENEWSTAGINGDEPLOYCASH__CHECKOUT__STEP_MOCK = utils.createMockStep('Checkout', 'Checkout', 'CREATENEWSTAGINGDEPLOYCASH', ['ref', 'token'], []); const FINISHRELEASECYCLE__CREATENEWSTAGINGDEPLOYCASH__TAG_VERSION__STEP_MOCK = utils.createMockStep('Tag version', 'Tagging version', 'CREATENEWSTAGINGDEPLOYCASH', [], []); const FINISHRELEASECYCLE__CREATENEWSTAGINGDEPLOYCASH__CREATE_NEW_STAGINGDEPLOYCASH__STEP_MOCK = utils.createMockStep( 'Create new StagingDeployCash', @@ -123,7 +172,7 @@ const FINISHRELEASECYCLE__CREATENEWSTAGINGDEPLOYCASH__ANNOUNCE_FAILED_WORKFLOW_I [], ); const FINISHRELEASECYCLE__CREATENEWSTAGINGDEPLOYCASH__STEP_MOCKS = [ - FINISHRELEASECYCLE__CREATENEWSTAGINGDEPLOYCASH__UPDATE_STAGING_BRANCH_TO_TRIGGER_STAGING_DEPLOY__STEP_MOCK, + FINISHRELEASECYCLE__CREATENEWSTAGINGDEPLOYCASH__CHECKOUT__STEP_MOCK, FINISHRELEASECYCLE__CREATENEWSTAGINGDEPLOYCASH__TAG_VERSION__STEP_MOCK, FINISHRELEASECYCLE__CREATENEWSTAGINGDEPLOYCASH__CREATE_NEW_STAGINGDEPLOYCASH__STEP_MOCK, FINISHRELEASECYCLE__CREATENEWSTAGINGDEPLOYCASH__ANNOUNCE_FAILED_WORKFLOW_IN_SLACK__STEP_MOCK, @@ -136,5 +185,6 @@ module.exports = { FINISHRELEASECYCLE__VALIDATE__NOT_TEAM_MEMBER_BLOCKERS__STEP_MOCKS, FINISHRELEASECYCLE__UPDATEPRODUCTION__STEP_MOCKS, FINISHRELEASECYCLE__CREATENEWPATCHVERSION__STEP_MOCKS, + FINISHRELEASECYCLE__UPDATESTAGING__STEP_MOCKS, FINISHRELEASECYCLE__CREATENEWSTAGINGDEPLOYCASH__STEP_MOCKS, }; From 15f2fbab25a52855ef028ce3083010fa13b149ed Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Mon, 3 Jul 2023 12:05:30 +0200 Subject: [PATCH 105/504] Fix platformDeploy tests Tests were failing after recent changes in main See: https://github.com/Expensify/App/issues/13604 --- .../assertions/platformDeployAssertions.js | 18 +++++------------- workflow_tests/mocks/platformDeployMocks.js | 18 ++++++++++-------- workflow_tests/platformDeploy.test.js | 6 ++++++ 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/workflow_tests/assertions/platformDeployAssertions.js b/workflow_tests/assertions/platformDeployAssertions.js index a848178d581b..4f33066d7d89 100644 --- a/workflow_tests/assertions/platformDeployAssertions.js +++ b/workflow_tests/assertions/platformDeployAssertions.js @@ -1,13 +1,7 @@ const utils = require('../utils/utils'); const assertVerifyActorJobExecuted = (workflowResult, username, didExecute = true) => { - const steps = [ - utils.createStepAssertion('Check if user is deployer', true, null, 'VALIDATE_ACTOR', 'Checking if the user is a deployer', [ - {key: 'GITHUB_TOKEN', value: '***'}, - {key: 'username', value: username}, - {key: 'team', value: 'mobile-deployers'}, - ]), - ]; + const steps = [utils.createStepAssertion('Check if user is deployer', true, null, 'VALIDATE_ACTOR', 'Checking if the user is a deployer', [], [{key: 'GITHUB_TOKEN', value: '***'}])]; steps.forEach((expectedStep) => { if (didExecute) { @@ -211,19 +205,17 @@ const assertWebJobExecuted = (workflowResult, didExecute = true, isProduction = {key: 'AWS_SECRET_ACCESS_KEY', value: '***'}, ]), ]; - if (isProduction) { - steps.push(utils.createStepAssertion('Build web for production', true, null, 'WEB', 'Building web for production')); - } else { - steps.push(utils.createStepAssertion('Build web for staging', true, null, 'WEB', 'Building web for staging')); - } - steps.push(utils.createStepAssertion('Build docs', true, null, 'WEB', 'Building docs')); if (isProduction) { steps.push( + utils.createStepAssertion('Build web for production', true, null, 'WEB', 'Building web for production'), + utils.createStepAssertion('Build storybook docs for production', true, null, 'WEB', 'Build storybook docs for production'), utils.createStepAssertion('Deploy production to S3', true, null, 'WEB', 'Deploying production to S3'), utils.createStepAssertion('Purge production Cloudflare cache', true, null, 'WEB', 'Purging production Cloudflare cache', null, [{key: 'CF_API_KEY', value: '***'}]), ); } else { steps.push( + utils.createStepAssertion('Build web for staging', true, null, 'WEB', 'Building web for staging'), + utils.createStepAssertion('Build storybook docs for staging', true, null, 'WEB', 'Build storybook docs for staging'), utils.createStepAssertion('Deploy staging to S3', true, null, 'WEB', 'Deploying staging to S3'), utils.createStepAssertion('Purge staging Cloudflare cache', true, null, 'WEB', 'Purging staging Cloudflare cache', null, [{key: 'CF_API_KEY', value: '***'}]), ); diff --git a/workflow_tests/mocks/platformDeployMocks.js b/workflow_tests/mocks/platformDeployMocks.js index 5811eba35681..2e9996b053d2 100644 --- a/workflow_tests/mocks/platformDeployMocks.js +++ b/workflow_tests/mocks/platformDeployMocks.js @@ -5,17 +5,17 @@ const PLATFORM_DEPLOY__VALIDATE_ACTOR__CHECK_USER_DEPLOYER__TEAM_MEMBER__STEP_MO 'Check if user is deployer', 'Checking if the user is a deployer', 'VALIDATE_ACTOR', - ['GITHUB_TOKEN', 'username', 'team'], - null, - {isTeamMember: true}, + [], + ['GITHUB_TOKEN'], + {IS_DEPLOYER: true}, ); const PLATFORM_DEPLOY__VALIDATE_ACTOR__CHECK_USER_DEPLOYER__OUTSIDER__STEP_MOCK = utils.createMockStep( 'Check if user is deployer', 'Checking if the user is a deployer', 'VALIDATE_ACTOR', - ['GITHUB_TOKEN', 'username', 'team'], - null, - {isTeamMember: false}, + [], + ['GITHUB_TOKEN'], + {IS_DEPLOYER: false}, ); const PLATFORM_DEPLOY__VALIDATE_ACTOR__TEAM_MEMBER__STEP_MOCKS = [PLATFORM_DEPLOY__VALIDATE_ACTOR__CHECK_USER_DEPLOYER__TEAM_MEMBER__STEP_MOCK]; const PLATFORM_DEPLOY__VALIDATE_ACTOR__OUTSIDER__STEP_MOCKS = [PLATFORM_DEPLOY__VALIDATE_ACTOR__CHECK_USER_DEPLOYER__OUTSIDER__STEP_MOCK]; @@ -144,7 +144,8 @@ const PLATFORM_DEPLOY__WEB__AWS_CREDENTIALS__STEP_MOCK = utils.createMockStep('C ]); const PLATFORM_DEPLOY__WEB__BUILD_PRODUCTION__STEP_MOCK = utils.createMockStep('Build web for production', 'Building web for production', 'WEB'); const PLATFORM_DEPLOY__WEB__BUILD_STAGING__STEP_MOCK = utils.createMockStep('Build web for staging', 'Building web for staging', 'WEB'); -const PLATFORM_DEPLOY__WEB__BUILD_DOCS__STEP_MOCK = utils.createMockStep('Build docs', 'Building docs', 'WEB'); +const PLATFORM_DEPLOY__WEB__BUILD_STORYBOOK_DOCS_FOR_PRODUCTION__STEP_MOCK = utils.createMockStep('Build storybook docs for production', 'Build storybook docs for production', 'WEB'); +const PLATFORM_DEPLOY__WEB__BUILD_STORYBOOK_DOCS_FOR_STAGING__STEP_MOCK = utils.createMockStep('Build storybook docs for staging', 'Build storybook docs for staging', 'WEB'); const PLATFORM_DEPLOY__WEB__DEPLOY_PRODUCTION_S3__STEP_MOCK = utils.createMockStep('Deploy production to S3', 'Deploying production to S3', 'WEB'); const PLATFORM_DEPLOY__WEB__DEPLOY_STAGING_S3__STEP_MOCK = utils.createMockStep('Deploy staging to S3', 'Deploying staging to S3', 'WEB'); const PLATFORM_DEPLOY__WEB__PURGE_PRODUCTION_CACHE__STEP_MOCK = utils.createMockStep('Purge production Cloudflare cache', 'Purging production Cloudflare cache', 'WEB', null, ['CF_API_KEY']); @@ -156,7 +157,8 @@ const PLATFORM_DEPLOY__WEB__STEP_MOCKS = [ PLATFORM_DEPLOY__WEB__AWS_CREDENTIALS__STEP_MOCK, PLATFORM_DEPLOY__WEB__BUILD_PRODUCTION__STEP_MOCK, PLATFORM_DEPLOY__WEB__BUILD_STAGING__STEP_MOCK, - PLATFORM_DEPLOY__WEB__BUILD_DOCS__STEP_MOCK, + PLATFORM_DEPLOY__WEB__BUILD_STORYBOOK_DOCS_FOR_PRODUCTION__STEP_MOCK, + PLATFORM_DEPLOY__WEB__BUILD_STORYBOOK_DOCS_FOR_STAGING__STEP_MOCK, PLATFORM_DEPLOY__WEB__DEPLOY_PRODUCTION_S3__STEP_MOCK, PLATFORM_DEPLOY__WEB__DEPLOY_STAGING_S3__STEP_MOCK, PLATFORM_DEPLOY__WEB__PURGE_PRODUCTION_CACHE__STEP_MOCK, diff --git a/workflow_tests/platformDeploy.test.js b/workflow_tests/platformDeploy.test.js index 6bbca9653a95..72e533eb1cce 100644 --- a/workflow_tests/platformDeploy.test.js +++ b/workflow_tests/platformDeploy.test.js @@ -83,6 +83,8 @@ describe('test workflow platformDeploy', () => { { desktop: 'ubuntu-latest', iOS: 'ubuntu-latest', + android: 'ubuntu-latest', + web: 'ubuntu-latest', }, workflowPath, ); @@ -155,6 +157,8 @@ describe('test workflow platformDeploy', () => { { desktop: 'ubuntu-latest', iOS: 'ubuntu-latest', + android: 'ubuntu-latest', + web: 'ubuntu-latest', }, workflowPath, ); @@ -227,6 +231,8 @@ describe('test workflow platformDeploy', () => { { desktop: 'ubuntu-latest', iOS: 'ubuntu-latest', + android: 'ubuntu-latest', + web: 'ubuntu-latest', }, workflowPath, ); From 7de1fbab31d3a63f68b53de784f82a00df0d39c1 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Mon, 3 Jul 2023 14:07:43 +0200 Subject: [PATCH 106/504] Fix preDeploy tests Tests were failing after recent changes in main See: https://github.com/Expensify/App/issues/13604 --- .github/workflows/preDeploy.yml | 13 +- .../assertions/preDeployAssertions.js | 72 +- workflow_tests/mocks/preDeployMocks.js | 76 +- workflow_tests/preDeploy.test.js | 776 +++++++----------- 4 files changed, 350 insertions(+), 587 deletions(-) diff --git a/.github/workflows/preDeploy.yml b/.github/workflows/preDeploy.yml index 1fc672925698..d294324964d0 100644 --- a/.github/workflows/preDeploy.yml +++ b/.github/workflows/preDeploy.yml @@ -7,16 +7,10 @@ on: jobs: lint: - runs-on: ubuntu-latest - steps: - - name: Run lint workflow - uses: Expensify/App/.github/workflows/lint.yml@main + uses: Expensify/App/.github/workflows/lint.yml@main test: - runs-on: ubuntu-latest - steps: - - name: Run test workflow - uses: Expensify/App/.github/workflows/test.yml@main + uses: Expensify/App/.github/workflows/test.yml@main confirmPassingBuild: runs-on: ubuntu-latest @@ -95,7 +89,8 @@ jobs: fetch-depth: 0 token: ${{ secrets.OS_BOTIFY_TOKEN }} - - uses: Expensify/App/.github/actions/composite/setupGitForOSBotify@main + - name: Setup Git for OSBotify + uses: Expensify/App/.github/actions/composite/setupGitForOSBotify@main with: GPG_PASSPHRASE: ${{ secrets.LARGE_SECRET_PASSPHRASE }} diff --git a/workflow_tests/assertions/preDeployAssertions.js b/workflow_tests/assertions/preDeployAssertions.js index 34169bf157e1..edf2bbe51389 100644 --- a/workflow_tests/assertions/preDeployAssertions.js +++ b/workflow_tests/assertions/preDeployAssertions.js @@ -27,11 +27,15 @@ const assertTestJobExecuted = (workflowResult, didExecute = true) => { const assertIsExpensifyEmployeeJobExecuted = (workflowResult, didExecute = true) => { const steps = [ utils.createStepAssertion('Get merged pull request', true, null, 'IS_EXPENSIFY_EMPLOYEE', 'Getting merged pull request', [{key: 'github_token', value: '***'}]), - utils.createStepAssertion('Check whether the actor is member of Expensify/expensify team', true, null, 'IS_EXPENSIFY_EMPLOYEE', 'Checking actors Expensify membership', [ - {key: 'GITHUB_TOKEN', value: '***'}, - {key: 'username', value: 'Dummy Author'}, - {key: 'team', value: 'Expensify/expensify'}, - ]), + utils.createStepAssertion( + 'Check whether the PR author is member of Expensify/expensify team', + true, + null, + 'IS_EXPENSIFY_EMPLOYEE', + 'Checking actors Expensify membership', + [], + [{key: 'GITHUB_TOKEN', value: '***'}], + ), ]; steps.forEach((expectedStep) => { @@ -109,8 +113,6 @@ const assertChooseDeployActionsJobExecuted = (workflowResult, didExecute = true) const steps = [ utils.createStepAssertion('Get merged pull request', true, null, 'CHOOSE_DEPLOY_ACTIONS', 'Getting merged pull request', [{key: 'github_token', value: '***'}]), utils.createStepAssertion('Check if StagingDeployCash is locked', true, null, 'CHOOSE_DEPLOY_ACTIONS', 'Checking StagingDeployCash', [{key: 'GITHUB_TOKEN', value: '***'}]), - utils.createStepAssertion('Check if merged pull request was an automated PR', true, ''), - utils.createStepAssertion('Check if merged pull request has `CP Staging` label', true, ''), utils.createStepAssertion('Check if merged pull request should trigger a deploy', true, ''), ]; @@ -154,68 +156,26 @@ const assertCreateNewVersionJobExecuted = (workflowResult, didExecute = true) => }); }; -const assertUpdateStagingJobExecuted = (workflowResult, didExecute = true, shouldCp = false) => { +const assertUpdateStagingJobExecuted = (workflowResult, didExecute = true) => { const steps = [ utils.createStepAssertion('Run turnstyle', true, null, 'UPDATE_STAGING', 'Running turnstyle', [ {key: 'poll-interval-seconds', value: '10'}, {key: 'GITHUB_TOKEN', value: '***'}, ]), - ]; - if (shouldCp) { - steps.push( - utils.createStepAssertion('Cherry-pick PR to staging', true, null, 'UPDATE_STAGING', 'Cherry picking', [ - {key: 'GITHUB_TOKEN', value: '***'}, - {key: 'WORKFLOW', value: 'cherryPick.yml'}, - {key: 'INPUTS', value: '{ PULL_REQUEST_NUMBER: 123, NEW_VERSION: 1.2.3 }'}, - ]), - ); - } else { - steps.push( - utils.createStepAssertion('Update staging branch from main', true, null, 'UPDATE_STAGING', 'Updating staging branch', [ - {key: 'TARGET_BRANCH', value: 'staging'}, - {key: 'OS_BOTIFY_TOKEN', value: '***'}, - {key: 'GPG_PASSPHRASE', value: '***'}, - ]), - ); - } - steps.push( - utils.createStepAssertion('Checkout staging', true, null, 'UPDATE_STAGING', 'Checking out staging', [ - {key: 'ref', value: 'staging'}, + utils.createStepAssertion('Checkout main', true, null, 'UPDATE_STAGING', 'Checkout main', [ + {key: 'ref', value: 'main'}, {key: 'fetch-depth', value: '0'}, + {key: 'token', value: '***'}, ]), + utils.createStepAssertion('Setup Git for OSBotify', true, null, 'UPDATE_STAGING', 'Setup Git for OSBotify', [{key: 'GPG_PASSPHRASE', value: '***'}]), + utils.createStepAssertion('Update staging branch from main', true, null, 'UPDATE_STAGING', 'Update staging branch from main'), utils.createStepAssertion('Tag staging', true, null, 'UPDATE_STAGING', 'Tagging staging'), utils.createStepAssertion('Update StagingDeployCash', true, null, 'UPDATE_STAGING', 'Updating StagingDeployCash', [ {key: 'GITHUB_TOKEN', value: '***'}, {key: 'NPM_VERSION', value: '1.2.3'}, ]), utils.createStepAssertion('Find open StagingDeployCash', true, null, 'UPDATE_STAGING', 'Finding open StagingDeployCash', null, [{key: 'GITHUB_TOKEN', value: '***'}]), - ); - if (shouldCp) { - steps.push( - utils.createStepAssertion( - 'Comment in StagingDeployCash to alert Applause that a new pull request has been cherry-picked', - true, - null, - 'UPDATE_STAGING', - 'Commenting in StagingDeployCash', - null, - [{key: 'GITHUB_TOKEN', value: '***'}], - ), - utils.createStepAssertion('Wait for staging deploys to finish', true, null, 'UPDATE_STAGING', 'Waiting for staging deploy to finish', [ - {key: 'GITHUB_TOKEN', value: '***'}, - {key: 'TAG', value: '1.2.3'}, - ]), - utils.createStepAssertion( - 'Comment in StagingDeployCash to alert Applause that cherry-picked pull request has been deployed.', - true, - null, - 'UPDATE_STAGING', - 'Commenting in StagingDeployCash', - null, - [{key: 'GITHUB_TOKEN', value: '***'}], - ), - ); - } + ]; steps.forEach((expectedStep) => { if (didExecute) { diff --git a/workflow_tests/mocks/preDeployMocks.js b/workflow_tests/mocks/preDeployMocks.js index d76cad3af8ed..bef658a55d15 100644 --- a/workflow_tests/mocks/preDeployMocks.js +++ b/workflow_tests/mocks/preDeployMocks.js @@ -17,14 +17,6 @@ const CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS = [ ]; // choose_deploy_actions -const GET_MERGED_PULL_REQUEST_MOCK_STEP__CHOOSE_DEPLOY__CP_LABEL = utils.createMockStep( - 'Get merged pull request', - 'Getting merged pull request', - 'CHOOSE_DEPLOY_ACTIONS', - ['github_token'], - null, - {number: '123', labels: "['CP Staging']"}, -); const GET_MERGED_PULL_REQUEST_MOCK_STEP__CHOOSE_DEPLOY = utils.createMockStep('Get merged pull request', 'Getting merged pull request', 'CHOOSE_DEPLOY_ACTIONS', ['github_token'], null, { number: '123', labels: '[]', @@ -49,25 +41,13 @@ const CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__STAGING_LOCKED = [ GET_MERGED_PULL_REQUEST_MOCK_STEP__CHOOSE_DEPLOY, CHECK_IF_STAGINGDEPLOYCASH_IS_LOCKED_MOCK_STEP__LOCKED, - // steps 3-5 run normally -]; -const CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__CP_LABEL__STAGING_LOCKED = [ - GET_MERGED_PULL_REQUEST_MOCK_STEP__CHOOSE_DEPLOY__CP_LABEL, - CHECK_IF_STAGINGDEPLOYCASH_IS_LOCKED_MOCK_STEP__LOCKED, - - // steps 3-5 run normally + // step 3 runs normally ]; const CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__STAGING_UNLOCKED = [ GET_MERGED_PULL_REQUEST_MOCK_STEP__CHOOSE_DEPLOY, CHECK_IF_STAGINGDEPLOYCASH_IS_LOCKED_MOCK_STEP__UNLOCKED, - // steps 3-5 run normally -]; -const CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__CP_LABEL__STAGING_UNLOCKED = [ - GET_MERGED_PULL_REQUEST_MOCK_STEP__CHOOSE_DEPLOY__CP_LABEL, - CHECK_IF_STAGINGDEPLOYCASH_IS_LOCKED_MOCK_STEP__UNLOCKED, - - // steps 3-5 run normally + // step 3 runs normally ]; // skip_deploy @@ -90,45 +70,23 @@ const CREATE_NEW_VERSION_JOB_MOCK_STEPS = [CREATE_NEW_VERSION_MOCK_STEP]; // update_staging const RUN_TURNSTYLE_MOCK_STEP = utils.createMockStep('Run turnstyle', 'Running turnstyle', 'UPDATE_STAGING', ['poll-interval-seconds'], ['GITHUB_TOKEN']); -const UPDATE_STAGING_BRANCH_MOCK_STEP = utils.createMockStep('Update staging branch from main', 'Updating staging branch', 'UPDATE_STAGING', [ - 'TARGET_BRANCH', - 'OS_BOTIFY_TOKEN', - 'GPG_PASSPHRASE', -]); -const CHERRYPICK_PR_MOCK_STEP = utils.createMockStep('Cherry-pick PR to staging', 'Cherry picking', 'UPDATE_STAGING', ['GITHUB_TOKEN', 'WORKFLOW', 'INPUTS']); -const CHECKOUT_STAGING_MOCK_STEP = utils.createMockStep('Checkout staging', 'Checking out staging', 'UPDATE_STAGING', ['ref', 'fetch-depth']); +const CHECKOUT_MAIN_MOCK_STEP = utils.createMockStep('Checkout main', 'Checkout main', 'UPDATE_STAGING', ['ref', 'fetch-depth', 'token']); +const SETUP_GIT_FOR_OSBOTIFY_MOCK_STEP = utils.createMockStep('Setup Git for OSBotify', 'Setup Git for OSBotify', 'UPDATE_STAGING', ['GPG_PASSPHRASE']); +const UPDATE_STAGING_BRANCH_FROM_MAIN_MOCK_STEP = utils.createMockStep('Update staging branch from main', 'Update staging branch from main', 'UPDATE_STAGING'); const TAG_STAGING_MOCK_STEP = utils.createMockStep('Tag staging', 'Tagging staging', 'UPDATE_STAGING'); const UPDATE_STAGINGDEPLOYCASH_MOCK_STEP = utils.createMockStep('Update StagingDeployCash', 'Updating StagingDeployCash', 'UPDATE_STAGING', ['GITHUB_TOKEN', 'NPM_VERSION']); const FIND_OPEN_STAGINGDEPLOYCASH_MOCK_STEP = utils.createMockStep('Find open StagingDeployCash', 'Finding open StagingDeployCash', 'UPDATE_STAGING', null, ['GITHUB_TOKEN'], { STAGING_DEPLOY_CASH: '1234', }); -const COMMENT_TO_ALERT_APPLAUSE_CHERRYPICK_MOCK_STEP = utils.createMockStep( - 'Comment in StagingDeployCash to alert Applause that a new pull request has been cherry-picked', - 'Commenting in StagingDeployCash', - 'UPDATE_STAGING', - null, - ['GITHUB_TOKEN'], -); -const WAIT_FOR_STAGING_DEPLOYS_MOCK_STEP = utils.createMockStep('Wait for staging deploys to finish', 'Waiting for staging deploy to finish', 'UPDATE_STAGING', ['GITHUB_TOKEN', 'TAG']); -const COMMENT_TO_ALERT_APPLAUSE_DEPLOY_MOCK_STEP = utils.createMockStep( - 'Comment in StagingDeployCash to alert Applause that cherry-picked pull request has been deployed.', - 'Commenting in StagingDeployCash', - 'UPDATE_STAGING', - null, - ['GITHUB_TOKEN'], -); const ANNOUNCE_FAILED_WORKFLOW_IN_SLACK_MOCK_STEP = utils.createMockStep('Announce failed workflow in Slack', 'Announcing failed workflow in Slack', 'UPDATE_STAGING', ['SLACK_WEBHOOK']); const UPDATE_STAGING_JOB_MOCK_STEPS = [ RUN_TURNSTYLE_MOCK_STEP, - UPDATE_STAGING_BRANCH_MOCK_STEP, - CHERRYPICK_PR_MOCK_STEP, - CHECKOUT_STAGING_MOCK_STEP, + CHECKOUT_MAIN_MOCK_STEP, + SETUP_GIT_FOR_OSBOTIFY_MOCK_STEP, + UPDATE_STAGING_BRANCH_FROM_MAIN_MOCK_STEP, TAG_STAGING_MOCK_STEP, UPDATE_STAGINGDEPLOYCASH_MOCK_STEP, FIND_OPEN_STAGINGDEPLOYCASH_MOCK_STEP, - COMMENT_TO_ALERT_APPLAUSE_CHERRYPICK_MOCK_STEP, - WAIT_FOR_STAGING_DEPLOYS_MOCK_STEP, - COMMENT_TO_ALERT_APPLAUSE_DEPLOY_MOCK_STEP, ANNOUNCE_FAILED_WORKFLOW_IN_SLACK_MOCK_STEP, ]; @@ -142,21 +100,21 @@ const GET_MERGED_PULL_REQUEST_MOCK_STEP__IS_EXPENSIFY_EMPLOYEE = utils.createMoc {author: 'Dummy Author'}, ); const CHECK_TEAM_MEMBERSHIP_MOCK_STEP__TRUE = utils.createMockStep( - 'Check whether the actor is member of Expensify/expensify team', + 'Check whether the PR author is member of Expensify/expensify team', 'Checking actors Expensify membership', 'IS_EXPENSIFY_EMPLOYEE', - ['GITHUB_TOKEN', 'username', 'team'], - null, - {isTeamMember: true}, + [], + ['GITHUB_TOKEN'], + {IS_EXPENSIFY_EMPLOYEE: true}, ); const IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE = [GET_MERGED_PULL_REQUEST_MOCK_STEP__IS_EXPENSIFY_EMPLOYEE, CHECK_TEAM_MEMBERSHIP_MOCK_STEP__TRUE]; const CHECK_TEAM_MEMBERSHIP_MOCK_STEP__FALSE = utils.createMockStep( - 'Check whether the actor is member of Expensify/expensify team', + 'Check whether the PR author is member of Expensify/expensify team', 'Checking actors Expensify membership', 'IS_EXPENSIFY_EMPLOYEE', - ['GITHUB_TOKEN', 'username', 'team'], - null, - {isTeamMember: false}, + [], + ['GITHUB_TOKEN'], + {IS_EXPENSIFY_EMPLOYEE: false}, ); const IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__FALSE = [GET_MERGED_PULL_REQUEST_MOCK_STEP__IS_EXPENSIFY_EMPLOYEE, CHECK_TEAM_MEMBERSHIP_MOCK_STEP__FALSE]; @@ -233,9 +191,7 @@ module.exports = { TEST_JOB_MOCK_STEPS, CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__STAGING_LOCKED, - CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__CP_LABEL__STAGING_LOCKED, CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__STAGING_UNLOCKED, - CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__CP_LABEL__STAGING_UNLOCKED, SKIP_DEPLOY_JOB_MOCK_STEPS, CREATE_NEW_VERSION_JOB_MOCK_STEPS, UPDATE_STAGING_JOB_MOCK_STEPS, diff --git a/workflow_tests/preDeploy.test.js b/workflow_tests/preDeploy.test.js index 61964d8ede09..41c12d20ba28 100644 --- a/workflow_tests/preDeploy.test.js +++ b/workflow_tests/preDeploy.test.js @@ -64,16 +64,22 @@ describe('test workflow preDeploy', () => { // set up mocks const testMockSteps = { - lint: mocks.LINT_JOB_MOCK_STEPS, - test: mocks.TEST_JOB_MOCK_STEPS, confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, - chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__CP_LABEL__STAGING_UNLOCKED, + chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__STAGING_UNLOCKED, skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, }; const testMockJobs = { + lint: { + steps: mocks.LINT_JOB_MOCK_STEPS, + runsOn: 'ubuntu-latest', + }, + test: { + steps: mocks.TEST_JOB_MOCK_STEPS, + runsOn: 'ubuntu-latest', + }, createNewVersion: { steps: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, outputs: { @@ -84,7 +90,7 @@ describe('test workflow preDeploy', () => { }, e2ePerformanceTests: { steps: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, - runsOn: 'ubuntu-20.04-64core', + runsOn: 'ubuntu-latest', }, }; @@ -113,16 +119,22 @@ describe('test workflow preDeploy', () => { const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); const testMockSteps = { - lint: mocks.LINT_JOB_MOCK_STEPS, - test: mocks.TEST_JOB_MOCK_STEPS, confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, - chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__CP_LABEL__STAGING_UNLOCKED, + chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__STAGING_UNLOCKED, skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, }; const testMockJobs = { + lint: { + steps: mocks.LINT_JOB_MOCK_STEPS, + runsOn: 'ubuntu-latest', + }, + test: { + steps: mocks.TEST_JOB_MOCK_STEPS, + runsOn: 'ubuntu-latest', + }, createNewVersion: { steps: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, outputs: { @@ -133,7 +145,7 @@ describe('test workflow preDeploy', () => { }, e2ePerformanceTests: { steps: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, - runsOn: 'ubuntu-20.04-64core', + runsOn: 'ubuntu-latest', }, }; @@ -209,16 +221,22 @@ describe('test workflow preDeploy', () => { 'dummy_github_token', ); const testMockSteps = { - lint: [utils.createMockStep('Run lint workflow', 'Running lint workflow - Lint workflow failed', 'LINT', null, null, null, null, false)], - test: mocks.TEST_JOB_MOCK_STEPS, confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, - chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__CP_LABEL__STAGING_UNLOCKED, + chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__STAGING_UNLOCKED, skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, }; const testMockJobs = { + lint: { + steps: [utils.createMockStep('Run lint workflow', 'Running lint workflow - Lint workflow failed', 'LINT', null, null, null, null, false)], + runsOn: 'ubuntu-latest', + }, + test: { + steps: mocks.TEST_JOB_MOCK_STEPS, + runsOn: 'ubuntu-latest', + }, createNewVersion: { steps: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, outputs: { @@ -229,7 +247,7 @@ describe('test workflow preDeploy', () => { }, e2ePerformanceTests: { steps: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, - runsOn: 'ubuntu-20.04-64core', + runsOn: 'ubuntu-latest', }, }; const result = await act.runEvent('push', { @@ -272,16 +290,22 @@ describe('test workflow preDeploy', () => { 'dummy_github_token', ); const testMockSteps = { - lint: mocks.LINT_JOB_MOCK_STEPS, - test: [utils.createMockStep('Run test workflow', 'Running test workflow - Test workflow failed', 'TEST', null, null, null, null, false)], confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, - chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__CP_LABEL__STAGING_UNLOCKED, + chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__STAGING_UNLOCKED, skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, }; const testMockJobs = { + lint: { + steps: mocks.LINT_JOB_MOCK_STEPS, + runsOn: 'ubuntu-latest', + }, + test: { + steps: [utils.createMockStep('Run test workflow', 'Running test workflow - Test workflow failed', 'TEST', null, null, null, null, false)], + runsOn: 'ubuntu-latest', + }, createNewVersion: { steps: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, outputs: { @@ -292,7 +316,7 @@ describe('test workflow preDeploy', () => { }, e2ePerformanceTests: { steps: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, - runsOn: 'ubuntu-20.04-64core', + runsOn: 'ubuntu-latest', }, }; const result = await act.runEvent('push', { @@ -335,16 +359,22 @@ describe('test workflow preDeploy', () => { 'dummy_github_token', ); const testMockSteps = { - lint: mocks.LINT_JOB_MOCK_STEPS, - test: mocks.TEST_JOB_MOCK_STEPS, confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, - chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__CP_LABEL__STAGING_UNLOCKED, + chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__STAGING_UNLOCKED, skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, }; const testMockJobs = { + lint: { + steps: mocks.LINT_JOB_MOCK_STEPS, + runsOn: 'ubuntu-latest', + }, + test: { + steps: mocks.TEST_JOB_MOCK_STEPS, + runsOn: 'ubuntu-latest', + }, createNewVersion: { steps: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, outputs: { @@ -355,7 +385,7 @@ describe('test workflow preDeploy', () => { }, e2ePerformanceTests: { steps: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, - runsOn: 'ubuntu-20.04-64core', + runsOn: 'ubuntu-latest', }, }; const result = await act.runEvent('push', { @@ -392,16 +422,22 @@ describe('test workflow preDeploy', () => { 'dummy_github_token', ); const testMockSteps = { - lint: mocks.LINT_JOB_MOCK_STEPS, - test: mocks.TEST_JOB_MOCK_STEPS, confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, - chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__CP_LABEL__STAGING_UNLOCKED, + chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__STAGING_UNLOCKED, skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__FALSE, newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__OSBOTIFY, }; const testMockJobs = { + lint: { + steps: mocks.LINT_JOB_MOCK_STEPS, + runsOn: 'ubuntu-latest', + }, + test: { + steps: mocks.TEST_JOB_MOCK_STEPS, + runsOn: 'ubuntu-latest', + }, createNewVersion: { steps: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, outputs: { @@ -412,7 +448,7 @@ describe('test workflow preDeploy', () => { }, e2ePerformanceTests: { steps: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, - runsOn: 'ubuntu-20.04-64core', + runsOn: 'ubuntu-latest', }, }; const result = await act.runEvent('push', { @@ -445,16 +481,22 @@ describe('test workflow preDeploy', () => { 'dummy_github_token', ); const testMockSteps = { - lint: mocks.LINT_JOB_MOCK_STEPS, - test: mocks.TEST_JOB_MOCK_STEPS, confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, - chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__CP_LABEL__STAGING_UNLOCKED, + chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__STAGING_UNLOCKED, skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, }; const testMockJobs = { + lint: { + steps: mocks.LINT_JOB_MOCK_STEPS, + runsOn: 'ubuntu-latest', + }, + test: { + steps: mocks.TEST_JOB_MOCK_STEPS, + runsOn: 'ubuntu-latest', + }, createNewVersion: { steps: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, outputs: { @@ -465,7 +507,7 @@ describe('test workflow preDeploy', () => { }, e2ePerformanceTests: { steps: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, - runsOn: 'ubuntu-20.04-64core', + runsOn: 'ubuntu-latest', }, }; const result = await act.runEvent('push', { @@ -498,16 +540,22 @@ describe('test workflow preDeploy', () => { 'dummy_github_token', ); const testMockSteps = { - lint: mocks.LINT_JOB_MOCK_STEPS, - test: mocks.TEST_JOB_MOCK_STEPS, confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, - chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__CP_LABEL__STAGING_UNLOCKED, + chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__STAGING_UNLOCKED, skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__FALSE, newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, }; const testMockJobs = { + lint: { + steps: mocks.LINT_JOB_MOCK_STEPS, + runsOn: 'ubuntu-latest', + }, + test: { + steps: mocks.TEST_JOB_MOCK_STEPS, + runsOn: 'ubuntu-latest', + }, createNewVersion: { steps: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, outputs: { @@ -518,7 +566,7 @@ describe('test workflow preDeploy', () => { }, e2ePerformanceTests: { steps: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, - runsOn: 'ubuntu-20.04-64core', + runsOn: 'ubuntu-latest', }, }; const result = await act.runEvent('push', { @@ -551,16 +599,22 @@ describe('test workflow preDeploy', () => { 'dummy_github_token', ); const testMockSteps = { - lint: mocks.LINT_JOB_MOCK_STEPS, - test: mocks.TEST_JOB_MOCK_STEPS, confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, - chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__CP_LABEL__STAGING_UNLOCKED, + chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__STAGING_UNLOCKED, skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__FALSE, newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__ONE_PR, }; const testMockJobs = { + lint: { + steps: mocks.LINT_JOB_MOCK_STEPS, + runsOn: 'ubuntu-latest', + }, + test: { + steps: mocks.TEST_JOB_MOCK_STEPS, + runsOn: 'ubuntu-latest', + }, createNewVersion: { steps: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, outputs: { @@ -571,7 +625,7 @@ describe('test workflow preDeploy', () => { }, e2ePerformanceTests: { steps: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, - runsOn: 'ubuntu-20.04-64core', + runsOn: 'ubuntu-latest', }, }; const result = await act.runEvent('push', { @@ -590,442 +644,234 @@ describe('test workflow preDeploy', () => { }); describe('choose deploy actions', () => { - describe('no CP label', () => { - describe('staging locked', () => { - it('not automated PR - deploy skipped and comment left', async () => { - const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; - const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); - let act = new eAct.ExtendedAct(repoPath, workflowPath); - act = utils.setUpActParams(act, 'push', {ref: 'refs/heads/main'}, {OS_BOTIFY_TOKEN: 'dummy_token', SLACK_WEBHOOK: 'dummy_slack_webhook'}, 'dummy_github_token'); - const testMockSteps = { - lint: mocks.LINT_JOB_MOCK_STEPS, - test: mocks.TEST_JOB_MOCK_STEPS, - confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, - chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__STAGING_LOCKED, - skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, - updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, - isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, - newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, - }; - const testMockJobs = { - createNewVersion: { - steps: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, - outputs: { - // eslint-disable-next-line no-template-curly-in-string - NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', - }, - runsOn: 'ubuntu-latest', - }, - e2ePerformanceTests: { - steps: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, - runsOn: 'ubuntu-20.04-64core', - }, - }; - const result = await act.runEvent('push', { - workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), - mockSteps: testMockSteps, - actor: 'Dummy Tester', - logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), - mockJobs: testMockJobs, - }); - assertions.assertLintJobExecuted(result); - assertions.assertTestJobExecuted(result); - assertions.assertIsExpensifyEmployeeJobExecuted(result); - assertions.assertChooseDeployActionsJobExecuted(result); - assertions.assertSkipDeployJobExecuted(result); - assertions.assertCreateNewVersionJobExecuted(result, false); - assertions.assertUpdateStagingJobExecuted(result, false, false); - assertions.assertUpdateStagingJobFailed(result, false); - }); - - it('automated PR - deploy skipped, but no comment left', async () => { - const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; - const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); - let act = new eAct.ExtendedAct(repoPath, workflowPath); - act = utils.setUpActParams(act, 'push', {ref: 'refs/heads/main'}, {OS_BOTIFY_TOKEN: 'dummy_token', SLACK_WEBHOOK: 'dummy_slack_webhook'}, 'dummy_github_token'); - const testMockSteps = { - lint: mocks.LINT_JOB_MOCK_STEPS, - test: mocks.TEST_JOB_MOCK_STEPS, - confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, - chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__STAGING_LOCKED, - skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, - updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, - isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, - newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__OSBOTIFY, - }; - const testMockJobs = { - createNewVersion: { - steps: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, - outputs: { - // eslint-disable-next-line no-template-curly-in-string - NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', - }, - runsOn: 'ubuntu-latest', - }, - e2ePerformanceTests: { - steps: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, - runsOn: 'ubuntu-20.04-64core', + describe('staging locked', () => { + it('not automated PR - deploy skipped and comment left', async () => { + const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + act = utils.setUpActParams(act, 'push', {ref: 'refs/heads/main'}, {OS_BOTIFY_TOKEN: 'dummy_token', SLACK_WEBHOOK: 'dummy_slack_webhook'}, 'dummy_github_token'); + const testMockSteps = { + confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, + chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__STAGING_LOCKED, + skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, + updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, + isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, + newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, + }; + const testMockJobs = { + lint: { + steps: mocks.LINT_JOB_MOCK_STEPS, + runsOn: 'ubuntu-latest', + }, + test: { + steps: mocks.TEST_JOB_MOCK_STEPS, + runsOn: 'ubuntu-latest', + }, + createNewVersion: { + steps: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, + outputs: { + // eslint-disable-next-line no-template-curly-in-string + NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', }, - }; - const result = await act.runEvent('push', { - workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), - mockSteps: testMockSteps, - actor: 'OSBotify', - logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), - mockJobs: testMockJobs, - }); - assertions.assertLintJobExecuted(result); - assertions.assertTestJobExecuted(result); - assertions.assertIsExpensifyEmployeeJobExecuted(result); - assertions.assertChooseDeployActionsJobExecuted(result); - assertions.assertSkipDeployJobExecuted(result, false); - assertions.assertCreateNewVersionJobExecuted(result, false); - assertions.assertUpdateStagingJobExecuted(result, false, false); - assertions.assertUpdateStagingJobFailed(result, false); + runsOn: 'ubuntu-latest', + }, + e2ePerformanceTests: { + steps: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, + runsOn: 'ubuntu-latest', + }, + }; + const result = await act.runEvent('push', { + workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), + mockSteps: testMockSteps, + actor: 'Dummy Tester', + logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), + mockJobs: testMockJobs, }); + assertions.assertLintJobExecuted(result); + assertions.assertTestJobExecuted(result); + assertions.assertIsExpensifyEmployeeJobExecuted(result); + assertions.assertChooseDeployActionsJobExecuted(result); + assertions.assertSkipDeployJobExecuted(result); + assertions.assertCreateNewVersionJobExecuted(result, false); + assertions.assertUpdateStagingJobExecuted(result, false); + assertions.assertUpdateStagingJobFailed(result, false); }); - describe('staging not locked', () => { - it('not automated PR - proceed with deploy', async () => { - const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; - const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); - let act = new eAct.ExtendedAct(repoPath, workflowPath); - act = utils.setUpActParams( - act, - 'push', - {ref: 'refs/heads/main'}, - { - OS_BOTIFY_TOKEN: 'dummy_token', - SLACK_WEBHOOK: 'dummy_slack_webhook', - LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', - }, - 'dummy_github_token', - ); - const testMockSteps = { - lint: mocks.LINT_JOB_MOCK_STEPS, - test: mocks.TEST_JOB_MOCK_STEPS, - confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, - chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__STAGING_UNLOCKED, - skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, - updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, - isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, - newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, - }; - const testMockJobs = { - createNewVersion: { - steps: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, - outputs: { - // eslint-disable-next-line no-template-curly-in-string - NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', - }, - runsOn: 'ubuntu-latest', - }, - e2ePerformanceTests: { - steps: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, - runsOn: 'ubuntu-20.04-64core', - }, - }; - const result = await act.runEvent('push', { - workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), - mockSteps: testMockSteps, - actor: 'Dummy Tester', - logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), - mockJobs: testMockJobs, - }); - assertions.assertLintJobExecuted(result); - assertions.assertTestJobExecuted(result); - assertions.assertIsExpensifyEmployeeJobExecuted(result); - assertions.assertChooseDeployActionsJobExecuted(result); - assertions.assertSkipDeployJobExecuted(result, false); - assertions.assertCreateNewVersionJobExecuted(result); - assertions.assertUpdateStagingJobExecuted(result, true, false); - assertions.assertUpdateStagingJobFailed(result, false); - }); - - it('automated PR - deploy skipped, but no comment left', async () => { - const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; - const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); - let act = new eAct.ExtendedAct(repoPath, workflowPath); - act = utils.setUpActParams( - act, - 'push', - {ref: 'refs/heads/main'}, - { - OS_BOTIFY_TOKEN: 'dummy_token', - SLACK_WEBHOOK: 'dummy_slack_webhook', - }, - 'dummy_github_token', - ); - const testMockSteps = { - lint: mocks.LINT_JOB_MOCK_STEPS, - test: mocks.TEST_JOB_MOCK_STEPS, - confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, - chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__STAGING_UNLOCKED, - skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, - updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, - isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, - newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__OSBOTIFY, - }; - const testMockJobs = { - createNewVersion: { - steps: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, - outputs: { - // eslint-disable-next-line no-template-curly-in-string - NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', - }, - runsOn: 'ubuntu-latest', - }, - e2ePerformanceTests: { - steps: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, - runsOn: 'ubuntu-20.04-64core', + it('automated PR - deploy skipped, but no comment left', async () => { + const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + act = utils.setUpActParams(act, 'push', {ref: 'refs/heads/main'}, {OS_BOTIFY_TOKEN: 'dummy_token', SLACK_WEBHOOK: 'dummy_slack_webhook'}, 'dummy_github_token'); + const testMockSteps = { + confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, + chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__STAGING_LOCKED, + skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, + updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, + isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, + newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__OSBOTIFY, + }; + const testMockJobs = { + lint: { + steps: mocks.LINT_JOB_MOCK_STEPS, + runsOn: 'ubuntu-latest', + }, + test: { + steps: mocks.TEST_JOB_MOCK_STEPS, + runsOn: 'ubuntu-latest', + }, + createNewVersion: { + steps: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, + outputs: { + // eslint-disable-next-line no-template-curly-in-string + NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', }, - }; - const result = await act.runEvent('push', { - workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), - mockSteps: testMockSteps, - actor: 'OSBotify', - logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), - mockJobs: testMockJobs, - }); - assertions.assertLintJobExecuted(result); - assertions.assertTestJobExecuted(result); - assertions.assertIsExpensifyEmployeeJobExecuted(result); - assertions.assertChooseDeployActionsJobExecuted(result); - assertions.assertSkipDeployJobExecuted(result, false); - assertions.assertCreateNewVersionJobExecuted(result, false); - assertions.assertUpdateStagingJobExecuted(result, false, false); - assertions.assertUpdateStagingJobFailed(result, false); + runsOn: 'ubuntu-latest', + }, + e2ePerformanceTests: { + steps: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, + runsOn: 'ubuntu-latest', + }, + }; + const result = await act.runEvent('push', { + workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), + mockSteps: testMockSteps, + actor: 'OSBotify', + logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), + mockJobs: testMockJobs, }); + assertions.assertLintJobExecuted(result); + assertions.assertTestJobExecuted(result); + assertions.assertIsExpensifyEmployeeJobExecuted(result); + assertions.assertChooseDeployActionsJobExecuted(result); + assertions.assertSkipDeployJobExecuted(result, false); + assertions.assertCreateNewVersionJobExecuted(result, false); + assertions.assertUpdateStagingJobExecuted(result, false); + assertions.assertUpdateStagingJobFailed(result, false); }); }); - describe('CP label', () => { - describe('staging locked', () => { - it('not automated PR - proceed with deploy', async () => { - const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; - const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); - let act = new eAct.ExtendedAct(repoPath, workflowPath); - act = utils.setUpActParams( - act, - 'push', - {ref: 'refs/heads/main'}, - { - OS_BOTIFY_TOKEN: 'dummy_token', - SLACK_WEBHOOK: 'dummy_slack_webhook', - LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', - }, - 'dummy_github_token', - ); - const testMockSteps = { - lint: mocks.LINT_JOB_MOCK_STEPS, - test: mocks.TEST_JOB_MOCK_STEPS, - confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, - chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__CP_LABEL__STAGING_LOCKED, - skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, - updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, - isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, - newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, - }; - const testMockJobs = { - createNewVersion: { - steps: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, - outputs: { - // eslint-disable-next-line no-template-curly-in-string - NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', - }, - runsOn: 'ubuntu-latest', - }, - e2ePerformanceTests: { - steps: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, - runsOn: 'ubuntu-20.04-64core', - }, - }; - const result = await act.runEvent('push', { - workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), - mockSteps: testMockSteps, - actor: 'Dummy Tester', - logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), - mockJobs: testMockJobs, - }); - assertions.assertLintJobExecuted(result); - assertions.assertTestJobExecuted(result); - assertions.assertIsExpensifyEmployeeJobExecuted(result); - assertions.assertChooseDeployActionsJobExecuted(result); - assertions.assertSkipDeployJobExecuted(result, false); - assertions.assertCreateNewVersionJobExecuted(result); - assertions.assertUpdateStagingJobExecuted(result, true, true); - assertions.assertUpdateStagingJobFailed(result, false); - }); - - it('automated PR - proceed with deploy', async () => { - const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; - const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); - let act = new eAct.ExtendedAct(repoPath, workflowPath); - act = utils.setUpActParams( - act, - 'push', - {ref: 'refs/heads/main'}, - { - OS_BOTIFY_TOKEN: 'dummy_token', - SLACK_WEBHOOK: 'dummy_slack_webhook', - LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', - }, - 'dummy_github_token', - ); - const testMockSteps = { - lint: mocks.LINT_JOB_MOCK_STEPS, - test: mocks.TEST_JOB_MOCK_STEPS, - confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, - chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__CP_LABEL__STAGING_LOCKED, - skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, - updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, - isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, - newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, - }; - const testMockJobs = { - createNewVersion: { - steps: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, - outputs: { - // eslint-disable-next-line no-template-curly-in-string - NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', - }, - runsOn: 'ubuntu-latest', - }, - e2ePerformanceTests: { - steps: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, - runsOn: 'ubuntu-20.04-64core', + describe('staging not locked', () => { + it('not automated PR - proceed with deploy', async () => { + const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + act = utils.setUpActParams( + act, + 'push', + {ref: 'refs/heads/main'}, + { + OS_BOTIFY_TOKEN: 'dummy_token', + SLACK_WEBHOOK: 'dummy_slack_webhook', + LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', + }, + 'dummy_github_token', + ); + const testMockSteps = { + confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, + chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__STAGING_UNLOCKED, + skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, + updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, + isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, + newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, + }; + const testMockJobs = { + lint: { + steps: mocks.LINT_JOB_MOCK_STEPS, + runsOn: 'ubuntu-latest', + }, + test: { + steps: mocks.TEST_JOB_MOCK_STEPS, + runsOn: 'ubuntu-latest', + }, + createNewVersion: { + steps: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, + outputs: { + // eslint-disable-next-line no-template-curly-in-string + NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', }, - }; - const result = await act.runEvent('push', { - workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), - mockSteps: testMockSteps, - actor: 'OSBotify', - logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), - mockJobs: testMockJobs, - }); - assertions.assertLintJobExecuted(result); - assertions.assertTestJobExecuted(result); - assertions.assertIsExpensifyEmployeeJobExecuted(result); - assertions.assertChooseDeployActionsJobExecuted(result); - assertions.assertSkipDeployJobExecuted(result, false); - assertions.assertCreateNewVersionJobExecuted(result); - assertions.assertUpdateStagingJobExecuted(result, true, true); - assertions.assertUpdateStagingJobFailed(result, false); + runsOn: 'ubuntu-latest', + }, + e2ePerformanceTests: { + steps: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, + runsOn: 'ubuntu-latest', + }, + }; + const result = await act.runEvent('push', { + workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), + mockSteps: testMockSteps, + actor: 'Dummy Tester', + logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), + mockJobs: testMockJobs, }); + assertions.assertLintJobExecuted(result); + assertions.assertTestJobExecuted(result); + assertions.assertIsExpensifyEmployeeJobExecuted(result); + assertions.assertChooseDeployActionsJobExecuted(result); + assertions.assertSkipDeployJobExecuted(result, false); + assertions.assertCreateNewVersionJobExecuted(result); + assertions.assertUpdateStagingJobExecuted(result, true); + assertions.assertUpdateStagingJobFailed(result, false); }); - describe('staging not locked', () => { - it('not automated PR - proceed with deploy', async () => { - const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; - const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); - let act = new eAct.ExtendedAct(repoPath, workflowPath); - act = utils.setUpActParams( - act, - 'push', - {ref: 'refs/heads/main'}, - { - OS_BOTIFY_TOKEN: 'dummy_token', - SLACK_WEBHOOK: 'dummy_slack_webhook', - LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', - }, - 'dummy_github_token', - ); - const testMockSteps = { - lint: mocks.LINT_JOB_MOCK_STEPS, - test: mocks.TEST_JOB_MOCK_STEPS, - confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, - chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__CP_LABEL__STAGING_UNLOCKED, - skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, - updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, - isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, - newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, - }; - const testMockJobs = { - createNewVersion: { - steps: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, - outputs: { - // eslint-disable-next-line no-template-curly-in-string - NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', - }, - runsOn: 'ubuntu-latest', - }, - e2ePerformanceTests: { - steps: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, - runsOn: 'ubuntu-20.04-64core', - }, - }; - const result = await act.runEvent('push', { - workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), - mockSteps: testMockSteps, - actor: 'Dummy Tester', - logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), - mockJobs: testMockJobs, - }); - assertions.assertLintJobExecuted(result); - assertions.assertTestJobExecuted(result); - assertions.assertIsExpensifyEmployeeJobExecuted(result); - assertions.assertChooseDeployActionsJobExecuted(result); - assertions.assertSkipDeployJobExecuted(result, false); - assertions.assertCreateNewVersionJobExecuted(result); - assertions.assertUpdateStagingJobExecuted(result, true, false); - assertions.assertUpdateStagingJobFailed(result, false); - }); - - it('automated PR - proceed with deploy', async () => { - const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; - const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); - let act = new eAct.ExtendedAct(repoPath, workflowPath); - act = utils.setUpActParams( - act, - 'push', - {ref: 'refs/heads/main'}, - { - OS_BOTIFY_TOKEN: 'dummy_token', - SLACK_WEBHOOK: 'dummy_slack_webhook', - LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', - }, - 'dummy_github_token', - ); - const testMockSteps = { - lint: mocks.LINT_JOB_MOCK_STEPS, - test: mocks.TEST_JOB_MOCK_STEPS, - confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, - chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__CP_LABEL__STAGING_UNLOCKED, - skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, - updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, - isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, - newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, - }; - const testMockJobs = { - createNewVersion: { - steps: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, - outputs: { - // eslint-disable-next-line no-template-curly-in-string - NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', - }, - runsOn: 'ubuntu-latest', - }, - e2ePerformanceTests: { - steps: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, - runsOn: 'ubuntu-20.04-64core', + it('automated PR - deploy skipped, but no comment left', async () => { + const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + act = utils.setUpActParams( + act, + 'push', + {ref: 'refs/heads/main'}, + { + OS_BOTIFY_TOKEN: 'dummy_token', + SLACK_WEBHOOK: 'dummy_slack_webhook', + }, + 'dummy_github_token', + ); + const testMockSteps = { + confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, + chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__STAGING_UNLOCKED, + skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, + updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, + isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, + newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__OSBOTIFY, + }; + const testMockJobs = { + lint: { + steps: mocks.LINT_JOB_MOCK_STEPS, + runsOn: 'ubuntu-latest', + }, + test: { + steps: mocks.TEST_JOB_MOCK_STEPS, + runsOn: 'ubuntu-latest', + }, + createNewVersion: { + steps: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, + outputs: { + // eslint-disable-next-line no-template-curly-in-string + NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', }, - }; - const result = await act.runEvent('push', { - workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), - mockSteps: testMockSteps, - actor: 'OSBotify', - logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), - mockJobs: testMockJobs, - }); - assertions.assertLintJobExecuted(result); - assertions.assertTestJobExecuted(result); - assertions.assertIsExpensifyEmployeeJobExecuted(result); - assertions.assertChooseDeployActionsJobExecuted(result); - assertions.assertSkipDeployJobExecuted(result, false); - assertions.assertCreateNewVersionJobExecuted(result); - assertions.assertUpdateStagingJobExecuted(result, true, false); - assertions.assertUpdateStagingJobFailed(result, false); + runsOn: 'ubuntu-latest', + }, + e2ePerformanceTests: { + steps: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, + runsOn: 'ubuntu-latest', + }, + }; + const result = await act.runEvent('push', { + workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), + mockSteps: testMockSteps, + actor: 'OSBotify', + logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), + mockJobs: testMockJobs, }); + assertions.assertLintJobExecuted(result); + assertions.assertTestJobExecuted(result); + assertions.assertIsExpensifyEmployeeJobExecuted(result); + assertions.assertChooseDeployActionsJobExecuted(result); + assertions.assertSkipDeployJobExecuted(result, false); + assertions.assertCreateNewVersionJobExecuted(result, false); + assertions.assertUpdateStagingJobExecuted(result, false); + assertions.assertUpdateStagingJobFailed(result, false); }); }); @@ -1045,10 +891,8 @@ describe('test workflow preDeploy', () => { 'dummy_github_token', ); const testMockSteps = { - lint: mocks.LINT_JOB_MOCK_STEPS, - test: mocks.TEST_JOB_MOCK_STEPS, confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, - chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__CP_LABEL__STAGING_UNLOCKED, + chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__STAGING_UNLOCKED, skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, @@ -1056,6 +900,14 @@ describe('test workflow preDeploy', () => { }; testMockSteps.updateStaging[3].mockWith = 'exit 1'; const testMockJobs = { + lint: { + steps: mocks.LINT_JOB_MOCK_STEPS, + runsOn: 'ubuntu-latest', + }, + test: { + steps: mocks.TEST_JOB_MOCK_STEPS, + runsOn: 'ubuntu-latest', + }, createNewVersion: { steps: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, outputs: { @@ -1066,13 +918,13 @@ describe('test workflow preDeploy', () => { }, e2ePerformanceTests: { steps: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, - runsOn: 'ubuntu-20.04-64core', + runsOn: 'ubuntu-latest', }, }; const result = await act.runEvent('push', { workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), mockSteps: testMockSteps, - actor: 'OSBotify', + actor: 'Dummy Tester', logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), mockJobs: testMockJobs, }); From c424a8d7890eb410638a64d53fa93fb100f8aa90 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Mon, 3 Jul 2023 14:11:31 +0200 Subject: [PATCH 107/504] Fix test tests Tests were failing after recent changes in main See: https://github.com/Expensify/App/issues/13604 --- workflow_tests/assertions/testAssertions.js | 2 +- workflow_tests/mocks/testMocks.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/workflow_tests/assertions/testAssertions.js b/workflow_tests/assertions/testAssertions.js index d2d42ff80dd8..cee379ad5903 100644 --- a/workflow_tests/assertions/testAssertions.js +++ b/workflow_tests/assertions/testAssertions.js @@ -40,7 +40,7 @@ const assertShellTestsJobExecuted = (workflowResult, didExecute = true) => { const steps = [ utils.createStepAssertion('Checkout', true, null, 'SHELLTESTS', 'Checkout', [], []), utils.createStepAssertion('Setup Node', true, null, 'SHELLTESTS', 'Setup Node', [], []), - utils.createStepAssertion('getPullRequestsMergedBetween', true, null, 'SHELLTESTS', 'getPullRequestsMergedBetween', [], []), + utils.createStepAssertion('Test CI git logic', true, null, 'SHELLTESTS', 'Test CI git logic', [], []), ]; steps.forEach((expectedStep) => { diff --git a/workflow_tests/mocks/testMocks.js b/workflow_tests/mocks/testMocks.js index 002325292de6..19011271bb47 100644 --- a/workflow_tests/mocks/testMocks.js +++ b/workflow_tests/mocks/testMocks.js @@ -17,8 +17,8 @@ const TEST__JEST__STEP_MOCKS = [ // shelltests const TEST__SHELLTESTS__CHECKOUT__STEP_MOCK = utils.createMockStep('Checkout', 'Checkout', 'SHELLTESTS', [], []); const TEST__SHELLTESTS__SETUP_NODE__STEP_MOCK = utils.createMockStep('Setup Node', 'Setup Node', 'SHELLTESTS', [], []); -const TEST__SHELLTESTS__GETPULLREQUESTSMERGEDBETWEEN__STEP_MOCK = utils.createMockStep('getPullRequestsMergedBetween', 'getPullRequestsMergedBetween', 'SHELLTESTS', [], []); -const TEST__SHELLTESTS__STEP_MOCKS = [TEST__SHELLTESTS__CHECKOUT__STEP_MOCK, TEST__SHELLTESTS__SETUP_NODE__STEP_MOCK, TEST__SHELLTESTS__GETPULLREQUESTSMERGEDBETWEEN__STEP_MOCK]; +const TEST__SHELLTESTS__TEST_CI_GIT_LOGIC__STEP_MOCK = utils.createMockStep('Test CI git logic', 'Test CI git logic', 'SHELLTESTS', [], []); +const TEST__SHELLTESTS__STEP_MOCKS = [TEST__SHELLTESTS__CHECKOUT__STEP_MOCK, TEST__SHELLTESTS__SETUP_NODE__STEP_MOCK, TEST__SHELLTESTS__TEST_CI_GIT_LOGIC__STEP_MOCK]; module.exports = { TEST__JEST__STEP_MOCKS, From e0e7a6361967cd002cd699de3bed56e08f363aaa Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Mon, 3 Jul 2023 14:15:44 +0200 Subject: [PATCH 108/504] Fix typo README had a typo in 2 places Response to https://github.com/Expensify/App/pull/15560#discussion_r1244031353 See: https://github.com/Expensify/App/issues/13604 --- workflow_tests/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/workflow_tests/README.md b/workflow_tests/README.md index 70565375cce6..f5975a421120 100644 --- a/workflow_tests/README.md +++ b/workflow_tests/README.md @@ -308,7 +308,7 @@ describe('test some general behaviour', () => { // assert results (some steps can run in parallel to each other so the order is not assured // therefore we can check which steps have been executed, but not the set job order - assertions.assertSomethingHappend(result); + assertions.assertSomethingHappened(result); assertions.assertSomethingDidNotHappen(result, false); }, timeout); ); @@ -407,7 +407,7 @@ const result = await act ``` Assert results are as expected. This can, for example, include using `expect()` to check if the steps that should be executed have indeed been executed, steps that shouldn't run have not been executed, compare statuses (which steps succeeded, which failed) and step outputs. Outputs can include additional information, like input values, environmental variables, secrets (although these are usually not accessible and represented by `***`, this can still be useful to check if the value exists or not). Here it's usually done with the helper assertion methods defined in the assertions file. Step assertions can be created manually or with `getStepAssertion()` helper method ```javascript -assertions.assertSomethingHappend(result); +assertions.assertSomethingHappened(result); assertions.assertSomethingDidNotHappen(result, false); ``` From f3865a49244533f86a046403d3e34a42903c093d Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Mon, 3 Jul 2023 15:21:56 +0200 Subject: [PATCH 109/504] Fix testBuild tests Tests were failing after the recent changes in main See: https://github.com/Expensify/App/issues/13604 --- .../assertions/testBuildAssertions.js | 16 +--- workflow_tests/mocks/testBuildMocks.js | 8 +- workflow_tests/testBuild.test.js | 80 +++++++++---------- 3 files changed, 46 insertions(+), 58 deletions(-) diff --git a/workflow_tests/assertions/testBuildAssertions.js b/workflow_tests/assertions/testBuildAssertions.js index bf0936182da5..9026caaabd4d 100644 --- a/workflow_tests/assertions/testBuildAssertions.js +++ b/workflow_tests/assertions/testBuildAssertions.js @@ -1,20 +1,8 @@ const utils = require('../utils/utils'); -const assertValidateActorJobExecuted = (workflowResult, actor = 'Dummy Actor', pullRequestNumber = '1234', didExecute = true) => { +const assertValidateActorJobExecuted = (workflowResult, pullRequestNumber = '1234', didExecute = true) => { const steps = [ - utils.createStepAssertion( - 'Is team member', - true, - null, - 'VALIDATEACTOR', - 'Is team member', - [ - {key: 'GITHUB_TOKEN', value: '***'}, - {key: 'username', value: actor}, - {key: 'team', value: 'Expensify/expensify'}, - ], - [], - ), + utils.createStepAssertion('Is Expensify employee', true, null, 'VALIDATEACTOR', 'Is Expensify employee', [], [{key: 'GITHUB_TOKEN', value: '***'}]), utils.createStepAssertion( 'Set HAS_READY_TO_BUILD_LABEL flag', true, diff --git a/workflow_tests/mocks/testBuildMocks.js b/workflow_tests/mocks/testBuildMocks.js index b20afbe2aa83..18d332e5dedc 100644 --- a/workflow_tests/mocks/testBuildMocks.js +++ b/workflow_tests/mocks/testBuildMocks.js @@ -1,11 +1,11 @@ const utils = require('../utils/utils'); // validateactor -const TESTBUILD__VALIDATEACTOR__IS_TEAM_MEMBER__TRUE__STEP_MOCK = utils.createMockStep('Is team member', 'Is team member', 'VALIDATEACTOR', ['GITHUB_TOKEN', 'username', 'team'], [], { - isTeamMember: true, +const TESTBUILD__VALIDATEACTOR__IS_TEAM_MEMBER__TRUE__STEP_MOCK = utils.createMockStep('Is Expensify employee', 'Is Expensify employee', 'VALIDATEACTOR', [], ['GITHUB_TOKEN'], { + IS_EXPENSIFY_EMPLOYEE: true, }); -const TESTBUILD__VALIDATEACTOR__IS_TEAM_MEMBER__FALSE__STEP_MOCK = utils.createMockStep('Is team member', 'Is team member', 'VALIDATEACTOR', ['GITHUB_TOKEN', 'username', 'team'], [], { - isTeamMember: false, +const TESTBUILD__VALIDATEACTOR__IS_TEAM_MEMBER__FALSE__STEP_MOCK = utils.createMockStep('Is Expensify employee', 'Is Expensify employee', 'VALIDATEACTOR', [], ['GITHUB_TOKEN'], { + IS_EXPENSIFY_EMPLOYEE: false, }); const TESTBUILD__VALIDATEACTOR__SET_HAS_READY_TO_BUILD_LABEL_FLAG__TRUE__STEP_MOCK = utils.createMockStep( 'Set HAS_READY_TO_BUILD_LABEL flag', diff --git a/workflow_tests/testBuild.test.js b/workflow_tests/testBuild.test.js index 713ec4a91c31..837699830650 100644 --- a/workflow_tests/testBuild.test.js +++ b/workflow_tests/testBuild.test.js @@ -62,7 +62,7 @@ describe('test workflow testBuild', () => { const workflowPath = path.join(repoPath, '.github', 'workflows', 'testBuild.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, {}, secrets, githubToken, {}, inputs); - act = utils.setJobRunners(act, {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest'}, workflowPath); + act = utils.setJobRunners(act, {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest', web: 'ubuntu-latest', android: 'ubuntu-latest'}, workflowPath); const testMockSteps = { validateActor: mocks.TESTBUILD__VALIDATEACTOR__TEAM_MEMBER_HAS_FLAG__STEP_MOCKS, getBranchRef: mocks.TESTBUILD__GETBRANCHREF__STEP_MOCKS, @@ -79,7 +79,7 @@ describe('test workflow testBuild', () => { logFile: utils.getLogFilePath('testBuild', expect.getState().currentTestName), }); - assertions.assertValidateActorJobExecuted(result, actor, '1234'); + assertions.assertValidateActorJobExecuted(result, '1234'); assertions.assertGetBranchRefJobExecuted(result); assertions.assertAndroidJobExecuted(result, 'test-ref'); assertions.assertIOSJobExecuted(result, 'test-ref'); @@ -93,7 +93,7 @@ describe('test workflow testBuild', () => { const workflowPath = path.join(repoPath, '.github', 'workflows', 'testBuild.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, {}, secrets, githubToken, {}, inputs); - act = utils.setJobRunners(act, {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest'}, workflowPath); + act = utils.setJobRunners(act, {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest', web: 'ubuntu-latest', android: 'ubuntu-latest'}, workflowPath); const testMockSteps = { validateActor: mocks.TESTBUILD__VALIDATEACTOR__NO_TEAM_MEMBER_HAS_FLAG__STEP_MOCKS, getBranchRef: mocks.TESTBUILD__GETBRANCHREF__STEP_MOCKS, @@ -110,7 +110,7 @@ describe('test workflow testBuild', () => { logFile: utils.getLogFilePath('testBuild', expect.getState().currentTestName), }); - assertions.assertValidateActorJobExecuted(result, actor, '1234'); + assertions.assertValidateActorJobExecuted(result, '1234'); assertions.assertGetBranchRefJobExecuted(result, false); assertions.assertAndroidJobExecuted(result, 'test-ref', false); assertions.assertIOSJobExecuted(result, 'test-ref', false); @@ -125,7 +125,7 @@ describe('test workflow testBuild', () => { const workflowPath = path.join(repoPath, '.github', 'workflows', 'testBuild.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, {}, secrets, githubToken, {}, inputs); - act = utils.setJobRunners(act, {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest'}, workflowPath); + act = utils.setJobRunners(act, {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest', web: 'ubuntu-latest', android: 'ubuntu-latest'}, workflowPath); const testMockSteps = { validateActor: mocks.TESTBUILD__VALIDATEACTOR__TEAM_MEMBER_NO_FLAG__STEP_MOCKS, getBranchRef: mocks.TESTBUILD__GETBRANCHREF__STEP_MOCKS, @@ -142,7 +142,7 @@ describe('test workflow testBuild', () => { logFile: utils.getLogFilePath('testBuild', expect.getState().currentTestName), }); - assertions.assertValidateActorJobExecuted(result, actor, '1234'); + assertions.assertValidateActorJobExecuted(result, '1234'); assertions.assertGetBranchRefJobExecuted(result, false); assertions.assertAndroidJobExecuted(result, 'test-ref', false); assertions.assertIOSJobExecuted(result, 'test-ref', false); @@ -157,7 +157,7 @@ describe('test workflow testBuild', () => { const workflowPath = path.join(repoPath, '.github', 'workflows', 'testBuild.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, {}, secrets, githubToken, {}, inputs); - act = utils.setJobRunners(act, {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest'}, workflowPath); + act = utils.setJobRunners(act, {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest', web: 'ubuntu-latest', android: 'ubuntu-latest'}, workflowPath); const testMockSteps = { validateActor: mocks.TESTBUILD__VALIDATEACTOR__NO_TEAM_MEMBER_NO_FLAG__STEP_MOCKS, getBranchRef: mocks.TESTBUILD__GETBRANCHREF__STEP_MOCKS, @@ -174,7 +174,7 @@ describe('test workflow testBuild', () => { logFile: utils.getLogFilePath('testBuild', expect.getState().currentTestName), }); - assertions.assertValidateActorJobExecuted(result, actor, '1234'); + assertions.assertValidateActorJobExecuted(result, '1234'); assertions.assertGetBranchRefJobExecuted(result, false); assertions.assertAndroidJobExecuted(result, 'test-ref', false); assertions.assertIOSJobExecuted(result, 'test-ref', false); @@ -189,7 +189,7 @@ describe('test workflow testBuild', () => { const workflowPath = path.join(repoPath, '.github', 'workflows', 'testBuild.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, {}, secrets, githubToken, {}, inputs); - act = utils.setJobRunners(act, {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest'}, workflowPath); + act = utils.setJobRunners(act, {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest', web: 'ubuntu-latest', android: 'ubuntu-latest'}, workflowPath); const testMockSteps = { validateActor: mocks.TESTBUILD__VALIDATEACTOR__TEAM_MEMBER_HAS_FLAG__STEP_MOCKS, getBranchRef: mocks.TESTBUILD__GETBRANCHREF__STEP_MOCKS, @@ -207,7 +207,7 @@ describe('test workflow testBuild', () => { logFile: utils.getLogFilePath('testBuild', expect.getState().currentTestName), }); - assertions.assertValidateActorJobExecuted(result, actor, '1234'); + assertions.assertValidateActorJobExecuted(result, '1234'); assertions.assertGetBranchRefJobExecuted(result); assertions.assertAndroidJobExecuted(result, 'test-ref', true, 4); assertions.assertIOSJobExecuted(result, 'test-ref'); @@ -222,7 +222,7 @@ describe('test workflow testBuild', () => { const workflowPath = path.join(repoPath, '.github', 'workflows', 'testBuild.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, {}, secrets, githubToken, {}, inputs); - act = utils.setJobRunners(act, {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest'}, workflowPath); + act = utils.setJobRunners(act, {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest', web: 'ubuntu-latest', android: 'ubuntu-latest'}, workflowPath); const testMockSteps = { validateActor: mocks.TESTBUILD__VALIDATEACTOR__TEAM_MEMBER_HAS_FLAG__STEP_MOCKS, getBranchRef: mocks.TESTBUILD__GETBRANCHREF__STEP_MOCKS, @@ -240,7 +240,7 @@ describe('test workflow testBuild', () => { logFile: utils.getLogFilePath('testBuild', expect.getState().currentTestName), }); - assertions.assertValidateActorJobExecuted(result, actor, '1234'); + assertions.assertValidateActorJobExecuted(result, '1234'); assertions.assertGetBranchRefJobExecuted(result); assertions.assertAndroidJobExecuted(result, 'test-ref'); assertions.assertIOSJobExecuted(result, 'test-ref', true, 4); @@ -255,7 +255,7 @@ describe('test workflow testBuild', () => { const workflowPath = path.join(repoPath, '.github', 'workflows', 'testBuild.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, {}, secrets, githubToken, {}, inputs); - act = utils.setJobRunners(act, {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest'}, workflowPath); + act = utils.setJobRunners(act, {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest', web: 'ubuntu-latest', android: 'ubuntu-latest'}, workflowPath); const testMockSteps = { validateActor: mocks.TESTBUILD__VALIDATEACTOR__TEAM_MEMBER_HAS_FLAG__STEP_MOCKS, getBranchRef: mocks.TESTBUILD__GETBRANCHREF__STEP_MOCKS, @@ -282,7 +282,7 @@ describe('test workflow testBuild', () => { logFile: utils.getLogFilePath('testBuild', expect.getState().currentTestName), }); - assertions.assertValidateActorJobExecuted(result, actor, '1234'); + assertions.assertValidateActorJobExecuted(result, '1234'); assertions.assertGetBranchRefJobExecuted(result); assertions.assertAndroidJobExecuted(result, 'test-ref'); assertions.assertIOSJobExecuted(result, 'test-ref'); @@ -297,7 +297,7 @@ describe('test workflow testBuild', () => { const workflowPath = path.join(repoPath, '.github', 'workflows', 'testBuild.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, {}, secrets, githubToken, {}, inputs); - act = utils.setJobRunners(act, {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest'}, workflowPath); + act = utils.setJobRunners(act, {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest', web: 'ubuntu-latest', android: 'ubuntu-latest'}, workflowPath); const testMockSteps = { validateActor: mocks.TESTBUILD__VALIDATEACTOR__TEAM_MEMBER_HAS_FLAG__STEP_MOCKS, getBranchRef: mocks.TESTBUILD__GETBRANCHREF__STEP_MOCKS, @@ -324,7 +324,7 @@ describe('test workflow testBuild', () => { logFile: utils.getLogFilePath('testBuild', expect.getState().currentTestName), }); - assertions.assertValidateActorJobExecuted(result, actor, '1234'); + assertions.assertValidateActorJobExecuted(result, '1234'); assertions.assertGetBranchRefJobExecuted(result); assertions.assertAndroidJobExecuted(result, 'test-ref'); assertions.assertIOSJobExecuted(result, 'test-ref'); @@ -350,7 +350,7 @@ describe('test workflow testBuild', () => { const workflowPath = path.join(repoPath, '.github', 'workflows', 'testBuild.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, eventOptions, secrets, githubToken, {}); - act = utils.setJobRunners(act, {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest'}, workflowPath); + act = utils.setJobRunners(act, {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest', web: 'ubuntu-latest', android: 'ubuntu-latest'}, workflowPath); const testMockSteps = { validateActor: mocks.TESTBUILD__VALIDATEACTOR__TEAM_MEMBER_HAS_FLAG__STEP_MOCKS, getBranchRef: mocks.TESTBUILD__GETBRANCHREF__STEP_MOCKS, @@ -367,7 +367,7 @@ describe('test workflow testBuild', () => { logFile: utils.getLogFilePath('testBuild', expect.getState().currentTestName), }); - assertions.assertValidateActorJobExecuted(result, actor, '1234'); + assertions.assertValidateActorJobExecuted(result, '1234'); assertions.assertGetBranchRefJobExecuted(result, false); assertions.assertAndroidJobExecuted(result, 'test-ref'); assertions.assertIOSJobExecuted(result, 'test-ref'); @@ -381,7 +381,7 @@ describe('test workflow testBuild', () => { const workflowPath = path.join(repoPath, '.github', 'workflows', 'testBuild.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, eventOptions, secrets, githubToken, {}); - act = utils.setJobRunners(act, {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest'}, workflowPath); + act = utils.setJobRunners(act, {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest', web: 'ubuntu-latest', android: 'ubuntu-latest'}, workflowPath); const testMockSteps = { validateActor: mocks.TESTBUILD__VALIDATEACTOR__NO_TEAM_MEMBER_HAS_FLAG__STEP_MOCKS, getBranchRef: mocks.TESTBUILD__GETBRANCHREF__STEP_MOCKS, @@ -398,7 +398,7 @@ describe('test workflow testBuild', () => { logFile: utils.getLogFilePath('testBuild', expect.getState().currentTestName), }); - assertions.assertValidateActorJobExecuted(result, actor, '1234'); + assertions.assertValidateActorJobExecuted(result, '1234'); assertions.assertGetBranchRefJobExecuted(result, false); assertions.assertAndroidJobExecuted(result, 'test-ref', false); assertions.assertIOSJobExecuted(result, 'test-ref', false); @@ -413,7 +413,7 @@ describe('test workflow testBuild', () => { const workflowPath = path.join(repoPath, '.github', 'workflows', 'testBuild.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, eventOptions, secrets, githubToken, {}); - act = utils.setJobRunners(act, {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest'}, workflowPath); + act = utils.setJobRunners(act, {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest', web: 'ubuntu-latest', android: 'ubuntu-latest'}, workflowPath); const testMockSteps = { validateActor: mocks.TESTBUILD__VALIDATEACTOR__TEAM_MEMBER_NO_FLAG__STEP_MOCKS, getBranchRef: mocks.TESTBUILD__GETBRANCHREF__STEP_MOCKS, @@ -430,7 +430,7 @@ describe('test workflow testBuild', () => { logFile: utils.getLogFilePath('testBuild', expect.getState().currentTestName), }); - assertions.assertValidateActorJobExecuted(result, actor, '1234'); + assertions.assertValidateActorJobExecuted(result, '1234'); assertions.assertGetBranchRefJobExecuted(result, false); assertions.assertAndroidJobExecuted(result, 'test-ref', false); assertions.assertIOSJobExecuted(result, 'test-ref', false); @@ -445,7 +445,7 @@ describe('test workflow testBuild', () => { const workflowPath = path.join(repoPath, '.github', 'workflows', 'testBuild.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, eventOptions, secrets, githubToken, {}); - act = utils.setJobRunners(act, {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest'}, workflowPath); + act = utils.setJobRunners(act, {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest', web: 'ubuntu-latest', android: 'ubuntu-latest'}, workflowPath); const testMockSteps = { validateActor: mocks.TESTBUILD__VALIDATEACTOR__NO_TEAM_MEMBER_NO_FLAG__STEP_MOCKS, getBranchRef: mocks.TESTBUILD__GETBRANCHREF__STEP_MOCKS, @@ -462,7 +462,7 @@ describe('test workflow testBuild', () => { logFile: utils.getLogFilePath('testBuild', expect.getState().currentTestName), }); - assertions.assertValidateActorJobExecuted(result, actor, '1234'); + assertions.assertValidateActorJobExecuted(result, '1234'); assertions.assertGetBranchRefJobExecuted(result, false); assertions.assertAndroidJobExecuted(result, 'test-ref', false); assertions.assertIOSJobExecuted(result, 'test-ref', false); @@ -488,7 +488,7 @@ describe('test workflow testBuild', () => { const workflowPath = path.join(repoPath, '.github', 'workflows', 'testBuild.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, eventOptions, secrets, githubToken, {}); - act = utils.setJobRunners(act, {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest'}, workflowPath); + act = utils.setJobRunners(act, {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest', web: 'ubuntu-latest', android: 'ubuntu-latest'}, workflowPath); const testMockSteps = { validateActor: mocks.TESTBUILD__VALIDATEACTOR__TEAM_MEMBER_HAS_FLAG__STEP_MOCKS, getBranchRef: mocks.TESTBUILD__GETBRANCHREF__STEP_MOCKS, @@ -505,7 +505,7 @@ describe('test workflow testBuild', () => { logFile: utils.getLogFilePath('testBuild', expect.getState().currentTestName), }); - assertions.assertValidateActorJobExecuted(result, actor, '1234'); + assertions.assertValidateActorJobExecuted(result, '1234'); assertions.assertGetBranchRefJobExecuted(result, false); assertions.assertAndroidJobExecuted(result, 'test-ref'); assertions.assertIOSJobExecuted(result, 'test-ref'); @@ -519,7 +519,7 @@ describe('test workflow testBuild', () => { const workflowPath = path.join(repoPath, '.github', 'workflows', 'testBuild.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, eventOptions, secrets, githubToken, {}); - act = utils.setJobRunners(act, {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest'}, workflowPath); + act = utils.setJobRunners(act, {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest', web: 'ubuntu-latest', android: 'ubuntu-latest'}, workflowPath); const testMockSteps = { validateActor: mocks.TESTBUILD__VALIDATEACTOR__NO_TEAM_MEMBER_HAS_FLAG__STEP_MOCKS, getBranchRef: mocks.TESTBUILD__GETBRANCHREF__STEP_MOCKS, @@ -536,7 +536,7 @@ describe('test workflow testBuild', () => { logFile: utils.getLogFilePath('testBuild', expect.getState().currentTestName), }); - assertions.assertValidateActorJobExecuted(result, actor, '1234'); + assertions.assertValidateActorJobExecuted(result, '1234'); assertions.assertGetBranchRefJobExecuted(result, false); assertions.assertAndroidJobExecuted(result, 'test-ref', false); assertions.assertIOSJobExecuted(result, 'test-ref', false); @@ -551,7 +551,7 @@ describe('test workflow testBuild', () => { const workflowPath = path.join(repoPath, '.github', 'workflows', 'testBuild.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, eventOptions, secrets, githubToken, {}); - act = utils.setJobRunners(act, {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest'}, workflowPath); + act = utils.setJobRunners(act, {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest', web: 'ubuntu-latest', android: 'ubuntu-latest'}, workflowPath); const testMockSteps = { validateActor: mocks.TESTBUILD__VALIDATEACTOR__TEAM_MEMBER_NO_FLAG__STEP_MOCKS, getBranchRef: mocks.TESTBUILD__GETBRANCHREF__STEP_MOCKS, @@ -568,7 +568,7 @@ describe('test workflow testBuild', () => { logFile: utils.getLogFilePath('testBuild', expect.getState().currentTestName), }); - assertions.assertValidateActorJobExecuted(result, actor, '1234'); + assertions.assertValidateActorJobExecuted(result, '1234'); assertions.assertGetBranchRefJobExecuted(result, false); assertions.assertAndroidJobExecuted(result, 'test-ref', false); assertions.assertIOSJobExecuted(result, 'test-ref', false); @@ -583,7 +583,7 @@ describe('test workflow testBuild', () => { const workflowPath = path.join(repoPath, '.github', 'workflows', 'testBuild.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, eventOptions, secrets, githubToken, {}); - act = utils.setJobRunners(act, {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest'}, workflowPath); + act = utils.setJobRunners(act, {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest', web: 'ubuntu-latest', android: 'ubuntu-latest'}, workflowPath); const testMockSteps = { validateActor: mocks.TESTBUILD__VALIDATEACTOR__NO_TEAM_MEMBER_NO_FLAG__STEP_MOCKS, getBranchRef: mocks.TESTBUILD__GETBRANCHREF__STEP_MOCKS, @@ -600,7 +600,7 @@ describe('test workflow testBuild', () => { logFile: utils.getLogFilePath('testBuild', expect.getState().currentTestName), }); - assertions.assertValidateActorJobExecuted(result, actor, '1234'); + assertions.assertValidateActorJobExecuted(result, '1234'); assertions.assertGetBranchRefJobExecuted(result, false); assertions.assertAndroidJobExecuted(result, 'test-ref', false); assertions.assertIOSJobExecuted(result, 'test-ref', false); @@ -626,7 +626,7 @@ describe('test workflow testBuild', () => { const workflowPath = path.join(repoPath, '.github', 'workflows', 'testBuild.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, eventOptions, secrets, githubToken, {}); - act = utils.setJobRunners(act, {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest'}, workflowPath); + act = utils.setJobRunners(act, {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest', web: 'ubuntu-latest', android: 'ubuntu-latest'}, workflowPath); const testMockSteps = { validateActor: mocks.TESTBUILD__VALIDATEACTOR__TEAM_MEMBER_HAS_FLAG__STEP_MOCKS, getBranchRef: mocks.TESTBUILD__GETBRANCHREF__STEP_MOCKS, @@ -643,7 +643,7 @@ describe('test workflow testBuild', () => { logFile: utils.getLogFilePath('testBuild', expect.getState().currentTestName), }); - assertions.assertValidateActorJobExecuted(result, actor, '1234'); + assertions.assertValidateActorJobExecuted(result, '1234'); assertions.assertGetBranchRefJobExecuted(result, false); assertions.assertAndroidJobExecuted(result, 'test-ref'); assertions.assertIOSJobExecuted(result, 'test-ref'); @@ -657,7 +657,7 @@ describe('test workflow testBuild', () => { const workflowPath = path.join(repoPath, '.github', 'workflows', 'testBuild.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, eventOptions, secrets, githubToken, {}); - act = utils.setJobRunners(act, {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest'}, workflowPath); + act = utils.setJobRunners(act, {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest', web: 'ubuntu-latest', android: 'ubuntu-latest'}, workflowPath); const testMockSteps = { validateActor: mocks.TESTBUILD__VALIDATEACTOR__NO_TEAM_MEMBER_HAS_FLAG__STEP_MOCKS, getBranchRef: mocks.TESTBUILD__GETBRANCHREF__STEP_MOCKS, @@ -674,7 +674,7 @@ describe('test workflow testBuild', () => { logFile: utils.getLogFilePath('testBuild', expect.getState().currentTestName), }); - assertions.assertValidateActorJobExecuted(result, actor, '1234'); + assertions.assertValidateActorJobExecuted(result, '1234'); assertions.assertGetBranchRefJobExecuted(result, false); assertions.assertAndroidJobExecuted(result, 'test-ref', false); assertions.assertIOSJobExecuted(result, 'test-ref', false); @@ -689,7 +689,7 @@ describe('test workflow testBuild', () => { const workflowPath = path.join(repoPath, '.github', 'workflows', 'testBuild.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, eventOptions, secrets, githubToken, {}); - act = utils.setJobRunners(act, {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest'}, workflowPath); + act = utils.setJobRunners(act, {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest', web: 'ubuntu-latest', android: 'ubuntu-latest'}, workflowPath); const testMockSteps = { validateActor: mocks.TESTBUILD__VALIDATEACTOR__TEAM_MEMBER_NO_FLAG__STEP_MOCKS, getBranchRef: mocks.TESTBUILD__GETBRANCHREF__STEP_MOCKS, @@ -706,7 +706,7 @@ describe('test workflow testBuild', () => { logFile: utils.getLogFilePath('testBuild', expect.getState().currentTestName), }); - assertions.assertValidateActorJobExecuted(result, actor, '1234'); + assertions.assertValidateActorJobExecuted(result, '1234'); assertions.assertGetBranchRefJobExecuted(result, false); assertions.assertAndroidJobExecuted(result, 'test-ref', false); assertions.assertIOSJobExecuted(result, 'test-ref', false); @@ -721,7 +721,7 @@ describe('test workflow testBuild', () => { const workflowPath = path.join(repoPath, '.github', 'workflows', 'testBuild.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); act = utils.setUpActParams(act, event, eventOptions, secrets, githubToken, {}); - act = utils.setJobRunners(act, {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest'}, workflowPath); + act = utils.setJobRunners(act, {iOS: 'ubuntu-latest', desktop: 'ubuntu-latest', web: 'ubuntu-latest', android: 'ubuntu-latest'}, workflowPath); const testMockSteps = { validateActor: mocks.TESTBUILD__VALIDATEACTOR__NO_TEAM_MEMBER_NO_FLAG__STEP_MOCKS, getBranchRef: mocks.TESTBUILD__GETBRANCHREF__STEP_MOCKS, @@ -738,7 +738,7 @@ describe('test workflow testBuild', () => { logFile: utils.getLogFilePath('testBuild', expect.getState().currentTestName), }); - assertions.assertValidateActorJobExecuted(result, actor, '1234'); + assertions.assertValidateActorJobExecuted(result, '1234'); assertions.assertGetBranchRefJobExecuted(result, false); assertions.assertAndroidJobExecuted(result, 'test-ref', false); assertions.assertIOSJobExecuted(result, 'test-ref', false); From 30609a54c39a33497b5dadda8ace0709178b5d74 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Wed, 12 Jul 2023 11:15:25 +0200 Subject: [PATCH 110/504] Remove dependency One of the packages was a leftover from a resolved merge conflicts and was causing issues with verifying the podfile See: https://github.com/Expensify/App/issues/13604 --- package-lock.json | 18 +----------------- package.json | 3 +-- 2 files changed, 2 insertions(+), 19 deletions(-) diff --git a/package-lock.json b/package-lock.json index 0b3570ddff3b..626be7f8213f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -104,8 +104,7 @@ "save": "^2.4.0", "semver": "^7.3.8", "shim-keyboard-event-key": "^1.0.3", - "underscore": "^1.13.1", - "urbanairship-react-native": "^14.6.1" + "underscore": "^1.13.1" }, "devDependencies": { "@actions/core": "1.10.0", @@ -42096,15 +42095,6 @@ "version": "1.0.0", "license": "ISC" }, - "node_modules/urbanairship-react-native": { - "version": "14.6.1", - "resolved": "https://registry.npmjs.org/urbanairship-react-native/-/urbanairship-react-native-14.6.1.tgz", - "integrity": "sha512-ddL3ZWZnhwCja9oMpq7YHEyuqca1IH34MtMm24w1SePzGRhcVAvKOe/lncIB1FAK6QyjG0pkPT5mu3vE/DsPEw==", - "peerDependencies": { - "react": "*", - "react-native": "*" - } - }, "node_modules/uri-js": { "version": "4.4.1", "license": "BSD-2-Clause", @@ -72253,12 +72243,6 @@ } } }, - "urbanairship-react-native": { - "version": "14.6.1", - "resolved": "https://registry.npmjs.org/urbanairship-react-native/-/urbanairship-react-native-14.6.1.tgz", - "integrity": "sha512-ddL3ZWZnhwCja9oMpq7YHEyuqca1IH34MtMm24w1SePzGRhcVAvKOe/lncIB1FAK6QyjG0pkPT5mu3vE/DsPEw==", - "requires": {} - }, "uri-js": { "version": "4.4.1", "requires": { diff --git a/package.json b/package.json index 2c026bd0a570..f5d75eee18d6 100644 --- a/package.json +++ b/package.json @@ -143,8 +143,7 @@ "save": "^2.4.0", "semver": "^7.3.8", "shim-keyboard-event-key": "^1.0.3", - "underscore": "^1.13.1", - "urbanairship-react-native": "^14.6.1" + "underscore": "^1.13.1" }, "devDependencies": { "@actions/core": "1.10.0", From 69e43bf7486755f295d7bbd2187702f72f6a0fb4 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Wed, 12 Jul 2023 11:51:05 +0200 Subject: [PATCH 111/504] Fix cherryPick.test.js Fixes after merging with main See: https://github.com/Expensify/App/issues/13604 --- .../assertions/cherryPickAssertions.js | 9 +- workflow_tests/cherryPick.test.js | 571 ++++++------------ workflow_tests/mocks/cherryPickMocks.js | 23 +- 3 files changed, 201 insertions(+), 402 deletions(-) diff --git a/workflow_tests/assertions/cherryPickAssertions.js b/workflow_tests/assertions/cherryPickAssertions.js index 7360858d8fed..e73f2067dafc 100644 --- a/workflow_tests/assertions/cherryPickAssertions.js +++ b/workflow_tests/assertions/cherryPickAssertions.js @@ -29,7 +29,6 @@ const assertCherryPickJobExecuted = ( user = 'Dummy Author', pullRequestNumber = '1234', didExecute = true, - inputNewVersion = '', hasConflicts = false, isSuccessful = true, ) => { @@ -47,12 +46,13 @@ const assertCherryPickJobExecuted = ( [], ), utils.createStepAssertion('Set up git for OSBotify', true, null, 'CHERRYPICK', 'Setting up git for OSBotify', [{key: 'GPG_PASSPHRASE', value: '***'}], []), + utils.createStepAssertion('Get version bump commit', true, null, 'CHERRYPICK', 'Get version bump commit', [], []), utils.createStepAssertion( - 'Get merge commit for CP pull request', + 'Get merge commit for pull request to CP', true, null, 'CHERRYPICK', - 'Getting merge commit for CP pull request', + 'Get merge commit for pull request to CP', [ {key: 'GITHUB_TOKEN', value: '***'}, {key: 'USER', value: user}, @@ -60,7 +60,8 @@ const assertCherryPickJobExecuted = ( ], [], ), - utils.createStepAssertion('Save correct NEW_VERSION to env', true, inputNewVersion ? `New version is ${inputNewVersion}` : 'New version is'), + utils.createStepAssertion('Get previous app version', true, null, 'CHERRYPICK', 'Get previous app version', [{key: 'SEMVER_LEVEL', value: 'PATCH'}]), + utils.createStepAssertion('Fetch history of relevant refs', true, null, 'CHERRYPICK', 'Fetch history of relevant refs'), utils.createStepAssertion('Cherry-pick the version-bump to staging', true, null, 'CHERRYPICK', 'Cherry-picking the version-bump to staging', [], []), utils.createStepAssertion('Cherry-pick the merge commit of target PR', true, null, 'CHERRYPICK', 'Cherry-picking the merge commit of target PR', [], []), utils.createStepAssertion('Push changes', true, null, 'CHERRYPICK', 'Pushing changes', [], []), diff --git a/workflow_tests/cherryPick.test.js b/workflow_tests/cherryPick.test.js index bfc9beee5b96..34c2b825d521 100644 --- a/workflow_tests/cherryPick.test.js +++ b/workflow_tests/cherryPick.test.js @@ -59,7 +59,6 @@ describe('test workflow cherryPick', () => { null, { PULL_REQUEST_NUMBER: '1234', - NEW_VERSION: '', }, ); const testMockSteps = { @@ -91,7 +90,6 @@ describe('test workflow cherryPick', () => { }); describe('actor is OSBotify', () => { const actor = 'OSBotify'; - const newVersion = ''; const mergeConflicts = false; const versionsMatch = true; it('behaviour is the same as with actor being the deployer', async () => { @@ -125,7 +123,6 @@ describe('test workflow cherryPick', () => { null, { PULL_REQUEST_NUMBER: '1234', - NEW_VERSION: newVersion, }, ); const result = await act.runEvent(event, { @@ -138,419 +135,206 @@ describe('test workflow cherryPick', () => { assertions.assertValidateActorJobExecuted(result); assertions.assertCreateNewVersionJobExecuted(result); - assertions.assertCherryPickJobExecuted(result, actor, '1234', true, newVersion); + assertions.assertCherryPickJobExecuted(result, actor, '1234', true); }); }); describe('actor is a deployer', () => { const actor = 'Dummy Author'; - describe('input version not set', () => { - const newVersion = ''; - describe('no merge conflicts', () => { - const mergeConflicts = false; - describe('version match', () => { - const versionsMatch = true; - it('workflow executes, new version created, PR approved and merged automatically', async () => { - const repoPath = mockGithub.repo.getPath('testCherryPickWorkflowRepo') || ''; - const workflowPath = path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'); - let act = new eAct.ExtendedAct(repoPath, workflowPath); - const testMockSteps = { - validateActor: mocks.CHERRYPICK__VALIDATEACTOR__TRUE__STEP_MOCKS, - }; - testMockSteps.cherryPick = mocks.getCherryPickMockSteps(versionsMatch, mergeConflicts); - const testMockJobs = { - createNewVersion: { - steps: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, - outputs: { - // eslint-disable-next-line no-template-curly-in-string - NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', - }, - runsOn: 'ubuntu-latest', + describe('no merge conflicts', () => { + const mergeConflicts = false; + describe('version match', () => { + const versionsMatch = true; + it('workflow executes, PR approved and merged automatically', async () => { + const repoPath = mockGithub.repo.getPath('testCherryPickWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + const testMockSteps = { + validateActor: mocks.CHERRYPICK__VALIDATEACTOR__TRUE__STEP_MOCKS, + }; + testMockSteps.cherryPick = mocks.getCherryPickMockSteps(versionsMatch, mergeConflicts); + const testMockJobs = { + createNewVersion: { + steps: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, + outputs: { + // eslint-disable-next-line no-template-curly-in-string + NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', }, - }; - act = utils.setUpActParams( - act, - event, - null, - { - OS_BOTIFY_TOKEN: 'dummy_token', - LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', - SLACK_WEBHOOK: 'dummy_slack_webhook', - }, - 'dummy_github_token', - null, - { - PULL_REQUEST_NUMBER: '1234', - NEW_VERSION: newVersion, - }, - ); - const result = await act.runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), - mockSteps: testMockSteps, - actor, - logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), - mockJobs: testMockJobs, - }); - - assertions.assertValidateActorJobExecuted(result); - assertions.assertCreateNewVersionJobExecuted(result); - assertions.assertCherryPickJobExecuted(result, actor, '1234', true, newVersion); + runsOn: 'ubuntu-latest', + }, + }; + act = utils.setUpActParams( + act, + event, + null, + { + OS_BOTIFY_TOKEN: 'dummy_token', + LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', + SLACK_WEBHOOK: 'dummy_slack_webhook', + }, + 'dummy_github_token', + null, + { + PULL_REQUEST_NUMBER: '1234', + }, + ); + const result = await act.runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), + mockSteps: testMockSteps, + actor, + logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), + mockJobs: testMockJobs, }); - }); - describe('version do not match', () => { - const versionsMatch = false; - it('workflow executes, new version created, PR auto-assigned and commented, approved and merged automatically', async () => { - const repoPath = mockGithub.repo.getPath('testCherryPickWorkflowRepo') || ''; - const workflowPath = path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'); - let act = new eAct.ExtendedAct(repoPath, workflowPath); - const testMockSteps = { - validateActor: mocks.CHERRYPICK__VALIDATEACTOR__TRUE__STEP_MOCKS, - }; - testMockSteps.cherryPick = mocks.getCherryPickMockSteps(versionsMatch, mergeConflicts); - const testMockJobs = { - createNewVersion: { - steps: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, - outputs: { - // eslint-disable-next-line no-template-curly-in-string - NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', - }, - runsOn: 'ubuntu-latest', - }, - }; - act = utils.setUpActParams( - act, - event, - null, - { - OS_BOTIFY_TOKEN: 'dummy_token', - LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', - SLACK_WEBHOOK: 'dummy_slack_webhook', - }, - 'dummy_github_token', - null, - { - PULL_REQUEST_NUMBER: '1234', - NEW_VERSION: newVersion, - }, - ); - const result = await act.runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), - mockSteps: testMockSteps, - actor, - logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), - mockJobs: testMockJobs, - }); - assertions.assertValidateActorJobExecuted(result); - assertions.assertCreateNewVersionJobExecuted(result); - assertions.assertCherryPickJobExecuted(result, actor, '1234', true, newVersion); - }); + assertions.assertValidateActorJobExecuted(result); + assertions.assertCreateNewVersionJobExecuted(result); + assertions.assertCherryPickJobExecuted(result, actor, '1234', true); }); }); - describe('merge conflicts', () => { - const mergeConflicts = true; - describe('version match', () => { - const versionsMatch = true; - it('workflow executes, new version created, PR auto-assigned and commented, not merged automatically', async () => { - const repoPath = mockGithub.repo.getPath('testCherryPickWorkflowRepo') || ''; - const workflowPath = path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'); - let act = new eAct.ExtendedAct(repoPath, workflowPath); - const testMockSteps = { - validateActor: mocks.CHERRYPICK__VALIDATEACTOR__TRUE__STEP_MOCKS, - }; - testMockSteps.cherryPick = mocks.getCherryPickMockSteps(versionsMatch, mergeConflicts); - const testMockJobs = { - createNewVersion: { - steps: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, - outputs: { - // eslint-disable-next-line no-template-curly-in-string - NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', - }, - runsOn: 'ubuntu-latest', - }, - }; - act = utils.setUpActParams( - act, - event, - null, - { - OS_BOTIFY_TOKEN: 'dummy_token', - LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', - SLACK_WEBHOOK: 'dummy_slack_webhook', + describe('version do not match', () => { + const versionsMatch = false; + it('workflow executes, PR auto-assigned and commented, approved and merged automatically', async () => { + const repoPath = mockGithub.repo.getPath('testCherryPickWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + const testMockSteps = { + validateActor: mocks.CHERRYPICK__VALIDATEACTOR__TRUE__STEP_MOCKS, + }; + testMockSteps.cherryPick = mocks.getCherryPickMockSteps(versionsMatch, mergeConflicts); + const testMockJobs = { + createNewVersion: { + steps: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, + outputs: { + // eslint-disable-next-line no-template-curly-in-string + NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', }, - 'dummy_github_token', - null, - { - PULL_REQUEST_NUMBER: '1234', - NEW_VERSION: newVersion, - }, - ); - const result = await act.runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), - mockSteps: testMockSteps, - actor, - logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), - mockJobs: testMockJobs, - }); - - assertions.assertValidateActorJobExecuted(result); - assertions.assertCreateNewVersionJobExecuted(result); - assertions.assertCherryPickJobExecuted(result, actor, '1234', true, newVersion, true); + runsOn: 'ubuntu-latest', + }, + }; + act = utils.setUpActParams( + act, + event, + null, + { + OS_BOTIFY_TOKEN: 'dummy_token', + LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', + SLACK_WEBHOOK: 'dummy_slack_webhook', + }, + 'dummy_github_token', + null, + { + PULL_REQUEST_NUMBER: '1234', + }, + ); + const result = await act.runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), + mockSteps: testMockSteps, + actor, + logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), + mockJobs: testMockJobs, }); - }); - describe('version do not match', () => { - const versionsMatch = false; - it('workflow executes, new version created, PR auto-assigned and commented, not merged automatically', async () => { - const repoPath = mockGithub.repo.getPath('testCherryPickWorkflowRepo') || ''; - const workflowPath = path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'); - let act = new eAct.ExtendedAct(repoPath, workflowPath); - const testMockSteps = { - validateActor: mocks.CHERRYPICK__VALIDATEACTOR__TRUE__STEP_MOCKS, - }; - testMockSteps.cherryPick = mocks.getCherryPickMockSteps(versionsMatch, mergeConflicts); - const testMockJobs = { - createNewVersion: { - steps: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, - outputs: { - // eslint-disable-next-line no-template-curly-in-string - NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', - }, - runsOn: 'ubuntu-latest', - }, - }; - act = utils.setUpActParams( - act, - event, - null, - { - OS_BOTIFY_TOKEN: 'dummy_token', - LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', - SLACK_WEBHOOK: 'dummy_slack_webhook', - }, - 'dummy_github_token', - null, - { - PULL_REQUEST_NUMBER: '1234', - NEW_VERSION: newVersion, - }, - ); - const result = await act.runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), - mockSteps: testMockSteps, - actor, - logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), - mockJobs: testMockJobs, - }); - assertions.assertValidateActorJobExecuted(result); - assertions.assertCreateNewVersionJobExecuted(result); - assertions.assertCherryPickJobExecuted(result, actor, '1234', true, newVersion, true); - }); + assertions.assertValidateActorJobExecuted(result); + assertions.assertCreateNewVersionJobExecuted(result); + assertions.assertCherryPickJobExecuted(result, actor, '1234', true); }); }); }); - - describe('input version set', () => { - const newVersion = '1.2.3'; - describe('no merge conflicts', () => { - const mergeConflicts = false; - describe('version match', () => { - const versionsMatch = true; - it('workflow executes, PR approved and merged automatically', async () => { - const repoPath = mockGithub.repo.getPath('testCherryPickWorkflowRepo') || ''; - const workflowPath = path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'); - let act = new eAct.ExtendedAct(repoPath, workflowPath); - const testMockSteps = { - validateActor: mocks.CHERRYPICK__VALIDATEACTOR__TRUE__STEP_MOCKS, - }; - testMockSteps.cherryPick = mocks.getCherryPickMockSteps(versionsMatch, mergeConflicts); - const testMockJobs = { - createNewVersion: { - steps: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, - outputs: { - // eslint-disable-next-line no-template-curly-in-string - NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', - }, - runsOn: 'ubuntu-latest', + describe('merge conflicts', () => { + const mergeConflicts = true; + describe('version match', () => { + const versionsMatch = true; + it('workflow executes, PR auto-assigned and commented, not merged automatically', async () => { + const repoPath = mockGithub.repo.getPath('testCherryPickWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + const testMockSteps = { + validateActor: mocks.CHERRYPICK__VALIDATEACTOR__TRUE__STEP_MOCKS, + }; + testMockSteps.cherryPick = mocks.getCherryPickMockSteps(versionsMatch, mergeConflicts); + const testMockJobs = { + createNewVersion: { + steps: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, + outputs: { + // eslint-disable-next-line no-template-curly-in-string + NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', }, - }; - act = utils.setUpActParams( - act, - event, - null, - { - OS_BOTIFY_TOKEN: 'dummy_token', - LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', - SLACK_WEBHOOK: 'dummy_slack_webhook', - }, - 'dummy_github_token', - null, - { - PULL_REQUEST_NUMBER: '1234', - NEW_VERSION: newVersion, - }, - ); - const result = await act.runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), - mockSteps: testMockSteps, - actor, - logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), - mockJobs: testMockJobs, - }); - - assertions.assertValidateActorJobExecuted(result); - assertions.assertCreateNewVersionJobExecuted(result, false); - assertions.assertCherryPickJobExecuted(result, actor, '1234', true, newVersion); + runsOn: 'ubuntu-latest', + }, + }; + act = utils.setUpActParams( + act, + event, + null, + { + OS_BOTIFY_TOKEN: 'dummy_token', + LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', + SLACK_WEBHOOK: 'dummy_slack_webhook', + }, + 'dummy_github_token', + null, + { + PULL_REQUEST_NUMBER: '1234', + }, + ); + const result = await act.runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), + mockSteps: testMockSteps, + actor, + logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), + mockJobs: testMockJobs, }); - }); - describe('version do not match', () => { - const versionsMatch = false; - it('workflow executes, PR auto-assigned and commented, approved and merged automatically', async () => { - const repoPath = mockGithub.repo.getPath('testCherryPickWorkflowRepo') || ''; - const workflowPath = path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'); - let act = new eAct.ExtendedAct(repoPath, workflowPath); - const testMockSteps = { - validateActor: mocks.CHERRYPICK__VALIDATEACTOR__TRUE__STEP_MOCKS, - }; - testMockSteps.cherryPick = mocks.getCherryPickMockSteps(versionsMatch, mergeConflicts); - const testMockJobs = { - createNewVersion: { - steps: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, - outputs: { - // eslint-disable-next-line no-template-curly-in-string - NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', - }, - runsOn: 'ubuntu-latest', - }, - }; - act = utils.setUpActParams( - act, - event, - null, - { - OS_BOTIFY_TOKEN: 'dummy_token', - LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', - SLACK_WEBHOOK: 'dummy_slack_webhook', - }, - 'dummy_github_token', - null, - { - PULL_REQUEST_NUMBER: '1234', - NEW_VERSION: newVersion, - }, - ); - const result = await act.runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), - mockSteps: testMockSteps, - actor, - logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), - mockJobs: testMockJobs, - }); - assertions.assertValidateActorJobExecuted(result); - assertions.assertCreateNewVersionJobExecuted(result, false); - assertions.assertCherryPickJobExecuted(result, actor, '1234', true, newVersion); - }); + assertions.assertValidateActorJobExecuted(result); + assertions.assertCreateNewVersionJobExecuted(result); + assertions.assertCherryPickJobExecuted(result, actor, '1234', true, true); }); }); - describe('merge conflicts', () => { - const mergeConflicts = true; - describe('version match', () => { - const versionsMatch = true; - it('workflow executes, PR auto-assigned and commented, not merged automatically', async () => { - const repoPath = mockGithub.repo.getPath('testCherryPickWorkflowRepo') || ''; - const workflowPath = path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'); - let act = new eAct.ExtendedAct(repoPath, workflowPath); - const testMockSteps = { - validateActor: mocks.CHERRYPICK__VALIDATEACTOR__TRUE__STEP_MOCKS, - }; - testMockSteps.cherryPick = mocks.getCherryPickMockSteps(versionsMatch, mergeConflicts); - const testMockJobs = { - createNewVersion: { - steps: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, - outputs: { - // eslint-disable-next-line no-template-curly-in-string - NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', - }, - runsOn: 'ubuntu-latest', + describe('version do not match', () => { + const versionsMatch = false; + it('workflow executes, PR auto-assigned and commented, not merged automatically', async () => { + const repoPath = mockGithub.repo.getPath('testCherryPickWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + const testMockSteps = { + validateActor: mocks.CHERRYPICK__VALIDATEACTOR__TRUE__STEP_MOCKS, + }; + testMockSteps.cherryPick = mocks.getCherryPickMockSteps(versionsMatch, mergeConflicts); + const testMockJobs = { + createNewVersion: { + steps: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, + outputs: { + // eslint-disable-next-line no-template-curly-in-string + NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', }, - }; - act = utils.setUpActParams( - act, - event, - null, - { - OS_BOTIFY_TOKEN: 'dummy_token', - LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', - SLACK_WEBHOOK: 'dummy_slack_webhook', - }, - 'dummy_github_token', - null, - { - PULL_REQUEST_NUMBER: '1234', - NEW_VERSION: newVersion, - }, - ); - const result = await act.runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), - mockSteps: testMockSteps, - actor, - logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), - mockJobs: testMockJobs, - }); - - assertions.assertValidateActorJobExecuted(result); - assertions.assertCreateNewVersionJobExecuted(result, false); - assertions.assertCherryPickJobExecuted(result, actor, '1234', true, newVersion, true); + runsOn: 'ubuntu-latest', + }, + }; + act = utils.setUpActParams( + act, + event, + null, + { + OS_BOTIFY_TOKEN: 'dummy_token', + LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', + SLACK_WEBHOOK: 'dummy_slack_webhook', + }, + 'dummy_github_token', + null, + { + PULL_REQUEST_NUMBER: '1234', + }, + ); + const result = await act.runEvent(event, { + workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), + mockSteps: testMockSteps, + actor, + logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), + mockJobs: testMockJobs, }); - }); - describe('version do not match', () => { - const versionsMatch = false; - it('workflow executes, PR auto-assigned and commented, not merged automatically', async () => { - const repoPath = mockGithub.repo.getPath('testCherryPickWorkflowRepo') || ''; - const workflowPath = path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'); - let act = new eAct.ExtendedAct(repoPath, workflowPath); - const testMockSteps = { - validateActor: mocks.CHERRYPICK__VALIDATEACTOR__TRUE__STEP_MOCKS, - }; - testMockSteps.cherryPick = mocks.getCherryPickMockSteps(versionsMatch, mergeConflicts); - const testMockJobs = { - createNewVersion: { - steps: mocks.CHERRYPICK__CREATENEWVERSION__STEP_MOCKS, - outputs: { - // eslint-disable-next-line no-template-curly-in-string - NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', - }, - runsOn: 'ubuntu-latest', - }, - }; - act = utils.setUpActParams( - act, - event, - null, - { - OS_BOTIFY_TOKEN: 'dummy_token', - LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', - SLACK_WEBHOOK: 'dummy_slack_webhook', - }, - 'dummy_github_token', - null, - { - PULL_REQUEST_NUMBER: '1234', - NEW_VERSION: newVersion, - }, - ); - const result = await act.runEvent(event, { - workflowFile: path.join(repoPath, '.github', 'workflows', 'cherryPick.yml'), - mockSteps: testMockSteps, - actor, - logFile: utils.getLogFilePath('cherryPick', expect.getState().currentTestName), - mockJobs: testMockJobs, - }); - assertions.assertValidateActorJobExecuted(result); - assertions.assertCreateNewVersionJobExecuted(result, false); - assertions.assertCherryPickJobExecuted(result, actor, '1234', true, newVersion, true); - }); + assertions.assertValidateActorJobExecuted(result); + assertions.assertCreateNewVersionJobExecuted(result); + assertions.assertCherryPickJobExecuted(result, actor, '1234', true, true); }); }); }); @@ -575,7 +359,6 @@ describe('test workflow cherryPick', () => { null, { PULL_REQUEST_NUMBER: '1234', - NEW_VERSION: '', }, ); const testMockSteps = { diff --git a/workflow_tests/mocks/cherryPickMocks.js b/workflow_tests/mocks/cherryPickMocks.js index 3f9242c806aa..327b17e7bab1 100644 --- a/workflow_tests/mocks/cherryPickMocks.js +++ b/workflow_tests/mocks/cherryPickMocks.js @@ -37,14 +37,26 @@ const CHERRYPICK__CREATENEWVERSION__STEP_MOCKS = [CHERRYPICK__CREATENEWVERSION__ // cherrypick const CHERRYPICK__CHERRYPICK__CHECKOUT_STAGING_BRANCH__STEP_MOCK = utils.createMockStep('Checkout staging branch', 'Checking out staging branch', 'CHERRYPICK', ['ref', 'token'], []); const CHERRYPICK__CHERRYPICK__SET_UP_GIT_FOR_OSBOTIFY__STEP_MOCK = utils.createMockStep('Set up git for OSBotify', 'Setting up git for OSBotify', 'CHERRYPICK', ['GPG_PASSPHRASE'], []); -const CHERRYPICK__CHERRYPICK__GET_MERGE_COMMIT_FOR_CP_PULL_REQUEST__STEP_MOCK = utils.createMockStep( - 'Get merge commit for CP pull request', - 'Getting merge commit for CP pull request', +const CHERRYPICK__CHERRYPICK__GET_VERSION_BUMP_COMMIT__STEP_MOCK = utils.createMockStep('Get version bump commit', 'Get version bump commit', 'CHERRYPICK', [], [], {VERSION_BUMP_SHA: 'version_bump_sha'}); +const CHERRYPICK__CHERRYPICK__GET_MERGE_COMMIT_FOR_PULL_REQUEST_TO_CP__STEP_MOCK = utils.createMockStep( + 'Get merge commit for pull request to CP', + 'Get merge commit for pull request to CP', 'CHERRYPICK', ['GITHUB_TOKEN', 'USER', 'PULL_REQUEST_NUMBER'], [], {MERGE_ACTOR: '@dummyauthor'}, ); +const CHERRYPICK__CHERRYPICK__GET_PREVIOUS_APP_VERSION__STEP_MOCK = utils.createMockStep( + 'Get previous app version', + 'Get previous app version', + 'CHERRYPICK', + ['SEMVER_LEVEL'], +); +const CHERRYPICK__CHERRYPICK__FETCH_HISTORY_OF_RELEVANT_REFS__STEP_MOCK = utils.createMockStep( + 'Fetch history of relevant refs', + 'Fetch history of relevant refs', + 'CHERRYPICK', +); const CHERRYPICK__CHERRYPICK__CHERRY_PICK_THE_VERSION_BUMP_TO_STAGING__STEP_MOCK = utils.createMockStep( 'Cherry-pick the version-bump to staging', 'Cherry-picking the version-bump to staging', @@ -88,7 +100,10 @@ const CHERRYPICK__CHERRYPICK__ANNOUNCES_A_CP_FAILURE_IN_THE_ANNOUNCE_SLACK_ROOM_ const getCherryPickMockSteps = (upToDate, hasConflicts) => [ CHERRYPICK__CHERRYPICK__CHECKOUT_STAGING_BRANCH__STEP_MOCK, CHERRYPICK__CHERRYPICK__SET_UP_GIT_FOR_OSBOTIFY__STEP_MOCK, - CHERRYPICK__CHERRYPICK__GET_MERGE_COMMIT_FOR_CP_PULL_REQUEST__STEP_MOCK, + CHERRYPICK__CHERRYPICK__GET_VERSION_BUMP_COMMIT__STEP_MOCK, + CHERRYPICK__CHERRYPICK__GET_MERGE_COMMIT_FOR_PULL_REQUEST_TO_CP__STEP_MOCK, + CHERRYPICK__CHERRYPICK__GET_PREVIOUS_APP_VERSION__STEP_MOCK, + CHERRYPICK__CHERRYPICK__FETCH_HISTORY_OF_RELEVANT_REFS__STEP_MOCK, CHERRYPICK__CHERRYPICK__CHERRY_PICK_THE_VERSION_BUMP_TO_STAGING__STEP_MOCK, hasConflicts ? CHERRYPICK__CHERRYPICK__CHERRY_PICK_THE_MERGE_COMMIT_OF_TARGET_PR_TO_NEW_BRANCH__HAS_CONFLICTS__STEP_MOCK From 6ce1fed5dd5ef6f8e2d7d598987bd7c5ce75e2de Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Wed, 12 Jul 2023 11:58:10 +0200 Subject: [PATCH 112/504] Fix deploy.test.js Fixes after merging with main See: https://github.com/Expensify/App/issues/13604 --- .github/workflows/deploy.yml | 2 +- workflow_tests/assertions/deployAssertions.js | 3 +-- workflow_tests/mocks/deployMocks.js | 4 +--- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 15ceb20ef92c..f2ff67680940 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -31,7 +31,7 @@ jobs: if: github.ref == 'refs/heads/production' steps: - name: Checkout - - uses: actions/checkout@v3 + uses: actions/checkout@v3 with: ref: production token: ${{ secrets.OS_BOTIFY_TOKEN }} diff --git a/workflow_tests/assertions/deployAssertions.js b/workflow_tests/assertions/deployAssertions.js index 7931f20db7cb..bff99298bde5 100644 --- a/workflow_tests/assertions/deployAssertions.js +++ b/workflow_tests/assertions/deployAssertions.js @@ -23,11 +23,10 @@ const assertDeployStagingJobExecuted = (workflowResult, didExecute = true) => { const assertDeployProductionJobExecuted = (workflowResult, didExecute = true) => { const steps = [ utils.createStepAssertion('Checkout', true, null, 'DEPLOY_PRODUCTION', 'Checking out', [ - {key: 'fetch-depth', value: '0'}, + {key: 'ref', value: 'production'}, {key: 'token', value: '***'}, ]), utils.createStepAssertion('Setup git for OSBotify', true, null, 'DEPLOY_PRODUCTION', 'Setting up git for OSBotify', [{key: 'GPG_PASSPHRASE', value: '***'}]), - utils.createStepAssertion('Checkout production branch', true, null, 'DEPLOY_PRODUCTION', 'Checking out production branch'), utils.createStepAssertion('Get current app version', true, null, 'DEPLOY_PRODUCTION', 'Getting current app version'), utils.createStepAssertion('Get Release Pull Request List', true, null, 'DEPLOY_PRODUCTION', 'Getting release PR list', [ {key: 'TAG', value: '1.2.3'}, diff --git a/workflow_tests/mocks/deployMocks.js b/workflow_tests/mocks/deployMocks.js index 997918fe9d91..dfec48ca7dc3 100644 --- a/workflow_tests/mocks/deployMocks.js +++ b/workflow_tests/mocks/deployMocks.js @@ -6,9 +6,8 @@ const DEPLOY_STAGING__TAG_VERSION__STEP_MOCK = utils.createMockStep('Tag version const DEPLOY_STAGING__PUSH_TAG__STEP_MOCK = utils.createMockStep('🚀 Push tags to trigger staging deploy 🚀', 'Pushing tag to trigger staging deploy', 'DEPLOY_STAGING'); const DEPLOY_STAGING_STEP_MOCKS = [DEPLOY_STAGING__CHECKOUT__STEP_MOCK, DEPLOY_STAGING__SETUP_GIT__STEP_MOCK, DEPLOY_STAGING__TAG_VERSION__STEP_MOCK, DEPLOY_STAGING__PUSH_TAG__STEP_MOCK]; -const DEPLOY_PRODUCTION__CHECKOUT__STEP_MOCK = utils.createMockStep('Checkout', 'Checking out', 'DEPLOY_PRODUCTION', ['fetch-depth', 'token']); +const DEPLOY_PRODUCTION__CHECKOUT__STEP_MOCK = utils.createMockStep('Checkout', 'Checking out', 'DEPLOY_PRODUCTION', ['ref', 'token']); const DEPLOY_PRODUCTION__SETUP_GIT__STEP_MOCK = utils.createMockStep('Setup git for OSBotify', 'Setting up git for OSBotify', 'DEPLOY_PRODUCTION', ['GPG_PASSPHRASE']); -const DEPLOY_PRODUCTION__CHECKOUT_PRODUCTION__STEP_MOCK = utils.createMockStep('Checkout production branch', 'Checking out production branch', 'DEPLOY_PRODUCTION'); const DEPLOY_PRODUCTION__CURRENT_APP_VERSION__STEP_MOCK = utils.createMockStep('Get current app version', 'Getting current app version', 'DEPLOY_PRODUCTION', null, null, null, { PRODUCTION_VERSION: '1.2.3', }); @@ -33,7 +32,6 @@ const DEPLOY_PRODUCTION__CREATE_RELEASE__STEP_MOCK = utils.createMockStep( const DEPLOY_PRODUCTION_STEP_MOCKS = [ DEPLOY_PRODUCTION__CHECKOUT__STEP_MOCK, DEPLOY_PRODUCTION__SETUP_GIT__STEP_MOCK, - DEPLOY_PRODUCTION__CHECKOUT_PRODUCTION__STEP_MOCK, DEPLOY_PRODUCTION__CURRENT_APP_VERSION__STEP_MOCK, DEPLOY_PRODUCTION__RELEASE_PR_LIST__STEP_MOCK, DEPLOY_PRODUCTION__GENERATE_RELEASE_BODY__STEP_MOCK, From fc12b0f98c7e10192a311a88fa65fad8868beeb4 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Wed, 12 Jul 2023 12:16:05 +0200 Subject: [PATCH 113/504] Fix deployBlocker.test.js Fixes after merging with main See: https://github.com/Expensify/App/issues/13604 --- .github/workflows/deployBlocker.yml | 2 +- workflow_tests/assertions/deployBlockerAssertions.js | 1 - workflow_tests/mocks/deployBlockerMocks.js | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/deployBlocker.yml b/.github/workflows/deployBlocker.yml index 9d3523d018d2..f42d19ca8241 100644 --- a/.github/workflows/deployBlocker.yml +++ b/.github/workflows/deployBlocker.yml @@ -12,7 +12,7 @@ jobs: steps: - name: Checkout - - uses: actions/checkout@v3 + uses: actions/checkout@v3 with: token: ${{ secrets.GITHUB_TOKEN }} diff --git a/workflow_tests/assertions/deployBlockerAssertions.js b/workflow_tests/assertions/deployBlockerAssertions.js index d3ca3e33209f..18dae2277c60 100644 --- a/workflow_tests/assertions/deployBlockerAssertions.js +++ b/workflow_tests/assertions/deployBlockerAssertions.js @@ -9,7 +9,6 @@ const assertDeployBlockerJobExecuted = (workflowResult, issueTitle, issueNumber, 'DEPLOYBLOCKER', 'Checkout', [ - {key: 'fetch-depth', value: '0'}, {key: 'token', value: '***'}, ], [], diff --git a/workflow_tests/mocks/deployBlockerMocks.js b/workflow_tests/mocks/deployBlockerMocks.js index 820e441a00dc..fbfc676f7701 100644 --- a/workflow_tests/mocks/deployBlockerMocks.js +++ b/workflow_tests/mocks/deployBlockerMocks.js @@ -1,7 +1,7 @@ const utils = require('../utils/utils'); // deployblocker -const DEPLOYBLOCKER__DEPLOYBLOCKER__CHECKOUT__STEP_MOCK = utils.createMockStep('Checkout', 'Checkout', 'DEPLOYBLOCKER', ['fetch-depth', 'token'], []); +const DEPLOYBLOCKER__DEPLOYBLOCKER__CHECKOUT__STEP_MOCK = utils.createMockStep('Checkout', 'Checkout', 'DEPLOYBLOCKER', ['token'], []); const DEPLOYBLOCKER__DEPLOYBLOCKER__GET_URL_TITLE_AND_NUMBER_OF_NEW_DEPLOY_BLOCKER_ISSUE__STEP_MOCK = utils.createMockStep( 'Get URL, title, & number of new deploy blocker (issue)', 'Get URL, title and number of new deploy blocker - issue', From 2518b36dce815eb4d39b8099bf4667118b4d4a4d Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Wed, 12 Jul 2023 12:19:35 +0200 Subject: [PATCH 114/504] Fix lockDeploys.test.js Fixes after merging with main See: https://github.com/Expensify/App/issues/13604 --- .github/workflows/lockDeploys.yml | 3 +-- workflow_tests/assertions/lockDeploysAssertions.js | 2 -- workflow_tests/mocks/lockDeploysMocks.js | 2 +- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/lockDeploys.yml b/.github/workflows/lockDeploys.yml index 3b95eabd8ec8..6ca025bb2a25 100644 --- a/.github/workflows/lockDeploys.yml +++ b/.github/workflows/lockDeploys.yml @@ -9,9 +9,8 @@ jobs: if: ${{ github.event.label.name == '🔐 LockCashDeploys 🔐' && contains(github.event.issue.labels.*.name, 'StagingDeployCash') && github.actor != 'OSBotify' }} runs-on: macos-12 steps: - # Version: 2.3.4 - name: Checkout - - uses: actions/checkout@v3 + uses: actions/checkout@v3 with: ref: main token: ${{ secrets.OS_BOTIFY_TOKEN }} diff --git a/workflow_tests/assertions/lockDeploysAssertions.js b/workflow_tests/assertions/lockDeploysAssertions.js index 59ce833fa1e0..874076dc3a28 100644 --- a/workflow_tests/assertions/lockDeploysAssertions.js +++ b/workflow_tests/assertions/lockDeploysAssertions.js @@ -10,7 +10,6 @@ const assertlockStagingDeploysJobExecuted = (workflowResult, didExecute = true, 'Checking out', [ {key: 'ref', value: 'main'}, - {key: 'fetch-depth', value: '0'}, {key: 'token', value: '***'}, ], [], @@ -58,7 +57,6 @@ const assertlockStagingDeploysJobFailedAfterFirstStep = (workflowResult) => { 'Checking out', [ {key: 'ref', value: 'main'}, - {key: 'fetch-depth', value: '0'}, {key: 'token', value: '***'}, ], [], diff --git a/workflow_tests/mocks/lockDeploysMocks.js b/workflow_tests/mocks/lockDeploysMocks.js index 0dd5c11f58ed..bb6246a2e1d9 100644 --- a/workflow_tests/mocks/lockDeploysMocks.js +++ b/workflow_tests/mocks/lockDeploysMocks.js @@ -1,7 +1,7 @@ const utils = require('../utils/utils'); // lockstagingdeploys -const LOCKDEPLOYS__LOCKSTAGINGDEPLOYS__CHECKOUT__STEP_MOCK = utils.createMockStep('Checkout', 'Checking out', 'LOCKSTAGINGDEPLOYS', ['ref', 'fetch-depth', 'token'], []); +const LOCKDEPLOYS__LOCKSTAGINGDEPLOYS__CHECKOUT__STEP_MOCK = utils.createMockStep('Checkout', 'Checking out', 'LOCKSTAGINGDEPLOYS', ['ref', 'token'], []); const LOCKDEPLOYS__LOCKSTAGINGDEPLOYS__WAIT_FOR_STAGING_DEPLOYS_TO_FINISH__STEP_MOCK = utils.createMockStep( 'Wait for staging deploys to finish', 'Waiting for staging deploys to finish', From d6c9bac7cb47830d8264ee943d5ac27fa228eef9 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Wed, 12 Jul 2023 12:25:37 +0200 Subject: [PATCH 115/504] Fix platformDeploy.test.js Fixes after merging with main See: https://github.com/Expensify/App/issues/13604 --- .../assertions/platformDeployAssertions.js | 12 ++++++------ workflow_tests/mocks/platformDeployMocks.js | 10 +++++----- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/workflow_tests/assertions/platformDeployAssertions.js b/workflow_tests/assertions/platformDeployAssertions.js index 4f33066d7d89..36a4667eca95 100644 --- a/workflow_tests/assertions/platformDeployAssertions.js +++ b/workflow_tests/assertions/platformDeployAssertions.js @@ -14,7 +14,7 @@ const assertVerifyActorJobExecuted = (workflowResult, username, didExecute = tru const assertAndroidJobExecuted = (workflowResult, didExecute = true, isProduction = true, isSuccessful = true) => { const steps = [ - utils.createStepAssertion('Checkout', true, null, 'ANDROID', 'Checking out', [{key: 'fetch-depth', value: '0'}]), + utils.createStepAssertion('Checkout', true, null, 'ANDROID', 'Checking out'), utils.createStepAssertion('Setup Node', true, null, 'ANDROID', 'Setting up Node'), utils.createStepAssertion('Setup Ruby', true, null, 'ANDROID', 'Setting up Ruby', [ {key: 'ruby-version', value: '2.7'}, @@ -82,7 +82,7 @@ const assertAndroidJobExecuted = (workflowResult, didExecute = true, isProductio const assertDesktopJobExecuted = (workflowResult, didExecute = true, isProduction = true) => { const steps = [ - utils.createStepAssertion('Checkout', true, null, 'DESKTOP', 'Checking out', [{key: 'fetch-depth', value: '0'}]), + utils.createStepAssertion('Checkout', true, null, 'DESKTOP', 'Checking out'), utils.createStepAssertion('Setup Node', true, null, 'DESKTOP', 'Setting up Node'), utils.createStepAssertion('Decrypt Developer ID Certificate', true, null, 'DESKTOP', 'Decrypting developer id certificate', null, [ {key: 'DEVELOPER_ID_SECRET_PASSPHRASE', value: '***'}, @@ -123,7 +123,7 @@ const assertDesktopJobExecuted = (workflowResult, didExecute = true, isProductio const assertIOSJobExecuted = (workflowResult, didExecute = true, isProduction = true, isSuccessful = true) => { const steps = [ - utils.createStepAssertion('Checkout', true, null, 'IOS', 'Checking out', [{key: 'fetch-depth', value: '0'}]), + utils.createStepAssertion('Checkout', true, null, 'IOS', 'Checking out'), utils.createStepAssertion('Setup Node', true, null, 'IOS', 'Setting up Node'), utils.createStepAssertion('Setup Ruby', true, null, 'IOS', 'Setting up Ruby', [ {key: 'ruby-version', value: '2.7'}, @@ -132,7 +132,7 @@ const assertIOSJobExecuted = (workflowResult, didExecute = true, isProduction = utils.createStepAssertion('Install cocoapods', true, null, 'IOS', 'Installing cocoapods', [ {key: 'timeout_minutes', value: '10'}, {key: 'max_attempts', value: '5'}, - {key: 'command', value: 'cd ios && pod install'}, + {key: 'command', value: 'cd ios && bundle exec pod install'}, ]), utils.createStepAssertion('Decrypt profile', true, null, 'IOS', 'Decrypting profile', null, [{key: 'LARGE_SECRET_PASSPHRASE', value: '***'}]), utils.createStepAssertion('Decrypt certificate', true, null, 'IOS', 'Decrypting certificate', null, [{key: 'LARGE_SECRET_PASSPHRASE', value: '***'}]), @@ -197,7 +197,7 @@ const assertIOSJobExecuted = (workflowResult, didExecute = true, isProduction = const assertWebJobExecuted = (workflowResult, didExecute = true, isProduction = true) => { const steps = [ - utils.createStepAssertion('Checkout', true, null, 'WEB', 'Checking out', [{key: 'fetch-depth', value: '0'}]), + utils.createStepAssertion('Checkout', true, null, 'WEB', 'Checking out'), utils.createStepAssertion('Setup Node', true, null, 'WEB', 'Setting up Node'), utils.createStepAssertion('Setup Cloudflare CLI', true, null, 'WEB', 'Setting up Cloudflare CLI'), utils.createStepAssertion('Configure AWS Credentials', true, null, 'WEB', 'Configuring AWS credentials', [ @@ -301,7 +301,7 @@ const assertPostSlackOnSuccessJobExecuted = (workflowResult, didExecute = true, const assertPostGithubCommentJobExecuted = (workflowResult, didExecute = true, isProduction = true, didDeploy = true) => { const steps = [ - utils.createStepAssertion('Checkout', true, null, 'POST_GITHUB_COMMENT', 'Checking out', [{key: 'fetch-depth', value: '0'}]), + utils.createStepAssertion('Checkout', true, null, 'POST_GITHUB_COMMENT', 'Checking out'), utils.createStepAssertion('Setup Node', true, null, 'POST_GITHUB_COMMENT', 'Setting up Node'), utils.createStepAssertion('Set version', true, null, 'POST_GITHUB_COMMENT', 'Setting version'), utils.createStepAssertion('Get Release Pull Request List', true, null, 'POST_GITHUB_COMMENT', 'Getting release pull request list', [ diff --git a/workflow_tests/mocks/platformDeployMocks.js b/workflow_tests/mocks/platformDeployMocks.js index 2e9996b053d2..56787ec5afa6 100644 --- a/workflow_tests/mocks/platformDeployMocks.js +++ b/workflow_tests/mocks/platformDeployMocks.js @@ -21,7 +21,7 @@ const PLATFORM_DEPLOY__VALIDATE_ACTOR__TEAM_MEMBER__STEP_MOCKS = [PLATFORM_DEPLO const PLATFORM_DEPLOY__VALIDATE_ACTOR__OUTSIDER__STEP_MOCKS = [PLATFORM_DEPLOY__VALIDATE_ACTOR__CHECK_USER_DEPLOYER__OUTSIDER__STEP_MOCK]; // android -const PLATFORM_DEPLOY__ANDROID__CHECKOUT__STEP_MOCK = utils.createMockStep('Checkout', 'Checking out', 'ANDROID', ['fetch-depth']); +const PLATFORM_DEPLOY__ANDROID__CHECKOUT__STEP_MOCK = utils.createMockStep('Checkout', 'Checking out', 'ANDROID'); const PLATFORM_DEPLOY__ANDROID__SETUP_NODE__STEP_MOCK = utils.createMockStep('Setup Node', 'Setting up Node', 'ANDROID'); const PLATFORM_DEPLOY__ANDROID__SETUP_RUBY__STEP_MOCK = utils.createMockStep('Setup Ruby', 'Setting up Ruby', 'ANDROID', ['ruby-version', 'bundler-cache']); const PLATFORM_DEPLOY__ANDROID__DECRYPT_KEYSTORE__STEP_MOCK = utils.createMockStep('Decrypt keystore', 'Decrypting keystore', 'ANDROID', null, ['LARGE_SECRET_PASSPHRASE']); @@ -62,7 +62,7 @@ const PLATFORM_DEPLOY__ANDROID__STEP_MOCKS = [ ]; // desktop -const PLATFORM_DEPLOY__DESKTOP__CHECKOUT__STEP_MOCK = utils.createMockStep('Checkout', 'Checking out', 'DESKTOP', ['fetch-depth']); +const PLATFORM_DEPLOY__DESKTOP__CHECKOUT__STEP_MOCK = utils.createMockStep('Checkout', 'Checking out', 'DESKTOP'); const PLATFORM_DEPLOY__DESKTOP__SETUP_NODE__STEP_MOCK = utils.createMockStep('Setup Node', 'Setting up Node', 'DESKTOP'); const PLATFORM_DEPLOY__DESKTOP__DECRYPT_ID__STEP_MOCK = utils.createMockStep('Decrypt Developer ID Certificate', 'Decrypting developer id certificate', 'DESKTOP', null, [ 'DEVELOPER_ID_SECRET_PASSPHRASE', @@ -92,7 +92,7 @@ const PLATFORM_DEPLOY__DESKTOP__STEP_MOCKS = [ ]; // ios -const PLATFORM_DEPLOY__IOS__CHECKOUT__STEP_MOCK = utils.createMockStep('Checkout', 'Checking out', 'IOS', ['fetch-depth']); +const PLATFORM_DEPLOY__IOS__CHECKOUT__STEP_MOCK = utils.createMockStep('Checkout', 'Checking out', 'IOS'); const PLATFORM_DEPLOY__IOS__SETUP_NODE__STEP_MOCK = utils.createMockStep('Setup Node', 'Setting up Node', 'IOS'); const PLATFORM_DEPLOY__IOS__SETUP_RUBY__STEP_MOCK = utils.createMockStep('Setup Ruby', 'Setting up Ruby', 'IOS', ['ruby-version', 'bundler-cache']); const PLATFORM_DEPLOY__IOS__COCOAPODS__STEP_MOCK = utils.createMockStep('Install cocoapods', 'Installing cocoapods', 'IOS', ['timeout_minutes', 'max_attempts', 'command']); @@ -135,7 +135,7 @@ const PLATFORM_DEPLOY__IOS__STEP_MOCKS = [ ]; // web -const PLATFORM_DEPLOY__WEB__CHECKOUT__STEP_MOCK = utils.createMockStep('Checkout', 'Checking out', 'WEB', ['fetch-depth']); +const PLATFORM_DEPLOY__WEB__CHECKOUT__STEP_MOCK = utils.createMockStep('Checkout', 'Checking out', 'WEB'); const PLATFORM_DEPLOY__WEB__SETUP_NODE__STEP_MOCK = utils.createMockStep('Setup Node', 'Setting up Node', 'WEB'); const PLATFORM_DEPLOY__WEB__CLOUDFLARE__STEP_MOCK = utils.createMockStep('Setup Cloudflare CLI', 'Setting up Cloudflare CLI', 'WEB'); const PLATFORM_DEPLOY__WEB__AWS_CREDENTIALS__STEP_MOCK = utils.createMockStep('Configure AWS Credentials', 'Configuring AWS credentials', 'WEB', [ @@ -204,7 +204,7 @@ const PLATFORM_DEPLOY__POST_SLACK_SUCCESS__STEP_MOCKS = [ ]; // post github comment -const PLATFORM_DEPLOY__POST_GIHUB_COMMENT__CHECKOUT__STEP_MOCK = utils.createMockStep('Checkout', 'Checking out', 'POST_GITHUB_COMMENT', ['fetch-depth']); +const PLATFORM_DEPLOY__POST_GIHUB_COMMENT__CHECKOUT__STEP_MOCK = utils.createMockStep('Checkout', 'Checking out', 'POST_GITHUB_COMMENT'); const PLATFORM_DEPLOY__POST_GIHUB_COMMENT__SETUP_NODE__STEP_MOCK = utils.createMockStep('Setup Node', 'Setting up Node', 'POST_GITHUB_COMMENT'); const PLATFORM_DEPLOY__POST_GIHUB_COMMENT__SET_VERSION__STEP_MOCK = utils.createMockStep('Set version', 'Setting version', 'POST_GITHUB_COMMENT', null, null, null, {VERSION: '1.2.3'}); const PLATFORM_DEPLOY__POST_GIHUB_COMMENT__GET_PR_LIST__STEP_MOCK = utils.createMockStep( From 277a02ea0899f450dd5524b43692cb30499b29bd Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Wed, 12 Jul 2023 12:32:02 +0200 Subject: [PATCH 116/504] Fix preDeploy.test.js Fixes after merging with main See: https://github.com/Expensify/App/issues/13604 --- workflow_tests/assertions/preDeployAssertions.js | 1 - workflow_tests/mocks/preDeployMocks.js | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/workflow_tests/assertions/preDeployAssertions.js b/workflow_tests/assertions/preDeployAssertions.js index edf2bbe51389..a93172abf200 100644 --- a/workflow_tests/assertions/preDeployAssertions.js +++ b/workflow_tests/assertions/preDeployAssertions.js @@ -164,7 +164,6 @@ const assertUpdateStagingJobExecuted = (workflowResult, didExecute = true) => { ]), utils.createStepAssertion('Checkout main', true, null, 'UPDATE_STAGING', 'Checkout main', [ {key: 'ref', value: 'main'}, - {key: 'fetch-depth', value: '0'}, {key: 'token', value: '***'}, ]), utils.createStepAssertion('Setup Git for OSBotify', true, null, 'UPDATE_STAGING', 'Setup Git for OSBotify', [{key: 'GPG_PASSPHRASE', value: '***'}]), diff --git a/workflow_tests/mocks/preDeployMocks.js b/workflow_tests/mocks/preDeployMocks.js index bef658a55d15..cfc868debadd 100644 --- a/workflow_tests/mocks/preDeployMocks.js +++ b/workflow_tests/mocks/preDeployMocks.js @@ -70,7 +70,7 @@ const CREATE_NEW_VERSION_JOB_MOCK_STEPS = [CREATE_NEW_VERSION_MOCK_STEP]; // update_staging const RUN_TURNSTYLE_MOCK_STEP = utils.createMockStep('Run turnstyle', 'Running turnstyle', 'UPDATE_STAGING', ['poll-interval-seconds'], ['GITHUB_TOKEN']); -const CHECKOUT_MAIN_MOCK_STEP = utils.createMockStep('Checkout main', 'Checkout main', 'UPDATE_STAGING', ['ref', 'fetch-depth', 'token']); +const CHECKOUT_MAIN_MOCK_STEP = utils.createMockStep('Checkout main', 'Checkout main', 'UPDATE_STAGING', ['ref', 'token']); const SETUP_GIT_FOR_OSBOTIFY_MOCK_STEP = utils.createMockStep('Setup Git for OSBotify', 'Setup Git for OSBotify', 'UPDATE_STAGING', ['GPG_PASSPHRASE']); const UPDATE_STAGING_BRANCH_FROM_MAIN_MOCK_STEP = utils.createMockStep('Update staging branch from main', 'Update staging branch from main', 'UPDATE_STAGING'); const TAG_STAGING_MOCK_STEP = utils.createMockStep('Tag staging', 'Tagging staging', 'UPDATE_STAGING'); From 629a68ffbccc847bad1a55ef5be5645fd44ca591 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Wed, 12 Jul 2023 12:40:06 +0200 Subject: [PATCH 117/504] Fix testBuild.test.js Fixes after merging with main See: https://github.com/Expensify/App/issues/13604 --- workflow_tests/assertions/testBuildAssertions.js | 4 +--- workflow_tests/mocks/testBuildMocks.js | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/workflow_tests/assertions/testBuildAssertions.js b/workflow_tests/assertions/testBuildAssertions.js index 9026caaabd4d..b074d4981823 100644 --- a/workflow_tests/assertions/testBuildAssertions.js +++ b/workflow_tests/assertions/testBuildAssertions.js @@ -158,7 +158,7 @@ const assertIOSJobExecuted = (workflowResult, ref = '', didExecute = true, fails [ {key: 'timeout_minutes', value: '10'}, {key: 'max_attempts', value: '5'}, - {key: 'command', value: 'cd ios && pod install'}, + {key: 'command', value: 'cd ios && bundle exec pod install'}, ], [], ), @@ -232,7 +232,6 @@ const assertDesktopJobExecuted = (workflowResult, ref = '', didExecute = true, f 'Checkout', [ {key: 'ref', value: ref}, - {key: 'fetch-depth', value: '0'}, ], [], ), @@ -304,7 +303,6 @@ const assertWebJobExecuted = (workflowResult, ref = '', didExecute = true, fails 'WEB', 'Checkout', [ - {key: 'fetch-depth', value: '0'}, {key: 'ref', value: ref}, ], [], diff --git a/workflow_tests/mocks/testBuildMocks.js b/workflow_tests/mocks/testBuildMocks.js index 18d332e5dedc..8cbf038a21e4 100644 --- a/workflow_tests/mocks/testBuildMocks.js +++ b/workflow_tests/mocks/testBuildMocks.js @@ -129,7 +129,7 @@ const TESTBUILD__IOS__STEP_MOCKS = [ ]; // desktop -const TESTBUILD__DESKTOP__CHECKOUT__STEP_MOCK = utils.createMockStep('Checkout', 'Checkout', 'DESKTOP', ['ref', 'fetch-depth'], []); +const TESTBUILD__DESKTOP__CHECKOUT__STEP_MOCK = utils.createMockStep('Checkout', 'Checkout', 'DESKTOP', ['ref'], []); const TESTBUILD__DESKTOP__CREATE_ENV_ADHOC__STEP_MOCK = utils.createMockStep( 'Create .env.adhoc file based on staging and add PULL_REQUEST_NUMBER env to it', 'Creating .env.adhoc file based on staging', @@ -169,7 +169,7 @@ const TESTBUILD__DESKTOP__STEP_MOCKS = [ ]; // web -const TESTBUILD__WEB__CHECKOUT__STEP_MOCK = utils.createMockStep('Checkout', 'Checkout', 'WEB', ['fetch-depth', 'ref'], []); +const TESTBUILD__WEB__CHECKOUT__STEP_MOCK = utils.createMockStep('Checkout', 'Checkout', 'WEB', ['ref'], []); const TESTBUILD__WEB__CREATE_ENV_ADHOC__STEP_MOCK = utils.createMockStep( 'Create .env.adhoc file based on staging and add PULL_REQUEST_NUMBER env to it', 'Creating .env.adhoc file based on staging', From deb4faf4cfe56757da4af4fe2f97d09f26dca717 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Wed, 12 Jul 2023 12:41:35 +0200 Subject: [PATCH 118/504] Fix validateGithubActions.test.js Fixes after merging with main See: https://github.com/Expensify/App/issues/13604 --- workflow_tests/assertions/validateGithubActionsAssertions.js | 2 +- workflow_tests/mocks/validateGithubActionsMocks.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/workflow_tests/assertions/validateGithubActionsAssertions.js b/workflow_tests/assertions/validateGithubActionsAssertions.js index f63923402cc7..fb5f58d2b5ed 100644 --- a/workflow_tests/assertions/validateGithubActionsAssertions.js +++ b/workflow_tests/assertions/validateGithubActionsAssertions.js @@ -2,7 +2,7 @@ const utils = require('../utils/utils'); const assertVerifyJobExecuted = (workflowResult, didExecute = true) => { const steps = [ - utils.createStepAssertion('Checkout', true, null, 'VERIFY', 'Checkout', [{key: 'fetch-depth', value: '0'}], []), + utils.createStepAssertion('Checkout', true, null, 'VERIFY', 'Checkout'), utils.createStepAssertion('Setup Node', true, null, 'VERIFY', 'Setup Node', [], []), utils.createStepAssertion('Verify Javascript Action Builds', true, null, 'VERIFY', 'Verify Javascript Action Builds', [], []), utils.createStepAssertion('Validate actions and workflows', true, null, 'VERIFY', 'Validate actions and workflows', [], []), diff --git a/workflow_tests/mocks/validateGithubActionsMocks.js b/workflow_tests/mocks/validateGithubActionsMocks.js index 53dcd1276078..e2d48932acf6 100644 --- a/workflow_tests/mocks/validateGithubActionsMocks.js +++ b/workflow_tests/mocks/validateGithubActionsMocks.js @@ -1,7 +1,7 @@ const utils = require('../utils/utils'); // verify -const VALIDATEGITHUBACTIONS__VERIFY__CHECKOUT__STEP_MOCK = utils.createMockStep('Checkout', 'Checkout', 'VERIFY', ['fetch-depth'], []); +const VALIDATEGITHUBACTIONS__VERIFY__CHECKOUT__STEP_MOCK = utils.createMockStep('Checkout', 'Checkout', 'VERIFY'); const VALIDATEGITHUBACTIONS__VERIFY__SETUP_NODE__STEP_MOCK = utils.createMockStep('Setup Node', 'Setup Node', 'VERIFY', [], []); const VALIDATEGITHUBACTIONS__VERIFY__VERIFY_JAVASCRIPT_ACTION_BUILDS__STEP_MOCK = utils.createMockStep( 'Verify Javascript Action Builds', From e9a593a42aadbe4b1223a29007a9485e4cfac677 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Wed, 12 Jul 2023 12:43:04 +0200 Subject: [PATCH 119/504] Fix verifyPodfile.test.js Fixes after merging with main See: https://github.com/Expensify/App/issues/13604 --- workflow_tests/assertions/verifyPodfileAssertions.js | 2 +- workflow_tests/mocks/verifyPodfileMocks.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/workflow_tests/assertions/verifyPodfileAssertions.js b/workflow_tests/assertions/verifyPodfileAssertions.js index c9b24348c868..e0cc50570fec 100644 --- a/workflow_tests/assertions/verifyPodfileAssertions.js +++ b/workflow_tests/assertions/verifyPodfileAssertions.js @@ -2,7 +2,7 @@ const utils = require('../utils/utils'); const assertVerifyJobExecuted = (workflowResult, didExecute = true) => { const steps = [ - utils.createStepAssertion('Checkout', true, null, 'VERIFY', 'Checkout', [{key: 'fetch-depth', value: '0'}], []), + utils.createStepAssertion('Checkout', true, null, 'VERIFY', 'Checkout'), utils.createStepAssertion('Setup Node', true, null, 'VERIFY', 'Setup Node', [], []), utils.createStepAssertion('Verify podfile', true, null, 'VERIFY', 'Verify podfile', [], []), ]; diff --git a/workflow_tests/mocks/verifyPodfileMocks.js b/workflow_tests/mocks/verifyPodfileMocks.js index a26f0d16609a..0a82eebcc748 100644 --- a/workflow_tests/mocks/verifyPodfileMocks.js +++ b/workflow_tests/mocks/verifyPodfileMocks.js @@ -1,7 +1,7 @@ const utils = require('../utils/utils'); // verify -const VERIFYPODFILE__VERIFY__CHECKOUT__STEP_MOCK = utils.createMockStep('Checkout', 'Checkout', 'VERIFY', ['fetch-depth'], []); +const VERIFYPODFILE__VERIFY__CHECKOUT__STEP_MOCK = utils.createMockStep('Checkout', 'Checkout', 'VERIFY'); const VERIFYPODFILE__VERIFY__SETUP_NODE__STEP_MOCK = utils.createMockStep('Setup Node', 'Setup Node', 'VERIFY', [], []); const VERIFYPODFILE__VERIFY__VERIFY_PODFILE__STEP_MOCK = utils.createMockStep('Verify podfile', 'Verify podfile', 'VERIFY', [], []); const VERIFYPODFILE__VERIFY__STEP_MOCKS = [VERIFYPODFILE__VERIFY__CHECKOUT__STEP_MOCK, VERIFYPODFILE__VERIFY__SETUP_NODE__STEP_MOCK, VERIFYPODFILE__VERIFY__VERIFY_PODFILE__STEP_MOCK]; From af57366b40441c09b55204a6b59a7cb71e7c9e3c Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Wed, 12 Jul 2023 12:45:26 +0200 Subject: [PATCH 120/504] Run lint/prettier Linting See: https://github.com/Expensify/App/issues/13604 --- .../assertions/cherryPickAssertions.js | 9 +------ .../assertions/deployBlockerAssertions.js | 12 +--------- .../assertions/testBuildAssertions.js | 24 ++----------------- workflow_tests/mocks/cherryPickMocks.js | 17 ++++--------- 4 files changed, 9 insertions(+), 53 deletions(-) diff --git a/workflow_tests/assertions/cherryPickAssertions.js b/workflow_tests/assertions/cherryPickAssertions.js index e73f2067dafc..c628f1211055 100644 --- a/workflow_tests/assertions/cherryPickAssertions.js +++ b/workflow_tests/assertions/cherryPickAssertions.js @@ -24,14 +24,7 @@ const assertCreateNewVersionJobExecuted = (workflowResult, didExecute = true) => }); }; -const assertCherryPickJobExecuted = ( - workflowResult, - user = 'Dummy Author', - pullRequestNumber = '1234', - didExecute = true, - hasConflicts = false, - isSuccessful = true, -) => { +const assertCherryPickJobExecuted = (workflowResult, user = 'Dummy Author', pullRequestNumber = '1234', didExecute = true, hasConflicts = false, isSuccessful = true) => { const steps = [ utils.createStepAssertion( 'Checkout staging branch', diff --git a/workflow_tests/assertions/deployBlockerAssertions.js b/workflow_tests/assertions/deployBlockerAssertions.js index 18dae2277c60..8d2d6039960e 100644 --- a/workflow_tests/assertions/deployBlockerAssertions.js +++ b/workflow_tests/assertions/deployBlockerAssertions.js @@ -2,17 +2,7 @@ const utils = require('../utils/utils'); const assertDeployBlockerJobExecuted = (workflowResult, issueTitle, issueNumber, didExecute = true, isSuccessful = true) => { const steps = [ - utils.createStepAssertion( - 'Checkout', - true, - null, - 'DEPLOYBLOCKER', - 'Checkout', - [ - {key: 'token', value: '***'}, - ], - [], - ), + utils.createStepAssertion('Checkout', true, null, 'DEPLOYBLOCKER', 'Checkout', [{key: 'token', value: '***'}], []), utils.createStepAssertion( 'Get URL, title, & number of new deploy blocker (issue)', true, diff --git a/workflow_tests/assertions/testBuildAssertions.js b/workflow_tests/assertions/testBuildAssertions.js index b074d4981823..44f7c2a17b20 100644 --- a/workflow_tests/assertions/testBuildAssertions.js +++ b/workflow_tests/assertions/testBuildAssertions.js @@ -224,17 +224,7 @@ const assertIOSJobExecuted = (workflowResult, ref = '', didExecute = true, fails }; const assertDesktopJobExecuted = (workflowResult, ref = '', didExecute = true, failsAt = -1) => { const steps = [ - utils.createStepAssertion( - 'Checkout', - true, - null, - 'DESKTOP', - 'Checkout', - [ - {key: 'ref', value: ref}, - ], - [], - ), + utils.createStepAssertion('Checkout', true, null, 'DESKTOP', 'Checkout', [{key: 'ref', value: ref}], []), utils.createStepAssertion( 'Create .env.adhoc file based on staging and add PULL_REQUEST_NUMBER env to it', true, @@ -296,17 +286,7 @@ const assertDesktopJobExecuted = (workflowResult, ref = '', didExecute = true, f }; const assertWebJobExecuted = (workflowResult, ref = '', didExecute = true, failsAt = -1) => { const steps = [ - utils.createStepAssertion( - 'Checkout', - true, - null, - 'WEB', - 'Checkout', - [ - {key: 'ref', value: ref}, - ], - [], - ), + utils.createStepAssertion('Checkout', true, null, 'WEB', 'Checkout', [{key: 'ref', value: ref}], []), utils.createStepAssertion('Create .env.adhoc file based on staging and add PULL_REQUEST_NUMBER env to it', true, null, 'WEB', 'Creating .env.adhoc file based on staging', [], []), utils.createStepAssertion('Setup Node', true, null, 'WEB', 'Setup Node', [], []), utils.createStepAssertion( diff --git a/workflow_tests/mocks/cherryPickMocks.js b/workflow_tests/mocks/cherryPickMocks.js index 327b17e7bab1..924c51767031 100644 --- a/workflow_tests/mocks/cherryPickMocks.js +++ b/workflow_tests/mocks/cherryPickMocks.js @@ -37,7 +37,9 @@ const CHERRYPICK__CREATENEWVERSION__STEP_MOCKS = [CHERRYPICK__CREATENEWVERSION__ // cherrypick const CHERRYPICK__CHERRYPICK__CHECKOUT_STAGING_BRANCH__STEP_MOCK = utils.createMockStep('Checkout staging branch', 'Checking out staging branch', 'CHERRYPICK', ['ref', 'token'], []); const CHERRYPICK__CHERRYPICK__SET_UP_GIT_FOR_OSBOTIFY__STEP_MOCK = utils.createMockStep('Set up git for OSBotify', 'Setting up git for OSBotify', 'CHERRYPICK', ['GPG_PASSPHRASE'], []); -const CHERRYPICK__CHERRYPICK__GET_VERSION_BUMP_COMMIT__STEP_MOCK = utils.createMockStep('Get version bump commit', 'Get version bump commit', 'CHERRYPICK', [], [], {VERSION_BUMP_SHA: 'version_bump_sha'}); +const CHERRYPICK__CHERRYPICK__GET_VERSION_BUMP_COMMIT__STEP_MOCK = utils.createMockStep('Get version bump commit', 'Get version bump commit', 'CHERRYPICK', [], [], { + VERSION_BUMP_SHA: 'version_bump_sha', +}); const CHERRYPICK__CHERRYPICK__GET_MERGE_COMMIT_FOR_PULL_REQUEST_TO_CP__STEP_MOCK = utils.createMockStep( 'Get merge commit for pull request to CP', 'Get merge commit for pull request to CP', @@ -46,17 +48,8 @@ const CHERRYPICK__CHERRYPICK__GET_MERGE_COMMIT_FOR_PULL_REQUEST_TO_CP__STEP_MOCK [], {MERGE_ACTOR: '@dummyauthor'}, ); -const CHERRYPICK__CHERRYPICK__GET_PREVIOUS_APP_VERSION__STEP_MOCK = utils.createMockStep( - 'Get previous app version', - 'Get previous app version', - 'CHERRYPICK', - ['SEMVER_LEVEL'], -); -const CHERRYPICK__CHERRYPICK__FETCH_HISTORY_OF_RELEVANT_REFS__STEP_MOCK = utils.createMockStep( - 'Fetch history of relevant refs', - 'Fetch history of relevant refs', - 'CHERRYPICK', -); +const CHERRYPICK__CHERRYPICK__GET_PREVIOUS_APP_VERSION__STEP_MOCK = utils.createMockStep('Get previous app version', 'Get previous app version', 'CHERRYPICK', ['SEMVER_LEVEL']); +const CHERRYPICK__CHERRYPICK__FETCH_HISTORY_OF_RELEVANT_REFS__STEP_MOCK = utils.createMockStep('Fetch history of relevant refs', 'Fetch history of relevant refs', 'CHERRYPICK'); const CHERRYPICK__CHERRYPICK__CHERRY_PICK_THE_VERSION_BUMP_TO_STAGING__STEP_MOCK = utils.createMockStep( 'Cherry-pick the version-bump to staging', 'Cherry-picking the version-bump to staging', From 75a9f3ececcdc865bb1e2f42084cd472acc8cfbc Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Thu, 13 Jul 2023 11:58:30 +0200 Subject: [PATCH 121/504] Increase the timeout Increased the test timeout to 90 seconds See: https://github.com/Expensify/App/issues/13604 --- workflow_tests/authorChecklist.test.js | 2 +- workflow_tests/cherryPick.test.js | 2 +- workflow_tests/cla.test.js | 2 +- workflow_tests/createNewVersion.test.js | 2 +- workflow_tests/deploy.test.js | 2 +- workflow_tests/deployBlocker.test.js | 2 +- workflow_tests/finishReleaseCycle.test.js | 2 +- workflow_tests/lint.test.js | 2 +- workflow_tests/lockDeploys.test.js | 2 +- workflow_tests/platformDeploy.test.js | 2 +- workflow_tests/preDeploy.test.js | 2 +- workflow_tests/reviewerChecklist.test.js | 2 +- workflow_tests/test.test.js | 2 +- workflow_tests/testBuild.test.js | 2 +- workflow_tests/utils/preGenerateTest.js | 2 +- workflow_tests/validateGithubActions.test.js | 2 +- workflow_tests/verifyPodfile.test.js | 2 +- workflow_tests/verifySignedCommits.test.js | 2 +- 18 files changed, 18 insertions(+), 18 deletions(-) diff --git a/workflow_tests/authorChecklist.test.js b/workflow_tests/authorChecklist.test.js index 688ff83f48bb..64a25c8fe1b8 100644 --- a/workflow_tests/authorChecklist.test.js +++ b/workflow_tests/authorChecklist.test.js @@ -5,7 +5,7 @@ const assertions = require('./assertions/authorChecklistAssertions'); const mocks = require('./mocks/authorChecklistMocks'); const eAct = require('./utils/ExtendedAct'); -jest.setTimeout(60 * 1000); +jest.setTimeout(90 * 1000); let mockGithub; const FILES_TO_COPY_INTO_TEST_REPO = [ ...utils.deepCopy(utils.FILES_TO_COPY_INTO_TEST_REPO), diff --git a/workflow_tests/cherryPick.test.js b/workflow_tests/cherryPick.test.js index 34c2b825d521..081d2f58a310 100644 --- a/workflow_tests/cherryPick.test.js +++ b/workflow_tests/cherryPick.test.js @@ -5,7 +5,7 @@ const assertions = require('./assertions/cherryPickAssertions'); const mocks = require('./mocks/cherryPickMocks'); const eAct = require('./utils/ExtendedAct'); -jest.setTimeout(60 * 1000); +jest.setTimeout(90 * 1000); let mockGithub; const FILES_TO_COPY_INTO_TEST_REPO = [ ...utils.deepCopy(utils.FILES_TO_COPY_INTO_TEST_REPO), diff --git a/workflow_tests/cla.test.js b/workflow_tests/cla.test.js index bd75a18a919a..301aa7587f53 100644 --- a/workflow_tests/cla.test.js +++ b/workflow_tests/cla.test.js @@ -5,7 +5,7 @@ const assertions = require('./assertions/claAssertions'); const mocks = require('./mocks/claMocks'); const eAct = require('./utils/ExtendedAct'); -jest.setTimeout(60 * 1000); +jest.setTimeout(90 * 1000); let mockGithub; const FILES_TO_COPY_INTO_TEST_REPO = [ ...utils.deepCopy(utils.FILES_TO_COPY_INTO_TEST_REPO), diff --git a/workflow_tests/createNewVersion.test.js b/workflow_tests/createNewVersion.test.js index 8a0b06d339b0..259e06450325 100644 --- a/workflow_tests/createNewVersion.test.js +++ b/workflow_tests/createNewVersion.test.js @@ -5,7 +5,7 @@ const assertions = require('./assertions/createNewVersionAssertions'); const mocks = require('./mocks/createNewVersionMocks'); const eAct = require('./utils/ExtendedAct'); -jest.setTimeout(60 * 1000); // 60 sec +jest.setTimeout(90 * 1000); // 90 sec let mockGithub; const FILES_TO_COPY_INTO_TEST_REPO = [ ...utils.deepCopy(utils.FILES_TO_COPY_INTO_TEST_REPO), diff --git a/workflow_tests/deploy.test.js b/workflow_tests/deploy.test.js index 13bd2c969bdd..a2ccdebc0b31 100644 --- a/workflow_tests/deploy.test.js +++ b/workflow_tests/deploy.test.js @@ -5,7 +5,7 @@ const assertions = require('./assertions/deployAssertions'); const mocks = require('./mocks/deployMocks'); const eAct = require('./utils/ExtendedAct'); -jest.setTimeout(60 * 1000); +jest.setTimeout(90 * 1000); let mockGithub; const FILES_TO_COPY_INTO_TEST_REPO = [ ...utils.deepCopy(utils.FILES_TO_COPY_INTO_TEST_REPO), diff --git a/workflow_tests/deployBlocker.test.js b/workflow_tests/deployBlocker.test.js index f279ddaa2933..1cfca11c90f5 100644 --- a/workflow_tests/deployBlocker.test.js +++ b/workflow_tests/deployBlocker.test.js @@ -5,7 +5,7 @@ const assertions = require('./assertions/deployBlockerAssertions'); const mocks = require('./mocks/deployBlockerMocks'); const eAct = require('./utils/ExtendedAct'); -jest.setTimeout(60 * 1000); +jest.setTimeout(90 * 1000); let mockGithub; const FILES_TO_COPY_INTO_TEST_REPO = [ ...utils.deepCopy(utils.FILES_TO_COPY_INTO_TEST_REPO), diff --git a/workflow_tests/finishReleaseCycle.test.js b/workflow_tests/finishReleaseCycle.test.js index 20c6340c9087..2f1f3b790f36 100644 --- a/workflow_tests/finishReleaseCycle.test.js +++ b/workflow_tests/finishReleaseCycle.test.js @@ -5,7 +5,7 @@ const assertions = require('./assertions/finishReleaseCycleAssertions'); const mocks = require('./mocks/finishReleaseCycleMocks'); const eAct = require('./utils/ExtendedAct'); -jest.setTimeout(60 * 1000); +jest.setTimeout(90 * 1000); let mockGithub; const FILES_TO_COPY_INTO_TEST_REPO = [ ...utils.deepCopy(utils.FILES_TO_COPY_INTO_TEST_REPO), diff --git a/workflow_tests/lint.test.js b/workflow_tests/lint.test.js index 878b081f14e4..bc51f31b657c 100644 --- a/workflow_tests/lint.test.js +++ b/workflow_tests/lint.test.js @@ -5,7 +5,7 @@ const assertions = require('./assertions/lintAssertions'); const mocks = require('./mocks/lintMocks'); const eAct = require('./utils/ExtendedAct'); -jest.setTimeout(60 * 1000); +jest.setTimeout(90 * 1000); let mockGithub; const FILES_TO_COPY_INTO_TEST_REPO = [ ...utils.deepCopy(utils.FILES_TO_COPY_INTO_TEST_REPO), diff --git a/workflow_tests/lockDeploys.test.js b/workflow_tests/lockDeploys.test.js index 8af555242987..a57ed8847fd3 100644 --- a/workflow_tests/lockDeploys.test.js +++ b/workflow_tests/lockDeploys.test.js @@ -5,7 +5,7 @@ const assertions = require('./assertions/lockDeploysAssertions'); const mocks = require('./mocks/lockDeploysMocks'); const eAct = require('./utils/ExtendedAct'); -jest.setTimeout(60 * 1000); +jest.setTimeout(90 * 1000); let mockGithub; const FILES_TO_COPY_INTO_TEST_REPO = [ ...utils.deepCopy(utils.FILES_TO_COPY_INTO_TEST_REPO), diff --git a/workflow_tests/platformDeploy.test.js b/workflow_tests/platformDeploy.test.js index 72e533eb1cce..ecdcfae8d337 100644 --- a/workflow_tests/platformDeploy.test.js +++ b/workflow_tests/platformDeploy.test.js @@ -5,7 +5,7 @@ const assertions = require('./assertions/platformDeployAssertions'); const mocks = require('./mocks/platformDeployMocks'); const eAct = require('./utils/ExtendedAct'); -jest.setTimeout(60 * 1000); +jest.setTimeout(90 * 1000); let mockGithub; const FILES_TO_COPY_INTO_TEST_REPO = [ ...utils.deepCopy(utils.FILES_TO_COPY_INTO_TEST_REPO), diff --git a/workflow_tests/preDeploy.test.js b/workflow_tests/preDeploy.test.js index 41c12d20ba28..eb2376eb61f8 100644 --- a/workflow_tests/preDeploy.test.js +++ b/workflow_tests/preDeploy.test.js @@ -5,7 +5,7 @@ const assertions = require('./assertions/preDeployAssertions'); const mocks = require('./mocks/preDeployMocks'); const eAct = require('./utils/ExtendedAct'); -jest.setTimeout(60 * 1000); +jest.setTimeout(90 * 1000); let mockGithub; const FILES_TO_COPY_INTO_TEST_REPO = [ ...utils.deepCopy(utils.FILES_TO_COPY_INTO_TEST_REPO), diff --git a/workflow_tests/reviewerChecklist.test.js b/workflow_tests/reviewerChecklist.test.js index 0136d80b5402..9903c3eb4b8d 100644 --- a/workflow_tests/reviewerChecklist.test.js +++ b/workflow_tests/reviewerChecklist.test.js @@ -5,7 +5,7 @@ const assertions = require('./assertions/reviewerChecklistAssertions'); const mocks = require('./mocks/reviewerChecklistMocks'); const eAct = require('./utils/ExtendedAct'); -jest.setTimeout(60 * 1000); +jest.setTimeout(90 * 1000); let mockGithub; const FILES_TO_COPY_INTO_TEST_REPO = [ ...utils.deepCopy(utils.FILES_TO_COPY_INTO_TEST_REPO), diff --git a/workflow_tests/test.test.js b/workflow_tests/test.test.js index 714c22d3f96a..6efe8d260928 100644 --- a/workflow_tests/test.test.js +++ b/workflow_tests/test.test.js @@ -5,7 +5,7 @@ const assertions = require('./assertions/testAssertions'); const mocks = require('./mocks/testMocks'); const eAct = require('./utils/ExtendedAct'); -jest.setTimeout(60 * 1000); +jest.setTimeout(90 * 1000); let mockGithub; const FILES_TO_COPY_INTO_TEST_REPO = [ ...utils.deepCopy(utils.FILES_TO_COPY_INTO_TEST_REPO), diff --git a/workflow_tests/testBuild.test.js b/workflow_tests/testBuild.test.js index 837699830650..59a718617a04 100644 --- a/workflow_tests/testBuild.test.js +++ b/workflow_tests/testBuild.test.js @@ -5,7 +5,7 @@ const assertions = require('./assertions/testBuildAssertions'); const mocks = require('./mocks/testBuildMocks'); const eAct = require('./utils/ExtendedAct'); -jest.setTimeout(60 * 1000); +jest.setTimeout(90 * 1000); let mockGithub; const FILES_TO_COPY_INTO_TEST_REPO = [ ...utils.deepCopy(utils.FILES_TO_COPY_INTO_TEST_REPO), diff --git a/workflow_tests/utils/preGenerateTest.js b/workflow_tests/utils/preGenerateTest.js index 7bfd5b382267..4ed485abec40 100644 --- a/workflow_tests/utils/preGenerateTest.js +++ b/workflow_tests/utils/preGenerateTest.js @@ -28,7 +28,7 @@ const assertions = require('./assertions/${workflowName}Assertions'); const mocks = require('./mocks/${workflowName}Mocks'); const eAct = require('./utils/ExtendedAct'); -jest.setTimeout(60 * 1000); +jest.setTimeout(90 * 1000); let mockGithub; const FILES_TO_COPY_INTO_TEST_REPO = [ { diff --git a/workflow_tests/validateGithubActions.test.js b/workflow_tests/validateGithubActions.test.js index a24d2a779077..dfa5e9362ce7 100644 --- a/workflow_tests/validateGithubActions.test.js +++ b/workflow_tests/validateGithubActions.test.js @@ -5,7 +5,7 @@ const assertions = require('./assertions/validateGithubActionsAssertions'); const mocks = require('./mocks/validateGithubActionsMocks'); const eAct = require('./utils/ExtendedAct'); -jest.setTimeout(60 * 1000); +jest.setTimeout(90 * 1000); let mockGithub; const FILES_TO_COPY_INTO_TEST_REPO = [ ...utils.deepCopy(utils.FILES_TO_COPY_INTO_TEST_REPO), diff --git a/workflow_tests/verifyPodfile.test.js b/workflow_tests/verifyPodfile.test.js index 38174511821c..de062af2a2c2 100644 --- a/workflow_tests/verifyPodfile.test.js +++ b/workflow_tests/verifyPodfile.test.js @@ -5,7 +5,7 @@ const assertions = require('./assertions/verifyPodfileAssertions'); const mocks = require('./mocks/verifyPodfileMocks'); const eAct = require('./utils/ExtendedAct'); -jest.setTimeout(60 * 1000); +jest.setTimeout(90 * 1000); let mockGithub; const FILES_TO_COPY_INTO_TEST_REPO = [ ...utils.deepCopy(utils.FILES_TO_COPY_INTO_TEST_REPO), diff --git a/workflow_tests/verifySignedCommits.test.js b/workflow_tests/verifySignedCommits.test.js index 6973ed14033d..911208e91f4a 100644 --- a/workflow_tests/verifySignedCommits.test.js +++ b/workflow_tests/verifySignedCommits.test.js @@ -5,7 +5,7 @@ const assertions = require('./assertions/verifySignedCommitsAssertions'); const mocks = require('./mocks/verifySignedCommitsMocks'); const eAct = require('./utils/ExtendedAct'); -jest.setTimeout(60 * 1000); +jest.setTimeout(90 * 1000); let mockGithub; const FILES_TO_COPY_INTO_TEST_REPO = [ ...utils.deepCopy(utils.FILES_TO_COPY_INTO_TEST_REPO), From 7b386bf83c0de3653a0c033cb908af953408fbe1 Mon Sep 17 00:00:00 2001 From: Georgia Monahan Date: Mon, 17 Jul 2023 07:54:51 +0100 Subject: [PATCH 122/504] remove old colors --- src/styles/StyleUtils.js | 33 -------------------- src/styles/colors.js | 49 +++++++++++++++++++++-------- src/styles/themes/default.js | 60 ------------------------------------ 3 files changed, 36 insertions(+), 106 deletions(-) diff --git a/src/styles/StyleUtils.js b/src/styles/StyleUtils.js index fd9650bc162a..8a520607d0c7 100644 --- a/src/styles/StyleUtils.js +++ b/src/styles/StyleUtils.js @@ -601,38 +601,6 @@ function getEmojiPickerStyle(isSmallScreenWidth) { }; } -/** - * Get the random promo color and image for Login page - * - * @return {Object} - */ -function getLoginPagePromoStyle() { - const promos = [ - { - backgroundColor: colors.green, - backgroundImageUri: `${CONST.CLOUDFRONT_URL}/images/homepage/brand-stories/freeplan_green.svg`, - }, - { - backgroundColor: colors.orange, - backgroundImageUri: `${CONST.CLOUDFRONT_URL}/images/homepage/brand-stories/freeplan_orange.svg`, - }, - { - backgroundColor: colors.pink, - backgroundImageUri: `${CONST.CLOUDFRONT_URL}/images/homepage/brand-stories/freeplan_pink.svg`, - }, - { - backgroundColor: colors.blue, - backgroundImageUri: `${CONST.CLOUDFRONT_URL}/images/homepage/brand-stories/freeplan_blue.svg`, - }, - { - backgroundColor: colors.floralwhite, - backgroundImageUri: `${CONST.CLOUDFRONT_URL}/images/homepage/brand-stories/cpa-card.svg`, - redirectUri: `${CONST.USE_EXPENSIFY_URL}/accountants`, - }, - ]; - return promos[_.random(0, 4)]; -} - /** * Generate the styles for the ReportActionItem wrapper view. * @@ -1319,7 +1287,6 @@ export { getModalPaddingStyles, getFontFamilyMonospace, getEmojiPickerStyle, - getLoginPagePromoStyle, getReportActionItemStyle, getMiniReportActionContextMenuWrapperStyle, getKeyboardShortcutsModalWidth, diff --git a/src/styles/colors.js b/src/styles/colors.js index 06513e0f18d4..61d7cdb5ef33 100644 --- a/src/styles/colors.js +++ b/src/styles/colors.js @@ -6,9 +6,6 @@ export default { black: '#000000', blue: '#0185ff', blueHover: '#B0D9FF', - floralwhite: '#fffaf0', - orange: '#FF7101', - pink: '#F68DFE', green: '#03D47C', greenHover: '#00C271', greenPressed: '#35DD96', @@ -27,6 +24,7 @@ export default { greenBordersLighter: '#2B5548', greenIcons: '#8B9C8F', greenSupportingText: '#AFBBB0', + greenPrimaryText: '#E7ECE9', white: '#E7ECE9', blueLink: '#5AB0FF', blueLinkHover: '#B0D9FF', @@ -34,51 +32,76 @@ export default { greenDefaultButton: '#184E3D', greenDefaultButtonHover: '#2C6755', greenDefaultButtonPressed: '#467164', - greenDefaultButtonDisabled: '#8BA69E', + midnight: '#002140', + + // Light Mode Theme Colors + lightAppBackground: '#FCFBF9', + lightHighlightBackground: '#F8F4F0', + lightBorders: '#EBE6DF', + lightBordersLighter: '#2B5548', + lightIcons: '#A2A9A3', + lightSupportingText: '#76847E', + lightPrimaryText: '#002E22', + blueLink: '#0164BF', + blueLinkHover: '#B0D9FF', + blueLinkPreview: '#2EAAE2', + lightDefaultButton: '#EEEBE7', + lightDefaultButtonHover: '#E3DFD9', + lightDefaultButtonPressed: '#D2CCC3', midnight: '#002140', // Brand Colors from Figma blue100: '#B0D9FF', blue200: '#8DC8FF', + blue300: '#5AB0FF', blue400: '#0185FF', + blue500: '#0676DE', blue600: '#0164BF', blue700: '#003C73', blue800: '#002140', green100: '#B1F2D6', green200: '#8EECC4', + green300: '#5BE3AA', green400: '#03D47C', + green500: '#00B268', green600: '#008C59', green700: '#085239', green800: '#002E22', + yellow100: '#FFF2B2', yellow200: '#FFED8F', + yellow300: '#FEE45E', yellow400: '#FED607', + yellow500: '#E4BC07', + yellow600: '#D18000', yellow700: '#722B03', yellow800: '#401102', + tangerine100: '#FFD7B0', tangerine200: '#FFC68C', + tangerine300: '#FFA75A', tangerine400: '#FF7101', + tangerine500: '#F25730', + tangerine600: '#BF3013', tangerine700: '#780505', tangerine800: '#400000', + pink100: '#FCDCFF', pink200: '#FBCCFF', + pink300: '#F9B5FE', pink400: '#F68DFE', + pink500: '#E96DF2', pink600: '#CF4CD9', pink700: '#712A76', pink800: '#49225B', + ice100: '#DFFDFE', ice200: '#CCF7FF', + ice300: '#A5FBFF', ice400: '#50EEF6', + ice500: '#4ED7DE', + ice600: '#4BA6A6', ice700: '#28736D', ice800: '#134038', - - // DEPRECATED COLORS. Do not reference these colors. Will be deleted in color switch PR. - gray1: '#FAFAFA', - gray2: '#ECECEC', - gray3: '#C6C9CA', - gray4: '#7D8B8F', - oldRed: '#fc3826', - oldRedHover: '#e13826', - oldRedDisabled: '#fea29a', }; diff --git a/src/styles/themes/default.js b/src/styles/themes/default.js index 232d1b873863..e7f020a9a4a9 100644 --- a/src/styles/themes/default.js +++ b/src/styles/themes/default.js @@ -20,7 +20,6 @@ const darkTheme = { link: colors.blueLink, linkHover: colors.blueLinkHover, buttonDefaultBG: colors.greenDefaultButton, - buttonDisabledBG: colors.greenDefaultButtonDisabled, buttonHoveredBG: colors.greenDefaultButtonHover, buttonPressedBG: colors.greenDefaultButtonPressed, danger: colors.red, @@ -82,63 +81,4 @@ darkTheme.PAGE_BACKGROUND_COLORS = { [SCREENS.HOME]: darkTheme.sidebar, }; -const oldTheme = { - shadow: colors.black, - link: colors.blue, - linkHover: colors.blueHover, - componentBG: colors.white, - hoverComponentBG: colors.gray1, - activeComponentBG: colors.gray2, - appBG: colors.white, - heading: colors.dark, - sidebar: colors.gray1, - sidebarHover: colors.white, - border: colors.gray2, - borderFocus: colors.blue, - icon: colors.gray3, - iconMenu: colors.gray3, - iconHovered: colors.dark, - iconSuccessFill: colors.green, - iconReversed: colors.white, - textSupporting: colors.gray4, - text: colors.dark, - textError: colors.oldRed, - textBackground: colors.gray1, - textReversed: colors.white, - textMutedReversed: colors.gray3, - buttonDefaultBG: colors.gray2, - offline: colors.gray3, - modalBackdrop: colors.gray3, - modalBackground: colors.gray2, - buttonDisabledBG: colors.gray2, - buttonHoveredBG: colors.gray1, - buttonPressedBG: colors.gray2, - spinner: colors.gray4, - unreadIndicator: colors.green, - placeholderText: colors.gray3, - heroCard: colors.blue, - uploadPreviewActivityIndicator: colors.gray1, - dropUIBG: 'rgba(6,27,9,0.92)', - dropTransparentOverlay: 'rgba(255,255,255,0)', - cardBG: colors.gray1, - cardBorder: colors.gray1, - checkBox: colors.blue, - overlay: colors.gray1, - - // Merging new Keys for Dark Mode merge. Delete after new branding is implemented. - highlightBG: colors.gray1, - danger: colors.oldRed, - dangerHover: colors.oldRedHover, - dangerPressed: colors.oldRedHover, - dangerDisabled: colors.oldRedDisabled, - warning: colors.yellow, - success: colors.green, - successHover: colors.greenHover, - successPressed: colors.greenPressed, - transparent: colors.transparent, - inverse: colors.dark, - textLight: colors.white, - textDark: colors.dark, -}; - export default darkTheme; From 67c2fee45eec181e9c0ce84668a589f1f7b67d0c Mon Sep 17 00:00:00 2001 From: Georgia Monahan Date: Mon, 17 Jul 2023 08:21:02 +0100 Subject: [PATCH 123/504] add v1 light theme, remove bordersLighter --- src/styles/colors.js | 3 -- src/styles/themes/default.js | 6 +-- src/styles/themes/light.js | 83 ++++++++++++++++++++++++++++++++++++ 3 files changed, 86 insertions(+), 6 deletions(-) create mode 100644 src/styles/themes/light.js diff --git a/src/styles/colors.js b/src/styles/colors.js index 61d7cdb5ef33..672fc6630372 100644 --- a/src/styles/colors.js +++ b/src/styles/colors.js @@ -9,7 +9,6 @@ export default { green: '#03D47C', greenHover: '#00C271', greenPressed: '#35DD96', - greenDisabled: '80E9BD', red: '#F25730', redHover: '#DE4822', redPressed: '#F57959', @@ -21,7 +20,6 @@ export default { greenAppBackground: '#061B09', greenHighlightBackground: '#07271F', greenBorders: '#1A3D32', - greenBordersLighter: '#2B5548', greenIcons: '#8B9C8F', greenSupportingText: '#AFBBB0', greenPrimaryText: '#E7ECE9', @@ -48,7 +46,6 @@ export default { lightDefaultButton: '#EEEBE7', lightDefaultButtonHover: '#E3DFD9', lightDefaultButtonPressed: '#D2CCC3', - midnight: '#002140', // Brand Colors from Figma blue100: '#B0D9FF', diff --git a/src/styles/themes/default.js b/src/styles/themes/default.js index e7f020a9a4a9..875da1591734 100644 --- a/src/styles/themes/default.js +++ b/src/styles/themes/default.js @@ -8,7 +8,7 @@ const darkTheme = { splashBG: colors.green, highlightBG: colors.greenHighlightBackground, border: colors.greenBorders, - borderLighter: colors.greenBordersLighter, + borderLighter: colors.greenDefaultButton, borderFocus: colors.green, icon: colors.greenIcons, iconMenu: colors.green, @@ -17,8 +17,8 @@ const darkTheme = { iconReversed: colors.greenAppBackground, textSupporting: colors.greenSupportingText, text: colors.white, - link: colors.blueLink, - linkHover: colors.blueLinkHover, + link: colors.blue300, + linkHover: colors.blue100, buttonDefaultBG: colors.greenDefaultButton, buttonHoveredBG: colors.greenDefaultButtonHover, buttonPressedBG: colors.greenDefaultButtonPressed, diff --git a/src/styles/themes/light.js b/src/styles/themes/light.js new file mode 100644 index 000000000000..3fd51134b038 --- /dev/null +++ b/src/styles/themes/light.js @@ -0,0 +1,83 @@ +import colors from '../colors'; +import SCREENS from '../../SCREENS'; + +const lightTheme = { + // Figma keys + appBG: colors.lightAppBackground, + splashBG: colors.green, + highlightBG: colors.lightHighlightBackground, + border: colors.lightBorders, + borderLighter: colors.lightDefaultButtonPressed, + borderFocus: colors.green, + icon: colors.lightIcons, + iconMenu: colors.green, + iconHovered: colors.white, + iconSuccessFill: colors.green, + iconReversed: colors.lightAppBackground, + textSupporting: colors.lightSupportingText, + text: colors.lightPrimaryText, + link: colors.blue600, + linkHover: colors.blue500, + buttonDefaultBG: colors.greenDefaultButton, + buttonHoveredBG: colors.greenDefaultButtonHover, + buttonPressedBG: colors.greenDefaultButtonPressed, + danger: colors.red, + dangerHover: colors.redHover, + dangerPressed: colors.redHover, + warning: colors.yellow, + success: colors.green, + successHover: colors.greenHover, + successPressed: colors.greenPressed, + transparent: colors.transparent, + midtone: colors.green700, + signInPage: colors.green800, + dark: colors.midnight, + + // Additional keys + overlay: colors.lightHighlightBackground, + inverse: colors.white, + shadow: colors.black, + componentBG: colors.lightAppBackground, + hoverComponentBG: colors.lightHighlightBackground, + activeComponentBG: colors.lightBorders, + signInSidebar: colors.green800, + sidebar: colors.lightHighlightBackground, + sidebarHover: colors.lightAppBackground, + heading: colors.white, + textLight: colors.white, + textDark: colors.lightPrimaryText, + textReversed: colors.lightAppBackground, + textBackground: colors.lightHighlightBackground, + textMutedReversed: colors.lightIcons, + textError: colors.red, + offline: colors.lightIcons, + modalBackdrop: colors.lightHighlightBackground, + modalBackground: colors.lightAppBackground, + cardBG: colors.lightHighlightBackground, + cardBorder: colors.lightHighlightBackground, + spinner: colors.lightSupportingText, + unreadIndicator: colors.green, + placeholderText: colors.lightIcons, + heroCard: colors.blue, + uploadPreviewActivityIndicator: colors.lightHighlightBackground, + dropUIBG: 'rgba(6,27,9,0.92)', + dropTransparentOverlay: 'rgba(255,255,255,0)', + checkBox: colors.green, + pickerOptionsTextColor: colors.white, + imageCropBackgroundColor: colors.lightIcons, + fallbackIconColor: colors.green700, + reactionActiveBackground: colors.green100, + reactionActiveText: colors.green600, + badgeAdHoc: colors.pink600, + badgeAdHocHover: colors.pink700, + mentionText: colors.blue600, + mentionBG: colors.blue100, + ourMentionText: colors.green600, + ourMentionBG: colors.green100, +}; + +lightTheme.PAGE_BACKGROUND_COLORS = { + [SCREENS.HOME]: lightTheme.sidebar, +}; + +export default lightTheme; From 8352a65b3fe5c5100b96255d1978194417b1bc4b Mon Sep 17 00:00:00 2001 From: Georgia Monahan Date: Mon, 17 Jul 2023 08:29:49 +0100 Subject: [PATCH 124/504] add greenPrimaryText key --- .storybook/theme.js | 4 ++-- src/pages/home/report/LinkPreviewer.js | 4 ++-- src/styles/StyleUtils.js | 2 +- src/styles/colors.js | 6 ------ src/styles/themes/default.js | 14 +++++++------- src/styles/themes/light.js | 12 ++++++------ 6 files changed, 18 insertions(+), 24 deletions(-) diff --git a/.storybook/theme.js b/.storybook/theme.js index 0867f6a830b5..e3d05cd2fb12 100644 --- a/.storybook/theme.js +++ b/.storybook/theme.js @@ -11,8 +11,8 @@ export default create({ colorPrimary: colors.greenDefaultButton, colorSecondary: colors.green, appContentBg: colors.greenAppBackground, - textColor: colors.white, - barTextColor: colors.white, + textColor: colors.greenPrimaryText, + barTextColor: colors.greenPrimaryText, barSelectedColor: colors.green, barBg: colors.greenAppBackground, appBorderColor: colors.greenBorders, diff --git a/src/pages/home/report/LinkPreviewer.js b/src/pages/home/report/LinkPreviewer.js index ca5614fe2208..809e8b8feccd 100644 --- a/src/pages/home/report/LinkPreviewer.js +++ b/src/pages/home/report/LinkPreviewer.js @@ -9,7 +9,7 @@ import TextLink from '../../../components/TextLink'; import * as StyleUtils from '../../../styles/StyleUtils'; import styles from '../../../styles/styles'; import variables from '../../../styles/variables'; -import colors from '../../../styles/colors'; +import themeColors from '../../../styles/themes/default'; const IMAGE_TYPES = ['jpg', 'jpeg', 'png']; const MAX_IMAGE_SIZE = 350; @@ -107,7 +107,7 @@ function LinkPreviewer(props) { {!_.isEmpty(title) && ( {title} diff --git a/src/styles/StyleUtils.js b/src/styles/StyleUtils.js index 8a520607d0c7..21af895ae5a6 100644 --- a/src/styles/StyleUtils.js +++ b/src/styles/StyleUtils.js @@ -1052,7 +1052,7 @@ function getAutoCompleteSuggestionContainerStyle(itemsHeight, shouldIncludeRepor * @param {Boolean} isColored * @returns {String | null} */ -const getColoredBackgroundStyle = (isColored) => ({backgroundColor: isColored ? colors.blueLink : null}); +const getColoredBackgroundStyle = (isColored) => ({backgroundColor: isColored ? themeColors.link : null}); function getEmojiReactionBubbleStyle(isHovered, hasUserReacted, isContextMenu = false) { let backgroundColor = themeColors.border; diff --git a/src/styles/colors.js b/src/styles/colors.js index 672fc6630372..7aac0c2da6da 100644 --- a/src/styles/colors.js +++ b/src/styles/colors.js @@ -24,9 +24,6 @@ export default { greenSupportingText: '#AFBBB0', greenPrimaryText: '#E7ECE9', white: '#E7ECE9', - blueLink: '#5AB0FF', - blueLinkHover: '#B0D9FF', - blueLinkPreview: '#2EAAE2', greenDefaultButton: '#184E3D', greenDefaultButtonHover: '#2C6755', greenDefaultButtonPressed: '#467164', @@ -40,9 +37,6 @@ export default { lightIcons: '#A2A9A3', lightSupportingText: '#76847E', lightPrimaryText: '#002E22', - blueLink: '#0164BF', - blueLinkHover: '#B0D9FF', - blueLinkPreview: '#2EAAE2', lightDefaultButton: '#EEEBE7', lightDefaultButtonHover: '#E3DFD9', lightDefaultButtonPressed: '#D2CCC3', diff --git a/src/styles/themes/default.js b/src/styles/themes/default.js index 875da1591734..b190c4c720cb 100644 --- a/src/styles/themes/default.js +++ b/src/styles/themes/default.js @@ -12,11 +12,11 @@ const darkTheme = { borderFocus: colors.green, icon: colors.greenIcons, iconMenu: colors.green, - iconHovered: colors.white, + iconHovered: colors.greenPrimaryText, iconSuccessFill: colors.green, iconReversed: colors.greenAppBackground, textSupporting: colors.greenSupportingText, - text: colors.white, + text: colors.greenPrimaryText, link: colors.blue300, linkHover: colors.blue100, buttonDefaultBG: colors.greenDefaultButton, @@ -32,11 +32,11 @@ const darkTheme = { transparent: colors.transparent, midtone: colors.green700, signInPage: colors.green800, - dark: colors.midnight, + dark: colors.blue800, // Additional keys overlay: colors.greenHighlightBackground, - inverse: colors.white, + inverse: colors.greenPrimaryText, shadow: colors.black, componentBG: colors.greenAppBackground, hoverComponentBG: colors.greenHighlightBackground, @@ -44,8 +44,8 @@ const darkTheme = { signInSidebar: colors.green800, sidebar: colors.greenHighlightBackground, sidebarHover: colors.greenAppBackground, - heading: colors.white, - textLight: colors.white, + heading: colors.greenPrimaryText, + textLight: colors.greenPrimaryText, textDark: colors.greenAppBackground, textReversed: colors.greenAppBackground, textBackground: colors.greenHighlightBackground, @@ -64,7 +64,7 @@ const darkTheme = { dropUIBG: 'rgba(6,27,9,0.92)', dropTransparentOverlay: 'rgba(255,255,255,0)', checkBox: colors.green, - pickerOptionsTextColor: colors.white, + pickerOptionsTextColor: colors.greenPrimaryText, imageCropBackgroundColor: colors.greenIcons, fallbackIconColor: colors.green700, reactionActiveBackground: colors.green600, diff --git a/src/styles/themes/light.js b/src/styles/themes/light.js index 3fd51134b038..1e268398e175 100644 --- a/src/styles/themes/light.js +++ b/src/styles/themes/light.js @@ -11,7 +11,7 @@ const lightTheme = { borderFocus: colors.green, icon: colors.lightIcons, iconMenu: colors.green, - iconHovered: colors.white, + iconHovered: colors.lightPrimaryText, iconSuccessFill: colors.green, iconReversed: colors.lightAppBackground, textSupporting: colors.lightSupportingText, @@ -31,11 +31,11 @@ const lightTheme = { transparent: colors.transparent, midtone: colors.green700, signInPage: colors.green800, - dark: colors.midnight, + dark: colors.blue800, // Additional keys overlay: colors.lightHighlightBackground, - inverse: colors.white, + inverse: colors.lightPrimaryText, shadow: colors.black, componentBG: colors.lightAppBackground, hoverComponentBG: colors.lightHighlightBackground, @@ -43,8 +43,8 @@ const lightTheme = { signInSidebar: colors.green800, sidebar: colors.lightHighlightBackground, sidebarHover: colors.lightAppBackground, - heading: colors.white, - textLight: colors.white, + heading: colors.lightPrimaryText, + textLight: colors.greenPrimaryText, textDark: colors.lightPrimaryText, textReversed: colors.lightAppBackground, textBackground: colors.lightHighlightBackground, @@ -63,7 +63,7 @@ const lightTheme = { dropUIBG: 'rgba(6,27,9,0.92)', dropTransparentOverlay: 'rgba(255,255,255,0)', checkBox: colors.green, - pickerOptionsTextColor: colors.white, + pickerOptionsTextColor: colors.lightPrimaryText, imageCropBackgroundColor: colors.lightIcons, fallbackIconColor: colors.green700, reactionActiveBackground: colors.green100, From 70b0f8050476509639d0cf5f6ee9acfd78d47816 Mon Sep 17 00:00:00 2001 From: Georgia Monahan Date: Mon, 17 Jul 2023 08:37:42 +0100 Subject: [PATCH 125/504] Clean up colors by removing duplicate colors --- .storybook/theme.js | 18 ++--- src/components/GrowlNotification/index.js | 8 +- .../ReimbursementAccount/BankAccountStep.js | 2 +- src/styles/colors.js | 24 +++--- src/styles/themes/default.js | 74 +++++++++---------- src/styles/themes/light.js | 12 +-- 6 files changed, 67 insertions(+), 71 deletions(-) diff --git a/.storybook/theme.js b/.storybook/theme.js index e3d05cd2fb12..96631764726f 100644 --- a/.storybook/theme.js +++ b/.storybook/theme.js @@ -7,17 +7,17 @@ export default create({ fontBase: 'ExpensifyNeue-Regular', fontCode: 'monospace', base: 'dark', - appBg: colors.greenHighlightBackground, - colorPrimary: colors.greenDefaultButton, + appBg: colors.darkHighlightBackground, + colorPrimary: colors.darkDefaultButton, colorSecondary: colors.green, - appContentBg: colors.greenAppBackground, - textColor: colors.greenPrimaryText, - barTextColor: colors.greenPrimaryText, + appContentBg: colors.darkAppBackground, + textColor: colors.darkPrimaryText, + barTextColor: colors.darkPrimaryText, barSelectedColor: colors.green, - barBg: colors.greenAppBackground, - appBorderColor: colors.greenBorders, - inputBg: colors.greenHighlightBackground, - inputBorder: colors.greenBorders, + barBg: colors.darkAppBackground, + appBorderColor: colors.darkBorders, + inputBg: colors.darkHighlightBackground, + inputBorder: colors.darkBorders, appBorderRadius: 8, inputBorderRadius: 8, }); diff --git a/src/components/GrowlNotification/index.js b/src/components/GrowlNotification/index.js index b995d0ec7039..964c4f3439f9 100644 --- a/src/components/GrowlNotification/index.js +++ b/src/components/GrowlNotification/index.js @@ -1,7 +1,7 @@ import React, {Component} from 'react'; import {View, Animated} from 'react-native'; import {Directions, FlingGestureHandler, State} from 'react-native-gesture-handler'; -import colors from '../../styles/colors'; +import themeColors from '../../styles/themes/default'; import Text from '../Text'; import Icon from '../Icon'; import * as Expensicons from '../Icon/Expensicons'; @@ -14,15 +14,15 @@ import * as Pressables from '../Pressable'; const types = { [CONST.GROWL.SUCCESS]: { icon: Expensicons.Checkmark, - iconColor: colors.green, + iconColor: themeColors.success, }, [CONST.GROWL.ERROR]: { icon: Expensicons.Exclamation, - iconColor: colors.red, + iconColor: themeColors.danger, }, [CONST.GROWL.WARNING]: { icon: Expensicons.Exclamation, - iconColor: colors.yellow, + iconColor: themeColors.warning, }, }; diff --git a/src/pages/ReimbursementAccount/BankAccountStep.js b/src/pages/ReimbursementAccount/BankAccountStep.js index 9617fbf46419..7cdd54548398 100644 --- a/src/pages/ReimbursementAccount/BankAccountStep.js +++ b/src/pages/ReimbursementAccount/BankAccountStep.js @@ -158,7 +158,7 @@ function BankAccountStep(props) { diff --git a/src/styles/colors.js b/src/styles/colors.js index 7aac0c2da6da..3b00a9a4c425 100644 --- a/src/styles/colors.js +++ b/src/styles/colors.js @@ -2,9 +2,8 @@ * DO NOT import colors.js into files. Use ../themes/default.js instead. */ export default { - dark: '#0b1b34', black: '#000000', - blue: '#0185ff', + white: '#E7ECE9', blueHover: '#B0D9FF', green: '#03D47C', greenHover: '#00C271', @@ -13,21 +12,18 @@ export default { redHover: '#DE4822', redPressed: '#F57959', redDisabled: '#F8AA97', - yellow: '#FED607', transparent: 'transparent', // Dark Mode Theme Colors - greenAppBackground: '#061B09', - greenHighlightBackground: '#07271F', - greenBorders: '#1A3D32', - greenIcons: '#8B9C8F', - greenSupportingText: '#AFBBB0', - greenPrimaryText: '#E7ECE9', - white: '#E7ECE9', - greenDefaultButton: '#184E3D', - greenDefaultButtonHover: '#2C6755', - greenDefaultButtonPressed: '#467164', - midnight: '#002140', + darkAppBackground: '#061B09', + darkHighlightBackground: '#07271F', + darkBorders: '#1A3D32', + darkIcons: '#8B9C8F', + darkSupportingText: '#AFBBB0', + darkPrimaryText: '#E7ECE9', + darkDefaultButton: '#184E3D', + darkDefaultButtonHover: '#2C6755', + darkDefaultButtonPressed: '#467164', // Light Mode Theme Colors lightAppBackground: '#FCFBF9', diff --git a/src/styles/themes/default.js b/src/styles/themes/default.js index b190c4c720cb..d885d6c578df 100644 --- a/src/styles/themes/default.js +++ b/src/styles/themes/default.js @@ -4,28 +4,28 @@ import SCREENS from '../../SCREENS'; const darkTheme = { // Figma keys - appBG: colors.greenAppBackground, + appBG: colors.darkAppBackground, splashBG: colors.green, - highlightBG: colors.greenHighlightBackground, - border: colors.greenBorders, - borderLighter: colors.greenDefaultButton, + highlightBG: colors.darkHighlightBackground, + border: colors.darkBorders, + borderLighter: colors.darkDefaultButton, borderFocus: colors.green, - icon: colors.greenIcons, + icon: colors.darkIcons, iconMenu: colors.green, - iconHovered: colors.greenPrimaryText, + iconHovered: colors.darkPrimaryText, iconSuccessFill: colors.green, - iconReversed: colors.greenAppBackground, - textSupporting: colors.greenSupportingText, - text: colors.greenPrimaryText, + iconReversed: colors.darkAppBackground, + textSupporting: colors.darkSupportingText, + text: colors.darkPrimaryText, link: colors.blue300, linkHover: colors.blue100, - buttonDefaultBG: colors.greenDefaultButton, - buttonHoveredBG: colors.greenDefaultButtonHover, - buttonPressedBG: colors.greenDefaultButtonPressed, + buttonDefaultBG: colors.darkDefaultButton, + buttonHoveredBG: colors.darkDefaultButtonHover, + buttonPressedBG: colors.darkDefaultButtonPressed, danger: colors.red, dangerHover: colors.redHover, dangerPressed: colors.redHover, - warning: colors.yellow, + warning: colors.yellow400, success: colors.green, successHover: colors.greenHover, successPressed: colors.greenPressed, @@ -35,37 +35,37 @@ const darkTheme = { dark: colors.blue800, // Additional keys - overlay: colors.greenHighlightBackground, - inverse: colors.greenPrimaryText, + overlay: colors.darkHighlightBackground, + inverse: colors.darkPrimaryText, shadow: colors.black, - componentBG: colors.greenAppBackground, - hoverComponentBG: colors.greenHighlightBackground, - activeComponentBG: colors.greenBorders, + componentBG: colors.darkAppBackground, + hoverComponentBG: colors.darkHighlightBackground, + activeComponentBG: colors.darkBorders, signInSidebar: colors.green800, - sidebar: colors.greenHighlightBackground, - sidebarHover: colors.greenAppBackground, - heading: colors.greenPrimaryText, - textLight: colors.greenPrimaryText, - textDark: colors.greenAppBackground, - textReversed: colors.greenAppBackground, - textBackground: colors.greenHighlightBackground, - textMutedReversed: colors.greenIcons, + sidebar: colors.darkHighlightBackground, + sidebarHover: colors.darkAppBackground, + heading: colors.darkPrimaryText, + textLight: colors.darkPrimaryText, + textDark: colors.darkAppBackground, + textReversed: colors.darkAppBackground, + textBackground: colors.darkHighlightBackground, + textMutedReversed: colors.darkIcons, textError: colors.red, - offline: colors.greenIcons, - modalBackdrop: colors.greenHighlightBackground, - modalBackground: colors.greenAppBackground, - cardBG: colors.greenHighlightBackground, - cardBorder: colors.greenHighlightBackground, - spinner: colors.greenSupportingText, + offline: colors.darkIcons, + modalBackdrop: colors.darkHighlightBackground, + modalBackground: colors.darkAppBackground, + cardBG: colors.darkHighlightBackground, + cardBorder: colors.darkHighlightBackground, + spinner: colors.darkSupportingText, unreadIndicator: colors.green, - placeholderText: colors.greenIcons, - heroCard: colors.blue, - uploadPreviewActivityIndicator: colors.greenHighlightBackground, + placeholderText: colors.darkIcons, + heroCard: colors.blue400, + uploadPreviewActivityIndicator: colors.darkHighlightBackground, dropUIBG: 'rgba(6,27,9,0.92)', dropTransparentOverlay: 'rgba(255,255,255,0)', checkBox: colors.green, - pickerOptionsTextColor: colors.greenPrimaryText, - imageCropBackgroundColor: colors.greenIcons, + pickerOptionsTextColor: colors.darkPrimaryText, + imageCropBackgroundColor: colors.darkIcons, fallbackIconColor: colors.green700, reactionActiveBackground: colors.green600, reactionActiveText: colors.green100, diff --git a/src/styles/themes/light.js b/src/styles/themes/light.js index 1e268398e175..f98ba9cb38f0 100644 --- a/src/styles/themes/light.js +++ b/src/styles/themes/light.js @@ -18,13 +18,13 @@ const lightTheme = { text: colors.lightPrimaryText, link: colors.blue600, linkHover: colors.blue500, - buttonDefaultBG: colors.greenDefaultButton, - buttonHoveredBG: colors.greenDefaultButtonHover, - buttonPressedBG: colors.greenDefaultButtonPressed, + buttonDefaultBG: colors.darkDefaultButton, + buttonHoveredBG: colors.darkDefaultButtonHover, + buttonPressedBG: colors.darkDefaultButtonPressed, danger: colors.red, dangerHover: colors.redHover, dangerPressed: colors.redHover, - warning: colors.yellow, + warning: colors.yellow400, success: colors.green, successHover: colors.greenHover, successPressed: colors.greenPressed, @@ -44,7 +44,7 @@ const lightTheme = { sidebar: colors.lightHighlightBackground, sidebarHover: colors.lightAppBackground, heading: colors.lightPrimaryText, - textLight: colors.greenPrimaryText, + textLight: colors.darkPrimaryText, textDark: colors.lightPrimaryText, textReversed: colors.lightAppBackground, textBackground: colors.lightHighlightBackground, @@ -58,7 +58,7 @@ const lightTheme = { spinner: colors.lightSupportingText, unreadIndicator: colors.green, placeholderText: colors.lightIcons, - heroCard: colors.blue, + heroCard: colors.blue400, uploadPreviewActivityIndicator: colors.lightHighlightBackground, dropUIBG: 'rgba(6,27,9,0.92)', dropTransparentOverlay: 'rgba(255,255,255,0)', From 0facffb9580cd2fbfaf28badf3f75cc2cbdb1baf Mon Sep 17 00:00:00 2001 From: Georgia Monahan Date: Mon, 17 Jul 2023 09:45:44 +0100 Subject: [PATCH 126/504] clean up hover styles for light theme --- src/styles/colors.js | 4 +--- src/styles/styles.js | 4 ++-- src/styles/themes/default.js | 4 +--- src/styles/themes/light.js | 18 +++++++++--------- 4 files changed, 13 insertions(+), 17 deletions(-) diff --git a/src/styles/colors.js b/src/styles/colors.js index 3b00a9a4c425..3dc4f3d1884b 100644 --- a/src/styles/colors.js +++ b/src/styles/colors.js @@ -3,15 +3,13 @@ */ export default { black: '#000000', - white: '#E7ECE9', - blueHover: '#B0D9FF', + white: '#FFFFFF', green: '#03D47C', greenHover: '#00C271', greenPressed: '#35DD96', red: '#F25730', redHover: '#DE4822', redPressed: '#F57959', - redDisabled: '#F8AA97', transparent: 'transparent', // Dark Mode Theme Colors diff --git a/src/styles/styles.js b/src/styles/styles.js index b27805b13515..aa3c3541770b 100644 --- a/src/styles/styles.js +++ b/src/styles/styles.js @@ -3281,7 +3281,7 @@ const styles = { }, fontColorReactionLabel: { - color: '#586A64', + color: themeColors.tooltipSupportingText, }, reactionEmojiTitle: { @@ -3290,7 +3290,7 @@ const styles = { }, textReactionSenders: { - color: themeColors.dark, + color: themeColors.tooltipPrimaryText, ...wordBreak.breakWord, }, diff --git a/src/styles/themes/default.js b/src/styles/themes/default.js index d885d6c578df..fe6e747372c7 100644 --- a/src/styles/themes/default.js +++ b/src/styles/themes/default.js @@ -30,9 +30,7 @@ const darkTheme = { successHover: colors.greenHover, successPressed: colors.greenPressed, transparent: colors.transparent, - midtone: colors.green700, signInPage: colors.green800, - dark: colors.blue800, // Additional keys overlay: colors.darkHighlightBackground, @@ -47,7 +45,7 @@ const darkTheme = { heading: colors.darkPrimaryText, textLight: colors.darkPrimaryText, textDark: colors.darkAppBackground, - textReversed: colors.darkAppBackground, + textReversed: colors.lightPrimaryText, textBackground: colors.darkHighlightBackground, textMutedReversed: colors.darkIcons, textError: colors.red, diff --git a/src/styles/themes/light.js b/src/styles/themes/light.js index f98ba9cb38f0..3aedacb77a45 100644 --- a/src/styles/themes/light.js +++ b/src/styles/themes/light.js @@ -18,9 +18,9 @@ const lightTheme = { text: colors.lightPrimaryText, link: colors.blue600, linkHover: colors.blue500, - buttonDefaultBG: colors.darkDefaultButton, - buttonHoveredBG: colors.darkDefaultButtonHover, - buttonPressedBG: colors.darkDefaultButtonPressed, + buttonDefaultBG: colors.lightDefaultButton, + buttonHoveredBG: colors.lightDefaultButtonHover, + buttonPressedBG: colors.lightDefaultButtonPressed, danger: colors.red, dangerHover: colors.redHover, dangerPressed: colors.redHover, @@ -29,9 +29,7 @@ const lightTheme = { successHover: colors.greenHover, successPressed: colors.greenPressed, transparent: colors.transparent, - midtone: colors.green700, signInPage: colors.green800, - dark: colors.blue800, // Additional keys overlay: colors.lightHighlightBackground, @@ -42,11 +40,11 @@ const lightTheme = { activeComponentBG: colors.lightBorders, signInSidebar: colors.green800, sidebar: colors.lightHighlightBackground, - sidebarHover: colors.lightAppBackground, + sidebarHover: colors.lightBorders, heading: colors.lightPrimaryText, - textLight: colors.darkPrimaryText, + textLight: colors.white, textDark: colors.lightPrimaryText, - textReversed: colors.lightAppBackground, + textReversed: colors.darkPrimaryText, textBackground: colors.lightHighlightBackground, textMutedReversed: colors.lightIcons, textError: colors.red, @@ -60,7 +58,7 @@ const lightTheme = { placeholderText: colors.lightIcons, heroCard: colors.blue400, uploadPreviewActivityIndicator: colors.lightHighlightBackground, - dropUIBG: 'rgba(6,27,9,0.92)', + dropUIBG: 'rgba(252, 251, 249, 0.92)', dropTransparentOverlay: 'rgba(255,255,255,0)', checkBox: colors.green, pickerOptionsTextColor: colors.lightPrimaryText, @@ -74,6 +72,8 @@ const lightTheme = { mentionBG: colors.blue100, ourMentionText: colors.green600, ourMentionBG: colors.green100, + tooltipSupportingText: colors.darkSupportingText, + tooltipPrimaryText: colors.darkPrimaryText, }; lightTheme.PAGE_BACKGROUND_COLORS = { From 3aec7e94f08b4618ef769795a5c112eaca1c7e89 Mon Sep 17 00:00:00 2001 From: Georgia Monahan Date: Tue, 18 Jul 2023 12:54:02 +0100 Subject: [PATCH 127/504] merge --- src/styles/colors.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/styles/colors.js b/src/styles/colors.js index 3dc4f3d1884b..9ac3226a1b80 100644 --- a/src/styles/colors.js +++ b/src/styles/colors.js @@ -4,6 +4,7 @@ export default { black: '#000000', white: '#FFFFFF', + ivory: '#fffaf0', green: '#03D47C', greenHover: '#00C271', greenPressed: '#35DD96', From 1a892d2fa0e49f7f69a7b2c231220582e5b0cf12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Fija=C5=82kiewicz?= Date: Tue, 18 Jul 2023 14:14:14 +0200 Subject: [PATCH 128/504] Convert SearchPage to functional component --- src/pages/SearchPage.js | 170 ++++++++++++++++++---------------------- 1 file changed, 76 insertions(+), 94 deletions(-) diff --git a/src/pages/SearchPage.js b/src/pages/SearchPage.js index 3e32922ebdd5..e1cdf92259d0 100755 --- a/src/pages/SearchPage.js +++ b/src/pages/SearchPage.js @@ -1,5 +1,5 @@ import _ from 'underscore'; -import React, {Component} from 'react'; +import React, {useCallback, useEffect, useState} from 'react'; import {View} from 'react-native'; import PropTypes from 'prop-types'; import {withOnyx} from 'react-native-onyx'; @@ -45,69 +45,68 @@ const defaultProps = { reports: {}, }; -class SearchPage extends Component { - constructor(props) { - super(props); +function SearchPage(props) { + const {recentReports: initialRecentReports, personalDetails: initialPersonalDetails, userToInvite: initialUserToInvite} = OptionsListUtils.getSearchOptions(props.reports, props.personalDetails, '', props.betas); - Timing.start(CONST.TIMING.SEARCH_RENDER); - Performance.markStart(CONST.TIMING.SEARCH_RENDER); + const [searchValue, setSearchValue] = useState('') + const [recentReports, setRecentReports] = useState(initialRecentReports) + const [personalDetails, setPersonalDetails] = useState(initialPersonalDetails) + const [userToInvite, setUserToInvite] = useState(initialUserToInvite) - this.searchRendered = this.searchRendered.bind(this); - this.selectReport = this.selectReport.bind(this); - this.onChangeText = this.onChangeText.bind(this); - this.debouncedUpdateOptions = _.debounce(this.updateOptions.bind(this), 75); + const updateOptions = useCallback(() => { + const {recentReports: localRecentReports, personalDetails: localPersonalDetails, userToInvite: localUserToInvite} = OptionsListUtils.getSearchOptions( + props.reports, + props.personalDetails, + searchValue.trim(), + props.betas, + ); - const {recentReports, personalDetails, userToInvite} = OptionsListUtils.getSearchOptions(props.reports, props.personalDetails, '', props.betas); + setUserToInvite(localUserToInvite) + setRecentReports(localRecentReports) + setPersonalDetails(localPersonalDetails) + }, [props.reports, props.personalDetails, searchValue, props.betas]) - this.state = { - searchValue: '', - recentReports, - personalDetails, - userToInvite, - }; - } + const debouncedUpdateOptions =_.debounce(updateOptions, 75); - componentDidUpdate(prevProps) { - if (_.isEqual(prevProps.reports, this.props.reports) && _.isEqual(prevProps.personalDetails, this.props.personalDetails)) { - return; - } - this.updateOptions(); - } + useEffect(() => { + Timing.start(CONST.TIMING.SEARCH_RENDER); + Performance.markStart(CONST.TIMING.SEARCH_RENDER); + },[]) - onChangeText(searchValue = '') { - this.setState({searchValue}, this.debouncedUpdateOptions); - } + useEffect(() => { + updateOptions(); + },[props.reports, props.personalDetails]) /** * Returns the sections needed for the OptionsSelector * * @returns {Array} */ - getSections() { + const getSections = () => { const sections = []; let indexOffset = 0; - if (this.state.recentReports.length > 0) { + if (recentReports.length > 0) { sections.push({ - data: this.state.recentReports, + data: recentReports, shouldShow: true, indexOffset, }); - indexOffset += this.state.recentReports.length; + indexOffset += recentReports.length; } - if (this.state.personalDetails.length > 0) { + if (personalDetails.length > 0) { sections.push({ - data: this.state.personalDetails, + data: personalDetails, shouldShow: true, indexOffset, }); - indexOffset += this.state.recentReports.length; + indexOffset += recentReports.length; } - if (this.state.userToInvite) { + if (userToInvite) { sections.push({ - data: [this.state.userToInvite], + data: [userToInvite], shouldShow: true, indexOffset, }); @@ -116,23 +115,17 @@ class SearchPage extends Component { return sections; } - searchRendered() { + const searchRendered = () => { Timing.end(CONST.TIMING.SEARCH_RENDER); Performance.markEnd(CONST.TIMING.SEARCH_RENDER); } - updateOptions() { - const {recentReports, personalDetails, userToInvite} = OptionsListUtils.getSearchOptions( - this.props.reports, - this.props.personalDetails, - this.state.searchValue.trim(), - this.props.betas, - ); - this.setState({ - userToInvite, - recentReports, - personalDetails, - }); + useEffect(() => { + debouncedUpdateOptions() + }, [searchValue]) + + const onChangeText = (value = '') => { + setSearchValue(value) } /** @@ -140,64 +133,53 @@ class SearchPage extends Component { * * @param {Object} option */ - selectReport(option) { + const selectReport = (option) => { if (!option) { return; } - if (option.reportID) { - this.setState( - { - searchValue: '', - }, - () => { - Navigation.dismissModal(option.reportID); - }, - ); + setSearchValue('') + Navigation.dismissModal(option.reportID); } else { Report.navigateToAndOpenReport([option.login]); } } - render() { - const sections = this.getSections(); - const isOptionsDataReady = ReportUtils.isReportDataReady() && OptionsListUtils.isPersonalDetailsReady(this.props.personalDetails); - const headerMessage = OptionsListUtils.getHeaderMessage( - this.state.recentReports.length + this.state.personalDetails.length !== 0, - Boolean(this.state.userToInvite), - this.state.searchValue, - ); - - return ( - - {({didScreenTransitionEnd, safeAreaPaddingBottomStyle}) => ( - <> - - - - - - )} - - ); - } + const isOptionsDataReady = ReportUtils.isReportDataReady() && OptionsListUtils.isPersonalDetailsReady(props.personalDetails); + const headerMessage = OptionsListUtils.getHeaderMessage( + recentReports.length + personalDetails.length !== 0, + Boolean(userToInvite), + searchValue, + ); + return ( + + {({didScreenTransitionEnd, safeAreaPaddingBottomStyle}) => ( + <> + + + + + + )} + + ) } SearchPage.propTypes = propTypes; SearchPage.defaultProps = defaultProps; - +SearchPage.displayName = 'SearchPage'; export default compose( withLocalize, withWindowDimensions, From a4a540a015b9746deaa6d862a54ef4b6826abc99 Mon Sep 17 00:00:00 2001 From: Georgia Monahan Date: Wed, 19 Jul 2023 11:39:15 +0100 Subject: [PATCH 129/504] Use Light Theme --- src/styles/themes/default.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/styles/themes/default.js b/src/styles/themes/default.js index 1d1aef4d16d8..aa03fbb9506a 100644 --- a/src/styles/themes/default.js +++ b/src/styles/themes/default.js @@ -1,6 +1,7 @@ /* eslint-disable no-unused-vars */ import colors from '../colors'; import SCREENS from '../../SCREENS'; +import lightTheme from './light'; const darkTheme = { // Figma keys @@ -81,4 +82,4 @@ darkTheme.PAGE_BACKGROUND_COLORS = { [SCREENS.SETTINGS.PREFERENCES]: colors.blue500, }; -export default darkTheme; +export default lightTheme; From 4f68432738611a244662344a275499d2322ec61c Mon Sep 17 00:00:00 2001 From: Georgia Monahan Date: Wed, 19 Jul 2023 15:06:54 +0100 Subject: [PATCH 130/504] use green400 in themes for readability, fix preferences page --- src/styles/themes/default.js | 14 +++++++------- src/styles/themes/light.js | 15 ++++++++------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/styles/themes/default.js b/src/styles/themes/default.js index 1d1aef4d16d8..145edb12b78c 100644 --- a/src/styles/themes/default.js +++ b/src/styles/themes/default.js @@ -5,15 +5,15 @@ import SCREENS from '../../SCREENS'; const darkTheme = { // Figma keys appBG: colors.darkAppBackground, - splashBG: colors.green, + splashBG: colors.green400, highlightBG: colors.darkHighlightBackground, border: colors.darkBorders, borderLighter: colors.darkDefaultButton, - borderFocus: colors.green, + borderFocus: colors.green400, icon: colors.darkIcons, - iconMenu: colors.green, + iconMenu: colors.green400, iconHovered: colors.darkPrimaryText, - iconSuccessFill: colors.green, + iconSuccessFill: colors.green400, iconReversed: colors.darkAppBackground, iconColorfulBackground: `${colors.ivory}cc`, textSupporting: colors.darkSupportingText, @@ -27,7 +27,7 @@ const darkTheme = { dangerHover: colors.redHover, dangerPressed: colors.redHover, warning: colors.yellow400, - success: colors.green, + success: colors.green400, successHover: colors.greenHover, successPressed: colors.greenPressed, transparent: colors.transparent, @@ -56,13 +56,13 @@ const darkTheme = { cardBG: colors.darkHighlightBackground, cardBorder: colors.darkHighlightBackground, spinner: colors.darkSupportingText, - unreadIndicator: colors.green, + unreadIndicator: colors.green400, placeholderText: colors.darkIcons, heroCard: colors.blue400, uploadPreviewActivityIndicator: colors.darkHighlightBackground, dropUIBG: 'rgba(6,27,9,0.92)', dropTransparentOverlay: 'rgba(255,255,255,0)', - checkBox: colors.green, + checkBox: colors.green400, pickerOptionsTextColor: colors.darkPrimaryText, imageCropBackgroundColor: colors.darkIcons, fallbackIconColor: colors.green700, diff --git a/src/styles/themes/light.js b/src/styles/themes/light.js index 3aedacb77a45..297722e08778 100644 --- a/src/styles/themes/light.js +++ b/src/styles/themes/light.js @@ -4,15 +4,15 @@ import SCREENS from '../../SCREENS'; const lightTheme = { // Figma keys appBG: colors.lightAppBackground, - splashBG: colors.green, + splashBG: colors.green400, highlightBG: colors.lightHighlightBackground, border: colors.lightBorders, borderLighter: colors.lightDefaultButtonPressed, - borderFocus: colors.green, + borderFocus: colors.green400, icon: colors.lightIcons, - iconMenu: colors.green, + iconMenu: colors.green400, iconHovered: colors.lightPrimaryText, - iconSuccessFill: colors.green, + iconSuccessFill: colors.green400, iconReversed: colors.lightAppBackground, textSupporting: colors.lightSupportingText, text: colors.lightPrimaryText, @@ -25,7 +25,7 @@ const lightTheme = { dangerHover: colors.redHover, dangerPressed: colors.redHover, warning: colors.yellow400, - success: colors.green, + success: colors.green400, successHover: colors.greenHover, successPressed: colors.greenPressed, transparent: colors.transparent, @@ -54,13 +54,13 @@ const lightTheme = { cardBG: colors.lightHighlightBackground, cardBorder: colors.lightHighlightBackground, spinner: colors.lightSupportingText, - unreadIndicator: colors.green, + unreadIndicator: colors.green400, placeholderText: colors.lightIcons, heroCard: colors.blue400, uploadPreviewActivityIndicator: colors.lightHighlightBackground, dropUIBG: 'rgba(252, 251, 249, 0.92)', dropTransparentOverlay: 'rgba(255,255,255,0)', - checkBox: colors.green, + checkBox: colors.green400, pickerOptionsTextColor: colors.lightPrimaryText, imageCropBackgroundColor: colors.lightIcons, fallbackIconColor: colors.green700, @@ -78,6 +78,7 @@ const lightTheme = { lightTheme.PAGE_BACKGROUND_COLORS = { [SCREENS.HOME]: lightTheme.sidebar, + [SCREENS.SETTINGS.PREFERENCES]: colors.blue500, }; export default lightTheme; From 666d370530a03e537ba4f50fdb38e70c381593ef Mon Sep 17 00:00:00 2001 From: Georgia Monahan Date: Wed, 19 Jul 2023 15:39:28 +0100 Subject: [PATCH 131/504] use text color instead of textLight --- src/styles/StyleUtils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/styles/StyleUtils.js b/src/styles/StyleUtils.js index 21af895ae5a6..ad50ebe2296d 100644 --- a/src/styles/StyleUtils.js +++ b/src/styles/StyleUtils.js @@ -1099,7 +1099,7 @@ function getEmojiReactionCounterTextStyle(hasUserReacted) { return {color: themeColors.reactionActiveText}; } - return {color: themeColors.textLight}; + return {color: themeColors.text}; } /** From 88b810581b2216ce656777a52412724f58c5880a Mon Sep 17 00:00:00 2001 From: Georgia Monahan Date: Mon, 24 Jul 2023 12:13:53 +0100 Subject: [PATCH 132/504] Fix skeletonUI --- src/components/OptionsList/BaseOptionsList.js | 2 +- src/components/OptionsListSkeletonView.js | 4 ++-- src/components/ReportActionsSkeletonView/SkeletonViewLines.js | 4 ++-- src/pages/home/sidebar/SidebarLinks.js | 2 +- src/styles/themes/default.js | 4 ++++ src/styles/themes/light.js | 2 ++ 6 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/components/OptionsList/BaseOptionsList.js b/src/components/OptionsList/BaseOptionsList.js index 9c5777e222c9..469f1a9eac64 100644 --- a/src/components/OptionsList/BaseOptionsList.js +++ b/src/components/OptionsList/BaseOptionsList.js @@ -208,7 +208,7 @@ class BaseOptionsList extends Component { return ( {this.props.isLoading ? ( - + ) : ( <> {this.props.headerMessage ? ( diff --git a/src/components/OptionsListSkeletonView.js b/src/components/OptionsListSkeletonView.js index ffe9652e3945..15c66affe84d 100644 --- a/src/components/OptionsListSkeletonView.js +++ b/src/components/OptionsListSkeletonView.js @@ -60,8 +60,8 @@ class OptionsListSkeletonView extends React.Component { key={`skeletonViewItems${i}`} animate={this.props.shouldAnimate} height={CONST.LHN_SKELETON_VIEW_ITEM_HEIGHT} - backgroundColor={themeColors.borderLighter} - foregroundColor={themeColors.border} + backgroundColor={themeColors.skeletonLHNIn} + foregroundColor={themeColors.skeletonLHNOut} style={styles.mr5} > diff --git a/src/styles/themes/default.js b/src/styles/themes/default.js index 7998ed6f44d1..27fe348da6d3 100644 --- a/src/styles/themes/default.js +++ b/src/styles/themes/default.js @@ -75,6 +75,10 @@ const darkTheme = { mentionBG: colors.blue600, ourMentionText: colors.green100, ourMentionBG: colors.green600, + tooltipSupportingText: colors.lightSupportingText, + tooltipPrimaryText: colors.lightPrimaryText, + skeletonLHNIn: colors.darkBorders, + skeletonLHNOut: colors.darkDefaultButton, }; darkTheme.PAGE_BACKGROUND_COLORS = { diff --git a/src/styles/themes/light.js b/src/styles/themes/light.js index 297722e08778..b43c834ac70b 100644 --- a/src/styles/themes/light.js +++ b/src/styles/themes/light.js @@ -74,6 +74,8 @@ const lightTheme = { ourMentionBG: colors.green100, tooltipSupportingText: colors.darkSupportingText, tooltipPrimaryText: colors.darkPrimaryText, + skeletonLHNIn: colors.lightBorders, + skeletonLHNOut: colors.lightDefaultButtonPressed, }; lightTheme.PAGE_BACKGROUND_COLORS = { From c9b198b9c1ae0e1840218357851a58b7223fd049 Mon Sep 17 00:00:00 2001 From: Georgia Monahan Date: Mon, 24 Jul 2023 12:22:26 +0100 Subject: [PATCH 133/504] Change toggle color --- src/components/QRShare/index.js | 2 +- src/styles/styles.js | 2 +- src/styles/themes/default.js | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/components/QRShare/index.js b/src/components/QRShare/index.js index 5dc2c53dc8d3..8b9a1db05618 100644 --- a/src/components/QRShare/index.js +++ b/src/components/QRShare/index.js @@ -50,7 +50,7 @@ class QRShare extends Component { > diff --git a/src/styles/styles.js b/src/styles/styles.js index 976c97c93e18..d364b683766e 100644 --- a/src/styles/styles.js +++ b/src/styles/styles.js @@ -2484,7 +2484,7 @@ const styles = { }, switchInactive: { - backgroundColor: themeColors.border, + backgroundColor: themeColors.icon, }, switchThumb: { diff --git a/src/styles/themes/default.js b/src/styles/themes/default.js index 27fe348da6d3..eb69703a8505 100644 --- a/src/styles/themes/default.js +++ b/src/styles/themes/default.js @@ -79,6 +79,7 @@ const darkTheme = { tooltipPrimaryText: colors.lightPrimaryText, skeletonLHNIn: colors.darkBorders, skeletonLHNOut: colors.darkDefaultButton, + QRLogo: colors.green500, }; darkTheme.PAGE_BACKGROUND_COLORS = { From 5eed00487fdcfb02be4be5fc66cf6832dc032e1f Mon Sep 17 00:00:00 2001 From: Georgia Monahan Date: Mon, 24 Jul 2023 18:49:27 +0100 Subject: [PATCH 134/504] fix light theme QR color --- src/styles/themes/default.js | 2 +- src/styles/themes/light.js | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/styles/themes/default.js b/src/styles/themes/default.js index eb69703a8505..4a53be9ab312 100644 --- a/src/styles/themes/default.js +++ b/src/styles/themes/default.js @@ -79,7 +79,7 @@ const darkTheme = { tooltipPrimaryText: colors.lightPrimaryText, skeletonLHNIn: colors.darkBorders, skeletonLHNOut: colors.darkDefaultButton, - QRLogo: colors.green500, + QRLogo: colors.green400, }; darkTheme.PAGE_BACKGROUND_COLORS = { diff --git a/src/styles/themes/light.js b/src/styles/themes/light.js index b43c834ac70b..7d2a88daeba1 100644 --- a/src/styles/themes/light.js +++ b/src/styles/themes/light.js @@ -76,6 +76,7 @@ const lightTheme = { tooltipPrimaryText: colors.darkPrimaryText, skeletonLHNIn: colors.lightBorders, skeletonLHNOut: colors.lightDefaultButtonPressed, + QRLogo: colors.green500, }; lightTheme.PAGE_BACKGROUND_COLORS = { From a45b938e10f3a47054e2c7d6b9d7a3c2e6658b26 Mon Sep 17 00:00:00 2001 From: Georgia Monahan Date: Mon, 24 Jul 2023 18:51:38 +0100 Subject: [PATCH 135/504] fix preferences page --- src/styles/themes/light.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/styles/themes/light.js b/src/styles/themes/light.js index 7d2a88daeba1..8bc01bb31cf6 100644 --- a/src/styles/themes/light.js +++ b/src/styles/themes/light.js @@ -14,6 +14,7 @@ const lightTheme = { iconHovered: colors.lightPrimaryText, iconSuccessFill: colors.green400, iconReversed: colors.lightAppBackground, + iconColorfulBackground: `${colors.ivory}cc`, textSupporting: colors.lightSupportingText, text: colors.lightPrimaryText, link: colors.blue600, From 2d2676e5f1322f9bdd4b0c9864e03ed83b9b1004 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Fija=C5=82kiewicz?= Date: Tue, 25 Jul 2023 11:00:22 +0200 Subject: [PATCH 136/504] Fix comments in SearchPage refactoring --- src/pages/SearchPage.js | 82 +++++++++++++++++------------------------ 1 file changed, 33 insertions(+), 49 deletions(-) diff --git a/src/pages/SearchPage.js b/src/pages/SearchPage.js index e1cdf92259d0..b072e74b51b5 100755 --- a/src/pages/SearchPage.js +++ b/src/pages/SearchPage.js @@ -1,5 +1,5 @@ import _ from 'underscore'; -import React, {useCallback, useEffect, useState} from 'react'; +import React, {useCallback, useEffect, useState, useMemo} from 'react'; import {View} from 'react-native'; import PropTypes from 'prop-types'; import {withOnyx} from 'react-native-onyx'; @@ -9,17 +9,16 @@ import * as ReportUtils from '../libs/ReportUtils'; import ONYXKEYS from '../ONYXKEYS'; import styles from '../styles/styles'; import Navigation from '../libs/Navigation/Navigation'; -import withWindowDimensions, {windowDimensionsPropTypes} from '../components/withWindowDimensions'; import * as Report from '../libs/actions/Report'; import HeaderWithBackButton from '../components/HeaderWithBackButton'; import ScreenWrapper from '../components/ScreenWrapper'; import Timing from '../libs/actions/Timing'; import CONST from '../CONST'; -import withLocalize, {withLocalizePropTypes} from '../components/withLocalize'; import compose from '../libs/compose'; import personalDetailsPropType from './personalDetailsPropType'; import reportPropTypes from './reportPropTypes'; import Performance from '../libs/Performance'; +import useLocalize from '../hooks/useLocalize'; const propTypes = { /* Onyx Props */ @@ -32,41 +31,33 @@ const propTypes = { /** All reports shared with the user */ reports: PropTypes.objectOf(reportPropTypes), - - /** Window Dimensions Props */ - ...windowDimensionsPropTypes, - - ...withLocalizePropTypes, }; -const defaultProps = { - betas: [], - personalDetails: {}, - reports: {}, -}; - -function SearchPage(props) { - const {recentReports: initialRecentReports, personalDetails: initialPersonalDetails, userToInvite: initialUserToInvite} = OptionsListUtils.getSearchOptions(props.reports, props.personalDetails, '', props.betas); +function SearchPage({betas = [], personalDetails = {}, reports= {}}) { + //Data for initialization (runs only on the first render) + const {recentReports: initialRecentReports, personalDetails: initialPersonalDetails, userToInvite: initialUserToInvite} = useMemo(() => OptionsListUtils.getSearchOptions(reports, personalDetails, '', betas), []); const [searchValue, setSearchValue] = useState('') - const [recentReports, setRecentReports] = useState(initialRecentReports) - const [personalDetails, setPersonalDetails] = useState(initialPersonalDetails) - const [userToInvite, setUserToInvite] = useState(initialUserToInvite) + const [activeRecentReports, setActiveRecentReports] = useState(initialRecentReports) + const [activePersonalDetails, setActivePersonalDetails] = useState(initialPersonalDetails) + const [activeUserToInvite, setActiveUserToInvite] = useState(initialUserToInvite) + + const {translate} = useLocalize(); const updateOptions = useCallback(() => { const {recentReports: localRecentReports, personalDetails: localPersonalDetails, userToInvite: localUserToInvite} = OptionsListUtils.getSearchOptions( - props.reports, - props.personalDetails, + reports, + personalDetails, searchValue.trim(), - props.betas, + betas, ); - setUserToInvite(localUserToInvite) - setRecentReports(localRecentReports) - setPersonalDetails(localPersonalDetails) - }, [props.reports, props.personalDetails, searchValue, props.betas]) + setActiveUserToInvite(localUserToInvite) + setActiveRecentReports(localRecentReports) + setActivePersonalDetails(localPersonalDetails) + }, [reports, personalDetails, searchValue, betas]) - const debouncedUpdateOptions =_.debounce(updateOptions, 75); + const debouncedUpdateOptions = useCallback(() => _.debounce(updateOptions, 75), [updateOptions]); useEffect(() => { Timing.start(CONST.TIMING.SEARCH_RENDER); @@ -74,8 +65,8 @@ function SearchPage(props) { },[]) useEffect(() => { - updateOptions(); - },[props.reports, props.personalDetails]) + debouncedUpdateOptions() + }, [searchValue, debouncedUpdateOptions]) /** * Returns the sections needed for the OptionsSelector @@ -86,27 +77,27 @@ function SearchPage(props) { const sections = []; let indexOffset = 0; - if (recentReports.length > 0) { + if (activeRecentReports.length > 0) { sections.push({ - data: recentReports, + data: activeRecentReports, shouldShow: true, indexOffset, }); - indexOffset += recentReports.length; + indexOffset += activeRecentReports.length; } - if (personalDetails.length > 0) { + if (activePersonalDetails.length > 0) { sections.push({ - data: personalDetails, + data: activePersonalDetails, shouldShow: true, indexOffset, }); - indexOffset += recentReports.length; + indexOffset += activeRecentReports.length; } - if (userToInvite) { + if (activeUserToInvite) { sections.push({ - data: [userToInvite], + data: [activeUserToInvite], shouldShow: true, indexOffset, }); @@ -120,10 +111,6 @@ function SearchPage(props) { Performance.markEnd(CONST.TIMING.SEARCH_RENDER); } - useEffect(() => { - debouncedUpdateOptions() - }, [searchValue]) - const onChangeText = (value = '') => { setSearchValue(value) } @@ -145,17 +132,17 @@ function SearchPage(props) { } } - const isOptionsDataReady = ReportUtils.isReportDataReady() && OptionsListUtils.isPersonalDetailsReady(props.personalDetails); + const isOptionsDataReady = ReportUtils.isReportDataReady() && OptionsListUtils.isPersonalDetailsReady(personalDetails); const headerMessage = OptionsListUtils.getHeaderMessage( - recentReports.length + personalDetails.length !== 0, - Boolean(userToInvite), + activeRecentReports.length + activePersonalDetails.length !== 0, + Boolean(activeUserToInvite), searchValue, ); return ( {({didScreenTransitionEnd, safeAreaPaddingBottomStyle}) => ( <> - + @@ -178,11 +165,8 @@ function SearchPage(props) { } SearchPage.propTypes = propTypes; -SearchPage.defaultProps = defaultProps; SearchPage.displayName = 'SearchPage'; export default compose( - withLocalize, - withWindowDimensions, withOnyx({ reports: { key: ONYXKEYS.COLLECTION.REPORT, From 804cc201dee44305de01eb2a56d0b1cad0a9ef4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Fija=C5=82kiewicz?= Date: Wed, 26 Jul 2023 11:50:29 +0200 Subject: [PATCH 137/504] refactor state in SearchPage --- src/pages/SearchPage.js | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/pages/SearchPage.js b/src/pages/SearchPage.js index b072e74b51b5..3f3e9bb380bf 100755 --- a/src/pages/SearchPage.js +++ b/src/pages/SearchPage.js @@ -38,9 +38,11 @@ function SearchPage({betas = [], personalDetails = {}, reports= {}}) { const {recentReports: initialRecentReports, personalDetails: initialPersonalDetails, userToInvite: initialUserToInvite} = useMemo(() => OptionsListUtils.getSearchOptions(reports, personalDetails, '', betas), []); const [searchValue, setSearchValue] = useState('') - const [activeRecentReports, setActiveRecentReports] = useState(initialRecentReports) - const [activePersonalDetails, setActivePersonalDetails] = useState(initialPersonalDetails) - const [activeUserToInvite, setActiveUserToInvite] = useState(initialUserToInvite) + const [searchOptions, setSearchOptions] = useState({ + recentReports: initialRecentReports, + personalDetails: initialPersonalDetails, + userToInvite: initialUserToInvite + }); const {translate} = useLocalize(); @@ -52,9 +54,7 @@ function SearchPage({betas = [], personalDetails = {}, reports= {}}) { betas, ); - setActiveUserToInvite(localUserToInvite) - setActiveRecentReports(localRecentReports) - setActivePersonalDetails(localPersonalDetails) + setSearchOptions({recentReports: localRecentReports, personalDetails: localPersonalDetails, userToInvite: localUserToInvite}) }, [reports, personalDetails, searchValue, betas]) const debouncedUpdateOptions = useCallback(() => _.debounce(updateOptions, 75), [updateOptions]); @@ -77,27 +77,27 @@ function SearchPage({betas = [], personalDetails = {}, reports= {}}) { const sections = []; let indexOffset = 0; - if (activeRecentReports.length > 0) { + if (searchOptions.recentReports.length > 0) { sections.push({ - data: activeRecentReports, + data: searchOptions.recentReports, shouldShow: true, indexOffset, }); - indexOffset += activeRecentReports.length; + indexOffset += searchOptions.recentReports.length; } - if (activePersonalDetails.length > 0) { + if (searchOptions.personalDetails.length > 0) { sections.push({ - data: activePersonalDetails, + data: searchOptions.personalDetails, shouldShow: true, indexOffset, }); - indexOffset += activeRecentReports.length; + indexOffset += searchOptions.recentReports.length; } - if (activeUserToInvite) { + if (searchOptions.userToInvite) { sections.push({ - data: [activeUserToInvite], + data: [searchOptions.userToInvite], shouldShow: true, indexOffset, }); @@ -134,8 +134,8 @@ function SearchPage({betas = [], personalDetails = {}, reports= {}}) { const isOptionsDataReady = ReportUtils.isReportDataReady() && OptionsListUtils.isPersonalDetailsReady(personalDetails); const headerMessage = OptionsListUtils.getHeaderMessage( - activeRecentReports.length + activePersonalDetails.length !== 0, - Boolean(activeUserToInvite), + searchOptions.recentReports.length + searchOptions.personalDetails.length !== 0, + Boolean(searchOptions.userToInvite), searchValue, ); return ( From d49f2714a715529bbe47a2de39456fbcec624df5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Fija=C5=82kiewicz?= Date: Wed, 26 Jul 2023 11:58:39 +0200 Subject: [PATCH 138/504] fix typo --- src/pages/SearchPage.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/SearchPage.js b/src/pages/SearchPage.js index 3f3e9bb380bf..1b063fc3bec1 100755 --- a/src/pages/SearchPage.js +++ b/src/pages/SearchPage.js @@ -33,8 +33,8 @@ const propTypes = { reports: PropTypes.objectOf(reportPropTypes), }; -function SearchPage({betas = [], personalDetails = {}, reports= {}}) { - //Data for initialization (runs only on the first render) +function SearchPage({betas = [], personalDetails = {}, reports = {}}) { + // Data for initialization (runs only on the first render) const {recentReports: initialRecentReports, personalDetails: initialPersonalDetails, userToInvite: initialUserToInvite} = useMemo(() => OptionsListUtils.getSearchOptions(reports, personalDetails, '', betas), []); const [searchValue, setSearchValue] = useState('') From c187f69ee49ffe081819fb3a1cb61020f894137b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Fija=C5=82kiewicz?= Date: Wed, 26 Jul 2023 12:08:42 +0200 Subject: [PATCH 139/504] fix debounced updated function --- src/pages/SearchPage.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/SearchPage.js b/src/pages/SearchPage.js index 1b063fc3bec1..6cc5076bee97 100755 --- a/src/pages/SearchPage.js +++ b/src/pages/SearchPage.js @@ -57,7 +57,7 @@ function SearchPage({betas = [], personalDetails = {}, reports = {}}) { setSearchOptions({recentReports: localRecentReports, personalDetails: localPersonalDetails, userToInvite: localUserToInvite}) }, [reports, personalDetails, searchValue, betas]) - const debouncedUpdateOptions = useCallback(() => _.debounce(updateOptions, 75), [updateOptions]); + const debouncedUpdateOptions = useCallback(_.debounce(updateOptions, 75), [updateOptions]); useEffect(() => { Timing.start(CONST.TIMING.SEARCH_RENDER); From 22bcfce5efa3feb4d0e4d007fa85a12e10af1ebb Mon Sep 17 00:00:00 2001 From: Georgia Monahan Date: Fri, 28 Jul 2023 14:31:11 +0100 Subject: [PATCH 140/504] Still use darkTheme --- src/styles/themes/default.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/styles/themes/default.js b/src/styles/themes/default.js index 4a53be9ab312..7067f51242c2 100644 --- a/src/styles/themes/default.js +++ b/src/styles/themes/default.js @@ -1,7 +1,6 @@ /* eslint-disable no-unused-vars */ import colors from '../colors'; import SCREENS from '../../SCREENS'; -import lightTheme from './light'; const darkTheme = { // Figma keys @@ -87,4 +86,4 @@ darkTheme.PAGE_BACKGROUND_COLORS = { [SCREENS.SETTINGS.PREFERENCES]: colors.blue500, }; -export default lightTheme; +export default darkTheme; From d05008c8750919560466cf03b1e17ff21f49ce52 Mon Sep 17 00:00:00 2001 From: Georgia Monahan Date: Fri, 28 Jul 2023 14:33:47 +0100 Subject: [PATCH 141/504] merge new key --- src/styles/themes/light.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/styles/themes/light.js b/src/styles/themes/light.js index 8bc01bb31cf6..ddb8f6bb85d3 100644 --- a/src/styles/themes/light.js +++ b/src/styles/themes/light.js @@ -15,6 +15,7 @@ const lightTheme = { iconSuccessFill: colors.green400, iconReversed: colors.lightAppBackground, iconColorfulBackground: `${colors.ivory}cc`, + textColorfulBackground: colors.ivory, textSupporting: colors.lightSupportingText, text: colors.lightPrimaryText, link: colors.blue600, From b1ccade1105dd208ce74107601ae33333c4a9ae4 Mon Sep 17 00:00:00 2001 From: Georgia Monahan Date: Fri, 28 Jul 2023 14:35:03 +0100 Subject: [PATCH 142/504] make QR logo 400 --- src/styles/themes/light.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/styles/themes/light.js b/src/styles/themes/light.js index ddb8f6bb85d3..82717f35f124 100644 --- a/src/styles/themes/light.js +++ b/src/styles/themes/light.js @@ -78,7 +78,7 @@ const lightTheme = { tooltipPrimaryText: colors.darkPrimaryText, skeletonLHNIn: colors.lightBorders, skeletonLHNOut: colors.lightDefaultButtonPressed, - QRLogo: colors.green500, + QRLogo: colors.green400, }; lightTheme.PAGE_BACKGROUND_COLORS = { From 41e6d57b3ef4681bcb9d3e141aa5835094f6cc5e Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Thu, 3 Aug 2023 16:39:55 +0200 Subject: [PATCH 143/504] Check setup before tests Added a script that checks the environment setup before running the workflow tests See: https://github.com/Expensify/App/issues/13604 --- package.json | 2 +- workflow_tests/scripts/runWorkflowTests.sh | 53 ++++++++++++++++++++++ 2 files changed, 54 insertions(+), 1 deletion(-) create mode 100755 workflow_tests/scripts/runWorkflowTests.sh diff --git a/package.json b/package.json index 75eb0fe6bfdc..f451822dab7a 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,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 --runInBand", + "workflow-test": "./workflow_tests/scripts/runWorkflowTests.sh", "workflow-test:generate": "node workflow_tests/utils/preGenerateTest.js" }, "dependencies": { diff --git a/workflow_tests/scripts/runWorkflowTests.sh b/workflow_tests/scripts/runWorkflowTests.sh new file mode 100755 index 000000000000..91f6dd9748a8 --- /dev/null +++ b/workflow_tests/scripts/runWorkflowTests.sh @@ -0,0 +1,53 @@ +#!/bin/bash + +source ./scripts/shellUtils.sh + +title 'GitHub Actions workflow tests' +printf '\n' + +# Check setup +info 'Checking environment setup' + +# Check if docker is installed +if ! docker --version > /dev/null 2>&1; then + error 'Docker is not installed' + info 'Act requires docker to be installed. Please install docker and try again' + exit 1 +fi +info 'Docker installed' + +# Check if docker is running +if ! docker info > /dev/null 2>&1; then + error 'Docker is not running' + info 'Act requires docker engine to be running. Enable docker engine and try again' + exit 1 +fi +info 'Docker engine running' + +# Check if act is installed +if ! act --version > /dev/null 2>&1; then + error 'Act not installed' + info 'Install Act with brew install act and follow the documentation on first Act run (https://github.com/nektos/act#first-act-run)' + exit 1 +fi +info 'Act installed' + +# Check if ACT_BINARY is set +if [[ -z ${ACT_BINARY} ]]; then + error 'ACT_BINARY variable not set' + info 'To make sure Act behaves in a predictable manner please set the ACT_BINARY environment variable to the path to your Act binary' + exit 1 +fi +info 'ACT_BINARY environment variable set' + +if ! eval '${ACT_BINARY} --version' > /dev/null 2>&1; then + error 'ACT_BINARY variable not set properly' + info 'ACT_BINARY environment variable should be set to the path to your Act executable. Please set the variable correctly (try running `which act` to check the path)' + exit 1 +fi +info 'ACT_BINARY environment variable set to an Act executable' + +success 'Environment setup properly - running tests' + +# Run tests +npm test -- --config=workflow_tests/jest.config.js --runInBand From 1f5e3360b99d8491707d6c1cd0260dcf57e23791 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Thu, 3 Aug 2023 16:56:33 +0200 Subject: [PATCH 144/504] Fix syntax Shellcheck was failing See: https://github.com/Expensify/App/issues/13604 --- workflow_tests/scripts/runWorkflowTests.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/workflow_tests/scripts/runWorkflowTests.sh b/workflow_tests/scripts/runWorkflowTests.sh index 91f6dd9748a8..4a29ad634206 100755 --- a/workflow_tests/scripts/runWorkflowTests.sh +++ b/workflow_tests/scripts/runWorkflowTests.sh @@ -42,7 +42,7 @@ info 'ACT_BINARY environment variable set' if ! eval '${ACT_BINARY} --version' > /dev/null 2>&1; then error 'ACT_BINARY variable not set properly' - info 'ACT_BINARY environment variable should be set to the path to your Act executable. Please set the variable correctly (try running `which act` to check the path)' + info 'ACT_BINARY environment variable should be set to the path to your Act executable. Please set the variable correctly (try running "which act" to check the path)' exit 1 fi info 'ACT_BINARY environment variable set to an Act executable' From a1013717c627c25556caa44b6513ccb6285042f4 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Fri, 4 Aug 2023 11:22:57 +0200 Subject: [PATCH 145/504] Sync with upstream Merged changes from upstream repository, resolved conflicts, updated workflow tests See: https://github.com/Expensify/App/issues/13604 --- package-lock.json | 412 ++++++++++++++++-- .../assertions/cherryPickAssertions.js | 4 +- .../assertions/preDeployAssertions.js | 13 + workflow_tests/mocks/cherryPickMocks.js | 8 +- workflow_tests/mocks/preDeployMocks.js | 5 + workflow_tests/preDeploy.test.js | 145 ++++++ 6 files changed, 533 insertions(+), 54 deletions(-) diff --git a/package-lock.json b/package-lock.json index 6ac853f3c5ab..9018ff8d6196 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,7 +17,9 @@ "@formatjs/intl-numberformat": "^8.5.0", "@formatjs/intl-pluralrules": "^5.2.2", "@gorhom/portal": "^1.0.14", - "@oguzhnatly/react-native-image-manipulator": "github:Expensify/react-native-image-manipulator#5cdae3d4455b03a04c57f50be3863e2fe6c92c52", + "@kie/act-js": "^2.0.1", + "@kie/mock-github": "^1.0.0", + "@oguzhnatly/react-native-image-manipulator": "github:Expensify/react-native-image-manipulator#c5f654fc9d0ad7cc5b89d50b34ecf8b0e3f4d050", "@onfido/react-native-sdk": "7.4.0", "@react-native-async-storage/async-storage": "^1.17.10", "@react-native-camera-roll/camera-roll": "5.4.0", @@ -33,6 +35,7 @@ "@react-navigation/native": "6.1.6", "@react-navigation/stack": "6.3.16", "@react-ng/bounds-observer": "^0.2.1", + "@types/node": "^18.14.0", "@ua/react-native-airship": "^15.2.6", "awesome-phonenumber": "^5.4.0", "babel-plugin-transform-remove-console": "^6.9.4", @@ -119,6 +122,8 @@ "@babel/runtime": "^7.20.0", "@electron/notarize": "^1.2.3", "@jest/globals": "^29.5.0", + "@kie/act-js": "^2.0.1", + "@kie/mock-github": "^1.0.0", "@octokit/core": "4.0.4", "@octokit/plugin-paginate-rest": "3.1.0", "@octokit/plugin-throttling": "4.1.0", @@ -213,7 +218,8 @@ "webpack-cli": "^4.10.0", "webpack-dev-server": "^4.9.3", "webpack-font-preload-plugin": "^1.5.0", - "webpack-merge": "^5.8.0" + "webpack-merge": "^5.8.0", + "yaml": "^2.2.1" }, "engines": { "node": "16.15.1", @@ -5332,6 +5338,65 @@ "react-native": "*" } }, + "node_modules/@kie/act-js": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/@kie/act-js/-/act-js-2.2.1.tgz", + "integrity": "sha512-YbID5l0ZVpxRgshi35ZYFbEYo/W6ISinxXh0LKJJkfW9jyv+ouF/11cxIAaPHbV64+HHiAKIosj9mw8TbJFDFA==", + "dev": true, + "hasInstallScript": true, + "dependencies": { + "@kie/mock-github": "^1.0.3", + "adm-zip": "^0.5.10", + "ajv": "^8.12.0", + "bin-links": "^4.0.1", + "express": "^4.18.1", + "follow-redirects": "^1.15.2", + "tar": "^6.1.13", + "yaml": "^2.1.3" + }, + "bin": { + "act-js": "bin/act" + } + }, + "node_modules/@kie/mock-github": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@kie/mock-github/-/mock-github-1.1.0.tgz", + "integrity": "sha512-fD+utlOiyZSOutOcXL0G9jfjbtvOO44PLUyTfgfkrm1+575R/dbvU6AcJfjc1DtHeRv7FC7f4ebyU+a1wgL6CA==", + "dev": true, + "dependencies": { + "@octokit/openapi-types-ghec": "^14.0.0", + "ajv": "^8.11.0", + "express": "^4.18.1", + "fast-glob": "^3.2.12", + "fs-extra": "^10.1.0", + "nock": "^13.2.7", + "simple-git": "^3.8.0", + "totalist": "^3.0.0" + } + }, + "node_modules/@kie/mock-github/node_modules/fs-extra": { + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz", + "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==", + "dev": true, + "dependencies": { + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^2.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/@kie/mock-github/node_modules/totalist": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/totalist/-/totalist-3.0.1.tgz", + "integrity": "sha512-sf4i37nQ2LBx4m3wB74y+ubopq6W/dIzXg0FDGjsYnZHVa1Da8FH853wlL2gtUhg+xJXjfk3kUZS3BRoQeoQBQ==", + "dev": true, + "engines": { + "node": ">=6" + } + }, "node_modules/@kwsites/file-exists": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/@kwsites/file-exists/-/file-exists-1.1.1.tgz", @@ -5755,6 +5820,12 @@ "dev": true, "license": "MIT" }, + "node_modules/@octokit/openapi-types-ghec": { + "version": "14.0.0", + "resolved": "https://registry.npmjs.org/@octokit/openapi-types-ghec/-/openapi-types-ghec-14.0.0.tgz", + "integrity": "sha512-xhd9oEvn2aroGn+sk09Ptx/76Y7aKU0EIgHukHPCU1+rGJreO36baEEk6k8ZPblieHNM39FcykJQmtDrETm0KA==", + "dev": true + }, "node_modules/@octokit/plugin-paginate-rest": { "version": "3.1.0", "dev": true, @@ -5861,8 +5932,8 @@ }, "node_modules/@oguzhnatly/react-native-image-manipulator": { "version": "1.0.5", - "resolved": "git+ssh://git@github.com/Expensify/react-native-image-manipulator.git#5cdae3d4455b03a04c57f50be3863e2fe6c92c52", - "integrity": "sha512-C9Br1BQqm6io6lvYHptlLcOHbzlaqxp9tS35P8Qj3pdiiYRTzU3KPvZ61rQ+ZnZ4FOQ6MwPsKsmB8+6WHkAY6Q==", + "resolved": "git+ssh://git@github.com/Expensify/react-native-image-manipulator.git#c5f654fc9d0ad7cc5b89d50b34ecf8b0e3f4d050", + "integrity": "sha512-PvrSoCq5PS1MA5ZWUpB0khfzH6sM8SI6YiVl4i2SItPr7IeRxiWfI4n45VhBCCElc1z5GhAwTZOBaIzXTX7/og==", "license": "MIT" }, "node_modules/@onfido/active-video-capture": { @@ -6458,14 +6529,6 @@ "node": ">=8" } }, - "node_modules/@react-native-community/cli-doctor/node_modules/yaml": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.3.1.tgz", - "integrity": "sha512-2eHWfjaoXgTBC2jNM1LRef62VQa0umtvRiDSk6HSzW7RvS5YtkabJrwYLLEKWBc8a5U2PTSCs+dJjUTJdlHsWQ==", - "engines": { - "node": ">= 14" - } - }, "node_modules/@react-native-community/cli-hermes": { "version": "11.3.3", "resolved": "https://registry.npmjs.org/@react-native-community/cli-hermes/-/cli-hermes-11.3.3.tgz", @@ -17993,6 +18056,15 @@ "node": ">= 10.0.0" } }, + "node_modules/adm-zip": { + "version": "0.5.10", + "resolved": "https://registry.npmjs.org/adm-zip/-/adm-zip-0.5.10.tgz", + "integrity": "sha512-x0HvcHqVJNTPk/Bw8JbLWlWoo6Wwnsug0fnYYro1HBrjxZ3G7/AZk7Ahv8JwDe1uIcz8eBqvu86FuF1POiG7vQ==", + "dev": true, + "engines": { + "node": ">=6.0" + } + }, "node_modules/agent-base": { "version": "6.0.2", "dev": true, @@ -18055,8 +18127,9 @@ } }, "node_modules/ajv": { - "version": "8.11.0", - "license": "MIT", + "version": "8.12.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.12.0.tgz", + "integrity": "sha512-sRu1kpcO9yLtYxBKvqfTeh9KzZEwO3STyX1HT+4CaDzC6HpTGYhIhPIzj9XuKU7KYDwnaeh5hcOwjy1QuJzBPA==", "dependencies": { "fast-deep-equal": "^3.1.1", "json-schema-traverse": "^1.0.0", @@ -19871,6 +19944,46 @@ "node": "*" } }, + "node_modules/bin-links": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/bin-links/-/bin-links-4.0.2.tgz", + "integrity": "sha512-jxJ0PbXR8eQyPlExCvCs3JFnikvs1Yp4gUJt6nmgathdOwvur+q22KWC3h20gvWl4T/14DXKj2IlkJwwZkZPOw==", + "dev": true, + "dependencies": { + "cmd-shim": "^6.0.0", + "npm-normalize-package-bin": "^3.0.0", + "read-cmd-shim": "^4.0.0", + "write-file-atomic": "^5.0.0" + }, + "engines": { + "node": "^14.17.0 || ^16.13.0 || >=18.0.0" + } + }, + "node_modules/bin-links/node_modules/signal-exit": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", + "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", + "dev": true, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/bin-links/node_modules/write-file-atomic": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-5.0.1.tgz", + "integrity": "sha512-+QU2zd6OTD8XWIJCbffaiQeH9U73qIqafo1x6V1snCWYGJf6cVE0cDR4D8xRzcEnfI21IFrUPzPGtcPf8AC+Rw==", + "dev": true, + "dependencies": { + "imurmurhash": "^0.1.4", + "signal-exit": "^4.0.1" + }, + "engines": { + "node": "^14.17.0 || ^16.13.0 || >=18.0.0" + } + }, "node_modules/binary-extensions": { "version": "2.2.0", "devOptional": true, @@ -21305,6 +21418,15 @@ "node": ">=6" } }, + "node_modules/cmd-shim": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/cmd-shim/-/cmd-shim-6.0.1.tgz", + "integrity": "sha512-S9iI9y0nKR4hwEQsVWpyxld/6kRfGepGfzff83FcaiEBpmvlbA2nnGe7Cylgrx2f/p1P5S5wpRm9oL8z1PbS3Q==", + "dev": true, + "engines": { + "node": "^14.17.0 || ^16.13.0 || >=18.0.0" + } + }, "node_modules/co": { "version": "4.6.0", "license": "MIT", @@ -21949,6 +22071,15 @@ "node": ">=10" } }, + "node_modules/cosmiconfig/node_modules/yaml": { + "version": "1.10.2", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-1.10.2.tgz", + "integrity": "sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==", + "dev": true, + "engines": { + "node": ">= 6" + } + }, "node_modules/cp-file": { "version": "7.0.0", "dev": true, @@ -26079,9 +26210,10 @@ "license": "MIT" }, "node_modules/fast-glob": { - "version": "3.2.11", + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.1.tgz", + "integrity": "sha512-kNFPyjhh5cKjrUltxs+wFx+ZkbRaxxmZ+X0ZU31SOsxCEtP9VPgtq2teZw1DebupL5GmDaNQ6yKMMVcM41iqDg==", "dev": true, - "license": "MIT", "dependencies": { "@nodelib/fs.stat": "^2.0.2", "@nodelib/fs.walk": "^1.2.3", @@ -26552,7 +26684,9 @@ } }, "node_modules/follow-redirects": { - "version": "1.15.1", + "version": "1.15.2", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.2.tgz", + "integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==", "dev": true, "funding": [ { @@ -26560,7 +26694,6 @@ "url": "https://github.com/sponsors/RubenVerborgh" } ], - "license": "MIT", "engines": { "node": ">=4.0" }, @@ -26759,6 +26892,15 @@ "node": ">=8" } }, + "node_modules/fork-ts-checker-webpack-plugin/node_modules/yaml": { + "version": "1.10.2", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-1.10.2.tgz", + "integrity": "sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==", + "dev": true, + "engines": { + "node": ">= 6" + } + }, "node_modules/form-data": { "version": "3.0.1", "dev": true, @@ -35312,6 +35454,21 @@ "node": ">=12.0.0" } }, + "node_modules/nock": { + "version": "13.3.2", + "resolved": "https://registry.npmjs.org/nock/-/nock-13.3.2.tgz", + "integrity": "sha512-CwbljitiWJhF1gL83NbanhoKs1l23TDlRioNraPTZrzZIEooPemrHRj5m0FZCPkB1ecdYCSWWGcHysJgX/ngnQ==", + "dev": true, + "dependencies": { + "debug": "^4.1.0", + "json-stringify-safe": "^5.0.1", + "lodash": "^4.17.21", + "propagate": "^2.0.0" + }, + "engines": { + "node": ">= 10.13" + } + }, "node_modules/node-abi": { "version": "3.45.0", "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.45.0.tgz", @@ -35616,6 +35773,15 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/npm-normalize-package-bin": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/npm-normalize-package-bin/-/npm-normalize-package-bin-3.0.1.tgz", + "integrity": "sha512-dMxCf+zZ+3zeQZXKxmyuCKlIDPGuv8EF940xbkC4kQVDTtqoh6rJFO+JTKSA6/Rwi0getWmtuy4Itup0AMcaDQ==", + "dev": true, + "engines": { + "node": "^14.17.0 || ^16.13.0 || >=18.0.0" + } + }, "node_modules/npm-run-path": { "version": "4.0.1", "license": "MIT", @@ -36575,14 +36741,6 @@ "node": ">=0.6.0" } }, - "node_modules/patch-package/node_modules/yaml": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.3.1.tgz", - "integrity": "sha512-2eHWfjaoXgTBC2jNM1LRef62VQa0umtvRiDSk6HSzW7RvS5YtkabJrwYLLEKWBc8a5U2PTSCs+dJjUTJdlHsWQ==", - "engines": { - "node": ">= 14" - } - }, "node_modules/path-browserify": { "version": "0.0.1", "license": "MIT" @@ -37242,6 +37400,15 @@ "react-is": "^16.13.1" } }, + "node_modules/propagate": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/propagate/-/propagate-2.0.1.tgz", + "integrity": "sha512-vGrhOavPSTz4QVNuBNdcNXePNdNMaO1xj9yBeH1ScQPjk/rhg9sSlCXPhMkFuaNNW/syTvYqsnbIJxMBfRbbag==", + "dev": true, + "engines": { + "node": ">= 8" + } + }, "node_modules/property-information": { "version": "5.6.0", "dev": true, @@ -39125,6 +39292,15 @@ "react-dom": ">=16.2.0" } }, + "node_modules/read-cmd-shim": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/read-cmd-shim/-/read-cmd-shim-4.0.0.tgz", + "integrity": "sha512-yILWifhaSEEytfXI76kB9xEEiG1AiozaCJZ83A87ytjRiN+jVibXjedjCRNjoZviinhG+4UkalO3mWTd8u5O0Q==", + "dev": true, + "engines": { + "node": "^14.17.0 || ^16.13.0 || >=18.0.0" + } + }, "node_modules/read-config-file": { "version": "6.3.2", "resolved": "https://registry.npmjs.org/read-config-file/-/read-config-file-6.3.2.tgz", @@ -45045,11 +45221,11 @@ "license": "ISC" }, "node_modules/yaml": { - "version": "1.10.2", - "dev": true, - "license": "ISC", + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.3.1.tgz", + "integrity": "sha512-2eHWfjaoXgTBC2jNM1LRef62VQa0umtvRiDSk6HSzW7RvS5YtkabJrwYLLEKWBc8a5U2PTSCs+dJjUTJdlHsWQ==", "engines": { - "node": ">= 6" + "node": ">= 14" } }, "node_modules/yargs": { @@ -48694,6 +48870,57 @@ "version": "2.3.1", "requires": {} }, + "@kie/act-js": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/@kie/act-js/-/act-js-2.2.1.tgz", + "integrity": "sha512-YbID5l0ZVpxRgshi35ZYFbEYo/W6ISinxXh0LKJJkfW9jyv+ouF/11cxIAaPHbV64+HHiAKIosj9mw8TbJFDFA==", + "dev": true, + "requires": { + "@kie/mock-github": "^1.0.3", + "adm-zip": "^0.5.10", + "ajv": "^8.12.0", + "bin-links": "^4.0.1", + "express": "^4.18.1", + "follow-redirects": "^1.15.2", + "tar": "^6.1.13", + "yaml": "^2.1.3" + } + }, + "@kie/mock-github": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@kie/mock-github/-/mock-github-1.1.0.tgz", + "integrity": "sha512-fD+utlOiyZSOutOcXL0G9jfjbtvOO44PLUyTfgfkrm1+575R/dbvU6AcJfjc1DtHeRv7FC7f4ebyU+a1wgL6CA==", + "dev": true, + "requires": { + "@octokit/openapi-types-ghec": "^14.0.0", + "ajv": "^8.11.0", + "express": "^4.18.1", + "fast-glob": "^3.2.12", + "fs-extra": "^10.1.0", + "nock": "^13.2.7", + "simple-git": "^3.8.0", + "totalist": "^3.0.0" + }, + "dependencies": { + "fs-extra": { + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz", + "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==", + "dev": true, + "requires": { + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^2.0.0" + } + }, + "totalist": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/totalist/-/totalist-3.0.1.tgz", + "integrity": "sha512-sf4i37nQ2LBx4m3wB74y+ubopq6W/dIzXg0FDGjsYnZHVa1Da8FH853wlL2gtUhg+xJXjfk3kUZS3BRoQeoQBQ==", + "dev": true + } + } + }, "@kwsites/file-exists": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/@kwsites/file-exists/-/file-exists-1.1.1.tgz", @@ -49006,6 +49233,12 @@ "version": "12.11.0", "dev": true }, + "@octokit/openapi-types-ghec": { + "version": "14.0.0", + "resolved": "https://registry.npmjs.org/@octokit/openapi-types-ghec/-/openapi-types-ghec-14.0.0.tgz", + "integrity": "sha512-xhd9oEvn2aroGn+sk09Ptx/76Y7aKU0EIgHukHPCU1+rGJreO36baEEk6k8ZPblieHNM39FcykJQmtDrETm0KA==", + "dev": true + }, "@octokit/plugin-paginate-rest": { "version": "3.1.0", "dev": true, @@ -49084,9 +49317,9 @@ } }, "@oguzhnatly/react-native-image-manipulator": { - "version": "git+ssh://git@github.com/Expensify/react-native-image-manipulator.git#5cdae3d4455b03a04c57f50be3863e2fe6c92c52", - "integrity": "sha512-C9Br1BQqm6io6lvYHptlLcOHbzlaqxp9tS35P8Qj3pdiiYRTzU3KPvZ61rQ+ZnZ4FOQ6MwPsKsmB8+6WHkAY6Q==", - "from": "@oguzhnatly/react-native-image-manipulator@github:Expensify/react-native-image-manipulator#5cdae3d4455b03a04c57f50be3863e2fe6c92c52" + "version": "git+ssh://git@github.com/Expensify/react-native-image-manipulator.git#c5f654fc9d0ad7cc5b89d50b34ecf8b0e3f4d050", + "integrity": "sha512-PvrSoCq5PS1MA5ZWUpB0khfzH6sM8SI6YiVl4i2SItPr7IeRxiWfI4n45VhBCCElc1z5GhAwTZOBaIzXTX7/og==", + "from": "@oguzhnatly/react-native-image-manipulator@github:Expensify/react-native-image-manipulator#c5f654fc9d0ad7cc5b89d50b34ecf8b0e3f4d050" }, "@onfido/active-video-capture": { "version": "0.27.12", @@ -49629,11 +49862,6 @@ "requires": { "has-flag": "^4.0.0" } - }, - "yaml": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.3.1.tgz", - "integrity": "sha512-2eHWfjaoXgTBC2jNM1LRef62VQa0umtvRiDSk6HSzW7RvS5YtkabJrwYLLEKWBc8a5U2PTSCs+dJjUTJdlHsWQ==" } } }, @@ -57381,6 +57609,12 @@ "version": "1.2.1", "dev": true }, + "adm-zip": { + "version": "0.5.10", + "resolved": "https://registry.npmjs.org/adm-zip/-/adm-zip-0.5.10.tgz", + "integrity": "sha512-x0HvcHqVJNTPk/Bw8JbLWlWoo6Wwnsug0fnYYro1HBrjxZ3G7/AZk7Ahv8JwDe1uIcz8eBqvu86FuF1POiG7vQ==", + "dev": true + }, "agent-base": { "version": "6.0.2", "dev": true, @@ -57431,7 +57665,9 @@ } }, "ajv": { - "version": "8.11.0", + "version": "8.12.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.12.0.tgz", + "integrity": "sha512-sRu1kpcO9yLtYxBKvqfTeh9KzZEwO3STyX1HT+4CaDzC6HpTGYhIhPIzj9XuKU7KYDwnaeh5hcOwjy1QuJzBPA==", "requires": { "fast-deep-equal": "^3.1.1", "json-schema-traverse": "^1.0.0", @@ -58681,6 +58917,36 @@ "version": "5.2.2", "devOptional": true }, + "bin-links": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/bin-links/-/bin-links-4.0.2.tgz", + "integrity": "sha512-jxJ0PbXR8eQyPlExCvCs3JFnikvs1Yp4gUJt6nmgathdOwvur+q22KWC3h20gvWl4T/14DXKj2IlkJwwZkZPOw==", + "dev": true, + "requires": { + "cmd-shim": "^6.0.0", + "npm-normalize-package-bin": "^3.0.0", + "read-cmd-shim": "^4.0.0", + "write-file-atomic": "^5.0.0" + }, + "dependencies": { + "signal-exit": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", + "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", + "dev": true + }, + "write-file-atomic": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-5.0.1.tgz", + "integrity": "sha512-+QU2zd6OTD8XWIJCbffaiQeH9U73qIqafo1x6V1snCWYGJf6cVE0cDR4D8xRzcEnfI21IFrUPzPGtcPf8AC+Rw==", + "dev": true, + "requires": { + "imurmurhash": "^0.1.4", + "signal-exit": "^4.0.1" + } + } + } + }, "binary-extensions": { "version": "2.2.0", "devOptional": true @@ -59644,6 +59910,12 @@ "resolved": "https://registry.npmjs.org/clsx/-/clsx-1.2.1.tgz", "integrity": "sha512-EcR6r5a8bj6pu3ycsa/E/cKVGuTgZJZdsyUYHOksG/UHIiKfjxzRxYJpyVBwYaQeOvghal9fcc4PidlgzugAQg==" }, + "cmd-shim": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/cmd-shim/-/cmd-shim-6.0.1.tgz", + "integrity": "sha512-S9iI9y0nKR4hwEQsVWpyxld/6kRfGepGfzff83FcaiEBpmvlbA2nnGe7Cylgrx2f/p1P5S5wpRm9oL8z1PbS3Q==", + "dev": true + }, "co": { "version": "4.6.0" }, @@ -60067,6 +60339,14 @@ "parse-json": "^5.0.0", "path-type": "^4.0.0", "yaml": "^1.10.0" + }, + "dependencies": { + "yaml": { + "version": "1.10.2", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-1.10.2.tgz", + "integrity": "sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==", + "dev": true + } } }, "cp-file": { @@ -62877,7 +63157,9 @@ "version": "4.0.3" }, "fast-glob": { - "version": "3.2.11", + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.1.tgz", + "integrity": "sha512-kNFPyjhh5cKjrUltxs+wFx+ZkbRaxxmZ+X0ZU31SOsxCEtP9VPgtq2teZw1DebupL5GmDaNQ6yKMMVcM41iqDg==", "dev": true, "requires": { "@nodelib/fs.stat": "^2.0.2", @@ -63209,7 +63491,9 @@ } }, "follow-redirects": { - "version": "1.15.1", + "version": "1.15.2", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.2.tgz", + "integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==", "dev": true }, "for-each": { @@ -63324,6 +63608,12 @@ "requires": { "has-flag": "^4.0.0" } + }, + "yaml": { + "version": "1.10.2", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-1.10.2.tgz", + "integrity": "sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==", + "dev": true } } }, @@ -69032,6 +69322,18 @@ "resolved": "https://registry.npmjs.org/nocache/-/nocache-3.0.4.tgz", "integrity": "sha512-WDD0bdg9mbq6F4mRxEYcPWwfA1vxd0mrvKOyxI7Xj/atfRHVeutzuWByG//jfm4uPzp0y4Kj051EORCBSQMycw==" }, + "nock": { + "version": "13.3.2", + "resolved": "https://registry.npmjs.org/nock/-/nock-13.3.2.tgz", + "integrity": "sha512-CwbljitiWJhF1gL83NbanhoKs1l23TDlRioNraPTZrzZIEooPemrHRj5m0FZCPkB1ecdYCSWWGcHysJgX/ngnQ==", + "dev": true, + "requires": { + "debug": "^4.1.0", + "json-stringify-safe": "^5.0.1", + "lodash": "^4.17.21", + "propagate": "^2.0.0" + } + }, "node-abi": { "version": "3.45.0", "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.45.0.tgz", @@ -69260,6 +69562,12 @@ "version": "6.1.0", "dev": true }, + "npm-normalize-package-bin": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/npm-normalize-package-bin/-/npm-normalize-package-bin-3.0.1.tgz", + "integrity": "sha512-dMxCf+zZ+3zeQZXKxmyuCKlIDPGuv8EF940xbkC4kQVDTtqoh6rJFO+JTKSA6/Rwi0getWmtuy4Itup0AMcaDQ==", + "dev": true + }, "npm-run-path": { "version": "4.0.1", "requires": { @@ -69876,11 +70184,6 @@ "requires": { "os-tmpdir": "~1.0.2" } - }, - "yaml": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.3.1.tgz", - "integrity": "sha512-2eHWfjaoXgTBC2jNM1LRef62VQa0umtvRiDSk6HSzW7RvS5YtkabJrwYLLEKWBc8a5U2PTSCs+dJjUTJdlHsWQ==" } } }, @@ -70306,6 +70609,12 @@ "react-is": "^16.13.1" } }, + "propagate": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/propagate/-/propagate-2.0.1.tgz", + "integrity": "sha512-vGrhOavPSTz4QVNuBNdcNXePNdNMaO1xj9yBeH1ScQPjk/rhg9sSlCXPhMkFuaNNW/syTvYqsnbIJxMBfRbbag==", + "dev": true + }, "property-information": { "version": "5.6.0", "dev": true, @@ -71526,6 +71835,12 @@ "integrity": "sha512-2W5WN8wmEv8ZlxvyAlOxVuw6new8Bi7+KSPqoq5oa7z1KSKZ72ucaKqCFRtHSuFjZ5sh5ioS9lp4BGwnaZ6lDg==", "requires": {} }, + "read-cmd-shim": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/read-cmd-shim/-/read-cmd-shim-4.0.0.tgz", + "integrity": "sha512-yILWifhaSEEytfXI76kB9xEEiG1AiozaCJZ83A87ytjRiN+jVibXjedjCRNjoZviinhG+4UkalO3mWTd8u5O0Q==", + "dev": true + }, "read-config-file": { "version": "6.3.2", "resolved": "https://registry.npmjs.org/read-config-file/-/read-config-file-6.3.2.tgz", @@ -75520,8 +75835,9 @@ "version": "4.0.0" }, "yaml": { - "version": "1.10.2", - "dev": true + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.3.1.tgz", + "integrity": "sha512-2eHWfjaoXgTBC2jNM1LRef62VQa0umtvRiDSk6HSzW7RvS5YtkabJrwYLLEKWBc8a5U2PTSCs+dJjUTJdlHsWQ==" }, "yargs": { "version": "13.3.2", diff --git a/workflow_tests/assertions/cherryPickAssertions.js b/workflow_tests/assertions/cherryPickAssertions.js index c628f1211055..42ecc3d64262 100644 --- a/workflow_tests/assertions/cherryPickAssertions.js +++ b/workflow_tests/assertions/cherryPickAssertions.js @@ -39,6 +39,8 @@ const assertCherryPickJobExecuted = (workflowResult, user = 'Dummy Author', pull [], ), utils.createStepAssertion('Set up git for OSBotify', true, null, 'CHERRYPICK', 'Setting up git for OSBotify', [{key: 'GPG_PASSPHRASE', value: '***'}], []), + utils.createStepAssertion('Get previous app version', true, null, 'CHERRYPICK', 'Get previous app version', [{key: 'SEMVER_LEVEL', value: 'PATCH'}]), + utils.createStepAssertion('Fetch history of relevant refs', true, null, 'CHERRYPICK', 'Fetch history of relevant refs'), utils.createStepAssertion('Get version bump commit', true, null, 'CHERRYPICK', 'Get version bump commit', [], []), utils.createStepAssertion( 'Get merge commit for pull request to CP', @@ -53,8 +55,6 @@ const assertCherryPickJobExecuted = (workflowResult, user = 'Dummy Author', pull ], [], ), - utils.createStepAssertion('Get previous app version', true, null, 'CHERRYPICK', 'Get previous app version', [{key: 'SEMVER_LEVEL', value: 'PATCH'}]), - utils.createStepAssertion('Fetch history of relevant refs', true, null, 'CHERRYPICK', 'Fetch history of relevant refs'), utils.createStepAssertion('Cherry-pick the version-bump to staging', true, null, 'CHERRYPICK', 'Cherry-picking the version-bump to staging', [], []), utils.createStepAssertion('Cherry-pick the merge commit of target PR', true, null, 'CHERRYPICK', 'Cherry-picking the merge commit of target PR', [], []), utils.createStepAssertion('Push changes', true, null, 'CHERRYPICK', 'Pushing changes', [], []), diff --git a/workflow_tests/assertions/preDeployAssertions.js b/workflow_tests/assertions/preDeployAssertions.js index a93172abf200..e1749c07f603 100644 --- a/workflow_tests/assertions/preDeployAssertions.js +++ b/workflow_tests/assertions/preDeployAssertions.js @@ -1,5 +1,17 @@ const utils = require('../utils/utils'); +const assertTypecheckJobExecuted = (workflowResult, didExecute = true) => { + const steps = [utils.createStepAssertion('Run typecheck workflow', true, null, 'TYPECHECK', 'Running typecheck workflow')]; + + steps.forEach((expectedStep) => { + if (didExecute) { + expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); + } else { + expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); + } + }); +}; + const assertLintJobExecuted = (workflowResult, didExecute = true) => { const steps = [utils.createStepAssertion('Run lint workflow', true, null, 'LINT', 'Running lint workflow')]; @@ -200,6 +212,7 @@ const assertUpdateStagingJobFailed = (workflowResult, didFail = false) => { }; module.exports = { + assertTypecheckJobExecuted, assertLintJobExecuted, assertTestJobExecuted, assertIsExpensifyEmployeeJobExecuted, diff --git a/workflow_tests/mocks/cherryPickMocks.js b/workflow_tests/mocks/cherryPickMocks.js index 924c51767031..778e6fd48ded 100644 --- a/workflow_tests/mocks/cherryPickMocks.js +++ b/workflow_tests/mocks/cherryPickMocks.js @@ -37,6 +37,8 @@ const CHERRYPICK__CREATENEWVERSION__STEP_MOCKS = [CHERRYPICK__CREATENEWVERSION__ // cherrypick const CHERRYPICK__CHERRYPICK__CHECKOUT_STAGING_BRANCH__STEP_MOCK = utils.createMockStep('Checkout staging branch', 'Checking out staging branch', 'CHERRYPICK', ['ref', 'token'], []); const CHERRYPICK__CHERRYPICK__SET_UP_GIT_FOR_OSBOTIFY__STEP_MOCK = utils.createMockStep('Set up git for OSBotify', 'Setting up git for OSBotify', 'CHERRYPICK', ['GPG_PASSPHRASE'], []); +const CHERRYPICK__CHERRYPICK__GET_PREVIOUS_APP_VERSION__STEP_MOCK = utils.createMockStep('Get previous app version', 'Get previous app version', 'CHERRYPICK', ['SEMVER_LEVEL']); +const CHERRYPICK__CHERRYPICK__FETCH_HISTORY_OF_RELEVANT_REFS__STEP_MOCK = utils.createMockStep('Fetch history of relevant refs', 'Fetch history of relevant refs', 'CHERRYPICK'); const CHERRYPICK__CHERRYPICK__GET_VERSION_BUMP_COMMIT__STEP_MOCK = utils.createMockStep('Get version bump commit', 'Get version bump commit', 'CHERRYPICK', [], [], { VERSION_BUMP_SHA: 'version_bump_sha', }); @@ -48,8 +50,6 @@ const CHERRYPICK__CHERRYPICK__GET_MERGE_COMMIT_FOR_PULL_REQUEST_TO_CP__STEP_MOCK [], {MERGE_ACTOR: '@dummyauthor'}, ); -const CHERRYPICK__CHERRYPICK__GET_PREVIOUS_APP_VERSION__STEP_MOCK = utils.createMockStep('Get previous app version', 'Get previous app version', 'CHERRYPICK', ['SEMVER_LEVEL']); -const CHERRYPICK__CHERRYPICK__FETCH_HISTORY_OF_RELEVANT_REFS__STEP_MOCK = utils.createMockStep('Fetch history of relevant refs', 'Fetch history of relevant refs', 'CHERRYPICK'); const CHERRYPICK__CHERRYPICK__CHERRY_PICK_THE_VERSION_BUMP_TO_STAGING__STEP_MOCK = utils.createMockStep( 'Cherry-pick the version-bump to staging', 'Cherry-picking the version-bump to staging', @@ -93,10 +93,10 @@ const CHERRYPICK__CHERRYPICK__ANNOUNCES_A_CP_FAILURE_IN_THE_ANNOUNCE_SLACK_ROOM_ const getCherryPickMockSteps = (upToDate, hasConflicts) => [ CHERRYPICK__CHERRYPICK__CHECKOUT_STAGING_BRANCH__STEP_MOCK, CHERRYPICK__CHERRYPICK__SET_UP_GIT_FOR_OSBOTIFY__STEP_MOCK, - CHERRYPICK__CHERRYPICK__GET_VERSION_BUMP_COMMIT__STEP_MOCK, - CHERRYPICK__CHERRYPICK__GET_MERGE_COMMIT_FOR_PULL_REQUEST_TO_CP__STEP_MOCK, CHERRYPICK__CHERRYPICK__GET_PREVIOUS_APP_VERSION__STEP_MOCK, CHERRYPICK__CHERRYPICK__FETCH_HISTORY_OF_RELEVANT_REFS__STEP_MOCK, + CHERRYPICK__CHERRYPICK__GET_VERSION_BUMP_COMMIT__STEP_MOCK, + CHERRYPICK__CHERRYPICK__GET_MERGE_COMMIT_FOR_PULL_REQUEST_TO_CP__STEP_MOCK, CHERRYPICK__CHERRYPICK__CHERRY_PICK_THE_VERSION_BUMP_TO_STAGING__STEP_MOCK, hasConflicts ? CHERRYPICK__CHERRYPICK__CHERRY_PICK_THE_MERGE_COMMIT_OF_TARGET_PR_TO_NEW_BRANCH__HAS_CONFLICTS__STEP_MOCK diff --git a/workflow_tests/mocks/preDeployMocks.js b/workflow_tests/mocks/preDeployMocks.js index cfc868debadd..88fa8e8c2020 100644 --- a/workflow_tests/mocks/preDeployMocks.js +++ b/workflow_tests/mocks/preDeployMocks.js @@ -1,5 +1,9 @@ const utils = require('../utils/utils'); +// typecheck +const TYPECHECK_WORKFLOW_MOCK_STEP = utils.createMockStep('Run typecheck workflow', 'Running typecheck workflow', 'TYPECHECK'); +const TYPECHECK_JOB_MOCK_STEPS = [TYPECHECK_WORKFLOW_MOCK_STEP]; + // lint const LINT_WORKFLOW_MOCK_STEP = utils.createMockStep('Run lint workflow', 'Running lint workflow', 'LINT'); const LINT_JOB_MOCK_STEPS = [LINT_WORKFLOW_MOCK_STEP]; @@ -187,6 +191,7 @@ const PREDEPLOY__E2EPERFORMANCETESTS__PERFORM_E2E_TESTS__MOCK_STEP = utils.creat const PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS = [PREDEPLOY__E2EPERFORMANCETESTS__PERFORM_E2E_TESTS__MOCK_STEP]; module.exports = { + TYPECHECK_JOB_MOCK_STEPS, LINT_JOB_MOCK_STEPS, TEST_JOB_MOCK_STEPS, CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, diff --git a/workflow_tests/preDeploy.test.js b/workflow_tests/preDeploy.test.js index eb2376eb61f8..3c3b26c85a1c 100644 --- a/workflow_tests/preDeploy.test.js +++ b/workflow_tests/preDeploy.test.js @@ -72,6 +72,10 @@ describe('test workflow preDeploy', () => { newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, }; const testMockJobs = { + typecheck: { + steps: mocks.TYPECHECK_JOB_MOCK_STEPS, + runsOn: 'ubuntu-latest', + }, lint: { steps: mocks.LINT_JOB_MOCK_STEPS, runsOn: 'ubuntu-latest', @@ -105,6 +109,7 @@ describe('test workflow preDeploy', () => { // assert results (some steps can run in parallel to each other so the order is not assured // therefore we can check which steps have been executed, but not the set job order + assertions.assertTypecheckJobExecuted(result); assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); assertions.assertIsExpensifyEmployeeJobExecuted(result); @@ -127,6 +132,10 @@ describe('test workflow preDeploy', () => { newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, }; const testMockJobs = { + typecheck: { + steps: mocks.TYPECHECK_JOB_MOCK_STEPS, + runsOn: 'ubuntu-latest', + }, lint: { steps: mocks.LINT_JOB_MOCK_STEPS, runsOn: 'ubuntu-latest', @@ -168,6 +177,7 @@ describe('test workflow preDeploy', () => { logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), mockJobs: testMockJobs, }); + assertions.assertTypecheckJobExecuted(result, false); assertions.assertLintJobExecuted(result, false); assertions.assertTestJobExecuted(result, false); assertions.assertIsExpensifyEmployeeJobExecuted(result, false); @@ -195,6 +205,7 @@ describe('test workflow preDeploy', () => { logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), mockJobs: testMockJobs, }); + assertions.assertTypecheckJobExecuted(result, false); assertions.assertLintJobExecuted(result, false); assertions.assertTestJobExecuted(result, false); assertions.assertIsExpensifyEmployeeJobExecuted(result, false); @@ -205,6 +216,80 @@ describe('test workflow preDeploy', () => { }); describe('confirm passing build', () => { + it('typecheck job failed - workflow exits', async () => { + const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; + const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); + let act = new eAct.ExtendedAct(repoPath, workflowPath); + act = utils.setUpActParams( + act, + 'push', + {ref: 'refs/heads/main'}, + { + OS_BOTIFY_TOKEN: 'dummy_token', + SLACK_WEBHOOK: 'dummy_slack_webhook', + LARGE_SECRET_PASSPHRASE: '3xtr3m3ly_53cr3t_p455w0rd', + }, + 'dummy_github_token', + ); + const testMockSteps = { + confirmPassingBuild: mocks.CONFIRM_PASSING_BUILD_JOB_MOCK_STEPS, + chooseDeployActions: mocks.CHOOSE_DEPLOY_ACTIONS_JOB_MOCK_STEPS__STAGING_UNLOCKED, + skipDeploy: mocks.SKIP_DEPLOY_JOB_MOCK_STEPS, + updateStaging: mocks.UPDATE_STAGING_JOB_MOCK_STEPS, + isExpensifyEmployee: mocks.IS_EXPENSIFY_EMPLOYEE_JOB_MOCK_STEPS__TRUE, + newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, + }; + const testMockJobs = { + typecheck: { + steps: [utils.createMockStep('Run typecheck workflow', 'Running typecheck workflow - Typecheck workflow failed', 'TYPECHECK', null, null, null, null, false)], + runsOn: 'ubuntu-latest', + }, + lint: { + steps: mocks.LINT_JOB_MOCK_STEPS, + runsOn: 'ubuntu-latest', + }, + test: { + steps: mocks.TEST_JOB_MOCK_STEPS, + runsOn: 'ubuntu-latest', + }, + createNewVersion: { + steps: mocks.CREATE_NEW_VERSION_JOB_MOCK_STEPS, + outputs: { + // eslint-disable-next-line no-template-curly-in-string + NEW_VERSION: '${{ steps.createNewVersion.outputs.NEW_VERSION }}', + }, + runsOn: 'ubuntu-latest', + }, + e2ePerformanceTests: { + steps: mocks.PREDEPLOY__E2EPERFORMANCETESTS__MOCK_STEPS, + runsOn: 'ubuntu-latest', + }, + }; + const result = await act.runEvent('push', { + workflowFile: path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'), + mockSteps: testMockSteps, + actor: 'Dummy Tester', + logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), + mockJobs: testMockJobs, + }); + expect(result).toEqual(expect.arrayContaining([utils.createStepAssertion('Run typecheck workflow', false, null, 'TYPECHECK', 'Running typecheck workflow - Typecheck workflow failed')])); + assertions.assertLintJobExecuted(result); + assertions.assertTestJobExecuted(result); + assertions.assertIsExpensifyEmployeeJobExecuted(result); + expect(result).toEqual( + expect.arrayContaining([ + utils.createStepAssertion('Announce failed workflow in Slack', true, null, 'CONFIRM_PASSING_BUILD', 'Announcing failed workflow in slack', [ + {key: 'SLACK_WEBHOOK', value: '***'}, + ]), + utils.createStepAssertion('Exit failed workflow', false, ''), + ]), + ); + assertions.assertChooseDeployActionsJobExecuted(result, false); + assertions.assertSkipDeployJobExecuted(result, false); + assertions.assertCreateNewVersionJobExecuted(result, false); + assertions.assertUpdateStagingJobExecuted(result, false); + }); + it('lint job failed - workflow exits', async () => { const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); @@ -229,6 +314,10 @@ describe('test workflow preDeploy', () => { newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, }; const testMockJobs = { + typecheck: { + steps: mocks.TYPECHECK_JOB_MOCK_STEPS, + runsOn: 'ubuntu-latest', + }, lint: { steps: [utils.createMockStep('Run lint workflow', 'Running lint workflow - Lint workflow failed', 'LINT', null, null, null, null, false)], runsOn: 'ubuntu-latest', @@ -257,6 +346,7 @@ describe('test workflow preDeploy', () => { logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), mockJobs: testMockJobs, }); + assertions.assertTypecheckJobExecuted(result); expect(result).toEqual(expect.arrayContaining([utils.createStepAssertion('Run lint workflow', false, null, 'LINT', 'Running lint workflow - Lint workflow failed')])); assertions.assertTestJobExecuted(result); assertions.assertIsExpensifyEmployeeJobExecuted(result); @@ -298,6 +388,10 @@ describe('test workflow preDeploy', () => { newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, }; const testMockJobs = { + typecheck: { + steps: mocks.TYPECHECK_JOB_MOCK_STEPS, + runsOn: 'ubuntu-latest', + }, lint: { steps: mocks.LINT_JOB_MOCK_STEPS, runsOn: 'ubuntu-latest', @@ -326,6 +420,7 @@ describe('test workflow preDeploy', () => { logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), mockJobs: testMockJobs, }); + assertions.assertTypecheckJobExecuted(result); assertions.assertLintJobExecuted(result); expect(result).toEqual(expect.arrayContaining([utils.createStepAssertion('Run test workflow', false, null, 'TEST', 'Running test workflow - Test workflow failed')])); assertions.assertIsExpensifyEmployeeJobExecuted(result); @@ -367,6 +462,10 @@ describe('test workflow preDeploy', () => { newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, }; const testMockJobs = { + typecheck: { + steps: mocks.TYPECHECK_JOB_MOCK_STEPS, + runsOn: 'ubuntu-latest', + }, lint: { steps: mocks.LINT_JOB_MOCK_STEPS, runsOn: 'ubuntu-latest', @@ -395,6 +494,7 @@ describe('test workflow preDeploy', () => { logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), mockJobs: testMockJobs, }); + assertions.assertTypecheckJobExecuted(result); assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); assertions.assertIsExpensifyEmployeeJobExecuted(result); @@ -430,6 +530,10 @@ describe('test workflow preDeploy', () => { newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__OSBOTIFY, }; const testMockJobs = { + typecheck: { + steps: mocks.TYPECHECK_JOB_MOCK_STEPS, + runsOn: 'ubuntu-latest', + }, lint: { steps: mocks.LINT_JOB_MOCK_STEPS, runsOn: 'ubuntu-latest', @@ -458,6 +562,7 @@ describe('test workflow preDeploy', () => { logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), mockJobs: testMockJobs, }); + assertions.assertTypecheckJobExecuted(result); assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); assertions.assertIsExpensifyEmployeeJobExecuted(result); @@ -489,6 +594,10 @@ describe('test workflow preDeploy', () => { newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, }; const testMockJobs = { + typecheck: { + steps: mocks.TYPECHECK_JOB_MOCK_STEPS, + runsOn: 'ubuntu-latest', + }, lint: { steps: mocks.LINT_JOB_MOCK_STEPS, runsOn: 'ubuntu-latest', @@ -517,6 +626,7 @@ describe('test workflow preDeploy', () => { logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), mockJobs: testMockJobs, }); + assertions.assertTypecheckJobExecuted(result); assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); assertions.assertIsExpensifyEmployeeJobExecuted(result); @@ -548,6 +658,10 @@ describe('test workflow preDeploy', () => { newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, }; const testMockJobs = { + typecheck: { + steps: mocks.TYPECHECK_JOB_MOCK_STEPS, + runsOn: 'ubuntu-latest', + }, lint: { steps: mocks.LINT_JOB_MOCK_STEPS, runsOn: 'ubuntu-latest', @@ -576,6 +690,7 @@ describe('test workflow preDeploy', () => { logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), mockJobs: testMockJobs, }); + assertions.assertTypecheckJobExecuted(result); assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); assertions.assertIsExpensifyEmployeeJobExecuted(result); @@ -607,6 +722,10 @@ describe('test workflow preDeploy', () => { newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__ONE_PR, }; const testMockJobs = { + typecheck: { + steps: mocks.TYPECHECK_JOB_MOCK_STEPS, + runsOn: 'ubuntu-latest', + }, lint: { steps: mocks.LINT_JOB_MOCK_STEPS, runsOn: 'ubuntu-latest', @@ -635,6 +754,7 @@ describe('test workflow preDeploy', () => { logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), mockJobs: testMockJobs, }); + assertions.assertTypecheckJobExecuted(result); assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); assertions.assertIsExpensifyEmployeeJobExecuted(result); @@ -659,6 +779,10 @@ describe('test workflow preDeploy', () => { newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, }; const testMockJobs = { + typecheck: { + steps: mocks.TYPECHECK_JOB_MOCK_STEPS, + runsOn: 'ubuntu-latest', + }, lint: { steps: mocks.LINT_JOB_MOCK_STEPS, runsOn: 'ubuntu-latest', @@ -687,6 +811,7 @@ describe('test workflow preDeploy', () => { logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), mockJobs: testMockJobs, }); + assertions.assertTypecheckJobExecuted(result); assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); assertions.assertIsExpensifyEmployeeJobExecuted(result); @@ -711,6 +836,10 @@ describe('test workflow preDeploy', () => { newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__OSBOTIFY, }; const testMockJobs = { + typecheck: { + steps: mocks.TYPECHECK_JOB_MOCK_STEPS, + runsOn: 'ubuntu-latest', + }, lint: { steps: mocks.LINT_JOB_MOCK_STEPS, runsOn: 'ubuntu-latest', @@ -739,6 +868,7 @@ describe('test workflow preDeploy', () => { logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), mockJobs: testMockJobs, }); + assertions.assertTypecheckJobExecuted(result); assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); assertions.assertIsExpensifyEmployeeJobExecuted(result); @@ -775,6 +905,10 @@ describe('test workflow preDeploy', () => { newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__MANY_PRS, }; const testMockJobs = { + typecheck: { + steps: mocks.TYPECHECK_JOB_MOCK_STEPS, + runsOn: 'ubuntu-latest', + }, lint: { steps: mocks.LINT_JOB_MOCK_STEPS, runsOn: 'ubuntu-latest', @@ -803,6 +937,7 @@ describe('test workflow preDeploy', () => { logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), mockJobs: testMockJobs, }); + assertions.assertTypecheckJobExecuted(result); assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); assertions.assertIsExpensifyEmployeeJobExecuted(result); @@ -836,6 +971,10 @@ describe('test workflow preDeploy', () => { newContributorWelcomeMessage: mocks.NEW_CONTRIBUTOR_WELCOME_MESSAGE_JOB_MOCK_STEPS__OSBOTIFY, }; const testMockJobs = { + typecheck: { + steps: mocks.TYPECHECK_JOB_MOCK_STEPS, + runsOn: 'ubuntu-latest', + }, lint: { steps: mocks.LINT_JOB_MOCK_STEPS, runsOn: 'ubuntu-latest', @@ -864,6 +1003,7 @@ describe('test workflow preDeploy', () => { logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), mockJobs: testMockJobs, }); + assertions.assertTypecheckJobExecuted(result); assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); assertions.assertIsExpensifyEmployeeJobExecuted(result); @@ -900,6 +1040,10 @@ describe('test workflow preDeploy', () => { }; testMockSteps.updateStaging[3].mockWith = 'exit 1'; const testMockJobs = { + typecheck: { + steps: mocks.TYPECHECK_JOB_MOCK_STEPS, + runsOn: 'ubuntu-latest', + }, lint: { steps: mocks.LINT_JOB_MOCK_STEPS, runsOn: 'ubuntu-latest', @@ -928,6 +1072,7 @@ describe('test workflow preDeploy', () => { logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), mockJobs: testMockJobs, }); + assertions.assertTypecheckJobExecuted(result); assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); assertions.assertIsExpensifyEmployeeJobExecuted(result); From af8618cd8f5e2a6d488633efe544543691996969 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Fri, 4 Aug 2023 11:26:36 +0200 Subject: [PATCH 146/504] Run prettier Run prettier See: https://github.com/Expensify/App/issues/13604 --- workflow_tests/preDeploy.test.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/workflow_tests/preDeploy.test.js b/workflow_tests/preDeploy.test.js index 3c3b26c85a1c..4a4d9dcc82bb 100644 --- a/workflow_tests/preDeploy.test.js +++ b/workflow_tests/preDeploy.test.js @@ -272,7 +272,9 @@ describe('test workflow preDeploy', () => { logFile: utils.getLogFilePath('preDeploy', expect.getState().currentTestName), mockJobs: testMockJobs, }); - expect(result).toEqual(expect.arrayContaining([utils.createStepAssertion('Run typecheck workflow', false, null, 'TYPECHECK', 'Running typecheck workflow - Typecheck workflow failed')])); + expect(result).toEqual( + expect.arrayContaining([utils.createStepAssertion('Run typecheck workflow', false, null, 'TYPECHECK', 'Running typecheck workflow - Typecheck workflow failed')]), + ); assertions.assertLintJobExecuted(result); assertions.assertTestJobExecuted(result); assertions.assertIsExpensifyEmployeeJobExecuted(result); @@ -289,7 +291,7 @@ describe('test workflow preDeploy', () => { assertions.assertCreateNewVersionJobExecuted(result, false); assertions.assertUpdateStagingJobExecuted(result, false); }); - + it('lint job failed - workflow exits', async () => { const repoPath = mockGithub.repo.getPath('testPreDeployWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'preDeploy.yml'); From a3d8b76703aeae0156ac794f1eed1f6936af7cc6 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Fri, 4 Aug 2023 11:44:47 +0200 Subject: [PATCH 147/504] Pass args Pass call args to npm test call from runWorkflowTests script See: https://github.com/Expensify/App/issues/13604 --- workflow_tests/scripts/runWorkflowTests.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/workflow_tests/scripts/runWorkflowTests.sh b/workflow_tests/scripts/runWorkflowTests.sh index 4a29ad634206..50fbad140677 100755 --- a/workflow_tests/scripts/runWorkflowTests.sh +++ b/workflow_tests/scripts/runWorkflowTests.sh @@ -50,4 +50,4 @@ info 'ACT_BINARY environment variable set to an Act executable' success 'Environment setup properly - running tests' # Run tests -npm test -- --config=workflow_tests/jest.config.js --runInBand +npm test -- --config=workflow_tests/jest.config.js --runInBand "$@" From e7fc13f921a9241fefd47ab12657f28e48bd80b5 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Mon, 7 Aug 2023 10:32:12 +0200 Subject: [PATCH 148/504] Check `.env` file If `ACT_BINARY` is not set, the script will check if the `.env` file exists, and if it does will load the env vars from it and check again See: https://github.com/Expensify/App/issues/13604 --- workflow_tests/scripts/runWorkflowTests.sh | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/workflow_tests/scripts/runWorkflowTests.sh b/workflow_tests/scripts/runWorkflowTests.sh index 50fbad140677..71ddcdceffb5 100755 --- a/workflow_tests/scripts/runWorkflowTests.sh +++ b/workflow_tests/scripts/runWorkflowTests.sh @@ -34,9 +34,19 @@ info 'Act installed' # Check if ACT_BINARY is set if [[ -z ${ACT_BINARY} ]]; then - error 'ACT_BINARY variable not set' - info 'To make sure Act behaves in a predictable manner please set the ACT_BINARY environment variable to the path to your Act binary' - exit 1 + info 'ACT_BINARY not set, checking .env file' + if [ -f .env ]; then + set -a + source .env + set +a + else + info '.env file does not exist' + fi + if [[ -z ${ACT_BINARY} ]]; then + error 'ACT_BINARY variable not set' + info 'To make sure Act behaves in a predictable manner please set the ACT_BINARY environment variable to the path to your Act binary' + exit 1 + fi fi info 'ACT_BINARY environment variable set' From 4b47c2456686936ab9cb14ee6f81c5560b652816 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Fija=C5=82kiewicz?= Date: Mon, 7 Aug 2023 13:40:20 +0200 Subject: [PATCH 149/504] fix lint issues --- src/pages/SearchPage.js | 66 +++++++++++++++++++++++++---------------- 1 file changed, 41 insertions(+), 25 deletions(-) diff --git a/src/pages/SearchPage.js b/src/pages/SearchPage.js index 6cc5076bee97..9c7c9986d69a 100755 --- a/src/pages/SearchPage.js +++ b/src/pages/SearchPage.js @@ -14,7 +14,6 @@ import HeaderWithBackButton from '../components/HeaderWithBackButton'; import ScreenWrapper from '../components/ScreenWrapper'; import Timing from '../libs/actions/Timing'; import CONST from '../CONST'; -import compose from '../libs/compose'; import personalDetailsPropType from './personalDetailsPropType'; import reportPropTypes from './reportPropTypes'; import Performance from '../libs/Performance'; @@ -33,9 +32,19 @@ const propTypes = { reports: PropTypes.objectOf(reportPropTypes), }; -function SearchPage({betas = [], personalDetails = {}, reports = {}}) { +const defaultProps = { + betas: [], + personalDetails: {}, + reports: {}, +}; + +function SearchPage(props) { // Data for initialization (runs only on the first render) - const {recentReports: initialRecentReports, personalDetails: initialPersonalDetails, userToInvite: initialUserToInvite} = useMemo(() => OptionsListUtils.getSearchOptions(reports, personalDetails, '', betas), []); + const { + recentReports: initialRecentReports, + personalDetails: initialPersonalDetails, + userToInvite: initialUserToInvite + } = useMemo(() => OptionsListUtils.getSearchOptions(props.reports, props.personalDetails, '', props.betas), []); const [searchValue, setSearchValue] = useState('') const [searchOptions, setSearchOptions] = useState({ @@ -47,22 +56,30 @@ function SearchPage({betas = [], personalDetails = {}, reports = {}}) { const {translate} = useLocalize(); const updateOptions = useCallback(() => { - const {recentReports: localRecentReports, personalDetails: localPersonalDetails, userToInvite: localUserToInvite} = OptionsListUtils.getSearchOptions( - reports, - personalDetails, + const { + recentReports: localRecentReports, + personalDetails: localPersonalDetails, + userToInvite: localUserToInvite + } = OptionsListUtils.getSearchOptions( + props.reports, + props.personalDetails, searchValue.trim(), - betas, + props.betas, ); - setSearchOptions({recentReports: localRecentReports, personalDetails: localPersonalDetails, userToInvite: localUserToInvite}) - }, [reports, personalDetails, searchValue, betas]) + setSearchOptions({ + recentReports: localRecentReports, + personalDetails: localPersonalDetails, + userToInvite: localUserToInvite + }) + }, [props.reports, props.personalDetails, searchValue, props.betas]) const debouncedUpdateOptions = useCallback(_.debounce(updateOptions, 75), [updateOptions]); useEffect(() => { Timing.start(CONST.TIMING.SEARCH_RENDER); Performance.markStart(CONST.TIMING.SEARCH_RENDER); - },[]) + }, []) useEffect(() => { debouncedUpdateOptions() @@ -132,7 +149,7 @@ function SearchPage({betas = [], personalDetails = {}, reports = {}}) { } } - const isOptionsDataReady = ReportUtils.isReportDataReady() && OptionsListUtils.isPersonalDetailsReady(personalDetails); + const isOptionsDataReady = ReportUtils.isReportDataReady() && OptionsListUtils.isPersonalDetailsReady(props.personalDetails); const headerMessage = OptionsListUtils.getHeaderMessage( searchOptions.recentReports.length + searchOptions.personalDetails.length !== 0, Boolean(searchOptions.userToInvite), @@ -142,7 +159,7 @@ function SearchPage({betas = [], personalDetails = {}, reports = {}}) { {({didScreenTransitionEnd, safeAreaPaddingBottomStyle}) => ( <> - + Date: Tue, 8 Aug 2023 15:08:41 +0200 Subject: [PATCH 150/504] Fix typos Fixed several typos in test descriptions See: https://github.com/Expensify/App/issues/13604 --- workflow_tests/cherryPick.test.js | 6 +++--- workflow_tests/testBuild.test.js | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/workflow_tests/cherryPick.test.js b/workflow_tests/cherryPick.test.js index 081d2f58a310..592170a7c64e 100644 --- a/workflow_tests/cherryPick.test.js +++ b/workflow_tests/cherryPick.test.js @@ -190,7 +190,7 @@ describe('test workflow cherryPick', () => { assertions.assertCherryPickJobExecuted(result, actor, '1234', true); }); }); - describe('version do not match', () => { + describe('version does not match', () => { const versionsMatch = false; it('workflow executes, PR auto-assigned and commented, approved and merged automatically', async () => { const repoPath = mockGithub.repo.getPath('testCherryPickWorkflowRepo') || ''; @@ -289,7 +289,7 @@ describe('test workflow cherryPick', () => { assertions.assertCherryPickJobExecuted(result, actor, '1234', true, true); }); }); - describe('version do not match', () => { + describe('version does not match', () => { const versionsMatch = false; it('workflow executes, PR auto-assigned and commented, not merged automatically', async () => { const repoPath = mockGithub.repo.getPath('testCherryPickWorkflowRepo') || ''; @@ -340,7 +340,7 @@ describe('test workflow cherryPick', () => { }); }); }); - describe('autmatic trigger', () => { + describe('automatic trigger', () => { const event = 'pull_request'; it('workflow does not execute', async () => { const repoPath = mockGithub.repo.getPath('testCherryPickWorkflowRepo') || ''; diff --git a/workflow_tests/testBuild.test.js b/workflow_tests/testBuild.test.js index 59a718617a04..b3ba7f57702a 100644 --- a/workflow_tests/testBuild.test.js +++ b/workflow_tests/testBuild.test.js @@ -345,7 +345,7 @@ describe('test workflow testBuild', () => { }, }, }; - it('executes workflow, withuout getBranchRef', async () => { + it('executes workflow, without getBranchRef', async () => { const repoPath = mockGithub.repo.getPath('testTestBuildWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'testBuild.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); @@ -483,7 +483,7 @@ describe('test workflow testBuild', () => { }, }, }; - it('executes workflow, withuout getBranchRef', async () => { + it('executes workflow, without getBranchRef', async () => { const repoPath = mockGithub.repo.getPath('testTestBuildWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'testBuild.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); From 8bf77af8fc8a78f6b8303d54a9e25432ed375227 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Wed, 9 Aug 2023 11:09:07 +0200 Subject: [PATCH 151/504] Merge from upstream Synced with upstream and updated package-lock See: https://github.com/Expensify/App/issues/13604 --- package-lock.json | 412 ++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 364 insertions(+), 48 deletions(-) diff --git a/package-lock.json b/package-lock.json index e01e664333df..6f5ddbf3cc0f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,7 +17,9 @@ "@formatjs/intl-numberformat": "^8.5.0", "@formatjs/intl-pluralrules": "^5.2.2", "@gorhom/portal": "^1.0.14", - "@oguzhnatly/react-native-image-manipulator": "github:Expensify/react-native-image-manipulator#5cdae3d4455b03a04c57f50be3863e2fe6c92c52", + "@kie/act-js": "^2.0.1", + "@kie/mock-github": "^1.0.0", + "@oguzhnatly/react-native-image-manipulator": "github:Expensify/react-native-image-manipulator#c5f654fc9d0ad7cc5b89d50b34ecf8b0e3f4d050", "@onfido/react-native-sdk": "7.4.0", "@react-native-async-storage/async-storage": "^1.17.10", "@react-native-camera-roll/camera-roll": "5.4.0", @@ -33,6 +35,7 @@ "@react-navigation/native": "6.1.6", "@react-navigation/stack": "6.3.16", "@react-ng/bounds-observer": "^0.2.1", + "@types/node": "^18.14.0", "@ua/react-native-airship": "^15.2.6", "awesome-phonenumber": "^5.4.0", "babel-plugin-transform-remove-console": "^6.9.4", @@ -121,6 +124,8 @@ "@babel/runtime": "^7.20.0", "@electron/notarize": "^1.2.3", "@jest/globals": "^29.5.0", + "@kie/act-js": "^2.0.1", + "@kie/mock-github": "^1.0.0", "@octokit/core": "4.0.4", "@octokit/plugin-paginate-rest": "3.1.0", "@octokit/plugin-throttling": "4.1.0", @@ -215,7 +220,8 @@ "webpack-cli": "^4.10.0", "webpack-dev-server": "^4.9.3", "webpack-font-preload-plugin": "^1.5.0", - "webpack-merge": "^5.8.0" + "webpack-merge": "^5.8.0", + "yaml": "^2.2.1" }, "engines": { "node": "16.15.1", @@ -5378,6 +5384,65 @@ "integrity": "sha512-dfLbk+PwWvFzSxwk3n5ySL0hfBog779o8h68wK/7/APo/7cgyWp5jcXockbxdk5kFRkbeXWm4Fbi9FrdN381sA==", "dev": true }, + "node_modules/@kie/act-js": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/@kie/act-js/-/act-js-2.2.1.tgz", + "integrity": "sha512-YbID5l0ZVpxRgshi35ZYFbEYo/W6ISinxXh0LKJJkfW9jyv+ouF/11cxIAaPHbV64+HHiAKIosj9mw8TbJFDFA==", + "dev": true, + "hasInstallScript": true, + "dependencies": { + "@kie/mock-github": "^1.0.3", + "adm-zip": "^0.5.10", + "ajv": "^8.12.0", + "bin-links": "^4.0.1", + "express": "^4.18.1", + "follow-redirects": "^1.15.2", + "tar": "^6.1.13", + "yaml": "^2.1.3" + }, + "bin": { + "act-js": "bin/act" + } + }, + "node_modules/@kie/mock-github": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@kie/mock-github/-/mock-github-1.1.0.tgz", + "integrity": "sha512-fD+utlOiyZSOutOcXL0G9jfjbtvOO44PLUyTfgfkrm1+575R/dbvU6AcJfjc1DtHeRv7FC7f4ebyU+a1wgL6CA==", + "dev": true, + "dependencies": { + "@octokit/openapi-types-ghec": "^14.0.0", + "ajv": "^8.11.0", + "express": "^4.18.1", + "fast-glob": "^3.2.12", + "fs-extra": "^10.1.0", + "nock": "^13.2.7", + "simple-git": "^3.8.0", + "totalist": "^3.0.0" + } + }, + "node_modules/@kie/mock-github/node_modules/fs-extra": { + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz", + "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==", + "dev": true, + "dependencies": { + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^2.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/@kie/mock-github/node_modules/totalist": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/totalist/-/totalist-3.0.1.tgz", + "integrity": "sha512-sf4i37nQ2LBx4m3wB74y+ubopq6W/dIzXg0FDGjsYnZHVa1Da8FH853wlL2gtUhg+xJXjfk3kUZS3BRoQeoQBQ==", + "dev": true, + "engines": { + "node": ">=6" + } + }, "node_modules/@kwsites/file-exists": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/@kwsites/file-exists/-/file-exists-1.1.1.tgz", @@ -5818,6 +5883,12 @@ "dev": true, "license": "MIT" }, + "node_modules/@octokit/openapi-types-ghec": { + "version": "14.0.0", + "resolved": "https://registry.npmjs.org/@octokit/openapi-types-ghec/-/openapi-types-ghec-14.0.0.tgz", + "integrity": "sha512-xhd9oEvn2aroGn+sk09Ptx/76Y7aKU0EIgHukHPCU1+rGJreO36baEEk6k8ZPblieHNM39FcykJQmtDrETm0KA==", + "dev": true + }, "node_modules/@octokit/plugin-paginate-rest": { "version": "3.1.0", "dev": true, @@ -5924,8 +5995,8 @@ }, "node_modules/@oguzhnatly/react-native-image-manipulator": { "version": "1.0.5", - "resolved": "git+ssh://git@github.com/Expensify/react-native-image-manipulator.git#5cdae3d4455b03a04c57f50be3863e2fe6c92c52", - "integrity": "sha512-C9Br1BQqm6io6lvYHptlLcOHbzlaqxp9tS35P8Qj3pdiiYRTzU3KPvZ61rQ+ZnZ4FOQ6MwPsKsmB8+6WHkAY6Q==", + "resolved": "git+ssh://git@github.com/Expensify/react-native-image-manipulator.git#c5f654fc9d0ad7cc5b89d50b34ecf8b0e3f4d050", + "integrity": "sha512-PvrSoCq5PS1MA5ZWUpB0khfzH6sM8SI6YiVl4i2SItPr7IeRxiWfI4n45VhBCCElc1z5GhAwTZOBaIzXTX7/og==", "license": "MIT" }, "node_modules/@onfido/active-video-capture": { @@ -7042,14 +7113,6 @@ "node": ">=8" } }, - "node_modules/@react-native-community/cli-doctor/node_modules/yaml": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.3.1.tgz", - "integrity": "sha512-2eHWfjaoXgTBC2jNM1LRef62VQa0umtvRiDSk6HSzW7RvS5YtkabJrwYLLEKWBc8a5U2PTSCs+dJjUTJdlHsWQ==", - "engines": { - "node": ">= 14" - } - }, "node_modules/@react-native-community/cli-hermes": { "version": "11.3.3", "resolved": "https://registry.npmjs.org/@react-native-community/cli-hermes/-/cli-hermes-11.3.3.tgz", @@ -21448,6 +21511,15 @@ "node": ">= 10.0.0" } }, + "node_modules/adm-zip": { + "version": "0.5.10", + "resolved": "https://registry.npmjs.org/adm-zip/-/adm-zip-0.5.10.tgz", + "integrity": "sha512-x0HvcHqVJNTPk/Bw8JbLWlWoo6Wwnsug0fnYYro1HBrjxZ3G7/AZk7Ahv8JwDe1uIcz8eBqvu86FuF1POiG7vQ==", + "dev": true, + "engines": { + "node": ">=6.0" + } + }, "node_modules/agent-base": { "version": "6.0.2", "dev": true, @@ -21510,8 +21582,9 @@ } }, "node_modules/ajv": { - "version": "8.11.0", - "license": "MIT", + "version": "8.12.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.12.0.tgz", + "integrity": "sha512-sRu1kpcO9yLtYxBKvqfTeh9KzZEwO3STyX1HT+4CaDzC6HpTGYhIhPIzj9XuKU7KYDwnaeh5hcOwjy1QuJzBPA==", "dependencies": { "fast-deep-equal": "^3.1.1", "json-schema-traverse": "^1.0.0", @@ -23210,6 +23283,46 @@ "node": "*" } }, + "node_modules/bin-links": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/bin-links/-/bin-links-4.0.2.tgz", + "integrity": "sha512-jxJ0PbXR8eQyPlExCvCs3JFnikvs1Yp4gUJt6nmgathdOwvur+q22KWC3h20gvWl4T/14DXKj2IlkJwwZkZPOw==", + "dev": true, + "dependencies": { + "cmd-shim": "^6.0.0", + "npm-normalize-package-bin": "^3.0.0", + "read-cmd-shim": "^4.0.0", + "write-file-atomic": "^5.0.0" + }, + "engines": { + "node": "^14.17.0 || ^16.13.0 || >=18.0.0" + } + }, + "node_modules/bin-links/node_modules/signal-exit": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", + "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", + "dev": true, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/bin-links/node_modules/write-file-atomic": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-5.0.1.tgz", + "integrity": "sha512-+QU2zd6OTD8XWIJCbffaiQeH9U73qIqafo1x6V1snCWYGJf6cVE0cDR4D8xRzcEnfI21IFrUPzPGtcPf8AC+Rw==", + "dev": true, + "dependencies": { + "imurmurhash": "^0.1.4", + "signal-exit": "^4.0.1" + }, + "engines": { + "node": "^14.17.0 || ^16.13.0 || >=18.0.0" + } + }, "node_modules/binary-extensions": { "version": "2.2.0", "devOptional": true, @@ -24633,6 +24746,15 @@ "node": ">=6" } }, + "node_modules/cmd-shim": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/cmd-shim/-/cmd-shim-6.0.1.tgz", + "integrity": "sha512-S9iI9y0nKR4hwEQsVWpyxld/6kRfGepGfzff83FcaiEBpmvlbA2nnGe7Cylgrx2f/p1P5S5wpRm9oL8z1PbS3Q==", + "dev": true, + "engines": { + "node": "^14.17.0 || ^16.13.0 || >=18.0.0" + } + }, "node_modules/co": { "version": "4.6.0", "license": "MIT", @@ -25278,6 +25400,15 @@ "node": ">=10" } }, + "node_modules/cosmiconfig/node_modules/yaml": { + "version": "1.10.2", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-1.10.2.tgz", + "integrity": "sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==", + "dev": true, + "engines": { + "node": ">= 6" + } + }, "node_modules/cp-file": { "version": "7.0.0", "dev": true, @@ -29521,9 +29652,10 @@ "license": "MIT" }, "node_modules/fast-glob": { - "version": "3.2.11", + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.1.tgz", + "integrity": "sha512-kNFPyjhh5cKjrUltxs+wFx+ZkbRaxxmZ+X0ZU31SOsxCEtP9VPgtq2teZw1DebupL5GmDaNQ6yKMMVcM41iqDg==", "dev": true, - "license": "MIT", "dependencies": { "@nodelib/fs.stat": "^2.0.2", "@nodelib/fs.walk": "^1.2.3", @@ -29994,7 +30126,9 @@ } }, "node_modules/follow-redirects": { - "version": "1.15.1", + "version": "1.15.2", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.2.tgz", + "integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==", "dev": true, "funding": [ { @@ -30002,7 +30136,6 @@ "url": "https://github.com/sponsors/RubenVerborgh" } ], - "license": "MIT", "engines": { "node": ">=4.0" }, @@ -30201,6 +30334,15 @@ "node": ">=8" } }, + "node_modules/fork-ts-checker-webpack-plugin/node_modules/yaml": { + "version": "1.10.2", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-1.10.2.tgz", + "integrity": "sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==", + "dev": true, + "engines": { + "node": ">= 6" + } + }, "node_modules/form-data": { "version": "3.0.1", "dev": true, @@ -39858,6 +40000,21 @@ "node": ">=12.0.0" } }, + "node_modules/nock": { + "version": "13.3.2", + "resolved": "https://registry.npmjs.org/nock/-/nock-13.3.2.tgz", + "integrity": "sha512-CwbljitiWJhF1gL83NbanhoKs1l23TDlRioNraPTZrzZIEooPemrHRj5m0FZCPkB1ecdYCSWWGcHysJgX/ngnQ==", + "dev": true, + "dependencies": { + "debug": "^4.1.0", + "json-stringify-safe": "^5.0.1", + "lodash": "^4.17.21", + "propagate": "^2.0.0" + }, + "engines": { + "node": ">= 10.13" + } + }, "node_modules/node-abi": { "version": "3.45.0", "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.45.0.tgz", @@ -40162,6 +40319,15 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/npm-normalize-package-bin": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/npm-normalize-package-bin/-/npm-normalize-package-bin-3.0.1.tgz", + "integrity": "sha512-dMxCf+zZ+3zeQZXKxmyuCKlIDPGuv8EF940xbkC4kQVDTtqoh6rJFO+JTKSA6/Rwi0getWmtuy4Itup0AMcaDQ==", + "dev": true, + "engines": { + "node": "^14.17.0 || ^16.13.0 || >=18.0.0" + } + }, "node_modules/npm-run-path": { "version": "4.0.1", "license": "MIT", @@ -41121,14 +41287,6 @@ "node": ">=0.6.0" } }, - "node_modules/patch-package/node_modules/yaml": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.3.1.tgz", - "integrity": "sha512-2eHWfjaoXgTBC2jNM1LRef62VQa0umtvRiDSk6HSzW7RvS5YtkabJrwYLLEKWBc8a5U2PTSCs+dJjUTJdlHsWQ==", - "engines": { - "node": ">= 14" - } - }, "node_modules/path-browserify": { "version": "0.0.1", "license": "MIT" @@ -41810,6 +41968,15 @@ "react-is": "^16.13.1" } }, + "node_modules/propagate": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/propagate/-/propagate-2.0.1.tgz", + "integrity": "sha512-vGrhOavPSTz4QVNuBNdcNXePNdNMaO1xj9yBeH1ScQPjk/rhg9sSlCXPhMkFuaNNW/syTvYqsnbIJxMBfRbbag==", + "dev": true, + "engines": { + "node": ">= 8" + } + }, "node_modules/property-information": { "version": "5.6.0", "dev": true, @@ -43808,6 +43975,15 @@ "react-dom": "^15.0.0 || ^16.0.0 || ^17.0.0 || ^18.0.0" } }, + "node_modules/read-cmd-shim": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/read-cmd-shim/-/read-cmd-shim-4.0.0.tgz", + "integrity": "sha512-yILWifhaSEEytfXI76kB9xEEiG1AiozaCJZ83A87ytjRiN+jVibXjedjCRNjoZviinhG+4UkalO3mWTd8u5O0Q==", + "dev": true, + "engines": { + "node": "^14.17.0 || ^16.13.0 || >=18.0.0" + } + }, "node_modules/read-config-file": { "version": "6.3.2", "resolved": "https://registry.npmjs.org/read-config-file/-/read-config-file-6.3.2.tgz", @@ -49857,11 +50033,11 @@ "license": "ISC" }, "node_modules/yaml": { - "version": "1.10.2", - "dev": true, - "license": "ISC", + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.3.1.tgz", + "integrity": "sha512-2eHWfjaoXgTBC2jNM1LRef62VQa0umtvRiDSk6HSzW7RvS5YtkabJrwYLLEKWBc8a5U2PTSCs+dJjUTJdlHsWQ==", "engines": { - "node": ">= 6" + "node": ">= 14" } }, "node_modules/yargs": { @@ -53470,6 +53646,57 @@ "integrity": "sha512-dfLbk+PwWvFzSxwk3n5ySL0hfBog779o8h68wK/7/APo/7cgyWp5jcXockbxdk5kFRkbeXWm4Fbi9FrdN381sA==", "dev": true }, + "@kie/act-js": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/@kie/act-js/-/act-js-2.2.1.tgz", + "integrity": "sha512-YbID5l0ZVpxRgshi35ZYFbEYo/W6ISinxXh0LKJJkfW9jyv+ouF/11cxIAaPHbV64+HHiAKIosj9mw8TbJFDFA==", + "dev": true, + "requires": { + "@kie/mock-github": "^1.0.3", + "adm-zip": "^0.5.10", + "ajv": "^8.12.0", + "bin-links": "^4.0.1", + "express": "^4.18.1", + "follow-redirects": "^1.15.2", + "tar": "^6.1.13", + "yaml": "^2.1.3" + } + }, + "@kie/mock-github": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@kie/mock-github/-/mock-github-1.1.0.tgz", + "integrity": "sha512-fD+utlOiyZSOutOcXL0G9jfjbtvOO44PLUyTfgfkrm1+575R/dbvU6AcJfjc1DtHeRv7FC7f4ebyU+a1wgL6CA==", + "dev": true, + "requires": { + "@octokit/openapi-types-ghec": "^14.0.0", + "ajv": "^8.11.0", + "express": "^4.18.1", + "fast-glob": "^3.2.12", + "fs-extra": "^10.1.0", + "nock": "^13.2.7", + "simple-git": "^3.8.0", + "totalist": "^3.0.0" + }, + "dependencies": { + "fs-extra": { + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz", + "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==", + "dev": true, + "requires": { + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^2.0.0" + } + }, + "totalist": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/totalist/-/totalist-3.0.1.tgz", + "integrity": "sha512-sf4i37nQ2LBx4m3wB74y+ubopq6W/dIzXg0FDGjsYnZHVa1Da8FH853wlL2gtUhg+xJXjfk3kUZS3BRoQeoQBQ==", + "dev": true + } + } + }, "@kwsites/file-exists": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/@kwsites/file-exists/-/file-exists-1.1.1.tgz", @@ -53792,6 +54019,12 @@ "version": "12.11.0", "dev": true }, + "@octokit/openapi-types-ghec": { + "version": "14.0.0", + "resolved": "https://registry.npmjs.org/@octokit/openapi-types-ghec/-/openapi-types-ghec-14.0.0.tgz", + "integrity": "sha512-xhd9oEvn2aroGn+sk09Ptx/76Y7aKU0EIgHukHPCU1+rGJreO36baEEk6k8ZPblieHNM39FcykJQmtDrETm0KA==", + "dev": true + }, "@octokit/plugin-paginate-rest": { "version": "3.1.0", "dev": true, @@ -53870,9 +54103,9 @@ } }, "@oguzhnatly/react-native-image-manipulator": { - "version": "git+ssh://git@github.com/Expensify/react-native-image-manipulator.git#5cdae3d4455b03a04c57f50be3863e2fe6c92c52", - "integrity": "sha512-C9Br1BQqm6io6lvYHptlLcOHbzlaqxp9tS35P8Qj3pdiiYRTzU3KPvZ61rQ+ZnZ4FOQ6MwPsKsmB8+6WHkAY6Q==", - "from": "@oguzhnatly/react-native-image-manipulator@github:Expensify/react-native-image-manipulator#5cdae3d4455b03a04c57f50be3863e2fe6c92c52" + "version": "git+ssh://git@github.com/Expensify/react-native-image-manipulator.git#c5f654fc9d0ad7cc5b89d50b34ecf8b0e3f4d050", + "integrity": "sha512-PvrSoCq5PS1MA5ZWUpB0khfzH6sM8SI6YiVl4i2SItPr7IeRxiWfI4n45VhBCCElc1z5GhAwTZOBaIzXTX7/og==", + "from": "@oguzhnatly/react-native-image-manipulator@github:Expensify/react-native-image-manipulator#c5f654fc9d0ad7cc5b89d50b34ecf8b0e3f4d050" }, "@onfido/active-video-capture": { "version": "0.27.12", @@ -54693,11 +54926,6 @@ "requires": { "has-flag": "^4.0.0" } - }, - "yaml": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.3.1.tgz", - "integrity": "sha512-2eHWfjaoXgTBC2jNM1LRef62VQa0umtvRiDSk6HSzW7RvS5YtkabJrwYLLEKWBc8a5U2PTSCs+dJjUTJdlHsWQ==" } } }, @@ -64690,6 +64918,12 @@ "version": "1.2.1", "dev": true }, + "adm-zip": { + "version": "0.5.10", + "resolved": "https://registry.npmjs.org/adm-zip/-/adm-zip-0.5.10.tgz", + "integrity": "sha512-x0HvcHqVJNTPk/Bw8JbLWlWoo6Wwnsug0fnYYro1HBrjxZ3G7/AZk7Ahv8JwDe1uIcz8eBqvu86FuF1POiG7vQ==", + "dev": true + }, "agent-base": { "version": "6.0.2", "dev": true, @@ -64740,7 +64974,9 @@ } }, "ajv": { - "version": "8.11.0", + "version": "8.12.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.12.0.tgz", + "integrity": "sha512-sRu1kpcO9yLtYxBKvqfTeh9KzZEwO3STyX1HT+4CaDzC6HpTGYhIhPIzj9XuKU7KYDwnaeh5hcOwjy1QuJzBPA==", "requires": { "fast-deep-equal": "^3.1.1", "json-schema-traverse": "^1.0.0", @@ -65913,6 +66149,36 @@ "version": "5.2.2", "devOptional": true }, + "bin-links": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/bin-links/-/bin-links-4.0.2.tgz", + "integrity": "sha512-jxJ0PbXR8eQyPlExCvCs3JFnikvs1Yp4gUJt6nmgathdOwvur+q22KWC3h20gvWl4T/14DXKj2IlkJwwZkZPOw==", + "dev": true, + "requires": { + "cmd-shim": "^6.0.0", + "npm-normalize-package-bin": "^3.0.0", + "read-cmd-shim": "^4.0.0", + "write-file-atomic": "^5.0.0" + }, + "dependencies": { + "signal-exit": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", + "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", + "dev": true + }, + "write-file-atomic": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-5.0.1.tgz", + "integrity": "sha512-+QU2zd6OTD8XWIJCbffaiQeH9U73qIqafo1x6V1snCWYGJf6cVE0cDR4D8xRzcEnfI21IFrUPzPGtcPf8AC+Rw==", + "dev": true, + "requires": { + "imurmurhash": "^0.1.4", + "signal-exit": "^4.0.1" + } + } + } + }, "binary-extensions": { "version": "2.2.0", "devOptional": true @@ -66869,6 +67135,12 @@ "resolved": "https://registry.npmjs.org/clsx/-/clsx-1.2.1.tgz", "integrity": "sha512-EcR6r5a8bj6pu3ycsa/E/cKVGuTgZJZdsyUYHOksG/UHIiKfjxzRxYJpyVBwYaQeOvghal9fcc4PidlgzugAQg==" }, + "cmd-shim": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/cmd-shim/-/cmd-shim-6.0.1.tgz", + "integrity": "sha512-S9iI9y0nKR4hwEQsVWpyxld/6kRfGepGfzff83FcaiEBpmvlbA2nnGe7Cylgrx2f/p1P5S5wpRm9oL8z1PbS3Q==", + "dev": true + }, "co": { "version": "4.6.0" }, @@ -67294,6 +67566,14 @@ "parse-json": "^5.0.0", "path-type": "^4.0.0", "yaml": "^1.10.0" + }, + "dependencies": { + "yaml": { + "version": "1.10.2", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-1.10.2.tgz", + "integrity": "sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==", + "dev": true + } } }, "cp-file": { @@ -70207,7 +70487,9 @@ "version": "4.0.3" }, "fast-glob": { - "version": "3.2.11", + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.1.tgz", + "integrity": "sha512-kNFPyjhh5cKjrUltxs+wFx+ZkbRaxxmZ+X0ZU31SOsxCEtP9VPgtq2teZw1DebupL5GmDaNQ6yKMMVcM41iqDg==", "dev": true, "requires": { "@nodelib/fs.stat": "^2.0.2", @@ -70539,7 +70821,9 @@ } }, "follow-redirects": { - "version": "1.15.1", + "version": "1.15.2", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.2.tgz", + "integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==", "dev": true }, "for-each": { @@ -70654,6 +70938,12 @@ "requires": { "has-flag": "^4.0.0" } + }, + "yaml": { + "version": "1.10.2", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-1.10.2.tgz", + "integrity": "sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==", + "dev": true } } }, @@ -77151,6 +77441,18 @@ "resolved": "https://registry.npmjs.org/nocache/-/nocache-3.0.4.tgz", "integrity": "sha512-WDD0bdg9mbq6F4mRxEYcPWwfA1vxd0mrvKOyxI7Xj/atfRHVeutzuWByG//jfm4uPzp0y4Kj051EORCBSQMycw==" }, + "nock": { + "version": "13.3.2", + "resolved": "https://registry.npmjs.org/nock/-/nock-13.3.2.tgz", + "integrity": "sha512-CwbljitiWJhF1gL83NbanhoKs1l23TDlRioNraPTZrzZIEooPemrHRj5m0FZCPkB1ecdYCSWWGcHysJgX/ngnQ==", + "dev": true, + "requires": { + "debug": "^4.1.0", + "json-stringify-safe": "^5.0.1", + "lodash": "^4.17.21", + "propagate": "^2.0.0" + } + }, "node-abi": { "version": "3.45.0", "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.45.0.tgz", @@ -77379,6 +77681,12 @@ "version": "6.1.0", "dev": true }, + "npm-normalize-package-bin": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/npm-normalize-package-bin/-/npm-normalize-package-bin-3.0.1.tgz", + "integrity": "sha512-dMxCf+zZ+3zeQZXKxmyuCKlIDPGuv8EF940xbkC4kQVDTtqoh6rJFO+JTKSA6/Rwi0getWmtuy4Itup0AMcaDQ==", + "dev": true + }, "npm-run-path": { "version": "4.0.1", "requires": { @@ -77995,11 +78303,6 @@ "requires": { "os-tmpdir": "~1.0.2" } - }, - "yaml": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.3.1.tgz", - "integrity": "sha512-2eHWfjaoXgTBC2jNM1LRef62VQa0umtvRiDSk6HSzW7RvS5YtkabJrwYLLEKWBc8a5U2PTSCs+dJjUTJdlHsWQ==" } } }, @@ -78450,6 +78753,12 @@ "react-is": "^16.13.1" } }, + "propagate": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/propagate/-/propagate-2.0.1.tgz", + "integrity": "sha512-vGrhOavPSTz4QVNuBNdcNXePNdNMaO1xj9yBeH1ScQPjk/rhg9sSlCXPhMkFuaNNW/syTvYqsnbIJxMBfRbbag==", + "dev": true + }, "property-information": { "version": "5.6.0", "dev": true, @@ -79733,6 +80042,12 @@ "memoize-one": ">=3.1.1 <6" } }, + "read-cmd-shim": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/read-cmd-shim/-/read-cmd-shim-4.0.0.tgz", + "integrity": "sha512-yILWifhaSEEytfXI76kB9xEEiG1AiozaCJZ83A87ytjRiN+jVibXjedjCRNjoZviinhG+4UkalO3mWTd8u5O0Q==", + "dev": true + }, "read-config-file": { "version": "6.3.2", "resolved": "https://registry.npmjs.org/read-config-file/-/read-config-file-6.3.2.tgz", @@ -83831,8 +84146,9 @@ "version": "4.0.0" }, "yaml": { - "version": "1.10.2", - "dev": true + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.3.1.tgz", + "integrity": "sha512-2eHWfjaoXgTBC2jNM1LRef62VQa0umtvRiDSk6HSzW7RvS5YtkabJrwYLLEKWBc8a5U2PTSCs+dJjUTJdlHsWQ==" }, "yargs": { "version": "13.3.2", From 2a7eb7d80ac2148026f9a5da68aa291c01c4658a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hanno=20J=2E=20G=C3=B6decke?= Date: Thu, 10 Aug 2023 10:01:29 +0200 Subject: [PATCH 152/504] check canUseTouchScreen on each render --- src/components/Attachments/AttachmentCarousel/index.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/Attachments/AttachmentCarousel/index.js b/src/components/Attachments/AttachmentCarousel/index.js index 564e60b65dd1..400f426ee9bd 100644 --- a/src/components/Attachments/AttachmentCarousel/index.js +++ b/src/components/Attachments/AttachmentCarousel/index.js @@ -16,7 +16,6 @@ import compose from '../../../libs/compose'; import useCarouselArrows from './useCarouselArrows'; import useWindowDimensions from '../../../hooks/useWindowDimensions'; -const canUseTouchScreen = DeviceCapabilities.canUseTouchScreen(); const viewabilityConfig = { // To facilitate paging through the attachments, we want to consider an item "viewable" when it is // more than 95% visible. When that happens we update the page index in the state. @@ -27,6 +26,7 @@ function AttachmentCarousel({report, reportActions, source, onNavigate}) { const scrollRef = useRef(null); const {windowWidth, isSmallScreenWidth} = useWindowDimensions(); + const canUseTouchScreen = DeviceCapabilities.canUseTouchScreen(); const {attachments, initialPage, initialActiveSource, initialItem} = useMemo(() => extractAttachmentsFromReport(report, reportActions, source), [report, reportActions, source]); @@ -82,7 +82,7 @@ function AttachmentCarousel({report, reportActions, source, onNavigate}) { scrollRef.current.scrollToIndex({index: nextIndex, animated: canUseTouchScreen}); }, - [attachments, page], + [attachments, canUseTouchScreen, page], ); /** @@ -143,7 +143,7 @@ function AttachmentCarousel({report, reportActions, source, onNavigate}) { isUsedInCarousel /> ), - [activeSource, setShouldShowArrows, shouldShowArrows], + [activeSource, canUseTouchScreen, setShouldShowArrows, shouldShowArrows], ); return ( From b6689a9e3dd5821f7cfbfc48e4d0b7ef8485537b Mon Sep 17 00:00:00 2001 From: Sibtain Ali Date: Tue, 15 Aug 2023 20:51:33 +0500 Subject: [PATCH 153/504] feat: update electron builder to generate separate builds --- config/electronBuilder.config.js | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/config/electronBuilder.config.js b/config/electronBuilder.config.js index da87c93ee367..4423be7aefe9 100644 --- a/config/electronBuilder.config.js +++ b/config/electronBuilder.config.js @@ -21,6 +21,24 @@ const macIcon = { adhoc: './desktop/icon-adhoc.png', }; +const appIds = { + production: 'com.expensifyreactnative.chat', + staging: 'com.expensifyreactnative.staging.chat', + adhoc: 'com.expensifyreactnative.adhoc.chat', +}; + +const productNames = { + production: 'New Expensify', + staging: 'New Expensify Staging', + adhoc: 'New Expensify AdHoc', +}; + +const artifactNames = { + production: 'NewExpensify.dmg', + staging: 'NewExpensifyStaging.dmg', + adhoc: 'NewExpensifyAdHoc.dmg', +}; + const isCorrectElectronEnv = ['production', 'staging', 'adhoc'].includes(process.env.ELECTRON_ENV); if (!isCorrectElectronEnv) { @@ -32,8 +50,8 @@ if (!isCorrectElectronEnv) { * It can be used to create local builds of the same, by omitting the `--publish` flag */ module.exports = { - appId: 'com.expensifyreactnative.chat', - productName: 'New Expensify', + appId: appIds[process.env.ELECTRON_ENV], + productName: productNames[process.env.ELECTRON_ENV], extraMetadata: { version, }, @@ -46,8 +64,8 @@ module.exports = { type: 'distribution', }, dmg: { - title: 'New Expensify', - artifactName: 'NewExpensify.dmg', + title: productNames[process.env.ELECTRON_ENV], + artifactName: artifactNames[process.env.ELECTRON_ENV], internetEnabled: true, }, publish: [ @@ -65,7 +83,7 @@ module.exports = { output: 'desktop-build', }, protocols: { - name: 'New Expensify', + name: productNames[process.env.ELECTRON_ENV], schemes: ['new-expensify'], }, }; From 938695699fb201f3cd9547ccdfc2ee2bde51ba49 Mon Sep 17 00:00:00 2001 From: Sibtain Ali Date: Tue, 15 Aug 2023 21:58:02 +0500 Subject: [PATCH 154/504] fix: update name of staging artifact --- config/electronBuilder.config.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/config/electronBuilder.config.js b/config/electronBuilder.config.js index 4423be7aefe9..a5478dbd8f78 100644 --- a/config/electronBuilder.config.js +++ b/config/electronBuilder.config.js @@ -23,19 +23,19 @@ const macIcon = { const appIds = { production: 'com.expensifyreactnative.chat', - staging: 'com.expensifyreactnative.staging.chat', + staging: 'com.expensifyreactnative.dev.chat', adhoc: 'com.expensifyreactnative.adhoc.chat', }; const productNames = { production: 'New Expensify', - staging: 'New Expensify Staging', + staging: 'New Expensify Dev', adhoc: 'New Expensify AdHoc', }; const artifactNames = { production: 'NewExpensify.dmg', - staging: 'NewExpensifyStaging.dmg', + staging: 'NewExpensifyDev.dmg', adhoc: 'NewExpensifyAdHoc.dmg', }; From 83b995bb94b17db50757595c82dce76a23cb4aea Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Wed, 16 Aug 2023 11:27:06 +0200 Subject: [PATCH 155/504] Merge from upstream Synced with upstream and updated testBuild tests See: https://github.com/Expensify/App/issues/13604 --- .github/workflows/testBuild.yml | 3 +-- workflow_tests/assertions/testBuildAssertions.js | 1 + workflow_tests/mocks/testBuildMocks.js | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/testBuild.yml b/.github/workflows/testBuild.yml index 69899ca37259..0ff2bd287c44 100644 --- a/.github/workflows/testBuild.yml +++ b/.github/workflows/testBuild.yml @@ -145,10 +145,9 @@ jobs: - name: Setup Node uses: Expensify/App/.github/actions/composite/setupNode@main - - name: Setup Xcode + - name: Setup XCode run: sudo xcode-select -switch /Applications/Xcode_14.2.app - - uses: ruby/setup-ruby@eae47962baca661befdfd24e4d6c34ade04858f7 - name: Setup Ruby uses: ruby/setup-ruby@eae47962baca661befdfd24e4d6c34ade04858f7 with: diff --git a/workflow_tests/assertions/testBuildAssertions.js b/workflow_tests/assertions/testBuildAssertions.js index 44f7c2a17b20..c93783c39acb 100644 --- a/workflow_tests/assertions/testBuildAssertions.js +++ b/workflow_tests/assertions/testBuildAssertions.js @@ -137,6 +137,7 @@ const assertIOSJobExecuted = (workflowResult, ref = '', didExecute = true, fails utils.createStepAssertion('Checkout', true, null, 'IOS', 'Checkout', [{key: 'ref', value: ref}], []), utils.createStepAssertion('Create .env.adhoc file based on staging and add PULL_REQUEST_NUMBER env to it', true, null, 'IOS', 'Creating .env.adhoc file based on staging', [], []), utils.createStepAssertion('Setup Node', true, null, 'IOS', 'Setup Node', [], []), + utils.createStepAssertion('Setup XCode', true, null, 'IOS', 'Setup XCode', [], []), utils.createStepAssertion( 'Setup Ruby', true, diff --git a/workflow_tests/mocks/testBuildMocks.js b/workflow_tests/mocks/testBuildMocks.js index 8cbf038a21e4..93c55e89d25d 100644 --- a/workflow_tests/mocks/testBuildMocks.js +++ b/workflow_tests/mocks/testBuildMocks.js @@ -102,6 +102,7 @@ const TESTBUILD__IOS__CREATE_ENV_ADHOC__STEP_MOCK = utils.createMockStep( [], ); const TESTBUILD__IOS__SETUP_NODE__STEP_MOCK = utils.createMockStep('Setup Node', 'Setup Node', 'IOS', [], []); +const TESTBUILD__IOS__SETUP_XCODE__STEP_MOCK = utils.createMockStep('Setup XCode', 'Setup XCode', 'IOS', [], []); const TESTBUILD__IOS__SETUP_RUBY__STEP_MOCK = utils.createMockStep('Setup Ruby', 'Setup Ruby', 'IOS', ['ruby-version', 'bundler-cache'], []); const TESTBUILD__IOS__INSTALL_COCOAPODS__STEP_MOCK = utils.createMockStep('Install cocoapods', 'Install cocoapods', 'IOS', ['timeout_minutes', 'max_attempts', 'command'], []); const TESTBUILD__IOS__DECRYPT_PROFILE__STEP_MOCK = utils.createMockStep('Decrypt profile', 'Decrypt profile', 'IOS', [], ['LARGE_SECRET_PASSPHRASE']); @@ -119,6 +120,7 @@ const TESTBUILD__IOS__STEP_MOCKS = [ TESTBUILD__IOS__CHECKOUT__STEP_MOCK, TESTBUILD__IOS__CREATE_ENV_ADHOC__STEP_MOCK, TESTBUILD__IOS__SETUP_NODE__STEP_MOCK, + TESTBUILD__IOS__SETUP_XCODE__STEP_MOCK, TESTBUILD__IOS__SETUP_RUBY__STEP_MOCK, TESTBUILD__IOS__INSTALL_COCOAPODS__STEP_MOCK, TESTBUILD__IOS__DECRYPT_PROFILE__STEP_MOCK, From ad372bc3e885f98ffba2f63f00f34b03bee70ee6 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Wed, 16 Aug 2023 11:36:06 +0200 Subject: [PATCH 156/504] Merge from upstream Synced with upstream and updated testBuild tests See: https://github.com/Expensify/App/issues/13604 --- workflow_tests/testBuild.test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/workflow_tests/testBuild.test.js b/workflow_tests/testBuild.test.js index b3ba7f57702a..227f8b2b917b 100644 --- a/workflow_tests/testBuild.test.js +++ b/workflow_tests/testBuild.test.js @@ -232,7 +232,7 @@ describe('test workflow testBuild', () => { web: mocks.TESTBUILD__WEB__STEP_MOCKS, postGithubComment: mocks.TESTBUILD__POSTGITHUBCOMMENT__STEP_MOCKS, }; - testMockSteps.iOS[4] = utils.createMockStep('Install cocoapods', 'Install cocoapods', 'IOS', ['timeout_minutes', 'max_attempts', 'command'], [], {}, {}, false); + testMockSteps.iOS[5] = utils.createMockStep('Install cocoapods', 'Install cocoapods', 'IOS', ['timeout_minutes', 'max_attempts', 'command'], [], {}, {}, false); const result = await act.runEvent(event, { workflowFile: path.join(repoPath, '.github', 'workflows', 'testBuild.yml'), mockSteps: testMockSteps, @@ -243,7 +243,7 @@ describe('test workflow testBuild', () => { assertions.assertValidateActorJobExecuted(result, '1234'); assertions.assertGetBranchRefJobExecuted(result); assertions.assertAndroidJobExecuted(result, 'test-ref'); - assertions.assertIOSJobExecuted(result, 'test-ref', true, 4); + assertions.assertIOSJobExecuted(result, 'test-ref', true, 5); assertions.assertDesktopJobExecuted(result, 'test-ref'); assertions.assertWebJobExecuted(result, 'test-ref'); assertions.assertPostGithubCommentJobExecuted(result, 'test-ref', '1234', true, 'success', 'failure', 'success', 'success'); From 6f46693faa24358ad5224d91f8af2ebf66b2396b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Fija=C5=82kiewicz?= Date: Wed, 16 Aug 2023 11:42:43 +0200 Subject: [PATCH 157/504] fix lint issues --- src/pages/SearchPage.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/pages/SearchPage.js b/src/pages/SearchPage.js index 9c7c9986d69a..ac4326651d0a 100755 --- a/src/pages/SearchPage.js +++ b/src/pages/SearchPage.js @@ -44,6 +44,8 @@ function SearchPage(props) { recentReports: initialRecentReports, personalDetails: initialPersonalDetails, userToInvite: initialUserToInvite + // Ignoring the rule because in this case we need the data only initially + // eslint-disable-next-line react-hooks/exhaustive-deps } = useMemo(() => OptionsListUtils.getSearchOptions(props.reports, props.personalDetails, '', props.betas), []); const [searchValue, setSearchValue] = useState('') @@ -74,7 +76,7 @@ function SearchPage(props) { }) }, [props.reports, props.personalDetails, searchValue, props.betas]) - const debouncedUpdateOptions = useCallback(_.debounce(updateOptions, 75), [updateOptions]); + const debouncedUpdateOptions = useMemo(() => _.debounce(updateOptions, 75), [updateOptions]); useEffect(() => { Timing.start(CONST.TIMING.SEARCH_RENDER); From d1391af1f305ec0f4961b37fc65c0f4c7fb99f90 Mon Sep 17 00:00:00 2001 From: Ana Margarida Silva Date: Thu, 17 Aug 2023 14:00:56 +0100 Subject: [PATCH 158/504] feat: migrate PressableWithSecondaryInteraction to function component --- .../index.js | 162 ++++++++++-------- 1 file changed, 92 insertions(+), 70 deletions(-) diff --git a/src/components/PressableWithSecondaryInteraction/index.js b/src/components/PressableWithSecondaryInteraction/index.js index 2771db6206ae..fd50c6ff0994 100644 --- a/src/components/PressableWithSecondaryInteraction/index.js +++ b/src/components/PressableWithSecondaryInteraction/index.js @@ -1,106 +1,128 @@ import _ from 'underscore'; -import React, {Component} from 'react'; -import * as pressableWithSecondaryInteractionPropTypes from './pressableWithSecondaryInteractionPropTypes'; +import React, {forwardRef, useCallback, useEffect, useRef} from 'react'; import styles from '../../styles/styles'; import * as DeviceCapabilities from '../../libs/DeviceCapabilities'; import * as StyleUtils from '../../styles/StyleUtils'; import PressableWithFeedback from '../Pressable/PressableWithFeedback'; +import * as pressableWithSecondaryInteractionPropTypes from './pressableWithSecondaryInteractionPropTypes'; /** * This is a special Pressable that calls onSecondaryInteraction when LongPressed, or right-clicked. */ -class PressableWithSecondaryInteraction extends Component { - constructor(props) { - super(props); - this.executeSecondaryInteraction = this.executeSecondaryInteraction.bind(this); - this.executeSecondaryInteractionOnContextMenu = this.executeSecondaryInteractionOnContextMenu.bind(this); - } - - componentDidMount() { - if (this.props.forwardedRef) { - if (_.isFunction(this.props.forwardedRef)) { - this.props.forwardedRef(this.pressableRef); - } else if (_.isObject(this.props.forwardedRef)) { - this.props.forwardedRef.current = this.pressableRef; - } - } - this.pressableRef.addEventListener('contextmenu', this.executeSecondaryInteractionOnContextMenu); - } - componentWillUnmount() { - this.pressableRef.removeEventListener('contextmenu', this.executeSecondaryInteractionOnContextMenu); - } +function PressableWithSecondaryInteraction(props) { + const { + children, + inline, + style, + enableLongPressWithHover, + withoutFocusOnSecondaryInteraction, + preventDefaultContextMenu, + onSecondaryInteraction, + onPressIn, + onPress, + onPressOut, + activeOpacity, + innerRef, + ...rest + } = props; + + const pressableRef = useRef(null); /** * @param {Event} e - the secondary interaction event */ - executeSecondaryInteraction(e) { - if (DeviceCapabilities.hasHoverSupport() && !this.props.enableLongPressWithHover) { + const executeSecondaryInteraction = (e) => { + if (DeviceCapabilities.hasHoverSupport() && !enableLongPressWithHover) { return; } - if (this.props.withoutFocusOnSecondaryInteraction && this.pressableRef) { - this.pressableRef.blur(); + if (withoutFocusOnSecondaryInteraction && pressableRef && pressableRef.current) { + pressableRef.current.blur(); } - this.props.onSecondaryInteraction(e); - } + onSecondaryInteraction(e); + }; /** * @param {contextmenu} e - A right-click MouseEvent. * https://developer.mozilla.org/en-US/docs/Web/API/Element/contextmenu_event */ - executeSecondaryInteractionOnContextMenu(e) { - if (!this.props.onSecondaryInteraction) { + const executeSecondaryInteractionOnContextMenu = useCallback( + (e) => { + if (!onSecondaryInteraction) { + return; + } + + e.stopPropagation(); + if (preventDefaultContextMenu) { + e.preventDefault(); + } + + onSecondaryInteraction(e); + + /** + * This component prevents the tapped element from capturing focus. + * We need to blur this element when clicked as it opens modal that implements focus-trapping. + * When the modal is closed it focuses back to the last active element. + * Therefore it shifts the element to bring it back to focus. + * https://github.com/Expensify/App/issues/14148 + */ + if (withoutFocusOnSecondaryInteraction && pressableRef && pressableRef.current) { + pressableRef.current.blur(); + } + }, + [onSecondaryInteraction, preventDefaultContextMenu, pressableRef, withoutFocusOnSecondaryInteraction], + ); + + useEffect(() => { + if (!pressableRef || !pressableRef.current) { return; } - e.stopPropagation(); - if (this.props.preventDefaultContextMenu) { - e.preventDefault(); + if (innerRef) { + if (_.isFunction(innerRef)) { + innerRef(pressableRef); + } else if (_.isObject(innerRef)) { + innerRef.current = pressableRef.current; + } } - this.props.onSecondaryInteraction(e); - /** - * This component prevents the tapped element from capturing focus. - * We need to blur this element when clicked as it opens modal that implements focus-trapping. - * When the modal is closed it focuses back to the last active element. - * Therefore it shifts the element to bring it back to focus. - * https://github.com/Expensify/App/issues/14148 - */ - if (this.props.withoutFocusOnSecondaryInteraction && this.pressableRef) { - this.pressableRef.blur(); - } - } - - render() { - const defaultPressableProps = _.omit(this.props, ['onSecondaryInteraction', 'children', 'onLongPress']); - const inlineStyle = this.props.inline ? styles.dInline : {}; - - // On Web, Text does not support LongPress events thus manage inline mode with styling instead of using Text. - return ( - (this.pressableRef = el)} - // eslint-disable-next-line react/jsx-props-no-spreading - {...defaultPressableProps} - style={(state) => [StyleUtils.parseStyleFromFunction(this.props.style, state), inlineStyle]} - > - {this.props.children} - - ); - } + const element = pressableRef.current; + element.addEventListener('contextmenu', executeSecondaryInteractionOnContextMenu); + + return () => { + element.removeEventListener('contextmenu', executeSecondaryInteractionOnContextMenu); + }; + }, [executeSecondaryInteractionOnContextMenu, innerRef, pressableRef]); + + const defaultPressableProps = _.omit(rest, ['onLongPress']); + const inlineStyle = inline ? styles.dInline : {}; + + return ( + [StyleUtils.parseStyleFromFunction(style, state), inlineStyle]} + > + {children} + + ); } PressableWithSecondaryInteraction.propTypes = pressableWithSecondaryInteractionPropTypes.propTypes; PressableWithSecondaryInteraction.defaultProps = pressableWithSecondaryInteractionPropTypes.defaultProps; -export default React.forwardRef((props, ref) => ( +PressableWithSecondaryInteraction.displayName = 'PressableWithSecondaryInteraction'; + +export default forwardRef((props, ref) => ( )); From aa4e245d6deee5c0ad2af2af21f2d51ef46b0617 Mon Sep 17 00:00:00 2001 From: Ana Margarida Silva Date: Thu, 17 Aug 2023 15:14:48 +0100 Subject: [PATCH 159/504] refactor: code improvements --- .../index.js | 81 +++++++++---------- 1 file changed, 39 insertions(+), 42 deletions(-) diff --git a/src/components/PressableWithSecondaryInteraction/index.js b/src/components/PressableWithSecondaryInteraction/index.js index fd50c6ff0994..ce1204967a8b 100644 --- a/src/components/PressableWithSecondaryInteraction/index.js +++ b/src/components/PressableWithSecondaryInteraction/index.js @@ -1,5 +1,5 @@ import _ from 'underscore'; -import React, {forwardRef, useCallback, useEffect, useRef} from 'react'; +import React, {forwardRef, useEffect, useRef} from 'react'; import styles from '../../styles/styles'; import * as DeviceCapabilities from '../../libs/DeviceCapabilities'; import * as StyleUtils from '../../styles/StyleUtils'; @@ -10,23 +10,21 @@ import * as pressableWithSecondaryInteractionPropTypes from './pressableWithSeco * This is a special Pressable that calls onSecondaryInteraction when LongPressed, or right-clicked. */ -function PressableWithSecondaryInteraction(props) { - const { - children, - inline, - style, - enableLongPressWithHover, - withoutFocusOnSecondaryInteraction, - preventDefaultContextMenu, - onSecondaryInteraction, - onPressIn, - onPress, - onPressOut, - activeOpacity, - innerRef, - ...rest - } = props; - +function PressableWithSecondaryInteraction({ + children, + inline, + style, + enableLongPressWithHover, + withoutFocusOnSecondaryInteraction, + preventDefaultContextMenu, + onSecondaryInteraction, + onPressIn, + onPress, + onPressOut, + activeOpacity, + forwardedRef, + ...rest +}) { const pressableRef = useRef(null); /** @@ -42,12 +40,25 @@ function PressableWithSecondaryInteraction(props) { onSecondaryInteraction(e); }; - /** - * @param {contextmenu} e - A right-click MouseEvent. - * https://developer.mozilla.org/en-US/docs/Web/API/Element/contextmenu_event - */ - const executeSecondaryInteractionOnContextMenu = useCallback( - (e) => { + useEffect(() => { + if (!pressableRef || !pressableRef.current) { + return; + } + + if (forwardedRef) { + if (_.isFunction(forwardedRef)) { + forwardedRef(pressableRef); + } else if (_.isObject(forwardedRef)) { + // eslint-disable-next-line no-param-reassign + forwardedRef.current = pressableRef.current; + } + } + + /** + * @param {contextmenu} e - A right-click MouseEvent. + * https://developer.mozilla.org/en-US/docs/Web/API/Element/contextmenu_event + */ + const executeSecondaryInteractionOnContextMenu = (e) => { if (!onSecondaryInteraction) { return; } @@ -69,22 +80,7 @@ function PressableWithSecondaryInteraction(props) { if (withoutFocusOnSecondaryInteraction && pressableRef && pressableRef.current) { pressableRef.current.blur(); } - }, - [onSecondaryInteraction, preventDefaultContextMenu, pressableRef, withoutFocusOnSecondaryInteraction], - ); - - useEffect(() => { - if (!pressableRef || !pressableRef.current) { - return; - } - - if (innerRef) { - if (_.isFunction(innerRef)) { - innerRef(pressableRef); - } else if (_.isObject(innerRef)) { - innerRef.current = pressableRef.current; - } - } + }; const element = pressableRef.current; element.addEventListener('contextmenu', executeSecondaryInteractionOnContextMenu); @@ -92,7 +88,8 @@ function PressableWithSecondaryInteraction(props) { return () => { element.removeEventListener('contextmenu', executeSecondaryInteractionOnContextMenu); }; - }, [executeSecondaryInteractionOnContextMenu, innerRef, pressableRef]); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, []); const defaultPressableProps = _.omit(rest, ['onLongPress']); const inlineStyle = inline ? styles.dInline : {}; @@ -123,6 +120,6 @@ export default forwardRef((props, ref) => ( )); From dfd18964a115a0e7039e36dadcc13a8b1f8c866a Mon Sep 17 00:00:00 2001 From: Ana Margarida Silva Date: Thu, 17 Aug 2023 15:17:16 +0100 Subject: [PATCH 160/504] refactor: simplify --- src/components/PressableWithSecondaryInteraction/index.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/components/PressableWithSecondaryInteraction/index.js b/src/components/PressableWithSecondaryInteraction/index.js index ce1204967a8b..ec74de1837b2 100644 --- a/src/components/PressableWithSecondaryInteraction/index.js +++ b/src/components/PressableWithSecondaryInteraction/index.js @@ -54,6 +54,8 @@ function PressableWithSecondaryInteraction({ } } + const element = pressableRef.current; + /** * @param {contextmenu} e - A right-click MouseEvent. * https://developer.mozilla.org/en-US/docs/Web/API/Element/contextmenu_event @@ -77,12 +79,11 @@ function PressableWithSecondaryInteraction({ * Therefore it shifts the element to bring it back to focus. * https://github.com/Expensify/App/issues/14148 */ - if (withoutFocusOnSecondaryInteraction && pressableRef && pressableRef.current) { - pressableRef.current.blur(); + if (withoutFocusOnSecondaryInteraction) { + element.blur(); } }; - const element = pressableRef.current; element.addEventListener('contextmenu', executeSecondaryInteractionOnContextMenu); return () => { From 46d11cfea68cf4a609ab5748b5f052567294244a Mon Sep 17 00:00:00 2001 From: Ana Margarida Silva Date: Thu, 17 Aug 2023 15:18:45 +0100 Subject: [PATCH 161/504] fix: add missing comment --- src/components/PressableWithSecondaryInteraction/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/PressableWithSecondaryInteraction/index.js b/src/components/PressableWithSecondaryInteraction/index.js index ec74de1837b2..46de532156c9 100644 --- a/src/components/PressableWithSecondaryInteraction/index.js +++ b/src/components/PressableWithSecondaryInteraction/index.js @@ -89,6 +89,7 @@ function PressableWithSecondaryInteraction({ return () => { element.removeEventListener('contextmenu', executeSecondaryInteractionOnContextMenu); }; + // We only want this to run on mount // eslint-disable-next-line react-hooks/exhaustive-deps }, []); From c1dd8616fd6228b154a6d27c4c298b9c97c65273 Mon Sep 17 00:00:00 2001 From: Ana Margarida Silva Date: Thu, 17 Aug 2023 15:36:31 +0100 Subject: [PATCH 162/504] refactor: simplify --- src/components/PressableWithSecondaryInteraction/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/PressableWithSecondaryInteraction/index.js b/src/components/PressableWithSecondaryInteraction/index.js index 46de532156c9..2cd7004a68df 100644 --- a/src/components/PressableWithSecondaryInteraction/index.js +++ b/src/components/PressableWithSecondaryInteraction/index.js @@ -34,14 +34,14 @@ function PressableWithSecondaryInteraction({ if (DeviceCapabilities.hasHoverSupport() && !enableLongPressWithHover) { return; } - if (withoutFocusOnSecondaryInteraction && pressableRef && pressableRef.current) { + if (withoutFocusOnSecondaryInteraction && pressableRef.current) { pressableRef.current.blur(); } onSecondaryInteraction(e); }; useEffect(() => { - if (!pressableRef || !pressableRef.current) { + if (!pressableRef.current) { return; } From 56aff086e00fe074ab4308ebca9430d87d0c89e4 Mon Sep 17 00:00:00 2001 From: Ana Margarida Silva Date: Thu, 17 Aug 2023 15:48:33 +0100 Subject: [PATCH 163/504] revert: useEffect dependencies --- src/components/PressableWithSecondaryInteraction/index.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/components/PressableWithSecondaryInteraction/index.js b/src/components/PressableWithSecondaryInteraction/index.js index 2cd7004a68df..50fb48fc1525 100644 --- a/src/components/PressableWithSecondaryInteraction/index.js +++ b/src/components/PressableWithSecondaryInteraction/index.js @@ -89,9 +89,7 @@ function PressableWithSecondaryInteraction({ return () => { element.removeEventListener('contextmenu', executeSecondaryInteractionOnContextMenu); }; - // We only want this to run on mount - // eslint-disable-next-line react-hooks/exhaustive-deps - }, []); + }, [forwardedRef, onSecondaryInteraction, preventDefaultContextMenu, withoutFocusOnSecondaryInteraction]); const defaultPressableProps = _.omit(rest, ['onLongPress']); const inlineStyle = inline ? styles.dInline : {}; From 3a0f64767d6ca9ce916e9be4e558ce496e684590 Mon Sep 17 00:00:00 2001 From: Ana Margarida Silva Date: Thu, 17 Aug 2023 16:04:08 +0100 Subject: [PATCH 164/504] docs: add more info to onSecondaryInteraction doc --- .../pressableWithSecondaryInteractionPropTypes.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/components/PressableWithSecondaryInteraction/pressableWithSecondaryInteractionPropTypes.js b/src/components/PressableWithSecondaryInteraction/pressableWithSecondaryInteractionPropTypes.js index de0adbe81297..f521a57957f3 100644 --- a/src/components/PressableWithSecondaryInteraction/pressableWithSecondaryInteractionPropTypes.js +++ b/src/components/PressableWithSecondaryInteraction/pressableWithSecondaryInteractionPropTypes.js @@ -12,7 +12,12 @@ const propTypes = { /** The function that should be called when this pressable is pressedOut */ onPressOut: PropTypes.func, - /** The function that should be called when this pressable is LongPressed or right-clicked. */ + /** + * The function that should be called when this pressable is LongPressed or right-clicked. + * + * This function should be stable, preferably wrapped in a `useCallback` so that it does not + * cause several re-renders. + */ onSecondaryInteraction: PropTypes.func, /** The children which should be contained in this wrapper component. */ From 6024bce5af71fab0fc3483f8a7dca0a12c11c49f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Fija=C5=82kiewicz?= Date: Fri, 18 Aug 2023 11:20:00 +0200 Subject: [PATCH 165/504] fix prettier --- src/pages/SearchPage.js | 45 ++++++++++++++++++----------------------- 1 file changed, 20 insertions(+), 25 deletions(-) diff --git a/src/pages/SearchPage.js b/src/pages/SearchPage.js index ac4326651d0a..bbd9364d6821 100755 --- a/src/pages/SearchPage.js +++ b/src/pages/SearchPage.js @@ -43,16 +43,16 @@ function SearchPage(props) { const { recentReports: initialRecentReports, personalDetails: initialPersonalDetails, - userToInvite: initialUserToInvite + userToInvite: initialUserToInvite, // Ignoring the rule because in this case we need the data only initially // eslint-disable-next-line react-hooks/exhaustive-deps } = useMemo(() => OptionsListUtils.getSearchOptions(props.reports, props.personalDetails, '', props.betas), []); - const [searchValue, setSearchValue] = useState('') + const [searchValue, setSearchValue] = useState(''); const [searchOptions, setSearchOptions] = useState({ recentReports: initialRecentReports, personalDetails: initialPersonalDetails, - userToInvite: initialUserToInvite + userToInvite: initialUserToInvite, }); const {translate} = useLocalize(); @@ -61,31 +61,26 @@ function SearchPage(props) { const { recentReports: localRecentReports, personalDetails: localPersonalDetails, - userToInvite: localUserToInvite - } = OptionsListUtils.getSearchOptions( - props.reports, - props.personalDetails, - searchValue.trim(), - props.betas, - ); + userToInvite: localUserToInvite, + } = OptionsListUtils.getSearchOptions(props.reports, props.personalDetails, searchValue.trim(), props.betas); setSearchOptions({ recentReports: localRecentReports, personalDetails: localPersonalDetails, - userToInvite: localUserToInvite - }) - }, [props.reports, props.personalDetails, searchValue, props.betas]) + userToInvite: localUserToInvite, + }); + }, [props.reports, props.personalDetails, searchValue, props.betas]); const debouncedUpdateOptions = useMemo(() => _.debounce(updateOptions, 75), [updateOptions]); useEffect(() => { Timing.start(CONST.TIMING.SEARCH_RENDER); Performance.markStart(CONST.TIMING.SEARCH_RENDER); - }, []) + }, []); useEffect(() => { - debouncedUpdateOptions() - }, [searchValue, debouncedUpdateOptions]) + debouncedUpdateOptions(); + }, [searchValue, debouncedUpdateOptions]); /** * Returns the sections needed for the OptionsSelector @@ -123,16 +118,16 @@ function SearchPage(props) { } return sections; - } + }; const searchRendered = () => { Timing.end(CONST.TIMING.SEARCH_RENDER); Performance.markEnd(CONST.TIMING.SEARCH_RENDER); - } + }; const onChangeText = (value = '') => { - setSearchValue(value) - } + setSearchValue(value); + }; /** * Reset the search value and redirect to the selected report @@ -144,12 +139,12 @@ function SearchPage(props) { return; } if (option.reportID) { - setSearchValue('') + setSearchValue(''); Navigation.dismissModal(option.reportID); } else { Report.navigateToAndOpenReport([option.login]); } - } + }; const isOptionsDataReady = ReportUtils.isReportDataReady() && OptionsListUtils.isPersonalDetailsReady(props.personalDetails); const headerMessage = OptionsListUtils.getHeaderMessage( @@ -161,7 +156,7 @@ function SearchPage(props) { {({didScreenTransitionEnd, safeAreaPaddingBottomStyle}) => ( <> - + )} - ) + ); } SearchPage.propTypes = propTypes; -SearchPage.defaultProps = defaultProps +SearchPage.defaultProps = defaultProps; SearchPage.displayName = 'SearchPage'; export default withOnyx({ reports: { From f0ff0a7921308590d9f2e4e184c477e2568d126c Mon Sep 17 00:00:00 2001 From: Ana Margarida Silva Date: Fri, 18 Aug 2023 15:39:53 +0100 Subject: [PATCH 166/504] feat: update IOU report total in optimistic data on edit money request --- src/libs/actions/IOU.js | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/libs/actions/IOU.js b/src/libs/actions/IOU.js index 13a9af5b42f6..5c0430afc143 100644 --- a/src/libs/actions/IOU.js +++ b/src/libs/actions/IOU.js @@ -954,7 +954,15 @@ function editMoneyRequest(transactionID, transactionThreadReportID, transactionC // STEP 2: Build new modified expense report action. const updatedReportAction = ReportUtils.buildOptimisticModifiedExpenseReportAction(transactionThread, transaction, transactionChanges, isFromExpenseReport); const updatedTransaction = TransactionUtils.getUpdatedTransaction(transaction, transactionChanges, isFromExpenseReport); + // STEP 3: Compute the IOU total and update the report preview message so LHN amount owed is correct + // Should only update if the transaction matches the currency of the report, else we wait for the update + // from the server with the currency conversion + const updatedIouReport = {...iouReport}; + if (updatedTransaction.currency === iouReport.currency && updatedTransaction.modifiedAmount) { + updatedIouReport.total = updatedIouReport.total - TransactionUtils.getAmount(transaction) + TransactionUtils.getAmount(updatedTransaction); + } + // STEP 4: Compose the optimistic data const optimisticData = [ { @@ -969,6 +977,11 @@ function editMoneyRequest(transactionID, transactionThreadReportID, transactionC key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`, value: updatedTransaction, }, + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.REPORT}${iouReport.reportID}`, + value: updatedIouReport, + }, ]; const successData = [ @@ -984,6 +997,11 @@ function editMoneyRequest(transactionID, transactionThreadReportID, transactionC key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`, value: {pendingAction: null}, }, + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.REPORT}${iouReport.reportID}`, + value: {pendingAction: null}, + }, ]; const failureData = [ @@ -1001,7 +1019,7 @@ function editMoneyRequest(transactionID, transactionThreadReportID, transactionC }, { onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.REPORT}${iouReport.report}`, + key: `${ONYXKEYS.COLLECTION.REPORT}${iouReport.reportID}`, value: iouReport, }, ]; From ed7d7ba65a5b3abde9e470ac27ca8a395a28fc82 Mon Sep 17 00:00:00 2001 From: Jakub Trzebiatowski Date: Mon, 21 Aug 2023 11:00:35 +0200 Subject: [PATCH 167/504] De-duplicate checking if a report action is an attachment --- src/libs/ReportUtils.js | 4 +++- src/libs/isReportActionAttachment.js | 14 ++++++++++++++ .../home/report/ContextMenu/ContextMenuActions.js | 14 ++++++-------- 3 files changed, 23 insertions(+), 9 deletions(-) create mode 100644 src/libs/isReportActionAttachment.js diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index 84c50fcb56f3..d64dfc0120bd 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -18,6 +18,7 @@ import Permissions from './Permissions'; import DateUtils from './DateUtils'; import linkingConfig from './Navigation/linkingConfig'; import isReportMessageAttachment from './isReportMessageAttachment'; +import isReportActionAttachment from './isReportActionAttachment'; import * as defaultWorkspaceAvatars from '../components/Icon/WorkspaceDefaultAvatars'; import * as CurrencyUtils from './CurrencyUtils'; import * as UserUtils from './UserUtils'; @@ -1415,7 +1416,7 @@ function getReportName(report, policy = undefined) { return getTransactionReportName(parentReportAction); } - const isAttachment = _.has(parentReportAction, 'isAttachment') ? parentReportAction.isAttachment : isReportMessageAttachment(_.last(lodashGet(parentReportAction, 'message', [{}]))); + const isAttachment = isReportActionAttachment(parentReportAction); const parentReportActionMessage = lodashGet(parentReportAction, ['message', 0, 'text'], '').replace(/(\r\n|\n|\r)/gm, ' '); if (isAttachment && parentReportActionMessage) { return `[${Localize.translateLocal('common.attachment')}]`; @@ -3163,6 +3164,7 @@ function getTaskAssigneeChatOnyxData(accountID, assigneeEmail, assigneeAccountID export { getReportParticipantsTitle, isReportMessageAttachment, + isReportActionAttachment, findLastAccessedReport, canEditReportAction, canFlagReportAction, diff --git a/src/libs/isReportActionAttachment.js b/src/libs/isReportActionAttachment.js new file mode 100644 index 000000000000..37504b782343 --- /dev/null +++ b/src/libs/isReportActionAttachment.js @@ -0,0 +1,14 @@ +import _ from 'underscore'; +import lodashGet from 'lodash/get'; +import isReportMessageAttachment from './isReportMessageAttachment'; + +/** + * Check whether a report action is an attachment. + * + * @param {Object} reportAction report action + * @returns {Boolean} + */ +export default function isReportActionAttachment(reportAction) { + const message = _.first(lodashGet(reportAction, 'message', [{}])); + return _.has(reportAction, 'isAttachment') ? reportAction.isAttachment : isReportMessageAttachment(message); +} diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.js b/src/pages/home/report/ContextMenu/ContextMenuActions.js index e66c61b1122f..4b6750bc94fa 100644 --- a/src/pages/home/report/ContextMenu/ContextMenuActions.js +++ b/src/pages/home/report/ContextMenu/ContextMenuActions.js @@ -94,9 +94,9 @@ export default [ successTextTranslateKey: 'common.download', successIcon: Expensicons.Download, shouldShow: (type, reportAction) => { - const message = _.last(lodashGet(reportAction, 'message', [{}])); - const isAttachment = _.has(reportAction, 'isAttachment') ? reportAction.isAttachment : ReportUtils.isReportMessageAttachment(message); - return isAttachment && message.html !== CONST.ATTACHMENT_UPLOADING_MESSAGE_HTML && reportAction.reportActionID && !ReportActionUtils.isMessageDeleted(reportAction); + const isAttachment = ReportUtils.isReportActionAttachment(reportAction); + const messageHtml = lodashGet(reportAction, ['message', 0, 'html']); + return isAttachment && messageHtml !== CONST.ATTACHMENT_UPLOADING_MESSAGE_HTML && reportAction.reportActionID && !ReportActionUtils.isMessageDeleted(reportAction); }, onPress: (closePopover, {reportAction}) => { const message = _.last(lodashGet(reportAction, 'message', [{}])); @@ -188,10 +188,9 @@ export default [ // the `text` and `icon` onPress: (closePopover, {reportAction, selection}) => { const isReportPreviewAction = ReportActionUtils.isReportPreviewAction(reportAction); - const message = _.last(lodashGet(reportAction, 'message', [{}])); - const messageHtml = lodashGet(message, 'html', ''); + const isAttachment = ReportUtils.isReportActionAttachment(reportAction); + const messageHtml = lodashGet(reportAction, ['message', 0, 'html'], ''); - const isAttachment = _.has(reportAction, 'isAttachment') ? reportAction.isAttachment : ReportUtils.isReportMessageAttachment(message); if (!isAttachment) { const content = selection || messageHtml; if (isReportPreviewAction) { @@ -224,8 +223,7 @@ export default [ successIcon: Expensicons.Checkmark, successTextTranslateKey: 'reportActionContextMenu.copied', shouldShow: (type, reportAction, isArchivedRoom, betas, menuTarget) => { - const message = _.last(lodashGet(reportAction, 'message', [{}])); - const isAttachment = _.has(reportAction, 'isAttachment') ? reportAction.isAttachment : ReportUtils.isReportMessageAttachment(message); + const isAttachment = ReportUtils.isReportActionAttachment(reportAction); // Only hide the copylink menu item when context menu is opened over img element. const isAttachmentTarget = lodashGet(menuTarget, 'tagName') === 'IMG' && isAttachment; From 4dd43c2d8f532dfd73a84a8268f72881fd80d079 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Mon, 21 Aug 2023 11:20:29 +0200 Subject: [PATCH 168/504] Merge from upstream Synced with upstream and updated package-lock See: https://github.com/Expensify/App/issues/13604 --- package-lock.json | 486 ++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 444 insertions(+), 42 deletions(-) diff --git a/package-lock.json b/package-lock.json index acfa4a420290..8021b4d91d2e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,6 +18,8 @@ "@formatjs/intl-pluralrules": "^5.2.2", "@gorhom/portal": "^1.0.14", "@invertase/react-native-apple-authentication": "^2.2.2", + "@kie/act-js": "^2.0.1", + "@kie/mock-github": "^1.0.0", "@oguzhnatly/react-native-image-manipulator": "github:Expensify/react-native-image-manipulator#5cdae3d4455b03a04c57f50be3863e2fe6c92c52", "@onfido/react-native-sdk": "7.4.0", "@react-native-async-storage/async-storage": "^1.17.10", @@ -36,6 +38,7 @@ "@react-navigation/stack": "6.3.16", "@react-ng/bounds-observer": "^0.2.1", "@rnmapbox/maps": "^10.0.11", + "@types/node": "^18.14.0", "@ua/react-native-airship": "^15.2.6", "awesome-phonenumber": "^5.4.0", "babel-plugin-transform-remove-console": "^6.9.4", @@ -130,6 +133,8 @@ "@babel/runtime": "^7.20.0", "@electron/notarize": "^1.2.3", "@jest/globals": "^29.5.0", + "@kie/act-js": "^2.0.1", + "@kie/mock-github": "^1.0.0", "@octokit/core": "4.0.4", "@octokit/plugin-paginate-rest": "3.1.0", "@octokit/plugin-throttling": "4.1.0", @@ -224,7 +229,8 @@ "webpack-cli": "^4.10.0", "webpack-dev-server": "^4.9.3", "webpack-font-preload-plugin": "^1.5.0", - "webpack-merge": "^5.8.0" + "webpack-merge": "^5.8.0", + "yaml": "^2.2.1" }, "engines": { "node": "16.15.1", @@ -5392,6 +5398,110 @@ "integrity": "sha512-dfLbk+PwWvFzSxwk3n5ySL0hfBog779o8h68wK/7/APo/7cgyWp5jcXockbxdk5kFRkbeXWm4Fbi9FrdN381sA==", "dev": true }, + "node_modules/@kie/act-js": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/@kie/act-js/-/act-js-2.3.0.tgz", + "integrity": "sha512-Q9k0b05uA46jXKWmVfoGDW+0xsCcE7QPiHi8IH7h41P36DujHKBj4k28RCeIEx3IwUCxYHKwubN8DH4Vzc9XcA==", + "dev": true, + "hasInstallScript": true, + "dependencies": { + "@kie/mock-github": "^2.0.0", + "adm-zip": "^0.5.10", + "ajv": "^8.12.0", + "bin-links": "^4.0.1", + "express": "^4.18.1", + "follow-redirects": "^1.15.2", + "tar": "^6.1.13", + "yaml": "^2.1.3" + }, + "bin": { + "act-js": "bin/act" + } + }, + "node_modules/@kie/act-js/node_modules/@kie/mock-github": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@kie/mock-github/-/mock-github-2.0.0.tgz", + "integrity": "sha512-od6UyICJYKMnz9HgEWCQAFT/JsCpKkLp+JQH8fV23tf+ZmmQI1dK3C20k6aO5uJhAHA0yOcFtbKFVF4+8i3DTg==", + "dev": true, + "dependencies": { + "@octokit/openapi-types-ghec": "^18.0.0", + "ajv": "^8.11.0", + "express": "^4.18.1", + "fast-glob": "^3.2.12", + "fs-extra": "^10.1.0", + "nock": "^13.2.7", + "simple-git": "^3.8.0", + "totalist": "^3.0.0" + } + }, + "node_modules/@kie/act-js/node_modules/@octokit/openapi-types-ghec": { + "version": "18.0.0", + "resolved": "https://registry.npmjs.org/@octokit/openapi-types-ghec/-/openapi-types-ghec-18.0.0.tgz", + "integrity": "sha512-xY5FTR/DW2gUJdC5GyzkqrfMHhr3u3hg+dUG6bA5FvuuODw6A7+0JTTSS1ndLQEKGmFxP7chf1BKkhvhnqxCew==", + "dev": true + }, + "node_modules/@kie/act-js/node_modules/fs-extra": { + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz", + "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==", + "dev": true, + "dependencies": { + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^2.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/@kie/act-js/node_modules/totalist": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/totalist/-/totalist-3.0.1.tgz", + "integrity": "sha512-sf4i37nQ2LBx4m3wB74y+ubopq6W/dIzXg0FDGjsYnZHVa1Da8FH853wlL2gtUhg+xJXjfk3kUZS3BRoQeoQBQ==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/@kie/mock-github": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@kie/mock-github/-/mock-github-1.1.0.tgz", + "integrity": "sha512-fD+utlOiyZSOutOcXL0G9jfjbtvOO44PLUyTfgfkrm1+575R/dbvU6AcJfjc1DtHeRv7FC7f4ebyU+a1wgL6CA==", + "dev": true, + "dependencies": { + "@octokit/openapi-types-ghec": "^14.0.0", + "ajv": "^8.11.0", + "express": "^4.18.1", + "fast-glob": "^3.2.12", + "fs-extra": "^10.1.0", + "nock": "^13.2.7", + "simple-git": "^3.8.0", + "totalist": "^3.0.0" + } + }, + "node_modules/@kie/mock-github/node_modules/fs-extra": { + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz", + "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==", + "dev": true, + "dependencies": { + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^2.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/@kie/mock-github/node_modules/totalist": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/totalist/-/totalist-3.0.1.tgz", + "integrity": "sha512-sf4i37nQ2LBx4m3wB74y+ubopq6W/dIzXg0FDGjsYnZHVa1Da8FH853wlL2gtUhg+xJXjfk3kUZS3BRoQeoQBQ==", + "dev": true, + "engines": { + "node": ">=6" + } + }, "node_modules/@kwsites/file-exists": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/@kwsites/file-exists/-/file-exists-1.1.1.tgz", @@ -5916,6 +6026,12 @@ "dev": true, "license": "MIT" }, + "node_modules/@octokit/openapi-types-ghec": { + "version": "14.0.0", + "resolved": "https://registry.npmjs.org/@octokit/openapi-types-ghec/-/openapi-types-ghec-14.0.0.tgz", + "integrity": "sha512-xhd9oEvn2aroGn+sk09Ptx/76Y7aKU0EIgHukHPCU1+rGJreO36baEEk6k8ZPblieHNM39FcykJQmtDrETm0KA==", + "dev": true + }, "node_modules/@octokit/plugin-paginate-rest": { "version": "3.1.0", "dev": true, @@ -7140,14 +7256,6 @@ "node": ">=8" } }, - "node_modules/@react-native-community/cli-doctor/node_modules/yaml": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.3.1.tgz", - "integrity": "sha512-2eHWfjaoXgTBC2jNM1LRef62VQa0umtvRiDSk6HSzW7RvS5YtkabJrwYLLEKWBc8a5U2PTSCs+dJjUTJdlHsWQ==", - "engines": { - "node": ">= 14" - } - }, "node_modules/@react-native-community/cli-hermes": { "version": "11.3.5", "resolved": "https://registry.npmjs.org/@react-native-community/cli-hermes/-/cli-hermes-11.3.5.tgz", @@ -21772,6 +21880,15 @@ "node": ">= 10.0.0" } }, + "node_modules/adm-zip": { + "version": "0.5.10", + "resolved": "https://registry.npmjs.org/adm-zip/-/adm-zip-0.5.10.tgz", + "integrity": "sha512-x0HvcHqVJNTPk/Bw8JbLWlWoo6Wwnsug0fnYYro1HBrjxZ3G7/AZk7Ahv8JwDe1uIcz8eBqvu86FuF1POiG7vQ==", + "dev": true, + "engines": { + "node": ">=6.0" + } + }, "node_modules/agent-base": { "version": "6.0.2", "dev": true, @@ -21834,8 +21951,9 @@ } }, "node_modules/ajv": { - "version": "8.11.0", - "license": "MIT", + "version": "8.12.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.12.0.tgz", + "integrity": "sha512-sRu1kpcO9yLtYxBKvqfTeh9KzZEwO3STyX1HT+4CaDzC6HpTGYhIhPIzj9XuKU7KYDwnaeh5hcOwjy1QuJzBPA==", "dependencies": { "fast-deep-equal": "^3.1.1", "json-schema-traverse": "^1.0.0", @@ -23532,6 +23650,46 @@ "node": "*" } }, + "node_modules/bin-links": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/bin-links/-/bin-links-4.0.2.tgz", + "integrity": "sha512-jxJ0PbXR8eQyPlExCvCs3JFnikvs1Yp4gUJt6nmgathdOwvur+q22KWC3h20gvWl4T/14DXKj2IlkJwwZkZPOw==", + "dev": true, + "dependencies": { + "cmd-shim": "^6.0.0", + "npm-normalize-package-bin": "^3.0.0", + "read-cmd-shim": "^4.0.0", + "write-file-atomic": "^5.0.0" + }, + "engines": { + "node": "^14.17.0 || ^16.13.0 || >=18.0.0" + } + }, + "node_modules/bin-links/node_modules/signal-exit": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", + "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", + "dev": true, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/bin-links/node_modules/write-file-atomic": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-5.0.1.tgz", + "integrity": "sha512-+QU2zd6OTD8XWIJCbffaiQeH9U73qIqafo1x6V1snCWYGJf6cVE0cDR4D8xRzcEnfI21IFrUPzPGtcPf8AC+Rw==", + "dev": true, + "dependencies": { + "imurmurhash": "^0.1.4", + "signal-exit": "^4.0.1" + }, + "engines": { + "node": "^14.17.0 || ^16.13.0 || >=18.0.0" + } + }, "node_modules/binary-extensions": { "version": "2.2.0", "devOptional": true, @@ -24972,6 +25130,15 @@ "node": ">=6" } }, + "node_modules/cmd-shim": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/cmd-shim/-/cmd-shim-6.0.1.tgz", + "integrity": "sha512-S9iI9y0nKR4hwEQsVWpyxld/6kRfGepGfzff83FcaiEBpmvlbA2nnGe7Cylgrx2f/p1P5S5wpRm9oL8z1PbS3Q==", + "dev": true, + "engines": { + "node": "^14.17.0 || ^16.13.0 || >=18.0.0" + } + }, "node_modules/co": { "version": "4.6.0", "license": "MIT", @@ -25617,6 +25784,15 @@ "node": ">=10" } }, + "node_modules/cosmiconfig/node_modules/yaml": { + "version": "1.10.2", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-1.10.2.tgz", + "integrity": "sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==", + "dev": true, + "engines": { + "node": ">= 6" + } + }, "node_modules/cp-file": { "version": "7.0.0", "dev": true, @@ -29874,9 +30050,10 @@ "license": "MIT" }, "node_modules/fast-glob": { - "version": "3.2.11", + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.1.tgz", + "integrity": "sha512-kNFPyjhh5cKjrUltxs+wFx+ZkbRaxxmZ+X0ZU31SOsxCEtP9VPgtq2teZw1DebupL5GmDaNQ6yKMMVcM41iqDg==", "dev": true, - "license": "MIT", "dependencies": { "@nodelib/fs.stat": "^2.0.2", "@nodelib/fs.walk": "^1.2.3", @@ -30347,7 +30524,9 @@ } }, "node_modules/follow-redirects": { - "version": "1.15.1", + "version": "1.15.2", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.2.tgz", + "integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==", "dev": true, "funding": [ { @@ -30355,7 +30534,6 @@ "url": "https://github.com/sponsors/RubenVerborgh" } ], - "license": "MIT", "engines": { "node": ">=4.0" }, @@ -30554,6 +30732,15 @@ "node": ">=8" } }, + "node_modules/fork-ts-checker-webpack-plugin/node_modules/yaml": { + "version": "1.10.2", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-1.10.2.tgz", + "integrity": "sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==", + "dev": true, + "engines": { + "node": ">= 6" + } + }, "node_modules/form-data": { "version": "3.0.1", "dev": true, @@ -40240,6 +40427,21 @@ "node": ">=12.0.0" } }, + "node_modules/nock": { + "version": "13.3.3", + "resolved": "https://registry.npmjs.org/nock/-/nock-13.3.3.tgz", + "integrity": "sha512-z+KUlILy9SK/RjpeXDiDUEAq4T94ADPHE3qaRkf66mpEhzc/ytOMm3Bwdrbq6k1tMWkbdujiKim3G2tfQARuJw==", + "dev": true, + "dependencies": { + "debug": "^4.1.0", + "json-stringify-safe": "^5.0.1", + "lodash": "^4.17.21", + "propagate": "^2.0.0" + }, + "engines": { + "node": ">= 10.13" + } + }, "node_modules/node-abi": { "version": "3.45.0", "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.45.0.tgz", @@ -40544,6 +40746,15 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/npm-normalize-package-bin": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/npm-normalize-package-bin/-/npm-normalize-package-bin-3.0.1.tgz", + "integrity": "sha512-dMxCf+zZ+3zeQZXKxmyuCKlIDPGuv8EF940xbkC4kQVDTtqoh6rJFO+JTKSA6/Rwi0getWmtuy4Itup0AMcaDQ==", + "dev": true, + "engines": { + "node": "^14.17.0 || ^16.13.0 || >=18.0.0" + } + }, "node_modules/npm-run-path": { "version": "4.0.1", "license": "MIT", @@ -41504,14 +41715,6 @@ "node": ">=0.6.0" } }, - "node_modules/patch-package/node_modules/yaml": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.3.1.tgz", - "integrity": "sha512-2eHWfjaoXgTBC2jNM1LRef62VQa0umtvRiDSk6HSzW7RvS5YtkabJrwYLLEKWBc8a5U2PTSCs+dJjUTJdlHsWQ==", - "engines": { - "node": ">= 14" - } - }, "node_modules/path-browserify": { "version": "0.0.1", "license": "MIT" @@ -42210,6 +42413,15 @@ "react-is": "^16.13.1" } }, + "node_modules/propagate": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/propagate/-/propagate-2.0.1.tgz", + "integrity": "sha512-vGrhOavPSTz4QVNuBNdcNXePNdNMaO1xj9yBeH1ScQPjk/rhg9sSlCXPhMkFuaNNW/syTvYqsnbIJxMBfRbbag==", + "dev": true, + "engines": { + "node": ">= 8" + } + }, "node_modules/property-information": { "version": "5.6.0", "dev": true, @@ -44289,6 +44501,15 @@ "react-dom": "^15.0.0 || ^16.0.0 || ^17.0.0 || ^18.0.0" } }, + "node_modules/read-cmd-shim": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/read-cmd-shim/-/read-cmd-shim-4.0.0.tgz", + "integrity": "sha512-yILWifhaSEEytfXI76kB9xEEiG1AiozaCJZ83A87ytjRiN+jVibXjedjCRNjoZviinhG+4UkalO3mWTd8u5O0Q==", + "dev": true, + "engines": { + "node": "^14.17.0 || ^16.13.0 || >=18.0.0" + } + }, "node_modules/read-config-file": { "version": "6.3.2", "resolved": "https://registry.npmjs.org/read-config-file/-/read-config-file-6.3.2.tgz", @@ -50441,11 +50662,11 @@ "license": "ISC" }, "node_modules/yaml": { - "version": "1.10.2", - "dev": true, - "license": "ISC", + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.3.1.tgz", + "integrity": "sha512-2eHWfjaoXgTBC2jNM1LRef62VQa0umtvRiDSk6HSzW7RvS5YtkabJrwYLLEKWBc8a5U2PTSCs+dJjUTJdlHsWQ==", "engines": { - "node": ">= 6" + "node": ">= 14" } }, "node_modules/yargs": { @@ -54059,6 +54280,98 @@ "integrity": "sha512-dfLbk+PwWvFzSxwk3n5ySL0hfBog779o8h68wK/7/APo/7cgyWp5jcXockbxdk5kFRkbeXWm4Fbi9FrdN381sA==", "dev": true }, + "@kie/act-js": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/@kie/act-js/-/act-js-2.3.0.tgz", + "integrity": "sha512-Q9k0b05uA46jXKWmVfoGDW+0xsCcE7QPiHi8IH7h41P36DujHKBj4k28RCeIEx3IwUCxYHKwubN8DH4Vzc9XcA==", + "dev": true, + "requires": { + "@kie/mock-github": "^2.0.0", + "adm-zip": "^0.5.10", + "ajv": "^8.12.0", + "bin-links": "^4.0.1", + "express": "^4.18.1", + "follow-redirects": "^1.15.2", + "tar": "^6.1.13", + "yaml": "^2.1.3" + }, + "dependencies": { + "@kie/mock-github": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@kie/mock-github/-/mock-github-2.0.0.tgz", + "integrity": "sha512-od6UyICJYKMnz9HgEWCQAFT/JsCpKkLp+JQH8fV23tf+ZmmQI1dK3C20k6aO5uJhAHA0yOcFtbKFVF4+8i3DTg==", + "dev": true, + "requires": { + "@octokit/openapi-types-ghec": "^18.0.0", + "ajv": "^8.11.0", + "express": "^4.18.1", + "fast-glob": "^3.2.12", + "fs-extra": "^10.1.0", + "nock": "^13.2.7", + "simple-git": "^3.8.0", + "totalist": "^3.0.0" + } + }, + "@octokit/openapi-types-ghec": { + "version": "18.0.0", + "resolved": "https://registry.npmjs.org/@octokit/openapi-types-ghec/-/openapi-types-ghec-18.0.0.tgz", + "integrity": "sha512-xY5FTR/DW2gUJdC5GyzkqrfMHhr3u3hg+dUG6bA5FvuuODw6A7+0JTTSS1ndLQEKGmFxP7chf1BKkhvhnqxCew==", + "dev": true + }, + "fs-extra": { + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz", + "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==", + "dev": true, + "requires": { + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^2.0.0" + } + }, + "totalist": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/totalist/-/totalist-3.0.1.tgz", + "integrity": "sha512-sf4i37nQ2LBx4m3wB74y+ubopq6W/dIzXg0FDGjsYnZHVa1Da8FH853wlL2gtUhg+xJXjfk3kUZS3BRoQeoQBQ==", + "dev": true + } + } + }, + "@kie/mock-github": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@kie/mock-github/-/mock-github-1.1.0.tgz", + "integrity": "sha512-fD+utlOiyZSOutOcXL0G9jfjbtvOO44PLUyTfgfkrm1+575R/dbvU6AcJfjc1DtHeRv7FC7f4ebyU+a1wgL6CA==", + "dev": true, + "requires": { + "@octokit/openapi-types-ghec": "^14.0.0", + "ajv": "^8.11.0", + "express": "^4.18.1", + "fast-glob": "^3.2.12", + "fs-extra": "^10.1.0", + "nock": "^13.2.7", + "simple-git": "^3.8.0", + "totalist": "^3.0.0" + }, + "dependencies": { + "fs-extra": { + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz", + "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==", + "dev": true, + "requires": { + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^2.0.0" + } + }, + "totalist": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/totalist/-/totalist-3.0.1.tgz", + "integrity": "sha512-sf4i37nQ2LBx4m3wB74y+ubopq6W/dIzXg0FDGjsYnZHVa1Da8FH853wlL2gtUhg+xJXjfk3kUZS3BRoQeoQBQ==", + "dev": true + } + } + }, "@kwsites/file-exists": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/@kwsites/file-exists/-/file-exists-1.1.1.tgz", @@ -54451,6 +54764,12 @@ "version": "12.11.0", "dev": true }, + "@octokit/openapi-types-ghec": { + "version": "14.0.0", + "resolved": "https://registry.npmjs.org/@octokit/openapi-types-ghec/-/openapi-types-ghec-14.0.0.tgz", + "integrity": "sha512-xhd9oEvn2aroGn+sk09Ptx/76Y7aKU0EIgHukHPCU1+rGJreO36baEEk6k8ZPblieHNM39FcykJQmtDrETm0KA==", + "dev": true + }, "@octokit/plugin-paginate-rest": { "version": "3.1.0", "dev": true, @@ -55352,11 +55671,6 @@ "requires": { "has-flag": "^4.0.0" } - }, - "yaml": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.3.1.tgz", - "integrity": "sha512-2eHWfjaoXgTBC2jNM1LRef62VQa0umtvRiDSk6HSzW7RvS5YtkabJrwYLLEKWBc8a5U2PTSCs+dJjUTJdlHsWQ==" } } }, @@ -65518,6 +65832,12 @@ "version": "1.2.1", "dev": true }, + "adm-zip": { + "version": "0.5.10", + "resolved": "https://registry.npmjs.org/adm-zip/-/adm-zip-0.5.10.tgz", + "integrity": "sha512-x0HvcHqVJNTPk/Bw8JbLWlWoo6Wwnsug0fnYYro1HBrjxZ3G7/AZk7Ahv8JwDe1uIcz8eBqvu86FuF1POiG7vQ==", + "dev": true + }, "agent-base": { "version": "6.0.2", "dev": true, @@ -65568,7 +65888,9 @@ } }, "ajv": { - "version": "8.11.0", + "version": "8.12.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.12.0.tgz", + "integrity": "sha512-sRu1kpcO9yLtYxBKvqfTeh9KzZEwO3STyX1HT+4CaDzC6HpTGYhIhPIzj9XuKU7KYDwnaeh5hcOwjy1QuJzBPA==", "requires": { "fast-deep-equal": "^3.1.1", "json-schema-traverse": "^1.0.0", @@ -66739,6 +67061,36 @@ "version": "5.2.2", "devOptional": true }, + "bin-links": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/bin-links/-/bin-links-4.0.2.tgz", + "integrity": "sha512-jxJ0PbXR8eQyPlExCvCs3JFnikvs1Yp4gUJt6nmgathdOwvur+q22KWC3h20gvWl4T/14DXKj2IlkJwwZkZPOw==", + "dev": true, + "requires": { + "cmd-shim": "^6.0.0", + "npm-normalize-package-bin": "^3.0.0", + "read-cmd-shim": "^4.0.0", + "write-file-atomic": "^5.0.0" + }, + "dependencies": { + "signal-exit": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", + "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", + "dev": true + }, + "write-file-atomic": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-5.0.1.tgz", + "integrity": "sha512-+QU2zd6OTD8XWIJCbffaiQeH9U73qIqafo1x6V1snCWYGJf6cVE0cDR4D8xRzcEnfI21IFrUPzPGtcPf8AC+Rw==", + "dev": true, + "requires": { + "imurmurhash": "^0.1.4", + "signal-exit": "^4.0.1" + } + } + } + }, "binary-extensions": { "version": "2.2.0", "devOptional": true @@ -67712,6 +68064,12 @@ "resolved": "https://registry.npmjs.org/clsx/-/clsx-1.2.1.tgz", "integrity": "sha512-EcR6r5a8bj6pu3ycsa/E/cKVGuTgZJZdsyUYHOksG/UHIiKfjxzRxYJpyVBwYaQeOvghal9fcc4PidlgzugAQg==" }, + "cmd-shim": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/cmd-shim/-/cmd-shim-6.0.1.tgz", + "integrity": "sha512-S9iI9y0nKR4hwEQsVWpyxld/6kRfGepGfzff83FcaiEBpmvlbA2nnGe7Cylgrx2f/p1P5S5wpRm9oL8z1PbS3Q==", + "dev": true + }, "co": { "version": "4.6.0" }, @@ -68137,6 +68495,14 @@ "parse-json": "^5.0.0", "path-type": "^4.0.0", "yaml": "^1.10.0" + }, + "dependencies": { + "yaml": { + "version": "1.10.2", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-1.10.2.tgz", + "integrity": "sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==", + "dev": true + } } }, "cp-file": { @@ -71064,7 +71430,9 @@ "version": "4.0.3" }, "fast-glob": { - "version": "3.2.11", + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.1.tgz", + "integrity": "sha512-kNFPyjhh5cKjrUltxs+wFx+ZkbRaxxmZ+X0ZU31SOsxCEtP9VPgtq2teZw1DebupL5GmDaNQ6yKMMVcM41iqDg==", "dev": true, "requires": { "@nodelib/fs.stat": "^2.0.2", @@ -71396,7 +71764,9 @@ } }, "follow-redirects": { - "version": "1.15.1", + "version": "1.15.2", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.2.tgz", + "integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==", "dev": true }, "for-each": { @@ -71511,6 +71881,12 @@ "requires": { "has-flag": "^4.0.0" } + }, + "yaml": { + "version": "1.10.2", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-1.10.2.tgz", + "integrity": "sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==", + "dev": true } } }, @@ -78051,6 +78427,18 @@ "resolved": "https://registry.npmjs.org/nocache/-/nocache-3.0.4.tgz", "integrity": "sha512-WDD0bdg9mbq6F4mRxEYcPWwfA1vxd0mrvKOyxI7Xj/atfRHVeutzuWByG//jfm4uPzp0y4Kj051EORCBSQMycw==" }, + "nock": { + "version": "13.3.3", + "resolved": "https://registry.npmjs.org/nock/-/nock-13.3.3.tgz", + "integrity": "sha512-z+KUlILy9SK/RjpeXDiDUEAq4T94ADPHE3qaRkf66mpEhzc/ytOMm3Bwdrbq6k1tMWkbdujiKim3G2tfQARuJw==", + "dev": true, + "requires": { + "debug": "^4.1.0", + "json-stringify-safe": "^5.0.1", + "lodash": "^4.17.21", + "propagate": "^2.0.0" + } + }, "node-abi": { "version": "3.45.0", "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.45.0.tgz", @@ -78279,6 +78667,12 @@ "version": "6.1.0", "dev": true }, + "npm-normalize-package-bin": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/npm-normalize-package-bin/-/npm-normalize-package-bin-3.0.1.tgz", + "integrity": "sha512-dMxCf+zZ+3zeQZXKxmyuCKlIDPGuv8EF940xbkC4kQVDTtqoh6rJFO+JTKSA6/Rwi0getWmtuy4Itup0AMcaDQ==", + "dev": true + }, "npm-run-path": { "version": "4.0.1", "requires": { @@ -78896,11 +79290,6 @@ "requires": { "os-tmpdir": "~1.0.2" } - }, - "yaml": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.3.1.tgz", - "integrity": "sha512-2eHWfjaoXgTBC2jNM1LRef62VQa0umtvRiDSk6HSzW7RvS5YtkabJrwYLLEKWBc8a5U2PTSCs+dJjUTJdlHsWQ==" } } }, @@ -79365,6 +79754,12 @@ "react-is": "^16.13.1" } }, + "propagate": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/propagate/-/propagate-2.0.1.tgz", + "integrity": "sha512-vGrhOavPSTz4QVNuBNdcNXePNdNMaO1xj9yBeH1ScQPjk/rhg9sSlCXPhMkFuaNNW/syTvYqsnbIJxMBfRbbag==", + "dev": true + }, "property-information": { "version": "5.6.0", "dev": true, @@ -80700,6 +81095,12 @@ "memoize-one": ">=3.1.1 <6" } }, + "read-cmd-shim": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/read-cmd-shim/-/read-cmd-shim-4.0.0.tgz", + "integrity": "sha512-yILWifhaSEEytfXI76kB9xEEiG1AiozaCJZ83A87ytjRiN+jVibXjedjCRNjoZviinhG+4UkalO3mWTd8u5O0Q==", + "dev": true + }, "read-config-file": { "version": "6.3.2", "resolved": "https://registry.npmjs.org/read-config-file/-/read-config-file-6.3.2.tgz", @@ -84887,8 +85288,9 @@ "version": "4.0.0" }, "yaml": { - "version": "1.10.2", - "dev": true + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.3.1.tgz", + "integrity": "sha512-2eHWfjaoXgTBC2jNM1LRef62VQa0umtvRiDSk6HSzW7RvS5YtkabJrwYLLEKWBc8a5U2PTSCs+dJjUTJdlHsWQ==" }, "yargs": { "version": "13.3.2", From 65edf96b211f0b3a238161bc7732ee1f99e4004c Mon Sep 17 00:00:00 2001 From: Maciej Dobosz Date: Mon, 21 Aug 2023 11:40:59 +0200 Subject: [PATCH 169/504] English and spanish translations --- src/languages/en.js | 15 +++++++++++---- src/languages/es.js | 16 +++++++++++----- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/src/languages/en.js b/src/languages/en.js index 19dbd9c63187..c0ed7b27a071 100755 --- a/src/languages/en.js +++ b/src/languages/en.js @@ -353,19 +353,23 @@ export default { }, }, sidebarScreen: { - fabAction: 'New chat', + chat: 'Chat', + room: 'Room', newChat: 'New chat', newGroup: 'New group', newRoom: 'New room', buttonSearch: 'Search', buttonMySettings: 'My settings', - fabNewChat: 'New chat (Floating action)', + fabNewChat: 'Send message', + fabNewChatExplained: 'Send message (Floating action)', chatPinned: 'Chat pinned', draftedMessage: 'Drafted message', listOfChatMessages: 'List of chat messages', listOfChats: 'List of chats', }, tabSelector: { + chat: 'Chat', + room: 'Room', manual: 'Manual', scan: 'Scan', distance: 'Distance', @@ -391,9 +395,10 @@ export default { amount: 'Amount', cash: 'Cash', split: 'Split', + addToSplit: 'Add to split', + splitBill: 'Split bill', request: 'Request', participants: 'Participants', - splitBill: 'Split bill', requestMoney: 'Request money', sendMoney: 'Send money', pay: 'Pay', @@ -862,7 +867,9 @@ export default { localTime: 'Local time', }, newChatPage: { + createChat: 'Create chat', createGroup: 'Create group', + addToGroup: 'Add to group', }, yearPickerPage: { year: 'Year', @@ -1410,7 +1417,7 @@ export default { openShortcutDialog: 'Opens the keyboard shortcuts dialog', escape: 'Escape dialogs', search: 'Open search dialog', - newGroup: 'New group screen', + newChat: 'New chat screen', copy: 'Copy comment', }, }, diff --git a/src/languages/es.js b/src/languages/es.js index bb3306417e17..605e6c3c5760 100644 --- a/src/languages/es.js +++ b/src/languages/es.js @@ -352,19 +352,22 @@ export default { }, }, sidebarScreen: { - fabAction: 'Nuevo chat', - newChat: 'Nuevo chat', + chat: 'Chat', + room: 'Sala', newGroup: 'Nuevo grupo', newRoom: 'Nueva sala de chat', buttonSearch: 'Buscar', buttonMySettings: 'Mi configuración', - fabNewChat: 'Nuevo chat', + fabNewChat: 'Enviar mensaje', + fabNewChatExplained: 'Enviar mensaje', chatPinned: 'Chat fijado', draftedMessage: 'Mensaje borrador', listOfChatMessages: 'Lista de mensajes del chat', listOfChats: 'lista de chats', }, tabSelector: { + chat: 'Chat', + room: 'Sala', manual: 'Manual', scan: 'Escanear', distance: 'Distancia', @@ -390,9 +393,10 @@ export default { amount: 'Importe', cash: 'Efectivo', split: 'Dividir', + addToSplit: 'Añadir para dividir', + splitBill: 'Dividir factura', request: 'Solicitar', participants: 'Participantes', - splitBill: 'Dividir factura', requestMoney: 'Pedir dinero', sendMoney: 'Enviar dinero', pay: 'Pagar', @@ -866,7 +870,9 @@ export default { localTime: 'Hora local', }, newChatPage: { + createChat: 'Crear chat', createGroup: 'Crear grupo', + addToGroup: 'Añadir al grupo', }, yearPickerPage: { year: 'Año', @@ -1437,7 +1443,7 @@ export default { openShortcutDialog: 'Abre el cuadro de diálogo de métodos abreviados de teclado', escape: 'Diálogos de escape', search: 'Abrir diálogo de búsqueda', - newGroup: 'Nueva pantalla de grupo', + newChat: 'Nueva pantalla de chat', copy: 'Copiar comentario', }, }, From d0ef97a5a3354cf25a2629325ba24a679f1b435a Mon Sep 17 00:00:00 2001 From: Maciej Dobosz Date: Mon, 21 Aug 2023 11:45:41 +0200 Subject: [PATCH 170/504] Assign icons to new tabs --- src/components/TabSelector/TabSelector.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/components/TabSelector/TabSelector.js b/src/components/TabSelector/TabSelector.js index 3e0ff7eb4e99..2d3901a237fe 100644 --- a/src/components/TabSelector/TabSelector.js +++ b/src/components/TabSelector/TabSelector.js @@ -29,12 +29,18 @@ const defaultProps = { const getIcon = (route) => { switch (route) { + case CONST.TAB.MANUAL: + return Expensicons.Pencil; case CONST.TAB.SCAN: return Expensicons.Receipt; + case CONST.TAB.NEW_CHAT: + return Expensicons.User; + case CONST.TAB.NEW_ROOM: + return Expensicons.Hashtag; case CONST.TAB.DISTANCE: return Expensicons.Car; default: - return Expensicons.Pencil; + throw new Error(`Route ${route} has no icon set.`); } }; From 3e61212d2bc8a441dfb872be6c446fbb32cd947d Mon Sep 17 00:00:00 2001 From: Maciej Dobosz Date: Mon, 21 Aug 2023 11:57:31 +0200 Subject: [PATCH 171/504] Checkbox can become a button --- src/components/OptionRow.js | 29 ++++++++++++++++++- src/components/OptionsList/BaseOptionsList.js | 3 ++ .../OptionsSelector/BaseOptionsSelector.js | 3 ++ .../optionsSelectorPropTypes.js | 9 ++++++ 4 files changed, 43 insertions(+), 1 deletion(-) diff --git a/src/components/OptionRow.js b/src/components/OptionRow.js index adaa4457bbd9..e65b2cf5eda8 100644 --- a/src/components/OptionRow.js +++ b/src/components/OptionRow.js @@ -8,6 +8,7 @@ import * as StyleUtils from '../styles/StyleUtils'; import optionPropTypes from './optionPropTypes'; import Icon from './Icon'; import * as Expensicons from './Icon/Expensicons'; +import Button from './Button'; import MultipleAvatars from './MultipleAvatars'; import Hoverable from './Hoverable'; import DisplayNames from './DisplayNames'; @@ -39,6 +40,15 @@ const propTypes = { /** Whether we should show the selected state */ showSelectedState: PropTypes.bool, + /** Whether to show a button pill instead of a tickbox */ + shouldShowSelectedStateAsButton: PropTypes.bool, + + /** Text for button pill */ + selectedStateButtonText: PropTypes.string, + + /** Callback to fire when the multiple selector (tickbox or button) is clicked */ + onSelectedStatePressed: PropTypes.func, + /** Whether this item is selected */ isSelected: PropTypes.bool, @@ -65,6 +75,9 @@ const propTypes = { const defaultProps = { hoverStyle: styles.sidebarLinkHover, showSelectedState: false, + shouldShowSelectedStateAsButton: false, + selectedStateButtonText: 'Select', + onSelectedStatePressed: undefined, isSelected: false, boldStyle: false, showTitleTooltip: false, @@ -248,7 +261,21 @@ class OptionRow extends Component { /> )} - {this.props.showSelectedState && } + {this.props.showSelectedState && ( + <> + {this.props.shouldShowSelectedStateAsButton && !this.props.isSelected ? ( +