From 5277afe4fb9914841c4ede96de95ea85069dbe2b Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Tue, 21 Feb 2023 12:21:14 +0100 Subject: [PATCH 001/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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/284] 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 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 122/284] 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 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 123/284] 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 124/284] 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 125/284] 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 126/284] 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 41e6d57b3ef4681bcb9d3e141aa5835094f6cc5e Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Thu, 3 Aug 2023 16:39:55 +0200 Subject: [PATCH 127/284] 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 128/284] 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 129/284] 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 130/284] 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 131/284] 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 132/284] 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 133/284] 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 134/284] 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 c2de4f0677d2ebfb3f5d348a5cade98b566902c3 Mon Sep 17 00:00:00 2001 From: Jakub Kosmydel <104823336+kosmydel@users.noreply.github.com> Date: Wed, 9 Aug 2023 09:20:17 +0200 Subject: [PATCH 135/284] Add focus-trap-react library --- package-lock.json | 50 +++++++++++++++++++++++++++++++++++++++++++++++ package.json | 5 +++-- 2 files changed, 53 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index df746a65f3ae..7162d7cfdc9b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -44,6 +44,7 @@ "domhandler": "^4.3.0", "expensify-common": "git+ssh://git@github.com/Expensify/expensify-common.git#9940dd127c2d44809c98ee628a8057f08c93bfc9", "fbjs": "^3.0.2", + "focus-trap-react": "^10.2.1", "htmlparser2": "^7.2.0", "jest-when": "^3.5.2", "localforage": "^1.10.0", @@ -29994,6 +29995,28 @@ "readable-stream": "^2.3.6" } }, + "node_modules/focus-trap": { + "version": "7.5.2", + "resolved": "https://registry.npmjs.org/focus-trap/-/focus-trap-7.5.2.tgz", + "integrity": "sha512-p6vGNNWLDGwJCiEjkSK6oERj/hEyI9ITsSwIUICBoKLlWiTWXJRfQibCwcoi50rTZdbi87qDtUlMCmQwsGSgPw==", + "dependencies": { + "tabbable": "^6.2.0" + } + }, + "node_modules/focus-trap-react": { + "version": "10.2.1", + "resolved": "https://registry.npmjs.org/focus-trap-react/-/focus-trap-react-10.2.1.tgz", + "integrity": "sha512-UrAKOn52lvfHF6lkUMfFhlQxFgahyNW5i6FpHWkDxAeD4FSk3iwx9n4UEA4Sims0G5WiGIi0fAyoq3/UVeNCYA==", + "dependencies": { + "focus-trap": "^7.5.2", + "tabbable": "^6.2.0" + }, + "peerDependencies": { + "prop-types": "^15.8.1", + "react": ">=16.3.0", + "react-dom": ">=16.3.0" + } + }, "node_modules/follow-redirects": { "version": "1.15.1", "dev": true, @@ -46743,6 +46766,11 @@ "dev": true, "license": "BSD-3-Clause" }, + "node_modules/tabbable": { + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/tabbable/-/tabbable-6.2.0.tgz", + "integrity": "sha512-Cat63mxsVJlzYvN51JmVXIgNoUokrIaT2zLclCXjRd8boZ0004U4KCs/sToJ75C6sdlByWxpYnb5Boif1VSFew==" + }, "node_modules/table": { "version": "6.8.0", "dev": true, @@ -70539,6 +70567,23 @@ "readable-stream": "^2.3.6" } }, + "focus-trap": { + "version": "7.5.2", + "resolved": "https://registry.npmjs.org/focus-trap/-/focus-trap-7.5.2.tgz", + "integrity": "sha512-p6vGNNWLDGwJCiEjkSK6oERj/hEyI9ITsSwIUICBoKLlWiTWXJRfQibCwcoi50rTZdbi87qDtUlMCmQwsGSgPw==", + "requires": { + "tabbable": "^6.2.0" + } + }, + "focus-trap-react": { + "version": "10.2.1", + "resolved": "https://registry.npmjs.org/focus-trap-react/-/focus-trap-react-10.2.1.tgz", + "integrity": "sha512-UrAKOn52lvfHF6lkUMfFhlQxFgahyNW5i6FpHWkDxAeD4FSk3iwx9n4UEA4Sims0G5WiGIi0fAyoq3/UVeNCYA==", + "requires": { + "focus-trap": "^7.5.2", + "tabbable": "^6.2.0" + } + }, "follow-redirects": { "version": "1.15.1", "dev": true @@ -81799,6 +81844,11 @@ "version": "2.0.15", "dev": true }, + "tabbable": { + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/tabbable/-/tabbable-6.2.0.tgz", + "integrity": "sha512-Cat63mxsVJlzYvN51JmVXIgNoUokrIaT2zLclCXjRd8boZ0004U4KCs/sToJ75C6sdlByWxpYnb5Boif1VSFew==" + }, "table": { "version": "6.8.0", "dev": true, diff --git a/package.json b/package.json index 56ac7926f0e5..47733b5500c1 100644 --- a/package.json +++ b/package.json @@ -83,6 +83,7 @@ "domhandler": "^4.3.0", "expensify-common": "git+ssh://git@github.com/Expensify/expensify-common.git#9940dd127c2d44809c98ee628a8057f08c93bfc9", "fbjs": "^3.0.2", + "focus-trap-react": "^10.2.1", "htmlparser2": "^7.2.0", "jest-when": "^3.5.2", "localforage": "^1.10.0", @@ -156,8 +157,8 @@ "@babel/preset-env": "^7.20.0", "@babel/preset-flow": "^7.12.13", "@babel/preset-react": "^7.10.4", - "@babel/runtime": "^7.20.0", "@babel/preset-typescript": "^7.21.5", + "@babel/runtime": "^7.20.0", "@electron/notarize": "^1.2.3", "@jest/globals": "^29.5.0", "@octokit/core": "4.0.4", @@ -177,12 +178,12 @@ "@svgr/webpack": "^6.0.0", "@testing-library/jest-native": "5.4.1", "@testing-library/react-native": "11.5.1", - "@types/metro-config": "^0.76.3", "@types/concurrently": "^7.0.0", "@types/jest": "^29.5.2", "@types/jest-when": "^3.5.2", "@types/js-yaml": "^4.0.5", "@types/lodash": "^4.14.195", + "@types/metro-config": "^0.76.3", "@types/mock-fs": "^4.13.1", "@types/pusher-js": "^5.1.0", "@types/react": "^18.2.12", From ca6bfc4a2fd2537ebcd32a2b5820df7a03fc64b0 Mon Sep 17 00:00:00 2001 From: Jakub Kosmydel <104823336+kosmydel@users.noreply.github.com> Date: Wed, 9 Aug 2023 09:29:37 +0200 Subject: [PATCH 136/284] Add focus trap to Screen Wrapper --- src/components/ScreenWrapper/index.js | 68 +++++++++++++---------- src/components/ScreenWrapper/propTypes.js | 4 ++ 2 files changed, 44 insertions(+), 28 deletions(-) diff --git a/src/components/ScreenWrapper/index.js b/src/components/ScreenWrapper/index.js index 8cd4206886f8..6fa0f7e254a6 100644 --- a/src/components/ScreenWrapper/index.js +++ b/src/components/ScreenWrapper/index.js @@ -3,6 +3,7 @@ import React from 'react'; import _ from 'underscore'; import lodashGet from 'lodash/get'; import {PickerAvoidingView} from 'react-native-picker-select'; +import FocusTrap from 'focus-trap-react'; import KeyboardAvoidingView from '../KeyboardAvoidingView'; import CONST from '../../CONST'; import styles from '../../styles/styles'; @@ -32,6 +33,8 @@ class ScreenWrapper extends React.Component { this.state = { didScreenTransitionEnd: false, }; + + this.focusRef = React.createRef(); } componentDidMount() { @@ -95,37 +98,46 @@ class ScreenWrapper extends React.Component { } return ( - this.focusRef.current, + clickOutsideDeactivates: true, + }} > - - - - {this.props.environment === CONST.ENVIRONMENT.DEV && } - {this.props.environment === CONST.ENVIRONMENT.DEV && } - { - // If props.children is a function, call it to provide the insets to the children. - _.isFunction(this.props.children) - ? this.props.children({ - insets, - safeAreaPaddingBottomStyle, - didScreenTransitionEnd: this.state.didScreenTransitionEnd, - }) - : this.props.children - } - {this.props.isSmallScreenWidth && this.props.shouldShowOfflineIndicator && } - - - + + + {this.props.environment === CONST.ENVIRONMENT.DEV && } + {this.props.environment === CONST.ENVIRONMENT.DEV && } + { + // If props.children is a function, call it to provide the insets to the children. + _.isFunction(this.props.children) + ? this.props.children({ + insets, + safeAreaPaddingBottomStyle, + didScreenTransitionEnd: this.state.didScreenTransitionEnd, + }) + : this.props.children + } + {this.props.isSmallScreenWidth && this.props.shouldShowOfflineIndicator && } + + + + ); }} diff --git a/src/components/ScreenWrapper/propTypes.js b/src/components/ScreenWrapper/propTypes.js index 7162ca074f43..ce6368056d47 100644 --- a/src/components/ScreenWrapper/propTypes.js +++ b/src/components/ScreenWrapper/propTypes.js @@ -45,6 +45,9 @@ const propTypes = { /** Styles for the offline indicator */ offlineIndicatorStyle: stylePropTypes, + + /** Whether to disable focus trap */ + shouldDisableFocusTrap: PropTypes.bool, }; const defaultProps = { @@ -59,6 +62,7 @@ const defaultProps = { shouldEnablePickerAvoiding: true, shouldShowOfflineIndicator: true, offlineIndicatorStyle: [], + shouldDisableFocusTrap: false, }; export {propTypes, defaultProps}; From 8bf77af8fc8a78f6b8303d54a9e25432ed375227 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Wed, 9 Aug 2023 11:09:07 +0200 Subject: [PATCH 137/284] 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 9e629a673c45291342d6d6cdef9b8dc165dbfecc Mon Sep 17 00:00:00 2001 From: Jakub Kosmydel <104823336+kosmydel@users.noreply.github.com> Date: Wed, 9 Aug 2023 11:14:45 +0200 Subject: [PATCH 138/284] Disable focus-trap where it isn't needed --- src/pages/home/ReportScreen.js | 1 + src/pages/home/sidebar/SidebarScreen/BaseSidebarScreen.js | 1 + 2 files changed, 2 insertions(+) diff --git a/src/pages/home/ReportScreen.js b/src/pages/home/ReportScreen.js index 94fe5e2beb00..15603f013aea 100644 --- a/src/pages/home/ReportScreen.js +++ b/src/pages/home/ReportScreen.js @@ -313,6 +313,7 @@ class ReportScreen extends React.Component { {({insets}) => ( <> From 1d401a513e57a234dccd66b36722f26fc56d9443 Mon Sep 17 00:00:00 2001 From: Jakub Kosmydel <104823336+kosmydel@users.noreply.github.com> Date: Wed, 9 Aug 2023 12:01:50 +0200 Subject: [PATCH 139/284] Create FocusTrapView, to make it work on the native --- src/components/FocusTrapView/index.js | 42 +++++++++++++++++++ src/components/FocusTrapView/index.native.js | 18 ++++++++ src/components/ScreenWrapper/index.js | 43 ++++++++------------ 3 files changed, 77 insertions(+), 26 deletions(-) create mode 100644 src/components/FocusTrapView/index.js create mode 100644 src/components/FocusTrapView/index.native.js diff --git a/src/components/FocusTrapView/index.js b/src/components/FocusTrapView/index.js new file mode 100644 index 000000000000..1e36550fcf46 --- /dev/null +++ b/src/components/FocusTrapView/index.js @@ -0,0 +1,42 @@ +/* + * The FocusTrap is only used on web and desktop + */ +import React, {useRef} from 'react'; +import FocusTrap from 'focus-trap-react'; +import {View} from 'react-native'; +import { PropTypes } from 'prop-types'; + +const propTypes = { + /** Whether or not to disable the FocusTrap */ + shouldDisableFocusTrap: PropTypes.bool, +}; + +const defaultProps = { + shouldDisableFocusTrap: false, +}; + +function FocusTrapView({shouldDisableFocusTrap, ...props}) { + const ref = useRef(null); + + return ( + ref.current, + clickOutsideDeactivates: true, + }} + > + + + ); +} + +FocusTrapView.displayName = 'FocusTrapView'; +FocusTrapView.propTypes = propTypes; +FocusTrapView.defaultProps = defaultProps; + +export default FocusTrapView; diff --git a/src/components/FocusTrapView/index.native.js b/src/components/FocusTrapView/index.native.js new file mode 100644 index 000000000000..cd9647808141 --- /dev/null +++ b/src/components/FocusTrapView/index.native.js @@ -0,0 +1,18 @@ +/* + * The FocusTrap is only used on web and desktop + */ +import React from 'react'; +import {View} from 'react-native'; +import _ from 'underscore'; + +function FocusTrapView(props) { + const viewProps = _.omit(props, ['shouldDisableFocusTrap']); + return ( + // eslint-disable-next-line react/jsx-props-no-spreading + + ); +} + +FocusTrapView.displayName = 'FocusTrapView'; + +export default FocusTrapView; diff --git a/src/components/ScreenWrapper/index.js b/src/components/ScreenWrapper/index.js index 6fa0f7e254a6..0b1f8a7ceada 100644 --- a/src/components/ScreenWrapper/index.js +++ b/src/components/ScreenWrapper/index.js @@ -3,7 +3,7 @@ import React from 'react'; import _ from 'underscore'; import lodashGet from 'lodash/get'; import {PickerAvoidingView} from 'react-native-picker-select'; -import FocusTrap from 'focus-trap-react'; +import FocusTrapView from '../FocusTrapView'; import KeyboardAvoidingView from '../KeyboardAvoidingView'; import CONST from '../../CONST'; import styles from '../../styles/styles'; @@ -33,8 +33,6 @@ class ScreenWrapper extends React.Component { this.state = { didScreenTransitionEnd: false, }; - - this.focusRef = React.createRef(); } componentDidMount() { @@ -98,28 +96,21 @@ class ScreenWrapper extends React.Component { } return ( - this.focusRef.current, - clickOutsideDeactivates: true, - }} + - - - + {this.props.environment === CONST.ENVIRONMENT.DEV && } {this.props.environment === CONST.ENVIRONMENT.DEV && } @@ -134,10 +125,10 @@ class ScreenWrapper extends React.Component { : this.props.children } {this.props.isSmallScreenWidth && this.props.shouldShowOfflineIndicator && } - - - - + + + + ); }} From bb3450bf26020021f5db0220796c0049a54a462d Mon Sep 17 00:00:00 2001 From: Jakub Kosmydel <104823336+kosmydel@users.noreply.github.com> Date: Wed, 9 Aug 2023 12:28:24 +0200 Subject: [PATCH 140/284] Disable initial focus & refactor --- src/components/FocusTrapView/index.js | 9 +++++---- src/components/FocusTrapView/index.native.js | 2 +- src/components/ScreenWrapper/index.js | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/components/FocusTrapView/index.js b/src/components/FocusTrapView/index.js index 1e36550fcf46..f60f9c8078d4 100644 --- a/src/components/FocusTrapView/index.js +++ b/src/components/FocusTrapView/index.js @@ -8,20 +8,21 @@ import { PropTypes } from 'prop-types'; const propTypes = { /** Whether or not to disable the FocusTrap */ - shouldDisableFocusTrap: PropTypes.bool, + enabled: PropTypes.bool, }; const defaultProps = { - shouldDisableFocusTrap: false, + enabled: true, }; -function FocusTrapView({shouldDisableFocusTrap, ...props}) { +function FocusTrapView({enabled, ...props}) { const ref = useRef(null); return ( ref.current, clickOutsideDeactivates: true, }} diff --git a/src/components/FocusTrapView/index.native.js b/src/components/FocusTrapView/index.native.js index cd9647808141..62a7591f0a08 100644 --- a/src/components/FocusTrapView/index.native.js +++ b/src/components/FocusTrapView/index.native.js @@ -6,7 +6,7 @@ import {View} from 'react-native'; import _ from 'underscore'; function FocusTrapView(props) { - const viewProps = _.omit(props, ['shouldDisableFocusTrap']); + const viewProps = _.omit(props, ['enabled']); return ( // eslint-disable-next-line react/jsx-props-no-spreading diff --git a/src/components/ScreenWrapper/index.js b/src/components/ScreenWrapper/index.js index 0b1f8a7ceada..1a43c6348531 100644 --- a/src/components/ScreenWrapper/index.js +++ b/src/components/ScreenWrapper/index.js @@ -110,7 +110,7 @@ class ScreenWrapper extends React.Component { style={styles.flex1} enabled={this.props.shouldEnablePickerAvoiding} > - + {this.props.environment === CONST.ENVIRONMENT.DEV && } {this.props.environment === CONST.ENVIRONMENT.DEV && } From b2958f55ebf7547a28a895f82353d5652646a69c Mon Sep 17 00:00:00 2001 From: Jakub Kosmydel <104823336+kosmydel@users.noreply.github.com> Date: Wed, 9 Aug 2023 14:19:29 +0200 Subject: [PATCH 141/284] Refactor, add comments --- src/components/FocusTrapView/index.js | 9 +++++++-- src/components/ScreenWrapper/index.js | 5 ++++- src/components/ScreenWrapper/propTypes.js | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/components/FocusTrapView/index.js b/src/components/FocusTrapView/index.js index f60f9c8078d4..f9077d636be6 100644 --- a/src/components/FocusTrapView/index.js +++ b/src/components/FocusTrapView/index.js @@ -4,10 +4,10 @@ import React, {useRef} from 'react'; import FocusTrap from 'focus-trap-react'; import {View} from 'react-native'; -import { PropTypes } from 'prop-types'; +import {PropTypes} from 'prop-types'; const propTypes = { - /** Whether or not to disable the FocusTrap */ + /** Whether to enable the FocusTrap */ enabled: PropTypes.bool, }; @@ -16,6 +16,11 @@ const defaultProps = { }; function FocusTrapView({enabled, ...props}) { + /** + * Focus trap always needs a focusable element. + * In case that we don't have any focusable elements in the modal, + * the FocusTrap will use fallback View element using this ref. + */ const ref = useRef(null); return ( diff --git a/src/components/ScreenWrapper/index.js b/src/components/ScreenWrapper/index.js index 1a43c6348531..aa0aaf0d8988 100644 --- a/src/components/ScreenWrapper/index.js +++ b/src/components/ScreenWrapper/index.js @@ -110,7 +110,10 @@ class ScreenWrapper extends React.Component { style={styles.flex1} enabled={this.props.shouldEnablePickerAvoiding} > - + {this.props.environment === CONST.ENVIRONMENT.DEV && } {this.props.environment === CONST.ENVIRONMENT.DEV && } diff --git a/src/components/ScreenWrapper/propTypes.js b/src/components/ScreenWrapper/propTypes.js index ce6368056d47..6b000da8a22b 100644 --- a/src/components/ScreenWrapper/propTypes.js +++ b/src/components/ScreenWrapper/propTypes.js @@ -46,7 +46,7 @@ const propTypes = { /** Styles for the offline indicator */ offlineIndicatorStyle: stylePropTypes, - /** Whether to disable focus trap */ + /** Whether to disable the focus trap */ shouldDisableFocusTrap: PropTypes.bool, }; From 222d706184297364b74d5ecc21ccf3d8cbc3a8e7 Mon Sep 17 00:00:00 2001 From: Jakub Kosmydel <104823336+kosmydel@users.noreply.github.com> Date: Wed, 9 Aug 2023 15:20:59 +0200 Subject: [PATCH 142/284] Temporarily turn on the initial focus --- src/components/FocusTrapView/index.js | 2 +- src/components/HeaderWithBackButton/index.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/components/FocusTrapView/index.js b/src/components/FocusTrapView/index.js index f9077d636be6..35285b570215 100644 --- a/src/components/FocusTrapView/index.js +++ b/src/components/FocusTrapView/index.js @@ -27,7 +27,7 @@ function FocusTrapView({enabled, ...props}) { ref.current, clickOutsideDeactivates: true, }} diff --git a/src/components/HeaderWithBackButton/index.js b/src/components/HeaderWithBackButton/index.js index 6e6164f4c4fc..52880a81dba0 100755 --- a/src/components/HeaderWithBackButton/index.js +++ b/src/components/HeaderWithBackButton/index.js @@ -64,7 +64,8 @@ function HeaderWithBackButton({ onBackButtonPress(); }} style={[styles.touchableButtonImage]} - accessibilityRole="button" + // Temporary solution to prevent Space from closing the RHP. + // accessibilityRole="button" accessibilityLabel={translate('common.back')} > Date: Thu, 10 Aug 2023 09:46:55 +0200 Subject: [PATCH 143/284] Update package.lock --- package-lock.json | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/package-lock.json b/package-lock.json index c6adf7c192b6..041343a19b1c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -144,6 +144,7 @@ "@types/jest-when": "^3.5.2", "@types/js-yaml": "^4.0.5", "@types/lodash": "^4.14.195", + "@types/metro-config": "^0.76.3", "@types/mock-fs": "^4.13.1", "@types/pusher-js": "^5.1.0", "@types/react": "^18.2.12", @@ -20107,6 +20108,16 @@ "integrity": "sha512-76CqzuD6Q7LC+AtbPqrvD9AqsN0k8bsYo2bM2J8pmNldP1aIPAbzUQ7QbobyXL4eLr1wK5x8FZFe8eF/ubRuBg==", "dev": true }, + "node_modules/@types/metro-config": { + "version": "0.76.3", + "resolved": "https://registry.npmjs.org/@types/metro-config/-/metro-config-0.76.3.tgz", + "integrity": "sha512-tq9IyKm1JzNRpM7V7LALxXiAyTlV5eZwoqntpnRIbnqDsIyNlnPkWQEoX77f40pzcUuAH4CiHRDxW5VskPlgtQ==", + "deprecated": "This is a stub types definition. metro-config provides its own type definitions, so you do not need this installed.", + "dev": true, + "dependencies": { + "metro-config": "*" + } + }, "node_modules/@types/mime": { "version": "3.0.1", "dev": true, @@ -63759,6 +63770,15 @@ "integrity": "sha512-76CqzuD6Q7LC+AtbPqrvD9AqsN0k8bsYo2bM2J8pmNldP1aIPAbzUQ7QbobyXL4eLr1wK5x8FZFe8eF/ubRuBg==", "dev": true }, + "@types/metro-config": { + "version": "0.76.3", + "resolved": "https://registry.npmjs.org/@types/metro-config/-/metro-config-0.76.3.tgz", + "integrity": "sha512-tq9IyKm1JzNRpM7V7LALxXiAyTlV5eZwoqntpnRIbnqDsIyNlnPkWQEoX77f40pzcUuAH4CiHRDxW5VskPlgtQ==", + "dev": true, + "requires": { + "metro-config": "*" + } + }, "@types/mime": { "version": "3.0.1", "dev": true 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 144/284] 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 db68328827935ab857db9be69965ea9b891451f4 Mon Sep 17 00:00:00 2001 From: Jakub Kosmydel <104823336+kosmydel@users.noreply.github.com> Date: Thu, 10 Aug 2023 10:33:49 +0200 Subject: [PATCH 145/284] Add tabindex property --- src/components/FocusTrapView/index.js | 14 +++++++++++--- src/components/HeaderWithBackButton/index.js | 3 +-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/components/FocusTrapView/index.js b/src/components/FocusTrapView/index.js index 35285b570215..96ab17fa068c 100644 --- a/src/components/FocusTrapView/index.js +++ b/src/components/FocusTrapView/index.js @@ -1,7 +1,7 @@ /* * The FocusTrap is only used on web and desktop */ -import React, {useRef} from 'react'; +import React, {useEffect, useRef} from 'react'; import FocusTrap from 'focus-trap-react'; import {View} from 'react-native'; import {PropTypes} from 'prop-types'; @@ -23,12 +23,20 @@ function FocusTrapView({enabled, ...props}) { */ const ref = useRef(null); + /** + * We have to set the 'tabindex' attribute to 0 to make the View focusable. + * Currently, it is not possible to set this through props. + * After the upgrade of 'react-native-web' to version 0.19 we can use 'tabIndex={0}' prop instead. + */ + useEffect(() => { + ref.current.setAttribute('tabindex', '0'); + }, []); + return ( ref.current, + initialFocus: () => ref.current, clickOutsideDeactivates: true, }} > diff --git a/src/components/HeaderWithBackButton/index.js b/src/components/HeaderWithBackButton/index.js index 52880a81dba0..6e6164f4c4fc 100755 --- a/src/components/HeaderWithBackButton/index.js +++ b/src/components/HeaderWithBackButton/index.js @@ -64,8 +64,7 @@ function HeaderWithBackButton({ onBackButtonPress(); }} style={[styles.touchableButtonImage]} - // Temporary solution to prevent Space from closing the RHP. - // accessibilityRole="button" + accessibilityRole="button" accessibilityLabel={translate('common.back')} > Date: Thu, 10 Aug 2023 12:04:32 +0200 Subject: [PATCH 146/284] Add shouldDisableAutoFocus prop to FocusTrapView --- src/components/FocusTrapView/index.js | 11 +++++++++-- src/components/FocusTrapView/index.native.js | 2 +- src/components/ScreenWrapper/index.js | 1 + src/components/ScreenWrapper/propTypes.js | 4 ++++ src/pages/SearchPage.js | 5 ++++- 5 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/components/FocusTrapView/index.js b/src/components/FocusTrapView/index.js index 96ab17fa068c..4ab5228e303a 100644 --- a/src/components/FocusTrapView/index.js +++ b/src/components/FocusTrapView/index.js @@ -9,13 +9,19 @@ import {PropTypes} from 'prop-types'; const propTypes = { /** Whether to enable the FocusTrap */ enabled: PropTypes.bool, + + /** Whether to disable auto focus + * It is used when the component inside the FocusTrap have their own auto focus logic + */ + shouldDisableAutoFocus: PropTypes.bool, }; const defaultProps = { enabled: true, + shouldDisableAutoFocus: false, }; -function FocusTrapView({enabled, ...props}) { +function FocusTrapView({enabled, shouldDisableAutoFocus, ...props}) { /** * Focus trap always needs a focusable element. * In case that we don't have any focusable elements in the modal, @@ -36,7 +42,8 @@ function FocusTrapView({enabled, ...props}) { ref.current, + initialFocus: () => !shouldDisableAutoFocus && ref.current, + fallbackFocus: () => ref.current, clickOutsideDeactivates: true, }} > diff --git a/src/components/FocusTrapView/index.native.js b/src/components/FocusTrapView/index.native.js index 62a7591f0a08..2e02edeadb72 100644 --- a/src/components/FocusTrapView/index.native.js +++ b/src/components/FocusTrapView/index.native.js @@ -6,7 +6,7 @@ import {View} from 'react-native'; import _ from 'underscore'; function FocusTrapView(props) { - const viewProps = _.omit(props, ['enabled']); + const viewProps = _.omit(props, ['enabled', 'shouldDisableAutoFocus']); return ( // eslint-disable-next-line react/jsx-props-no-spreading diff --git a/src/components/ScreenWrapper/index.js b/src/components/ScreenWrapper/index.js index b66bf7fb4dc5..71c3659f73fa 100644 --- a/src/components/ScreenWrapper/index.js +++ b/src/components/ScreenWrapper/index.js @@ -128,6 +128,7 @@ class ScreenWrapper extends React.Component { {this.props.environment === CONST.ENVIRONMENT.DEV && } diff --git a/src/components/ScreenWrapper/propTypes.js b/src/components/ScreenWrapper/propTypes.js index 6b000da8a22b..6f2502935246 100644 --- a/src/components/ScreenWrapper/propTypes.js +++ b/src/components/ScreenWrapper/propTypes.js @@ -48,6 +48,9 @@ const propTypes = { /** Whether to disable the focus trap */ shouldDisableFocusTrap: PropTypes.bool, + + /** Whether to disable auto focus of the focus trap */ + shouldDisableAutoFocus: PropTypes.bool, }; const defaultProps = { @@ -63,6 +66,7 @@ const defaultProps = { shouldShowOfflineIndicator: true, offlineIndicatorStyle: [], shouldDisableFocusTrap: false, + shouldDisableAutoFocus: false, }; export {propTypes, defaultProps}; diff --git a/src/pages/SearchPage.js b/src/pages/SearchPage.js index 3e32922ebdd5..8a65cfdc0cab 100755 --- a/src/pages/SearchPage.js +++ b/src/pages/SearchPage.js @@ -169,7 +169,10 @@ class SearchPage extends Component { ); return ( - + {({didScreenTransitionEnd, safeAreaPaddingBottomStyle}) => ( <> From f46797cd002c512f739275582bedf62c6e821c6a Mon Sep 17 00:00:00 2001 From: Jakub Kosmydel <104823336+kosmydel@users.noreply.github.com> Date: Thu, 10 Aug 2023 14:08:40 +0200 Subject: [PATCH 147/284] Check isFocused prop --- src/components/FocusTrapView/index.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/components/FocusTrapView/index.js b/src/components/FocusTrapView/index.js index 4ab5228e303a..fc194455f8fb 100644 --- a/src/components/FocusTrapView/index.js +++ b/src/components/FocusTrapView/index.js @@ -5,6 +5,7 @@ import React, {useEffect, useRef} from 'react'; import FocusTrap from 'focus-trap-react'; import {View} from 'react-native'; import {PropTypes} from 'prop-types'; +import {useIsFocused} from '@react-navigation/native'; const propTypes = { /** Whether to enable the FocusTrap */ @@ -22,6 +23,8 @@ const defaultProps = { }; function FocusTrapView({enabled, shouldDisableAutoFocus, ...props}) { + const isFocused = useIsFocused(); + /** * Focus trap always needs a focusable element. * In case that we don't have any focusable elements in the modal, @@ -40,7 +43,7 @@ function FocusTrapView({enabled, shouldDisableAutoFocus, ...props}) { return ( !shouldDisableAutoFocus && ref.current, fallbackFocus: () => ref.current, From 83b995bb94b17db50757595c82dce76a23cb4aea Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Wed, 16 Aug 2023 11:27:06 +0200 Subject: [PATCH 148/284] 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 149/284] 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 150/284] 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 6e880a8fea277734dd55eecdee90ef7696264943 Mon Sep 17 00:00:00 2001 From: Jakub Kosmydel <104823336+kosmydel@users.noreply.github.com> Date: Fri, 18 Aug 2023 09:44:43 +0200 Subject: [PATCH 151/284] Remove redundant library --- package-lock.json | 20 -------------------- package.json | 1 - 2 files changed, 21 deletions(-) diff --git a/package-lock.json b/package-lock.json index 041343a19b1c..c6adf7c192b6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -144,7 +144,6 @@ "@types/jest-when": "^3.5.2", "@types/js-yaml": "^4.0.5", "@types/lodash": "^4.14.195", - "@types/metro-config": "^0.76.3", "@types/mock-fs": "^4.13.1", "@types/pusher-js": "^5.1.0", "@types/react": "^18.2.12", @@ -20108,16 +20107,6 @@ "integrity": "sha512-76CqzuD6Q7LC+AtbPqrvD9AqsN0k8bsYo2bM2J8pmNldP1aIPAbzUQ7QbobyXL4eLr1wK5x8FZFe8eF/ubRuBg==", "dev": true }, - "node_modules/@types/metro-config": { - "version": "0.76.3", - "resolved": "https://registry.npmjs.org/@types/metro-config/-/metro-config-0.76.3.tgz", - "integrity": "sha512-tq9IyKm1JzNRpM7V7LALxXiAyTlV5eZwoqntpnRIbnqDsIyNlnPkWQEoX77f40pzcUuAH4CiHRDxW5VskPlgtQ==", - "deprecated": "This is a stub types definition. metro-config provides its own type definitions, so you do not need this installed.", - "dev": true, - "dependencies": { - "metro-config": "*" - } - }, "node_modules/@types/mime": { "version": "3.0.1", "dev": true, @@ -63770,15 +63759,6 @@ "integrity": "sha512-76CqzuD6Q7LC+AtbPqrvD9AqsN0k8bsYo2bM2J8pmNldP1aIPAbzUQ7QbobyXL4eLr1wK5x8FZFe8eF/ubRuBg==", "dev": true }, - "@types/metro-config": { - "version": "0.76.3", - "resolved": "https://registry.npmjs.org/@types/metro-config/-/metro-config-0.76.3.tgz", - "integrity": "sha512-tq9IyKm1JzNRpM7V7LALxXiAyTlV5eZwoqntpnRIbnqDsIyNlnPkWQEoX77f40pzcUuAH4CiHRDxW5VskPlgtQ==", - "dev": true, - "requires": { - "metro-config": "*" - } - }, "@types/mime": { "version": "3.0.1", "dev": true diff --git a/package.json b/package.json index 2c8bc20506cc..d34eccde5417 100644 --- a/package.json +++ b/package.json @@ -183,7 +183,6 @@ "@types/jest-when": "^3.5.2", "@types/js-yaml": "^4.0.5", "@types/lodash": "^4.14.195", - "@types/metro-config": "^0.76.3", "@types/mock-fs": "^4.13.1", "@types/pusher-js": "^5.1.0", "@types/react": "^18.2.12", 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 152/284] 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 9b02fce21bff4a698a6a5c06d71809c28d0caa90 Mon Sep 17 00:00:00 2001 From: Jakub Kosmydel <104823336+kosmydel@users.noreply.github.com> Date: Mon, 21 Aug 2023 09:16:04 +0200 Subject: [PATCH 153/284] Remove outline --- src/components/ScreenWrapper/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/ScreenWrapper/index.js b/src/components/ScreenWrapper/index.js index d25180736986..73f0e4b9d4b8 100644 --- a/src/components/ScreenWrapper/index.js +++ b/src/components/ScreenWrapper/index.js @@ -126,7 +126,7 @@ class ScreenWrapper extends React.Component { enabled={this.props.shouldEnablePickerAvoiding} > From 354abe4ba73492d6ba5e0e9fed8c24350404b1ac Mon Sep 17 00:00:00 2001 From: Jakub Kosmydel <104823336+kosmydel@users.noreply.github.com> Date: Mon, 21 Aug 2023 09:48:42 +0200 Subject: [PATCH 154/284] Refactor shouldDisableAutoFocus to shouldEnableAutoFocus --- src/components/FocusTrapView/index.js | 8 ++++---- src/components/FocusTrapView/index.native.js | 2 +- src/components/ScreenWrapper/index.js | 2 +- src/components/ScreenWrapper/propTypes.js | 4 ++-- src/pages/ProfilePage.js | 2 +- src/pages/SearchPage.js | 5 +---- 6 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/components/FocusTrapView/index.js b/src/components/FocusTrapView/index.js index fc194455f8fb..dc429a8cbe49 100644 --- a/src/components/FocusTrapView/index.js +++ b/src/components/FocusTrapView/index.js @@ -14,15 +14,15 @@ const propTypes = { /** Whether to disable auto focus * It is used when the component inside the FocusTrap have their own auto focus logic */ - shouldDisableAutoFocus: PropTypes.bool, + shouldEnableAutoFocus: PropTypes.bool, }; const defaultProps = { enabled: true, - shouldDisableAutoFocus: false, + shouldEnableAutoFocus: false, }; -function FocusTrapView({enabled, shouldDisableAutoFocus, ...props}) { +function FocusTrapView({enabled, shouldEnableAutoFocus, ...props}) { const isFocused = useIsFocused(); /** @@ -45,7 +45,7 @@ function FocusTrapView({enabled, shouldDisableAutoFocus, ...props}) { !shouldDisableAutoFocus && ref.current, + initialFocus: () => shouldEnableAutoFocus && ref.current, fallbackFocus: () => ref.current, clickOutsideDeactivates: true, }} diff --git a/src/components/FocusTrapView/index.native.js b/src/components/FocusTrapView/index.native.js index 2e02edeadb72..1c077229760c 100644 --- a/src/components/FocusTrapView/index.native.js +++ b/src/components/FocusTrapView/index.native.js @@ -6,7 +6,7 @@ import {View} from 'react-native'; import _ from 'underscore'; function FocusTrapView(props) { - const viewProps = _.omit(props, ['enabled', 'shouldDisableAutoFocus']); + const viewProps = _.omit(props, ['enabled', 'shouldEnableAutoFocus']); return ( // eslint-disable-next-line react/jsx-props-no-spreading diff --git a/src/components/ScreenWrapper/index.js b/src/components/ScreenWrapper/index.js index 73f0e4b9d4b8..581b4338bcf2 100644 --- a/src/components/ScreenWrapper/index.js +++ b/src/components/ScreenWrapper/index.js @@ -128,7 +128,7 @@ class ScreenWrapper extends React.Component { {this.props.environment === CONST.ENVIRONMENT.DEV && } diff --git a/src/components/ScreenWrapper/propTypes.js b/src/components/ScreenWrapper/propTypes.js index 6f2502935246..617f3ea844ca 100644 --- a/src/components/ScreenWrapper/propTypes.js +++ b/src/components/ScreenWrapper/propTypes.js @@ -50,7 +50,7 @@ const propTypes = { shouldDisableFocusTrap: PropTypes.bool, /** Whether to disable auto focus of the focus trap */ - shouldDisableAutoFocus: PropTypes.bool, + shouldEnableAutoFocus: PropTypes.bool, }; const defaultProps = { @@ -66,7 +66,7 @@ const defaultProps = { shouldShowOfflineIndicator: true, offlineIndicatorStyle: [], shouldDisableFocusTrap: false, - shouldDisableAutoFocus: false, + shouldEnableAutoFocus: false, }; export {propTypes, defaultProps}; diff --git a/src/pages/ProfilePage.js b/src/pages/ProfilePage.js index 11e006c8d8fa..37d4e3a25d4c 100755 --- a/src/pages/ProfilePage.js +++ b/src/pages/ProfilePage.js @@ -140,7 +140,7 @@ function ProfilePage(props) { const statusContent = `${statusEmojiCode} ${statusText}`; return ( - + Navigation.goBack(ROUTES.HOME)} diff --git a/src/pages/SearchPage.js b/src/pages/SearchPage.js index 6753fb23267d..6505b604b614 100755 --- a/src/pages/SearchPage.js +++ b/src/pages/SearchPage.js @@ -169,10 +169,7 @@ class SearchPage extends Component { ); return ( - + {({didScreenTransitionEnd, safeAreaPaddingBottomStyle}) => ( <> From 18a3047984a588f104eb1fa438b8dbd8c19114c8 Mon Sep 17 00:00:00 2001 From: Jakub Kosmydel <104823336+kosmydel@users.noreply.github.com> Date: Mon, 21 Aug 2023 10:03:26 +0200 Subject: [PATCH 155/284] Refactor --- src/components/FocusTrapView/index.js | 16 ++++++++++++---- src/components/FocusTrapView/index.native.js | 11 ++--------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/components/FocusTrapView/index.js b/src/components/FocusTrapView/index.js index dc429a8cbe49..63380dd71d87 100644 --- a/src/components/FocusTrapView/index.js +++ b/src/components/FocusTrapView/index.js @@ -8,12 +8,14 @@ import {PropTypes} from 'prop-types'; import {useIsFocused} from '@react-navigation/native'; const propTypes = { + /** Children to wrap with FocusTrap */ + children: PropTypes.node.isRequired, + /** Whether to enable the FocusTrap */ enabled: PropTypes.bool, /** Whether to disable auto focus - * It is used when the component inside the FocusTrap have their own auto focus logic - */ + * It is used when the component inside the FocusTrap have their own auto focus logic */ shouldEnableAutoFocus: PropTypes.bool, }; @@ -38,12 +40,15 @@ function FocusTrapView({enabled, shouldEnableAutoFocus, ...props}) { * After the upgrade of 'react-native-web' to version 0.19 we can use 'tabIndex={0}' prop instead. */ useEffect(() => { + if (!ref.current) { + return; + } ref.current.setAttribute('tabindex', '0'); }, []); - return ( + return enabled ? ( shouldEnableAutoFocus && ref.current, fallbackFocus: () => ref.current, @@ -56,6 +61,9 @@ function FocusTrapView({enabled, shouldEnableAutoFocus, ...props}) { {...props} /> + ) : ( + // eslint-disable-next-line react/jsx-props-no-spreading + props.children ); } diff --git a/src/components/FocusTrapView/index.native.js b/src/components/FocusTrapView/index.native.js index 1c077229760c..5720601f5a2b 100644 --- a/src/components/FocusTrapView/index.native.js +++ b/src/components/FocusTrapView/index.native.js @@ -1,16 +1,9 @@ /* * The FocusTrap is only used on web and desktop */ -import React from 'react'; -import {View} from 'react-native'; -import _ from 'underscore'; -function FocusTrapView(props) { - const viewProps = _.omit(props, ['enabled', 'shouldEnableAutoFocus']); - return ( - // eslint-disable-next-line react/jsx-props-no-spreading - - ); +function FocusTrapView({children}) { + return children; } FocusTrapView.displayName = 'FocusTrapView'; From ce8cf2979e68cac5ccffba2908341490b1fce663 Mon Sep 17 00:00:00 2001 From: Jakub Kosmydel <104823336+kosmydel@users.noreply.github.com> Date: Mon, 21 Aug 2023 10:08:58 +0200 Subject: [PATCH 156/284] Reformat --- src/components/FocusTrapView/index.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/components/FocusTrapView/index.js b/src/components/FocusTrapView/index.js index 63380dd71d87..2dcab7b9d998 100644 --- a/src/components/FocusTrapView/index.js +++ b/src/components/FocusTrapView/index.js @@ -14,8 +14,10 @@ const propTypes = { /** Whether to enable the FocusTrap */ enabled: PropTypes.bool, - /** Whether to disable auto focus - * It is used when the component inside the FocusTrap have their own auto focus logic */ + /** + * Whether to disable auto focus + * It is used when the component inside the FocusTrap have their own auto focus logic + */ shouldEnableAutoFocus: PropTypes.bool, }; @@ -62,7 +64,6 @@ function FocusTrapView({enabled, shouldEnableAutoFocus, ...props}) { /> ) : ( - // eslint-disable-next-line react/jsx-props-no-spreading props.children ); } From 4dd43c2d8f532dfd73a84a8268f72881fd80d079 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Mon, 21 Aug 2023 11:20:29 +0200 Subject: [PATCH 157/284] 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 7799937f9ff528720dd94d090e953e7c0e053959 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Mon, 21 Aug 2023 12:58:18 +0200 Subject: [PATCH 158/284] Merge from upstream Fixed failing tests See: https://github.com/Expensify/App/issues/13604 --- workflow_tests/assertions/platformDeployAssertions.js | 2 ++ workflow_tests/assertions/testBuildAssertions.js | 4 ++++ workflow_tests/mocks/platformDeployMocks.js | 4 ++++ workflow_tests/mocks/testBuildMocks.js | 6 +++++- workflow_tests/testBuild.test.js | 6 ++++-- 5 files changed, 19 insertions(+), 3 deletions(-) diff --git a/workflow_tests/assertions/platformDeployAssertions.js b/workflow_tests/assertions/platformDeployAssertions.js index 36a4667eca95..25460348e4af 100644 --- a/workflow_tests/assertions/platformDeployAssertions.js +++ b/workflow_tests/assertions/platformDeployAssertions.js @@ -129,6 +129,7 @@ const assertIOSJobExecuted = (workflowResult, didExecute = true, isProduction = {key: 'ruby-version', value: '2.7'}, {key: 'bundler-cache', value: 'true'}, ]), + utils.createStepAssertion('Setup credentails for Mapbox SDK', true, null, 'IOS', 'Setup credentials for Mapbox SDK'), utils.createStepAssertion('Install cocoapods', true, null, 'IOS', 'Installing cocoapods', [ {key: 'timeout_minutes', value: '10'}, {key: 'max_attempts', value: '5'}, @@ -204,6 +205,7 @@ const assertWebJobExecuted = (workflowResult, didExecute = true, isProduction = {key: 'AWS_ACCESS_KEY_ID', value: '***'}, {key: 'AWS_SECRET_ACCESS_KEY', value: '***'}, ]), + utils.createStepAssertion('Setup credentails for Mapbox SDK', true, null, 'WEB', 'Setup credentials for Mapbox SDK'), ]; if (isProduction) { steps.push( diff --git a/workflow_tests/assertions/testBuildAssertions.js b/workflow_tests/assertions/testBuildAssertions.js index c93783c39acb..479d8aebdfbe 100644 --- a/workflow_tests/assertions/testBuildAssertions.js +++ b/workflow_tests/assertions/testBuildAssertions.js @@ -86,6 +86,7 @@ const assertAndroidJobExecuted = (workflowResult, ref = '', didExecute = true, f ], [], ), + utils.createStepAssertion('Setup credentails for Mapbox SDK', true, null, 'ANDROID', 'Setup credentials for Mapbox SDK'), utils.createStepAssertion( 'Run Fastlane beta test', true, @@ -98,6 +99,8 @@ const assertAndroidJobExecuted = (workflowResult, ref = '', didExecute = true, f {key: 'S3_SECRET_ACCESS_KEY', value: '***'}, {key: 'S3_BUCKET', value: 'ad-hoc-expensify-cash'}, {key: 'S3_REGION', value: 'us-east-1'}, + {key: 'MYAPP_UPLOAD_STORE_PASSWORD', value: '***'}, + {key: 'MYAPP_UPLOAD_KEY_PASSWORD', value: '***'}, ], ), utils.createStepAssertion( @@ -150,6 +153,7 @@ const assertIOSJobExecuted = (workflowResult, ref = '', didExecute = true, fails ], [], ), + utils.createStepAssertion('Setup credentails for Mapbox SDK', true, null, 'IOS', 'Setup credentials for Mapbox SDK'), utils.createStepAssertion( 'Install cocoapods', true, diff --git a/workflow_tests/mocks/platformDeployMocks.js b/workflow_tests/mocks/platformDeployMocks.js index 56787ec5afa6..2e774eb6f2bc 100644 --- a/workflow_tests/mocks/platformDeployMocks.js +++ b/workflow_tests/mocks/platformDeployMocks.js @@ -95,6 +95,7 @@ const PLATFORM_DEPLOY__DESKTOP__STEP_MOCKS = [ 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__SETUP_CREDENTIALS_FOR_MAPBOX_SDK__STEP_MOCK = utils.createMockStep('Setup credentails for Mapbox SDK', 'Setup credentials for Mapbox SDK', 'IOS'); 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']); @@ -122,6 +123,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__SETUP_CREDENTIALS_FOR_MAPBOX_SDK__STEP_MOCK, PLATFORM_DEPLOY__IOS__COCOAPODS__STEP_MOCK, PLATFORM_DEPLOY__IOS__DECRYPT_PROFILE__STEP_MOCK, PLATFORM_DEPLOY__IOS__DECRYPT_CERTIFICATE__STEP_MOCK, @@ -142,6 +144,7 @@ const PLATFORM_DEPLOY__WEB__AWS_CREDENTIALS__STEP_MOCK = utils.createMockStep('C 'AWS_ACCESS_KEY_ID', 'AWS_SECRET_ACCESS_KEY', ]); +const PLATFORM_DEPLOY__WEB__SETUP_CREDENTIALS_FOR_MAPBOX_SDK__STEP_MOCK = utils.createMockStep('Setup credentails for Mapbox SDK', 'Setup credentials for Mapbox SDK', 'WEB'); 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_STORYBOOK_DOCS_FOR_PRODUCTION__STEP_MOCK = utils.createMockStep('Build storybook docs for production', 'Build storybook docs for production', 'WEB'); @@ -155,6 +158,7 @@ const PLATFORM_DEPLOY__WEB__STEP_MOCKS = [ PLATFORM_DEPLOY__WEB__SETUP_NODE__STEP_MOCK, PLATFORM_DEPLOY__WEB__CLOUDFLARE__STEP_MOCK, PLATFORM_DEPLOY__WEB__AWS_CREDENTIALS__STEP_MOCK, + PLATFORM_DEPLOY__WEB__SETUP_CREDENTIALS_FOR_MAPBOX_SDK__STEP_MOCK, PLATFORM_DEPLOY__WEB__BUILD_PRODUCTION__STEP_MOCK, PLATFORM_DEPLOY__WEB__BUILD_STAGING__STEP_MOCK, PLATFORM_DEPLOY__WEB__BUILD_STORYBOOK_DOCS_FOR_PRODUCTION__STEP_MOCK, diff --git a/workflow_tests/mocks/testBuildMocks.js b/workflow_tests/mocks/testBuildMocks.js index 93c55e89d25d..e2838fb00932 100644 --- a/workflow_tests/mocks/testBuildMocks.js +++ b/workflow_tests/mocks/testBuildMocks.js @@ -72,12 +72,13 @@ const TESTBUILD__ANDROID__CONFIGURE_AWS_CREDENTIALS__STEP_MOCK = utils.createMoc ['AWS_ACCESS_KEY_ID', 'AWS_SECRET_ACCESS_KEY'], [], ); +const TESTBUILD__ANDROID__SETUP_CREDENTIALS_FOR_MAPBOX_SDK__STEP_MOCK = utils.createMockStep('Setup credentails for Mapbox SDK', 'Setup credentials for Mapbox SDK', 'ANDROID'); 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'], + ['S3_ACCESS_KEY', 'S3_SECRET_ACCESS_KEY', 'S3_BUCKET', 'S3_REGION', 'MYAPP_UPLOAD_STORE_PASSWORD', 'MYAPP_UPLOAD_KEY_PASSWORD'], ); const TESTBUILD__ANDROID__UPLOAD_ARTIFACT__STEP_MOCK = utils.createMockStep('Upload Artifact', 'Upload Artifact', 'ANDROID', ['name', 'path'], []); const TESTBUILD__ANDROID__STEP_MOCKS = [ @@ -88,6 +89,7 @@ const TESTBUILD__ANDROID__STEP_MOCKS = [ TESTBUILD__ANDROID__DECRYPT_KEYSTORE__STEP_MOCK, TESTBUILD__ANDROID__DECRYPT_JSON_KEY__STEP_MOCK, TESTBUILD__ANDROID__CONFIGURE_AWS_CREDENTIALS__STEP_MOCK, + TESTBUILD__ANDROID__SETUP_CREDENTIALS_FOR_MAPBOX_SDK__STEP_MOCK, TESTBUILD__ANDROID__RUN_FASTLANE_BETA_TEST__STEP_MOCK, TESTBUILD__ANDROID__UPLOAD_ARTIFACT__STEP_MOCK, ]; @@ -104,6 +106,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__SETUP_CREDENTIALS_FOR_MAPBOX_SDK__STEP_MOCK = utils.createMockStep('Setup credentails for Mapbox SDK', 'Setup credentials for Mapbox SDK', 'IOS'); 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']); @@ -122,6 +125,7 @@ const TESTBUILD__IOS__STEP_MOCKS = [ TESTBUILD__IOS__SETUP_NODE__STEP_MOCK, TESTBUILD__IOS__SETUP_XCODE__STEP_MOCK, TESTBUILD__IOS__SETUP_RUBY__STEP_MOCK, + TESTBUILD__IOS__SETUP_CREDENTIALS_FOR_MAPBOX_SDK__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 227f8b2b917b..cd966e2cdef0 100644 --- a/workflow_tests/testBuild.test.js +++ b/workflow_tests/testBuild.test.js @@ -28,6 +28,8 @@ describe('test workflow testBuild', () => { CSC_KEY_PASSWORD: 'dummy_csc_key_password', APPLE_ID_PASSWORD: 'dummy_apple_id_password', APPLE_ID: 'dummy_apple_id_value', + MYAPP_UPLOAD_STORE_PASSWORD: 'dummy_myapp_upload_store_password', + MYAPP_UPLOAD_KEY_PASSWORD: 'dummy_myapp_upload_key_password', }; beforeAll(async () => { @@ -232,7 +234,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[6] = 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 +245,7 @@ describe('test workflow testBuild', () => { assertions.assertValidateActorJobExecuted(result, '1234'); assertions.assertGetBranchRefJobExecuted(result); assertions.assertAndroidJobExecuted(result, 'test-ref'); - assertions.assertIOSJobExecuted(result, 'test-ref', true, 5); + assertions.assertIOSJobExecuted(result, 'test-ref', true, 6); assertions.assertDesktopJobExecuted(result, 'test-ref'); assertions.assertWebJobExecuted(result, 'test-ref'); assertions.assertPostGithubCommentJobExecuted(result, 'test-ref', '1234', true, 'success', 'failure', 'success', 'success'); From 22042e51213dacff39a9ad280bb8e729fe66ca65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Fija=C5=82kiewicz?= Date: Mon, 21 Aug 2023 16:25:37 +0200 Subject: [PATCH 159/284] destructure the props --- src/pages/SearchPage.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/pages/SearchPage.js b/src/pages/SearchPage.js index bbd9364d6821..8ceb8599ddcf 100755 --- a/src/pages/SearchPage.js +++ b/src/pages/SearchPage.js @@ -38,7 +38,7 @@ const defaultProps = { reports: {}, }; -function SearchPage(props) { +function SearchPage({betas, personalDetails, reports}) { // Data for initialization (runs only on the first render) const { recentReports: initialRecentReports, @@ -46,7 +46,7 @@ function SearchPage(props) { 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), []); + } = useMemo(() => OptionsListUtils.getSearchOptions(reports, personalDetails, '', betas), []); const [searchValue, setSearchValue] = useState(''); const [searchOptions, setSearchOptions] = useState({ @@ -62,14 +62,14 @@ function SearchPage(props) { recentReports: localRecentReports, personalDetails: localPersonalDetails, userToInvite: localUserToInvite, - } = OptionsListUtils.getSearchOptions(props.reports, props.personalDetails, searchValue.trim(), props.betas); + } = OptionsListUtils.getSearchOptions(reports, personalDetails, searchValue.trim(), betas); setSearchOptions({ recentReports: localRecentReports, personalDetails: localPersonalDetails, userToInvite: localUserToInvite, }); - }, [props.reports, props.personalDetails, searchValue, props.betas]); + }, [reports, personalDetails, searchValue, betas]); const debouncedUpdateOptions = useMemo(() => _.debounce(updateOptions, 75), [updateOptions]); @@ -146,7 +146,7 @@ function SearchPage(props) { } }; - const isOptionsDataReady = ReportUtils.isReportDataReady() && OptionsListUtils.isPersonalDetailsReady(props.personalDetails); + const isOptionsDataReady = ReportUtils.isReportDataReady() && OptionsListUtils.isPersonalDetailsReady(personalDetails); const headerMessage = OptionsListUtils.getHeaderMessage( searchOptions.recentReports.length + searchOptions.personalDetails.length !== 0, Boolean(searchOptions.userToInvite), From e3b58528a8cb56f23866f66191f8ee7f984ddc01 Mon Sep 17 00:00:00 2001 From: Ana Margarida Silva Date: Wed, 23 Aug 2023 14:13:19 +0100 Subject: [PATCH 160/284] test: unit test for translation flatten object function --- tests/unit/translations.js | 45 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 tests/unit/translations.js diff --git a/tests/unit/translations.js b/tests/unit/translations.js new file mode 100644 index 000000000000..c411237e6c67 --- /dev/null +++ b/tests/unit/translations.js @@ -0,0 +1,45 @@ +const translations = require('../../src/languages/translations'); + +describe('Translations', () => { + describe('flattenObject()', () => { + it('It should work correctly', () => { + const func = ({content}) => `This is the content: ${content}`; + const simpleObject = { + common: { + yes: 'Yes', + no: 'No', + }, + complex: { + activity: { + none: 'No Activity', + some: 'Some Activity', + }, + report: { + title: { + expense: 'Expense', + task: 'Task', + }, + description: { + none: 'No description', + }, + content: func, + messages: ["Hello", "Hi", "Sup!"] + }, + }, + }; + + const result = translations.flattenObject(simpleObject); + expect(result).toStrictEqual({ + 'common.yes': 'Yes', + 'common.no': 'No', + 'complex.activity.none': 'No Activity', + 'complex.activity.some': 'Some Activity', + 'complex.report.title.expense': 'Expense', + 'complex.report.title.task': 'Task', + 'complex.report.description.none': 'No description', + 'complex.report.content': func, + 'complex.report.messages': ["Hello", "Hi", "Sup!"], + }); + }); + }); +}); From 82919b7856bbc5e8a48d5c1f99771a962d84cf2a Mon Sep 17 00:00:00 2001 From: Ana Margarida Silva Date: Wed, 23 Aug 2023 14:13:26 +0100 Subject: [PATCH 161/284] feat: flatten object function to flatten translation --- src/languages/translations.js | 46 +++++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/src/languages/translations.js b/src/languages/translations.js index c8dd8c8ab0e0..5dd45e83624f 100644 --- a/src/languages/translations.js +++ b/src/languages/translations.js @@ -1,9 +1,51 @@ +import _ from 'underscore'; import en from './en'; import es from './es'; import esES from './es-ES'; +/** + * Converts an object to it's flattened version. + * + * Ex: + * Input: { common: { yes: "Yes", no: "No" }} + * Output: { "common.yes": "Yes", "common.no": "No" } + * + * @param {Object} obj + * @returns {Object} + */ +// Necessary to export so that it is accessible to the unit tests +// eslint-disable-next-line rulesdir/no-inline-named-export +export function flattenObject(obj) { + const result = {}; + + const recursive = (data, key) => { + // If the data is a function or not a object (eg. a string), it's + // the value of the key being built and no need for more recursion + if (_.isFunction(data) || _.isArray(data) || !_.isObject(data)) { + result[key] = data; + } else { + let isEmpty = true; + + // Recursive call to the keys and connect to the respective data + _.keys(data).forEach((k) => { + isEmpty = false; + recursive(data[k], key ? `${key}.${k}` : k); + }); + + // Check for when the object is empty but a key exists, so that + // it defaults to an empty object + if (isEmpty && key) { + result[key] = {}; + } + } + }; + + recursive(obj, ''); + return result; +} + export default { - en, - es, + en: flattenObject(en), + es: flattenObject(es), 'es-ES': esES, }; From 463daff3e06ed6f94484588ee3c90aff8beccc9f Mon Sep 17 00:00:00 2001 From: Ana Margarida Silva Date: Wed, 23 Aug 2023 16:02:00 +0100 Subject: [PATCH 162/284] feat: remove lodashGet from translate --- src/libs/Localize/index.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/libs/Localize/index.js b/src/libs/Localize/index.js index 9878873377b8..a581e42b65e0 100644 --- a/src/libs/Localize/index.js +++ b/src/libs/Localize/index.js @@ -47,15 +47,15 @@ function translate(desiredLanguage = CONST.LOCALES.DEFAULT, phraseKey, phrasePar let translatedPhrase; // Search phrase in full locale e.g. es-ES - const desiredLanguageDictionary = lodashGet(translations, desiredLanguage); - translatedPhrase = lodashGet(desiredLanguageDictionary, phraseKey); + const desiredLanguageDictionary = translations[desiredLanguage] || {}; + translatedPhrase = desiredLanguageDictionary[phraseKey]; if (translatedPhrase) { return Str.result(translatedPhrase, phraseParameters); } // Phrase is not found in full locale, search it in fallback language e.g. es - const fallbackLanguageDictionary = lodashGet(translations, languageAbbreviation); - translatedPhrase = lodashGet(fallbackLanguageDictionary, phraseKey); + const fallbackLanguageDictionary = translations[desiredLanguage] || {}; + translatedPhrase = fallbackLanguageDictionary[phraseKey]; if (translatedPhrase) { return Str.result(translatedPhrase, phraseParameters); } @@ -64,8 +64,8 @@ function translate(desiredLanguage = CONST.LOCALES.DEFAULT, phraseKey, phrasePar } // Phrase is not translated, search it in default language (en) - const defaultLanguageDictionary = lodashGet(translations, CONST.LOCALES.DEFAULT, {}); - translatedPhrase = lodashGet(defaultLanguageDictionary, phraseKey); + const defaultLanguageDictionary = translations[CONST.LOCALES.DEFAULT] || {}; + translatedPhrase = defaultLanguageDictionary[phraseKey]; if (translatedPhrase) { return Str.result(translatedPhrase, phraseParameters); } From 62d4e91f3b6cee85f65433f0adc90c696c9975bc Mon Sep 17 00:00:00 2001 From: Ana Margarida Silva Date: Wed, 23 Aug 2023 16:03:00 +0100 Subject: [PATCH 163/284] feat: migrate use of languages translate to new solution --- src/CONST.js | 2 ++ src/components/LocalePicker.js | 8 +++++--- src/pages/settings/Preferences/LanguagePage.js | 12 +++++++----- src/pages/settings/Preferences/PreferencesPage.js | 7 ++----- 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/CONST.js b/src/CONST.js index 878d3f858dfb..72433212e320 100755 --- a/src/CONST.js +++ b/src/CONST.js @@ -1078,6 +1078,8 @@ const CONST = { DEFAULT: 'en', }, + LANGUAGES: ['en', 'es'], + POLICY: { TYPE: { FREE: 'free', diff --git a/src/components/LocalePicker.js b/src/components/LocalePicker.js index 532c29535e50..435f88e51e53 100644 --- a/src/components/LocalePicker.js +++ b/src/components/LocalePicker.js @@ -27,9 +27,11 @@ const defaultProps = { }; function LocalePicker(props) { - const localesToLanguages = _.map(props.translate('languagePage.languages'), (language, key) => ({ - value: key, - label: language.label, + const localesToLanguages = _.map(CONST.LANGUAGES, (language) => ({ + value: language, + label: props.translate(`languagePage.languages.${language}.label`), + keyForList: language, + isSelected: props.preferredLocale === language, })); return ( ({ - value: key, - text: language.label, - keyForList: key, - isSelected: props.preferredLocale === key, + const localesToLanguages = _.map(CONST.LANGUAGES, (language) => ({ + value: language, + text: props.translate(`languagePage.languages.${language}.label`), + keyForList: language, + isSelected: props.preferredLocale === language, })); + return ( Navigation.navigate(ROUTES.SETTINGS_PRIORITY_MODE)} /> Navigation.navigate(ROUTES.SETTINGS_LANGUAGE)} /> From 370d6790cce9b4d1808c3f052a4908e85331e462 Mon Sep 17 00:00:00 2001 From: Ana Margarida Silva Date: Wed, 23 Aug 2023 16:03:07 +0100 Subject: [PATCH 164/284] feat: migrate use of pronouns translate to new solution --- src/CONST.js | 21 +++++++++++++++++++++ src/pages/settings/Profile/ProfilePage.js | 6 +++++- src/pages/settings/Profile/PronounsPage.js | 13 ++++++------- 3 files changed, 32 insertions(+), 8 deletions(-) diff --git a/src/CONST.js b/src/CONST.js index 72433212e320..0aa4c0f082c0 100755 --- a/src/CONST.js +++ b/src/CONST.js @@ -1080,6 +1080,27 @@ const CONST = { LANGUAGES: ['en', 'es'], + PRONOUNS_LIST: [ + 'coCos', + 'eEyEmEir', + 'heHimHis', + 'heHimHisTheyThemTheirs', + 'sheHerHers', + 'sheHerHersTheyThemTheirs', + 'merMers', + 'neNirNirs', + 'neeNerNers', + 'perPers', + 'theyThemTheirs', + 'thonThons', + 'veVerVis', + 'viVir', + 'xeXemXyr', + 'zeZieZirHir', + 'zeHirHirs', + 'callMeByMyName' + ], + POLICY: { TYPE: { FREE: 'free', diff --git a/src/pages/settings/Profile/ProfilePage.js b/src/pages/settings/Profile/ProfilePage.js index 1f89756353ff..e86ccd685d3e 100755 --- a/src/pages/settings/Profile/ProfilePage.js +++ b/src/pages/settings/Profile/ProfilePage.js @@ -57,7 +57,11 @@ function ProfilePage(props) { if (pronounsKey.startsWith(CONST.PRONOUNS.PREFIX)) { pronounsKey = pronounsKey.slice(CONST.PRONOUNS.PREFIX.length); } - return lodashGet(props.translate('pronouns'), pronounsKey, props.translate('profilePage.selectYourPronouns')); + + if (!pronounsKey) { + return props.translate('profilePage.selectYourPronouns') + } + return props.translate(`pronouns.${pronounsKey}`); }; const currentUserDetails = props.currentUserPersonalDetails || {}; const contactMethodBrickRoadIndicator = UserUtils.getLoginListBrickRoadIndicator(props.loginList); diff --git a/src/pages/settings/Profile/PronounsPage.js b/src/pages/settings/Profile/PronounsPage.js index 50a231523834..eb799a4fe190 100644 --- a/src/pages/settings/Profile/PronounsPage.js +++ b/src/pages/settings/Profile/PronounsPage.js @@ -36,22 +36,21 @@ function PronounsPage(props) { const loadPronouns = useCallback(() => { const currentPronouns = lodashGet(props.currentUserPersonalDetails, 'pronouns', ''); - const pronouns = _.chain(props.translate('pronouns')) - .map((value, key) => { - const fullPronounKey = `${CONST.PRONOUNS.PREFIX}${key}`; + const pronouns = _.chain(CONST.PRONOUNS_LIST).map((value) => { + const fullPronounKey = `${CONST.PRONOUNS.PREFIX}${value}`; const isCurrentPronouns = fullPronounKey === currentPronouns; if (isCurrentPronouns) { setInitiallyFocusedOption({ - text: value, - keyForList: key, + text: props.translate(`pronouns.${value}`), + keyForList: value, }); } return { - text: value, + text: props.translate(`pronouns.${value}`), value: fullPronounKey, - keyForList: key, + keyForList: value, isSelected: isCurrentPronouns, }; }) From 9f84e4245048122fa0fd0f1978cc1d76a1dc21d3 Mon Sep 17 00:00:00 2001 From: Ana Margarida Silva Date: Wed, 23 Aug 2023 17:11:58 +0100 Subject: [PATCH 165/284] feat: migrate use of countries and states translate to new solution --- src/CONST.js | 57 ++++++++++++++++++- .../CountryPicker/CountrySelectorModal.js | 17 +++--- src/components/CountryPicker/index.js | 12 ++-- .../StatePicker/StateSelectorModal.js | 18 +++--- src/components/StatePicker/index.js | 12 ++-- 5 files changed, 87 insertions(+), 29 deletions(-) diff --git a/src/CONST.js b/src/CONST.js index 0aa4c0f082c0..0b64d0904c8e 100755 --- a/src/CONST.js +++ b/src/CONST.js @@ -1098,7 +1098,7 @@ const CONST = { 'xeXemXyr', 'zeZieZirHir', 'zeHirHirs', - 'callMeByMyName' + 'callMeByMyName', ], POLICY: { @@ -1664,6 +1664,61 @@ const CONST = { ZW: 'Zimbabwe', }, + ALL_STATES: { + AK: 'Alaska', + AL: 'Alabama', + AR: 'Arkansas', + AZ: 'Arizona', + CA: 'California', + CO: 'Colorado', + CT: 'Connecticut', + DE: 'Delaware', + FL: 'Florida', + GA: 'Georgia', + HI: 'Hawaii', + IA: 'Iowa', + ID: 'Idaho', + IL: 'Illinois', + IN: 'Indiana', + KS: 'Kansas', + KY: 'Kentucky', + LA: 'Louisiana', + MA: 'Massachusetts', + MD: 'Maryland', + ME: 'Maine', + MI: 'Michigan', + MN: 'Minnesota', + MO: 'Missouri', + MS: 'Mississippi', + MT: 'Montana', + NC: 'North Carolina', + ND: 'North Dakota', + NE: 'Nebraska', + NH: 'New Hampshire', + NJ: 'New Jersey', + NM: 'New Mexico', + NV: 'Nevada', + NY: 'New York', + OH: 'Ohio', + OK: 'Oklahoma', + OR: 'Oregon', + PA: 'Pennsylvania', + PR: 'Puerto Rico', + RI: 'Rhode Island', + SC: 'South Carolina', + SD: 'South Dakota', + TN: 'Tennessee', + TX: 'Texas', + UT: 'Utah', + VA: 'Virginia', + VT: 'Vermont', + WA: 'Washington', + WI: 'Wisconsin', + WV: 'West Virginia', + WY: 'Wyoming', + DC: 'District Of Columbia', + }, + // Sources: https://github.com/Expensify/App/issues/14958#issuecomment-1442138427 // https://github.com/Expensify/App/issues/14958#issuecomment-1456026810 COUNTRY_ZIP_REGEX_DATA: { diff --git a/src/components/CountryPicker/CountrySelectorModal.js b/src/components/CountryPicker/CountrySelectorModal.js index 146b023bbf0c..c68aea276ee2 100644 --- a/src/components/CountryPicker/CountrySelectorModal.js +++ b/src/components/CountryPicker/CountrySelectorModal.js @@ -42,13 +42,16 @@ function CountrySelectorModal({currentCountry, isVisible, onClose, onCountrySele const countries = useMemo( () => - _.map(translate('allCountries'), (countryName, countryISO) => ({ - value: countryISO, - keyForList: countryISO, - text: countryName, - isSelected: currentCountry === countryISO, - searchValue: StringUtils.sanitizeString(`${countryISO}${countryName}`), - })), + _.map(_.keys(CONST.ALL_COUNTRIES), (countryISO) => { + const countryName = translate(`allCountries.${countryISO}`); + return { + value: countryISO, + keyForList: countryISO, + text: countryName, + isSelected: currentCountry === countryISO, + searchValue: StringUtils.sanitizeString(`${countryISO}${countryName}`), + }; + }), [translate, currentCountry], ); diff --git a/src/components/CountryPicker/index.js b/src/components/CountryPicker/index.js index 6d1435dca796..9cae6291fafa 100644 --- a/src/components/CountryPicker/index.js +++ b/src/components/CountryPicker/index.js @@ -1,7 +1,6 @@ import React, {useEffect, useState} from 'react'; import {View} from 'react-native'; import PropTypes from 'prop-types'; -import lodashGet from 'lodash/get'; import styles from '../../styles/styles'; import MenuItemWithTopDescription from '../MenuItemWithTopDescription'; import useLocalize from '../../hooks/useLocalize'; @@ -31,16 +30,15 @@ const defaultProps = { function CountryPicker({value, errorText, onInputChange, forwardedRef}) { const {translate} = useLocalize(); - const allCountries = translate('allCountries'); const [isPickerVisible, setIsPickerVisible] = useState(false); - const [searchValue, setSearchValue] = useState(lodashGet(allCountries, value, '')); + const [searchValue, setSearchValue] = useState(value ? translate(`allCountries.${value}`) : ''); useEffect(() => { - setSearchValue(lodashGet(allCountries, value, '')); - }, [value, allCountries]); + setSearchValue(value ? translate(`allCountries.${value}`) : ''); + }, [value, translate]); const showPickerModal = () => { - setSearchValue(lodashGet(allCountries, value, '')); + setSearchValue(value ? translate(`allCountries.${value}`) : ''); setIsPickerVisible(true); }; @@ -53,7 +51,7 @@ function CountryPicker({value, errorText, onInputChange, forwardedRef}) { hidePickerModal(); }; - const title = allCountries[value] || ''; + const title = value ? translate(`allCountries.${value}`) : ''; const descStyle = title.length === 0 ? styles.textNormal : null; return ( diff --git a/src/components/StatePicker/StateSelectorModal.js b/src/components/StatePicker/StateSelectorModal.js index 91ee1b225a1f..707562026786 100644 --- a/src/components/StatePicker/StateSelectorModal.js +++ b/src/components/StatePicker/StateSelectorModal.js @@ -46,13 +46,17 @@ function StateSelectorModal({currentState, isVisible, onClose, onStateSelected, const countryStates = useMemo( () => - _.map(translate('allStates'), (state) => ({ - value: state.stateISO, - keyForList: state.stateISO, - text: state.stateName, - isSelected: currentState === state.stateISO, - searchValue: StringUtils.sanitizeString(`${state.stateISO}${state.stateName}`), - })), + _.map(_.keys(CONST.ALL_STATES), (state) => { + const stateName = translate(`allStates.${state}.stateName`); + const stateISO = translate(`allStates.${state}.stateISO`); + return { + value: stateISO, + keyForList: stateISO, + text: stateName, + isSelected: currentState === stateISO, + searchValue: StringUtils.sanitizeString(`${stateISO}${stateName}`), + }; + }), [translate, currentState], ); diff --git a/src/components/StatePicker/index.js b/src/components/StatePicker/index.js index c934790f54e5..a069a39623c0 100644 --- a/src/components/StatePicker/index.js +++ b/src/components/StatePicker/index.js @@ -1,6 +1,5 @@ import React, {useEffect, useState} from 'react'; import {View} from 'react-native'; -import lodashGet from 'lodash/get'; import PropTypes from 'prop-types'; import styles from '../../styles/styles'; import MenuItemWithTopDescription from '../MenuItemWithTopDescription'; @@ -35,16 +34,15 @@ const defaultProps = { function StatePicker({value, errorText, onInputChange, forwardedRef, label}) { const {translate} = useLocalize(); - const allStates = translate('allStates'); const [isPickerVisible, setIsPickerVisible] = useState(false); - const [searchValue, setSearchValue] = useState(lodashGet(allStates, `${value}.stateName`, '')); + const [searchValue, setSearchValue] = useState(value ? translate(`allStates.${value}.stateName`) : ''); useEffect(() => { - setSearchValue(lodashGet(allStates, `${value}.stateName`, '')); - }, [value, allStates]); + setSearchValue(value ? translate(`allStates.${value}.stateName`) : ''); + }, [translate, value]); const showPickerModal = () => { - setSearchValue(lodashGet(allStates, `${value}.stateName`, '')); + setSearchValue(value ? translate(`allStates.${value}.stateName`) : ''); setIsPickerVisible(true); }; @@ -57,7 +55,7 @@ function StatePicker({value, errorText, onInputChange, forwardedRef, label}) { hidePickerModal(); }; - const title = allStates[value] ? allStates[value].stateName : ''; + const title = value ? translate(`allStates.${value}.stateName`) : ''; const descStyle = title.length === 0 ? styles.textNormal : null; return ( From 654824122508f525977b1971735a5f05778da9c6 Mon Sep 17 00:00:00 2001 From: Ana Margarida Silva Date: Wed, 23 Aug 2023 17:12:04 +0100 Subject: [PATCH 166/284] style: prettier --- src/pages/settings/Preferences/LanguagePage.js | 1 - src/pages/settings/Profile/ProfilePage.js | 2 +- src/pages/settings/Profile/PronounsPage.js | 3 ++- tests/unit/translations.js | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/pages/settings/Preferences/LanguagePage.js b/src/pages/settings/Preferences/LanguagePage.js index ac575b987ba2..706fa3b62db6 100644 --- a/src/pages/settings/Preferences/LanguagePage.js +++ b/src/pages/settings/Preferences/LanguagePage.js @@ -25,7 +25,6 @@ function LanguagePage(props) { isSelected: props.preferredLocale === language, })); - return ( { const currentPronouns = lodashGet(props.currentUserPersonalDetails, 'pronouns', ''); - const pronouns = _.chain(CONST.PRONOUNS_LIST).map((value) => { + const pronouns = _.chain(CONST.PRONOUNS_LIST) + .map((value) => { const fullPronounKey = `${CONST.PRONOUNS.PREFIX}${value}`; const isCurrentPronouns = fullPronounKey === currentPronouns; diff --git a/tests/unit/translations.js b/tests/unit/translations.js index c411237e6c67..0f79f61f34fb 100644 --- a/tests/unit/translations.js +++ b/tests/unit/translations.js @@ -23,7 +23,7 @@ describe('Translations', () => { none: 'No description', }, content: func, - messages: ["Hello", "Hi", "Sup!"] + messages: ['Hello', 'Hi', 'Sup!'], }, }, }; @@ -38,7 +38,7 @@ describe('Translations', () => { 'complex.report.title.task': 'Task', 'complex.report.description.none': 'No description', 'complex.report.content': func, - 'complex.report.messages': ["Hello", "Hi", "Sup!"], + 'complex.report.messages': ['Hello', 'Hi', 'Sup!'], }); }); }); From f38a0bf7e664d20d2ad3158d7fd496992e9443a1 Mon Sep 17 00:00:00 2001 From: Ana Margarida Silva Date: Thu, 24 Aug 2023 14:18:59 +0100 Subject: [PATCH 167/284] fix: small error --- src/libs/Localize/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/Localize/index.js b/src/libs/Localize/index.js index a581e42b65e0..db371301f43f 100644 --- a/src/libs/Localize/index.js +++ b/src/libs/Localize/index.js @@ -38,7 +38,7 @@ function init() { * Return translated string for given locale and phrase * * @param {String} [desiredLanguage] eg 'en', 'es-ES' - * @param {String|Array} phraseKey + * @param {String} phraseKey * @param {Object} [phraseParameters] Parameters to supply if the phrase is a template literal. * @returns {String} */ @@ -54,7 +54,7 @@ function translate(desiredLanguage = CONST.LOCALES.DEFAULT, phraseKey, phrasePar } // Phrase is not found in full locale, search it in fallback language e.g. es - const fallbackLanguageDictionary = translations[desiredLanguage] || {}; + const fallbackLanguageDictionary = translations[languageAbbreviation] || {}; translatedPhrase = fallbackLanguageDictionary[phraseKey]; if (translatedPhrase) { return Str.result(translatedPhrase, phraseParameters); From 2fef893390000ace720f3c71af1be726ff6b0f86 Mon Sep 17 00:00:00 2001 From: Ana Margarida Silva Date: Thu, 24 Aug 2023 14:20:02 +0100 Subject: [PATCH 168/284] refactor: move unit test to translate unit suite --- tests/unit/TranslateTest.js | 53 ++++++++++++++++++++++++++++++++----- tests/unit/translations.js | 45 ------------------------------- 2 files changed, 47 insertions(+), 51 deletions(-) delete mode 100644 tests/unit/translations.js diff --git a/tests/unit/TranslateTest.js b/tests/unit/TranslateTest.js index 9ac23d6b81b0..d7dffa2293e7 100644 --- a/tests/unit/TranslateTest.js +++ b/tests/unit/TranslateTest.js @@ -7,19 +7,19 @@ const CONST = require('../../src/CONST').default; const originalTranslations = _.clone(translations); translations.default = { - [CONST.LOCALES.EN]: { + [CONST.LOCALES.EN]: translations.flattenObject({ testKey1: 'English', testKey2: 'Test Word 2', testKey3: 'Test Word 3', testKeyGroup: { testFunction: ({testVariable}) => `With variable ${testVariable}`, }, - }, - [CONST.LOCALES.ES]: { + }), + [CONST.LOCALES.ES]: translations.flattenObject({ testKey1: 'Spanish', testKey2: 'Spanish Word 2', - }, - [CONST.LOCALES.ES_ES]: {testKey1: 'Spanish ES'}, + }), + [CONST.LOCALES.ES_ES]: translations.flattenObject({testKey1: 'Spanish ES'}), }; describe('translate', () => { @@ -53,7 +53,6 @@ describe('translate', () => { const expectedValue = 'With variable Test Variable'; const testVariable = 'Test Variable'; expect(Localize.translate(CONST.LOCALES.EN, 'testKeyGroup.testFunction', {testVariable})).toBe(expectedValue); - expect(Localize.translate(CONST.LOCALES.EN, ['testKeyGroup', 'testFunction'], {testVariable})).toBe(expectedValue); }); }); @@ -97,3 +96,45 @@ describe('Translation Keys', () => { }); }); }); + +describe('flattenObject', () => { + it('It should work correctly', () => { + const func = ({content}) => `This is the content: ${content}`; + const simpleObject = { + common: { + yes: 'Yes', + no: 'No', + }, + complex: { + activity: { + none: 'No Activity', + some: 'Some Activity', + }, + report: { + title: { + expense: 'Expense', + task: 'Task', + }, + description: { + none: 'No description', + }, + content: func, + messages: ['Hello', 'Hi', 'Sup!'], + }, + }, + }; + + const result = translations.flattenObject(simpleObject); + expect(result).toStrictEqual({ + 'common.yes': 'Yes', + 'common.no': 'No', + 'complex.activity.none': 'No Activity', + 'complex.activity.some': 'Some Activity', + 'complex.report.title.expense': 'Expense', + 'complex.report.title.task': 'Task', + 'complex.report.description.none': 'No description', + 'complex.report.content': func, + 'complex.report.messages': ['Hello', 'Hi', 'Sup!'], + }); + }); +}); diff --git a/tests/unit/translations.js b/tests/unit/translations.js deleted file mode 100644 index 0f79f61f34fb..000000000000 --- a/tests/unit/translations.js +++ /dev/null @@ -1,45 +0,0 @@ -const translations = require('../../src/languages/translations'); - -describe('Translations', () => { - describe('flattenObject()', () => { - it('It should work correctly', () => { - const func = ({content}) => `This is the content: ${content}`; - const simpleObject = { - common: { - yes: 'Yes', - no: 'No', - }, - complex: { - activity: { - none: 'No Activity', - some: 'Some Activity', - }, - report: { - title: { - expense: 'Expense', - task: 'Task', - }, - description: { - none: 'No description', - }, - content: func, - messages: ['Hello', 'Hi', 'Sup!'], - }, - }, - }; - - const result = translations.flattenObject(simpleObject); - expect(result).toStrictEqual({ - 'common.yes': 'Yes', - 'common.no': 'No', - 'complex.activity.none': 'No Activity', - 'complex.activity.some': 'Some Activity', - 'complex.report.title.expense': 'Expense', - 'complex.report.title.task': 'Task', - 'complex.report.description.none': 'No description', - 'complex.report.content': func, - 'complex.report.messages': ['Hello', 'Hi', 'Sup!'], - }); - }); - }); -}); From 9d8b224bde17718943ecb66b884ef28d43acfcba Mon Sep 17 00:00:00 2001 From: Ana Margarida Silva Date: Thu, 24 Aug 2023 14:24:00 +0100 Subject: [PATCH 169/284] fix: remove unused usage --- tests/unit/TranslateTest.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/unit/TranslateTest.js b/tests/unit/TranslateTest.js index d7dffa2293e7..45d4a12b61f5 100644 --- a/tests/unit/TranslateTest.js +++ b/tests/unit/TranslateTest.js @@ -38,14 +38,12 @@ describe('translate', () => { test('Test when key is not found in default', () => { expect(() => Localize.translate(CONST.LOCALES.ES_ES, 'testKey4')).toThrow(Error); - expect(() => Localize.translate(CONST.LOCALES.ES_ES, ['a', 'b', 'c'])).toThrow(Error); }); test('Test when key is not found in default (Production Mode)', () => { const ORIGINAL_IS_IN_PRODUCTION = CONFIG.default.IS_IN_PRODUCTION; CONFIG.default.IS_IN_PRODUCTION = true; expect(Localize.translate(CONST.LOCALES.ES_ES, 'testKey4')).toBe('testKey4'); - expect(Localize.translate(CONST.LOCALES.ES_ES, ['a', 'b', 'c'])).toBe('a.b.c'); CONFIG.default.IS_IN_PRODUCTION = ORIGINAL_IS_IN_PRODUCTION; }); From ad78499070c7f8ca766e7f47d951f35c37863d2f Mon Sep 17 00:00:00 2001 From: Ana Margarida Silva Date: Fri, 25 Aug 2023 14:41:41 +0100 Subject: [PATCH 170/284] feat: rename const --- src/CONST.js | 2 +- src/components/StatePicker/StateSelectorModal.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/CONST.js b/src/CONST.js index 0b64d0904c8e..9b4a84c10ce4 100755 --- a/src/CONST.js +++ b/src/CONST.js @@ -1664,7 +1664,7 @@ const CONST = { ZW: 'Zimbabwe', }, - ALL_STATES: { + ALL_US_STATES: { AK: 'Alaska', AL: 'Alabama', AR: 'Arkansas', diff --git a/src/components/StatePicker/StateSelectorModal.js b/src/components/StatePicker/StateSelectorModal.js index 707562026786..91458892676a 100644 --- a/src/components/StatePicker/StateSelectorModal.js +++ b/src/components/StatePicker/StateSelectorModal.js @@ -46,7 +46,7 @@ function StateSelectorModal({currentState, isVisible, onClose, onStateSelected, const countryStates = useMemo( () => - _.map(_.keys(CONST.ALL_STATES), (state) => { + _.map(_.keys(CONST.ALL_US_STATES), (state) => { const stateName = translate(`allStates.${state}.stateName`); const stateISO = translate(`allStates.${state}.stateISO`); return { From 15c870495f0affc4d41853acb50c6099cdc507f7 Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Mon, 28 Aug 2023 09:52:09 +0200 Subject: [PATCH 171/284] add "useCanUseTouchScreen" hook --- .../Attachments/AttachmentCarousel/index.js | 3 ++- .../AttachmentCarousel/useCarouselArrows.js | 6 +++--- src/hooks/useCanUseTouchScreen.js | 19 +++++++++++++++++++ 3 files changed, 24 insertions(+), 4 deletions(-) create mode 100644 src/hooks/useCanUseTouchScreen.js diff --git a/src/components/Attachments/AttachmentCarousel/index.js b/src/components/Attachments/AttachmentCarousel/index.js index aaf9ae2ceba9..dc044eac3c7d 100644 --- a/src/components/Attachments/AttachmentCarousel/index.js +++ b/src/components/Attachments/AttachmentCarousel/index.js @@ -19,6 +19,7 @@ import Navigation from '../../../libs/Navigation/Navigation'; import BlockingView from '../../BlockingViews/BlockingView'; import * as Illustrations from '../../Icon/Illustrations'; import variables from '../../../styles/variables'; +import useCanUseTouchScreen from '../../../hooks/useCanUseTouchScreen'; const viewabilityConfig = { // To facilitate paging through the attachments, we want to consider an item "viewable" when it is @@ -30,7 +31,7 @@ function AttachmentCarousel({report, reportActions, source, onNavigate, setDownl const scrollRef = useRef(null); const {windowWidth, isSmallScreenWidth} = useWindowDimensions(); - const canUseTouchScreen = DeviceCapabilities.canUseTouchScreen(); + const canUseTouchScreen = useCanUseTouchScreen(); const [containerWidth, setContainerWidth] = useState(0); const [page, setPage] = useState(0); diff --git a/src/components/Attachments/AttachmentCarousel/useCarouselArrows.js b/src/components/Attachments/AttachmentCarousel/useCarouselArrows.js index f43a26ab94ee..6ecf790d4345 100644 --- a/src/components/Attachments/AttachmentCarousel/useCarouselArrows.js +++ b/src/components/Attachments/AttachmentCarousel/useCarouselArrows.js @@ -1,10 +1,10 @@ import {useCallback, useEffect, useRef, useState} from 'react'; import CONST from '../../../CONST'; import * as DeviceCapabilities from '../../../libs/DeviceCapabilities'; - -const canUseTouchScreen = DeviceCapabilities.canUseTouchScreen(); +import useCanUseTouchScreen from '../../../hooks/useCanUseTouchScreen'; function useCarouselArrows() { + const canUseTouchScreen = useCanUseTouchScreen(); const [shouldShowArrows, setShouldShowArrowsInternal] = useState(canUseTouchScreen); const autoHideArrowTimeout = useRef(null); @@ -25,7 +25,7 @@ function useCarouselArrows() { autoHideArrowTimeout.current = setTimeout(() => { setShouldShowArrowsInternal(false); }, CONST.ARROW_HIDE_DELAY); - }, [cancelAutoHideArrows]); + }, [canUseTouchScreen, cancelAutoHideArrows]); const setShouldShowArrows = useCallback( (show = true) => { diff --git a/src/hooks/useCanUseTouchScreen.js b/src/hooks/useCanUseTouchScreen.js new file mode 100644 index 000000000000..b5632fe08770 --- /dev/null +++ b/src/hooks/useCanUseTouchScreen.js @@ -0,0 +1,19 @@ +import {useEffect, useState} from 'react'; +import * as DeviceCapabilities from '../libs/DeviceCapabilities'; + +/** + * This hooks returns a boolean of whether the device is a touch screen or not. + * @returns {Boolean} + */ +export default function useCanUseTouchScreen() { + const [canUseTouchScreen, setCanUseTouchScreen] = useState(DeviceCapabilities.canUseTouchScreen()); + + // eslint-disable-next-line react-hooks/exhaustive-deps + useEffect(() => { + const newCanUseTouchScreen = DeviceCapabilities.canUseTouchScreen(); + if (canUseTouchScreen === newCanUseTouchScreen) return; + setCanUseTouchScreen(); + }); + + return canUseTouchScreen; +} From fb4b3e1c208c6c8c77c5b9c91473c690ffef99c0 Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Mon, 28 Aug 2023 14:12:40 +0200 Subject: [PATCH 172/284] remove unused import --- src/components/Attachments/AttachmentCarousel/index.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/Attachments/AttachmentCarousel/index.js b/src/components/Attachments/AttachmentCarousel/index.js index dc044eac3c7d..46bd8d8b56c1 100644 --- a/src/components/Attachments/AttachmentCarousel/index.js +++ b/src/components/Attachments/AttachmentCarousel/index.js @@ -2,7 +2,6 @@ import React, {useRef, useCallback, useState, useEffect} from 'react'; import {View, FlatList, PixelRatio, Keyboard} from 'react-native'; import {withOnyx} from 'react-native-onyx'; import _ from 'underscore'; -import * as DeviceCapabilities from '../../../libs/DeviceCapabilities'; import styles from '../../../styles/styles'; import CarouselActions from './CarouselActions'; import AttachmentView from '../AttachmentView'; From 8fc594bc53a4cb4315650a6e5802e1fa413cf601 Mon Sep 17 00:00:00 2001 From: Thiago Brezinski Date: Mon, 28 Aug 2023 15:49:39 +0100 Subject: [PATCH 173/284] feat(selection-list): add tooltip --- .../SelectionList/BaseSelectionList.js | 7 +- .../SelectionList/CheckboxListItem.js | 66 ++++++++++++------- .../SelectionList/selectionListPropTypes.js | 3 + src/pages/workspace/WorkspaceMembersPage.js | 1 + 4 files changed, 53 insertions(+), 24 deletions(-) diff --git a/src/components/SelectionList/BaseSelectionList.js b/src/components/SelectionList/BaseSelectionList.js index 046b64e9e5c0..1842abfe732a 100644 --- a/src/components/SelectionList/BaseSelectionList.js +++ b/src/components/SelectionList/BaseSelectionList.js @@ -242,8 +242,11 @@ function BaseSelectionList({ }; const renderItem = ({item, index, section}) => { + const normalizedIndex = index + lodashGet(section, 'indexOffset', 0); const isDisabled = section.isDisabled; - const isFocused = !isDisabled && focusedIndex === index + lodashGet(section, 'indexOffset', 0); + const isFocused = !isDisabled && focusedIndex === normalizedIndex; + // We only create tooltips for the first 10 users or so since some reports have hundreds of users, causing performance to degrade. + const showTooltip = normalizedIndex < 10; if (canSelectMultiple) { return ( @@ -252,6 +255,7 @@ function BaseSelectionList({ isFocused={isFocused} onSelectRow={() => selectRow(item, index)} onDismissError={onDismissError} + showTooltip={showTooltip} /> ); } @@ -262,6 +266,7 @@ function BaseSelectionList({ isFocused={isFocused} isDisabled={isDisabled} onSelectRow={() => selectRow(item, index)} + showTooltip={showTooltip} /> ); }; diff --git a/src/components/SelectionList/CheckboxListItem.js b/src/components/SelectionList/CheckboxListItem.js index 256182a38e8b..694e03bae632 100644 --- a/src/components/SelectionList/CheckboxListItem.js +++ b/src/components/SelectionList/CheckboxListItem.js @@ -13,10 +13,39 @@ import * as StyleUtils from '../../styles/StyleUtils'; import Icon from '../Icon'; import * as Expensicons from '../Icon/Expensicons'; import themeColors from '../../styles/themes/default'; +import Tooltip from '../Tooltip'; +import UserDetailsTooltip from '../UserDetailsTooltip'; -function CheckboxListItem({item, isFocused = false, onSelectRow, onDismissError = () => {}}) { +function CheckboxListItem({item, isFocused = false, showTooltip = false, onSelectRow, onDismissError = () => {}}) { const hasError = !_.isEmpty(item.errors); + const avatar = ( + + ); + + const text = ( + + {item.text} + + ); + + const alternateText = ( + + {item.alternateText} + + ); + return ( onDismissError(item)} @@ -53,29 +82,20 @@ function CheckboxListItem({item, isFocused = false, onSelectRow, onDismissError /> )} - {Boolean(item.avatar) && ( - - )} - - - {item.text} - - {Boolean(item.alternateText) && ( - - {item.alternateText} - - )} + {avatar} + + ) : ( + avatar + ))} + + {showTooltip ? {text} : text} + {Boolean(item.alternateText) && (showTooltip ? {alternateText} : alternateText)} {Boolean(item.rightElement) && item.rightElement} diff --git a/src/components/SelectionList/selectionListPropTypes.js b/src/components/SelectionList/selectionListPropTypes.js index 9adf42833ebc..c398050a6eae 100644 --- a/src/components/SelectionList/selectionListPropTypes.js +++ b/src/components/SelectionList/selectionListPropTypes.js @@ -46,6 +46,9 @@ const checkboxListItemPropTypes = { /** Whether this item is focused (for arrow key controls) */ isFocused: PropTypes.bool, + /** Whether this item should show Tooltip */ + showTooltip: PropTypes.bool, + /** Callback to fire when the item is pressed */ onSelectRow: PropTypes.func.isRequired, diff --git a/src/pages/workspace/WorkspaceMembersPage.js b/src/pages/workspace/WorkspaceMembersPage.js index d598f90e4326..734714477e47 100644 --- a/src/pages/workspace/WorkspaceMembersPage.js +++ b/src/pages/workspace/WorkspaceMembersPage.js @@ -307,6 +307,7 @@ function WorkspaceMembersPage(props) { result.push({ keyForList: accountID, + accountID, isSelected: _.contains(selectedEmployees, Number(accountID)), isDisabled: accountID === props.session.accountID || details.login === props.policy.owner || policyMember.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE, text: props.formatPhoneNumber(details.displayName), From 883fb01b0aa99995914fa1528e9e64ec09419b6a Mon Sep 17 00:00:00 2001 From: Thiago Brezinski Date: Mon, 28 Aug 2023 16:48:16 +0100 Subject: [PATCH 174/284] fix(selection-list): accountID to number --- src/pages/workspace/WorkspaceMembersPage.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/workspace/WorkspaceMembersPage.js b/src/pages/workspace/WorkspaceMembersPage.js index 734714477e47..22c0a2aca2c4 100644 --- a/src/pages/workspace/WorkspaceMembersPage.js +++ b/src/pages/workspace/WorkspaceMembersPage.js @@ -307,7 +307,7 @@ function WorkspaceMembersPage(props) { result.push({ keyForList: accountID, - accountID, + accountID: Number(accountID), isSelected: _.contains(selectedEmployees, Number(accountID)), isDisabled: accountID === props.session.accountID || details.login === props.policy.owner || policyMember.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE, text: props.formatPhoneNumber(details.displayName), From 2b9cb821d016932ded4d341a516846debde5f146 Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Mon, 28 Aug 2023 20:08:08 +0200 Subject: [PATCH 175/284] Update src/hooks/useCanUseTouchScreen.js Co-authored-by: Bernhard Owen Josephus <50919443+bernhardoj@users.noreply.github.com> --- src/hooks/useCanUseTouchScreen.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hooks/useCanUseTouchScreen.js b/src/hooks/useCanUseTouchScreen.js index b5632fe08770..37a4530eb9dc 100644 --- a/src/hooks/useCanUseTouchScreen.js +++ b/src/hooks/useCanUseTouchScreen.js @@ -12,7 +12,7 @@ export default function useCanUseTouchScreen() { useEffect(() => { const newCanUseTouchScreen = DeviceCapabilities.canUseTouchScreen(); if (canUseTouchScreen === newCanUseTouchScreen) return; - setCanUseTouchScreen(); + setCanUseTouchScreen(newCanUseTouchScreen); }); return canUseTouchScreen; From 05f22e5a014281a82021b662900418563e134baf Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Mon, 28 Aug 2023 20:08:20 +0200 Subject: [PATCH 176/284] Update src/hooks/useCanUseTouchScreen.js Co-authored-by: Maria D'Costa --- src/hooks/useCanUseTouchScreen.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hooks/useCanUseTouchScreen.js b/src/hooks/useCanUseTouchScreen.js index 37a4530eb9dc..347316afc4bd 100644 --- a/src/hooks/useCanUseTouchScreen.js +++ b/src/hooks/useCanUseTouchScreen.js @@ -2,7 +2,7 @@ import {useEffect, useState} from 'react'; import * as DeviceCapabilities from '../libs/DeviceCapabilities'; /** - * This hooks returns a boolean of whether the device is a touch screen or not. + * This hook returns a boolean indicating whether the device is a touch screen or not. * @returns {Boolean} */ export default function useCanUseTouchScreen() { From 15fc3a7508561ca1465258e519dc10797eb48fb8 Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Mon, 28 Aug 2023 20:13:23 +0200 Subject: [PATCH 177/284] revert "useCanUseTouchScreen" changes --- .../Attachments/AttachmentCarousel/index.js | 4 ++-- .../AttachmentCarousel/useCarouselArrows.js | 3 +-- src/hooks/useCanUseTouchScreen.js | 19 ------------------- 3 files changed, 3 insertions(+), 23 deletions(-) delete mode 100644 src/hooks/useCanUseTouchScreen.js diff --git a/src/components/Attachments/AttachmentCarousel/index.js b/src/components/Attachments/AttachmentCarousel/index.js index 46bd8d8b56c1..f2f91afb00b0 100644 --- a/src/components/Attachments/AttachmentCarousel/index.js +++ b/src/components/Attachments/AttachmentCarousel/index.js @@ -18,7 +18,7 @@ import Navigation from '../../../libs/Navigation/Navigation'; import BlockingView from '../../BlockingViews/BlockingView'; import * as Illustrations from '../../Icon/Illustrations'; import variables from '../../../styles/variables'; -import useCanUseTouchScreen from '../../../hooks/useCanUseTouchScreen'; +import * as DeviceCapabilities from '../../../libs/DeviceCapabilities'; const viewabilityConfig = { // To facilitate paging through the attachments, we want to consider an item "viewable" when it is @@ -30,7 +30,7 @@ function AttachmentCarousel({report, reportActions, source, onNavigate, setDownl const scrollRef = useRef(null); const {windowWidth, isSmallScreenWidth} = useWindowDimensions(); - const canUseTouchScreen = useCanUseTouchScreen(); + const canUseTouchScreen = DeviceCapabilities.canUseTouchScreen(); const [containerWidth, setContainerWidth] = useState(0); const [page, setPage] = useState(0); diff --git a/src/components/Attachments/AttachmentCarousel/useCarouselArrows.js b/src/components/Attachments/AttachmentCarousel/useCarouselArrows.js index 6ecf790d4345..64c97fa99819 100644 --- a/src/components/Attachments/AttachmentCarousel/useCarouselArrows.js +++ b/src/components/Attachments/AttachmentCarousel/useCarouselArrows.js @@ -1,10 +1,9 @@ import {useCallback, useEffect, useRef, useState} from 'react'; import CONST from '../../../CONST'; import * as DeviceCapabilities from '../../../libs/DeviceCapabilities'; -import useCanUseTouchScreen from '../../../hooks/useCanUseTouchScreen'; function useCarouselArrows() { - const canUseTouchScreen = useCanUseTouchScreen(); + const canUseTouchScreen = DeviceCapabilities.canUseTouchScreen(); const [shouldShowArrows, setShouldShowArrowsInternal] = useState(canUseTouchScreen); const autoHideArrowTimeout = useRef(null); diff --git a/src/hooks/useCanUseTouchScreen.js b/src/hooks/useCanUseTouchScreen.js deleted file mode 100644 index 347316afc4bd..000000000000 --- a/src/hooks/useCanUseTouchScreen.js +++ /dev/null @@ -1,19 +0,0 @@ -import {useEffect, useState} from 'react'; -import * as DeviceCapabilities from '../libs/DeviceCapabilities'; - -/** - * This hook returns a boolean indicating whether the device is a touch screen or not. - * @returns {Boolean} - */ -export default function useCanUseTouchScreen() { - const [canUseTouchScreen, setCanUseTouchScreen] = useState(DeviceCapabilities.canUseTouchScreen()); - - // eslint-disable-next-line react-hooks/exhaustive-deps - useEffect(() => { - const newCanUseTouchScreen = DeviceCapabilities.canUseTouchScreen(); - if (canUseTouchScreen === newCanUseTouchScreen) return; - setCanUseTouchScreen(newCanUseTouchScreen); - }); - - return canUseTouchScreen; -} From c7b94dbb9afa2e7fe42bcaae2c92e355d0189c44 Mon Sep 17 00:00:00 2001 From: Kamil Owczarz Date: Tue, 29 Aug 2023 11:23:40 +0200 Subject: [PATCH 178/284] Add more debuggable variants --- android/app/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index 133c71d6e7f4..a2350b06d106 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -22,7 +22,7 @@ react { // The list of variants to that are debuggable. For those we're going to // skip the bundling of the JS bundle and the assets. By default is just 'debug'. // If you add flavors like lite, prod, etc. you'll have to list your debuggableVariants. - debuggableVariants = ["developmentDebug"] + debuggableVariants = ["developmentDebug", "productionDebug"] /* Bundling */ // A list containing the node command and its flags. Default is just 'node'. From 2b468b4a2ff86aeeb952f0254885c97b2056ec6f Mon Sep 17 00:00:00 2001 From: Kamil Owczarz Date: Tue, 29 Aug 2023 11:44:24 +0200 Subject: [PATCH 179/284] Rename schemes to make it work with the new architecture --- ios/NewExpensify.xcodeproj/project.pbxproj | 24 +++++++++---------- .../xcschemes/New Expensify AdHoc.xcscheme | 10 ++++---- .../xcschemes/New Expensify Dev.xcscheme | 10 ++++---- .../xcschemes/New Expensify.xcscheme | 8 +++---- ios/Podfile | 14 +++++------ ios/Podfile.lock | 6 ++--- package.json | 6 ++--- 7 files changed, 39 insertions(+), 39 deletions(-) diff --git a/ios/NewExpensify.xcodeproj/project.pbxproj b/ios/NewExpensify.xcodeproj/project.pbxproj index d87226269a8b..d50ee21329ad 100644 --- a/ios/NewExpensify.xcodeproj/project.pbxproj +++ b/ios/NewExpensify.xcodeproj/project.pbxproj @@ -386,29 +386,29 @@ "${PODS_ROOT}/Target Support Files/Pods-NewExpensify/Pods-NewExpensify-frameworks.sh", "${BUILT_PRODUCTS_DIR}/MapboxMaps/MapboxMaps.framework", "${BUILT_PRODUCTS_DIR}/Turf/Turf.framework", - "${PODS_XCFRAMEWORKS_BUILD_DIR}/Flipper-DoubleConversion/double-conversion.framework/double-conversion", - "${PODS_XCFRAMEWORKS_BUILD_DIR}/Flipper-Glog/glog.framework/glog", "${PODS_XCFRAMEWORKS_BUILD_DIR}/MapboxCommon/MapboxCommon.framework/MapboxCommon", "${PODS_XCFRAMEWORKS_BUILD_DIR}/MapboxCoreMaps/MapboxCoreMaps.framework/MapboxCoreMaps", "${PODS_XCFRAMEWORKS_BUILD_DIR}/MapboxMobileEvents/MapboxMobileEvents.framework/MapboxMobileEvents", "${PODS_XCFRAMEWORKS_BUILD_DIR}/Onfido/Onfido.framework/Onfido", - "${PODS_XCFRAMEWORKS_BUILD_DIR}/OpenSSL-Universal/OpenSSL.framework/OpenSSL", "${PODS_XCFRAMEWORKS_BUILD_DIR}/Plaid/LinkKit.framework/LinkKit", "${PODS_XCFRAMEWORKS_BUILD_DIR}/hermes-engine/Pre-built/hermes.framework/hermes", + "${PODS_XCFRAMEWORKS_BUILD_DIR}/Flipper-DoubleConversion/double-conversion.framework/double-conversion", + "${PODS_XCFRAMEWORKS_BUILD_DIR}/Flipper-Glog/glog.framework/glog", + "${PODS_XCFRAMEWORKS_BUILD_DIR}/OpenSSL-Universal/OpenSSL.framework/OpenSSL", ); name = "[CP] Embed Pods Frameworks"; outputPaths = ( "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MapboxMaps.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Turf.framework", - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/double-conversion.framework", - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/glog.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MapboxCommon.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MapboxCoreMaps.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MapboxMobileEvents.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Onfido.framework", - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/OpenSSL.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/LinkKit.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/hermes.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/double-conversion.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/glog.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/OpenSSL.framework", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; @@ -467,29 +467,29 @@ "${PODS_ROOT}/Target Support Files/Pods-NewExpensify-NewExpensifyTests/Pods-NewExpensify-NewExpensifyTests-frameworks.sh", "${BUILT_PRODUCTS_DIR}/MapboxMaps/MapboxMaps.framework", "${BUILT_PRODUCTS_DIR}/Turf/Turf.framework", - "${PODS_XCFRAMEWORKS_BUILD_DIR}/Flipper-DoubleConversion/double-conversion.framework/double-conversion", - "${PODS_XCFRAMEWORKS_BUILD_DIR}/Flipper-Glog/glog.framework/glog", "${PODS_XCFRAMEWORKS_BUILD_DIR}/MapboxCommon/MapboxCommon.framework/MapboxCommon", "${PODS_XCFRAMEWORKS_BUILD_DIR}/MapboxCoreMaps/MapboxCoreMaps.framework/MapboxCoreMaps", "${PODS_XCFRAMEWORKS_BUILD_DIR}/MapboxMobileEvents/MapboxMobileEvents.framework/MapboxMobileEvents", "${PODS_XCFRAMEWORKS_BUILD_DIR}/Onfido/Onfido.framework/Onfido", - "${PODS_XCFRAMEWORKS_BUILD_DIR}/OpenSSL-Universal/OpenSSL.framework/OpenSSL", "${PODS_XCFRAMEWORKS_BUILD_DIR}/Plaid/LinkKit.framework/LinkKit", "${PODS_XCFRAMEWORKS_BUILD_DIR}/hermes-engine/Pre-built/hermes.framework/hermes", + "${PODS_XCFRAMEWORKS_BUILD_DIR}/Flipper-DoubleConversion/double-conversion.framework/double-conversion", + "${PODS_XCFRAMEWORKS_BUILD_DIR}/Flipper-Glog/glog.framework/glog", + "${PODS_XCFRAMEWORKS_BUILD_DIR}/OpenSSL-Universal/OpenSSL.framework/OpenSSL", ); name = "[CP] Embed Pods Frameworks"; outputPaths = ( "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MapboxMaps.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Turf.framework", - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/double-conversion.framework", - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/glog.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MapboxCommon.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MapboxCoreMaps.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MapboxMobileEvents.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Onfido.framework", - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/OpenSSL.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/LinkKit.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/hermes.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/double-conversion.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/glog.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/OpenSSL.framework", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; diff --git a/ios/NewExpensify.xcodeproj/xcshareddata/xcschemes/New Expensify AdHoc.xcscheme b/ios/NewExpensify.xcodeproj/xcshareddata/xcschemes/New Expensify AdHoc.xcscheme index 0e0fad6399a0..6cd590456eed 100644 --- a/ios/NewExpensify.xcodeproj/xcshareddata/xcschemes/New Expensify AdHoc.xcscheme +++ b/ios/NewExpensify.xcodeproj/xcshareddata/xcschemes/New Expensify AdHoc.xcscheme @@ -57,7 +57,7 @@ @@ -75,7 +75,7 @@ + buildConfiguration = "DebugAdHoc"> diff --git a/ios/NewExpensify.xcodeproj/xcshareddata/xcschemes/New Expensify Dev.xcscheme b/ios/NewExpensify.xcodeproj/xcshareddata/xcschemes/New Expensify Dev.xcscheme index 77f512242f67..93d775217f11 100644 --- a/ios/NewExpensify.xcodeproj/xcshareddata/xcschemes/New Expensify Dev.xcscheme +++ b/ios/NewExpensify.xcodeproj/xcshareddata/xcschemes/New Expensify Dev.xcscheme @@ -23,7 +23,7 @@ @@ -41,7 +41,7 @@ + buildConfiguration = "DebugDevelopment"> diff --git a/ios/NewExpensify.xcodeproj/xcshareddata/xcschemes/New Expensify.xcscheme b/ios/NewExpensify.xcodeproj/xcshareddata/xcschemes/New Expensify.xcscheme index f68be2705527..b6b5874506a8 100644 --- a/ios/NewExpensify.xcodeproj/xcshareddata/xcschemes/New Expensify.xcscheme +++ b/ios/NewExpensify.xcodeproj/xcshareddata/xcschemes/New Expensify.xcscheme @@ -75,7 +75,7 @@ + buildConfiguration = "DebugProduction"> diff --git a/ios/Podfile b/ios/Podfile index 6445685db014..b30510572448 100644 --- a/ios/Podfile +++ b/ios/Podfile @@ -22,7 +22,7 @@ prepare_react_native_project! # dependencies: { # ...(process.env.NO_FLIPPER ? { 'react-native-flipper': { platforms: { ios: null } } } : {}), # ``` -flipper_config = ENV['NO_FLIPPER'] == "1" ? FlipperConfiguration.disabled : FlipperConfiguration.enabled(['Debug Production', 'Debug Development', 'Debug AdHoc']) +flipper_config = ENV['NO_FLIPPER'] == "1" ? FlipperConfiguration.disabled : FlipperConfiguration.enabled(['DebugProduction', 'DebugDevelopment', 'DebugAdHoc']) linkage = ENV['USE_FRAMEWORKS'] if linkage != nil @@ -54,12 +54,12 @@ target 'NewExpensify' do permissions_path = '../node_modules/react-native-permissions/ios' project 'NewExpensify', - 'Debug Development' => :debug, - 'Debug AdHoc' => :debug, - 'Debug Production' => :debug, - 'Release Development' => :release, - 'Release AdHoc' => :release, - 'Release Production' => :release + 'DebugDevelopment' => :debug, + 'DebugAdHoc' => :debug, + 'DebugProduction' => :debug, + 'ReleaseDevelopment' => :release, + 'ReleaseAdHoc' => :release, + 'ReleaseProduction' => :release pod 'Permission-LocationAccuracy', :path => "#{permissions_path}/LocationAccuracy" pod 'Permission-LocationAlways', :path => "#{permissions_path}/LocationAlways" diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 16ed1e05dc64..aeb1887223cd 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -591,7 +591,7 @@ PODS: - React-Core - react-native-pager-view (6.2.0): - React-Core - - react-native-pdf (6.6.2): + - react-native-pdf (6.7.1): - React-Core - react-native-performance (4.0.0): - React-Core @@ -1254,7 +1254,7 @@ SPEC CHECKSUMS: react-native-key-command: c2645ec01eb1fa664606c09480c05cb4220ef67b react-native-netinfo: ccbe1085dffd16592791d550189772e13bf479e2 react-native-pager-view: 0ccb8bf60e2ebd38b1f3669fa3650ecce81db2df - react-native-pdf: 33c622cbdf776a649929e8b9d1ce2d313347c4fa + react-native-pdf: 7c0e91ada997bac8bac3bb5bea5b6b81f5a3caae react-native-performance: 224bd53e6a835fda4353302cf891d088a0af7406 react-native-plaid-link-sdk: 9eb0f71dad94b3bdde649c7a384cba93024af46c react-native-quick-sqlite: bcc7a7a250a40222f18913a97cd356bf82d0a6c4 @@ -1309,6 +1309,6 @@ SPEC CHECKSUMS: Yoga: 8796b55dba14d7004f980b54bcc9833ee45b28ce YogaKit: f782866e155069a2cca2517aafea43200b01fd5a -PODFILE CHECKSUM: 845537d35601574adcd0794e17003ba7dbccdbfd +PODFILE CHECKSUM: 2daf34c870819a933f3fefe426801d54b2ff2a14 COCOAPODS: 1.12.1 diff --git a/package.json b/package.json index 58bb57b1bb98..b59023438f9c 100644 --- a/package.json +++ b/package.json @@ -11,10 +11,10 @@ "postinstall": "scripts/postInstall.sh", "clean": "npx react-native clean-project-auto", "android": "scripts/set-pusher-suffix.sh && npx react-native run-android --variant=developmentDebug --appId=com.expensify.chat.dev", - "ios": "scripts/set-pusher-suffix.sh && npx react-native run-ios --configuration=\"Debug Development\" --scheme=\"New Expensify Dev\"", + "ios": "scripts/set-pusher-suffix.sh && npx react-native run-ios --configuration=\"DebugDevelopment\" --scheme=\"New Expensify Dev\"", "pod-install": "cd ios && bundle exec pod install", - "ipad": "concurrently \"npx react-native run-ios --simulator=\\\"iPad Pro (12.9-inch) (6th generation)\\\" --configuration=\\\"Debug Development\\\" --scheme=\\\"New Expensify Dev\\\"\"", - "ipad-sm": "concurrently \"npx react-native run-ios --simulator=\\\"iPad Pro (11-inch) (4th generation)\\\" --configuration=\\\"Debug Development\\\" --scheme=\\\"New Expensify Dev\\\"\"", + "ipad": "concurrently \"npx react-native run-ios --simulator=\\\"iPad Pro (12.9-inch) (6th generation)\\\" --configuration=\\\"DebugDevelopment\\\" --scheme=\\\"New Expensify Dev\\\"\"", + "ipad-sm": "concurrently \"npx react-native run-ios --simulator=\\\"iPad Pro (11-inch) (4th generation)\\\" --configuration=\\\"DebugDevelopment\\\" --scheme=\\\"New Expensify Dev\\\"\"", "start": "npx react-native start", "web": "scripts/set-pusher-suffix.sh && concurrently npm:web-proxy npm:web-server", "web-proxy": "node web/proxy.js", From bdadeb76f264c0982bda719eba7410c7ea18e642 Mon Sep 17 00:00:00 2001 From: Kamil Owczarz Date: Tue, 29 Aug 2023 16:51:04 +0200 Subject: [PATCH 180/284] Update misssing build configuration names --- ios/NewExpensify.xcodeproj/project.pbxproj | 118 ++++++++++----------- 1 file changed, 59 insertions(+), 59 deletions(-) diff --git a/ios/NewExpensify.xcodeproj/project.pbxproj b/ios/NewExpensify.xcodeproj/project.pbxproj index d50ee21329ad..711e6cc77a73 100644 --- a/ios/NewExpensify.xcodeproj/project.pbxproj +++ b/ios/NewExpensify.xcodeproj/project.pbxproj @@ -29,7 +29,7 @@ 70CF6E82262E297300711ADC /* BootSplash.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 70CF6E81262E297300711ADC /* BootSplash.storyboard */; }; BDB853621F354EBB84E619C2 /* ExpensifyNewKansas-MediumItalic.otf in Resources */ = {isa = PBXBuildFile; fileRef = D2AFB39EC1D44BF9B91D3227 /* ExpensifyNewKansas-MediumItalic.otf */; }; DD79042B2792E76D004484B4 /* RCTBootSplash.m in Sources */ = {isa = PBXBuildFile; fileRef = DD79042A2792E76D004484B4 /* RCTBootSplash.m */; }; - E51DC681C7DEE40AEBDDFBFE /* BuildFile in Frameworks */ = {isa = PBXBuildFile; }; + E51DC681C7DEE40AEBDDFBFE /* (null) in Frameworks */ = {isa = PBXBuildFile; }; E9DF872D2525201700607FDC /* AirshipConfig.plist in Resources */ = {isa = PBXBuildFile; fileRef = E9DF872C2525201700607FDC /* AirshipConfig.plist */; }; ED222ED90E074A5481A854FA /* ExpensifyNeue-BoldItalic.otf in Resources */ = {isa = PBXBuildFile; fileRef = 8B28D84EF339436DBD42A203 /* ExpensifyNeue-BoldItalic.otf */; }; F0C450EA2705020500FD2970 /* colors.json in Resources */ = {isa = PBXBuildFile; fileRef = F0C450E92705020500FD2970 /* colors.json */; }; @@ -112,7 +112,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - E51DC681C7DEE40AEBDDFBFE /* BuildFile in Frameworks */, + E51DC681C7DEE40AEBDDFBFE /* (null) in Frameworks */, 5A464BC8112CDB1DE1E38F1C /* libPods-NewExpensify.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -641,7 +641,7 @@ /* End PBXTargetDependency section */ /* Begin XCBuildConfiguration section */ - 00E356F61AD99517003FC87E /* Debug Development */ = { + 00E356F61AD99517003FC87E /* DebugDevelopment */ = { isa = XCBuildConfiguration; baseConfigurationReference = E2F1036F70CBFE39E9352674 /* Pods-NewExpensify-NewExpensifyTests.debug development.xcconfig */; buildSettings = { @@ -664,9 +664,9 @@ PRODUCT_NAME = "$(TARGET_NAME)"; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/NewExpensify.app/NewExpensify"; }; - name = "Debug Development"; + name = DebugDevelopment; }; - 00E356F71AD99517003FC87E /* Release Development */ = { + 00E356F71AD99517003FC87E /* ReleaseDevelopment */ = { isa = XCBuildConfiguration; baseConfigurationReference = BD6E1BA27D6ABE0AC9D70586 /* Pods-NewExpensify-NewExpensifyTests.release development.xcconfig */; buildSettings = { @@ -687,9 +687,9 @@ PRODUCT_NAME = "$(TARGET_NAME)"; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/NewExpensify.app/NewExpensify"; }; - name = "Release Development"; + name = ReleaseDevelopment; }; - 13B07F941A680F5B00A75B9A /* Debug Development */ = { + 13B07F941A680F5B00A75B9A /* DebugDevelopment */ = { isa = XCBuildConfiguration; baseConfigurationReference = CECC4CBB97A55705A33BEA9E /* Pods-NewExpensify.debug development.xcconfig */; buildSettings = { @@ -719,9 +719,9 @@ TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; }; - name = "Debug Development"; + name = DebugDevelopment; }; - 13B07F951A680F5B00A75B9A /* Release Development */ = { + 13B07F951A680F5B00A75B9A /* ReleaseDevelopment */ = { isa = XCBuildConfiguration; baseConfigurationReference = 02BE6CF80ED1BD2445267F92 /* Pods-NewExpensify.release development.xcconfig */; buildSettings = { @@ -749,9 +749,9 @@ TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; }; - name = "Release Development"; + name = ReleaseDevelopment; }; - 83CBBA201A601CBA00E9B192 /* Debug Development */ = { + 83CBBA201A601CBA00E9B192 /* DebugDevelopment */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; @@ -814,9 +814,9 @@ REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native"; SDKROOT = iphoneos; }; - name = "Debug Development"; + name = DebugDevelopment; }; - 83CBBA211A601CBA00E9B192 /* Release Development */ = { + 83CBBA211A601CBA00E9B192 /* ReleaseDevelopment */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; @@ -873,9 +873,9 @@ SDKROOT = iphoneos; VALIDATE_PRODUCT = YES; }; - name = "Release Development"; + name = ReleaseDevelopment; }; - CF9AF93E29EE9276001FA527 /* Debug Production */ = { + CF9AF93E29EE9276001FA527 /* DebugProduction */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; @@ -938,9 +938,9 @@ REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native"; SDKROOT = iphoneos; }; - name = "Debug Production"; + name = DebugProduction; }; - CF9AF93F29EE9276001FA527 /* Debug Production */ = { + CF9AF93F29EE9276001FA527 /* DebugProduction */ = { isa = XCBuildConfiguration; baseConfigurationReference = 0E27AA27706D894246E7946D /* Pods-NewExpensify.debug production.xcconfig */; buildSettings = { @@ -970,9 +970,9 @@ TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; }; - name = "Debug Production"; + name = DebugProduction; }; - CF9AF94029EE9276001FA527 /* Debug Production */ = { + CF9AF94029EE9276001FA527 /* DebugProduction */ = { isa = XCBuildConfiguration; baseConfigurationReference = DB76E0D5C670190A0997C71E /* Pods-NewExpensify-NewExpensifyTests.debug production.xcconfig */; buildSettings = { @@ -995,9 +995,9 @@ PRODUCT_NAME = "$(TARGET_NAME)"; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/NewExpensify.app/NewExpensify"; }; - name = "Debug Production"; + name = DebugProduction; }; - CF9AF94429EE927A001FA527 /* Debug AdHoc */ = { + CF9AF94429EE927A001FA527 /* DebugAdHoc */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; @@ -1060,9 +1060,9 @@ REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native"; SDKROOT = iphoneos; }; - name = "Debug AdHoc"; + name = DebugAdHoc; }; - CF9AF94529EE927A001FA527 /* Debug AdHoc */ = { + CF9AF94529EE927A001FA527 /* DebugAdHoc */ = { isa = XCBuildConfiguration; baseConfigurationReference = 0B09CE5BDAF34DD3573AB4E2 /* Pods-NewExpensify.debug adhoc.xcconfig */; buildSettings = { @@ -1092,9 +1092,9 @@ TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; }; - name = "Debug AdHoc"; + name = DebugAdHoc; }; - CF9AF94629EE927A001FA527 /* Debug AdHoc */ = { + CF9AF94629EE927A001FA527 /* DebugAdHoc */ = { isa = XCBuildConfiguration; baseConfigurationReference = 432FF5842B766535509FC547 /* Pods-NewExpensify-NewExpensifyTests.debug adhoc.xcconfig */; buildSettings = { @@ -1117,9 +1117,9 @@ PRODUCT_NAME = "$(TARGET_NAME)"; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/NewExpensify.app/NewExpensify"; }; - name = "Debug AdHoc"; + name = DebugAdHoc; }; - CF9AF94729EE928E001FA527 /* Release Production */ = { + CF9AF94729EE928E001FA527 /* ReleaseProduction */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; @@ -1176,9 +1176,9 @@ SDKROOT = iphoneos; VALIDATE_PRODUCT = YES; }; - name = "Release Production"; + name = ReleaseProduction; }; - CF9AF94829EE928E001FA527 /* Release Production */ = { + CF9AF94829EE928E001FA527 /* ReleaseProduction */ = { isa = XCBuildConfiguration; baseConfigurationReference = 34A8FDD1F9AA58B8F15C8380 /* Pods-NewExpensify.release production.xcconfig */; buildSettings = { @@ -1206,9 +1206,9 @@ TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; }; - name = "Release Production"; + name = ReleaseProduction; }; - CF9AF94929EE928E001FA527 /* Release Production */ = { + CF9AF94929EE928E001FA527 /* ReleaseProduction */ = { isa = XCBuildConfiguration; baseConfigurationReference = 96552D489D9F09B6A5ABD81B /* Pods-NewExpensify-NewExpensifyTests.release production.xcconfig */; buildSettings = { @@ -1229,9 +1229,9 @@ PRODUCT_NAME = "$(TARGET_NAME)"; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/NewExpensify.app/NewExpensify"; }; - name = "Release Production"; + name = ReleaseProduction; }; - CF9AF94D29EE9293001FA527 /* Release AdHoc */ = { + CF9AF94D29EE9293001FA527 /* ReleaseAdHoc */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; @@ -1288,9 +1288,9 @@ SDKROOT = iphoneos; VALIDATE_PRODUCT = YES; }; - name = "Release AdHoc"; + name = ReleaseAdHoc; }; - CF9AF94E29EE9293001FA527 /* Release AdHoc */ = { + CF9AF94E29EE9293001FA527 /* ReleaseAdHoc */ = { isa = XCBuildConfiguration; baseConfigurationReference = 1DDE5449979A136852B939B5 /* Pods-NewExpensify.release adhoc.xcconfig */; buildSettings = { @@ -1318,9 +1318,9 @@ TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; }; - name = "Release AdHoc"; + name = ReleaseAdHoc; }; - CF9AF94F29EE9293001FA527 /* Release AdHoc */ = { + CF9AF94F29EE9293001FA527 /* ReleaseAdHoc */ = { isa = XCBuildConfiguration; baseConfigurationReference = 6B5211DB0EEB46E12DF4AD2D /* Pods-NewExpensify-NewExpensifyTests.release adhoc.xcconfig */; buildSettings = { @@ -1341,7 +1341,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/NewExpensify.app/NewExpensify"; }; - name = "Release AdHoc"; + name = ReleaseAdHoc; }; /* End XCBuildConfiguration section */ @@ -1349,41 +1349,41 @@ 00E357021AD99517003FC87E /* Build configuration list for PBXNativeTarget "NewExpensifyTests" */ = { isa = XCConfigurationList; buildConfigurations = ( - 00E356F61AD99517003FC87E /* Debug Development */, - CF9AF94629EE927A001FA527 /* Debug AdHoc */, - CF9AF94029EE9276001FA527 /* Debug Production */, - 00E356F71AD99517003FC87E /* Release Development */, - CF9AF94F29EE9293001FA527 /* Release AdHoc */, - CF9AF94929EE928E001FA527 /* Release Production */, + 00E356F61AD99517003FC87E /* DebugDevelopment */, + CF9AF94629EE927A001FA527 /* DebugAdHoc */, + CF9AF94029EE9276001FA527 /* DebugProduction */, + 00E356F71AD99517003FC87E /* ReleaseDevelopment */, + CF9AF94F29EE9293001FA527 /* ReleaseAdHoc */, + CF9AF94929EE928E001FA527 /* ReleaseProduction */, ); defaultConfigurationIsVisible = 0; - defaultConfigurationName = "Debug Development"; + defaultConfigurationName = DebugDevelopment; }; 13B07F931A680F5B00A75B9A /* Build configuration list for PBXNativeTarget "NewExpensify" */ = { isa = XCConfigurationList; buildConfigurations = ( - 13B07F941A680F5B00A75B9A /* Debug Development */, - CF9AF94529EE927A001FA527 /* Debug AdHoc */, - CF9AF93F29EE9276001FA527 /* Debug Production */, - 13B07F951A680F5B00A75B9A /* Release Development */, - CF9AF94E29EE9293001FA527 /* Release AdHoc */, - CF9AF94829EE928E001FA527 /* Release Production */, + 13B07F941A680F5B00A75B9A /* DebugDevelopment */, + CF9AF94529EE927A001FA527 /* DebugAdHoc */, + CF9AF93F29EE9276001FA527 /* DebugProduction */, + 13B07F951A680F5B00A75B9A /* ReleaseDevelopment */, + CF9AF94E29EE9293001FA527 /* ReleaseAdHoc */, + CF9AF94829EE928E001FA527 /* ReleaseProduction */, ); defaultConfigurationIsVisible = 0; - defaultConfigurationName = "Debug Development"; + defaultConfigurationName = DebugDevelopment; }; 83CBB9FA1A601CBA00E9B192 /* Build configuration list for PBXProject "NewExpensify" */ = { isa = XCConfigurationList; buildConfigurations = ( - 83CBBA201A601CBA00E9B192 /* Debug Development */, - CF9AF94429EE927A001FA527 /* Debug AdHoc */, - CF9AF93E29EE9276001FA527 /* Debug Production */, - 83CBBA211A601CBA00E9B192 /* Release Development */, - CF9AF94D29EE9293001FA527 /* Release AdHoc */, - CF9AF94729EE928E001FA527 /* Release Production */, + 83CBBA201A601CBA00E9B192 /* DebugDevelopment */, + CF9AF94429EE927A001FA527 /* DebugAdHoc */, + CF9AF93E29EE9276001FA527 /* DebugProduction */, + 83CBBA211A601CBA00E9B192 /* ReleaseDevelopment */, + CF9AF94D29EE9293001FA527 /* ReleaseAdHoc */, + CF9AF94729EE928E001FA527 /* ReleaseProduction */, ); defaultConfigurationIsVisible = 0; - defaultConfigurationName = "Debug Development"; + defaultConfigurationName = DebugDevelopment; }; /* End XCConfigurationList section */ }; From be06765e056dd59512c091f0f79b1cb6d3f5fcbb Mon Sep 17 00:00:00 2001 From: Kamil Owczarz Date: Tue, 29 Aug 2023 16:55:15 +0200 Subject: [PATCH 181/284] Update pods --- ios/NewExpensify.xcodeproj/project.pbxproj | 76 ++++++++++++++-------- ios/Podfile.lock | 4 +- 2 files changed, 52 insertions(+), 28 deletions(-) diff --git a/ios/NewExpensify.xcodeproj/project.pbxproj b/ios/NewExpensify.xcodeproj/project.pbxproj index 711e6cc77a73..64ed3fda8b02 100644 --- a/ios/NewExpensify.xcodeproj/project.pbxproj +++ b/ios/NewExpensify.xcodeproj/project.pbxproj @@ -29,7 +29,7 @@ 70CF6E82262E297300711ADC /* BootSplash.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 70CF6E81262E297300711ADC /* BootSplash.storyboard */; }; BDB853621F354EBB84E619C2 /* ExpensifyNewKansas-MediumItalic.otf in Resources */ = {isa = PBXBuildFile; fileRef = D2AFB39EC1D44BF9B91D3227 /* ExpensifyNewKansas-MediumItalic.otf */; }; DD79042B2792E76D004484B4 /* RCTBootSplash.m in Sources */ = {isa = PBXBuildFile; fileRef = DD79042A2792E76D004484B4 /* RCTBootSplash.m */; }; - E51DC681C7DEE40AEBDDFBFE /* (null) in Frameworks */ = {isa = PBXBuildFile; }; + E51DC681C7DEE40AEBDDFBFE /* BuildFile in Frameworks */ = {isa = PBXBuildFile; }; E9DF872D2525201700607FDC /* AirshipConfig.plist in Resources */ = {isa = PBXBuildFile; fileRef = E9DF872C2525201700607FDC /* AirshipConfig.plist */; }; ED222ED90E074A5481A854FA /* ExpensifyNeue-BoldItalic.otf in Resources */ = {isa = PBXBuildFile; fileRef = 8B28D84EF339436DBD42A203 /* ExpensifyNeue-BoldItalic.otf */; }; F0C450EA2705020500FD2970 /* colors.json in Resources */ = {isa = PBXBuildFile; fileRef = F0C450E92705020500FD2970 /* colors.json */; }; @@ -52,6 +52,7 @@ 00E356F11AD99517003FC87E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 02BE6CF80ED1BD2445267F92 /* Pods-NewExpensify.release development.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-NewExpensify.release development.xcconfig"; path = "Target Support Files/Pods-NewExpensify/Pods-NewExpensify.release development.xcconfig"; sourceTree = ""; }; 0B09CE5BDAF34DD3573AB4E2 /* Pods-NewExpensify.debug adhoc.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-NewExpensify.debug adhoc.xcconfig"; path = "Target Support Files/Pods-NewExpensify/Pods-NewExpensify.debug adhoc.xcconfig"; sourceTree = ""; }; + 0B627F2A465153FFA6E3A4E0 /* Pods-NewExpensify.debugdevelopment.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-NewExpensify.debugdevelopment.xcconfig"; path = "Target Support Files/Pods-NewExpensify/Pods-NewExpensify.debugdevelopment.xcconfig"; sourceTree = ""; }; 0CDA8E33287DD650004ECBEC /* AppDelegate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = AppDelegate.mm; path = NewExpensify/AppDelegate.mm; sourceTree = ""; }; 0CDA8E36287DD6A0004ECBEC /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Images.xcassets; path = NewExpensify/Images.xcassets; sourceTree = ""; }; 0E27AA27706D894246E7946D /* Pods-NewExpensify.debug production.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-NewExpensify.debug production.xcconfig"; path = "Target Support Files/Pods-NewExpensify/Pods-NewExpensify.debug production.xcconfig"; sourceTree = ""; }; @@ -64,38 +65,49 @@ 13B07FB71A68108700A75B9A /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = NewExpensify/main.m; sourceTree = ""; }; 18D050DF262400AF000D658B /* BridgingFile.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BridgingFile.swift; sourceTree = ""; }; 1DDE5449979A136852B939B5 /* Pods-NewExpensify.release adhoc.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-NewExpensify.release adhoc.xcconfig"; path = "Target Support Files/Pods-NewExpensify/Pods-NewExpensify.release adhoc.xcconfig"; sourceTree = ""; }; + 25A4587E168FD67CF890B448 /* Pods-NewExpensify-NewExpensifyTests.debugadhoc.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-NewExpensify-NewExpensifyTests.debugadhoc.xcconfig"; path = "Target Support Files/Pods-NewExpensify-NewExpensifyTests/Pods-NewExpensify-NewExpensifyTests.debugadhoc.xcconfig"; sourceTree = ""; }; + 30FFBD291B71222A393D9CC9 /* Pods-NewExpensify.releasedevelopment.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-NewExpensify.releasedevelopment.xcconfig"; path = "Target Support Files/Pods-NewExpensify/Pods-NewExpensify.releasedevelopment.xcconfig"; sourceTree = ""; }; 34A8FDD1F9AA58B8F15C8380 /* Pods-NewExpensify.release production.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-NewExpensify.release production.xcconfig"; path = "Target Support Files/Pods-NewExpensify/Pods-NewExpensify.release production.xcconfig"; sourceTree = ""; }; 374FB8D528A133A7000D84EF /* OriginImageRequestHandler.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = OriginImageRequestHandler.h; path = NewExpensify/OriginImageRequestHandler.h; sourceTree = ""; }; 374FB8D628A133FE000D84EF /* OriginImageRequestHandler.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = OriginImageRequestHandler.mm; path = NewExpensify/OriginImageRequestHandler.mm; sourceTree = ""; }; 3D393D7ABC1092F1DE91397F /* Pods-NewExpensify-NewExpensifyTests.debug staging.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-NewExpensify-NewExpensifyTests.debug staging.xcconfig"; path = "Target Support Files/Pods-NewExpensify-NewExpensifyTests/Pods-NewExpensify-NewExpensifyTests.debug staging.xcconfig"; sourceTree = ""; }; 432FF5842B766535509FC547 /* Pods-NewExpensify-NewExpensifyTests.debug adhoc.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-NewExpensify-NewExpensifyTests.debug adhoc.xcconfig"; path = "Target Support Files/Pods-NewExpensify-NewExpensifyTests/Pods-NewExpensify-NewExpensifyTests.debug adhoc.xcconfig"; sourceTree = ""; }; 44BF435285B94E5B95F90994 /* ExpensifyNewKansas-Medium.otf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = "ExpensifyNewKansas-Medium.otf"; path = "../assets/fonts/native/ExpensifyNewKansas-Medium.otf"; sourceTree = ""; }; + 47D5DF3C6779D41BE70CD031 /* Pods-NewExpensify.releaseproduction.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-NewExpensify.releaseproduction.xcconfig"; path = "Target Support Files/Pods-NewExpensify/Pods-NewExpensify.releaseproduction.xcconfig"; sourceTree = ""; }; + 4E8BF7B08BA3181991BFCF4B /* Pods-NewExpensify-NewExpensifyTests.releasedevelopment.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-NewExpensify-NewExpensifyTests.releasedevelopment.xcconfig"; path = "Target Support Files/Pods-NewExpensify-NewExpensifyTests/Pods-NewExpensify-NewExpensifyTests.releasedevelopment.xcconfig"; sourceTree = ""; }; 52796131E6554494B2DDB056 /* ExpensifyNeue-Bold.otf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = "ExpensifyNeue-Bold.otf"; path = "../assets/fonts/native/ExpensifyNeue-Bold.otf"; sourceTree = ""; }; + 57DBBEDB9692E096D4BA0141 /* Pods-NewExpensify-NewExpensifyTests.releaseproduction.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-NewExpensify-NewExpensifyTests.releaseproduction.xcconfig"; path = "Target Support Files/Pods-NewExpensify-NewExpensifyTests/Pods-NewExpensify-NewExpensifyTests.releaseproduction.xcconfig"; sourceTree = ""; }; 6B5211DB0EEB46E12DF4AD2D /* Pods-NewExpensify-NewExpensifyTests.release adhoc.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-NewExpensify-NewExpensifyTests.release adhoc.xcconfig"; path = "Target Support Files/Pods-NewExpensify-NewExpensifyTests/Pods-NewExpensify-NewExpensifyTests.release adhoc.xcconfig"; sourceTree = ""; }; 6BE16DA6EFF88513DB1CD47B /* Pods-NewExpensify-NewExpensifyTests.release staging.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-NewExpensify-NewExpensifyTests.release staging.xcconfig"; path = "Target Support Files/Pods-NewExpensify-NewExpensifyTests/Pods-NewExpensify-NewExpensifyTests.release staging.xcconfig"; sourceTree = ""; }; + 6F6A514B4DF07A60EC8355BA /* Pods-NewExpensify.debugadhoc.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-NewExpensify.debugadhoc.xcconfig"; path = "Target Support Files/Pods-NewExpensify/Pods-NewExpensify.debugadhoc.xcconfig"; sourceTree = ""; }; 6FB387B20AE4E6E98858B6AA /* libPods-NewExpensify-NewExpensifyTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-NewExpensify-NewExpensifyTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 7041848326A8E40900E09F4D /* RCTStartupTimer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = RCTStartupTimer.h; path = NewExpensify/RCTStartupTimer.h; sourceTree = ""; }; 7041848426A8E47D00E09F4D /* RCTStartupTimer.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = RCTStartupTimer.m; path = NewExpensify/RCTStartupTimer.m; sourceTree = ""; }; 70CF6E81262E297300711ADC /* BootSplash.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = BootSplash.storyboard; path = NewExpensify/BootSplash.storyboard; sourceTree = ""; }; 75CABB0D0ABB0082FE0EB600 /* Pods-NewExpensify.release staging.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-NewExpensify.release staging.xcconfig"; path = "Target Support Files/Pods-NewExpensify/Pods-NewExpensify.release staging.xcconfig"; sourceTree = ""; }; + 8709DF3C8D91F0FC1581CDD7 /* Pods-NewExpensify-NewExpensifyTests.debugdevelopment.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-NewExpensify-NewExpensifyTests.debugdevelopment.xcconfig"; path = "Target Support Files/Pods-NewExpensify-NewExpensifyTests/Pods-NewExpensify-NewExpensifyTests.debugdevelopment.xcconfig"; sourceTree = ""; }; 8B28D84EF339436DBD42A203 /* ExpensifyNeue-BoldItalic.otf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = "ExpensifyNeue-BoldItalic.otf"; path = "../assets/fonts/native/ExpensifyNeue-BoldItalic.otf"; sourceTree = ""; }; 8D3B36BF88E773E3C1A383FA /* Pods-NewExpensify.debug staging.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-NewExpensify.debug staging.xcconfig"; path = "Target Support Files/Pods-NewExpensify/Pods-NewExpensify.debug staging.xcconfig"; sourceTree = ""; }; 96552D489D9F09B6A5ABD81B /* Pods-NewExpensify-NewExpensifyTests.release production.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-NewExpensify-NewExpensifyTests.release production.xcconfig"; path = "Target Support Files/Pods-NewExpensify-NewExpensifyTests/Pods-NewExpensify-NewExpensifyTests.release production.xcconfig"; sourceTree = ""; }; AEFE6CD54912D427D19133C7 /* libPods-NewExpensify.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-NewExpensify.a"; sourceTree = BUILT_PRODUCTS_DIR; }; BD6E1BA27D6ABE0AC9D70586 /* Pods-NewExpensify-NewExpensifyTests.release development.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-NewExpensify-NewExpensifyTests.release development.xcconfig"; path = "Target Support Files/Pods-NewExpensify-NewExpensifyTests/Pods-NewExpensify-NewExpensifyTests.release development.xcconfig"; sourceTree = ""; }; + BD8828A882E2D6B51362AAC3 /* Pods-NewExpensify.releaseadhoc.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-NewExpensify.releaseadhoc.xcconfig"; path = "Target Support Files/Pods-NewExpensify/Pods-NewExpensify.releaseadhoc.xcconfig"; sourceTree = ""; }; BF6A4C5167244B9FB8E4D4E3 /* ExpensifyNeue-Italic.otf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = "ExpensifyNeue-Italic.otf"; path = "../assets/fonts/native/ExpensifyNeue-Italic.otf"; sourceTree = ""; }; + CE2F84BEE9A6DCC228AF7E42 /* Pods-NewExpensify.debugproduction.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-NewExpensify.debugproduction.xcconfig"; path = "Target Support Files/Pods-NewExpensify/Pods-NewExpensify.debugproduction.xcconfig"; sourceTree = ""; }; CECC4CBB97A55705A33BEA9E /* Pods-NewExpensify.debug development.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-NewExpensify.debug development.xcconfig"; path = "Target Support Files/Pods-NewExpensify/Pods-NewExpensify.debug development.xcconfig"; sourceTree = ""; }; D2AFB39EC1D44BF9B91D3227 /* ExpensifyNewKansas-MediumItalic.otf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = "ExpensifyNewKansas-MediumItalic.otf"; path = "../assets/fonts/native/ExpensifyNewKansas-MediumItalic.otf"; sourceTree = ""; }; DB76E0D5C670190A0997C71E /* Pods-NewExpensify-NewExpensifyTests.debug production.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-NewExpensify-NewExpensifyTests.debug production.xcconfig"; path = "Target Support Files/Pods-NewExpensify-NewExpensifyTests/Pods-NewExpensify-NewExpensifyTests.debug production.xcconfig"; sourceTree = ""; }; DCF33E34FFEC48128CDD41D4 /* ExpensifyMono-Bold.otf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = "ExpensifyMono-Bold.otf"; path = "../assets/fonts/native/ExpensifyMono-Bold.otf"; sourceTree = ""; }; DD7904292792E76D004484B4 /* RCTBootSplash.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RCTBootSplash.h; path = NewExpensify/RCTBootSplash.h; sourceTree = ""; }; DD79042A2792E76D004484B4 /* RCTBootSplash.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = RCTBootSplash.m; path = NewExpensify/RCTBootSplash.m; sourceTree = ""; }; + E2C8555C607612465A7473F8 /* Pods-NewExpensify-NewExpensifyTests.releaseadhoc.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-NewExpensify-NewExpensifyTests.releaseadhoc.xcconfig"; path = "Target Support Files/Pods-NewExpensify-NewExpensifyTests/Pods-NewExpensify-NewExpensifyTests.releaseadhoc.xcconfig"; sourceTree = ""; }; E2F1036F70CBFE39E9352674 /* Pods-NewExpensify-NewExpensifyTests.debug development.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-NewExpensify-NewExpensifyTests.debug development.xcconfig"; path = "Target Support Files/Pods-NewExpensify-NewExpensifyTests/Pods-NewExpensify-NewExpensifyTests.debug development.xcconfig"; sourceTree = ""; }; E704648954784DDFBAADF568 /* ExpensifyMono-Regular.otf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = "ExpensifyMono-Regular.otf"; path = "../assets/fonts/native/ExpensifyMono-Regular.otf"; sourceTree = ""; }; E9DF872C2525201700607FDC /* AirshipConfig.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = AirshipConfig.plist; sourceTree = ""; }; ED297162215061F000B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; }; ED2971642150620600B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS12.0.sdk/System/Library/Frameworks/JavaScriptCore.framework; sourceTree = DEVELOPER_DIR; }; F0C450E92705020500FD2970 /* colors.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; name = colors.json; path = ../colors.json; sourceTree = ""; }; + F15A36A3262EEC3B0CAB8EDF /* Pods-NewExpensify-NewExpensifyTests.debugproduction.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-NewExpensify-NewExpensifyTests.debugproduction.xcconfig"; path = "Target Support Files/Pods-NewExpensify-NewExpensifyTests/Pods-NewExpensify-NewExpensifyTests.debugproduction.xcconfig"; sourceTree = ""; }; F4F8A052A22040339996324B /* ExpensifyNeue-Regular.otf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = "ExpensifyNeue-Regular.otf"; path = "../assets/fonts/native/ExpensifyNeue-Regular.otf"; sourceTree = ""; }; /* End PBXFileReference section */ @@ -112,7 +124,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - E51DC681C7DEE40AEBDDFBFE /* (null) in Frameworks */, + E51DC681C7DEE40AEBDDFBFE /* BuildFile in Frameworks */, 5A464BC8112CDB1DE1E38F1C /* libPods-NewExpensify.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -239,6 +251,18 @@ 6B5211DB0EEB46E12DF4AD2D /* Pods-NewExpensify-NewExpensifyTests.release adhoc.xcconfig */, 6BE16DA6EFF88513DB1CD47B /* Pods-NewExpensify-NewExpensifyTests.release staging.xcconfig */, 96552D489D9F09B6A5ABD81B /* Pods-NewExpensify-NewExpensifyTests.release production.xcconfig */, + 0B627F2A465153FFA6E3A4E0 /* Pods-NewExpensify.debugdevelopment.xcconfig */, + 6F6A514B4DF07A60EC8355BA /* Pods-NewExpensify.debugadhoc.xcconfig */, + CE2F84BEE9A6DCC228AF7E42 /* Pods-NewExpensify.debugproduction.xcconfig */, + 30FFBD291B71222A393D9CC9 /* Pods-NewExpensify.releasedevelopment.xcconfig */, + BD8828A882E2D6B51362AAC3 /* Pods-NewExpensify.releaseadhoc.xcconfig */, + 47D5DF3C6779D41BE70CD031 /* Pods-NewExpensify.releaseproduction.xcconfig */, + 8709DF3C8D91F0FC1581CDD7 /* Pods-NewExpensify-NewExpensifyTests.debugdevelopment.xcconfig */, + 25A4587E168FD67CF890B448 /* Pods-NewExpensify-NewExpensifyTests.debugadhoc.xcconfig */, + F15A36A3262EEC3B0CAB8EDF /* Pods-NewExpensify-NewExpensifyTests.debugproduction.xcconfig */, + 4E8BF7B08BA3181991BFCF4B /* Pods-NewExpensify-NewExpensifyTests.releasedevelopment.xcconfig */, + E2C8555C607612465A7473F8 /* Pods-NewExpensify-NewExpensifyTests.releaseadhoc.xcconfig */, + 57DBBEDB9692E096D4BA0141 /* Pods-NewExpensify-NewExpensifyTests.releaseproduction.xcconfig */, ); path = Pods; sourceTree = ""; @@ -386,29 +410,29 @@ "${PODS_ROOT}/Target Support Files/Pods-NewExpensify/Pods-NewExpensify-frameworks.sh", "${BUILT_PRODUCTS_DIR}/MapboxMaps/MapboxMaps.framework", "${BUILT_PRODUCTS_DIR}/Turf/Turf.framework", + "${PODS_XCFRAMEWORKS_BUILD_DIR}/Flipper-DoubleConversion/double-conversion.framework/double-conversion", + "${PODS_XCFRAMEWORKS_BUILD_DIR}/Flipper-Glog/glog.framework/glog", "${PODS_XCFRAMEWORKS_BUILD_DIR}/MapboxCommon/MapboxCommon.framework/MapboxCommon", "${PODS_XCFRAMEWORKS_BUILD_DIR}/MapboxCoreMaps/MapboxCoreMaps.framework/MapboxCoreMaps", "${PODS_XCFRAMEWORKS_BUILD_DIR}/MapboxMobileEvents/MapboxMobileEvents.framework/MapboxMobileEvents", "${PODS_XCFRAMEWORKS_BUILD_DIR}/Onfido/Onfido.framework/Onfido", + "${PODS_XCFRAMEWORKS_BUILD_DIR}/OpenSSL-Universal/OpenSSL.framework/OpenSSL", "${PODS_XCFRAMEWORKS_BUILD_DIR}/Plaid/LinkKit.framework/LinkKit", "${PODS_XCFRAMEWORKS_BUILD_DIR}/hermes-engine/Pre-built/hermes.framework/hermes", - "${PODS_XCFRAMEWORKS_BUILD_DIR}/Flipper-DoubleConversion/double-conversion.framework/double-conversion", - "${PODS_XCFRAMEWORKS_BUILD_DIR}/Flipper-Glog/glog.framework/glog", - "${PODS_XCFRAMEWORKS_BUILD_DIR}/OpenSSL-Universal/OpenSSL.framework/OpenSSL", ); name = "[CP] Embed Pods Frameworks"; outputPaths = ( "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MapboxMaps.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Turf.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/double-conversion.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/glog.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MapboxCommon.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MapboxCoreMaps.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MapboxMobileEvents.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Onfido.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/OpenSSL.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/LinkKit.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/hermes.framework", - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/double-conversion.framework", - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/glog.framework", - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/OpenSSL.framework", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; @@ -467,29 +491,29 @@ "${PODS_ROOT}/Target Support Files/Pods-NewExpensify-NewExpensifyTests/Pods-NewExpensify-NewExpensifyTests-frameworks.sh", "${BUILT_PRODUCTS_DIR}/MapboxMaps/MapboxMaps.framework", "${BUILT_PRODUCTS_DIR}/Turf/Turf.framework", + "${PODS_XCFRAMEWORKS_BUILD_DIR}/Flipper-DoubleConversion/double-conversion.framework/double-conversion", + "${PODS_XCFRAMEWORKS_BUILD_DIR}/Flipper-Glog/glog.framework/glog", "${PODS_XCFRAMEWORKS_BUILD_DIR}/MapboxCommon/MapboxCommon.framework/MapboxCommon", "${PODS_XCFRAMEWORKS_BUILD_DIR}/MapboxCoreMaps/MapboxCoreMaps.framework/MapboxCoreMaps", "${PODS_XCFRAMEWORKS_BUILD_DIR}/MapboxMobileEvents/MapboxMobileEvents.framework/MapboxMobileEvents", "${PODS_XCFRAMEWORKS_BUILD_DIR}/Onfido/Onfido.framework/Onfido", + "${PODS_XCFRAMEWORKS_BUILD_DIR}/OpenSSL-Universal/OpenSSL.framework/OpenSSL", "${PODS_XCFRAMEWORKS_BUILD_DIR}/Plaid/LinkKit.framework/LinkKit", "${PODS_XCFRAMEWORKS_BUILD_DIR}/hermes-engine/Pre-built/hermes.framework/hermes", - "${PODS_XCFRAMEWORKS_BUILD_DIR}/Flipper-DoubleConversion/double-conversion.framework/double-conversion", - "${PODS_XCFRAMEWORKS_BUILD_DIR}/Flipper-Glog/glog.framework/glog", - "${PODS_XCFRAMEWORKS_BUILD_DIR}/OpenSSL-Universal/OpenSSL.framework/OpenSSL", ); name = "[CP] Embed Pods Frameworks"; outputPaths = ( "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MapboxMaps.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Turf.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/double-conversion.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/glog.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MapboxCommon.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MapboxCoreMaps.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MapboxMobileEvents.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Onfido.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/OpenSSL.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/LinkKit.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/hermes.framework", - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/double-conversion.framework", - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/glog.framework", - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/OpenSSL.framework", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; @@ -643,7 +667,7 @@ /* Begin XCBuildConfiguration section */ 00E356F61AD99517003FC87E /* DebugDevelopment */ = { isa = XCBuildConfiguration; - baseConfigurationReference = E2F1036F70CBFE39E9352674 /* Pods-NewExpensify-NewExpensifyTests.debug development.xcconfig */; + baseConfigurationReference = 8709DF3C8D91F0FC1581CDD7 /* Pods-NewExpensify-NewExpensifyTests.debugdevelopment.xcconfig */; buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; BUNDLE_LOADER = "$(TEST_HOST)"; @@ -668,7 +692,7 @@ }; 00E356F71AD99517003FC87E /* ReleaseDevelopment */ = { isa = XCBuildConfiguration; - baseConfigurationReference = BD6E1BA27D6ABE0AC9D70586 /* Pods-NewExpensify-NewExpensifyTests.release development.xcconfig */; + baseConfigurationReference = 4E8BF7B08BA3181991BFCF4B /* Pods-NewExpensify-NewExpensifyTests.releasedevelopment.xcconfig */; buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; BUNDLE_LOADER = "$(TEST_HOST)"; @@ -691,7 +715,7 @@ }; 13B07F941A680F5B00A75B9A /* DebugDevelopment */ = { isa = XCBuildConfiguration; - baseConfigurationReference = CECC4CBB97A55705A33BEA9E /* Pods-NewExpensify.debug development.xcconfig */; + baseConfigurationReference = 0B627F2A465153FFA6E3A4E0 /* Pods-NewExpensify.debugdevelopment.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIconDev; ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = NO; @@ -723,7 +747,7 @@ }; 13B07F951A680F5B00A75B9A /* ReleaseDevelopment */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 02BE6CF80ED1BD2445267F92 /* Pods-NewExpensify.release development.xcconfig */; + baseConfigurationReference = 30FFBD291B71222A393D9CC9 /* Pods-NewExpensify.releasedevelopment.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIconDev; ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = NO; @@ -942,7 +966,7 @@ }; CF9AF93F29EE9276001FA527 /* DebugProduction */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 0E27AA27706D894246E7946D /* Pods-NewExpensify.debug production.xcconfig */; + baseConfigurationReference = CE2F84BEE9A6DCC228AF7E42 /* Pods-NewExpensify.debugproduction.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = NO; @@ -974,7 +998,7 @@ }; CF9AF94029EE9276001FA527 /* DebugProduction */ = { isa = XCBuildConfiguration; - baseConfigurationReference = DB76E0D5C670190A0997C71E /* Pods-NewExpensify-NewExpensifyTests.debug production.xcconfig */; + baseConfigurationReference = F15A36A3262EEC3B0CAB8EDF /* Pods-NewExpensify-NewExpensifyTests.debugproduction.xcconfig */; buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; BUNDLE_LOADER = "$(TEST_HOST)"; @@ -1064,7 +1088,7 @@ }; CF9AF94529EE927A001FA527 /* DebugAdHoc */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 0B09CE5BDAF34DD3573AB4E2 /* Pods-NewExpensify.debug adhoc.xcconfig */; + baseConfigurationReference = 6F6A514B4DF07A60EC8355BA /* Pods-NewExpensify.debugadhoc.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIconAdHoc; ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = NO; @@ -1096,7 +1120,7 @@ }; CF9AF94629EE927A001FA527 /* DebugAdHoc */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 432FF5842B766535509FC547 /* Pods-NewExpensify-NewExpensifyTests.debug adhoc.xcconfig */; + baseConfigurationReference = 25A4587E168FD67CF890B448 /* Pods-NewExpensify-NewExpensifyTests.debugadhoc.xcconfig */; buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; BUNDLE_LOADER = "$(TEST_HOST)"; @@ -1180,7 +1204,7 @@ }; CF9AF94829EE928E001FA527 /* ReleaseProduction */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 34A8FDD1F9AA58B8F15C8380 /* Pods-NewExpensify.release production.xcconfig */; + baseConfigurationReference = 47D5DF3C6779D41BE70CD031 /* Pods-NewExpensify.releaseproduction.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = NO; @@ -1210,7 +1234,7 @@ }; CF9AF94929EE928E001FA527 /* ReleaseProduction */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 96552D489D9F09B6A5ABD81B /* Pods-NewExpensify-NewExpensifyTests.release production.xcconfig */; + baseConfigurationReference = 57DBBEDB9692E096D4BA0141 /* Pods-NewExpensify-NewExpensifyTests.releaseproduction.xcconfig */; buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; BUNDLE_LOADER = "$(TEST_HOST)"; @@ -1292,7 +1316,7 @@ }; CF9AF94E29EE9293001FA527 /* ReleaseAdHoc */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 1DDE5449979A136852B939B5 /* Pods-NewExpensify.release adhoc.xcconfig */; + baseConfigurationReference = BD8828A882E2D6B51362AAC3 /* Pods-NewExpensify.releaseadhoc.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIconAdHoc; ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = NO; @@ -1322,7 +1346,7 @@ }; CF9AF94F29EE9293001FA527 /* ReleaseAdHoc */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 6B5211DB0EEB46E12DF4AD2D /* Pods-NewExpensify-NewExpensifyTests.release adhoc.xcconfig */; + baseConfigurationReference = E2C8555C607612465A7473F8 /* Pods-NewExpensify-NewExpensifyTests.releaseadhoc.xcconfig */; buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; BUNDLE_LOADER = "$(TEST_HOST)"; diff --git a/ios/Podfile.lock b/ios/Podfile.lock index aeb1887223cd..0897692d3ef6 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -591,7 +591,7 @@ PODS: - React-Core - react-native-pager-view (6.2.0): - React-Core - - react-native-pdf (6.7.1): + - react-native-pdf (6.6.2): - React-Core - react-native-performance (4.0.0): - React-Core @@ -1254,7 +1254,7 @@ SPEC CHECKSUMS: react-native-key-command: c2645ec01eb1fa664606c09480c05cb4220ef67b react-native-netinfo: ccbe1085dffd16592791d550189772e13bf479e2 react-native-pager-view: 0ccb8bf60e2ebd38b1f3669fa3650ecce81db2df - react-native-pdf: 7c0e91ada997bac8bac3bb5bea5b6b81f5a3caae + react-native-pdf: 33c622cbdf776a649929e8b9d1ce2d313347c4fa react-native-performance: 224bd53e6a835fda4353302cf891d088a0af7406 react-native-plaid-link-sdk: 9eb0f71dad94b3bdde649c7a384cba93024af46c react-native-quick-sqlite: bcc7a7a250a40222f18913a97cd356bf82d0a6c4 From 6fbfec70ef5dae0f715cfcdc3d939c7877c89210 Mon Sep 17 00:00:00 2001 From: Artem Makushov Date: Tue, 29 Aug 2023 21:33:00 +0200 Subject: [PATCH 182/284] datetime polyfill, remove moment.tz.guess() --- package-lock.json | 57 +++++++++++++++++++ package.json | 1 + src/libs/IntlPolyfill/index.js | 1 + src/libs/IntlPolyfill/index.native.js | 1 + .../Navigation/AppNavigator/AuthScreens.js | 2 +- src/libs/actions/App.js | 2 +- .../settings/Profile/TimezoneInitialPage.js | 2 +- 7 files changed, 63 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index ea0cb56b1ceb..5c53db0713b0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,6 +11,7 @@ "license": "MIT", "dependencies": { "@expensify/react-native-web": "0.18.15", + "@formatjs/intl-datetimeformat": "^6.10.0", "@formatjs/intl-getcanonicallocales": "^2.2.0", "@formatjs/intl-listformat": "^7.2.2", "@formatjs/intl-locale": "^3.3.0", @@ -3872,6 +3873,33 @@ "tslib": "^2.4.0" } }, + "node_modules/@formatjs/intl-datetimeformat": { + "version": "6.10.0", + "resolved": "https://registry.npmjs.org/@formatjs/intl-datetimeformat/-/intl-datetimeformat-6.10.0.tgz", + "integrity": "sha512-5tJWZxOyP5D4PDrqv27h0LWAPHhQM9BHR0pDBTZOKWFEZNrS2IgREbyalSGwQLtN1tZaDrt3YeNfNLbZk1wSUw==", + "dependencies": { + "@formatjs/ecma402-abstract": "1.17.0", + "@formatjs/intl-localematcher": "0.4.0", + "tslib": "^2.4.0" + } + }, + "node_modules/@formatjs/intl-datetimeformat/node_modules/@formatjs/ecma402-abstract": { + "version": "1.17.0", + "resolved": "https://registry.npmjs.org/@formatjs/ecma402-abstract/-/ecma402-abstract-1.17.0.tgz", + "integrity": "sha512-6ueQTeJZtwKjmh23bdkq/DMqH4l4bmfvtQH98blOSbiXv/OUiyijSW6jU22IT8BNM1ujCaEvJfTtyCYVH38EMQ==", + "dependencies": { + "@formatjs/intl-localematcher": "0.4.0", + "tslib": "^2.4.0" + } + }, + "node_modules/@formatjs/intl-datetimeformat/node_modules/@formatjs/intl-localematcher": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/@formatjs/intl-localematcher/-/intl-localematcher-0.4.0.tgz", + "integrity": "sha512-bRTd+rKomvfdS4QDlVJ6TA/Jx1F2h/TBVO5LjvhQ7QPPHp19oPNMIum7W2CMEReq/zPxpmCeB31F9+5gl/qtvw==", + "dependencies": { + "tslib": "^2.4.0" + } + }, "node_modules/@formatjs/intl-enumerator": { "version": "1.3.0", "license": "MIT", @@ -50880,6 +50908,35 @@ "tslib": "^2.4.0" } }, + "@formatjs/intl-datetimeformat": { + "version": "6.10.0", + "resolved": "https://registry.npmjs.org/@formatjs/intl-datetimeformat/-/intl-datetimeformat-6.10.0.tgz", + "integrity": "sha512-5tJWZxOyP5D4PDrqv27h0LWAPHhQM9BHR0pDBTZOKWFEZNrS2IgREbyalSGwQLtN1tZaDrt3YeNfNLbZk1wSUw==", + "requires": { + "@formatjs/ecma402-abstract": "1.17.0", + "@formatjs/intl-localematcher": "0.4.0", + "tslib": "^2.4.0" + }, + "dependencies": { + "@formatjs/ecma402-abstract": { + "version": "1.17.0", + "resolved": "https://registry.npmjs.org/@formatjs/ecma402-abstract/-/ecma402-abstract-1.17.0.tgz", + "integrity": "sha512-6ueQTeJZtwKjmh23bdkq/DMqH4l4bmfvtQH98blOSbiXv/OUiyijSW6jU22IT8BNM1ujCaEvJfTtyCYVH38EMQ==", + "requires": { + "@formatjs/intl-localematcher": "0.4.0", + "tslib": "^2.4.0" + } + }, + "@formatjs/intl-localematcher": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/@formatjs/intl-localematcher/-/intl-localematcher-0.4.0.tgz", + "integrity": "sha512-bRTd+rKomvfdS4QDlVJ6TA/Jx1F2h/TBVO5LjvhQ7QPPHp19oPNMIum7W2CMEReq/zPxpmCeB31F9+5gl/qtvw==", + "requires": { + "tslib": "^2.4.0" + } + } + } + }, "@formatjs/intl-enumerator": { "version": "1.3.0", "requires": { diff --git a/package.json b/package.json index d4e0a7b856dd..abdad2ca9e75 100644 --- a/package.json +++ b/package.json @@ -51,6 +51,7 @@ }, "dependencies": { "@expensify/react-native-web": "0.18.15", + "@formatjs/intl-datetimeformat": "^6.10.0", "@formatjs/intl-getcanonicallocales": "^2.2.0", "@formatjs/intl-listformat": "^7.2.2", "@formatjs/intl-locale": "^3.3.0", diff --git a/src/libs/IntlPolyfill/index.js b/src/libs/IntlPolyfill/index.js index 3925b98729a9..a99fc4cfed44 100644 --- a/src/libs/IntlPolyfill/index.js +++ b/src/libs/IntlPolyfill/index.js @@ -7,4 +7,5 @@ import polyfillNumberFormat from './polyfillNumberFormat'; export default function intlPolyfill() { // Just need to polyfill Intl.NumberFormat for web based platforms polyfillNumberFormat(); + require('@formatjs/intl-datetimeformat'); } diff --git a/src/libs/IntlPolyfill/index.native.js b/src/libs/IntlPolyfill/index.native.js index a628654fefea..4fb5ca585e25 100644 --- a/src/libs/IntlPolyfill/index.native.js +++ b/src/libs/IntlPolyfill/index.native.js @@ -9,6 +9,7 @@ export default function polyfill() { require('@formatjs/intl-getcanonicallocales/polyfill'); require('@formatjs/intl-locale/polyfill'); require('@formatjs/intl-pluralrules/polyfill'); + require('@formatjs/intl-datetimeformat'); polyfillNumberFormat(); polyfillListFormat(); } diff --git a/src/libs/Navigation/AppNavigator/AuthScreens.js b/src/libs/Navigation/AppNavigator/AuthScreens.js index 7317306cdbe6..96285f1aab74 100644 --- a/src/libs/Navigation/AppNavigator/AuthScreens.js +++ b/src/libs/Navigation/AppNavigator/AuthScreens.js @@ -64,7 +64,7 @@ Onyx.connect({ } timezone = lodashGet(val, [currentAccountID, 'timezone'], {}); - const currentTimezone = moment.tz.guess(true); + const currentTimezone = Intl.DateTimeFormat().resolvedOptions().timeZone; // If the current timezone is different than the user's timezone, and their timezone is set to automatic // then update their timezone. diff --git a/src/libs/actions/App.js b/src/libs/actions/App.js index 46d21d50cc3e..468e735437d2 100644 --- a/src/libs/actions/App.js +++ b/src/libs/actions/App.js @@ -399,7 +399,7 @@ function openProfile(personalDetails) { if (lodashGet(oldTimezoneData, 'automatic', true)) { newTimezoneData = { automatic: true, - selected: moment.tz.guess(true), + selected: Intl.DateTimeFormat().resolvedOptions().timeZone, }; } diff --git a/src/pages/settings/Profile/TimezoneInitialPage.js b/src/pages/settings/Profile/TimezoneInitialPage.js index 7dfc9fb6f9de..6bfe04982f3d 100644 --- a/src/pages/settings/Profile/TimezoneInitialPage.js +++ b/src/pages/settings/Profile/TimezoneInitialPage.js @@ -37,7 +37,7 @@ function TimezoneInitialPage(props) { const updateAutomaticTimezone = (isAutomatic) => { PersonalDetails.updateAutomaticTimezone({ automatic: isAutomatic, - selected: isAutomatic ? moment.tz.guess() : timezone.selected, + selected: isAutomatic ? Intl.DateTimeFormat().resolvedOptions().timeZone : timezone.selected, }); }; From ffcd370b591df6221726cc6ebfcc1cbae3b870f6 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Wed, 30 Aug 2023 08:25:30 +0200 Subject: [PATCH 183/284] Update .eslintrc.js Added `tests` and `.github` dirs to the overrides removing check for `no-async-await` See: https://github.com/Expensify/App/issues/13604 --- .eslintrc.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.eslintrc.js b/.eslintrc.js index 449eca32c05e..7f8bc4a35fc6 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -164,7 +164,11 @@ module.exports = { }, }, { - files: ['workflow_tests/**/*.js'], + files: [ + 'workflow_tests/**/*.{js,jsx,ts,tsx}', + 'tests/**/*.{js,jsx,ts,tsx}', + '.github/**/*.{js,jsx,ts,tsx}' + ], rules: { '@lwc/lwc/no-async-await': 'off', }, From a995ca83040f1e5c256decfad799e05f193d8c5a Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Wed, 30 Aug 2023 08:50:30 +0200 Subject: [PATCH 184/284] Merge from upstream Updated tests after merge 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 | 8 ++++---- workflow_tests/mocks/testBuildMocks.js | 8 ++++---- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/workflow_tests/assertions/platformDeployAssertions.js b/workflow_tests/assertions/platformDeployAssertions.js index 25460348e4af..bf20cb7687c9 100644 --- a/workflow_tests/assertions/platformDeployAssertions.js +++ b/workflow_tests/assertions/platformDeployAssertions.js @@ -15,6 +15,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'), + utils.createStepAssertion('Configure MapBox SDK', true, null, 'ANDROID', 'Configure MapBox SDK'), 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'}, @@ -124,12 +125,12 @@ 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'), + utils.createStepAssertion('Configure MapBox SDK', true, null, 'IOS', 'Configure MapBox SDK'), 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('Setup credentails for Mapbox SDK', true, null, 'IOS', 'Setup credentials for Mapbox SDK'), utils.createStepAssertion('Install cocoapods', true, null, 'IOS', 'Installing cocoapods', [ {key: 'timeout_minutes', value: '10'}, {key: 'max_attempts', value: '5'}, @@ -205,7 +206,6 @@ const assertWebJobExecuted = (workflowResult, didExecute = true, isProduction = {key: 'AWS_ACCESS_KEY_ID', value: '***'}, {key: 'AWS_SECRET_ACCESS_KEY', value: '***'}, ]), - utils.createStepAssertion('Setup credentails for Mapbox SDK', true, null, 'WEB', 'Setup credentials for Mapbox SDK'), ]; if (isProduction) { steps.push( diff --git a/workflow_tests/assertions/testBuildAssertions.js b/workflow_tests/assertions/testBuildAssertions.js index 479d8aebdfbe..4ff9e2be40c7 100644 --- a/workflow_tests/assertions/testBuildAssertions.js +++ b/workflow_tests/assertions/testBuildAssertions.js @@ -86,7 +86,7 @@ const assertAndroidJobExecuted = (workflowResult, ref = '', didExecute = true, f ], [], ), - utils.createStepAssertion('Setup credentails for Mapbox SDK', true, null, 'ANDROID', 'Setup credentials for Mapbox SDK'), + utils.createStepAssertion('Configure MapBox SDK', true, null, 'ANDROID', 'Configure MapBox SDK'), utils.createStepAssertion( 'Run Fastlane beta test', true, @@ -138,6 +138,7 @@ 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('Configure MapBox SDK', true, null, 'IOS', 'Configure MapBox SDK'), 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', [], []), @@ -153,7 +154,6 @@ const assertIOSJobExecuted = (workflowResult, ref = '', didExecute = true, fails ], [], ), - utils.createStepAssertion('Setup credentails for Mapbox SDK', true, null, 'IOS', 'Setup credentials for Mapbox SDK'), utils.createStepAssertion( 'Install cocoapods', true, diff --git a/workflow_tests/mocks/platformDeployMocks.js b/workflow_tests/mocks/platformDeployMocks.js index 2e774eb6f2bc..358dccf79028 100644 --- a/workflow_tests/mocks/platformDeployMocks.js +++ b/workflow_tests/mocks/platformDeployMocks.js @@ -22,6 +22,7 @@ const PLATFORM_DEPLOY__VALIDATE_ACTOR__OUTSIDER__STEP_MOCKS = [PLATFORM_DEPLOY__ // android const PLATFORM_DEPLOY__ANDROID__CHECKOUT__STEP_MOCK = utils.createMockStep('Checkout', 'Checking out', 'ANDROID'); +const PLATFORM_DEPLOY__ANDROID__CONFIGURE_MAPBOX_SDK__STEP_MOCK = utils.createMockStep('Configure MapBox SDK', 'Configure MapBox SDK', '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']); @@ -49,6 +50,7 @@ const PLATFORM_DEPLOY__ANDROID__WARN_DEPLOYERS__STEP_MOCK = utils.createMockStep ); const PLATFORM_DEPLOY__ANDROID__STEP_MOCKS = [ PLATFORM_DEPLOY__ANDROID__CHECKOUT__STEP_MOCK, + PLATFORM_DEPLOY__ANDROID__CONFIGURE_MAPBOX_SDK__STEP_MOCK, PLATFORM_DEPLOY__ANDROID__SETUP_NODE__STEP_MOCK, PLATFORM_DEPLOY__ANDROID__SETUP_RUBY__STEP_MOCK, PLATFORM_DEPLOY__ANDROID__DECRYPT_KEYSTORE__STEP_MOCK, @@ -93,9 +95,9 @@ const PLATFORM_DEPLOY__DESKTOP__STEP_MOCKS = [ // ios const PLATFORM_DEPLOY__IOS__CHECKOUT__STEP_MOCK = utils.createMockStep('Checkout', 'Checking out', 'IOS'); +const PLATFORM_DEPLOY__IOS__CONFIGURE_MAPBOX_SDK__STEP_MOCK = utils.createMockStep('Configure MapBox SDK', 'Configure MapBox SDK', '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__SETUP_CREDENTIALS_FOR_MAPBOX_SDK__STEP_MOCK = utils.createMockStep('Setup credentails for Mapbox SDK', 'Setup credentials for Mapbox SDK', 'IOS'); 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']); @@ -121,9 +123,9 @@ const PLATFORM_DEPLOY__IOS__WARN_FAIL__STEP_MOCK = utils.createMockStep( ); const PLATFORM_DEPLOY__IOS__STEP_MOCKS = [ PLATFORM_DEPLOY__IOS__CHECKOUT__STEP_MOCK, + PLATFORM_DEPLOY__IOS__CONFIGURE_MAPBOX_SDK__STEP_MOCK, PLATFORM_DEPLOY__IOS__SETUP_NODE__STEP_MOCK, PLATFORM_DEPLOY__IOS__SETUP_RUBY__STEP_MOCK, - PLATFORM_DEPLOY__IOS__SETUP_CREDENTIALS_FOR_MAPBOX_SDK__STEP_MOCK, PLATFORM_DEPLOY__IOS__COCOAPODS__STEP_MOCK, PLATFORM_DEPLOY__IOS__DECRYPT_PROFILE__STEP_MOCK, PLATFORM_DEPLOY__IOS__DECRYPT_CERTIFICATE__STEP_MOCK, @@ -144,7 +146,6 @@ const PLATFORM_DEPLOY__WEB__AWS_CREDENTIALS__STEP_MOCK = utils.createMockStep('C 'AWS_ACCESS_KEY_ID', 'AWS_SECRET_ACCESS_KEY', ]); -const PLATFORM_DEPLOY__WEB__SETUP_CREDENTIALS_FOR_MAPBOX_SDK__STEP_MOCK = utils.createMockStep('Setup credentails for Mapbox SDK', 'Setup credentials for Mapbox SDK', 'WEB'); 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_STORYBOOK_DOCS_FOR_PRODUCTION__STEP_MOCK = utils.createMockStep('Build storybook docs for production', 'Build storybook docs for production', 'WEB'); @@ -158,7 +159,6 @@ const PLATFORM_DEPLOY__WEB__STEP_MOCKS = [ PLATFORM_DEPLOY__WEB__SETUP_NODE__STEP_MOCK, PLATFORM_DEPLOY__WEB__CLOUDFLARE__STEP_MOCK, PLATFORM_DEPLOY__WEB__AWS_CREDENTIALS__STEP_MOCK, - PLATFORM_DEPLOY__WEB__SETUP_CREDENTIALS_FOR_MAPBOX_SDK__STEP_MOCK, PLATFORM_DEPLOY__WEB__BUILD_PRODUCTION__STEP_MOCK, PLATFORM_DEPLOY__WEB__BUILD_STAGING__STEP_MOCK, PLATFORM_DEPLOY__WEB__BUILD_STORYBOOK_DOCS_FOR_PRODUCTION__STEP_MOCK, diff --git a/workflow_tests/mocks/testBuildMocks.js b/workflow_tests/mocks/testBuildMocks.js index e2838fb00932..1faa1fb38e9d 100644 --- a/workflow_tests/mocks/testBuildMocks.js +++ b/workflow_tests/mocks/testBuildMocks.js @@ -72,7 +72,7 @@ const TESTBUILD__ANDROID__CONFIGURE_AWS_CREDENTIALS__STEP_MOCK = utils.createMoc ['AWS_ACCESS_KEY_ID', 'AWS_SECRET_ACCESS_KEY'], [], ); -const TESTBUILD__ANDROID__SETUP_CREDENTIALS_FOR_MAPBOX_SDK__STEP_MOCK = utils.createMockStep('Setup credentails for Mapbox SDK', 'Setup credentials for Mapbox SDK', 'ANDROID'); +const TESTBUILD__ANDROID__CONFIGURE_MAPBOX_SDK__STEP_MOCK = utils.createMockStep('Configure MapBox SDK', 'Configure MapBox SDK', 'ANDROID'); const TESTBUILD__ANDROID__RUN_FASTLANE_BETA_TEST__STEP_MOCK = utils.createMockStep( 'Run Fastlane beta test', 'Run Fastlane beta test', @@ -89,13 +89,14 @@ const TESTBUILD__ANDROID__STEP_MOCKS = [ TESTBUILD__ANDROID__DECRYPT_KEYSTORE__STEP_MOCK, TESTBUILD__ANDROID__DECRYPT_JSON_KEY__STEP_MOCK, TESTBUILD__ANDROID__CONFIGURE_AWS_CREDENTIALS__STEP_MOCK, - TESTBUILD__ANDROID__SETUP_CREDENTIALS_FOR_MAPBOX_SDK__STEP_MOCK, + TESTBUILD__ANDROID__CONFIGURE_MAPBOX_SDK__STEP_MOCK, TESTBUILD__ANDROID__RUN_FASTLANE_BETA_TEST__STEP_MOCK, TESTBUILD__ANDROID__UPLOAD_ARTIFACT__STEP_MOCK, ]; // ios const TESTBUILD__IOS__CHECKOUT__STEP_MOCK = utils.createMockStep('Checkout', 'Checkout', 'IOS', ['ref'], []); +const TESTBUILD__IOS__CONFIGURE_MAPBOX_SDK__STEP_MOCK = utils.createMockStep('Configure MapBox SDK', 'Configure MapBox SDK', 'IOS'); 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', @@ -106,7 +107,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_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__SETUP_CREDENTIALS_FOR_MAPBOX_SDK__STEP_MOCK = utils.createMockStep('Setup credentails for Mapbox SDK', 'Setup credentials for Mapbox SDK', 'IOS'); 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,11 +121,11 @@ const TESTBUILD__IOS__RUN_FASTLANE__STEP_MOCK = utils.createMockStep('Run Fastla 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__CONFIGURE_MAPBOX_SDK__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__SETUP_CREDENTIALS_FOR_MAPBOX_SDK__STEP_MOCK, TESTBUILD__IOS__INSTALL_COCOAPODS__STEP_MOCK, TESTBUILD__IOS__DECRYPT_PROFILE__STEP_MOCK, TESTBUILD__IOS__DECRYPT_CERTIFICATE__STEP_MOCK, From 1a40aa1bd278bfbc0622d5e1c57ad6a9c7d555a4 Mon Sep 17 00:00:00 2001 From: Artem Makushov Date: Wed, 30 Aug 2023 12:56:44 +0200 Subject: [PATCH 185/284] lint fix --- src/libs/Navigation/AppNavigator/AuthScreens.js | 1 - src/libs/actions/App.js | 1 - src/pages/settings/Profile/TimezoneInitialPage.js | 1 - 3 files changed, 3 deletions(-) diff --git a/src/libs/Navigation/AppNavigator/AuthScreens.js b/src/libs/Navigation/AppNavigator/AuthScreens.js index 96285f1aab74..a4c62d9893ea 100644 --- a/src/libs/Navigation/AppNavigator/AuthScreens.js +++ b/src/libs/Navigation/AppNavigator/AuthScreens.js @@ -1,7 +1,6 @@ import React from 'react'; import Onyx, {withOnyx} from 'react-native-onyx'; import PropTypes from 'prop-types'; -import moment from 'moment'; import _ from 'underscore'; import lodashGet from 'lodash/get'; import withWindowDimensions, {windowDimensionsPropTypes} from '../../../components/withWindowDimensions'; diff --git a/src/libs/actions/App.js b/src/libs/actions/App.js index 468e735437d2..18593603780c 100644 --- a/src/libs/actions/App.js +++ b/src/libs/actions/App.js @@ -1,4 +1,3 @@ -import moment from 'moment-timezone'; import {AppState} from 'react-native'; import Onyx from 'react-native-onyx'; import lodashGet from 'lodash/get'; diff --git a/src/pages/settings/Profile/TimezoneInitialPage.js b/src/pages/settings/Profile/TimezoneInitialPage.js index 6bfe04982f3d..94cb40a3f6f3 100644 --- a/src/pages/settings/Profile/TimezoneInitialPage.js +++ b/src/pages/settings/Profile/TimezoneInitialPage.js @@ -1,7 +1,6 @@ import lodashGet from 'lodash/get'; import React from 'react'; import {View} from 'react-native'; -import moment from 'moment-timezone'; import withCurrentUserPersonalDetails, {withCurrentUserPersonalDetailsPropTypes, withCurrentUserPersonalDetailsDefaultProps} from '../../../components/withCurrentUserPersonalDetails'; import ScreenWrapper from '../../../components/ScreenWrapper'; import HeaderWithBackButton from '../../../components/HeaderWithBackButton'; From 5c67b87bafef168a37be90a81dcf1acad0e5f325 Mon Sep 17 00:00:00 2001 From: Thiago Brezinski Date: Wed, 30 Aug 2023 12:26:56 +0100 Subject: [PATCH 186/284] refactor(selection-list): rename CheckboxListItem to UserListItem --- src/components/SelectionList/BaseSelectionList.js | 4 ++-- .../{CheckboxListItem.js => UserListItem.js} | 10 +++++----- src/components/SelectionList/selectionListPropTypes.js | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) rename src/components/SelectionList/{CheckboxListItem.js => UserListItem.js} (92%) diff --git a/src/components/SelectionList/BaseSelectionList.js b/src/components/SelectionList/BaseSelectionList.js index 1842abfe732a..81d486b38b7e 100644 --- a/src/components/SelectionList/BaseSelectionList.js +++ b/src/components/SelectionList/BaseSelectionList.js @@ -11,7 +11,7 @@ import CONST from '../../CONST'; import variables from '../../styles/variables'; import {propTypes as selectionListPropTypes} from './selectionListPropTypes'; import RadioListItem from './RadioListItem'; -import CheckboxListItem from './CheckboxListItem'; +import UserListItem from './UserListItem'; import useKeyboardShortcut from '../../hooks/useKeyboardShortcut'; import SafeAreaConsumer from '../SafeAreaConsumer'; import withKeyboardState, {keyboardStatePropTypes} from '../withKeyboardState'; @@ -250,7 +250,7 @@ function BaseSelectionList({ if (canSelectMultiple) { return ( - selectRow(item, index)} diff --git a/src/components/SelectionList/CheckboxListItem.js b/src/components/SelectionList/UserListItem.js similarity index 92% rename from src/components/SelectionList/CheckboxListItem.js rename to src/components/SelectionList/UserListItem.js index 694e03bae632..0b3c05d6b752 100644 --- a/src/components/SelectionList/CheckboxListItem.js +++ b/src/components/SelectionList/UserListItem.js @@ -5,7 +5,7 @@ import lodashGet from 'lodash/get'; import PressableWithFeedback from '../Pressable/PressableWithFeedback'; import styles from '../../styles/styles'; import Text from '../Text'; -import {checkboxListItemPropTypes} from './selectionListPropTypes'; +import {userListItemPropTypes} from './selectionListPropTypes'; import Avatar from '../Avatar'; import OfflineWithFeedback from '../OfflineWithFeedback'; import CONST from '../../CONST'; @@ -16,7 +16,7 @@ import themeColors from '../../styles/themes/default'; import Tooltip from '../Tooltip'; import UserDetailsTooltip from '../UserDetailsTooltip'; -function CheckboxListItem({item, isFocused = false, showTooltip = false, onSelectRow, onDismissError = () => {}}) { +function UserListItem({item, isFocused = false, showTooltip = false, onSelectRow, onDismissError = () => {}}) { const hasError = !_.isEmpty(item.errors); const avatar = ( @@ -103,7 +103,7 @@ function CheckboxListItem({item, isFocused = false, showTooltip = false, onSelec ); } -CheckboxListItem.displayName = 'CheckboxListItem'; -CheckboxListItem.propTypes = checkboxListItemPropTypes; +UserListItem.displayName = 'UserListItem'; +UserListItem.propTypes = userListItemPropTypes; -export default CheckboxListItem; +export default UserListItem; diff --git a/src/components/SelectionList/selectionListPropTypes.js b/src/components/SelectionList/selectionListPropTypes.js index c398050a6eae..9946e3bfcc35 100644 --- a/src/components/SelectionList/selectionListPropTypes.js +++ b/src/components/SelectionList/selectionListPropTypes.js @@ -2,7 +2,7 @@ import PropTypes from 'prop-types'; import _ from 'underscore'; import CONST from '../../CONST'; -const checkboxListItemPropTypes = { +const userListItemPropTypes = { /** The section list item */ item: PropTypes.shape({ /** Text to display */ @@ -93,7 +93,7 @@ const propTypes = { indexOffset: PropTypes.number, /** Array of options */ - data: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.shape(checkboxListItemPropTypes.item), PropTypes.shape(radioListItemPropTypes.item)])), + data: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.shape(userListItemPropTypes.item), PropTypes.shape(radioListItemPropTypes.item)])), /** Whether this section items disabled for selection */ isDisabled: PropTypes.bool, @@ -161,4 +161,4 @@ const propTypes = { showConfirmButton: PropTypes.bool, }; -export {propTypes, radioListItemPropTypes, checkboxListItemPropTypes}; +export {propTypes, radioListItemPropTypes, userListItemPropTypes}; From 0b2d4b473c175edb2739f64dcc9555c1a589b938 Mon Sep 17 00:00:00 2001 From: Thiago Brezinski Date: Wed, 30 Aug 2023 19:36:29 +0100 Subject: [PATCH 187/284] fix(selection-list): make showTooltip required --- src/components/SelectionList/BaseSelectionList.js | 1 - src/components/SelectionList/UserListItem.js | 2 +- src/components/SelectionList/selectionListPropTypes.js | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/components/SelectionList/BaseSelectionList.js b/src/components/SelectionList/BaseSelectionList.js index 81d486b38b7e..d5cd96b9b029 100644 --- a/src/components/SelectionList/BaseSelectionList.js +++ b/src/components/SelectionList/BaseSelectionList.js @@ -266,7 +266,6 @@ function BaseSelectionList({ isFocused={isFocused} isDisabled={isDisabled} onSelectRow={() => selectRow(item, index)} - showTooltip={showTooltip} /> ); }; diff --git a/src/components/SelectionList/UserListItem.js b/src/components/SelectionList/UserListItem.js index 0b3c05d6b752..dd90fc750510 100644 --- a/src/components/SelectionList/UserListItem.js +++ b/src/components/SelectionList/UserListItem.js @@ -16,7 +16,7 @@ import themeColors from '../../styles/themes/default'; import Tooltip from '../Tooltip'; import UserDetailsTooltip from '../UserDetailsTooltip'; -function UserListItem({item, isFocused = false, showTooltip = false, onSelectRow, onDismissError = () => {}}) { +function UserListItem({item, isFocused = false, showTooltip, onSelectRow, onDismissError = () => {}}) { const hasError = !_.isEmpty(item.errors); const avatar = ( diff --git a/src/components/SelectionList/selectionListPropTypes.js b/src/components/SelectionList/selectionListPropTypes.js index 9946e3bfcc35..501de8314934 100644 --- a/src/components/SelectionList/selectionListPropTypes.js +++ b/src/components/SelectionList/selectionListPropTypes.js @@ -47,7 +47,7 @@ const userListItemPropTypes = { isFocused: PropTypes.bool, /** Whether this item should show Tooltip */ - showTooltip: PropTypes.bool, + showTooltip: PropTypes.bool.isRequired, /** Callback to fire when the item is pressed */ onSelectRow: PropTypes.func.isRequired, From 1a1bb0445b150d58cc4020bcdc9ce36905b12485 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Thu, 31 Aug 2023 11:40:55 +0200 Subject: [PATCH 188/284] Run prettier Run prettier See: https://github.com/Expensify/App/issues/13604 --- .eslintrc.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 7f8bc4a35fc6..14529a393c8e 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -164,11 +164,7 @@ module.exports = { }, }, { - files: [ - 'workflow_tests/**/*.{js,jsx,ts,tsx}', - 'tests/**/*.{js,jsx,ts,tsx}', - '.github/**/*.{js,jsx,ts,tsx}' - ], + files: ['workflow_tests/**/*.{js,jsx,ts,tsx}', 'tests/**/*.{js,jsx,ts,tsx}', '.github/**/*.{js,jsx,ts,tsx}'], rules: { '@lwc/lwc/no-async-await': 'off', }, From d7a4e0bee2b2964e94cb36caeade1431394feb5e Mon Sep 17 00:00:00 2001 From: Nathalie Kuoch Date: Thu, 31 Aug 2023 14:29:47 +0200 Subject: [PATCH 189/284] Restrict Plaid link on Native too --- src/components/PlaidLink/index.native.js | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/components/PlaidLink/index.native.js b/src/components/PlaidLink/index.native.js index cd17453820cf..48cd41e283c3 100644 --- a/src/components/PlaidLink/index.native.js +++ b/src/components/PlaidLink/index.native.js @@ -1,16 +1,13 @@ import {useEffect} from 'react'; import {openLink, useDeepLinkRedirector, usePlaidEmitter} from 'react-native-plaid-link-sdk'; import Log from '../../libs/Log'; -import CONST from '../../CONST'; import {plaidLinkPropTypes, plaidLinkDefaultProps} from './plaidLinkPropTypes'; function PlaidLink(props) { useDeepLinkRedirector(); usePlaidEmitter((event) => { Log.info('[PlaidLink] Handled Plaid Event: ', false, event); - if (event.eventName === CONST.PLAID.EVENT.ERROR) { - props.onError(event.metadata); - } + props.onEvent(event.eventName, event.metadata); }); useEffect(() => { openLink({ @@ -20,9 +17,6 @@ function PlaidLink(props) { onSuccess: ({publicToken, metadata}) => { props.onSuccess({publicToken, metadata}); }, - onEvent: (event, metadata) => { - props.onEvent(event, metadata); - }, onExit: (exitError, metadata) => { Log.info('[PlaidLink] Exit: ', false, {exitError, metadata}); props.onExit(); From 539a304ff4acb77bfaf62caf3598534ce431c1a1 Mon Sep 17 00:00:00 2001 From: tienifr Date: Thu, 31 Aug 2023 22:42:05 +0700 Subject: [PATCH 190/284] fix: 26075 image does not show in full view on Staging Server --- src/components/AttachmentModal.js | 3 +-- .../HTMLRenderers/ImageRenderer.js | 20 +++++++++++++++++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/components/AttachmentModal.js b/src/components/AttachmentModal.js index c07a4474a68b..d39906faf3a3 100755 --- a/src/components/AttachmentModal.js +++ b/src/components/AttachmentModal.js @@ -25,7 +25,6 @@ import HeaderGap from './HeaderGap'; import SafeAreaConsumer from './SafeAreaConsumer'; import addEncryptedAuthTokenToURL from '../libs/addEncryptedAuthTokenToURL'; import reportPropTypes from '../pages/reportPropTypes'; -import tryResolveUrlFromApiRoot from '../libs/tryResolveUrlFromApiRoot'; /** * Modal render prop component that exposes modal launching triggers that can be used @@ -351,7 +350,7 @@ function AttachmentModal(props) { prevProps.translate === nextProps.translate && lodashGet(prevProps, 'user.shouldUseStagingServer') === lodashGet(nextProps, 'user.shouldUseStagingServer'), + ), +); From e220b1602d61fae81f8b1f70adf55bad4d93ca52 Mon Sep 17 00:00:00 2001 From: tienifr Date: Thu, 31 Aug 2023 23:49:22 +0700 Subject: [PATCH 191/284] fix: remove memo and withLocalize --- .../HTMLRenderers/ImageRenderer.js | 30 +++++++------------ 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/src/components/HTMLEngineProvider/HTMLRenderers/ImageRenderer.js b/src/components/HTMLEngineProvider/HTMLRenderers/ImageRenderer.js index 9d31e2ec99d9..4035959dc185 100644 --- a/src/components/HTMLEngineProvider/HTMLRenderers/ImageRenderer.js +++ b/src/components/HTMLEngineProvider/HTMLRenderers/ImageRenderer.js @@ -1,6 +1,5 @@ -import React, {memo} from 'react'; +import React from 'react'; import {withOnyx} from 'react-native-onyx'; -import lodashGet from 'lodash/get'; import Navigation from '../../../libs/Navigation/Navigation'; import htmlRendererPropTypes from './htmlRendererPropTypes'; import styles from '../../../styles/styles'; @@ -10,14 +9,15 @@ import CONST from '../../../CONST'; import {ShowContextMenuContext, showContextMenuForReport} from '../../ShowContextMenuContext'; import tryResolveUrlFromApiRoot from '../../../libs/tryResolveUrlFromApiRoot'; import * as ReportUtils from '../../../libs/ReportUtils'; -import withLocalize, {withLocalizePropTypes} from '../../withLocalize'; import ROUTES from '../../../ROUTES'; -import compose from '../../../libs/compose'; import ONYXKEYS from '../../../ONYXKEYS'; +import useLocalize from '../../../hooks/useLocalize'; -const propTypes = {...htmlRendererPropTypes, ...withLocalizePropTypes}; +const propTypes = {...htmlRendererPropTypes}; function ImageRenderer(props) { + const {translate} = useLocalize(); + const htmlAttribs = props.tnode.attributes; // There are two kinds of images that need to be displayed: @@ -76,7 +76,7 @@ function ImageRenderer(props) { ) } accessibilityRole={CONST.ACCESSIBILITY_ROLE.IMAGEBUTTON} - accessibilityLabel={props.translate('accessibilityHints.viewAttachment')} + accessibilityLabel={translate('accessibilityHints.viewAttachment')} > prevProps.translate === nextProps.translate && lodashGet(prevProps, 'user.shouldUseStagingServer') === lodashGet(nextProps, 'user.shouldUseStagingServer'), - ), -); +export default withOnyx({ + user: { + key: ONYXKEYS.USER, + }, +})(ImageRenderer); From 0f0b95a0f1ae18c17f916aa271e7186968654a32 Mon Sep 17 00:00:00 2001 From: tienifr Date: Fri, 1 Sep 2023 23:25:43 +0700 Subject: [PATCH 192/284] add memo hook --- .../HTMLRenderers/ImageRenderer.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/components/HTMLEngineProvider/HTMLRenderers/ImageRenderer.js b/src/components/HTMLEngineProvider/HTMLRenderers/ImageRenderer.js index 4035959dc185..b920349eaf38 100644 --- a/src/components/HTMLEngineProvider/HTMLRenderers/ImageRenderer.js +++ b/src/components/HTMLEngineProvider/HTMLRenderers/ImageRenderer.js @@ -1,4 +1,4 @@ -import React from 'react'; +import React, {memo} from 'react'; import {withOnyx} from 'react-native-onyx'; import Navigation from '../../../libs/Navigation/Navigation'; import htmlRendererPropTypes from './htmlRendererPropTypes'; @@ -12,6 +12,7 @@ import * as ReportUtils from '../../../libs/ReportUtils'; import ROUTES from '../../../ROUTES'; import ONYXKEYS from '../../../ONYXKEYS'; import useLocalize from '../../../hooks/useLocalize'; +import lodashGet from 'lodash/get'; const propTypes = {...htmlRendererPropTypes}; @@ -98,4 +99,11 @@ export default withOnyx({ user: { key: ONYXKEYS.USER, }, -})(ImageRenderer); +})( + memo( + ImageRenderer, + (prevProps, nextProps) => + lodashGet(prevProps, 'tnode.attributes') === lodashGet(nextProps, 'tnode.attributes') && + lodashGet(prevProps, 'user.shouldUseStagingServer') === lodashGet(nextProps, 'user.shouldUseStagingServer'), + ), +); From 865bf60eec59a918ad77fbe8bd7da3b6e71b6684 Mon Sep 17 00:00:00 2001 From: tienifr Date: Sat, 2 Sep 2023 00:01:58 +0700 Subject: [PATCH 193/284] fix: lint --- .../HTMLEngineProvider/HTMLRenderers/ImageRenderer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/HTMLEngineProvider/HTMLRenderers/ImageRenderer.js b/src/components/HTMLEngineProvider/HTMLRenderers/ImageRenderer.js index b920349eaf38..74cf83a4a6f0 100644 --- a/src/components/HTMLEngineProvider/HTMLRenderers/ImageRenderer.js +++ b/src/components/HTMLEngineProvider/HTMLRenderers/ImageRenderer.js @@ -1,5 +1,6 @@ import React, {memo} from 'react'; import {withOnyx} from 'react-native-onyx'; +import lodashGet from 'lodash/get'; import Navigation from '../../../libs/Navigation/Navigation'; import htmlRendererPropTypes from './htmlRendererPropTypes'; import styles from '../../../styles/styles'; @@ -12,7 +13,6 @@ import * as ReportUtils from '../../../libs/ReportUtils'; import ROUTES from '../../../ROUTES'; import ONYXKEYS from '../../../ONYXKEYS'; import useLocalize from '../../../hooks/useLocalize'; -import lodashGet from 'lodash/get'; const propTypes = {...htmlRendererPropTypes}; From 0088b39d496cddb72ad9b1e8a8d33f89e2c4f877 Mon Sep 17 00:00:00 2001 From: Ana Margarida Silva Date: Mon, 4 Sep 2023 08:52:36 +0100 Subject: [PATCH 194/284] feat: switch us states const to an array of ISOs --- src/CONST.js | 108 +++++++++--------- .../StatePicker/StateSelectorModal.js | 2 +- 2 files changed, 55 insertions(+), 55 deletions(-) diff --git a/src/CONST.js b/src/CONST.js index 9b4a84c10ce4..33c8aeaf5289 100755 --- a/src/CONST.js +++ b/src/CONST.js @@ -1664,60 +1664,60 @@ const CONST = { ZW: 'Zimbabwe', }, - ALL_US_STATES: { - AK: 'Alaska', - AL: 'Alabama', - AR: 'Arkansas', - AZ: 'Arizona', - CA: 'California', - CO: 'Colorado', - CT: 'Connecticut', - DE: 'Delaware', - FL: 'Florida', - GA: 'Georgia', - HI: 'Hawaii', - IA: 'Iowa', - ID: 'Idaho', - IL: 'Illinois', - IN: 'Indiana', - KS: 'Kansas', - KY: 'Kentucky', - LA: 'Louisiana', - MA: 'Massachusetts', - MD: 'Maryland', - ME: 'Maine', - MI: 'Michigan', - MN: 'Minnesota', - MO: 'Missouri', - MS: 'Mississippi', - MT: 'Montana', - NC: 'North Carolina', - ND: 'North Dakota', - NE: 'Nebraska', - NH: 'New Hampshire', - NJ: 'New Jersey', - NM: 'New Mexico', - NV: 'Nevada', - NY: 'New York', - OH: 'Ohio', - OK: 'Oklahoma', - OR: 'Oregon', - PA: 'Pennsylvania', - PR: 'Puerto Rico', - RI: 'Rhode Island', - SC: 'South Carolina', - SD: 'South Dakota', - TN: 'Tennessee', - TX: 'Texas', - UT: 'Utah', - VA: 'Virginia', - VT: 'Vermont', - WA: 'Washington', - WI: 'Wisconsin', - WV: 'West Virginia', - WY: 'Wyoming', - DC: 'District Of Columbia', - }, + ALL_US_ISO_STATES: [ + 'AK', + 'AL', + 'AR', + 'AZ', + 'CA', + 'CO', + 'CT', + 'DE', + 'FL', + 'GA', + 'HI', + 'IA', + 'ID', + 'IL', + 'IN', + 'KS', + 'KY', + 'LA', + 'MA', + 'MD', + 'ME', + 'MI', + 'MN', + 'MO', + 'MS', + 'MT', + 'NC', + 'ND', + 'NE', + 'NH', + 'NJ', + 'NM', + 'NV', + 'NY', + 'OH', + 'OK', + 'OR', + 'PA', + 'PR', + 'RI', + 'SC', + 'SD', + 'TN', + 'TX', + 'UT', + 'VA', + 'VT', + 'WA', + 'WI', + 'WV', + 'WY', + 'DC', + ], // Sources: https://github.com/Expensify/App/issues/14958#issuecomment-1442138427 // https://github.com/Expensify/App/issues/14958#issuecomment-1456026810 diff --git a/src/components/StatePicker/StateSelectorModal.js b/src/components/StatePicker/StateSelectorModal.js index 91458892676a..39dcf3479478 100644 --- a/src/components/StatePicker/StateSelectorModal.js +++ b/src/components/StatePicker/StateSelectorModal.js @@ -46,7 +46,7 @@ function StateSelectorModal({currentState, isVisible, onClose, onStateSelected, const countryStates = useMemo( () => - _.map(_.keys(CONST.ALL_US_STATES), (state) => { + _.map(CONST.ALL_US_ISO_STATES, (state) => { const stateName = translate(`allStates.${state}.stateName`); const stateISO = translate(`allStates.${state}.stateISO`); return { From 7bf3c0114b0fcba73a4fc91b943ecc7bba937e37 Mon Sep 17 00:00:00 2001 From: Jakub Butkiewicz Date: Mon, 4 Sep 2023 15:53:45 +0200 Subject: [PATCH 195/284] ref: migrate CollectionUtils to Typescript --- src/libs/CollectionUtils.js | 27 --------------------------- src/libs/CollectionUtils.ts | 10 ++++++++++ 2 files changed, 10 insertions(+), 27 deletions(-) delete mode 100644 src/libs/CollectionUtils.js create mode 100644 src/libs/CollectionUtils.ts diff --git a/src/libs/CollectionUtils.js b/src/libs/CollectionUtils.js deleted file mode 100644 index 3625c68d2c39..000000000000 --- a/src/libs/CollectionUtils.js +++ /dev/null @@ -1,27 +0,0 @@ -import _ from 'underscore'; - -/** - * Return the highest item in a numbered collection - * - * e.g. {1: '1', 2: '2', 3: '3'} -> '3' - * - * @param {Object} object - * @returns {*} - */ -function lastItem(object = {}) { - const lastKey = _.last(_.keys(object)) || 0; - return object[lastKey]; -} - -/** - * Used to grab the id for a particular collection item's key. - * e.g. reportActions_1 -> 1 - * - * @param {String} key - * @returns {String} - */ -function extractCollectionItemID(key) { - return key.split('_')[1]; -} - -export {lastItem, extractCollectionItemID}; diff --git a/src/libs/CollectionUtils.ts b/src/libs/CollectionUtils.ts new file mode 100644 index 000000000000..9994cfe42437 --- /dev/null +++ b/src/libs/CollectionUtils.ts @@ -0,0 +1,10 @@ +function lastItem(object: Record = {}) { + const lastKey = Object.keys(object).pop() ?? 0; + return object[lastKey]; +} + +function extractCollectionItemID(key: string) { + return key.split('_')[1]; +} + +export {lastItem, extractCollectionItemID}; From d8667aec81336cf48d929e4b96a452327adb7a17 Mon Sep 17 00:00:00 2001 From: Jakub Butkiewicz Date: Mon, 4 Sep 2023 17:00:55 +0200 Subject: [PATCH 196/284] ref: added generic type --- src/libs/CollectionUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/CollectionUtils.ts b/src/libs/CollectionUtils.ts index 9994cfe42437..17dee2735cd4 100644 --- a/src/libs/CollectionUtils.ts +++ b/src/libs/CollectionUtils.ts @@ -1,4 +1,4 @@ -function lastItem(object: Record = {}) { +function lastItem(object: Record = {}): T { const lastKey = Object.keys(object).pop() ?? 0; return object[lastKey]; } From 5df95cbf54a94532619691711b4279800dcb8c6e Mon Sep 17 00:00:00 2001 From: Nam Le Date: Mon, 4 Sep 2023 22:10:09 +0700 Subject: [PATCH 197/284] add message when search no result for timezone selector --- src/pages/settings/Profile/TimezoneSelectPage.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pages/settings/Profile/TimezoneSelectPage.js b/src/pages/settings/Profile/TimezoneSelectPage.js index c4fdda42114f..9860cfb6dff8 100644 --- a/src/pages/settings/Profile/TimezoneSelectPage.js +++ b/src/pages/settings/Profile/TimezoneSelectPage.js @@ -84,6 +84,7 @@ function TimezoneSelectPage(props) { onBackButtonPress={() => Navigation.goBack(ROUTES.SETTINGS_TIMEZONE)} /> Date: Tue, 5 Sep 2023 13:31:59 +0200 Subject: [PATCH 198/284] ref: resolve issue after discusion --- src/libs/CollectionUtils.ts | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/libs/CollectionUtils.ts b/src/libs/CollectionUtils.ts index 17dee2735cd4..8d5bf75fc8f7 100644 --- a/src/libs/CollectionUtils.ts +++ b/src/libs/CollectionUtils.ts @@ -1,9 +1,21 @@ -function lastItem(object: Record = {}): T { - const lastKey = Object.keys(object).pop() ?? 0; +/* eslint-disable */ +import {OnyxCollectionKey} from '../ONYXKEYS'; + +/** + * Return the highest item in a numbered collection + * + * e.g. {1: '1', 2: '2', 3: '3'} -> '3' + */ +function lastItem(object: Record = {}): T | undefined { + const lastKey = +(Object.keys(object).pop() ?? 0); return object[lastKey]; } -function extractCollectionItemID(key: string) { +/** + * Used to grab the id for a particular collection item's key. + * e.g. reportActions_1 -> 1 + */ +function extractCollectionItemID(key: `${OnyxCollectionKey}${string}`) { return key.split('_')[1]; } From 54b732e6854b771b344ae128e52be61f362aeff6 Mon Sep 17 00:00:00 2001 From: Jakub Butkiewicz Date: Tue, 5 Sep 2023 15:35:52 +0200 Subject: [PATCH 199/284] ref: removed number conversion added a warning comment --- src/libs/CollectionUtils.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/libs/CollectionUtils.ts b/src/libs/CollectionUtils.ts index 8d5bf75fc8f7..ddd54bab862a 100644 --- a/src/libs/CollectionUtils.ts +++ b/src/libs/CollectionUtils.ts @@ -1,13 +1,14 @@ -/* eslint-disable */ import {OnyxCollectionKey} from '../ONYXKEYS'; /** * Return the highest item in a numbered collection * * e.g. {1: '1', 2: '2', 3: '3'} -> '3' + * + * Use this only for collections that are numbered in other cases it will return the last item in the object not the highest */ -function lastItem(object: Record = {}): T | undefined { - const lastKey = +(Object.keys(object).pop() ?? 0); +function lastItem(object: Record = {}): T | undefined { + const lastKey = Object.keys(object).pop() ?? 0; return object[lastKey]; } From d94615d07d186d49c1ccb4b2d0c01be11180dd63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Ch=C3=A1vez?= Date: Wed, 6 Sep 2023 00:30:25 +0900 Subject: [PATCH 200/284] change route to teachersunite for the campaign --- src/ROUTES.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ROUTES.js b/src/ROUTES.js index b38ce25f590f..bff46cf25045 100644 --- a/src/ROUTES.js +++ b/src/ROUTES.js @@ -129,10 +129,10 @@ export default { FLAG_COMMENT: `flag/:reportID/:reportActionID`, getFlagCommentRoute: (reportID, reportActionID) => `flag/${reportID}/${reportActionID}`, SEARCH: 'search', - SAVE_THE_WORLD: 'save-the-world', - I_KNOW_A_TEACHER: 'save-the-world/i-know-a-teacher', - INTRO_SCHOOL_PRINCIPAL: 'save-the-world/intro-school-principal', - I_AM_A_TEACHER: 'save-the-world/i-am-a-teacher', + SAVE_THE_WORLD: 'teachersunite', + I_KNOW_A_TEACHER: 'teachersunite/i-know-a-teacher', + INTRO_SCHOOL_PRINCIPAL: 'teachersunite/intro-school-principal', + I_AM_A_TEACHER: 'teachersunite/i-am-a-teacher', DETAILS: 'details', getDetailsRoute: (login) => `details?login=${encodeURIComponent(login)}`, PROFILE: 'a/:accountID', From fd6b500c66c9b12f75be4adab8070f92395641e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Ch=C3=A1vez?= Date: Wed, 6 Sep 2023 00:30:44 +0900 Subject: [PATCH 201/284] add deep link for teachers unite campaign --- .well-known/apple-app-site-association | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.well-known/apple-app-site-association b/.well-known/apple-app-site-association index 9274dd8c1382..d2c447cf2a49 100644 --- a/.well-known/apple-app-site-association +++ b/.well-known/apple-app-site-association @@ -63,6 +63,10 @@ { "/": "/new/*", "comment": "New Chat" + }, + { + "/": "/teachersunite/*", + "comment": "Teachers Unite!" } ] } From acd97b1da449b552c6afdc96580a437b8840fd3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Ch=C3=A1vez?= Date: Wed, 6 Sep 2023 00:33:33 +0900 Subject: [PATCH 202/284] change const name SAVE_THE_WORLD to TEACHERS_UNITE --- src/ROUTES.js | 2 +- src/libs/Navigation/linkingConfig.js | 2 +- src/pages/TeachersUnite/ImTeacherPage.js | 2 +- src/pages/TeachersUnite/IntroSchoolPrincipalPage.js | 2 +- src/pages/TeachersUnite/KnowATeacherPage.js | 2 +- .../sidebar/SidebarScreen/FloatingActionButtonAndPopover.js | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/ROUTES.js b/src/ROUTES.js index bff46cf25045..6d9ba099911d 100644 --- a/src/ROUTES.js +++ b/src/ROUTES.js @@ -129,7 +129,7 @@ export default { FLAG_COMMENT: `flag/:reportID/:reportActionID`, getFlagCommentRoute: (reportID, reportActionID) => `flag/${reportID}/${reportActionID}`, SEARCH: 'search', - SAVE_THE_WORLD: 'teachersunite', + TEACHERS_UNITE: 'teachersunite', I_KNOW_A_TEACHER: 'teachersunite/i-know-a-teacher', INTRO_SCHOOL_PRINCIPAL: 'teachersunite/intro-school-principal', I_AM_A_TEACHER: 'teachersunite/i-am-a-teacher', diff --git a/src/libs/Navigation/linkingConfig.js b/src/libs/Navigation/linkingConfig.js index ee3054e02f96..89caab4d733f 100644 --- a/src/libs/Navigation/linkingConfig.js +++ b/src/libs/Navigation/linkingConfig.js @@ -265,7 +265,7 @@ export default { }, TeachersUnite: { screens: { - SaveTheWorld_Root: ROUTES.SAVE_THE_WORLD, + SaveTheWorld_Root: ROUTES.TEACHERS_UNITE, I_Know_A_Teacher: ROUTES.I_KNOW_A_TEACHER, Intro_School_Principal: ROUTES.INTRO_SCHOOL_PRINCIPAL, I_Am_A_Teacher: ROUTES.I_AM_A_TEACHER, diff --git a/src/pages/TeachersUnite/ImTeacherPage.js b/src/pages/TeachersUnite/ImTeacherPage.js index f077c7724978..dbeba700d208 100644 --- a/src/pages/TeachersUnite/ImTeacherPage.js +++ b/src/pages/TeachersUnite/ImTeacherPage.js @@ -22,7 +22,7 @@ function ImTeacherPage() { Navigation.goBack(ROUTES.SAVE_THE_WORLD)} + onBackButtonPress={() => Navigation.goBack(ROUTES.TEACHERS_UNITE)} /> Navigation.goBack(ROUTES.SAVE_THE_WORLD)} + onBackButtonPress={() => Navigation.goBack(ROUTES.TEACHERS_UNITE)} />
Navigation.goBack(ROUTES.SAVE_THE_WORLD)} + onBackButtonPress={() => Navigation.goBack(ROUTES.TEACHERS_UNITE)} /> interceptAnonymousUser(() => Navigation.navigate(ROUTES.SAVE_THE_WORLD)), + onSelected: () => interceptAnonymousUser(() => Navigation.navigate(ROUTES.TEACHERS_UNITE)), }, { icon: Expensicons.Receipt, From 4d703bd56dd4e46ff811c4e5ef5a09672b1ce94e Mon Sep 17 00:00:00 2001 From: Bartosz Grajdek Date: Wed, 6 Sep 2023 10:15:34 +0200 Subject: [PATCH 203/284] [TS migration] Migrate 'tryResolveUrlFromApiRoot.js' lib to TypeScript --- ...yResolveUrlFromApiRoot.js => tryResolveUrlFromApiRoot.ts} | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) rename src/libs/{tryResolveUrlFromApiRoot.js => tryResolveUrlFromApiRoot.ts} (91%) diff --git a/src/libs/tryResolveUrlFromApiRoot.js b/src/libs/tryResolveUrlFromApiRoot.ts similarity index 91% rename from src/libs/tryResolveUrlFromApiRoot.js rename to src/libs/tryResolveUrlFromApiRoot.ts index dc5780bb25e3..02388d98112e 100644 --- a/src/libs/tryResolveUrlFromApiRoot.js +++ b/src/libs/tryResolveUrlFromApiRoot.ts @@ -15,11 +15,8 @@ const ORIGIN_PATTERN = new RegExp(`^(${ORIGINS_TO_REPLACE.join('|')})`); * - Similarly for prod or staging URLs we replace the `https://www.expensify` * or `https://staging.expensify` part, with `https://{API_ROOT}` * - Unmatched URLs (non expensify) are returned with no modifications - * - * @param {String} url - * @returns {String} */ -export default function tryResolveUrlFromApiRoot(url) { +export default function tryResolveUrlFromApiRoot(url: string): string { const apiRoot = ApiUtils.getApiRoot({shouldUseSecure: false}); return url.replace(ORIGIN_PATTERN, apiRoot); } From ce450d3c9153c372ecd04e596387e5af6265d9d9 Mon Sep 17 00:00:00 2001 From: Bartosz Grajdek Date: Wed, 6 Sep 2023 15:02:30 +0200 Subject: [PATCH 204/284] [TS migration] Migrate 'LocaleDigitUtils.js' lib to TypeScript --- src/libs/{LocaleDigitUtils.js => LocaleDigitUtils.ts} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/libs/{LocaleDigitUtils.js => LocaleDigitUtils.ts} (100%) diff --git a/src/libs/LocaleDigitUtils.js b/src/libs/LocaleDigitUtils.ts similarity index 100% rename from src/libs/LocaleDigitUtils.js rename to src/libs/LocaleDigitUtils.ts From d58d63c25203fe94d3163512074c0a1588583a3e Mon Sep 17 00:00:00 2001 From: Bartosz Grajdek Date: Thu, 7 Sep 2023 11:03:52 +0200 Subject: [PATCH 205/284] [TS migration] Migrate 'LocaleDigitUtils.js' lib to TypeScript --- src/libs/LocaleDigitUtils.ts | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/src/libs/LocaleDigitUtils.ts b/src/libs/LocaleDigitUtils.ts index 23396f8d2fb6..ac9f84cb2743 100644 --- a/src/libs/LocaleDigitUtils.ts +++ b/src/libs/LocaleDigitUtils.ts @@ -1,4 +1,4 @@ -import _ from 'underscore'; +import _ from 'lodash'; import * as NumberFormatUtils from './NumberFormatUtils'; @@ -8,12 +8,12 @@ const INDEX_DECIMAL = 10; const INDEX_MINUS_SIGN = 11; const INDEX_GROUP = 12; -const getLocaleDigits = _.memoize((locale) => { - const localeDigits = _.clone(STANDARD_DIGITS); +const getLocaleDigits = _.memoize((locale: string) => { + const localeDigits = [...STANDARD_DIGITS]; for (let i = 0; i <= 9; i++) { localeDigits[i] = NumberFormatUtils.format(locale, i); } - _.forEach(NumberFormatUtils.formatToParts(locale, 1000000.5), (part) => { + NumberFormatUtils.formatToParts(locale, 1000000.5).forEach((part) => { switch (part.type) { case 'decimal': localeDigits[INDEX_DECIMAL] = part.value; @@ -34,15 +34,13 @@ const getLocaleDigits = _.memoize((locale) => { /** * Gets the locale digit corresponding to a standard digit. * - * @param {String} locale - * @param {String} digit - Character of a single standard digit . It may be "0" ~ "9" (digits), + * @param digit - Character of a single standard digit . It may be "0" ~ "9" (digits), * "," (group separator), "." (decimal separator) or "-" (minus sign). - * @returns {String} * * @throws If `digit` is not a valid standard digit. */ -function toLocaleDigit(locale, digit) { - const index = _.indexOf(STANDARD_DIGITS, digit); +function toLocaleDigit(locale: string, digit: string): string { + const index = STANDARD_DIGITS.indexOf(digit); if (index < 0) { throw new Error(`"${digit}" must be in ${JSON.stringify(STANDARD_DIGITS)}`); } @@ -52,15 +50,13 @@ function toLocaleDigit(locale, digit) { /** * Gets the standard digit corresponding to a locale digit. * - * @param {String} locale - * @param {String} localeDigit - Character of a single locale digit. It may be **the localized version** of + * @param localeDigit - Character of a single locale digit. It may be **the localized version** of * "0" ~ "9" (digits), "," (group separator), "." (decimal separator) or "-" (minus sign). - * @returns {String} * * @throws If `localeDigit` is not a valid locale digit. */ -function fromLocaleDigit(locale, localeDigit) { - const index = _.indexOf(getLocaleDigits(locale), localeDigit); +function fromLocaleDigit(locale: string, localeDigit: string): string { + const index = getLocaleDigits(locale).indexOf(localeDigit); if (index < 0) { throw new Error(`"${localeDigit}" must be in ${JSON.stringify(getLocaleDigits(locale))}`); } From 002bcf025ae3979271a85ab494b37a5ee8d755af Mon Sep 17 00:00:00 2001 From: Ana Margarida Silva Date: Thu, 7 Sep 2023 11:28:19 +0100 Subject: [PATCH 206/284] feat: tag picker component --- src/CONST.ts | 1 + src/ONYXKEYS.ts | 3 + src/components/TagPicker/index.js | 90 +++++++++++++++++++ .../TagPicker/tagPickerPropTypes.js | 39 ++++++++ 4 files changed, 133 insertions(+) create mode 100644 src/components/TagPicker/index.js create mode 100644 src/components/TagPicker/tagPickerPropTypes.js diff --git a/src/CONST.ts b/src/CONST.ts index 56f61536b3cb..795d09d48322 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -235,6 +235,7 @@ const CONST = { TASKS: 'tasks', THREADS: 'threads', CUSTOM_STATUS: 'customStatus', + NEW_DOT_TAGS: 'newDotTags', }, BUTTON_STATES: { DEFAULT: 'default', diff --git a/src/ONYXKEYS.ts b/src/ONYXKEYS.ts index b3ef88cc0094..d8d584df18bf 100755 --- a/src/ONYXKEYS.ts +++ b/src/ONYXKEYS.ts @@ -236,12 +236,15 @@ const ONYXKEYS = { // Max width supported for HTML element MAX_CANVAS_WIDTH: 'maxCanvasWidth', + RECENTLY_USED_POLICY_TAGS: 'recentlyUsedPolicyTags_', + /** Collection Keys */ COLLECTION: { DOWNLOAD: 'download_', POLICY: 'policy_', POLICY_MEMBERS: 'policyMembers_', POLICY_CATEGORIES: 'policyCategories_', + POLICY_TAGS: 'policyTags_', WORKSPACE_INVITE_MEMBERS_DRAFT: 'workspaceInviteMembersDraft_', REPORT: 'report_', REPORT_ACTIONS: 'reportActions_', diff --git a/src/components/TagPicker/index.js b/src/components/TagPicker/index.js new file mode 100644 index 000000000000..61856c1033cc --- /dev/null +++ b/src/components/TagPicker/index.js @@ -0,0 +1,90 @@ +import React, {useMemo} from 'react'; +import _ from 'underscore'; +import lodashGet from 'lodash/get'; +import {withOnyx} from 'react-native-onyx'; +import ONYXKEYS from '../../ONYXKEYS'; +import styles from '../../styles/styles'; +import Navigation from '../../libs/Navigation/Navigation'; +import ROUTES from '../../ROUTES'; +import useLocalize from '../../hooks/useLocalize'; +import * as OptionsListUtils from '../../libs/OptionsListUtils'; +import OptionsSelector from '../OptionsSelector'; +import {propTypes, defaultProps} from './tagPickerPropTypes'; + +function TagPicker({policyTags, reportID, iouType, iou}) { + const {translate} = useLocalize(); + + const selectedOptions = useMemo(() => { + if (!iou.tag) { + return []; + } + + return [ + { + name: iou.tag, + enabled: true, + accountID: null, + }, + ]; + }, [iou.tag]); + + // Only shows one section, which will be the default behavior if there are + // less than 8 policy tags + // TODO: support sections with search + const sections = useMemo(() => { + const tagList = _.chain(policyTags) + .values() + .map((tag) => ({ + text: tag.name, + keyForList: tag.name, + tooltipText: tag.name, + })) + .value(); + + return [ + { + data: tagList, + }, + ]; + }, [policyTags]); + + const headerMessage = OptionsListUtils.getHeaderMessage(lodashGet(sections, '[0].data.length', 0) > 0, false, ''); + + const navigateBack = () => { + Navigation.goBack(ROUTES.getMoneyRequestConfirmationRoute(iouType, reportID)); + }; + + const updateTag = () => { + // TODO: add logic to save the selected tag + navigateBack(); + }; + + return ( + + ); +} + +TagPicker.displayName = 'TagPicker'; +TagPicker.propTypes = propTypes; +TagPicker.defaultProps = defaultProps; + +export default withOnyx({ + policyTags: { + key: ({policyID}) => `${ONYXKEYS.COLLECTION.POLICY_TAGS}${policyID}`, + }, + recentlyUsedPolicyTags: { + key: ({policyID}) => `${ONYXKEYS.RECENTLY_USED_POLICY_TAGS}${policyID}`, + }, + iou: { + key: ONYXKEYS.IOU, + }, +})(TagPicker); diff --git a/src/components/TagPicker/tagPickerPropTypes.js b/src/components/TagPicker/tagPickerPropTypes.js new file mode 100644 index 000000000000..fb3942d94c80 --- /dev/null +++ b/src/components/TagPicker/tagPickerPropTypes.js @@ -0,0 +1,39 @@ +import PropTypes from 'prop-types'; +import tagPropTypes from '../tagPropTypes'; + +const propTypes = { + /** The report ID of the IOU */ + reportID: PropTypes.string.isRequired, + + /** The policyID we are getting tags for */ + policyID: PropTypes.string.isRequired, + + /** The type of IOU report, i.e. bill, request, send */ + iouType: PropTypes.string.isRequired, + + /** Callback to submit the selected tag */ + onSubmit: PropTypes.func, + + /* Onyx Props */ + /** Collection of tags attached to a policy */ + policyTags: PropTypes.objectOf(tagPropTypes), + + /* Onyx Props */ + /** List of recently used tags */ + recentlyUsedPolicyTags: PropTypes.arrayOf(PropTypes.string), + + /* Onyx Props */ + /** Holds data related to Money Request view state, rather than the underlying Money Request data. */ + iou: PropTypes.shape({ + tag: PropTypes.string, + }), +}; + +const defaultProps = { + policyID: '', + policyTags: {}, + recentlyUsedPolicyTags: [], + iou: {}, +}; + +export {propTypes, defaultProps}; From c0e23527ae3bba9c256dd2f78e4d7a66346179ca Mon Sep 17 00:00:00 2001 From: Ana Margarida Silva Date: Thu, 7 Sep 2023 11:31:22 +0100 Subject: [PATCH 207/284] feat: money request tag page and tag menu item --- src/ROUTES.js | 2 + .../MoneyRequestConfirmationList.js | 32 ++++++++ src/components/tagPropTypes.js | 9 +++ src/languages/en.ts | 2 + src/languages/es.ts | 2 + .../AppNavigator/ModalStackNavigators.js | 7 ++ src/libs/Navigation/linkingConfig.js | 1 + src/libs/Permissions.js | 9 +++ src/pages/iou/MoneyRequestTagPage.js | 74 +++++++++++++++++++ 9 files changed, 138 insertions(+) create mode 100644 src/components/tagPropTypes.js create mode 100644 src/pages/iou/MoneyRequestTagPage.js diff --git a/src/ROUTES.js b/src/ROUTES.js index b38ce25f590f..ae4b45c19437 100644 --- a/src/ROUTES.js +++ b/src/ROUTES.js @@ -92,6 +92,7 @@ export default { MONEY_REQUEST_CURRENCY: ':iouType/new/currency/:reportID?', MONEY_REQUEST_DESCRIPTION: ':iouType/new/description/:reportID?', MONEY_REQUEST_CATEGORY: ':iouType/new/category/:reportID?', + MONEY_REQUEST_TAG: ':iouType/new/tag/:reportID?', MONEY_REQUEST_MERCHANT: ':iouType/new/merchant/:reportID?', MONEY_REQUEST_MANUAL_TAB: ':iouType/new/:reportID?/manual', MONEY_REQUEST_SCAN_TAB: ':iouType/new/:reportID?/scan', @@ -108,6 +109,7 @@ export default { getMoneyRequestCurrencyRoute: (iouType, reportID = '', currency, backTo) => `${iouType}/new/currency/${reportID}?currency=${currency}&backTo=${backTo}`, getMoneyRequestDescriptionRoute: (iouType, reportID = '') => `${iouType}/new/description/${reportID}`, getMoneyRequestCategoryRoute: (iouType, reportID = '') => `${iouType}/new/category/${reportID}`, + getMoneyRequestTagRoute: (iouType, reportID = '') => `${iouType}/new/tag/${reportID}`, getMoneyRequestMerchantRoute: (iouType, reportID = '') => `${iouType}/new/merchant/${reportID}`, getMoneyRequestDistanceTabRoute: (iouType, reportID = '') => `${iouType}/new/${reportID}/distance`, getMoneyRequestWaypointRoute: (iouType, waypointIndex) => `${iouType}/new/waypoint/${waypointIndex}`, diff --git a/src/components/MoneyRequestConfirmationList.js b/src/components/MoneyRequestConfirmationList.js index a7695c939907..ea2e213b4c26 100755 --- a/src/components/MoneyRequestConfirmationList.js +++ b/src/components/MoneyRequestConfirmationList.js @@ -8,6 +8,7 @@ import lodashGet from 'lodash/get'; import styles from '../styles/styles'; import * as ReportUtils from '../libs/ReportUtils'; import * as OptionsListUtils from '../libs/OptionsListUtils'; +import Permissions from '../libs/Permissions'; import OptionsSelector from './OptionsSelector'; import ONYXKEYS from '../ONYXKEYS'; import compose from '../libs/compose'; @@ -29,6 +30,7 @@ import Image from './Image'; import useLocalize from '../hooks/useLocalize'; import * as ReceiptUtils from '../libs/ReceiptUtils'; import categoryPropTypes from './categoryPropTypes'; +import tagPropTypes from './tagPropTypes'; import ConfirmedRoute from './ConfirmedRoute'; import transactionPropTypes from './transactionPropTypes'; import DistanceRequestUtils from '../libs/DistanceRequestUtils'; @@ -68,6 +70,9 @@ const propTypes = { /** IOU Category */ iouCategory: PropTypes.string, + /** IOU Tag */ + iouTag: PropTypes.string, + /** Selected participants from MoneyRequestModal with login / accountID */ selectedParticipants: PropTypes.arrayOf(optionPropTypes).isRequired, @@ -109,6 +114,14 @@ const propTypes = { /** Collection of categories attached to a policy */ policyCategories: PropTypes.objectOf(categoryPropTypes), + /* Onyx Props */ + /** Collection of tags attached to a policy */ + policyTags: PropTypes.objectOf(tagPropTypes), + + /* Onyx Props */ + /* Beta features list */ + betas: PropTypes.arrayOf(PropTypes.string), + /** ID of the transaction that represents the money request */ transactionID: PropTypes.string, @@ -151,6 +164,8 @@ const defaultProps = { receiptSource: '', listStyles: [], policyCategories: {}, + policyTags: {}, + betas: [], transactionID: '', transaction: {}, mileageRate: {unit: CONST.CUSTOM_UNITS.DISTANCE_UNIT_MILES, rate: 0, currency: 'USD'}, @@ -172,6 +187,7 @@ function MoneyRequestConfirmationList(props) { const distance = lodashGet(transaction, 'routes.route0.distance', 0); const shouldCalculateDistanceAmount = props.isDistanceRequest && props.iouAmount === 0; const shouldCategoryEditable = !_.isEmpty(props.policyCategories) && !props.isDistanceRequest; + const shouldTagsBeEditable = !_.isEmpty(props.policyTags) && Permissions.canUseNewDotTags(props.betas); const formattedAmount = CurrencyUtils.convertToDisplayString( shouldCalculateDistanceAmount ? DistanceRequestUtils.getDistanceRequestAmount(distance, unit, rate) : props.iouAmount, @@ -494,6 +510,16 @@ function MoneyRequestConfirmationList(props) { disabled={didConfirm || props.isReadOnly} /> )} + {shouldTagsBeEditable && ( + Navigation.navigate(ROUTES.getMoneyRequestTagRoute(props.iouType, props.reportID))} + style={[styles.moneyRequestMenuItem, styles.mb2]} + disabled={didConfirm || props.isReadOnly} + /> + )} )} @@ -509,9 +535,15 @@ export default compose( session: { key: ONYXKEYS.SESSION, }, + betas: { + key: ONYXKEYS.BETAS, + }, policyCategories: { key: ({policyID}) => `${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${policyID}`, }, + policyTags: { + key: ({policyID}) => `${ONYXKEYS.COLLECTION.POLICY_TAGS}${policyID}`, + }, mileageRate: { key: ({policyID}) => `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, selector: DistanceRequestUtils.getDefaultMileageRate, diff --git a/src/components/tagPropTypes.js b/src/components/tagPropTypes.js new file mode 100644 index 000000000000..09ba8d403cf8 --- /dev/null +++ b/src/components/tagPropTypes.js @@ -0,0 +1,9 @@ +import PropTypes from 'prop-types'; + +export default PropTypes.shape({ + /** Name of a tag */ + name: PropTypes.string.isRequired, + + /** Flag that determines if a tag is active and able to be selected */ + enabled: PropTypes.bool.isRequired, +}); diff --git a/src/languages/en.ts b/src/languages/en.ts index af7957e1a560..4bea3f64198d 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -230,6 +230,7 @@ export default { showMore: 'Show more', merchant: 'Merchant', category: 'Category', + tag: 'Tag', receipt: 'Receipt', replace: 'Replace', distance: 'Distance', @@ -525,6 +526,7 @@ export default { pendingConversionMessage: "Total will update when you're back online", threadRequestReportName: ({formattedAmount, comment}: ThreadRequestReportNameParams) => `${formattedAmount} request${comment ? ` for ${comment}` : ''}`, threadSentMoneyReportName: ({formattedAmount, comment}: ThreadSentMoneyReportNameParams) => `${formattedAmount} sent${comment ? ` for ${comment}` : ''}`, + tagSelection: 'Select a tag to add additional organization to your money', error: { invalidSplit: 'Split amounts do not equal total amount', other: 'Unexpected error, please try again later', diff --git a/src/languages/es.ts b/src/languages/es.ts index f950733b005c..5387c33d1939 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -229,6 +229,7 @@ export default { showMore: 'Mostrar más', merchant: 'Comerciante', category: 'Categoría', + tag: 'Etiqueta', receipt: 'Recibo', replace: 'Sustituir', distance: 'Distancia', @@ -526,6 +527,7 @@ export default { pendingConversionMessage: 'El total se actualizará cuando estés online', threadRequestReportName: ({formattedAmount, comment}: ThreadRequestReportNameParams) => `Solicitud de ${formattedAmount}${comment ? ` para ${comment}` : ''}`, threadSentMoneyReportName: ({formattedAmount, comment}: ThreadSentMoneyReportNameParams) => `${formattedAmount} enviado${comment ? ` para ${comment}` : ''}`, + tagSelection: '', error: { invalidSplit: 'La suma de las partes no equivale al monto total', other: 'Error inesperado, por favor inténtalo más tarde', diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators.js b/src/libs/Navigation/AppNavigator/ModalStackNavigators.js index 2adaf0397a2c..851f7aff3a8d 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators.js +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators.js @@ -90,6 +90,13 @@ const MoneyRequestModalStackNavigator = createModalStackNavigator([ }, name: 'Money_Request_Category', }, + { + getComponent: () => { + const MoneyRequestTagPage = require('../../../pages/iou/MoneyRequestTagPage').default; + return MoneyRequestTagPage; + }, + name: 'Money_Request_Tag', + }, { getComponent: () => { const MoneyRequestMerchantPage = require('../../../pages/iou/MoneyRequestMerchantPage').default; diff --git a/src/libs/Navigation/linkingConfig.js b/src/libs/Navigation/linkingConfig.js index ee3054e02f96..00bd74163418 100644 --- a/src/libs/Navigation/linkingConfig.js +++ b/src/libs/Navigation/linkingConfig.js @@ -318,6 +318,7 @@ export default { Money_Request_Currency: ROUTES.MONEY_REQUEST_CURRENCY, Money_Request_Description: ROUTES.MONEY_REQUEST_DESCRIPTION, Money_Request_Category: ROUTES.MONEY_REQUEST_CATEGORY, + Money_Request_Tag: ROUTES.MONEY_REQUEST_TAG, Money_Request_Merchant: ROUTES.MONEY_REQUEST_MERCHANT, Money_Request_Waypoint: ROUTES.MONEY_REQUEST_WAYPOINT, IOU_Send_Enable_Payments: ROUTES.IOU_SEND_ENABLE_PAYMENTS, diff --git a/src/libs/Permissions.js b/src/libs/Permissions.js index f37cd5bb5bf3..52cd91cc072e 100644 --- a/src/libs/Permissions.js +++ b/src/libs/Permissions.js @@ -86,6 +86,14 @@ function canUseCustomStatus(betas) { return _.contains(betas, CONST.BETAS.CUSTOM_STATUS) || canUseAllBetas(betas); } +/** + * @param {Array} betas + * @returns {Boolean} + */ +function canUseNewDotTags(betas) { + return _.contains(betas, CONST.BETAS.NEW_DOT_TAGS) || canUseAllBetas(betas); +} + /** * Link previews are temporarily disabled. * @returns {Boolean} @@ -104,5 +112,6 @@ export default { canUsePolicyRooms, canUseTasks, canUseCustomStatus, + canUseNewDotTags, canUseLinkPreviews, }; diff --git a/src/pages/iou/MoneyRequestTagPage.js b/src/pages/iou/MoneyRequestTagPage.js new file mode 100644 index 000000000000..fa1f2e886521 --- /dev/null +++ b/src/pages/iou/MoneyRequestTagPage.js @@ -0,0 +1,74 @@ +import React from 'react'; +import PropTypes from 'prop-types'; +import lodashGet from 'lodash/get'; +import {withOnyx} from 'react-native-onyx'; +import ROUTES from '../../ROUTES'; +import Navigation from '../../libs/Navigation/Navigation'; +import useLocalize from '../../hooks/useLocalize'; +import ScreenWrapper from '../../components/ScreenWrapper'; +import HeaderWithBackButton from '../../components/HeaderWithBackButton'; +import TagPicker from '../../components/TagPicker'; +import Text from '../../components/Text'; +import ONYXKEYS from '../../ONYXKEYS'; +import reportPropTypes from '../reportPropTypes'; +import styles from '../../styles/styles'; + +const propTypes = { + /** Navigation route context info provided by react navigation */ + route: PropTypes.shape({ + /** Route specific parameters used on this screen via route :iouType/new/tag/:reportID? */ + params: PropTypes.shape({ + /** The type of IOU report, i.e. bill, request, send */ + iouType: PropTypes.string, + + /** The report ID of the IOU */ + reportID: PropTypes.string, + }), + }).isRequired, + + /** The report currently being used */ + report: reportPropTypes, +}; + +const defaultProps = { + report: {}, +}; + +function MoneyRequestTagPage({route, report}) { + const {translate} = useLocalize(); + + const reportID = lodashGet(route, 'params.reportID', ''); + const iouType = lodashGet(route, 'params.iouType', ''); + + const navigateBack = () => { + Navigation.goBack(ROUTES.getMoneyRequestConfirmationRoute(iouType, reportID)); + }; + + return ( + + + {translate('iou.tagSelection')} + + + ); +} + +MoneyRequestTagPage.displayName = 'MoneyRequestTagPage'; +MoneyRequestTagPage.propTypes = propTypes; +MoneyRequestTagPage.defaultProps = defaultProps; + +export default withOnyx({ + report: { + key: ({route}) => `${ONYXKEYS.COLLECTION.REPORT}${lodashGet(route, 'params.reportID', '')}`, + }, +})(MoneyRequestTagPage); From 6e6ec88de33b64e9657e64a3ca6055301c4034c7 Mon Sep 17 00:00:00 2001 From: Ana Margarida Silva Date: Thu, 7 Sep 2023 11:31:48 +0100 Subject: [PATCH 208/284] feat: pass IOU tag to confirmation list --- src/pages/iou/steps/MoneyRequestConfirmPage.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pages/iou/steps/MoneyRequestConfirmPage.js b/src/pages/iou/steps/MoneyRequestConfirmPage.js index 178179f31745..bcc089adb236 100644 --- a/src/pages/iou/steps/MoneyRequestConfirmPage.js +++ b/src/pages/iou/steps/MoneyRequestConfirmPage.js @@ -272,6 +272,7 @@ function MoneyRequestConfirmPage(props) { iouAmount={props.iou.amount} iouComment={props.iou.comment} iouCurrencyCode={props.iou.currency} + iouTag={props.iou.tag} onConfirm={createTransaction} onSendMoney={sendMoney} onSelectParticipant={(option) => { From 412e191afc4ec94f60ed48d682f98b25e8e0f2c6 Mon Sep 17 00:00:00 2001 From: Ana Margarida Silva Date: Thu, 7 Sep 2023 12:29:55 +0100 Subject: [PATCH 209/284] feat: fetch reportID from IOU participants --- .../TagPicker/tagPickerPropTypes.js | 7 ++--- src/pages/iou/MoneyRequestTagPage.js | 30 ++++++++++++++----- src/pages/iou/propTypes/index.js | 4 +++ 3 files changed, 29 insertions(+), 12 deletions(-) diff --git a/src/components/TagPicker/tagPickerPropTypes.js b/src/components/TagPicker/tagPickerPropTypes.js index fb3942d94c80..d1705670fc0b 100644 --- a/src/components/TagPicker/tagPickerPropTypes.js +++ b/src/components/TagPicker/tagPickerPropTypes.js @@ -1,5 +1,6 @@ import PropTypes from 'prop-types'; import tagPropTypes from '../tagPropTypes'; +import {iouPropTypes, iouDefaultProps} from '../../pages/iou/propTypes'; const propTypes = { /** The report ID of the IOU */ @@ -24,16 +25,14 @@ const propTypes = { /* Onyx Props */ /** Holds data related to Money Request view state, rather than the underlying Money Request data. */ - iou: PropTypes.shape({ - tag: PropTypes.string, - }), + iou: iouPropTypes, }; const defaultProps = { policyID: '', policyTags: {}, recentlyUsedPolicyTags: [], - iou: {}, + iou: iouDefaultProps, }; export {propTypes, defaultProps}; diff --git a/src/pages/iou/MoneyRequestTagPage.js b/src/pages/iou/MoneyRequestTagPage.js index fa1f2e886521..d7562a140468 100644 --- a/src/pages/iou/MoneyRequestTagPage.js +++ b/src/pages/iou/MoneyRequestTagPage.js @@ -2,6 +2,7 @@ import React from 'react'; import PropTypes from 'prop-types'; import lodashGet from 'lodash/get'; import {withOnyx} from 'react-native-onyx'; +import compose from '../../libs/compose'; import ROUTES from '../../ROUTES'; import Navigation from '../../libs/Navigation/Navigation'; import useLocalize from '../../hooks/useLocalize'; @@ -12,6 +13,7 @@ import Text from '../../components/Text'; import ONYXKEYS from '../../ONYXKEYS'; import reportPropTypes from '../reportPropTypes'; import styles from '../../styles/styles'; +import {iouPropTypes, iouDefaultProps} from './propTypes'; const propTypes = { /** Navigation route context info provided by react navigation */ @@ -28,20 +30,24 @@ const propTypes = { /** The report currently being used */ report: reportPropTypes, + + /* Onyx Props */ + /** Holds data related to Money Request view state, rather than the underlying Money Request data. */ + iou: iouPropTypes, }; const defaultProps = { report: {}, + iou: iouDefaultProps, }; function MoneyRequestTagPage({route, report}) { const {translate} = useLocalize(); - const reportID = lodashGet(route, 'params.reportID', ''); const iouType = lodashGet(route, 'params.iouType', ''); const navigateBack = () => { - Navigation.goBack(ROUTES.getMoneyRequestConfirmationRoute(iouType, reportID)); + Navigation.goBack(ROUTES.getMoneyRequestConfirmationRoute(iouType, report.reportID)); }; return ( @@ -56,7 +62,7 @@ function MoneyRequestTagPage({route, report}) { {translate('iou.tagSelection')} @@ -67,8 +73,16 @@ MoneyRequestTagPage.displayName = 'MoneyRequestTagPage'; MoneyRequestTagPage.propTypes = propTypes; MoneyRequestTagPage.defaultProps = defaultProps; -export default withOnyx({ - report: { - key: ({route}) => `${ONYXKEYS.COLLECTION.REPORT}${lodashGet(route, 'params.reportID', '')}`, - }, -})(MoneyRequestTagPage); +export default compose( + withOnyx({ + iou: { + key: ONYXKEYS.IOU, + }, + }), + withOnyx({ + report: { + // Fetch report ID from IOU participants if no report ID is set in route + key: ({route, iou}) => `${ONYXKEYS.COLLECTION.REPORT}${lodashGet(route, 'params.reportID', '') || lodashGet(iou, 'participants.0.reportID', '')}`, + }, + }), +)(MoneyRequestTagPage); diff --git a/src/pages/iou/propTypes/index.js b/src/pages/iou/propTypes/index.js index c7559323ebc1..5ecd00d11876 100644 --- a/src/pages/iou/propTypes/index.js +++ b/src/pages/iou/propTypes/index.js @@ -18,6 +18,9 @@ const iouPropTypes = PropTypes.shape({ /** The merchant name */ merchant: PropTypes.string, + /** The tag */ + tag: PropTypes.string, + /** Date that the request was created */ created: PropTypes.string, @@ -34,6 +37,7 @@ const iouDefaultProps = { currency: CONST.CURRENCY.USD, comment: '', merchant: '', + tag: '', created: '', participants: [], receiptPath: '', From e2cf2b568611e0abfbb5e1b15055e802525c5c22 Mon Sep 17 00:00:00 2001 From: Ana Margarida Silva Date: Thu, 7 Sep 2023 13:35:32 +0100 Subject: [PATCH 210/284] feat: add missing translation --- src/languages/es.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/languages/es.ts b/src/languages/es.ts index 5387c33d1939..2e2cfd164a6a 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -527,7 +527,7 @@ export default { pendingConversionMessage: 'El total se actualizará cuando estés online', threadRequestReportName: ({formattedAmount, comment}: ThreadRequestReportNameParams) => `Solicitud de ${formattedAmount}${comment ? ` para ${comment}` : ''}`, threadSentMoneyReportName: ({formattedAmount, comment}: ThreadSentMoneyReportNameParams) => `${formattedAmount} enviado${comment ? ` para ${comment}` : ''}`, - tagSelection: '', + tagSelection: 'Seleccione una etiqueta para agregar una organización adicional a tu dinero.', error: { invalidSplit: 'La suma de las partes no equivale al monto total', other: 'Error inesperado, por favor inténtalo más tarde', From 7aca47c3b9daa0aa9d3918553b88770c92859604 Mon Sep 17 00:00:00 2001 From: Ana Margarida Silva Date: Thu, 7 Sep 2023 13:37:47 +0100 Subject: [PATCH 211/284] fix: small typo --- src/components/MoneyRequestConfirmationList.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/MoneyRequestConfirmationList.js b/src/components/MoneyRequestConfirmationList.js index ea2e213b4c26..0e28939eaece 100755 --- a/src/components/MoneyRequestConfirmationList.js +++ b/src/components/MoneyRequestConfirmationList.js @@ -187,7 +187,7 @@ function MoneyRequestConfirmationList(props) { const distance = lodashGet(transaction, 'routes.route0.distance', 0); const shouldCalculateDistanceAmount = props.isDistanceRequest && props.iouAmount === 0; const shouldCategoryEditable = !_.isEmpty(props.policyCategories) && !props.isDistanceRequest; - const shouldTagsBeEditable = !_.isEmpty(props.policyTags) && Permissions.canUseNewDotTags(props.betas); + const shouldTagBeEditable = !_.isEmpty(props.policyTags) && Permissions.canUseNewDotTags(props.betas); const formattedAmount = CurrencyUtils.convertToDisplayString( shouldCalculateDistanceAmount ? DistanceRequestUtils.getDistanceRequestAmount(distance, unit, rate) : props.iouAmount, @@ -510,7 +510,7 @@ function MoneyRequestConfirmationList(props) { disabled={didConfirm || props.isReadOnly} /> )} - {shouldTagsBeEditable && ( + {shouldTagBeEditable && ( Date: Thu, 7 Sep 2023 13:54:29 +0100 Subject: [PATCH 212/284] fix: lint errors --- src/pages/iou/MoneyRequestTagPage.js | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/pages/iou/MoneyRequestTagPage.js b/src/pages/iou/MoneyRequestTagPage.js index d7562a140468..f02164e77b65 100644 --- a/src/pages/iou/MoneyRequestTagPage.js +++ b/src/pages/iou/MoneyRequestTagPage.js @@ -13,7 +13,6 @@ import Text from '../../components/Text'; import ONYXKEYS from '../../ONYXKEYS'; import reportPropTypes from '../reportPropTypes'; import styles from '../../styles/styles'; -import {iouPropTypes, iouDefaultProps} from './propTypes'; const propTypes = { /** Navigation route context info provided by react navigation */ @@ -30,15 +29,10 @@ const propTypes = { /** The report currently being used */ report: reportPropTypes, - - /* Onyx Props */ - /** Holds data related to Money Request view state, rather than the underlying Money Request data. */ - iou: iouPropTypes, }; const defaultProps = { report: {}, - iou: iouDefaultProps, }; function MoneyRequestTagPage({route, report}) { From 1c219a24382d80d41745cf83c45c6cf476af8e61 Mon Sep 17 00:00:00 2001 From: Bartosz Grajdek Date: Thu, 7 Sep 2023 15:01:27 +0200 Subject: [PATCH 213/284] [TS migration] Migrate 'Modal.js' lib to TypeScript --- src/libs/actions/{Modal.js => Modal.ts} | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) rename src/libs/actions/{Modal.js => Modal.ts} (74%) diff --git a/src/libs/actions/Modal.js b/src/libs/actions/Modal.ts similarity index 74% rename from src/libs/actions/Modal.js rename to src/libs/actions/Modal.ts index ea3bfc351593..c5dd878ed1b7 100644 --- a/src/libs/actions/Modal.js +++ b/src/libs/actions/Modal.ts @@ -1,25 +1,20 @@ import Onyx from 'react-native-onyx'; import ONYXKEYS from '../../ONYXKEYS'; -let closeModal; -let onModalClose; +let closeModal: (isNavigating: boolean) => void; +let onModalClose: null | (() => void); /** * Allows other parts of the app to call modal close function - * - * @param {Function} [onClose] */ -function setCloseModal(onClose) { +function setCloseModal(onClose: () => void): void { closeModal = onClose; } /** * Close modal in other parts of the app - * - * @param {Function} [onModalCloseCallback] - * @param {Boolean} isNavigating */ -function close(onModalCloseCallback, isNavigating = true) { +function close(onModalCloseCallback: () => void, isNavigating = true) { if (!closeModal) { // If modal is already closed, no need to wait for modal close. So immediately call callback. if (onModalCloseCallback) { @@ -42,20 +37,16 @@ function onModalDidClose() { /** * Allows other parts of the app to know when a modal has been opened or closed - * - * @param {Boolean} isVisible */ -function setModalVisibility(isVisible) { +function setModalVisibility(isVisible: boolean): void { Onyx.merge(ONYXKEYS.MODAL, {isVisible}); } /** * Allows other parts of app to know that an alert modal is about to open. * This will trigger as soon as a modal is opened but not yet visible while animation is running. - * - * @param {Boolean} isVisible */ -function willAlertModalBecomeVisible(isVisible) { +function willAlertModalBecomeVisible(isVisible: boolean): void { Onyx.merge(ONYXKEYS.MODAL, {willAlertModalBecomeVisible: isVisible}); } From 51b6979b4ce37ee859af5d9c0cea9f5d78c787ee Mon Sep 17 00:00:00 2001 From: Ana Margarida Silva Date: Thu, 7 Sep 2023 17:03:54 +0100 Subject: [PATCH 214/284] docs: add missing comment for recently used tags of a policy --- src/ONYXKEYS.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ONYXKEYS.ts b/src/ONYXKEYS.ts index d8d584df18bf..342e69a77dfe 100755 --- a/src/ONYXKEYS.ts +++ b/src/ONYXKEYS.ts @@ -236,6 +236,7 @@ const ONYXKEYS = { // Max width supported for HTML element MAX_CANVAS_WIDTH: 'maxCanvasWidth', + // A list of recently used tags of a policy RECENTLY_USED_POLICY_TAGS: 'recentlyUsedPolicyTags_', /** Collection Keys */ From 87923822b0ca1008fe00a1ada328d68edcedaa54 Mon Sep 17 00:00:00 2001 From: pradeepkumar Date: Wed, 6 Sep 2023 11:02:01 +0530 Subject: [PATCH 215/284] adding condition --- src/libs/isReportMessageAttachment.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/libs/isReportMessageAttachment.ts b/src/libs/isReportMessageAttachment.ts index 3f9e9d2de201..98aebefe947d 100644 --- a/src/libs/isReportMessageAttachment.ts +++ b/src/libs/isReportMessageAttachment.ts @@ -13,14 +13,15 @@ type IsReportMessageAttachmentParams = { * @param reportActionMessage report action's message as text, html and translationKey */ export default function isReportMessageAttachment({text, html, translationKey}: IsReportMessageAttachmentParams): boolean { - if (translationKey) { - return translationKey === CONST.TRANSLATION_KEYS.ATTACHMENT; - } if (!text || !html) { return false; } + if (translationKey && text === CONST.ATTACHMENT_MESSAGE_TEXT) { + return translationKey === CONST.TRANSLATION_KEYS.ATTACHMENT; + } + const regex = new RegExp(` ${CONST.ATTACHMENT_SOURCE_ATTRIBUTE}="(.*)"`, 'i'); return text === CONST.ATTACHMENT_MESSAGE_TEXT && (!!html.match(regex) || html === CONST.ATTACHMENT_UPLOADING_MESSAGE_HTML); } From 00718d8c315263a0b11242c7a3ec36cae5dd80f4 Mon Sep 17 00:00:00 2001 From: pradeepkumar Date: Fri, 8 Sep 2023 09:17:04 +0530 Subject: [PATCH 216/284] fix conflicts --- src/libs/isReportMessageAttachment.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libs/isReportMessageAttachment.ts b/src/libs/isReportMessageAttachment.ts index 98aebefe947d..c257e1db4191 100644 --- a/src/libs/isReportMessageAttachment.ts +++ b/src/libs/isReportMessageAttachment.ts @@ -13,7 +13,6 @@ type IsReportMessageAttachmentParams = { * @param reportActionMessage report action's message as text, html and translationKey */ export default function isReportMessageAttachment({text, html, translationKey}: IsReportMessageAttachmentParams): boolean { - if (!text || !html) { return false; } From 9c141b70d0781391e37d4083be72e3d9f4c4f294 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Fri, 8 Sep 2023 16:21:13 +0700 Subject: [PATCH 217/284] add margin left to green dot icon --- src/components/LHNOptionsList/OptionRowLHN.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/components/LHNOptionsList/OptionRowLHN.js b/src/components/LHNOptionsList/OptionRowLHN.js index 95b1fc0f801e..c3d91cb31cfe 100644 --- a/src/components/LHNOptionsList/OptionRowLHN.js +++ b/src/components/LHNOptionsList/OptionRowLHN.js @@ -256,10 +256,12 @@ function OptionRowLHN(props) { accessible={false} > {shouldShowGreenDotIndicator && ( - + + + )} {optionItem.hasDraftComment && optionItem.isAllowedToComment && ( Date: Fri, 8 Sep 2023 11:05:16 +0100 Subject: [PATCH 218/284] feat: add type and change collection key according to category --- src/ONYXKEYS.ts | 5 ++--- src/components/TagPicker/index.js | 4 ++-- src/components/TagPicker/tagPickerPropTypes.js | 4 ++-- src/types/onyx/RecentlyUsedTags.ts | 3 +++ src/types/onyx/index.ts | 2 ++ 5 files changed, 11 insertions(+), 7 deletions(-) create mode 100644 src/types/onyx/RecentlyUsedTags.ts diff --git a/src/ONYXKEYS.ts b/src/ONYXKEYS.ts index 342e69a77dfe..a34b53f6c7ef 100755 --- a/src/ONYXKEYS.ts +++ b/src/ONYXKEYS.ts @@ -236,9 +236,6 @@ const ONYXKEYS = { // Max width supported for HTML element MAX_CANVAS_WIDTH: 'maxCanvasWidth', - // A list of recently used tags of a policy - RECENTLY_USED_POLICY_TAGS: 'recentlyUsedPolicyTags_', - /** Collection Keys */ COLLECTION: { DOWNLOAD: 'download_', @@ -257,6 +254,7 @@ const ONYXKEYS = { REPORT_USER_IS_TYPING: 'reportUserIsTyping_', SECURITY_GROUP: 'securityGroup_', TRANSACTION: 'transactions_', + POLICY_RECENTLY_USED_TAGS: 'policyRecentlyUsedTags_', /** This is deprecated, but needed for a migration, so we still need to include it here so that it will be initialized in Onyx.init */ DEPRECATED_POLICY_MEMBER_LIST: 'policyMemberList_', @@ -393,6 +391,7 @@ type OnyxValues = { [ONYXKEYS.COLLECTION.REPORT_USER_IS_TYPING]: boolean; [ONYXKEYS.COLLECTION.SECURITY_GROUP]: OnyxTypes.SecurityGroup; [ONYXKEYS.COLLECTION.TRANSACTION]: OnyxTypes.Transaction; + [ONYXKEYS.COLLECTION.POLICY_RECENTLY_USED_TAGS]: OnyxTypes.RecentlyUsedTags; // Forms [ONYXKEYS.FORMS.ADD_DEBIT_CARD_FORM]: OnyxTypes.AddDebitCardForm; diff --git a/src/components/TagPicker/index.js b/src/components/TagPicker/index.js index 61856c1033cc..daa26ca9d58c 100644 --- a/src/components/TagPicker/index.js +++ b/src/components/TagPicker/index.js @@ -81,8 +81,8 @@ export default withOnyx({ policyTags: { key: ({policyID}) => `${ONYXKEYS.COLLECTION.POLICY_TAGS}${policyID}`, }, - recentlyUsedPolicyTags: { - key: ({policyID}) => `${ONYXKEYS.RECENTLY_USED_POLICY_TAGS}${policyID}`, + policyRecentlyUsedTags: { + key: ({policyID}) => `${ONYXKEYS.COLLECTION.POLICY_RECENTLY_USED_TAGS}${policyID}`, }, iou: { key: ONYXKEYS.IOU, diff --git a/src/components/TagPicker/tagPickerPropTypes.js b/src/components/TagPicker/tagPickerPropTypes.js index d1705670fc0b..34353cb81f97 100644 --- a/src/components/TagPicker/tagPickerPropTypes.js +++ b/src/components/TagPicker/tagPickerPropTypes.js @@ -21,7 +21,7 @@ const propTypes = { /* Onyx Props */ /** List of recently used tags */ - recentlyUsedPolicyTags: PropTypes.arrayOf(PropTypes.string), + policyRecentlyUsedTags: PropTypes.arrayOf(PropTypes.string), /* Onyx Props */ /** Holds data related to Money Request view state, rather than the underlying Money Request data. */ @@ -31,7 +31,7 @@ const propTypes = { const defaultProps = { policyID: '', policyTags: {}, - recentlyUsedPolicyTags: [], + policyRecentlyUsedTags: [], iou: iouDefaultProps, }; diff --git a/src/types/onyx/RecentlyUsedTags.ts b/src/types/onyx/RecentlyUsedTags.ts new file mode 100644 index 000000000000..1f593b10ecbc --- /dev/null +++ b/src/types/onyx/RecentlyUsedTags.ts @@ -0,0 +1,3 @@ +type RecentlyUsedTags = string[]; + +export default RecentlyUsedTags; diff --git a/src/types/onyx/index.ts b/src/types/onyx/index.ts index 039448fac531..66e5ee5fc979 100644 --- a/src/types/onyx/index.ts +++ b/src/types/onyx/index.ts @@ -43,6 +43,7 @@ import SecurityGroup from './SecurityGroup'; import Transaction from './Transaction'; import Form, {AddDebitCardForm} from './Form'; import RecentWaypoints from './RecentWaypoints'; +import RecentlyUsedTags from './RecentlyUsedTags'; export type { Account, @@ -91,4 +92,5 @@ export type { Form, AddDebitCardForm, RecentWaypoints, + RecentlyUsedTags, }; From 68a389320d416c00c30803eead2e33323dfeb59d Mon Sep 17 00:00:00 2001 From: Ana Margarida Silva Date: Fri, 8 Sep 2023 11:38:18 +0100 Subject: [PATCH 219/284] refactor: rename method --- src/components/MoneyRequestConfirmationList.js | 2 +- src/libs/Permissions.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/MoneyRequestConfirmationList.js b/src/components/MoneyRequestConfirmationList.js index 0e28939eaece..0fd1966445c3 100755 --- a/src/components/MoneyRequestConfirmationList.js +++ b/src/components/MoneyRequestConfirmationList.js @@ -187,7 +187,7 @@ function MoneyRequestConfirmationList(props) { const distance = lodashGet(transaction, 'routes.route0.distance', 0); const shouldCalculateDistanceAmount = props.isDistanceRequest && props.iouAmount === 0; const shouldCategoryEditable = !_.isEmpty(props.policyCategories) && !props.isDistanceRequest; - const shouldTagBeEditable = !_.isEmpty(props.policyTags) && Permissions.canUseNewDotTags(props.betas); + const shouldTagBeEditable = !_.isEmpty(props.policyTags) && Permissions.canUseTags(props.betas); const formattedAmount = CurrencyUtils.convertToDisplayString( shouldCalculateDistanceAmount ? DistanceRequestUtils.getDistanceRequestAmount(distance, unit, rate) : props.iouAmount, diff --git a/src/libs/Permissions.js b/src/libs/Permissions.js index 52cd91cc072e..37892552f037 100644 --- a/src/libs/Permissions.js +++ b/src/libs/Permissions.js @@ -90,7 +90,7 @@ function canUseCustomStatus(betas) { * @param {Array} betas * @returns {Boolean} */ -function canUseNewDotTags(betas) { +function canUseTags(betas) { return _.contains(betas, CONST.BETAS.NEW_DOT_TAGS) || canUseAllBetas(betas); } @@ -112,6 +112,6 @@ export default { canUsePolicyRooms, canUseTasks, canUseCustomStatus, - canUseNewDotTags, + canUseTags, canUseLinkPreviews, }; From acb16e3aa92fc0ee503b78f2af3969492e60c9d7 Mon Sep 17 00:00:00 2001 From: Bartosz Grajdek Date: Sun, 10 Sep 2023 22:21:44 +0200 Subject: [PATCH 220/284] [TS migration] Migrate 'CurrentDate.js' lib to TypeScript --- src/libs/actions/{CurrentDate.js => CurrentDate.ts} | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) rename src/libs/actions/{CurrentDate.js => CurrentDate.ts} (74%) diff --git a/src/libs/actions/CurrentDate.js b/src/libs/actions/CurrentDate.ts similarity index 74% rename from src/libs/actions/CurrentDate.js rename to src/libs/actions/CurrentDate.ts index 078b35a760cb..7554fb16ea8f 100644 --- a/src/libs/actions/CurrentDate.js +++ b/src/libs/actions/CurrentDate.ts @@ -1,10 +1,7 @@ import Onyx from 'react-native-onyx'; import ONYXKEYS from '../../ONYXKEYS'; -/** - * @param {String} currentDate - */ -function setCurrentDate(currentDate) { +function setCurrentDate(currentDate: string): void { Onyx.set(ONYXKEYS.CURRENT_DATE, currentDate); } From b2fe4f48311e3d3929b6d02201e47df9ed09b059 Mon Sep 17 00:00:00 2001 From: Oscar Franco Date: Mon, 11 Sep 2023 10:17:13 +0200 Subject: [PATCH 221/284] Update Onyx --- package-lock.json | 14 +++++++------- package.json | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index cd763dffefbe..644b1dfaf239 100644 --- a/package-lock.json +++ b/package-lock.json @@ -85,7 +85,7 @@ "react-native-linear-gradient": "^2.8.1", "react-native-localize": "^2.2.6", "react-native-modal": "^13.0.0", - "react-native-onyx": "1.0.72", + "react-native-onyx": "1.0.74", "react-native-pager-view": "^6.2.0", "react-native-pdf": "^6.7.1", "react-native-performance": "^4.0.0", @@ -40884,9 +40884,9 @@ } }, "node_modules/react-native-onyx": { - "version": "1.0.72", - "resolved": "https://registry.npmjs.org/react-native-onyx/-/react-native-onyx-1.0.72.tgz", - "integrity": "sha512-roJuA92qZH2PLYSqBhSPCse+Ra2EJu4FBpVqguwJRp6oaLNHR1CtPTgU1xMh/kj2nWmdpcqKoOc3nS35asb80g==", + "version": "1.0.74", + "resolved": "https://registry.npmjs.org/react-native-onyx/-/react-native-onyx-1.0.74.tgz", + "integrity": "sha512-JunRuenpY3XuX0/kKyU4jEf4gbba4PHckuCd58yQsQSoCQdBBRHNqSH5Cdm0dkUO9jj/JOVbQO8SpNMXmMdSZg==", "dependencies": { "ascii-table": "0.0.9", "fast-equals": "^4.0.3", @@ -76679,9 +76679,9 @@ } }, "react-native-onyx": { - "version": "1.0.72", - "resolved": "https://registry.npmjs.org/react-native-onyx/-/react-native-onyx-1.0.72.tgz", - "integrity": "sha512-roJuA92qZH2PLYSqBhSPCse+Ra2EJu4FBpVqguwJRp6oaLNHR1CtPTgU1xMh/kj2nWmdpcqKoOc3nS35asb80g==", + "version": "1.0.74", + "resolved": "https://registry.npmjs.org/react-native-onyx/-/react-native-onyx-1.0.74.tgz", + "integrity": "sha512-JunRuenpY3XuX0/kKyU4jEf4gbba4PHckuCd58yQsQSoCQdBBRHNqSH5Cdm0dkUO9jj/JOVbQO8SpNMXmMdSZg==", "requires": { "ascii-table": "0.0.9", "fast-equals": "^4.0.3", diff --git a/package.json b/package.json index 6666fd19cf7a..d4bf74b4c24a 100644 --- a/package.json +++ b/package.json @@ -125,7 +125,7 @@ "react-native-linear-gradient": "^2.8.1", "react-native-localize": "^2.2.6", "react-native-modal": "^13.0.0", - "react-native-onyx": "1.0.72", + "react-native-onyx": "1.0.74", "react-native-pager-view": "^6.2.0", "react-native-pdf": "^6.7.1", "react-native-performance": "^4.0.0", From b4f8adfcdd0ea7ce2d8199f77f86b108e3828be6 Mon Sep 17 00:00:00 2001 From: Ana Margarida Silva Date: Mon, 11 Sep 2023 09:26:24 +0100 Subject: [PATCH 222/284] fix: review improvements --- .../MoneyRequestConfirmationList.js | 22 +++++++++---------- src/components/TagPicker/index.js | 1 + .../TagPicker/tagPickerPropTypes.js | 2 -- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/src/components/MoneyRequestConfirmationList.js b/src/components/MoneyRequestConfirmationList.js index 0fd1966445c3..f629bbd00038 100755 --- a/src/components/MoneyRequestConfirmationList.js +++ b/src/components/MoneyRequestConfirmationList.js @@ -110,18 +110,6 @@ const propTypes = { /** List styles for OptionsSelector */ listStyles: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.object), PropTypes.object]), - /* Onyx Props */ - /** Collection of categories attached to a policy */ - policyCategories: PropTypes.objectOf(categoryPropTypes), - - /* Onyx Props */ - /** Collection of tags attached to a policy */ - policyTags: PropTypes.objectOf(tagPropTypes), - - /* Onyx Props */ - /* Beta features list */ - betas: PropTypes.arrayOf(PropTypes.string), - /** ID of the transaction that represents the money request */ transactionID: PropTypes.string, @@ -142,6 +130,16 @@ const propTypes = { /** Whether the money request is a distance request */ isDistanceRequest: PropTypes.bool, + + /* Onyx Props */ + /** Collection of categories attached to a policy */ + policyCategories: PropTypes.objectOf(categoryPropTypes), + + /** Collection of tags attached to a policy */ + policyTags: PropTypes.objectOf(tagPropTypes), + + /* Beta features list */ + betas: PropTypes.arrayOf(PropTypes.string), }; const defaultProps = { diff --git a/src/components/TagPicker/index.js b/src/components/TagPicker/index.js index daa26ca9d58c..215d6f13e3d6 100644 --- a/src/components/TagPicker/index.js +++ b/src/components/TagPicker/index.js @@ -67,6 +67,7 @@ function TagPicker({policyTags, reportID, iouType, iou}) { headerMessage={headerMessage} textInputLabel={translate('common.search')} boldStyle + value={''} onSelectRow={updateTag} shouldShowTextInput={false} /> diff --git a/src/components/TagPicker/tagPickerPropTypes.js b/src/components/TagPicker/tagPickerPropTypes.js index 34353cb81f97..a50beb40ec8b 100644 --- a/src/components/TagPicker/tagPickerPropTypes.js +++ b/src/components/TagPicker/tagPickerPropTypes.js @@ -19,11 +19,9 @@ const propTypes = { /** Collection of tags attached to a policy */ policyTags: PropTypes.objectOf(tagPropTypes), - /* Onyx Props */ /** List of recently used tags */ policyRecentlyUsedTags: PropTypes.arrayOf(PropTypes.string), - /* Onyx Props */ /** Holds data related to Money Request view state, rather than the underlying Money Request data. */ iou: iouPropTypes, }; From cc7d773c997a0ba4f9baa6963d5f22b234964e02 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Mon, 11 Sep 2023 15:36:49 +0700 Subject: [PATCH 223/284] add ability to request money from iou and expense report --- src/libs/ReportUtils.js | 4 ++-- src/libs/actions/IOU.js | 15 ++++++++++----- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index 53423e8deaf2..1129204c65f4 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -3103,8 +3103,8 @@ function getMoneyRequestOptions(report, reportParticipants, betas) { return []; } - // Additional requests should be blocked for money request reports - if (isMoneyRequestReport(report)) { + // Additional requests should be blocked for money request reports if it is approved or reimbursed + if (isMoneyRequestReport(report) && (isReportApproved(report) || isSettled(report.reportID))) { return []; } diff --git a/src/libs/actions/IOU.js b/src/libs/actions/IOU.js index bc7adf47bd8c..b7c31d19a957 100644 --- a/src/libs/actions/IOU.js +++ b/src/libs/actions/IOU.js @@ -562,8 +562,11 @@ function createDistanceRequest(report, participant, comment, created, transactio * @param {Object} [receipt] */ function requestMoney(report, amount, currency, created, merchant, payeeEmail, payeeAccountID, participant, comment, receipt = undefined) { + // If the report is iou or expense report, we should get the chat report of this to pass to getMoneyRequestInformation function + const isMoneyRequestReport = ReportUtils.isMoneyRequestReport(report.reportID); + const currentReport = isMoneyRequestReport ? ReportUtils.getReport(report.chatReportID) : report; const {payerEmail, iouReport, chatReport, transaction, iouAction, createdChatReportActionID, createdIOUReportActionID, reportPreviewAction, onyxData} = getMoneyRequestInformation( - report, + currentReport, participant, comment, amount, @@ -596,7 +599,7 @@ function requestMoney(report, amount, currency, created, merchant, payeeEmail, p onyxData, ); resetMoneyRequestInfo(); - Navigation.dismissModal(chatReport.reportID); + Navigation.dismissModal(isMoneyRequestReport ? report.reportID : chatReport.reportID); Report.notifyNewAction(chatReport.reportID, payeeAccountID); } @@ -1872,12 +1875,14 @@ function navigateToNextPage(iou, iouType, reportID, report) { // If a request is initiated on a report, skip the participants selection step and navigate to the confirmation page. if (report.reportID) { + // If the report is iou or expense report, we should get the chat report to set participant for request money + const chatReport = ReportUtils.isMoneyRequestReport(report.reportID) ? ReportUtils.getReport(report.chatReportID) : report; // Reinitialize the participants when the money request ID in Onyx does not match the ID from params if (_.isEmpty(iou.participants) || shouldReset) { const currentUserAccountID = currentUserPersonalDetails.accountID; - const participants = ReportUtils.isPolicyExpenseChat(report) - ? [{reportID: report.reportID, isPolicyExpenseChat: true, selected: true}] - : _.chain(report.participantAccountIDs) + const participants = ReportUtils.isPolicyExpenseChat(chatReport) + ? [{reportID: chatReport.reportID, isPolicyExpenseChat: true, selected: true}] + : _.chain(chatReport.participantAccountIDs) .filter((accountID) => currentUserAccountID !== accountID) .map((accountID) => ({accountID, selected: true})) .value(); From feb8020dca68a8260f023022cde9204779975f92 Mon Sep 17 00:00:00 2001 From: Ana Margarida Silva Date: Mon, 11 Sep 2023 09:39:06 +0100 Subject: [PATCH 224/284] fix: small lint error --- src/components/TagPicker/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/TagPicker/index.js b/src/components/TagPicker/index.js index 215d6f13e3d6..9b6ad771cea4 100644 --- a/src/components/TagPicker/index.js +++ b/src/components/TagPicker/index.js @@ -67,7 +67,7 @@ function TagPicker({policyTags, reportID, iouType, iou}) { headerMessage={headerMessage} textInputLabel={translate('common.search')} boldStyle - value={''} + value='' onSelectRow={updateTag} shouldShowTextInput={false} /> From 40bd1512980e44bfab17d6fa9713d24336586bd6 Mon Sep 17 00:00:00 2001 From: Ana Margarida Silva Date: Mon, 11 Sep 2023 09:49:08 +0100 Subject: [PATCH 225/284] fix: small linter fix --- src/components/TagPicker/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/TagPicker/index.js b/src/components/TagPicker/index.js index 9b6ad771cea4..225473a46b5f 100644 --- a/src/components/TagPicker/index.js +++ b/src/components/TagPicker/index.js @@ -67,7 +67,7 @@ function TagPicker({policyTags, reportID, iouType, iou}) { headerMessage={headerMessage} textInputLabel={translate('common.search')} boldStyle - value='' + value="" onSelectRow={updateTag} shouldShowTextInput={false} /> From 8badad23c33e68e6a1d2183b862042aec34af44e Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Mon, 11 Sep 2023 15:59:17 +0700 Subject: [PATCH 226/284] use report instead of reportID --- src/libs/actions/IOU.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/actions/IOU.js b/src/libs/actions/IOU.js index b7c31d19a957..75834ce0b1b7 100644 --- a/src/libs/actions/IOU.js +++ b/src/libs/actions/IOU.js @@ -563,7 +563,7 @@ function createDistanceRequest(report, participant, comment, created, transactio */ function requestMoney(report, amount, currency, created, merchant, payeeEmail, payeeAccountID, participant, comment, receipt = undefined) { // If the report is iou or expense report, we should get the chat report of this to pass to getMoneyRequestInformation function - const isMoneyRequestReport = ReportUtils.isMoneyRequestReport(report.reportID); + const isMoneyRequestReport = ReportUtils.isMoneyRequestReport(report); const currentReport = isMoneyRequestReport ? ReportUtils.getReport(report.chatReportID) : report; const {payerEmail, iouReport, chatReport, transaction, iouAction, createdChatReportActionID, createdIOUReportActionID, reportPreviewAction, onyxData} = getMoneyRequestInformation( currentReport, @@ -1876,7 +1876,7 @@ function navigateToNextPage(iou, iouType, reportID, report) { // If a request is initiated on a report, skip the participants selection step and navigate to the confirmation page. if (report.reportID) { // If the report is iou or expense report, we should get the chat report to set participant for request money - const chatReport = ReportUtils.isMoneyRequestReport(report.reportID) ? ReportUtils.getReport(report.chatReportID) : report; + const chatReport = ReportUtils.isMoneyRequestReport(report) ? ReportUtils.getReport(report.chatReportID) : report; // Reinitialize the participants when the money request ID in Onyx does not match the ID from params if (_.isEmpty(iou.participants) || shouldReset) { const currentUserAccountID = currentUserPersonalDetails.accountID; From 919339aacfb722314941755ba9f981e032ac60c0 Mon Sep 17 00:00:00 2001 From: Oscar Franco Date: Mon, 11 Sep 2023 16:22:07 +0200 Subject: [PATCH 227/284] Update onyx dependency --- package-lock.json | 14 +++++++------- package.json | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index 644b1dfaf239..83d7f69f9a44 100644 --- a/package-lock.json +++ b/package-lock.json @@ -85,7 +85,7 @@ "react-native-linear-gradient": "^2.8.1", "react-native-localize": "^2.2.6", "react-native-modal": "^13.0.0", - "react-native-onyx": "1.0.74", + "react-native-onyx": "1.0.75", "react-native-pager-view": "^6.2.0", "react-native-pdf": "^6.7.1", "react-native-performance": "^4.0.0", @@ -40884,9 +40884,9 @@ } }, "node_modules/react-native-onyx": { - "version": "1.0.74", - "resolved": "https://registry.npmjs.org/react-native-onyx/-/react-native-onyx-1.0.74.tgz", - "integrity": "sha512-JunRuenpY3XuX0/kKyU4jEf4gbba4PHckuCd58yQsQSoCQdBBRHNqSH5Cdm0dkUO9jj/JOVbQO8SpNMXmMdSZg==", + "version": "1.0.75", + "resolved": "https://registry.npmjs.org/react-native-onyx/-/react-native-onyx-1.0.75.tgz", + "integrity": "sha512-pcRwQD5FzREg8LoR4pL9FyAUyksULb2QJd95NMBxXwX4ItoxFZrOXYh4CKJBrNJWFYgEmndMW5VPb08iSCTF/w==", "dependencies": { "ascii-table": "0.0.9", "fast-equals": "^4.0.3", @@ -76679,9 +76679,9 @@ } }, "react-native-onyx": { - "version": "1.0.74", - "resolved": "https://registry.npmjs.org/react-native-onyx/-/react-native-onyx-1.0.74.tgz", - "integrity": "sha512-JunRuenpY3XuX0/kKyU4jEf4gbba4PHckuCd58yQsQSoCQdBBRHNqSH5Cdm0dkUO9jj/JOVbQO8SpNMXmMdSZg==", + "version": "1.0.75", + "resolved": "https://registry.npmjs.org/react-native-onyx/-/react-native-onyx-1.0.75.tgz", + "integrity": "sha512-pcRwQD5FzREg8LoR4pL9FyAUyksULb2QJd95NMBxXwX4ItoxFZrOXYh4CKJBrNJWFYgEmndMW5VPb08iSCTF/w==", "requires": { "ascii-table": "0.0.9", "fast-equals": "^4.0.3", diff --git a/package.json b/package.json index d4bf74b4c24a..1cc33eded220 100644 --- a/package.json +++ b/package.json @@ -125,7 +125,7 @@ "react-native-linear-gradient": "^2.8.1", "react-native-localize": "^2.2.6", "react-native-modal": "^13.0.0", - "react-native-onyx": "1.0.74", + "react-native-onyx": "1.0.75", "react-native-pager-view": "^6.2.0", "react-native-pdf": "^6.7.1", "react-native-performance": "^4.0.0", From a2b9e261bb4baf29460c2d40ba8108723adc1d41 Mon Sep 17 00:00:00 2001 From: dukenv0307 <129500732+dukenv0307@users.noreply.github.com> Date: Mon, 11 Sep 2023 22:25:23 +0700 Subject: [PATCH 228/284] Update src/libs/actions/IOU.js Co-authored-by: Vit Horacek <36083550+mountiny@users.noreply.github.com> --- src/libs/actions/IOU.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/actions/IOU.js b/src/libs/actions/IOU.js index 75834ce0b1b7..bb9d19f2a906 100644 --- a/src/libs/actions/IOU.js +++ b/src/libs/actions/IOU.js @@ -562,7 +562,7 @@ function createDistanceRequest(report, participant, comment, created, transactio * @param {Object} [receipt] */ function requestMoney(report, amount, currency, created, merchant, payeeEmail, payeeAccountID, participant, comment, receipt = undefined) { - // If the report is iou or expense report, we should get the chat report of this to pass to getMoneyRequestInformation function + // If the report is iou or expense report, we should get the linked chat report to be passed to the getMoneyRequestInformation function const isMoneyRequestReport = ReportUtils.isMoneyRequestReport(report); const currentReport = isMoneyRequestReport ? ReportUtils.getReport(report.chatReportID) : report; const {payerEmail, iouReport, chatReport, transaction, iouAction, createdChatReportActionID, createdIOUReportActionID, reportPreviewAction, onyxData} = getMoneyRequestInformation( From 65ff2fd281972c91fdef91348a4281e16d1f9b57 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Mon, 11 Sep 2023 22:32:51 +0700 Subject: [PATCH 229/284] rename current report --- src/libs/actions/IOU.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/actions/IOU.js b/src/libs/actions/IOU.js index bb9d19f2a906..47a7b048bc4d 100644 --- a/src/libs/actions/IOU.js +++ b/src/libs/actions/IOU.js @@ -564,9 +564,9 @@ function createDistanceRequest(report, participant, comment, created, transactio function requestMoney(report, amount, currency, created, merchant, payeeEmail, payeeAccountID, participant, comment, receipt = undefined) { // If the report is iou or expense report, we should get the linked chat report to be passed to the getMoneyRequestInformation function const isMoneyRequestReport = ReportUtils.isMoneyRequestReport(report); - const currentReport = isMoneyRequestReport ? ReportUtils.getReport(report.chatReportID) : report; + const currentChatReport = isMoneyRequestReport ? ReportUtils.getReport(report.chatReportID) : report; const {payerEmail, iouReport, chatReport, transaction, iouAction, createdChatReportActionID, createdIOUReportActionID, reportPreviewAction, onyxData} = getMoneyRequestInformation( - currentReport, + currentChatReport, participant, comment, amount, From ba44afa3be9ec49b4c773b5aceac2acad6a44c4b Mon Sep 17 00:00:00 2001 From: tienifr Date: Mon, 11 Sep 2023 23:27:58 +0700 Subject: [PATCH 230/284] fix: incorrect tooltip position when hovering over email --- src/components/UnreadActionIndicator.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/UnreadActionIndicator.js b/src/components/UnreadActionIndicator.js index 5273ab52ec28..8992f21c923a 100755 --- a/src/components/UnreadActionIndicator.js +++ b/src/components/UnreadActionIndicator.js @@ -10,7 +10,7 @@ function UnreadActionIndicator(props) { From 1454d207c695b7dfe79e382c5568e474bcc0a401 Mon Sep 17 00:00:00 2001 From: tienifr Date: Tue, 12 Sep 2023 01:27:47 +0700 Subject: [PATCH 231/284] use pointerEvents prop instead --- src/components/UnreadActionIndicator.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/UnreadActionIndicator.js b/src/components/UnreadActionIndicator.js index 8992f21c923a..ff1090640570 100755 --- a/src/components/UnreadActionIndicator.js +++ b/src/components/UnreadActionIndicator.js @@ -10,7 +10,8 @@ function UnreadActionIndicator(props) { From 3a3b325aacbde0986c955dfc160e84cb5d7cb16d Mon Sep 17 00:00:00 2001 From: Steven KKC Date: Mon, 11 Sep 2023 16:01:40 -0400 Subject: [PATCH 232/284] fix duplicated IOU report --- src/libs/actions/IOU.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/actions/IOU.js b/src/libs/actions/IOU.js index 2102ed9223c8..521892c8f8fa 100644 --- a/src/libs/actions/IOU.js +++ b/src/libs/actions/IOU.js @@ -1053,7 +1053,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 9d23ffbeee01bf47edeb93c23a6bd9b2392fa5d0 Mon Sep 17 00:00:00 2001 From: Sam Hariri <137707942+samh-nl@users.noreply.github.com> Date: Tue, 12 Sep 2023 09:43:51 +0200 Subject: [PATCH 233/284] fix: use more specific popover anchor --- .../Reactions/ReportActionItemEmojiReactions.js | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/components/Reactions/ReportActionItemEmojiReactions.js b/src/components/Reactions/ReportActionItemEmojiReactions.js index ec2755f1a5dd..c1e1764ed9f1 100644 --- a/src/components/Reactions/ReportActionItemEmojiReactions.js +++ b/src/components/Reactions/ReportActionItemEmojiReactions.js @@ -42,7 +42,7 @@ const defaultProps = { function ReportActionItemEmojiReactions(props) { const {reactionListRef} = useContext(ReportScreenContext); - const popoverReactionListAnchor = useRef(null); + const popoverReactionListAnchors = useRef({}); let totalReactionCount = 0; // Each emoji is sorted by the oldest timestamp of user reactions so that they will always appear in the same order for everyone @@ -95,7 +95,7 @@ function ReportActionItemEmojiReactions(props) { }; const onReactionListOpen = (event) => { - reactionListRef.current.showReactionList(event, popoverReactionListAnchor.current, reactionEmojiName, props.reportActionID); + reactionListRef.current.showReactionList(event, popoverReactionListAnchors.current[reactionEmojiName], reactionEmojiName, props.reportActionID); }; return { @@ -112,10 +112,7 @@ function ReportActionItemEmojiReactions(props) { return ( totalReactionCount > 0 && ( - + {_.map(formattedReactions, (reaction) => { if (reaction === null) { return; @@ -135,7 +132,7 @@ function ReportActionItemEmojiReactions(props) { > (popoverReactionListAnchors.current[reaction.reactionEmojiName] = ref)} count={reaction.reactionCount} emojiCodes={reaction.emojiCodes} onPress={reaction.onPress} From 7064b80426de0906b45585f7d3a7ab4a25a87fab Mon Sep 17 00:00:00 2001 From: Bartosz Grajdek Date: Tue, 12 Sep 2023 11:14:54 +0200 Subject: [PATCH 234/284] Remove void return --- src/libs/actions/CurrentDate.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/actions/CurrentDate.ts b/src/libs/actions/CurrentDate.ts index 7554fb16ea8f..b19a3430e96f 100644 --- a/src/libs/actions/CurrentDate.ts +++ b/src/libs/actions/CurrentDate.ts @@ -1,7 +1,7 @@ import Onyx from 'react-native-onyx'; import ONYXKEYS from '../../ONYXKEYS'; -function setCurrentDate(currentDate: string): void { +function setCurrentDate(currentDate: string) { Onyx.set(ONYXKEYS.CURRENT_DATE, currentDate); } From 0224d059481bd1126683ab480c3024d96b59d7e4 Mon Sep 17 00:00:00 2001 From: Bartosz Grajdek Date: Tue, 12 Sep 2023 11:18:07 +0200 Subject: [PATCH 235/284] Remove void return --- src/libs/actions/Modal.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libs/actions/Modal.ts b/src/libs/actions/Modal.ts index c5dd878ed1b7..ff09731f59a7 100644 --- a/src/libs/actions/Modal.ts +++ b/src/libs/actions/Modal.ts @@ -7,7 +7,7 @@ let onModalClose: null | (() => void); /** * Allows other parts of the app to call modal close function */ -function setCloseModal(onClose: () => void): void { +function setCloseModal(onClose: () => void) { closeModal = onClose; } @@ -38,7 +38,7 @@ function onModalDidClose() { /** * Allows other parts of the app to know when a modal has been opened or closed */ -function setModalVisibility(isVisible: boolean): void { +function setModalVisibility(isVisible: boolean) { Onyx.merge(ONYXKEYS.MODAL, {isVisible}); } @@ -46,7 +46,7 @@ function setModalVisibility(isVisible: boolean): void { * Allows other parts of app to know that an alert modal is about to open. * This will trigger as soon as a modal is opened but not yet visible while animation is running. */ -function willAlertModalBecomeVisible(isVisible: boolean): void { +function willAlertModalBecomeVisible(isVisible: boolean) { Onyx.merge(ONYXKEYS.MODAL, {willAlertModalBecomeVisible: isVisible}); } From a30f45c9d5acdf9c33c526df06cc68cc87a9a82e Mon Sep 17 00:00:00 2001 From: Bartosz Grajdek Date: Tue, 12 Sep 2023 11:26:45 +0200 Subject: [PATCH 236/284] Add return type for memoize --- src/libs/LocaleDigitUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/LocaleDigitUtils.ts b/src/libs/LocaleDigitUtils.ts index ac9f84cb2743..e17620aa5427 100644 --- a/src/libs/LocaleDigitUtils.ts +++ b/src/libs/LocaleDigitUtils.ts @@ -8,7 +8,7 @@ const INDEX_DECIMAL = 10; const INDEX_MINUS_SIGN = 11; const INDEX_GROUP = 12; -const getLocaleDigits = _.memoize((locale: string) => { +const getLocaleDigits = _.memoize((locale: string): string[] => { const localeDigits = [...STANDARD_DIGITS]; for (let i = 0; i <= 9; i++) { localeDigits[i] = NumberFormatUtils.format(locale, i); From b7fd43135e54d100da8c7216bf22209c59f1ddf5 Mon Sep 17 00:00:00 2001 From: Ana Margarida Silva Date: Tue, 12 Sep 2023 10:40:52 +0100 Subject: [PATCH 237/284] fix: add missing types and fix proptypes --- src/ONYXKEYS.ts | 1 + .../MoneyRequestConfirmationList.js | 19 ++++++++++++++----- src/pages/iou/MoneyRequestTagPage.js | 2 +- src/types/onyx/PolicyTag.ts | 9 +++++++++ src/types/onyx/RecentlyUsedTags.ts | 2 +- src/types/onyx/index.ts | 2 ++ 6 files changed, 28 insertions(+), 7 deletions(-) create mode 100644 src/types/onyx/PolicyTag.ts diff --git a/src/ONYXKEYS.ts b/src/ONYXKEYS.ts index f5200b42c191..bfe4250fe42c 100755 --- a/src/ONYXKEYS.ts +++ b/src/ONYXKEYS.ts @@ -379,6 +379,7 @@ type OnyxValues = { [ONYXKEYS.COLLECTION.DOWNLOAD]: OnyxTypes.Download; [ONYXKEYS.COLLECTION.POLICY]: OnyxTypes.Policy; [ONYXKEYS.COLLECTION.POLICY_CATEGORIES]: unknown; + [ONYXKEYS.COLLECTION.POLICY_TAGS]: OnyxTypes.PolicyTag; [ONYXKEYS.COLLECTION.POLICY_MEMBERS]: OnyxTypes.PolicyMember; [ONYXKEYS.COLLECTION.POLICY_RECENTLY_USED_CATEGORIES]: OnyxTypes.RecentlyUsedCategories; [ONYXKEYS.COLLECTION.DEPRECATED_POLICY_MEMBER_LIST]: OnyxTypes.PolicyMember; diff --git a/src/components/MoneyRequestConfirmationList.js b/src/components/MoneyRequestConfirmationList.js index f629bbd00038..d4a4ffbe6816 100755 --- a/src/components/MoneyRequestConfirmationList.js +++ b/src/components/MoneyRequestConfirmationList.js @@ -136,7 +136,12 @@ const propTypes = { policyCategories: PropTypes.objectOf(categoryPropTypes), /** Collection of tags attached to a policy */ - policyTags: PropTypes.objectOf(tagPropTypes), + policyTags: PropTypes.objectOf( + PropTypes.shape({ + name: PropTypes.string, + tags: tagPropTypes, + }), + ), /* Beta features list */ betas: PropTypes.arrayOf(PropTypes.string), @@ -185,7 +190,9 @@ function MoneyRequestConfirmationList(props) { const distance = lodashGet(transaction, 'routes.route0.distance', 0); const shouldCalculateDistanceAmount = props.isDistanceRequest && props.iouAmount === 0; const shouldCategoryEditable = !_.isEmpty(props.policyCategories) && !props.isDistanceRequest; - const shouldTagBeEditable = !_.isEmpty(props.policyTags) && Permissions.canUseTags(props.betas); + + const tags = _.keys(props.policyTags); + const canUseTags = Permissions.canUseTags(props.betas); const formattedAmount = CurrencyUtils.convertToDisplayString( shouldCalculateDistanceAmount ? DistanceRequestUtils.getDistanceRequestAmount(distance, unit, rate) : props.iouAmount, @@ -508,16 +515,18 @@ function MoneyRequestConfirmationList(props) { disabled={didConfirm || props.isReadOnly} /> )} - {shouldTagBeEditable && ( + {canUseTags ? _.map(tags, (tag) => ( + !_.isEmpty(tag.tags) && ( Navigation.navigate(ROUTES.getMoneyRequestTagRoute(props.iouType, props.reportID))} style={[styles.moneyRequestMenuItem, styles.mb2]} disabled={didConfirm || props.isReadOnly} /> - )} + ) + )) : null} )} diff --git a/src/pages/iou/MoneyRequestTagPage.js b/src/pages/iou/MoneyRequestTagPage.js index f02164e77b65..dd92d7782cbc 100644 --- a/src/pages/iou/MoneyRequestTagPage.js +++ b/src/pages/iou/MoneyRequestTagPage.js @@ -41,7 +41,7 @@ function MoneyRequestTagPage({route, report}) { const iouType = lodashGet(route, 'params.iouType', ''); const navigateBack = () => { - Navigation.goBack(ROUTES.getMoneyRequestConfirmationRoute(iouType, report.reportID)); + Navigation.goBack(ROUTES.getMoneyRequestConfirmationRoute(iouType, lodashGet(report, 'reportID', ''))); }; return ( diff --git a/src/types/onyx/PolicyTag.ts b/src/types/onyx/PolicyTag.ts new file mode 100644 index 000000000000..baee10d6e0d0 --- /dev/null +++ b/src/types/onyx/PolicyTag.ts @@ -0,0 +1,9 @@ +type PolicyTag = { + /** Name of a Tag */ + name: string; + + /** Flag that determines if a tag is active and able to be selected */ + enabled: boolean; +}; + +export default PolicyTag; diff --git a/src/types/onyx/RecentlyUsedTags.ts b/src/types/onyx/RecentlyUsedTags.ts index 1f593b10ecbc..1d6112514609 100644 --- a/src/types/onyx/RecentlyUsedTags.ts +++ b/src/types/onyx/RecentlyUsedTags.ts @@ -1,3 +1,3 @@ -type RecentlyUsedTags = string[]; +type RecentlyUsedTags = Record; export default RecentlyUsedTags; diff --git a/src/types/onyx/index.ts b/src/types/onyx/index.ts index b40c82b58285..1aa39e879388 100644 --- a/src/types/onyx/index.ts +++ b/src/types/onyx/index.ts @@ -46,6 +46,7 @@ import Form, {AddDebitCardForm} from './Form'; import RecentWaypoints from './RecentWaypoints'; import RecentlyUsedCategories from './RecentlyUsedCategories'; import RecentlyUsedTags from './RecentlyUsedTags'; +import PolicyTag from './PolicyTag'; export type { Account, @@ -97,4 +98,5 @@ export type { RecentWaypoints, RecentlyUsedCategories, RecentlyUsedTags, + PolicyTag, }; From 65a6b4849f7b2af0511c2e61917b646dd88f2491 Mon Sep 17 00:00:00 2001 From: Ana Margarida Silva Date: Tue, 12 Sep 2023 11:41:00 +0100 Subject: [PATCH 238/284] feat: adapt to changes in structure and pass current tag around --- src/ROUTES.ts | 4 +-- .../MoneyRequestConfirmationList.js | 36 +++++++++++-------- src/components/TagPicker/index.js | 21 ++++++----- .../TagPicker/tagPickerPropTypes.js | 15 +++++--- src/languages/en.ts | 3 +- src/languages/es.ts | 3 +- src/languages/types.ts | 3 ++ src/pages/iou/MoneyRequestTagPage.js | 30 +++++++++++++--- src/pages/iou/propTypes/index.js | 4 +-- .../iou/steps/MoneyRequestConfirmPage.js | 2 +- src/types/onyx/IOU.ts | 1 + 11 files changed, 81 insertions(+), 41 deletions(-) diff --git a/src/ROUTES.ts b/src/ROUTES.ts index 6b86d88b31ec..2819740cd963 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -98,7 +98,7 @@ export default { MONEY_REQUEST_CURRENCY: ':iouType/new/currency/:reportID?', MONEY_REQUEST_DESCRIPTION: ':iouType/new/description/:reportID?', MONEY_REQUEST_CATEGORY: ':iouType/new/category/:reportID?', - MONEY_REQUEST_TAG: ':iouType/new/tag/:reportID?', + MONEY_REQUEST_TAG: ':iouType/new/tag/:reportID/:tag?', MONEY_REQUEST_MERCHANT: ':iouType/new/merchant/:reportID?', MONEY_REQUEST_MANUAL_TAB: ':iouType/new/:reportID?/manual', MONEY_REQUEST_SCAN_TAB: ':iouType/new/:reportID?/scan', @@ -118,7 +118,7 @@ export default { getMoneyRequestMerchantRoute: (iouType: string, reportID = '') => `${iouType}/new/merchant/${reportID}`, getMoneyRequestDistanceTabRoute: (iouType: string, reportID = '') => `${iouType}/new/${reportID}/distance`, getMoneyRequestWaypointRoute: (iouType: string, waypointIndex: number) => `${iouType}/new/waypoint/${waypointIndex}`, - getMoneyRequestTagRoute: (iouType: string, reportID = '') => `${iouType}/new/tag/${reportID}`, + getMoneyRequestTagRoute: (iouType: string, reportID = '', tag = '') => `${iouType}/new/tag/${reportID}/${tag}`, SPLIT_BILL_DETAILS: `r/:reportID/split/:reportActionID`, getSplitBillDetailsRoute: (reportID: string, reportActionID: string) => `r/${reportID}/split/${reportActionID}`, getNewTaskRoute: (reportID: string) => `${NEW_TASK}/${reportID}`, diff --git a/src/components/MoneyRequestConfirmationList.js b/src/components/MoneyRequestConfirmationList.js index d4a4ffbe6816..6869f413e900 100755 --- a/src/components/MoneyRequestConfirmationList.js +++ b/src/components/MoneyRequestConfirmationList.js @@ -71,7 +71,7 @@ const propTypes = { iouCategory: PropTypes.string, /** IOU Tag */ - iouTag: PropTypes.string, + iouTags: PropTypes.objectOf(PropTypes.string), /** Selected participants from MoneyRequestModal with login / accountID */ selectedParticipants: PropTypes.arrayOf(optionPropTypes).isRequired, @@ -139,7 +139,7 @@ const propTypes = { policyTags: PropTypes.objectOf( PropTypes.shape({ name: PropTypes.string, - tags: tagPropTypes, + tags: PropTypes.objectOf(tagPropTypes), }), ), @@ -153,6 +153,7 @@ const defaultProps = { onSelectParticipant: () => {}, iouType: CONST.IOU.MONEY_REQUEST_TYPE.REQUEST, iouCategory: '', + iouTags: {}, payeePersonalDetails: null, canModifyParticipants: false, isReadOnly: false, @@ -190,7 +191,7 @@ function MoneyRequestConfirmationList(props) { const distance = lodashGet(transaction, 'routes.route0.distance', 0); const shouldCalculateDistanceAmount = props.isDistanceRequest && props.iouAmount === 0; const shouldCategoryEditable = !_.isEmpty(props.policyCategories) && !props.isDistanceRequest; - + const tags = _.keys(props.policyTags); const canUseTags = Permissions.canUseTags(props.betas); @@ -515,18 +516,23 @@ function MoneyRequestConfirmationList(props) { disabled={didConfirm || props.isReadOnly} /> )} - {canUseTags ? _.map(tags, (tag) => ( - !_.isEmpty(tag.tags) && ( - Navigation.navigate(ROUTES.getMoneyRequestTagRoute(props.iouType, props.reportID))} - style={[styles.moneyRequestMenuItem, styles.mb2]} - disabled={didConfirm || props.isReadOnly} - /> - ) - )) : null} + {canUseTags + ? _.map( + tags, + (tag) => + !_.isEmpty(lodashGet(props.policyTags, [tag, 'tags'], [])) && ( + Navigation.navigate(ROUTES.getMoneyRequestTagRoute(props.iouType, props.reportID, tag))} + style={[styles.moneyRequestMenuItem, styles.mb2]} + disabled={didConfirm || props.isReadOnly} + /> + ), + ) + : null} )} diff --git a/src/components/TagPicker/index.js b/src/components/TagPicker/index.js index 225473a46b5f..cba2ffc3bc15 100644 --- a/src/components/TagPicker/index.js +++ b/src/components/TagPicker/index.js @@ -11,33 +11,32 @@ import * as OptionsListUtils from '../../libs/OptionsListUtils'; import OptionsSelector from '../OptionsSelector'; import {propTypes, defaultProps} from './tagPickerPropTypes'; -function TagPicker({policyTags, reportID, iouType, iou}) { +function TagPicker({policyTags, reportID, tag, iouType, iou}) { const {translate} = useLocalize(); const selectedOptions = useMemo(() => { - if (!iou.tag) { + if (!iou.tags || !iou.tags[tag]) { return []; } return [ { - name: iou.tag, + name: iou.tags[tag], enabled: true, - accountID: null, }, ]; - }, [iou.tag]); + }, [iou.tags, tag]); // Only shows one section, which will be the default behavior if there are // less than 8 policy tags // TODO: support sections with search const sections = useMemo(() => { - const tagList = _.chain(policyTags) + const tagList = _.chain(lodashGet(policyTags, [tag, 'tags'], {})) .values() - .map((tag) => ({ - text: tag.name, - keyForList: tag.name, - tooltipText: tag.name, + .map((t) => ({ + text: t.name, + keyForList: t.name, + tooltipText: t.name, })) .value(); @@ -46,7 +45,7 @@ function TagPicker({policyTags, reportID, iouType, iou}) { data: tagList, }, ]; - }, [policyTags]); + }, [policyTags, tag]); const headerMessage = OptionsListUtils.getHeaderMessage(lodashGet(sections, '[0].data.length', 0) > 0, false, ''); diff --git a/src/components/TagPicker/tagPickerPropTypes.js b/src/components/TagPicker/tagPickerPropTypes.js index a50beb40ec8b..35bfd0891ef6 100644 --- a/src/components/TagPicker/tagPickerPropTypes.js +++ b/src/components/TagPicker/tagPickerPropTypes.js @@ -9,6 +9,9 @@ const propTypes = { /** The policyID we are getting tags for */ policyID: PropTypes.string.isRequired, + /** The policyID we are getting tags for */ + tag: PropTypes.string.isRequired, + /** The type of IOU report, i.e. bill, request, send */ iouType: PropTypes.string.isRequired, @@ -17,19 +20,23 @@ const propTypes = { /* Onyx Props */ /** Collection of tags attached to a policy */ - policyTags: PropTypes.objectOf(tagPropTypes), + policyTags: PropTypes.objectOf( + PropTypes.shape({ + name: PropTypes.string, + tags: PropTypes.objectOf(tagPropTypes), + }), + ), /** List of recently used tags */ - policyRecentlyUsedTags: PropTypes.arrayOf(PropTypes.string), + policyRecentlyUsedTags: PropTypes.objectOf(PropTypes.arrayOf(PropTypes.string)), /** Holds data related to Money Request view state, rather than the underlying Money Request data. */ iou: iouPropTypes, }; const defaultProps = { - policyID: '', policyTags: {}, - policyRecentlyUsedTags: [], + policyRecentlyUsedTags: {}, iou: iouDefaultProps, }; diff --git a/src/languages/en.ts b/src/languages/en.ts index f41c823e66d7..7361ca19146b 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -71,6 +71,7 @@ import type { SetTheRequestParams, UpdatedTheRequestParams, RemovedTheRequestParams, + TagSelectionParams, } from './types'; import * as ReportActionsUtils from '../libs/ReportActionsUtils'; @@ -534,7 +535,7 @@ export default { `changed the ${valueName} to ${newValueToDisplay} (previously ${oldValueToDisplay})`, threadRequestReportName: ({formattedAmount, comment}: ThreadRequestReportNameParams) => `${formattedAmount} request${comment ? ` for ${comment}` : ''}`, threadSentMoneyReportName: ({formattedAmount, comment}: ThreadSentMoneyReportNameParams) => `${formattedAmount} sent${comment ? ` for ${comment}` : ''}`, - tagSelection: 'Select a tag to add additional organization to your money', + tagSelection: ({tagName}: TagSelectionParams) => `Select a ${tagName} to add additional organization to your money`, error: { invalidSplit: 'Split amounts do not equal total amount', other: 'Unexpected error, please try again later', diff --git a/src/languages/es.ts b/src/languages/es.ts index 312b70239970..4d8b102274cd 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -71,6 +71,7 @@ import type { SetTheRequestParams, UpdatedTheRequestParams, RemovedTheRequestParams, + TagSelectionParams, } from './types'; /* eslint-disable max-len */ @@ -536,7 +537,7 @@ export default { `cambío ${valueName === 'comerciante' ? 'el' : 'la'} ${valueName} a ${newValueToDisplay} (previamente ${oldValueToDisplay})`, threadRequestReportName: ({formattedAmount, comment}: ThreadRequestReportNameParams) => `Solicitud de ${formattedAmount}${comment ? ` para ${comment}` : ''}`, threadSentMoneyReportName: ({formattedAmount, comment}: ThreadSentMoneyReportNameParams) => `${formattedAmount} enviado${comment ? ` para ${comment}` : ''}`, - tagSelection: 'Seleccione una etiqueta para agregar una organización adicional a tu dinero.', + tagSelection: ({tagName}: TagSelectionParams) => `Seleccione una ${tagName} para agregar una organización adicional a tu dinero`, error: { invalidSplit: 'La suma de las partes no equivale al monto total', other: 'Error inesperado, por favor inténtalo más tarde', diff --git a/src/languages/types.ts b/src/languages/types.ts index 059d944fd4ba..50533a4a8569 100644 --- a/src/languages/types.ts +++ b/src/languages/types.ts @@ -190,6 +190,8 @@ type RemovedTheRequestParams = {valueName: string; oldValueToDisplay: string}; type UpdatedTheRequestParams = {valueName: string; newValueToDisplay: string; oldValueToDisplay: string}; +type TagSelectionParams = {tagName: string}; + export type { AddressLineParams, CharacterLimitParams, @@ -261,4 +263,5 @@ export type { SetTheRequestParams, UpdatedTheRequestParams, RemovedTheRequestParams, + TagSelectionParams, }; diff --git a/src/pages/iou/MoneyRequestTagPage.js b/src/pages/iou/MoneyRequestTagPage.js index dd92d7782cbc..fba7bb6c1d29 100644 --- a/src/pages/iou/MoneyRequestTagPage.js +++ b/src/pages/iou/MoneyRequestTagPage.js @@ -10,6 +10,7 @@ import ScreenWrapper from '../../components/ScreenWrapper'; import HeaderWithBackButton from '../../components/HeaderWithBackButton'; import TagPicker from '../../components/TagPicker'; import Text from '../../components/Text'; +import tagPropTypes from '../../components/tagPropTypes'; import ONYXKEYS from '../../ONYXKEYS'; import reportPropTypes from '../reportPropTypes'; import styles from '../../styles/styles'; @@ -17,28 +18,43 @@ import styles from '../../styles/styles'; const propTypes = { /** Navigation route context info provided by react navigation */ route: PropTypes.shape({ - /** Route specific parameters used on this screen via route :iouType/new/tag/:reportID? */ + /** Route specific parameters used on this screen via route :iouType/new/tag/:reportID/:tag? */ params: PropTypes.shape({ /** The type of IOU report, i.e. bill, request, send */ iouType: PropTypes.string, /** The report ID of the IOU */ reportID: PropTypes.string, + + /** The tag name of the IOU */ + tag: PropTypes.string, }), }).isRequired, + /* Onyx props */ /** The report currently being used */ report: reportPropTypes, + + /** Collection of tags attached to a policy */ + policyTags: PropTypes.objectOf( + PropTypes.shape({ + name: PropTypes.string, + tags: PropTypes.objectOf(tagPropTypes), + }), + ), }; const defaultProps = { report: {}, + policyTags: {}, }; -function MoneyRequestTagPage({route, report}) { +function MoneyRequestTagPage({route, report, policyTags}) { const {translate} = useLocalize(); const iouType = lodashGet(route, 'params.iouType', ''); + const tag = lodashGet(route, 'params.tag', ''); + const tagName = lodashGet(policyTags, [tag, 'name'], ''); const navigateBack = () => { Navigation.goBack(ROUTES.getMoneyRequestConfirmationRoute(iouType, lodashGet(report, 'reportID', ''))); @@ -50,13 +66,14 @@ function MoneyRequestTagPage({route, report}) { shouldEnableMaxHeight > - {translate('iou.tagSelection')} + {translate('iou.tagSelection', {tagName} || translate('common.tag'))} @@ -79,4 +96,9 @@ export default compose( key: ({route, iou}) => `${ONYXKEYS.COLLECTION.REPORT}${lodashGet(route, 'params.reportID', '') || lodashGet(iou, 'participants.0.reportID', '')}`, }, }), + withOnyx({ + policyTags: { + key: ({report}) => `${ONYXKEYS.COLLECTION.POLICY_TAGS}${report ? report.policyID : '0'}`, + }, + }), )(MoneyRequestTagPage); diff --git a/src/pages/iou/propTypes/index.js b/src/pages/iou/propTypes/index.js index 5ecd00d11876..3ceba7d969d8 100644 --- a/src/pages/iou/propTypes/index.js +++ b/src/pages/iou/propTypes/index.js @@ -19,7 +19,7 @@ const iouPropTypes = PropTypes.shape({ merchant: PropTypes.string, /** The tag */ - tag: PropTypes.string, + tags: PropTypes.objectOf(PropTypes.string), /** Date that the request was created */ created: PropTypes.string, @@ -37,7 +37,7 @@ const iouDefaultProps = { currency: CONST.CURRENCY.USD, comment: '', merchant: '', - tag: '', + tags: {}, created: '', participants: [], receiptPath: '', diff --git a/src/pages/iou/steps/MoneyRequestConfirmPage.js b/src/pages/iou/steps/MoneyRequestConfirmPage.js index bcc089adb236..8edb97b52605 100644 --- a/src/pages/iou/steps/MoneyRequestConfirmPage.js +++ b/src/pages/iou/steps/MoneyRequestConfirmPage.js @@ -272,7 +272,7 @@ function MoneyRequestConfirmPage(props) { iouAmount={props.iou.amount} iouComment={props.iou.comment} iouCurrencyCode={props.iou.currency} - iouTag={props.iou.tag} + iouTags={props.iou.tags} onConfirm={createTransaction} onSendMoney={sendMoney} onSelectParticipant={(option) => { diff --git a/src/types/onyx/IOU.ts b/src/types/onyx/IOU.ts index 66f85c98d70c..8c01081a6482 100644 --- a/src/types/onyx/IOU.ts +++ b/src/types/onyx/IOU.ts @@ -19,6 +19,7 @@ type IOU = { receiptSource?: string; transactionID?: string; participants?: Participant[]; + tags: Record; }; export default IOU; From 42abfa88724e9d8397a14e2d36d541cafdcdded9 Mon Sep 17 00:00:00 2001 From: Oscar Franco Date: Tue, 12 Sep 2023 12:43:17 +0200 Subject: [PATCH 239/284] Update onyx --- package-lock.json | 14 +++++++------- package.json | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index 83d7f69f9a44..a80385277098 100644 --- a/package-lock.json +++ b/package-lock.json @@ -85,7 +85,7 @@ "react-native-linear-gradient": "^2.8.1", "react-native-localize": "^2.2.6", "react-native-modal": "^13.0.0", - "react-native-onyx": "1.0.75", + "react-native-onyx": "1.0.76", "react-native-pager-view": "^6.2.0", "react-native-pdf": "^6.7.1", "react-native-performance": "^4.0.0", @@ -40884,9 +40884,9 @@ } }, "node_modules/react-native-onyx": { - "version": "1.0.75", - "resolved": "https://registry.npmjs.org/react-native-onyx/-/react-native-onyx-1.0.75.tgz", - "integrity": "sha512-pcRwQD5FzREg8LoR4pL9FyAUyksULb2QJd95NMBxXwX4ItoxFZrOXYh4CKJBrNJWFYgEmndMW5VPb08iSCTF/w==", + "version": "1.0.76", + "resolved": "https://registry.npmjs.org/react-native-onyx/-/react-native-onyx-1.0.76.tgz", + "integrity": "sha512-mcMlYQCo1B/kom+4hu7CQKKLwvPFjQAJsVIzV2s9aa8XKNlcnYiJbfuM6RSJ1fFmSIeud4Y66rhv4/oWUkSl5A==", "dependencies": { "ascii-table": "0.0.9", "fast-equals": "^4.0.3", @@ -76679,9 +76679,9 @@ } }, "react-native-onyx": { - "version": "1.0.75", - "resolved": "https://registry.npmjs.org/react-native-onyx/-/react-native-onyx-1.0.75.tgz", - "integrity": "sha512-pcRwQD5FzREg8LoR4pL9FyAUyksULb2QJd95NMBxXwX4ItoxFZrOXYh4CKJBrNJWFYgEmndMW5VPb08iSCTF/w==", + "version": "1.0.76", + "resolved": "https://registry.npmjs.org/react-native-onyx/-/react-native-onyx-1.0.76.tgz", + "integrity": "sha512-mcMlYQCo1B/kom+4hu7CQKKLwvPFjQAJsVIzV2s9aa8XKNlcnYiJbfuM6RSJ1fFmSIeud4Y66rhv4/oWUkSl5A==", "requires": { "ascii-table": "0.0.9", "fast-equals": "^4.0.3", diff --git a/package.json b/package.json index 1cc33eded220..432fff543b89 100644 --- a/package.json +++ b/package.json @@ -125,7 +125,7 @@ "react-native-linear-gradient": "^2.8.1", "react-native-localize": "^2.2.6", "react-native-modal": "^13.0.0", - "react-native-onyx": "1.0.75", + "react-native-onyx": "1.0.76", "react-native-pager-view": "^6.2.0", "react-native-pdf": "^6.7.1", "react-native-performance": "^4.0.0", From 7bf00494529a9b5d7c5f33416cb80d6abf74addf Mon Sep 17 00:00:00 2001 From: Jakub Butkiewicz Date: Tue, 12 Sep 2023 12:51:54 +0200 Subject: [PATCH 240/284] ref: migrate Browser lib to TS --- src/libs/Browser/{index.js => index.ts} | 0 .../Browser/{index.web.js => index.web.ts} | 22 ++++++++----------- 2 files changed, 9 insertions(+), 13 deletions(-) rename src/libs/Browser/{index.js => index.ts} (100%) rename src/libs/Browser/{index.web.js => index.web.ts} (88%) diff --git a/src/libs/Browser/index.js b/src/libs/Browser/index.ts similarity index 100% rename from src/libs/Browser/index.js rename to src/libs/Browser/index.ts diff --git a/src/libs/Browser/index.web.js b/src/libs/Browser/index.web.ts similarity index 88% rename from src/libs/Browser/index.web.js rename to src/libs/Browser/index.web.ts index 32f6392aef76..9f193062aa16 100644 --- a/src/libs/Browser/index.web.js +++ b/src/libs/Browser/index.web.ts @@ -5,12 +5,12 @@ import ROUTES from '../../ROUTES'; /** * Fetch browser name from UA string * - * @return {String} e.g. Chrome */ -function getBrowser() { +function getBrowser(): string { const {userAgent} = window.navigator; - let match = userAgent.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))/i) || []; - let temp; + const match = userAgent.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))/i) ?? []; + let temp: RegExpMatchArray | null; + let browserName = ''; if (/trident/i.test(match[1])) { return 'IE'; @@ -28,15 +28,14 @@ function getBrowser() { } } - match = match[1] ? match[1] : navigator.appName; - return match ? match.toLowerCase() : CONST.BROWSER.OTHER; + browserName = match[1] ? match[1] : navigator.appName; + return browserName ? browserName.toLowerCase() : CONST.BROWSER.OTHER; } /** * Whether the platform is a mobile browser. * https://developer.mozilla.org/en-US/docs/Web/HTTP/Browser_detection_using_the_user_agent * - * @returns {Boolean} */ function isMobile() { return /Android|webOS|iPhone|iPad|iPod|BlackBerry|BB|PlayBook|IEMobile|Windows Phone|Silk|Opera Mini/i.test(navigator.userAgent); @@ -45,7 +44,6 @@ function isMobile() { /** * Checks if requesting user agent is Safari browser on a mobile device * - * @returns {Boolean} */ function isMobileSafari() { const userAgent = navigator.userAgent; @@ -55,7 +53,6 @@ function isMobileSafari() { /** * Checks if requesting user agent is Chrome browser on a mobile device * - * @returns {Boolean} */ function isMobileChrome() { const userAgent = navigator.userAgent; @@ -68,8 +65,6 @@ function isSafari() { /** * The session information needs to be passed to the Desktop app, and the only way to do that is by using query params. There is no other way to transfer the data. - * @param {String} shortLivedAuthToken - * @param {String} email */ function openRouteInDesktopApp(shortLivedAuthToken = '', email = '') { const params = new URLSearchParams(); @@ -95,8 +90,9 @@ function openRouteInDesktopApp(shortLivedAuthToken = '', email = '') { const iframe = document.createElement('iframe'); iframe.style.display = 'none'; document.body.appendChild(iframe); - iframe.contentWindow.location.href = expensifyDeeplinkUrl; - + if (iframe.contentWindow) { + iframe.contentWindow.location.href = expensifyDeeplinkUrl; + } // Since we're creating an iframe for Safari to handle deeplink, // we need to give Safari some time to open the pop-up window. // After that we can just remove the iframe. From 650f42aa95f298b0cae14a300216981dd5d6d5f7 Mon Sep 17 00:00:00 2001 From: Blazej Kustra Date: Tue, 12 Sep 2023 14:29:20 +0200 Subject: [PATCH 241/284] [TS migration] Migrate 'addEncryptedAuthTokenToURL.js' lib to TypeScript --- ...tedAuthTokenToURL.js => addEncryptedAuthTokenToURL.ts} | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) rename src/libs/{addEncryptedAuthTokenToURL.js => addEncryptedAuthTokenToURL.ts} (58%) diff --git a/src/libs/addEncryptedAuthTokenToURL.js b/src/libs/addEncryptedAuthTokenToURL.ts similarity index 58% rename from src/libs/addEncryptedAuthTokenToURL.js rename to src/libs/addEncryptedAuthTokenToURL.ts index 827454fa2aa3..9bdb83c284ce 100644 --- a/src/libs/addEncryptedAuthTokenToURL.js +++ b/src/libs/addEncryptedAuthTokenToURL.ts @@ -1,19 +1,15 @@ -import lodashGet from 'lodash/get'; import Onyx from 'react-native-onyx'; import ONYXKEYS from '../ONYXKEYS'; let encryptedAuthToken = ''; Onyx.connect({ key: ONYXKEYS.SESSION, - callback: (session) => (encryptedAuthToken = lodashGet(session, 'encryptedAuthToken', '')), + callback: (session) => (encryptedAuthToken = session?.encryptedAuthToken ?? ''), }); /** * Add encryptedAuthToken to this attachment URL - * - * @param {String} url - * @returns {String} */ -export default function (url) { +export default function (url: string) { return `${url}?encryptedAuthToken=${encodeURIComponent(encryptedAuthToken)}`; } From 93966f975a64440ce1e22b193564d65eacdb7088 Mon Sep 17 00:00:00 2001 From: Jakub Butkiewicz Date: Tue, 12 Sep 2023 14:39:11 +0200 Subject: [PATCH 242/284] fix: resolved review comments --- src/libs/Browser/index.web.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/Browser/index.web.ts b/src/libs/Browser/index.web.ts index 9f193062aa16..064358c6bed5 100644 --- a/src/libs/Browser/index.web.ts +++ b/src/libs/Browser/index.web.ts @@ -28,7 +28,7 @@ function getBrowser(): string { } } - browserName = match[1] ? match[1] : navigator.appName; + browserName = match[1] ?? navigator.appName; return browserName ? browserName.toLowerCase() : CONST.BROWSER.OTHER; } From 016ad538d59b33be1bfe5c4115efd7cbd8b88ba1 Mon Sep 17 00:00:00 2001 From: Ana Margarida Silva Date: Tue, 12 Sep 2023 13:47:09 +0100 Subject: [PATCH 243/284] feat: udpate ES translation for tag selection --- src/languages/es.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/languages/es.ts b/src/languages/es.ts index 0a569fda161c..dcd1c7916157 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -537,7 +537,7 @@ export default { `cambío ${valueName === 'comerciante' ? 'el' : 'la'} ${valueName} a ${newValueToDisplay} (previamente ${oldValueToDisplay})`, threadRequestReportName: ({formattedAmount, comment}: ThreadRequestReportNameParams) => `Solicitud de ${formattedAmount}${comment ? ` para ${comment}` : ''}`, threadSentMoneyReportName: ({formattedAmount, comment}: ThreadSentMoneyReportNameParams) => `${formattedAmount} enviado${comment ? ` para ${comment}` : ''}`, - tagSelection: ({tagName}: TagSelectionParams) => `Seleccione una ${tagName} para agregar una organización adicional a tu dinero`, + tagSelection: ({tagName}: TagSelectionParams) => `Seleccione una ${tagName} para organizar mejor tu dinero`, error: { invalidSplit: 'La suma de las partes no equivale al monto total', other: 'Error inesperado, por favor inténtalo más tarde', From 9b7d7c16ff004dccbf9726e5bd4a69241975eeb2 Mon Sep 17 00:00:00 2001 From: Ana Margarida Silva Date: Tue, 12 Sep 2023 14:22:27 +0100 Subject: [PATCH 244/284] revert: use only first tag of policy --- .../MoneyRequestConfirmationList.js | 35 ++++++++----------- src/components/TagPicker/index.js | 6 ++-- src/pages/iou/propTypes/index.js | 4 +-- .../iou/steps/MoneyRequestConfirmPage.js | 2 +- src/types/onyx/IOU.ts | 2 +- 5 files changed, 22 insertions(+), 27 deletions(-) diff --git a/src/components/MoneyRequestConfirmationList.js b/src/components/MoneyRequestConfirmationList.js index 6869f413e900..cebea71c5779 100755 --- a/src/components/MoneyRequestConfirmationList.js +++ b/src/components/MoneyRequestConfirmationList.js @@ -71,7 +71,7 @@ const propTypes = { iouCategory: PropTypes.string, /** IOU Tag */ - iouTags: PropTypes.objectOf(PropTypes.string), + iouTag: PropTypes.string, /** Selected participants from MoneyRequestModal with login / accountID */ selectedParticipants: PropTypes.arrayOf(optionPropTypes).isRequired, @@ -153,7 +153,7 @@ const defaultProps = { onSelectParticipant: () => {}, iouType: CONST.IOU.MONEY_REQUEST_TYPE.REQUEST, iouCategory: '', - iouTags: {}, + iouTag: '', payeePersonalDetails: null, canModifyParticipants: false, isReadOnly: false, @@ -192,7 +192,9 @@ function MoneyRequestConfirmationList(props) { const shouldCalculateDistanceAmount = props.isDistanceRequest && props.iouAmount === 0; const shouldCategoryEditable = !_.isEmpty(props.policyCategories) && !props.isDistanceRequest; - const tags = _.keys(props.policyTags); + // Fetches the first tag of the policy + const tagKey = _.first(_.keys(props.policyTags)); + const tag = lodashGet(props.policyTags, tagKey, {}); const canUseTags = Permissions.canUseTags(props.betas); const formattedAmount = CurrencyUtils.convertToDisplayString( @@ -516,23 +518,16 @@ function MoneyRequestConfirmationList(props) { disabled={didConfirm || props.isReadOnly} /> )} - {canUseTags - ? _.map( - tags, - (tag) => - !_.isEmpty(lodashGet(props.policyTags, [tag, 'tags'], [])) && ( - Navigation.navigate(ROUTES.getMoneyRequestTagRoute(props.iouType, props.reportID, tag))} - style={[styles.moneyRequestMenuItem, styles.mb2]} - disabled={didConfirm || props.isReadOnly} - /> - ), - ) - : null} + {canUseTags && tag.tags ? ( + Navigation.navigate(ROUTES.getMoneyRequestTagRoute(props.iouType, props.reportID, tagKey))} + style={[styles.moneyRequestMenuItem, styles.mb2]} + disabled={didConfirm || props.isReadOnly} + /> + ) : null} )} diff --git a/src/components/TagPicker/index.js b/src/components/TagPicker/index.js index cba2ffc3bc15..25021bd817d7 100644 --- a/src/components/TagPicker/index.js +++ b/src/components/TagPicker/index.js @@ -15,17 +15,17 @@ function TagPicker({policyTags, reportID, tag, iouType, iou}) { const {translate} = useLocalize(); const selectedOptions = useMemo(() => { - if (!iou.tags || !iou.tags[tag]) { + if (!iou.tag) { return []; } return [ { - name: iou.tags[tag], + name: iou.tag, enabled: true, }, ]; - }, [iou.tags, tag]); + }, [iou.tag]); // Only shows one section, which will be the default behavior if there are // less than 8 policy tags diff --git a/src/pages/iou/propTypes/index.js b/src/pages/iou/propTypes/index.js index 3ceba7d969d8..5ecd00d11876 100644 --- a/src/pages/iou/propTypes/index.js +++ b/src/pages/iou/propTypes/index.js @@ -19,7 +19,7 @@ const iouPropTypes = PropTypes.shape({ merchant: PropTypes.string, /** The tag */ - tags: PropTypes.objectOf(PropTypes.string), + tag: PropTypes.string, /** Date that the request was created */ created: PropTypes.string, @@ -37,7 +37,7 @@ const iouDefaultProps = { currency: CONST.CURRENCY.USD, comment: '', merchant: '', - tags: {}, + tag: '', created: '', participants: [], receiptPath: '', diff --git a/src/pages/iou/steps/MoneyRequestConfirmPage.js b/src/pages/iou/steps/MoneyRequestConfirmPage.js index 7df500e8f80a..a6418df3712d 100644 --- a/src/pages/iou/steps/MoneyRequestConfirmPage.js +++ b/src/pages/iou/steps/MoneyRequestConfirmPage.js @@ -272,7 +272,7 @@ function MoneyRequestConfirmPage(props) { iouAmount={props.iou.amount} iouComment={props.iou.comment} iouCurrencyCode={props.iou.currency} - iouTags={props.iou.tags} + iouTag={props.iou.tag} onConfirm={createTransaction} onSendMoney={sendMoney} onSelectParticipant={(option) => { diff --git a/src/types/onyx/IOU.ts b/src/types/onyx/IOU.ts index 8c01081a6482..7151bb84d1f1 100644 --- a/src/types/onyx/IOU.ts +++ b/src/types/onyx/IOU.ts @@ -19,7 +19,7 @@ type IOU = { receiptSource?: string; transactionID?: string; participants?: Participant[]; - tags: Record; + tag?: string; }; export default IOU; From 5f7bada1bd307272469b383e7e95cf0b77230b69 Mon Sep 17 00:00:00 2001 From: Bartosz Grajdek Date: Tue, 12 Sep 2023 15:27:03 +0200 Subject: [PATCH 245/284] Resolve conflicts --- src/libs/tryResolveUrlFromApiRoot.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/libs/tryResolveUrlFromApiRoot.ts b/src/libs/tryResolveUrlFromApiRoot.ts index 251366cb3488..f9aef09a00a7 100644 --- a/src/libs/tryResolveUrlFromApiRoot.ts +++ b/src/libs/tryResolveUrlFromApiRoot.ts @@ -16,16 +16,16 @@ const ORIGIN_PATTERN = new RegExp(`^(${ORIGINS_TO_REPLACE.join('|')})`); * or `https://staging.expensify` part, with `https://{API_ROOT}` * - Unmatched URLs (non expensify) are returned with no modifications */ -<<<<<<< HEAD:src/libs/tryResolveUrlFromApiRoot.ts -export default function tryResolveUrlFromApiRoot(url: string): string { -======= -export default function tryResolveUrlFromApiRoot(url) { +function tryResolveUrlFromApiRoot(url: string): string; +function tryResolveUrlFromApiRoot(url: number): number; +function tryResolveUrlFromApiRoot(url: string | number): string | number { // in native, when we import an image asset, it will have a number representation which can be used in `source` of Image // in this case we can skip the url resolving if (typeof url === 'number') { return url; } ->>>>>>> origin/main:src/libs/tryResolveUrlFromApiRoot.js const apiRoot = ApiUtils.getApiRoot({shouldUseSecure: false}); return url.replace(ORIGIN_PATTERN, apiRoot); } + +export default tryResolveUrlFromApiRoot; From 35675a229c13f78f88093848a6874bc3a8f196fe Mon Sep 17 00:00:00 2001 From: Jakub Butkiewicz Date: Tue, 12 Sep 2023 16:10:53 +0200 Subject: [PATCH 246/284] fix: added return type to extractCollectionItemID function --- src/libs/CollectionUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/CollectionUtils.ts b/src/libs/CollectionUtils.ts index ddd54bab862a..ac47633c2e08 100644 --- a/src/libs/CollectionUtils.ts +++ b/src/libs/CollectionUtils.ts @@ -16,7 +16,7 @@ function lastItem(object: Record = {}): T | undefined { * Used to grab the id for a particular collection item's key. * e.g. reportActions_1 -> 1 */ -function extractCollectionItemID(key: `${OnyxCollectionKey}${string}`) { +function extractCollectionItemID(key: `${OnyxCollectionKey}${string}`): string { return key.split('_')[1]; } From 7d6f91fbe39574cef11cbdfd5ffacbcebe5fa3e5 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Tue, 12 Sep 2023 16:55:48 +0200 Subject: [PATCH 247/284] Resolve conflicts Resolved conflicts and updated tests after merging from upstream See: https://github.com/Expensify/App/issues/13604 --- .github/workflows/platformDeploy.yml | 6 +- package-lock.json | 468 ++++++++++++++++-- .../finishReleaseCycleAssertions.js | 55 -- workflow_tests/assertions/lintAssertions.js | 2 +- .../assertions/platformDeployAssertions.js | 27 + .../assertions/preDeployAssertions.js | 6 - .../assertions/testBuildAssertions.js | 6 + workflow_tests/finishReleaseCycle.test.js | 76 +-- .../mocks/finishReleaseCycleMocks.js | 25 - workflow_tests/mocks/lintMocks.js | 2 +- workflow_tests/mocks/platformDeployMocks.js | 31 ++ workflow_tests/mocks/preDeployMocks.js | 8 - workflow_tests/mocks/testBuildMocks.js | 8 + workflow_tests/platformDeploy.test.js | 6 + workflow_tests/testBuild.test.js | 4 +- 15 files changed, 521 insertions(+), 209 deletions(-) diff --git a/.github/workflows/platformDeploy.yml b/.github/workflows/platformDeploy.yml index c8a34cc147c4..ad002e164837 100644 --- a/.github/workflows/platformDeploy.yml +++ b/.github/workflows/platformDeploy.yml @@ -36,8 +36,10 @@ jobs: if: ${{ github.event_name != 'release' }} needs: validateActor steps: - - uses: actions/checkout@v3 - - uses: Expensify/App/.github/actions/composite/setupNode@main + - name: Checkout + uses: actions/checkout@v3 + - name: Setup Node + uses: Expensify/App/.github/actions/composite/setupNode@main - name: Set version id: getVersion diff --git a/package-lock.json b/package-lock.json index 1ae63b31fd0c..55c654a5c344 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", @@ -128,6 +131,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", @@ -221,7 +226,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", @@ -5193,6 +5199,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", @@ -5699,6 +5809,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, @@ -6929,14 +7045,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", @@ -19380,6 +19488,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, @@ -21217,6 +21334,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, @@ -22650,6 +22807,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", @@ -23304,6 +23470,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, @@ -28092,7 +28267,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": [ { @@ -28100,7 +28277,6 @@ "url": "https://github.com/sponsors/RubenVerborgh" } ], - "license": "MIT", "engines": { "node": ">=4.0" }, @@ -28299,6 +28475,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, @@ -37534,6 +37719,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-abort-controller": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/node-abort-controller/-/node-abort-controller-3.1.1.tgz", @@ -37717,6 +37917,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", @@ -38687,14 +38896,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" @@ -39393,6 +39594,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, @@ -41403,6 +41613,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", @@ -47697,11 +47916,11 @@ "license": "ISC" }, "node_modules/yaml": { - "version": "1.10.2", - "dev": true, - "license": "ISC", + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.3.2.tgz", + "integrity": "sha512-N/lyzTPaJasoDmfV7YTrYCI0G/3ivm/9wdG0aHuheKowWQwGTsK0Eoiw6utmzAnI6pkJa0DUVygvp3spqqEKXg==", "engines": { - "node": ">= 6" + "node": ">= 14" } }, "node_modules/yargs": { @@ -51206,6 +51425,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", @@ -51588,6 +51899,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, @@ -52501,11 +52818,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==" } } }, @@ -61211,6 +61523,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, @@ -62510,6 +62828,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 @@ -63485,6 +63833,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" }, @@ -63919,6 +64273,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": { @@ -67267,7 +67629,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": { @@ -67383,6 +67747,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 } } }, @@ -73699,6 +74069,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-abort-controller": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/node-abort-controller/-/node-abort-controller-3.1.1.tgz", @@ -73832,6 +74214,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": { @@ -74463,11 +74851,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==" } } }, @@ -74932,6 +75315,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, @@ -76222,6 +76611,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", @@ -80552,8 +80947,9 @@ "version": "4.0.0" }, "yaml": { - "version": "1.10.2", - "dev": true + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.3.2.tgz", + "integrity": "sha512-N/lyzTPaJasoDmfV7YTrYCI0G/3ivm/9wdG0aHuheKowWQwGTsK0Eoiw6utmzAnI6pkJa0DUVygvp3spqqEKXg==" }, "yargs": { "version": "13.3.2", diff --git a/workflow_tests/assertions/finishReleaseCycleAssertions.js b/workflow_tests/assertions/finishReleaseCycleAssertions.js index 5d2e9c66555f..12a8b9f2b05d 100644 --- a/workflow_tests/assertions/finishReleaseCycleAssertions.js +++ b/workflow_tests/assertions/finishReleaseCycleAssertions.js @@ -178,64 +178,9 @@ const assertUpdateStagingJobExecuted = (workflowResult, didExecute = true, isSuc }); }; -const assertCreateNewStagingDeployCashJobExecuted = (workflowResult, newVersion = '', didExecute = true, isSuccessful = true) => { - const steps = [ - utils.createStepAssertion( - 'Checkout', - true, - null, - 'CREATENEWSTAGINGDEPLOYCASH', - 'Checkout', - [ - {key: 'ref', value: 'staging'}, - {key: 'token', value: '***'}, - ], - [], - ), - utils.createStepAssertion('Tag version', true, null, 'CREATENEWSTAGINGDEPLOYCASH', 'Tagging version', [], []), - utils.createStepAssertion( - 'Create new StagingDeployCash', - true, - null, - 'CREATENEWSTAGINGDEPLOYCASH', - 'Creating new StagingDeployCash', - [ - {key: 'GITHUB_TOKEN', value: '***'}, - {key: 'NPM_VERSION', value: newVersion}, - ], - [], - ), - ]; - - if (!isSuccessful) { - steps[2].status = 1; - } - - steps.forEach((expectedStep) => { - if (didExecute) { - expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); - } else { - expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); - } - }); - - const failProdSteps = [ - utils.createStepAssertion('Announce failed workflow in Slack', true, null, 'CREATENEWSTAGINGDEPLOYCASH', 'Announcing failed workflow', [{key: 'SLACK_WEBHOOK', value: '***'}], []), - ]; - - failProdSteps.forEach((expectedStep) => { - if (didExecute && !isSuccessful) { - expect(workflowResult).toEqual(expect.arrayContaining([expectedStep])); - } else { - expect(workflowResult).not.toEqual(expect.arrayContaining([expectedStep])); - } - }); -}; - module.exports = { assertValidateJobExecuted, assertUpdateProductionJobExecuted, assertCreateNewPatchVersionJobExecuted, assertUpdateStagingJobExecuted, - assertCreateNewStagingDeployCashJobExecuted, }; diff --git a/workflow_tests/assertions/lintAssertions.js b/workflow_tests/assertions/lintAssertions.js index 4282ddb81d24..938f9b383464 100644 --- a/workflow_tests/assertions/lintAssertions.js +++ b/workflow_tests/assertions/lintAssertions.js @@ -4,7 +4,7 @@ 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 JavaScript and Typescript 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', [], []), ]; diff --git a/workflow_tests/assertions/platformDeployAssertions.js b/workflow_tests/assertions/platformDeployAssertions.js index bf20cb7687c9..35242cd24d31 100644 --- a/workflow_tests/assertions/platformDeployAssertions.js +++ b/workflow_tests/assertions/platformDeployAssertions.js @@ -12,6 +12,26 @@ const assertVerifyActorJobExecuted = (workflowResult, username, didExecute = tru }); }; +const assertDeployChecklistJobExecuted = (workflowResult, didExecute = true) => { + const steps = [ + utils.createStepAssertion('Checkout', true, null, 'DEPLOY_CHECKLIST', 'Checkout'), + utils.createStepAssertion('Setup Node', true, null, 'DEPLOY_CHECKLIST', 'Setup Node'), + utils.createStepAssertion('Set version', true, null, 'DEPLOY_CHECKLIST', 'Set version'), + utils.createStepAssertion('Create or update staging deploy', true, null, 'DEPLOY_CHECKLIST', 'Create or update staging deploy', [ + {key: 'GITHUB_TOKEN', value: '***'}, + {key: 'NPM_VERSION', value: '1.2.3'}, + ]), + ]; + + 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) => { const steps = [ utils.createStepAssertion('Checkout', true, null, 'ANDROID', 'Checking out'), @@ -131,6 +151,12 @@ const assertIOSJobExecuted = (workflowResult, didExecute = true, isProduction = {key: 'ruby-version', value: '2.7'}, {key: 'bundler-cache', value: 'true'}, ]), + utils.createStepAssertion('Cache Pod dependencies', true, null, 'IOS', 'Cache Pod dependencies', [ + {key: 'path', value: 'ios/Pods'}, + {key: 'key', value: 'Linux-pods-cache-'}, + {key: 'restore-keys', value: 'Linux-pods-cache-'}, + ]), + utils.createStepAssertion('Compare Podfile.lock and Manifest.lock', true, null, 'IOS', 'Compare Podfile.lock and Manifest.lock'), utils.createStepAssertion('Install cocoapods', true, null, 'IOS', 'Installing cocoapods', [ {key: 'timeout_minutes', value: '10'}, {key: 'max_attempts', value: '5'}, @@ -334,6 +360,7 @@ const assertPostGithubCommentJobExecuted = (workflowResult, didExecute = true, i module.exports = { assertVerifyActorJobExecuted, + assertDeployChecklistJobExecuted, assertAndroidJobExecuted, assertDesktopJobExecuted, assertIOSJobExecuted, diff --git a/workflow_tests/assertions/preDeployAssertions.js b/workflow_tests/assertions/preDeployAssertions.js index e1749c07f603..90d6f9febb75 100644 --- a/workflow_tests/assertions/preDeployAssertions.js +++ b/workflow_tests/assertions/preDeployAssertions.js @@ -180,12 +180,6 @@ const assertUpdateStagingJobExecuted = (workflowResult, didExecute = true) => { ]), 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: '***'}]), ]; steps.forEach((expectedStep) => { diff --git a/workflow_tests/assertions/testBuildAssertions.js b/workflow_tests/assertions/testBuildAssertions.js index 4ff9e2be40c7..a4f7a46259ad 100644 --- a/workflow_tests/assertions/testBuildAssertions.js +++ b/workflow_tests/assertions/testBuildAssertions.js @@ -154,6 +154,12 @@ const assertIOSJobExecuted = (workflowResult, ref = '', didExecute = true, fails ], [], ), + utils.createStepAssertion('Cache Pod dependencies', true, null, 'IOS', 'Cache Pod dependencies', [ + {key: 'path', value: 'ios/Pods'}, + {key: 'key', value: 'Linux-pods-cache-'}, + {key: 'restore-keys', value: 'Linux-pods-cache-'}, + ]), + utils.createStepAssertion('Compare Podfile.lock and Manifest.lock', true, null, 'IOS', 'Compare Podfile.lock and Manifest.lock'), utils.createStepAssertion( 'Install cocoapods', true, diff --git a/workflow_tests/finishReleaseCycle.test.js b/workflow_tests/finishReleaseCycle.test.js index 2f1f3b790f36..7c17ca8d4122 100644 --- a/workflow_tests/finishReleaseCycle.test.js +++ b/workflow_tests/finishReleaseCycle.test.js @@ -42,7 +42,7 @@ describe('test workflow finishReleaseCycle', () => { describe('issue has StagingDeployCash', () => { describe('actor is a team member', () => { describe('no deploy blockers', () => { - it('production updated, new version created, new StagingDeployCash created', async () => { + it('production updated, new version created', async () => { const repoPath = mockGithub.repo.getPath('testFinishReleaseCycleWorkflowRepo') || ''; const workflowPath = path.join(repoPath, '.github', 'workflows', 'finishReleaseCycle.yml'); let act = new eAct.ExtendedAct(repoPath, workflowPath); @@ -67,7 +67,6 @@ describe('test workflow finishReleaseCycle', () => { 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 = { createNewPatchVersion: { @@ -90,73 +89,10 @@ describe('test workflow finishReleaseCycle', () => { assertions.assertUpdateProductionJobExecuted(result); assertions.assertCreateNewPatchVersionJobExecuted(result); assertions.assertUpdateStagingJobExecuted(result); - assertions.assertCreateNewStagingDeployCashJobExecuted(result, '1.2.3'); - }); - describe('createNewStagingDeployCash fails', () => { - 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); - 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, - updateStaging: mocks.FINISHRELEASECYCLE__UPDATESTAGING__STEP_MOCKS, - createNewStagingDeployCash: mocks.FINISHRELEASECYCLE__CREATENEWSTAGINGDEPLOYCASH__STEP_MOCKS, - }; - testMockSteps.createNewStagingDeployCash[2] = utils.createMockStep( - 'Create new StagingDeployCash', - 'Creating new StagingDeployCash', - 'CREATENEWSTAGINGDEPLOYCASH', - ['GITHUB_TOKEN', 'NPM_VERSION'], - [], - null, - 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, '1234'); - assertions.assertUpdateProductionJobExecuted(result); - assertions.assertCreateNewPatchVersionJobExecuted(result); - assertions.assertUpdateStagingJobExecuted(result); - assertions.assertCreateNewStagingDeployCashJobExecuted(result, '1.2.3', true, false); - }); }); }); describe('deploy blockers', () => { - it('production not updated, new version not created, new StagingDeployCash not created, issue reopened', async () => { + it('production not updated, new version 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); @@ -181,7 +117,6 @@ describe('test workflow finishReleaseCycle', () => { 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 = { createNewPatchVersion: { @@ -204,12 +139,11 @@ describe('test workflow finishReleaseCycle', () => { assertions.assertUpdateProductionJobExecuted(result, false); assertions.assertCreateNewPatchVersionJobExecuted(result, false); assertions.assertUpdateStagingJobExecuted(result, false); - assertions.assertCreateNewStagingDeployCashJobExecuted(result, '1.2.3', false); }); }); }); describe('actor is not a team member', () => { - it('production not updated, new version not created, new StagingDeployCash not created, issue reopened', async () => { + it('production not updated, new version 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); @@ -234,7 +168,6 @@ describe('test workflow finishReleaseCycle', () => { 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 = { createNewPatchVersion: { @@ -257,7 +190,6 @@ describe('test workflow finishReleaseCycle', () => { assertions.assertUpdateProductionJobExecuted(result, false); assertions.assertCreateNewPatchVersionJobExecuted(result, false); assertions.assertUpdateStagingJobExecuted(result, false); - assertions.assertCreateNewStagingDeployCashJobExecuted(result, '1.2.3', false); }); }); }); @@ -287,7 +219,6 @@ describe('test workflow finishReleaseCycle', () => { 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 = { createNewPatchVersion: { @@ -310,7 +241,6 @@ describe('test workflow finishReleaseCycle', () => { 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 82b1b44e1ed9..e1bb0d112429 100644 --- a/workflow_tests/mocks/finishReleaseCycleMocks.js +++ b/workflow_tests/mocks/finishReleaseCycleMocks.js @@ -154,30 +154,6 @@ const FINISHRELEASECYCLE__UPDATESTAGING__STEP_MOCKS = [ 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', - 'Creating new StagingDeployCash', - 'CREATENEWSTAGINGDEPLOYCASH', - ['GITHUB_TOKEN', 'NPM_VERSION'], - [], -); -const FINISHRELEASECYCLE__CREATENEWSTAGINGDEPLOYCASH__ANNOUNCE_FAILED_WORKFLOW_IN_SLACK__STEP_MOCK = utils.createMockStep( - 'Announce failed workflow in Slack', - 'Announcing failed workflow', - 'CREATENEWSTAGINGDEPLOYCASH', - ['SLACK_WEBHOOK'], - [], -); -const FINISHRELEASECYCLE__CREATENEWSTAGINGDEPLOYCASH__STEP_MOCKS = [ - 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, -]; - module.exports = { FINISHRELEASECYCLE__VALIDATE__TEAM_MEMBER_NO_BLOCKERS__STEP_MOCKS, FINISHRELEASECYCLE__VALIDATE__TEAM_MEMBER_BLOCKERS__STEP_MOCKS, @@ -186,5 +162,4 @@ module.exports = { FINISHRELEASECYCLE__UPDATEPRODUCTION__STEP_MOCKS, FINISHRELEASECYCLE__CREATENEWPATCHVERSION__STEP_MOCKS, FINISHRELEASECYCLE__UPDATESTAGING__STEP_MOCKS, - FINISHRELEASECYCLE__CREATENEWSTAGINGDEPLOYCASH__STEP_MOCKS, }; diff --git a/workflow_tests/mocks/lintMocks.js b/workflow_tests/mocks/lintMocks.js index 169503ea8f3d..ecf11074e20f 100644 --- a/workflow_tests/mocks/lintMocks.js +++ b/workflow_tests/mocks/lintMocks.js @@ -3,7 +3,7 @@ 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_JAVASCRIPT_WITH_ESLINT__STEP_MOCK = utils.createMockStep('Lint JavaScript and Typescript 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, diff --git a/workflow_tests/mocks/platformDeployMocks.js b/workflow_tests/mocks/platformDeployMocks.js index 358dccf79028..9e0b91b29156 100644 --- a/workflow_tests/mocks/platformDeployMocks.js +++ b/workflow_tests/mocks/platformDeployMocks.js @@ -20,6 +20,23 @@ const 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]; +// deployChecklist +const PLATFORM_DEPLOY__DEPLOY_CHECKLIST__CHECKOUT__STEP_MOCK = utils.createMockStep('Checkout', 'Checkout', 'DEPLOY_CHECKLIST'); +const PLATFORM_DEPLOY__DEPLOY_CHECKLIST__SETUP_NODE__STEP_MOCK = utils.createMockStep('Setup Node', 'Setup Node', 'DEPLOY_CHECKLIST'); +const PLATFORM_DEPLOY__DEPLOY_CHECKLIST__SET_VERSION__STEP_MOCK = utils.createMockStep('Set version', 'Set version', 'DEPLOY_CHECKLIST', [], [], {VERSION: '1.2.3'}); +const PLATFORM_DEPLOY__DEPLOY_CHECKLIST__CREATE_OR_UPDATE_STAGING_DEPLOY__STEP_MOCK = utils.createMockStep( + 'Create or update staging deploy', + 'Create or update staging deploy', + 'DEPLOY_CHECKLIST', + ['GITHUB_TOKEN', 'NPM_VERSION'], +); +const PLATFORM_DEPLOY__DEPLOY_CHECKLIST__STEP_MOCKS = [ + PLATFORM_DEPLOY__DEPLOY_CHECKLIST__CHECKOUT__STEP_MOCK, + PLATFORM_DEPLOY__DEPLOY_CHECKLIST__SETUP_NODE__STEP_MOCK, + PLATFORM_DEPLOY__DEPLOY_CHECKLIST__SET_VERSION__STEP_MOCK, + PLATFORM_DEPLOY__DEPLOY_CHECKLIST__CREATE_OR_UPDATE_STAGING_DEPLOY__STEP_MOCK, +]; + // android const PLATFORM_DEPLOY__ANDROID__CHECKOUT__STEP_MOCK = utils.createMockStep('Checkout', 'Checking out', 'ANDROID'); const PLATFORM_DEPLOY__ANDROID__CONFIGURE_MAPBOX_SDK__STEP_MOCK = utils.createMockStep('Configure MapBox SDK', 'Configure MapBox SDK', 'ANDROID'); @@ -98,6 +115,17 @@ const PLATFORM_DEPLOY__IOS__CHECKOUT__STEP_MOCK = utils.createMockStep('Checkout const PLATFORM_DEPLOY__IOS__CONFIGURE_MAPBOX_SDK__STEP_MOCK = utils.createMockStep('Configure MapBox SDK', 'Configure MapBox SDK', '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__CACHE_POD_DEPENDENCIES__STEP_MOCK = utils.createMockStep('Cache Pod dependencies', 'Cache Pod dependencies', 'IOS', ['path', 'key', 'restore-keys'], [], { + 'cache-hit': false, +}); +const PLATFORM_DEPLOY__IOS__COMPARE_PODFILE_AND_MANIFEST__STEP_MOCK = utils.createMockStep( + 'Compare Podfile.lock and Manifest.lock', + 'Compare Podfile.lock and Manifest.lock', + 'IOS', + [], + [], + {IS_PODFILE_SAME_AS_MANIFEST: false}, +); 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']); @@ -126,6 +154,8 @@ const PLATFORM_DEPLOY__IOS__STEP_MOCKS = [ PLATFORM_DEPLOY__IOS__CONFIGURE_MAPBOX_SDK__STEP_MOCK, PLATFORM_DEPLOY__IOS__SETUP_NODE__STEP_MOCK, PLATFORM_DEPLOY__IOS__SETUP_RUBY__STEP_MOCK, + PLATFORM_DEPLOY__IOS__CACHE_POD_DEPENDENCIES__STEP_MOCK, + PLATFORM_DEPLOY__IOS__COMPARE_PODFILE_AND_MANIFEST__STEP_MOCK, PLATFORM_DEPLOY__IOS__COCOAPODS__STEP_MOCK, PLATFORM_DEPLOY__IOS__DECRYPT_PROFILE__STEP_MOCK, PLATFORM_DEPLOY__IOS__DECRYPT_CERTIFICATE__STEP_MOCK, @@ -247,4 +277,5 @@ module.exports = { PLATFORM_DEPLOY__POST_SLACK_FAIL__STEP_MOCKS, PLATFORM_DEPLOY__POST_SLACK_SUCCESS__STEP_MOCKS, PLATFORM_DEPLOY__POST_GITHUB_COMMENT__STEP_MOCKS, + PLATFORM_DEPLOY__DEPLOY_CHECKLIST__STEP_MOCKS, }; diff --git a/workflow_tests/mocks/preDeployMocks.js b/workflow_tests/mocks/preDeployMocks.js index 88fa8e8c2020..3dc67a904cf9 100644 --- a/workflow_tests/mocks/preDeployMocks.js +++ b/workflow_tests/mocks/preDeployMocks.js @@ -77,20 +77,12 @@ const RUN_TURNSTYLE_MOCK_STEP = utils.createMockStep('Run turnstyle', 'Running t 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'); -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 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, 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, ANNOUNCE_FAILED_WORKFLOW_IN_SLACK_MOCK_STEP, ]; diff --git a/workflow_tests/mocks/testBuildMocks.js b/workflow_tests/mocks/testBuildMocks.js index 1faa1fb38e9d..bdff0ac57ae1 100644 --- a/workflow_tests/mocks/testBuildMocks.js +++ b/workflow_tests/mocks/testBuildMocks.js @@ -107,6 +107,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_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__CACHE_POD_DEPENDENCIES__STEP_MOCK = utils.createMockStep('Cache Pod dependencies', 'Cache Pod dependencies', 'IOS', ['path', 'key', 'restore-keys'], [], { + 'cache-hit': false, +}); +const TESTBUILD__IOS__COMPARE_PODFILE_AND_MANIFEST__STEP_MOCK = utils.createMockStep('Compare Podfile.lock and Manifest.lock', 'Compare Podfile.lock and Manifest.lock', 'IOS', [], [], { + IS_PODFILE_SAME_AS_MANIFEST: false, +}); 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']); @@ -126,6 +132,8 @@ const TESTBUILD__IOS__STEP_MOCKS = [ TESTBUILD__IOS__SETUP_NODE__STEP_MOCK, TESTBUILD__IOS__SETUP_XCODE__STEP_MOCK, TESTBUILD__IOS__SETUP_RUBY__STEP_MOCK, + TESTBUILD__IOS__CACHE_POD_DEPENDENCIES__STEP_MOCK, + TESTBUILD__IOS__COMPARE_PODFILE_AND_MANIFEST__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/platformDeploy.test.js b/workflow_tests/platformDeploy.test.js index ecdcfae8d337..e74b8e873001 100644 --- a/workflow_tests/platformDeploy.test.js +++ b/workflow_tests/platformDeploy.test.js @@ -90,6 +90,7 @@ describe('test workflow platformDeploy', () => { ); const testMockSteps = { validateActor: mocks.PLATFORM_DEPLOY__VALIDATE_ACTOR__TEAM_MEMBER__STEP_MOCKS, + deployChecklist: mocks.PLATFORM_DEPLOY__DEPLOY_CHECKLIST__STEP_MOCKS, android: mocks.PLATFORM_DEPLOY__ANDROID__STEP_MOCKS, desktop: mocks.PLATFORM_DEPLOY__DESKTOP__STEP_MOCKS, iOS: mocks.PLATFORM_DEPLOY__IOS__STEP_MOCKS, @@ -106,6 +107,7 @@ describe('test workflow platformDeploy', () => { }); assertions.assertVerifyActorJobExecuted(result, 'Dummy Author'); + assertions.assertDeployChecklistJobExecuted(result, true); assertions.assertAndroidJobExecuted(result, true, false, true); assertions.assertDesktopJobExecuted(result, true, false); assertions.assertIOSJobExecuted(result, true, false, true); @@ -164,6 +166,7 @@ describe('test workflow platformDeploy', () => { ); const testMockSteps = { validateActor: mocks.PLATFORM_DEPLOY__VALIDATE_ACTOR__OUTSIDER__STEP_MOCKS, + deployChecklist: mocks.PLATFORM_DEPLOY__DEPLOY_CHECKLIST__STEP_MOCKS, android: mocks.PLATFORM_DEPLOY__ANDROID__STEP_MOCKS, desktop: mocks.PLATFORM_DEPLOY__DESKTOP__STEP_MOCKS, iOS: mocks.PLATFORM_DEPLOY__IOS__STEP_MOCKS, @@ -180,6 +183,7 @@ describe('test workflow platformDeploy', () => { }); assertions.assertVerifyActorJobExecuted(result, 'OSBotify'); + assertions.assertDeployChecklistJobExecuted(result, true); assertions.assertAndroidJobExecuted(result, true, false, true); assertions.assertDesktopJobExecuted(result, true, false); assertions.assertIOSJobExecuted(result, true, false, true); @@ -238,6 +242,7 @@ describe('test workflow platformDeploy', () => { ); const testMockSteps = { validateActor: mocks.PLATFORM_DEPLOY__VALIDATE_ACTOR__OUTSIDER__STEP_MOCKS, + deployChecklist: mocks.PLATFORM_DEPLOY__DEPLOY_CHECKLIST__STEP_MOCKS, android: mocks.PLATFORM_DEPLOY__ANDROID__STEP_MOCKS, desktop: mocks.PLATFORM_DEPLOY__DESKTOP__STEP_MOCKS, iOS: mocks.PLATFORM_DEPLOY__IOS__STEP_MOCKS, @@ -254,6 +259,7 @@ describe('test workflow platformDeploy', () => { }); assertions.assertVerifyActorJobExecuted(result, 'Dummy Author'); + assertions.assertDeployChecklistJobExecuted(result, true); assertions.assertAndroidJobExecuted(result, false); assertions.assertDesktopJobExecuted(result, false); assertions.assertIOSJobExecuted(result, false); diff --git a/workflow_tests/testBuild.test.js b/workflow_tests/testBuild.test.js index cd966e2cdef0..4288ea236ab2 100644 --- a/workflow_tests/testBuild.test.js +++ b/workflow_tests/testBuild.test.js @@ -234,7 +234,7 @@ describe('test workflow testBuild', () => { web: mocks.TESTBUILD__WEB__STEP_MOCKS, postGithubComment: mocks.TESTBUILD__POSTGITHUBCOMMENT__STEP_MOCKS, }; - testMockSteps.iOS[6] = utils.createMockStep('Install cocoapods', 'Install cocoapods', 'IOS', ['timeout_minutes', 'max_attempts', 'command'], [], {}, {}, false); + testMockSteps.iOS[8] = 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, @@ -245,7 +245,7 @@ describe('test workflow testBuild', () => { assertions.assertValidateActorJobExecuted(result, '1234'); assertions.assertGetBranchRefJobExecuted(result); assertions.assertAndroidJobExecuted(result, 'test-ref'); - assertions.assertIOSJobExecuted(result, 'test-ref', true, 6); + assertions.assertIOSJobExecuted(result, 'test-ref', true, 8); assertions.assertDesktopJobExecuted(result, 'test-ref'); assertions.assertWebJobExecuted(result, 'test-ref'); assertions.assertPostGithubCommentJobExecuted(result, 'test-ref', '1234', true, 'success', 'failure', 'success', 'success'); From 77b853d10b99efecd7cca045ee78ccdd693153d4 Mon Sep 17 00:00:00 2001 From: Ana Margarida Silva Date: Tue, 12 Sep 2023 16:49:57 +0100 Subject: [PATCH 248/284] feat: remove tag from route and use hardcoded value --- src/ROUTES.ts | 4 ++-- src/components/MoneyRequestConfirmationList.js | 14 ++++++++------ src/components/TagPicker/tagPickerPropTypes.js | 2 +- src/components/tagPropTypes.js | 3 +++ src/pages/iou/MoneyRequestTagPage.js | 17 +++++++++-------- src/types/onyx/PolicyTag.ts | 4 ++++ 6 files changed, 27 insertions(+), 17 deletions(-) diff --git a/src/ROUTES.ts b/src/ROUTES.ts index 2819740cd963..6b86d88b31ec 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -98,7 +98,7 @@ export default { MONEY_REQUEST_CURRENCY: ':iouType/new/currency/:reportID?', MONEY_REQUEST_DESCRIPTION: ':iouType/new/description/:reportID?', MONEY_REQUEST_CATEGORY: ':iouType/new/category/:reportID?', - MONEY_REQUEST_TAG: ':iouType/new/tag/:reportID/:tag?', + MONEY_REQUEST_TAG: ':iouType/new/tag/:reportID?', MONEY_REQUEST_MERCHANT: ':iouType/new/merchant/:reportID?', MONEY_REQUEST_MANUAL_TAB: ':iouType/new/:reportID?/manual', MONEY_REQUEST_SCAN_TAB: ':iouType/new/:reportID?/scan', @@ -118,7 +118,7 @@ export default { getMoneyRequestMerchantRoute: (iouType: string, reportID = '') => `${iouType}/new/merchant/${reportID}`, getMoneyRequestDistanceTabRoute: (iouType: string, reportID = '') => `${iouType}/new/${reportID}/distance`, getMoneyRequestWaypointRoute: (iouType: string, waypointIndex: number) => `${iouType}/new/waypoint/${waypointIndex}`, - getMoneyRequestTagRoute: (iouType: string, reportID = '', tag = '') => `${iouType}/new/tag/${reportID}/${tag}`, + getMoneyRequestTagRoute: (iouType: string, reportID = '') => `${iouType}/new/tag/${reportID}`, SPLIT_BILL_DETAILS: `r/:reportID/split/:reportActionID`, getSplitBillDetailsRoute: (reportID: string, reportActionID: string) => `r/${reportID}/split/${reportActionID}`, getNewTaskRoute: (reportID: string) => `${NEW_TASK}/${reportID}`, diff --git a/src/components/MoneyRequestConfirmationList.js b/src/components/MoneyRequestConfirmationList.js index cebea71c5779..188eb8db49d5 100755 --- a/src/components/MoneyRequestConfirmationList.js +++ b/src/components/MoneyRequestConfirmationList.js @@ -139,6 +139,7 @@ const propTypes = { policyTags: PropTypes.objectOf( PropTypes.shape({ name: PropTypes.string, + required: PropTypes.bool, tags: PropTypes.objectOf(tagPropTypes), }), ), @@ -192,9 +193,10 @@ function MoneyRequestConfirmationList(props) { const shouldCalculateDistanceAmount = props.isDistanceRequest && props.iouAmount === 0; const shouldCategoryEditable = !_.isEmpty(props.policyCategories) && !props.isDistanceRequest; - // Fetches the first tag of the policy - const tagKey = _.first(_.keys(props.policyTags)); - const tag = lodashGet(props.policyTags, tagKey, {}); + // Fetches the first tag list of the policy + const tagListKey = _.first(_.keys(props.policyTags)); + const tagList = lodashGet(props.policyTags, [tagListKey, 'tags'], []); + const tagListName = lodashGet(props.policyTags, [tagListKey, 'name'], ''); const canUseTags = Permissions.canUseTags(props.betas); const formattedAmount = CurrencyUtils.convertToDisplayString( @@ -518,12 +520,12 @@ function MoneyRequestConfirmationList(props) { disabled={didConfirm || props.isReadOnly} /> )} - {canUseTags && tag.tags ? ( + {canUseTags && tagList ? ( Navigation.navigate(ROUTES.getMoneyRequestTagRoute(props.iouType, props.reportID, tagKey))} + description={tagListName || translate('common.tag')} + onPress={() => Navigation.navigate(ROUTES.getMoneyRequestTagRoute(props.iouType, props.reportID, tagListKey))} style={[styles.moneyRequestMenuItem, styles.mb2]} disabled={didConfirm || props.isReadOnly} /> diff --git a/src/components/TagPicker/tagPickerPropTypes.js b/src/components/TagPicker/tagPickerPropTypes.js index 35bfd0891ef6..250b22cfddf4 100644 --- a/src/components/TagPicker/tagPickerPropTypes.js +++ b/src/components/TagPicker/tagPickerPropTypes.js @@ -9,7 +9,7 @@ const propTypes = { /** The policyID we are getting tags for */ policyID: PropTypes.string.isRequired, - /** The policyID we are getting tags for */ + /** The tag list we are getting tags for */ tag: PropTypes.string.isRequired, /** The type of IOU report, i.e. bill, request, send */ diff --git a/src/components/tagPropTypes.js b/src/components/tagPropTypes.js index 09ba8d403cf8..7c4a6d16483b 100644 --- a/src/components/tagPropTypes.js +++ b/src/components/tagPropTypes.js @@ -6,4 +6,7 @@ export default PropTypes.shape({ /** Flag that determines if a tag is active and able to be selected */ enabled: PropTypes.bool.isRequired, + + /** "General Ledger code" that corresponds to this category in an accounting system. Similar to an ID. */ + 'GL Code': PropTypes.string, }); diff --git a/src/pages/iou/MoneyRequestTagPage.js b/src/pages/iou/MoneyRequestTagPage.js index fba7bb6c1d29..cac295ff46fa 100644 --- a/src/pages/iou/MoneyRequestTagPage.js +++ b/src/pages/iou/MoneyRequestTagPage.js @@ -1,4 +1,5 @@ import React from 'react'; +import _ from 'underscore'; import PropTypes from 'prop-types'; import lodashGet from 'lodash/get'; import {withOnyx} from 'react-native-onyx'; @@ -25,9 +26,6 @@ const propTypes = { /** The report ID of the IOU */ reportID: PropTypes.string, - - /** The tag name of the IOU */ - tag: PropTypes.string, }), }).isRequired, @@ -53,8 +51,11 @@ function MoneyRequestTagPage({route, report, policyTags}) { const {translate} = useLocalize(); const iouType = lodashGet(route, 'params.iouType', ''); - const tag = lodashGet(route, 'params.tag', ''); - const tagName = lodashGet(policyTags, [tag, 'name'], ''); + + // Fetches the first tag list of the policy + const tagListKey = _.first(_.keys(policyTags)); + const tagList = lodashGet(policyTags, tagListKey, {}); + const tagListName = lodashGet(tagList, 'name', ''); const navigateBack = () => { Navigation.goBack(ROUTES.getMoneyRequestConfirmationRoute(iouType, lodashGet(report, 'reportID', ''))); @@ -66,14 +67,14 @@ function MoneyRequestTagPage({route, report, policyTags}) { shouldEnableMaxHeight > - {translate('iou.tagSelection', {tagName} || translate('common.tag'))} + {translate('iou.tagSelection', {tagListName} || translate('common.tag'))} diff --git a/src/types/onyx/PolicyTag.ts b/src/types/onyx/PolicyTag.ts index baee10d6e0d0..2dd4880ce086 100644 --- a/src/types/onyx/PolicyTag.ts +++ b/src/types/onyx/PolicyTag.ts @@ -4,6 +4,10 @@ type PolicyTag = { /** Flag that determines if a tag is active and able to be selected */ enabled: boolean; + + /** "General Ledger code" that corresponds to this category in an accounting system. Similar to an ID. */ + // eslint-disable-next-line @typescript-eslint/naming-convention + 'GL Code': string; }; export default PolicyTag; From be487e778beea017cf8e0913fa142d6c2c3b8140 Mon Sep 17 00:00:00 2001 From: Ana Margarida Silva Date: Tue, 12 Sep 2023 16:59:00 +0100 Subject: [PATCH 249/284] feat: improve translation types --- src/languages/en.ts | 2 +- src/languages/es.ts | 3 ++- src/languages/translations.ts | 10 +++++----- src/languages/types.ts | 32 +++++++++++++++++++++++++++++--- 4 files changed, 37 insertions(+), 10 deletions(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index e9fb2fc0fb7c..1f3e8048a7b0 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -1756,4 +1756,4 @@ export default { selectSuggestedAddress: 'Please select a suggested address', }, }, -} as Translation; +} satisfies Translation; diff --git a/src/languages/es.ts b/src/languages/es.ts index 3c5d98b724d2..7b7f736dc994 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -1,6 +1,7 @@ import CONST from '../CONST'; import * as ReportActionsUtils from '../libs/ReportActionsUtils'; import type { + Translation, AddressLineParams, CharacterLimitParams, MaxParticipantsReachedParams, @@ -2247,4 +2248,4 @@ export default { selectSuggestedAddress: 'Por favor, selecciona una dirección sugerida', }, }, -}; +} satisfies Translation; diff --git a/src/languages/translations.ts b/src/languages/translations.ts index e631c2f4522d..3a04190b2bff 100644 --- a/src/languages/translations.ts +++ b/src/languages/translations.ts @@ -1,7 +1,7 @@ import en from './en'; import es from './es'; import esES from './es-ES'; -import type {Translation, TranslationBaseValue, TranslationFlatObject} from './types'; +import type {Translation, TranslationFlatObject} from './types'; /** * Converts an object to it's flattened version. @@ -13,14 +13,14 @@ import type {Translation, TranslationBaseValue, TranslationFlatObject} from './t // Necessary to export so that it is accessible to the unit tests // eslint-disable-next-line rulesdir/no-inline-named-export export function flattenObject(obj: Translation): TranslationFlatObject { - const result: TranslationFlatObject = {}; + const result: Record = {}; const recursive = (data: Translation, key: string): void => { // If the data is a function or not a object (eg. a string or array), // it's the final value for the key being built and there is no need // for more recursion if (typeof data === 'function' || Array.isArray(data) || !(typeof data === 'object' && !!data)) { - result[key] = data as TranslationBaseValue; + result[key] = data; } else { let isEmpty = true; @@ -33,13 +33,13 @@ export function flattenObject(obj: Translation): TranslationFlatObject { // Check for when the object is empty but a key exists, so that // it defaults to an empty object if (isEmpty && key) { - result[key] = {} as TranslationBaseValue; + result[key] = ''; } } }; recursive(obj, ''); - return result; + return result as TranslationFlatObject; } export default { diff --git a/src/languages/types.ts b/src/languages/types.ts index dff6488312e7..124a67d05ad7 100644 --- a/src/languages/types.ts +++ b/src/languages/types.ts @@ -1,3 +1,5 @@ +import en from './en'; + type AddressLineParams = { lineNumber: number; }; @@ -190,16 +192,40 @@ type RemovedTheRequestParams = {valueName: string; oldValueToDisplay: string}; type UpdatedTheRequestParams = {valueName: string; newValueToDisplay: string; oldValueToDisplay: string}; +/* Translation Object types */ // eslint-disable-next-line @typescript-eslint/no-explicit-any -type TranslationBaseValue = string | string[] | ((args: any) => string); +type TranslationBaseValue = string | string[] | ((...args: any[]) => string); type Translation = {[key: string]: TranslationBaseValue | Translation}; -type TranslationFlatObject = Record; +/* Flat Translation Object types */ +// Flattens an object and returns concatenations of all the keys of nested objects +type FlattenObject = { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + [K in keyof T]: T[K] extends (...args: any[]) => any + ? `${Prefix}${K & string}` + : // eslint-disable-next-line @typescript-eslint/no-explicit-any + T[K] extends any[] + ? `${Prefix}${K & string}` + : // eslint-disable-next-line @typescript-eslint/ban-types + T[K] extends object + ? FlattenObject + : `${Prefix}${K & string}`; +}[keyof T]; + +// Retrieves a type for a given key path (calculated from the type above) +type TranslateType = Path extends keyof T ? T[Path] : Path extends `${infer K}.${infer Rest}` ? (K extends keyof T ? TranslateType : never) : never; + +type TranslationsType = typeof en; + +type TranslationPaths = FlattenObject; + +type TranslationFlatObject = { + [K in TranslationPaths]: TranslateType; +}; export type { Translation, - TranslationBaseValue, TranslationFlatObject, AddressLineParams, CharacterLimitParams, From 2931a451afb74738bc172868e97f8da9c596019c Mon Sep 17 00:00:00 2001 From: Ana Margarida Silva Date: Tue, 12 Sep 2023 17:15:11 +0100 Subject: [PATCH 250/284] refactor: rename generics --- src/languages/types.ts | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/languages/types.ts b/src/languages/types.ts index 124a67d05ad7..d0482bea8bfd 100644 --- a/src/languages/types.ts +++ b/src/languages/types.ts @@ -200,28 +200,28 @@ type Translation = {[key: string]: TranslationBaseValue | Translation}; /* Flat Translation Object types */ // Flattens an object and returns concatenations of all the keys of nested objects -type FlattenObject = { +type FlattenObject = { // eslint-disable-next-line @typescript-eslint/no-explicit-any - [K in keyof T]: T[K] extends (...args: any[]) => any - ? `${Prefix}${K & string}` + [TKey in keyof TObject]: TObject[TKey] extends (...args: any[]) => any + ? `${TPrefix}${TKey & string}` : // eslint-disable-next-line @typescript-eslint/no-explicit-any - T[K] extends any[] - ? `${Prefix}${K & string}` + TObject[TKey] extends any[] + ? `${TPrefix}${TKey & string}` : // eslint-disable-next-line @typescript-eslint/ban-types - T[K] extends object - ? FlattenObject - : `${Prefix}${K & string}`; -}[keyof T]; + TObject[TKey] extends object + ? FlattenObject + : `${TPrefix}${TKey & string}`; +}[keyof TObject]; // Retrieves a type for a given key path (calculated from the type above) -type TranslateType = Path extends keyof T ? T[Path] : Path extends `${infer K}.${infer Rest}` ? (K extends keyof T ? TranslateType : never) : never; +type TranslateType = TPath extends keyof TObject ? TObject[TPath] : TPath extends `${infer TKey}.${infer TRest}` ? (TKey extends keyof TObject ? TranslateType : never) : never; type TranslationsType = typeof en; type TranslationPaths = FlattenObject; type TranslationFlatObject = { - [K in TranslationPaths]: TranslateType; + [TKey in TranslationPaths]: TranslateType; }; export type { From 76ffe962f0889f7828c5f1d1c7b77f08a2feffcd Mon Sep 17 00:00:00 2001 From: Yauheni Pasiukevich Date: Thu, 24 Aug 2023 21:52:05 +0200 Subject: [PATCH 251/284] migrate 'cardStyles' to ts --- src/styles/cardStyles/index.js | 12 ------------ src/styles/cardStyles/index.native.js | 3 --- src/styles/cardStyles/index.native.ts | 5 +++++ src/styles/cardStyles/index.ts | 12 ++++++++++++ src/styles/cardStyles/types.ts | 6 ++++++ 5 files changed, 23 insertions(+), 15 deletions(-) delete mode 100644 src/styles/cardStyles/index.js delete mode 100644 src/styles/cardStyles/index.native.js create mode 100644 src/styles/cardStyles/index.native.ts create mode 100644 src/styles/cardStyles/index.ts create mode 100644 src/styles/cardStyles/types.ts diff --git a/src/styles/cardStyles/index.js b/src/styles/cardStyles/index.js deleted file mode 100644 index d8af8a627ffe..000000000000 --- a/src/styles/cardStyles/index.js +++ /dev/null @@ -1,12 +0,0 @@ -/** - * Get card style for cardStyleInterpolator - * @param {Number} screenWidth - * @returns {Object} - */ -export default function getCardStyles(screenWidth) { - return { - position: 'fixed', - width: screenWidth, - height: '100%', - }; -} diff --git a/src/styles/cardStyles/index.native.js b/src/styles/cardStyles/index.native.js deleted file mode 100644 index fef33f500708..000000000000 --- a/src/styles/cardStyles/index.native.js +++ /dev/null @@ -1,3 +0,0 @@ -export default function getCardStyles() { - return {}; -} diff --git a/src/styles/cardStyles/index.native.ts b/src/styles/cardStyles/index.native.ts new file mode 100644 index 000000000000..94b8758efd05 --- /dev/null +++ b/src/styles/cardStyles/index.native.ts @@ -0,0 +1,5 @@ +import GetCardStyles from './types'; + +const getCardStyles: GetCardStyles = () => ({}); + +export default getCardStyles; diff --git a/src/styles/cardStyles/index.ts b/src/styles/cardStyles/index.ts new file mode 100644 index 000000000000..823081b62904 --- /dev/null +++ b/src/styles/cardStyles/index.ts @@ -0,0 +1,12 @@ +import GetCardStyles from './types'; + +/** + * Get card style for cardStyleInterpolator + */ +const getCardStyles: GetCardStyles = (screenWidth) => ({ + position: 'fixed', + width: screenWidth, + height: '100%', +}); + +export default getCardStyles; diff --git a/src/styles/cardStyles/types.ts b/src/styles/cardStyles/types.ts new file mode 100644 index 000000000000..e1598b7696ff --- /dev/null +++ b/src/styles/cardStyles/types.ts @@ -0,0 +1,6 @@ +import {CSSProperties} from 'react'; +import {ViewStyle} from 'react-native'; + +type GetCardStyles = (screenWidth: number) => Partial>; + +export default GetCardStyles; From 8f8420afe666c5838a0c061caaf94f097196b13a Mon Sep 17 00:00:00 2001 From: Ana Margarida Silva Date: Tue, 12 Sep 2023 17:52:18 +0100 Subject: [PATCH 252/284] style: prettier --- src/languages/types.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/languages/types.ts b/src/languages/types.ts index d0482bea8bfd..17c5e1f1a07c 100644 --- a/src/languages/types.ts +++ b/src/languages/types.ts @@ -214,7 +214,13 @@ type FlattenObject = { }[keyof TObject]; // Retrieves a type for a given key path (calculated from the type above) -type TranslateType = TPath extends keyof TObject ? TObject[TPath] : TPath extends `${infer TKey}.${infer TRest}` ? (TKey extends keyof TObject ? TranslateType : never) : never; +type TranslateType = TPath extends keyof TObject + ? TObject[TPath] + : TPath extends `${infer TKey}.${infer TRest}` + ? TKey extends keyof TObject + ? TranslateType + : never + : never; type TranslationsType = typeof en; From c42584ce3bf4401d7cd51e7667475ddd81406a10 Mon Sep 17 00:00:00 2001 From: Ana Margarida Silva Date: Tue, 12 Sep 2023 17:55:02 +0100 Subject: [PATCH 253/284] fix: review fixes --- src/components/MoneyRequestConfirmationList.js | 2 +- src/components/tagPropTypes.js | 2 +- src/pages/iou/MoneyRequestTagPage.js | 2 +- src/types/onyx/PolicyTag.ts | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/MoneyRequestConfirmationList.js b/src/components/MoneyRequestConfirmationList.js index 188eb8db49d5..e1df58e38abc 100755 --- a/src/components/MoneyRequestConfirmationList.js +++ b/src/components/MoneyRequestConfirmationList.js @@ -525,7 +525,7 @@ function MoneyRequestConfirmationList(props) { shouldShowRightIcon={!props.isReadOnly} title={props.iouTag} description={tagListName || translate('common.tag')} - onPress={() => Navigation.navigate(ROUTES.getMoneyRequestTagRoute(props.iouType, props.reportID, tagListKey))} + onPress={() => Navigation.navigate(ROUTES.getMoneyRequestTagRoute(props.iouType, props.reportID))} style={[styles.moneyRequestMenuItem, styles.mb2]} disabled={didConfirm || props.isReadOnly} /> diff --git a/src/components/tagPropTypes.js b/src/components/tagPropTypes.js index 7c4a6d16483b..29d913dcd035 100644 --- a/src/components/tagPropTypes.js +++ b/src/components/tagPropTypes.js @@ -7,6 +7,6 @@ export default PropTypes.shape({ /** Flag that determines if a tag is active and able to be selected */ enabled: PropTypes.bool.isRequired, - /** "General Ledger code" that corresponds to this category in an accounting system. Similar to an ID. */ + /** "General Ledger code" that corresponds to this tag in an accounting system. Similar to an ID. */ 'GL Code': PropTypes.string, }); diff --git a/src/pages/iou/MoneyRequestTagPage.js b/src/pages/iou/MoneyRequestTagPage.js index cac295ff46fa..a1795d50df8a 100644 --- a/src/pages/iou/MoneyRequestTagPage.js +++ b/src/pages/iou/MoneyRequestTagPage.js @@ -19,7 +19,7 @@ import styles from '../../styles/styles'; const propTypes = { /** Navigation route context info provided by react navigation */ route: PropTypes.shape({ - /** Route specific parameters used on this screen via route :iouType/new/tag/:reportID/:tag? */ + /** Route specific parameters used on this screen via route :iouType/new/tag/:reportID? */ params: PropTypes.shape({ /** The type of IOU report, i.e. bill, request, send */ iouType: PropTypes.string, diff --git a/src/types/onyx/PolicyTag.ts b/src/types/onyx/PolicyTag.ts index 2dd4880ce086..fe6bee3a1f31 100644 --- a/src/types/onyx/PolicyTag.ts +++ b/src/types/onyx/PolicyTag.ts @@ -5,7 +5,7 @@ type PolicyTag = { /** Flag that determines if a tag is active and able to be selected */ enabled: boolean; - /** "General Ledger code" that corresponds to this category in an accounting system. Similar to an ID. */ + /** "General Ledger code" that corresponds to this tag in an accounting system. Similar to an ID. */ // eslint-disable-next-line @typescript-eslint/naming-convention 'GL Code': string; }; From eb54ef27386f0d851f869f2af24f361adec9e3c5 Mon Sep 17 00:00:00 2001 From: tienifr Date: Wed, 13 Sep 2023 02:07:34 +0700 Subject: [PATCH 254/284] fix: cannot edit money request in offline mode --- src/libs/ReportUtils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index 8b84555ca2a9..1f4e355986bb 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -2622,7 +2622,7 @@ function buildTransactionThread(reportAction, moneyRequestReportID) { participantAccountIDs, getTransactionReportName(reportAction), '', - lodashGet(getReport(reportAction.reportID), 'policyID', CONST.POLICY.OWNER_EMAIL_FAKE), + lodashGet(getReport(moneyRequestReportID), 'policyID', CONST.POLICY.OWNER_EMAIL_FAKE), CONST.POLICY.OWNER_ACCOUNT_ID_FAKE, false, '', From f155753306fa7f12489d1944ec8cff0e32da31cc Mon Sep 17 00:00:00 2001 From: tienifr Date: Wed, 13 Sep 2023 03:19:08 +0700 Subject: [PATCH 255/284] fix: lose focus in money request participant selector --- .../MoneyRequestParticipantsPage.js | 3 +++ .../MoneyRequestParticipantsSelector.js | 17 ++++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsPage.js b/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsPage.js index 968faa6e5f23..b44b956ac547 100644 --- a/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsPage.js +++ b/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsPage.js @@ -49,6 +49,7 @@ function MoneyRequestParticipantsPage(props) { const prevMoneyRequestId = useRef(props.iou.id); const iouType = useRef(lodashGet(props.route, 'params.iouType', '')); const reportID = useRef(lodashGet(props.route, 'params.reportID', '')); + const optionsSelectorRef = useRef(); const isDistanceRequest = MoneyRequestUtils.isDistanceRequest(iouType.current, props.selectedTab); const navigateToNextStep = () => { @@ -88,6 +89,7 @@ function MoneyRequestParticipantsPage(props) { optionsSelectorRef.current && optionsSelectorRef.current.focus()} > {({safeAreaPaddingBottomStyle}) => ( @@ -104,6 +106,7 @@ function MoneyRequestParticipantsPage(props) { /> ) : ( (optionsSelectorRef.current = el)} onStepComplete={navigateToNextStep} onAddParticipants={IOU.setMoneyRequestParticipants} safeAreaPaddingBottomStyle={safeAreaPaddingBottomStyle} diff --git a/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsSelector.js b/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsSelector.js index ef1d6565f595..8dcd6e5e08bf 100755 --- a/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsSelector.js +++ b/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsSelector.js @@ -11,11 +11,15 @@ import compose from '../../../../libs/compose'; import CONST from '../../../../CONST'; import personalDetailsPropType from '../../../personalDetailsPropType'; import reportPropTypes from '../../../reportPropTypes'; +import refPropTypes from "../../../../components/refPropTypes"; const propTypes = { /** Beta features list */ betas: PropTypes.arrayOf(PropTypes.string), + /** A ref to forward to options selector's text input */ + forwardedRef: refPropTypes, + /** Callback to inform parent modal of success */ onStepComplete: PropTypes.func.isRequired, @@ -41,6 +45,7 @@ const propTypes = { }; const defaultProps = { + forwardedRef: undefined, safeAreaPaddingBottomStyle: {}, personalDetails: {}, reports: {}, @@ -161,6 +166,8 @@ class MoneyRequestParticipantsSelector extends Component { return ( ( + + )) +); From 54f0ee6e5e8ba63548441631219000782dc14ebd Mon Sep 17 00:00:00 2001 From: tienifr Date: Wed, 13 Sep 2023 03:36:06 +0700 Subject: [PATCH 256/284] fix lint --- .../MoneyRequestParticipantsSelector.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsSelector.js b/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsSelector.js index 8dcd6e5e08bf..693a55b14e07 100755 --- a/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsSelector.js +++ b/src/pages/iou/steps/MoneyRequstParticipantsPage/MoneyRequestParticipantsSelector.js @@ -11,7 +11,7 @@ import compose from '../../../../libs/compose'; import CONST from '../../../../CONST'; import personalDetailsPropType from '../../../personalDetailsPropType'; import reportPropTypes from '../../../reportPropTypes'; -import refPropTypes from "../../../../components/refPropTypes"; +import refPropTypes from '../../../../components/refPropTypes'; const propTypes = { /** Beta features list */ @@ -205,5 +205,5 @@ export default compose( {...props} forwardedRef={ref} /> - )) + )), ); From ad7822759d2e5cfbedb383c659b468e413db4afa Mon Sep 17 00:00:00 2001 From: Yauheni Date: Wed, 13 Sep 2023 01:14:11 +0200 Subject: [PATCH 257/284] Fix bug with toggle attribution button is not placed on the right position for android --- src/components/MapView/MapView.tsx | 3 +++ src/styles/utilities/positioning.ts | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/components/MapView/MapView.tsx b/src/components/MapView/MapView.tsx index aebd63edf559..bfe042f2e217 100644 --- a/src/components/MapView/MapView.tsx +++ b/src/components/MapView/MapView.tsx @@ -2,6 +2,7 @@ import {View} from 'react-native'; import {useFocusEffect} from '@react-navigation/native'; import Mapbox, {MapState, MarkerView, setAccessToken} from '@rnmapbox/maps'; import {forwardRef, memo, useCallback, useEffect, useImperativeHandle, useRef, useState} from 'react'; +import styles from '../../styles/styles'; import responder from './responder'; import utils from './utils'; @@ -64,6 +65,8 @@ const MapView = forwardRef(({accessToken, style, ma styleURL={styleURL} onMapIdle={setMapIdle} pitchEnabled={pitchEnabled} + attributionPosition={{ ...styles.r2, ...styles.b2 }} + logoPosition={{ ...styles.l2, ...styles.b2 }} // eslint-disable-next-line {...responder.panHandlers} > diff --git a/src/styles/utilities/positioning.ts b/src/styles/utilities/positioning.ts index fc505e4cb608..dfecfcc12a78 100644 --- a/src/styles/utilities/positioning.ts +++ b/src/styles/utilities/positioning.ts @@ -47,4 +47,7 @@ export default { b0: { bottom: 0, }, + b2:{ + bottom: 8, + } } satisfies Record; From faec65c047bdce0deae422a16fbf18d3058dd476 Mon Sep 17 00:00:00 2001 From: Yauheni Date: Wed, 13 Sep 2023 01:24:23 +0200 Subject: [PATCH 258/284] Fix spaces --- src/components/MapView/MapView.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/MapView/MapView.tsx b/src/components/MapView/MapView.tsx index bfe042f2e217..c04f1e839258 100644 --- a/src/components/MapView/MapView.tsx +++ b/src/components/MapView/MapView.tsx @@ -65,8 +65,8 @@ const MapView = forwardRef(({accessToken, style, ma styleURL={styleURL} onMapIdle={setMapIdle} pitchEnabled={pitchEnabled} - attributionPosition={{ ...styles.r2, ...styles.b2 }} - logoPosition={{ ...styles.l2, ...styles.b2 }} + attributionPosition={{ ...styles.r2, ...styles.b2 }} + logoPosition={{ ...styles.l2, ...styles.b2 }} // eslint-disable-next-line {...responder.panHandlers} > From 350f082402b61befc936821d0096a2e61fe3c8cc Mon Sep 17 00:00:00 2001 From: Yauheni Date: Wed, 13 Sep 2023 01:24:56 +0200 Subject: [PATCH 259/284] Fix spaces x2 --- src/styles/utilities/positioning.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/styles/utilities/positioning.ts b/src/styles/utilities/positioning.ts index dfecfcc12a78..adba1f37a9e8 100644 --- a/src/styles/utilities/positioning.ts +++ b/src/styles/utilities/positioning.ts @@ -47,7 +47,7 @@ export default { b0: { bottom: 0, }, - b2:{ + b2: { bottom: 8, } } satisfies Record; From 10c41da000bb36d46da014111921b04ddadae50d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Ch=C3=A1vez?= Date: Wed, 13 Sep 2023 13:38:53 +0800 Subject: [PATCH 260/284] moving the workspace route to its original place --- .well-known/apple-app-site-association | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.well-known/apple-app-site-association b/.well-known/apple-app-site-association index 9097ad8f5be7..c871764117ed 100644 --- a/.well-known/apple-app-site-association +++ b/.well-known/apple-app-site-association @@ -64,13 +64,13 @@ "/": "/new/*", "comment": "New Chat" }, - { - "/": "/teachersunite/*", - "comment": "Teachers Unite!" - }, { "/": "/workspace/*", "comment": "Workspace Details" + }, + { + "/": "/teachersunite/*", + "comment": "Teachers Unite!" } ] } From d3be54d72d107d79e09d242a61d085cc5429917c Mon Sep 17 00:00:00 2001 From: Blazej Kustra Date: Wed, 13 Sep 2023 09:53:31 +0200 Subject: [PATCH 261/284] Improve translations: keep translations in sync --- src/languages/en.ts | 17 +++++++++++++---- src/languages/es.ts | 2 +- src/languages/translations.ts | 8 ++++---- src/languages/types.ts | 9 +++++---- 4 files changed, 23 insertions(+), 13 deletions(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index a8b093b2adae..77f8e0c8ec1c 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -1,7 +1,6 @@ import {CONST as COMMON_CONST} from 'expensify-common/lib/CONST'; import CONST from '../CONST'; import type { - Translation, AddressLineParams, CharacterLimitParams, MaxParticipantsReachedParams, @@ -75,6 +74,16 @@ import type { } from './types'; import * as ReportActionsUtils from '../libs/ReportActionsUtils'; +type States = Record< + keyof typeof COMMON_CONST.STATES, + { + stateISO: string; + stateName: string; + } +>; + +type AllCountries = Record; + /* eslint-disable max-len */ export default { common: { @@ -1662,8 +1671,8 @@ export default { createAccount: 'Create A New Account', logIn: 'Log In', }, - allStates: COMMON_CONST.STATES, - allCountries: CONST.ALL_COUNTRIES, + allStates: COMMON_CONST.STATES as States, + allCountries: CONST.ALL_COUNTRIES as AllCountries, accessibilityHints: { navigateToChatsList: 'Navigate back to chats list', chatWelcomeMessage: 'Chat welcome message', @@ -1757,4 +1766,4 @@ export default { selectSuggestedAddress: 'Please select a suggested address', }, }, -} satisfies Translation; +}; diff --git a/src/languages/es.ts b/src/languages/es.ts index d3525f0375e4..6bbf0cff9d89 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -1,7 +1,6 @@ import CONST from '../CONST'; import * as ReportActionsUtils from '../libs/ReportActionsUtils'; import type { - Translation, AddressLineParams, CharacterLimitParams, MaxParticipantsReachedParams, @@ -72,6 +71,7 @@ import type { SetTheRequestParams, UpdatedTheRequestParams, RemovedTheRequestParams, + Translation, } from './types'; /* eslint-disable max-len */ diff --git a/src/languages/translations.ts b/src/languages/translations.ts index 3a04190b2bff..d228394589b2 100644 --- a/src/languages/translations.ts +++ b/src/languages/translations.ts @@ -1,7 +1,7 @@ import en from './en'; import es from './es'; import esES from './es-ES'; -import type {Translation, TranslationFlatObject} from './types'; +import type {TranslationBase, TranslationFlatObject} from './types'; /** * Converts an object to it's flattened version. @@ -12,10 +12,10 @@ import type {Translation, TranslationFlatObject} from './types'; */ // Necessary to export so that it is accessible to the unit tests // eslint-disable-next-line rulesdir/no-inline-named-export -export function flattenObject(obj: Translation): TranslationFlatObject { +export function flattenObject(obj: TranslationBase): TranslationFlatObject { const result: Record = {}; - const recursive = (data: Translation, key: string): void => { + const recursive = (data: TranslationBase, key: string): void => { // If the data is a function or not a object (eg. a string or array), // it's the final value for the key being built and there is no need // for more recursion @@ -27,7 +27,7 @@ export function flattenObject(obj: Translation): TranslationFlatObject { // Recursive call to the keys and connect to the respective data Object.keys(data).forEach((k) => { isEmpty = false; - recursive(data[k] as Translation, key ? `${key}.${k}` : k); + recursive(data[k] as TranslationBase, key ? `${key}.${k}` : k); }); // Check for when the object is empty but a key exists, so that diff --git a/src/languages/types.ts b/src/languages/types.ts index 17c5e1f1a07c..358cb206a0ec 100644 --- a/src/languages/types.ts +++ b/src/languages/types.ts @@ -196,7 +196,7 @@ type UpdatedTheRequestParams = {valueName: string; newValueToDisplay: string; ol // eslint-disable-next-line @typescript-eslint/no-explicit-any type TranslationBaseValue = string | string[] | ((...args: any[]) => string); -type Translation = {[key: string]: TranslationBaseValue | Translation}; +type TranslationBase = {[key: string]: TranslationBaseValue | TranslationBase}; /* Flat Translation Object types */ // Flattens an object and returns concatenations of all the keys of nested objects @@ -222,15 +222,16 @@ type TranslateType = TPath extends keyof TObject : never : never; -type TranslationsType = typeof en; +type Translation = typeof en; -type TranslationPaths = FlattenObject; +type TranslationPaths = FlattenObject; type TranslationFlatObject = { - [TKey in TranslationPaths]: TranslateType; + [TKey in TranslationPaths]: TranslateType; }; export type { + TranslationBase, Translation, TranslationFlatObject, AddressLineParams, From 43467f77da905ab292117ae10703a01eaa197e97 Mon Sep 17 00:00:00 2001 From: Yauheni Date: Wed, 13 Sep 2023 09:58:30 +0200 Subject: [PATCH 262/284] Fix prettier issues --- src/components/MapView/MapView.tsx | 4 ++-- src/styles/utilities/positioning.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/MapView/MapView.tsx b/src/components/MapView/MapView.tsx index c04f1e839258..0431a02695ec 100644 --- a/src/components/MapView/MapView.tsx +++ b/src/components/MapView/MapView.tsx @@ -65,8 +65,8 @@ const MapView = forwardRef(({accessToken, style, ma styleURL={styleURL} onMapIdle={setMapIdle} pitchEnabled={pitchEnabled} - attributionPosition={{ ...styles.r2, ...styles.b2 }} - logoPosition={{ ...styles.l2, ...styles.b2 }} + attributionPosition={{...styles.r2, ...styles.b2}} + logoPosition={{...styles.l2, ...styles.b2}} // eslint-disable-next-line {...responder.panHandlers} > diff --git a/src/styles/utilities/positioning.ts b/src/styles/utilities/positioning.ts index adba1f37a9e8..651d2a12f2ea 100644 --- a/src/styles/utilities/positioning.ts +++ b/src/styles/utilities/positioning.ts @@ -49,5 +49,5 @@ export default { }, b2: { bottom: 8, - } + }, } satisfies Record; From 3f40a657870c7695f82237953339ff9c573b7b85 Mon Sep 17 00:00:00 2001 From: Ana Margarida Silva Date: Wed, 13 Sep 2023 09:19:52 +0100 Subject: [PATCH 263/284] fix: small comment fix and code simplification --- src/components/MoneyRequestConfirmationList.js | 4 ++-- src/components/TagPicker/tagPickerPropTypes.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/MoneyRequestConfirmationList.js b/src/components/MoneyRequestConfirmationList.js index e1df58e38abc..4cf4d2d74be9 100755 --- a/src/components/MoneyRequestConfirmationList.js +++ b/src/components/MoneyRequestConfirmationList.js @@ -520,7 +520,7 @@ function MoneyRequestConfirmationList(props) { disabled={didConfirm || props.isReadOnly} /> )} - {canUseTags && tagList ? ( + {canUseTags && !!tagList && ( - ) : null} + )} )} diff --git a/src/components/TagPicker/tagPickerPropTypes.js b/src/components/TagPicker/tagPickerPropTypes.js index 250b22cfddf4..ad57a0409f15 100644 --- a/src/components/TagPicker/tagPickerPropTypes.js +++ b/src/components/TagPicker/tagPickerPropTypes.js @@ -9,7 +9,7 @@ const propTypes = { /** The policyID we are getting tags for */ policyID: PropTypes.string.isRequired, - /** The tag list we are getting tags for */ + /** The name of tag list we are getting tags for */ tag: PropTypes.string.isRequired, /** The type of IOU report, i.e. bill, request, send */ From 40eabd8acd554793d69b3143fb8a8955fc02da21 Mon Sep 17 00:00:00 2001 From: Ana Margarida Silva Date: Wed, 13 Sep 2023 09:25:23 +0100 Subject: [PATCH 264/284] fix: remove duplicated key from merge with main --- src/components/MoneyRequestConfirmationList.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/components/MoneyRequestConfirmationList.js b/src/components/MoneyRequestConfirmationList.js index 615b390aaef2..cfc9289b9168 100755 --- a/src/components/MoneyRequestConfirmationList.js +++ b/src/components/MoneyRequestConfirmationList.js @@ -146,9 +146,6 @@ const propTypes = { tags: PropTypes.objectOf(tagPropTypes), }), ), - - /* Beta features list */ - betas: PropTypes.arrayOf(PropTypes.string), }; const defaultProps = { From 02d1ddddc7bbb907bfddbedcd4bd649635d6d03f Mon Sep 17 00:00:00 2001 From: Ana Margarida Silva Date: Wed, 13 Sep 2023 09:26:16 +0100 Subject: [PATCH 265/284] fix: remove duplicated key --- src/components/MoneyRequestConfirmationList.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/MoneyRequestConfirmationList.js b/src/components/MoneyRequestConfirmationList.js index cfc9289b9168..966f5f4340a7 100755 --- a/src/components/MoneyRequestConfirmationList.js +++ b/src/components/MoneyRequestConfirmationList.js @@ -171,7 +171,6 @@ const defaultProps = { listStyles: [], policyCategories: {}, policyTags: {}, - betas: [], transactionID: '', transaction: {}, mileageRate: {unit: CONST.CUSTOM_UNITS.DISTANCE_UNIT_MILES, rate: 0, currency: 'USD'}, From 9b0d92f5ef4cfb256029fab226ef0d456b02ce37 Mon Sep 17 00:00:00 2001 From: OSBotify Date: Wed, 13 Sep 2023 08:26:58 +0000 Subject: [PATCH 266/284] Update version to 1.3.69-0 --- android/app/build.gradle | 4 ++-- ios/NewExpensify/Info.plist | 4 ++-- ios/NewExpensifyTests/Info.plist | 4 ++-- package-lock.json | 4 ++-- package.json | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index 64dd8a10eb44..534c1e38c958 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -90,8 +90,8 @@ android { minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion multiDexEnabled rootProject.ext.multiDexEnabled - versionCode 1001036817 - versionName "1.3.68-17" + versionCode 1001036900 + versionName "1.3.69-0" } flavorDimensions "default" diff --git a/ios/NewExpensify/Info.plist b/ios/NewExpensify/Info.plist index bb7c187963ec..4d8c217ade89 100644 --- a/ios/NewExpensify/Info.plist +++ b/ios/NewExpensify/Info.plist @@ -19,7 +19,7 @@ CFBundlePackageType APPL CFBundleShortVersionString - 1.3.68 + 1.3.69 CFBundleSignature ???? CFBundleURLTypes @@ -40,7 +40,7 @@ CFBundleVersion - 1.3.68.17 + 1.3.69.0 ITSAppUsesNonExemptEncryption LSApplicationQueriesSchemes diff --git a/ios/NewExpensifyTests/Info.plist b/ios/NewExpensifyTests/Info.plist index 425fc3525ebd..54e6a723c383 100644 --- a/ios/NewExpensifyTests/Info.plist +++ b/ios/NewExpensifyTests/Info.plist @@ -15,10 +15,10 @@ CFBundlePackageType BNDL CFBundleShortVersionString - 1.3.68 + 1.3.69 CFBundleSignature ???? CFBundleVersion - 1.3.68.17 + 1.3.69.0 diff --git a/package-lock.json b/package-lock.json index 09b1c343613a..a46ea3ce2880 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "new.expensify", - "version": "1.3.68-17", + "version": "1.3.69-0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "new.expensify", - "version": "1.3.68-17", + "version": "1.3.69-0", "hasInstallScript": true, "license": "MIT", "dependencies": { diff --git a/package.json b/package.json index 2e1bc5905a61..a89542bda646 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "new.expensify", - "version": "1.3.68-17", + "version": "1.3.69-0", "author": "Expensify, Inc.", "homepage": "https://new.expensify.com", "description": "New Expensify is the next generation of Expensify: a reimagination of payments based atop a foundation of chat.", From 88525b3e8ffedcad73ce68b947905a7de2ab06c2 Mon Sep 17 00:00:00 2001 From: Blazej Kustra Date: Wed, 13 Sep 2023 11:41:40 +0200 Subject: [PATCH 267/284] Fix names and clean a bit --- src/languages/en.ts | 13 ++++++------- src/languages/es.ts | 4 ++-- src/languages/types.ts | 8 ++++---- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index 77f8e0c8ec1c..a667c38e9662 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -74,13 +74,12 @@ import type { } from './types'; import * as ReportActionsUtils from '../libs/ReportActionsUtils'; -type States = Record< - keyof typeof COMMON_CONST.STATES, - { - stateISO: string; - stateName: string; - } ->; +type StateValue = { + stateISO: string; + stateName: string; +}; + +type States = Record; type AllCountries = Record; diff --git a/src/languages/es.ts b/src/languages/es.ts index 6bbf0cff9d89..f562ed5fd536 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -71,7 +71,7 @@ import type { SetTheRequestParams, UpdatedTheRequestParams, RemovedTheRequestParams, - Translation, + EnglishTranslation, } from './types'; /* eslint-disable max-len */ @@ -2249,4 +2249,4 @@ export default { selectSuggestedAddress: 'Por favor, selecciona una dirección sugerida', }, }, -} satisfies Translation; +} satisfies EnglishTranslation; diff --git a/src/languages/types.ts b/src/languages/types.ts index 358cb206a0ec..5d1963b404f4 100644 --- a/src/languages/types.ts +++ b/src/languages/types.ts @@ -222,17 +222,17 @@ type TranslateType = TPath extends keyof TObject : never : never; -type Translation = typeof en; +type EnglishTranslation = typeof en; -type TranslationPaths = FlattenObject; +type TranslationPaths = FlattenObject; type TranslationFlatObject = { - [TKey in TranslationPaths]: TranslateType; + [TKey in TranslationPaths]: TranslateType; }; export type { TranslationBase, - Translation, + EnglishTranslation, TranslationFlatObject, AddressLineParams, CharacterLimitParams, From f3af4fa5da9e1d56ed8271f90fc78b339776f38f Mon Sep 17 00:00:00 2001 From: Blazej Kustra Date: Wed, 13 Sep 2023 12:08:14 +0200 Subject: [PATCH 268/284] [No QA][TS migration] Improve translations: keep translations in sync --- src/languages/en.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index a667c38e9662..8d2782f4b8ae 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -71,6 +71,7 @@ import type { SetTheRequestParams, UpdatedTheRequestParams, RemovedTheRequestParams, + TranslationBase, } from './types'; import * as ReportActionsUtils from '../libs/ReportActionsUtils'; @@ -1765,4 +1766,4 @@ export default { selectSuggestedAddress: 'Please select a suggested address', }, }, -}; +} satisfies TranslationBase; From 7c8ffcf0ca1b66067e30a2ac1de2e9a025b294d5 Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Wed, 13 Sep 2023 12:43:43 +0200 Subject: [PATCH 269/284] feat: improve how we use static styles in ThemeStylesProvider --- src/styles/ThemeStylesProvider.tsx | 22 +- src/styles/styles.js | 579 +++++++++++++++-------------- 2 files changed, 296 insertions(+), 305 deletions(-) diff --git a/src/styles/ThemeStylesProvider.tsx b/src/styles/ThemeStylesProvider.tsx index d8a081572644..0a32d2de1cf7 100644 --- a/src/styles/ThemeStylesProvider.tsx +++ b/src/styles/ThemeStylesProvider.tsx @@ -2,7 +2,9 @@ import React, {useMemo} from 'react'; import useTheme from './themes/useTheme'; import StylesContext from './ThemeStylesContext'; -import defaultStyles from './styles'; +import {styles as stylesUntyped} from './styles'; + +const styles = stylesUntyped as (theme: Record) => Record; type ThemeStylesProviderProps = { children: React.ReactNode; @@ -11,23 +13,9 @@ type ThemeStylesProviderProps = { function ThemeStylesProvider({children}: ThemeStylesProviderProps) { const theme = useTheme(); - const appContentStyle = useMemo( - () => ({ - ...defaultStyles.appContent, - backgroundColor: theme.appBG, - }), - [theme.appBG], - ); - - const styles = useMemo( - () => ({ - ...defaultStyles, - appContent: appContentStyle, - }), - [appContentStyle], - ); + const themeStyles = useMemo(() => styles(theme), [theme]); - return {children}; + return {children}; } ThemeStylesProvider.displayName = 'ThemeStylesProvider'; diff --git a/src/styles/styles.js b/src/styles/styles.js index 29d4541c9b4a..9cc18b6c44a0 100644 --- a/src/styles/styles.js +++ b/src/styles/styles.js @@ -2,7 +2,7 @@ import {defaultStyles as defaultPickerStyles} from 'react-native-picker-select/s import lodashClamp from 'lodash/clamp'; import fontFamily from './fontFamily'; import addOutlineWidth from './addOutlineWidth'; -import themeColors from './themes/default'; +import defaultTheme from './themes/default'; import fontWeightBold from './fontWeight/bold'; import variables from './variables'; import spacing from './utilities/spacing'; @@ -31,9 +31,9 @@ import Colors from './colors'; // touchCallout is an iOS safari only property that controls the display of the callout information when you touch and hold a target const touchCalloutNone = Browser.isMobileSafari() ? {WebkitTouchCallout: 'none'} : {}; -const picker = { - backgroundColor: themeColors.transparent, - color: themeColors.text, +const picker = (theme) => ({ + backgroundColor: theme.transparent, + color: theme.text, fontFamily: fontFamily.EXP_NEUE, fontSize: variables.fontSizeNormal, lineHeight: variables.fontSizeNormalHeight, @@ -44,27 +44,27 @@ const picker = { height: variables.inputHeight, borderWidth: 0, textAlign: 'left', -}; +}); -const link = { - color: themeColors.link, - textDecorationColor: themeColors.link, +const link = (theme) => ({ + color: theme.link, + textDecorationColor: theme.link, fontFamily: fontFamily.EXP_NEUE, -}; +}); -const baseCodeTagStyles = { +const baseCodeTagStyles = (theme) => ({ borderWidth: 1, borderRadius: 5, - borderColor: themeColors.border, - backgroundColor: themeColors.textBackground, -}; + borderColor: theme.border, + backgroundColor: theme.textBackground, +}); const headlineFont = { fontFamily: fontFamily.EXP_NEW_KANSAS_MEDIUM, fontWeight: '500', }; -const webViewStyles = { +const webViewStyles = (theme) => ({ // As of react-native-render-html v6, don't declare distinct styles for // custom renderers, the API for custom renderers has changed. Declare the // styles in the below "tagStyles" instead. If you need to reuse those @@ -86,7 +86,7 @@ const webViewStyles = { fontWeight: 'bold', }, - a: link, + a: link(theme), ul: { maxWidth: '100%', @@ -101,7 +101,7 @@ const webViewStyles = { }, blockquote: { - borderLeftColor: themeColors.border, + borderLeftColor: theme.border, borderLeftWidth: 4, paddingLeft: 12, marginTop: 4, @@ -112,7 +112,7 @@ const webViewStyles = { }, pre: { - ...baseCodeTagStyles, + ...baseCodeTagStyles(theme), paddingTop: 12, paddingBottom: 12, paddingRight: 8, @@ -123,7 +123,7 @@ const webViewStyles = { }, code: { - ...baseCodeTagStyles, + ...baseCodeTagStyles(theme), ...codeStyles.codeTextStyle, paddingLeft: 5, paddingRight: 5, @@ -132,7 +132,7 @@ const webViewStyles = { }, img: { - borderColor: themeColors.border, + borderColor: theme.border, borderRadius: variables.componentBorderRadiusNormal, borderWidth: 1, ...touchCalloutNone, @@ -149,15 +149,15 @@ const webViewStyles = { }, baseFontStyle: { - color: themeColors.text, + color: theme.text, fontSize: variables.fontSizeNormal, fontFamily: fontFamily.EXP_NEUE, flex: 1, lineHeight: variables.fontSizeNormalHeight, }, -}; +}); -const styles = { +const styles = (theme) => ({ // Add all of our utility and helper styles ...spacing, ...sizing, @@ -170,8 +170,8 @@ const styles = { ...writingDirection, ...cursor, ...userSelect, - ...themeColors, ...textUnderline, + ...theme, // TODO: Should we do this? rateCol: { margin: 0, @@ -180,10 +180,10 @@ const styles = { }, autoCompleteSuggestionsContainer: { - backgroundColor: themeColors.appBG, + backgroundColor: theme.appBG, borderRadius: 8, borderWidth: 1, - borderColor: themeColors.border, + borderColor: theme.border, justifyContent: 'center', boxShadow: variables.popoverMenuShadow, position: 'absolute', @@ -227,7 +227,7 @@ const styles = { }, mentionSuggestionsHandle: { - color: themeColors.textSupporting, + color: theme.textSupporting, }, appIconBorderRadius: { @@ -242,30 +242,30 @@ const styles = { flexBasis: '48%', }, - webViewStyles, + webViewStyles: webViewStyles(theme), - link, + link: link(theme), linkMuted: { - color: themeColors.textSupporting, - textDecorationColor: themeColors.textSupporting, + color: theme.textSupporting, + textDecorationColor: theme.textSupporting, fontFamily: fontFamily.EXP_NEUE, }, linkMutedHovered: { - color: themeColors.textMutedReversed, + color: theme.textMutedReversed, }, highlightBG: { - backgroundColor: themeColors.highlightBG, + backgroundColor: theme.highlightBG, }, appBG: { - backgroundColor: themeColors.appBG, + backgroundColor: theme.appBG, }, h1: { - color: themeColors.heading, + color: theme.heading, fontFamily: fontFamily.EXP_NEUE_BOLD, fontSize: variables.fontSizeh1, fontWeight: fontWeightBold, @@ -305,13 +305,13 @@ const styles = { }, textLabel: { - color: themeColors.text, + color: theme.text, fontSize: variables.fontSizeLabel, lineHeight: variables.lineHeightLarge, }, mutedTextLabel: { - color: themeColors.textSupporting, + color: theme.textSupporting, fontSize: variables.fontSizeLabel, lineHeight: variables.lineHeightLarge, }, @@ -323,7 +323,7 @@ const styles = { }, textMicroBold: { - color: themeColors.text, + color: theme.text, fontWeight: fontWeightBold, fontFamily: fontFamily.EXP_NEUE_BOLD, fontSize: variables.fontSizeSmall, @@ -331,14 +331,14 @@ const styles = { }, textMicroSupporting: { - color: themeColors.textSupporting, + color: theme.textSupporting, fontFamily: fontFamily.EXP_NEUE, fontSize: variables.fontSizeSmall, lineHeight: variables.lineHeightSmall, }, textExtraSmallSupporting: { - color: themeColors.textSupporting, + color: theme.textSupporting, fontFamily: fontFamily.EXP_NEUE, fontSize: variables.fontSizeExtraSmall, }, @@ -382,7 +382,7 @@ const styles = { textHeadline: { ...headlineFont, ...whiteSpace.preWrap, - color: themeColors.heading, + color: theme.heading, fontSize: variables.fontSizeXLarge, lineHeight: variables.lineHeightXXLarge, }, @@ -390,7 +390,7 @@ const styles = { textHeadlineH1: { ...headlineFont, ...whiteSpace.preWrap, - color: themeColors.heading, + color: theme.heading, fontSize: variables.fontSizeh1, lineHeight: variables.lineHeightSizeh1, }, @@ -400,11 +400,11 @@ const styles = { }, textWhite: { - color: themeColors.textLight, + color: theme.textLight, }, textBlue: { - color: themeColors.link, + color: theme.link, }, textUppercase: { @@ -416,19 +416,19 @@ const styles = { }, colorReversed: { - color: themeColors.textReversed, + color: theme.textReversed, }, colorMutedReversed: { - color: themeColors.textMutedReversed, + color: theme.textMutedReversed, }, colorMuted: { - color: themeColors.textSupporting, + color: theme.textSupporting, }, colorHeading: { - color: themeColors.heading, + color: theme.heading, }, bgTransparent: { @@ -436,7 +436,7 @@ const styles = { }, bgDark: { - backgroundColor: themeColors.inverse, + backgroundColor: theme.inverse, }, opacity0: { @@ -448,7 +448,7 @@ const styles = { }, textDanger: { - color: themeColors.danger, + color: theme.danger, }, borderRadiusNormal: { @@ -456,7 +456,7 @@ const styles = { }, button: { - backgroundColor: themeColors.buttonDefaultBG, + backgroundColor: theme.buttonDefaultBG, borderRadius: variables.buttonBorderRadius, minHeight: variables.componentSizeLarge, justifyContent: 'center', @@ -469,7 +469,7 @@ const styles = { }, buttonText: { - color: themeColors.text, + color: theme.text, fontFamily: fontFamily.EXP_NEUE_BOLD, fontSize: variables.fontSizeNormal, fontWeight: fontWeightBold, @@ -490,7 +490,7 @@ const styles = { paddingTop: 4, paddingHorizontal: 14, paddingBottom: 4, - backgroundColor: themeColors.buttonDefaultBG, + backgroundColor: theme.buttonDefaultBG, }, buttonMedium: { @@ -500,7 +500,7 @@ const styles = { paddingRight: 16, paddingBottom: 12, paddingLeft: 16, - backgroundColor: themeColors.buttonDefaultBG, + backgroundColor: theme.buttonDefaultBG, }, buttonLarge: { @@ -510,7 +510,7 @@ const styles = { paddingRight: 10, paddingBottom: 8, paddingLeft: 18, - backgroundColor: themeColors.buttonDefaultBG, + backgroundColor: theme.buttonDefaultBG, }, buttonSmallText: { @@ -535,12 +535,12 @@ const styles = { }, buttonDefaultHovered: { - backgroundColor: themeColors.buttonHoveredBG, + backgroundColor: theme.buttonHoveredBG, borderWidth: 0, }, buttonSuccess: { - backgroundColor: themeColors.success, + backgroundColor: theme.success, borderWidth: 0, }, @@ -549,29 +549,29 @@ const styles = { }, buttonSuccessHovered: { - backgroundColor: themeColors.successHover, + backgroundColor: theme.successHover, borderWidth: 0, }, buttonDanger: { - backgroundColor: themeColors.danger, + backgroundColor: theme.danger, borderWidth: 0, }, buttonDangerHovered: { - backgroundColor: themeColors.dangerHover, + backgroundColor: theme.dangerHover, borderWidth: 0, }, buttonDisabled: { - backgroundColor: themeColors.buttonDefaultBG, + backgroundColor: theme.buttonDefaultBG, borderWidth: 0, }, buttonDivider: { height: variables.dropDownButtonDividerHeight, borderWidth: 0.7, - borderColor: themeColors.text, + borderColor: theme.text, }, noBorderRadius: { @@ -616,19 +616,19 @@ const styles = { }, buttonSuccessText: { - color: themeColors.textLight, + color: theme.textLight, }, buttonDangerText: { - color: themeColors.textLight, + color: theme.textLight, }, hoveredComponentBG: { - backgroundColor: themeColors.hoverComponentBG, + backgroundColor: theme.hoverComponentBG, }, activeComponentBG: { - backgroundColor: themeColors.activeComponentBG, + backgroundColor: theme.activeComponentBG, }, fontWeightBold: { @@ -658,7 +658,7 @@ const styles = { height: 140, }, - pickerSmall: (backgroundColor = themeColors.highlightBG) => ({ + pickerSmall: (backgroundColor = theme.highlightBG) => ({ inputIOS: { fontFamily: fontFamily.EXP_NEUE, fontSize: variables.fontSizeSmall, @@ -667,23 +667,23 @@ const styles = { paddingTop: 6, paddingBottom: 6, borderWidth: 0, - color: themeColors.text, + color: theme.text, height: 26, opacity: 1, backgroundColor: 'transparent', }, done: { - color: themeColors.text, + color: theme.text, }, doneDepressed: { fontSize: defaultPickerStyles.done.fontSize, }, modalViewMiddle: { - backgroundColor: themeColors.border, + backgroundColor: theme.border, borderTopWidth: 0, }, modalViewBottom: { - backgroundColor: themeColors.highlightBG, + backgroundColor: theme.highlightBG, }, inputWeb: { fontFamily: fontFamily.EXP_NEUE, @@ -693,7 +693,7 @@ const styles = { paddingTop: 6, paddingBottom: 6, borderWidth: 0, - color: themeColors.text, + color: theme.text, appearance: 'none', height: 26, opacity: 1, @@ -708,7 +708,7 @@ const styles = { paddingTop: 6, paddingBottom: 6, borderWidth: 0, - color: themeColors.text, + color: theme.text, height: 26, opacity: 1, backgroundColor: 'transparent', @@ -724,7 +724,7 @@ const styles = { }), badge: { - backgroundColor: themeColors.border, + backgroundColor: theme.border, borderRadius: 14, height: variables.iconSizeNormal, flexDirection: 'row', @@ -733,31 +733,31 @@ const styles = { }, badgeSuccess: { - backgroundColor: themeColors.success, + backgroundColor: theme.success, }, badgeSuccessPressed: { - backgroundColor: themeColors.successHover, + backgroundColor: theme.successHover, }, badgeAdHocSuccess: { - backgroundColor: themeColors.badgeAdHoc, + backgroundColor: theme.badgeAdHoc, }, badgeAdHocSuccessPressed: { - backgroundColor: themeColors.badgeAdHocHover, + backgroundColor: theme.badgeAdHocHover, }, badgeDanger: { - backgroundColor: themeColors.danger, + backgroundColor: theme.danger, }, badgeDangerPressed: { - backgroundColor: themeColors.dangerPressed, + backgroundColor: theme.dangerPressed, }, badgeText: { - color: themeColors.text, + color: theme.text, fontSize: variables.fontSizeSmall, lineHeight: variables.lineHeightNormal, ...whiteSpace.noWrap, @@ -766,37 +766,37 @@ const styles = { border: { borderWidth: 1, borderRadius: variables.componentBorderRadius, - borderColor: themeColors.border, + borderColor: theme.border, }, borderColorFocus: { - borderColor: themeColors.borderFocus, + borderColor: theme.borderFocus, }, borderColorDanger: { - borderColor: themeColors.danger, + borderColor: theme.danger, }, textInputDisabled: { // Adding disabled color theme to indicate user that the field is not editable. - backgroundColor: themeColors.highlightBG, + backgroundColor: theme.highlightBG, borderBottomWidth: 2, - borderColor: themeColors.borderLighter, + borderColor: theme.borderLighter, // Adding browser specefic style to bring consistency between Safari and other platforms. // Applying the Webkit styles only to browsers as it is not available in native. ...(Browser.getBrowser() ? { - WebkitTextFillColor: themeColors.textSupporting, + WebkitTextFillColor: theme.textSupporting, WebkitOpacity: 1, } : {}), - color: themeColors.textSupporting, + color: theme.textSupporting, }, uploadReceiptView: (isSmallScreenWidth) => ({ borderRadius: variables.componentBorderRadiusLarge, borderWidth: isSmallScreenWidth ? 0 : 2, - borderColor: themeColors.borderFocus, + borderColor: theme.borderFocus, borderStyle: 'dotted', marginBottom: 20, marginLeft: 20, @@ -827,14 +827,14 @@ const styles = { }, headerAnonymousFooter: { - color: themeColors.heading, + color: theme.heading, fontFamily: fontFamily.EXP_NEW_KANSAS_MEDIUM, fontSize: variables.fontSizeXLarge, lineHeight: variables.lineHeightXXLarge, }, headerText: { - color: themeColors.heading, + color: theme.heading, fontFamily: fontFamily.EXP_NEUE_BOLD, fontSize: variables.fontSizeNormal, fontWeight: fontWeightBold, @@ -859,7 +859,7 @@ const styles = { }, chatItemComposeSecondaryRowSubText: { - color: themeColors.textSupporting, + color: theme.textSupporting, fontFamily: fontFamily.EXP_NEUE, fontSize: variables.fontSizeSmall, lineHeight: variables.lineHeightSmall, @@ -920,7 +920,7 @@ const styles = { }, calendarDayContainerSelected: { - backgroundColor: themeColors.buttonDefaultBG, + backgroundColor: theme.buttonDefaultBG, }, /** @@ -946,7 +946,7 @@ const styles = { height: '100%', backgroundColor: 'transparent', borderBottomWidth: 2, - borderColor: themeColors.border, + borderColor: theme.border, overflow: 'hidden', }, @@ -955,7 +955,7 @@ const styles = { left: 0, top: 0, fontSize: variables.fontSizeNormal, - color: themeColors.textSupporting, + color: theme.textSupporting, fontFamily: fontFamily.EXP_NEUE, width: '100%', }, @@ -965,7 +965,7 @@ const styles = { top: 0, width: '100%', height: 23, - backgroundColor: themeColors.componentBG, + backgroundColor: theme.componentBG, }, textInputLabelDesktop: { @@ -980,7 +980,7 @@ const styles = { fontFamily: fontFamily.EXP_NEUE, fontSize: variables.fontSizeNormal, lineHeight: variables.lineHeightXLarge, - color: themeColors.text, + color: theme.text, paddingTop: 23, paddingBottom: 8, paddingLeft: 0, @@ -1019,9 +1019,9 @@ const styles = { backgroundColor: 'transparent', borderRadius: variables.componentBorderRadiusNormal, height: variables.inputComponentSizeNormal, - borderColor: themeColors.border, + borderColor: theme.border, borderWidth: 1, - color: themeColors.text, + color: theme.text, fontFamily: fontFamily.EXP_NEUE, fontSize: variables.fontSizeNormal, paddingLeft: 12, @@ -1044,7 +1044,7 @@ const styles = { }, textInputPrefix: { - color: themeColors.text, + color: theme.text, fontFamily: fontFamily.EXP_NEUE, fontSize: variables.fontSizeNormal, textAlignVertical: 'center', @@ -1054,7 +1054,7 @@ const styles = { borderBottomWidth: 2, paddingLeft: 0, borderStyle: 'solid', - borderColor: themeColors.border, + borderColor: theme.border, justifyContent: 'center', backgroundColor: 'transparent', height: variables.inputHeight, @@ -1072,7 +1072,7 @@ const styles = { zIndex: 1, }, - picker: (disabled = false, backgroundColor = themeColors.appBG) => ({ + picker: (disabled = false, backgroundColor = theme.appBG) => ({ iconContainer: { top: Math.round(variables.inputHeight * 0.5) - 11, right: 0, @@ -1082,63 +1082,63 @@ const styles = { inputWeb: { appearance: 'none', ...(disabled ? cursor.cursorDisabled : cursor.cursorPointer), - ...picker, + ...picker(theme), backgroundColor, }, inputIOS: { - ...picker, + ...picker(theme), }, done: { - color: themeColors.text, + color: theme.text, }, doneDepressed: { fontSize: defaultPickerStyles.done.fontSize, }, modalViewMiddle: { - backgroundColor: themeColors.border, + backgroundColor: theme.border, borderTopWidth: 0, }, modalViewBottom: { - backgroundColor: themeColors.highlightBG, + backgroundColor: theme.highlightBG, }, inputAndroid: { - ...picker, + ...picker(theme), }, }), disabledText: { - color: themeColors.icon, + color: theme.icon, }, inputDisabled: { - backgroundColor: themeColors.highlightBG, - color: themeColors.icon, + backgroundColor: theme.highlightBG, + color: theme.icon, }, noOutline: addOutlineWidth({}, 0), errorOutline: { - borderColor: themeColors.danger, + borderColor: theme.danger, }, textLabelSupporting: { fontFamily: fontFamily.EXP_NEUE, fontSize: variables.fontSizeLabel, - color: themeColors.textSupporting, + color: theme.textSupporting, }, textLabelError: { fontFamily: fontFamily.EXP_NEUE, fontSize: variables.fontSizeLabel, - color: themeColors.textError, + color: theme.textError, }, textReceiptUpload: { ...headlineFont, fontSize: variables.fontSizeXLarge, - color: themeColors.textLight, + color: theme.textLight, textAlign: 'center', }, @@ -1146,13 +1146,13 @@ const styles = { fontFamily: fontFamily.EXP_NEUE, lineHeight: variables.lineHeightLarge, textAlign: 'center', - color: themeColors.textLight, + color: theme.textLight, }, furtherDetailsText: { fontFamily: fontFamily.EXP_NEUE, fontSize: variables.fontSizeSmall, - color: themeColors.textSupporting, + color: theme.textSupporting, }, lh16: { @@ -1168,35 +1168,35 @@ const styles = { }, formHelp: { - color: themeColors.textSupporting, + color: theme.textSupporting, fontSize: variables.fontSizeLabel, lineHeight: variables.lineHeightLarge, marginBottom: 4, }, formError: { - color: themeColors.textError, + color: theme.textError, fontSize: variables.fontSizeLabel, lineHeight: variables.formErrorLineHeight, marginBottom: 4, }, formSuccess: { - color: themeColors.success, + color: theme.success, fontSize: variables.fontSizeLabel, lineHeight: 18, marginBottom: 4, }, desktopRedirectPage: { - backgroundColor: themeColors.appBG, + backgroundColor: theme.appBG, minHeight: '100%', flex: 1, alignItems: 'center', }, signInPage: { - backgroundColor: themeColors.highlightBG, + backgroundColor: theme.highlightBG, minHeight: '100%', flex: 1, }, @@ -1276,7 +1276,7 @@ const styles = { // Sidebar Styles sidebar: { - backgroundColor: themeColors.sidebar, + backgroundColor: theme.sidebar, height: '100%', }, @@ -1294,14 +1294,14 @@ const styles = { }, sidebarAvatar: { - backgroundColor: themeColors.icon, + backgroundColor: theme.icon, borderRadius: 20, height: variables.componentSizeNormal, width: variables.componentSizeNormal, }, - statusIndicator: (backgroundColor = themeColors.danger) => ({ - borderColor: themeColors.sidebar, + statusIndicator: (backgroundColor = theme.danger) => ({ + borderColor: theme.sidebar, backgroundColor, borderRadius: 8, borderWidth: 2, @@ -1323,7 +1323,7 @@ const styles = { }, floatingActionButton: { - backgroundColor: themeColors.success, + backgroundColor: theme.success, height: variables.componentSizeLarge, width: variables.componentSizeLarge, borderRadius: 999, @@ -1332,7 +1332,7 @@ const styles = { }, sidebarFooterUsername: { - color: themeColors.heading, + color: theme.heading, fontSize: variables.fontSizeLabel, fontWeight: '700', width: 200, @@ -1342,7 +1342,7 @@ const styles = { }, sidebarFooterLink: { - color: themeColors.textSupporting, + color: theme.textSupporting, fontSize: variables.fontSizeSmall, textDecorationLine: 'none', fontFamily: fontFamily.EXP_NEUE, @@ -1403,7 +1403,7 @@ const styles = { createMenuHeaderText: { fontFamily: fontFamily.EXP_NEUE, fontSize: variables.fontSizeLabel, - color: themeColors.heading, + color: theme.heading, }, popoverMenuItem: { @@ -1423,7 +1423,7 @@ const styles = { popoverMenuText: { fontSize: variables.fontSizeNormal, - color: themeColors.heading, + color: theme.heading, }, popoverInnerContainer: { @@ -1453,28 +1453,28 @@ const styles = { }, sidebarLinkText: { - color: themeColors.textSupporting, + color: theme.textSupporting, fontSize: variables.fontSizeNormal, textDecorationLine: 'none', overflow: 'hidden', }, sidebarLinkHover: { - backgroundColor: themeColors.sidebarHover, + backgroundColor: theme.sidebarHover, }, sidebarLinkActive: { - backgroundColor: themeColors.border, + backgroundColor: theme.border, textDecorationLine: 'none', }, sidebarLinkTextBold: { fontWeight: '700', - color: themeColors.heading, + color: theme.heading, }, sidebarLinkActiveText: { - color: themeColors.textSupporting, + color: theme.textSupporting, fontSize: variables.fontSizeNormal, textDecorationLine: 'none', overflow: 'hidden', @@ -1525,11 +1525,11 @@ const styles = { }, optionRowSelected: { - backgroundColor: themeColors.activeComponentBG, + backgroundColor: theme.activeComponentBG, }, optionRowDisabled: { - color: themeColors.textSupporting, + color: theme.textSupporting, }, optionRowCompact: { @@ -1559,7 +1559,7 @@ const styles = { }), appContent: { - backgroundColor: themeColors.appBG, + backgroundColor: theme.appBG, overflow: 'hidden', }, @@ -1632,7 +1632,7 @@ const styles = { }, chatItemMessageHeaderSender: { - color: themeColors.heading, + color: theme.heading, fontFamily: fontFamily.EXP_NEUE_BOLD, fontSize: variables.fontSizeNormal, fontWeight: fontWeightBold, @@ -1642,13 +1642,13 @@ const styles = { chatItemMessageHeaderTimestamp: { flexShrink: 0, - color: themeColors.textSupporting, + color: theme.textSupporting, fontSize: variables.fontSizeSmall, paddingTop: 2, }, chatItemMessage: { - color: themeColors.text, + color: theme.text, fontSize: variables.fontSizeNormal, fontFamily: fontFamily.EXP_NEUE, lineHeight: variables.lineHeightXLarge, @@ -1667,15 +1667,15 @@ const styles = { }, chatItemComposeBoxColor: { - borderColor: themeColors.border, + borderColor: theme.border, }, chatItemComposeBoxFocusedColor: { - borderColor: themeColors.borderFocus, + borderColor: theme.borderFocus, }, chatItemComposeBox: { - backgroundColor: themeColors.componentBG, + backgroundColor: theme.componentBG, borderWidth: 1, borderRadius: variables.componentBorderRadiusRounded, minHeight: variables.componentSizeMedium, @@ -1690,7 +1690,7 @@ const styles = { paddingLeft: 20, paddingRight: 20, display: 'flex', - backgroundColor: themeColors.appBG, + backgroundColor: theme.appBG, }, chatFooterFullCompose: { @@ -1718,9 +1718,9 @@ const styles = { // Make sure you run the following tests against any changes: #12669 textInputCompose: addOutlineWidth( { - backgroundColor: themeColors.componentBG, - borderColor: themeColors.border, - color: themeColors.text, + backgroundColor: theme.componentBG, + borderColor: theme.border, + color: theme.text, fontFamily: fontFamily.EXP_NEUE, fontSize: variables.fontSizeNormal, borderWidth: 0, @@ -1748,7 +1748,7 @@ const styles = { }, editInputComposeSpacing: { - backgroundColor: themeColors.transparent, + backgroundColor: theme.transparent, marginVertical: 8, }, @@ -1761,13 +1761,13 @@ const styles = { textInputComposeBorder: { borderLeftWidth: 1, - borderColor: themeColors.border, + borderColor: theme.border, }, chatItemSubmitButton: { alignSelf: 'flex-end', borderRadius: variables.componentBorderRadiusRounded, - backgroundColor: themeColors.transparent, + backgroundColor: theme.transparent, height: 40, padding: 10, margin: 3, @@ -1775,11 +1775,11 @@ const styles = { }, emojiPickerContainer: { - backgroundColor: themeColors.componentBG, + backgroundColor: theme.componentBG, }, emojiHeaderContainer: { - backgroundColor: themeColors.componentBG, + backgroundColor: theme.componentBG, display: 'flex', height: CONST.EMOJI_PICKER_HEADER_HEIGHT, justifyContent: 'center', @@ -1791,7 +1791,7 @@ const styles = { ...spacing.pv1, fontFamily: fontFamily.EXP_NEUE_BOLD, fontWeight: fontWeightBold, - color: themeColors.heading, + color: theme.heading, fontSize: variables.fontSizeSmall, }, @@ -1815,13 +1815,13 @@ const styles = { emojiItemHighlighted: { transition: '0.2s ease', - backgroundColor: themeColors.buttonDefaultBG, + backgroundColor: theme.buttonDefaultBG, }, emojiItemKeyboardHighlighted: { transition: '0.2s ease', borderWidth: 1, - borderColor: themeColors.link, + borderColor: theme.link, borderRadius: variables.buttonBorderRadius, }, @@ -1848,7 +1848,7 @@ const styles = { }, hoveredButton: { - backgroundColor: themeColors.buttonHoveredBG, + backgroundColor: theme.buttonHoveredBG, }, composerSizeButton: { @@ -1858,13 +1858,13 @@ const styles = { padding: 6, margin: 3, borderRadius: variables.componentBorderRadiusRounded, - backgroundColor: themeColors.transparent, + backgroundColor: theme.transparent, justifyContent: 'center', }, chatItemAttachmentPlaceholder: { - backgroundColor: themeColors.sidebar, - borderColor: themeColors.border, + backgroundColor: theme.sidebar, + borderColor: theme.border, borderWidth: 1, borderRadius: variables.componentBorderRadiusNormal, height: 150, @@ -1902,7 +1902,7 @@ const styles = { exampleCheckImage: { width: '100%', height: 80, - borderColor: themeColors.border, + borderColor: theme.border, borderWidth: 1, borderRadius: variables.componentBorderRadiusNormal, }, @@ -1910,14 +1910,14 @@ const styles = { singleAvatar: { height: 24, width: 24, - backgroundColor: themeColors.icon, + backgroundColor: theme.icon, borderRadius: 24, }, singleSubscript: { height: variables.iconSizeNormal, width: variables.iconSizeNormal, - backgroundColor: themeColors.icon, + backgroundColor: theme.icon, borderRadius: 20, zIndex: 1, }, @@ -1925,7 +1925,7 @@ const styles = { singleAvatarSmall: { height: 18, width: 18, - backgroundColor: themeColors.icon, + backgroundColor: theme.icon, borderRadius: 18, }, @@ -1981,8 +1981,8 @@ const styles = { right: -25, borderWidth: 3, borderRadius: 18, - borderColor: themeColors.cardBorder, - backgroundColor: themeColors.appBG, + borderColor: theme.cardBorder, + backgroundColor: theme.appBG, }, avatarLarge: { @@ -2003,7 +2003,7 @@ const styles = { }, avatarInnerText: { - color: themeColors.textLight, + color: theme.textLight, fontSize: variables.fontSizeSmall, lineHeight: undefined, marginLeft: -3, @@ -2011,7 +2011,7 @@ const styles = { }, avatarInnerTextSmall: { - color: themeColors.textLight, + color: theme.textLight, fontSize: variables.fontSizeExtraSmall, lineHeight: undefined, marginLeft: -2, @@ -2024,13 +2024,13 @@ const styles = { }, avatar: { - backgroundColor: themeColors.sidebar, - borderColor: themeColors.sidebar, + backgroundColor: theme.sidebar, + borderColor: theme.sidebar, }, focusedAvatar: { - backgroundColor: themeColors.border, - borderColor: themeColors.border, + backgroundColor: theme.border, + borderColor: theme.border, }, emptyAvatar: { @@ -2086,26 +2086,26 @@ const styles = { borderTop: { borderTopWidth: variables.borderTopWidth, - borderColor: themeColors.border, + borderColor: theme.border, }, borderTopRounded: { borderTopWidth: 1, - borderColor: themeColors.border, + borderColor: theme.border, borderTopLeftRadius: variables.componentBorderRadiusNormal, borderTopRightRadius: variables.componentBorderRadiusNormal, }, borderBottomRounded: { borderBottomWidth: 1, - borderColor: themeColors.border, + borderColor: theme.border, borderBottomLeftRadius: variables.componentBorderRadiusNormal, borderBottomRightRadius: variables.componentBorderRadiusNormal, }, borderBottom: { borderBottomWidth: 1, - borderColor: themeColors.border, + borderColor: theme.border, }, borderNone: { @@ -2115,12 +2115,12 @@ const styles = { borderRight: { borderRightWidth: 1, - borderColor: themeColors.border, + borderColor: theme.border, }, borderLeft: { borderLeftWidth: 1, - borderColor: themeColors.border, + borderColor: theme.border, }, pointerEventsNone, @@ -2145,7 +2145,7 @@ const styles = { imageModalPDF: { flex: 1, - backgroundColor: themeColors.modalBackground, + backgroundColor: theme.modalBackground, }, PDFView: { @@ -2153,7 +2153,7 @@ const styles = { // It's being used on Web/Desktop only to vertically center short PDFs, // while preventing the overflow of the top of long PDF files. display: 'grid', - backgroundColor: themeColors.modalBackground, + backgroundColor: theme.modalBackground, width: '100%', height: '100%', justifyContent: 'center', @@ -2178,7 +2178,7 @@ const styles = { flexDirection: 'column', justifyContent: 'center', alignItems: 'center', - backgroundColor: themeColors.modalBackdrop, + backgroundColor: theme.modalBackdrop, }, centeredModalStyles: (isSmallScreenWidth, isFullScreenWhenSmall) => ({ @@ -2194,10 +2194,10 @@ const styles = { }, defaultAttachmentView: { - backgroundColor: themeColors.sidebar, + backgroundColor: theme.sidebar, borderRadius: variables.componentBorderRadiusNormal, borderWidth: 1, - borderColor: themeColors.border, + borderColor: theme.border, flexDirection: 'row', padding: 20, alignItems: 'center', @@ -2205,7 +2205,7 @@ const styles = { notFoundSafeArea: { flex: 1, - backgroundColor: themeColors.heading, + backgroundColor: theme.heading, }, notFoundView: { @@ -2227,7 +2227,7 @@ const styles = { notFoundTextHeader: { ...headlineFont, - color: themeColors.heading, + color: theme.heading, fontSize: variables.fontSizeXLarge, lineHeight: variables.lineHeightXXLarge, marginTop: 20, @@ -2236,14 +2236,14 @@ const styles = { }, notFoundTextBody: { - color: themeColors.componentBG, + color: theme.componentBG, fontFamily: fontFamily.EXP_NEUE_BOLD, fontWeight: fontWeightBold, fontSize: 15, }, notFoundButtonText: { - color: themeColors.link, + color: theme.link, fontFamily: fontFamily.EXP_NEUE_BOLD, fontWeight: fontWeightBold, fontSize: 15, @@ -2254,8 +2254,8 @@ const styles = { }, defaultModalContainer: { - backgroundColor: themeColors.componentBG, - borderColor: themeColors.transparent, + backgroundColor: theme.componentBG, + borderColor: theme.transparent, }, reportActionContextMenuMiniButton: { @@ -2312,7 +2312,7 @@ const styles = { }, twoFactorAuthSection: { - backgroundColor: themeColors.appBG, + backgroundColor: theme.appBG, padding: 0, }, @@ -2330,7 +2330,7 @@ const styles = { return { alignItems: 'center', justifyContent: 'center', - backgroundColor: themeColors.highlightBG, + backgroundColor: theme.highlightBG, paddingVertical: 28, borderRadius: 16, marginTop: 32, @@ -2381,7 +2381,7 @@ const styles = { justifyContent: 'space-between', }), padding: 20, - backgroundColor: themeColors.sidebar, + backgroundColor: theme.sidebar, borderRadius: variables.componentBorderRadiusLarge, overflow: 'hidden', }), @@ -2401,7 +2401,7 @@ const styles = { anonymousRoomFooterLogoTaglineText: { fontFamily: fontFamily.EXP_NEUE, fontSize: variables.fontSizeMedium, - color: themeColors.textLight, + color: theme.textLight, }, signInButtonAvatar: { width: 80, @@ -2417,9 +2417,9 @@ const styles = { }, roomHeaderAvatar: { - backgroundColor: themeColors.appBG, + backgroundColor: theme.appBG, borderRadius: 100, - borderColor: themeColors.componentBG, + borderColor: theme.componentBG, borderWidth: 4, }, @@ -2429,7 +2429,7 @@ const styles = { right: 0, bottom: 0, left: 0, - backgroundColor: themeColors.overlay, + backgroundColor: theme.overlay, opacity: variables.overlayOpacity, borderRadius: 88, }, @@ -2438,7 +2438,7 @@ const styles = { RHPNavigatorContainerNavigatorContainerStyles: (isSmallScreenWidth) => ({marginLeft: isSmallScreenWidth ? 0 : variables.sideBarWidth, flex: 1}), avatarInnerTextChat: { - color: themeColors.textLight, + color: theme.textLight, fontSize: variables.fontSizeXLarge, fontFamily: fontFamily.EXP_NEW_KANSAS_MEDIUM, textAlign: 'center', @@ -2457,7 +2457,7 @@ const styles = { fontSize: variables.fontSizeLarge, fontFamily: fontFamily.EXP_NEUE_BOLD, fontWeight: fontWeightBold, - color: themeColors.heading, + color: theme.heading, }, pageWrapper: { @@ -2482,12 +2482,12 @@ const styles = { selectCircle: { width: variables.componentSizeSmall, height: variables.componentSizeSmall, - borderColor: themeColors.border, + borderColor: theme.border, borderWidth: 1, borderRadius: variables.componentSizeSmall / 2, justifyContent: 'center', alignItems: 'center', - backgroundColor: themeColors.componentBG, + backgroundColor: theme.componentBG, marginLeft: 8, }, @@ -2506,7 +2506,7 @@ const styles = { unreadIndicatorLine: { height: 1, - backgroundColor: themeColors.unreadIndicator, + backgroundColor: theme.unreadIndicator, flexGrow: 1, marginRight: 8, opacity: 0.5, @@ -2514,13 +2514,13 @@ const styles = { threadDividerLine: { height: 1, - backgroundColor: themeColors.border, + backgroundColor: theme.border, flexGrow: 1, marginHorizontal: 20, }, unreadIndicatorText: { - color: themeColors.unreadIndicator, + color: theme.unreadIndicator, fontFamily: fontFamily.EXP_NEUE_BOLD, fontSize: variables.fontSizeSmall, fontWeight: fontWeightBold, @@ -2532,11 +2532,11 @@ const styles = { }, navigationSceneContainer: { - backgroundColor: themeColors.appBG, + backgroundColor: theme.appBG, }, navigationScreenCardStyle: { - backgroundColor: themeColors.appBG, + backgroundColor: theme.appBG, height: '100%', }, @@ -2592,7 +2592,7 @@ const styles = { detailsPageSectionVersion: { alignSelf: 'center', - color: themeColors.textSupporting, + color: theme.textSupporting, fontSize: variables.fontSizeSmall, height: 24, lineHeight: 20, @@ -2604,11 +2604,11 @@ const styles = { justifyContent: 'center', borderRadius: 20, padding: 15, - backgroundColor: themeColors.success, + backgroundColor: theme.success, }, switchInactive: { - backgroundColor: themeColors.border, + backgroundColor: theme.border, }, switchThumb: { @@ -2617,7 +2617,7 @@ const styles = { borderRadius: 11, position: 'absolute', left: 4, - backgroundColor: themeColors.appBG, + backgroundColor: theme.appBG, }, switchThumbTransformation: (translateX) => ({ @@ -2625,11 +2625,11 @@ const styles = { }), radioButtonContainer: { - backgroundColor: themeColors.componentBG, + backgroundColor: theme.componentBG, borderRadius: 10, height: 20, width: 20, - borderColor: themeColors.icon, + borderColor: theme.icon, borderWidth: 1, justifyContent: 'center', alignItems: 'center', @@ -2643,7 +2643,7 @@ const styles = { }, checkedContainer: { - backgroundColor: themeColors.checkBox, + backgroundColor: theme.checkBox, }, magicCodeInputContainer: { @@ -2654,7 +2654,7 @@ const styles = { magicCodeInput: { fontSize: variables.fontSizeXLarge, - color: themeColors.heading, + color: theme.heading, lineHeight: variables.inputHeight, }, @@ -2678,7 +2678,7 @@ const styles = { iouAmountText: { ...headlineFont, fontSize: variables.iouAmountTextSize, - color: themeColors.heading, + color: theme.heading, lineHeight: variables.inputHeight, }, @@ -2686,7 +2686,7 @@ const styles = { { ...headlineFont, fontSize: variables.iouAmountTextSize, - color: themeColors.heading, + color: theme.heading, padding: 0, lineHeight: undefined, }, @@ -2713,7 +2713,7 @@ const styles = { }, moneyRequestPreviewBox: { - backgroundColor: themeColors.cardBG, + backgroundColor: theme.cardBG, borderRadius: variables.componentBorderRadiusLarge, maxWidth: variables.sideBarWidth, width: '100%', @@ -2739,7 +2739,7 @@ const styles = { moneyRequestPreviewAmount: { ...headlineFont, ...whiteSpace.preWrap, - color: themeColors.heading, + color: theme.heading, }, defaultCheckmarkWrapper: { @@ -2785,7 +2785,7 @@ const styles = { }, fullScreenLoading: { - backgroundColor: themeColors.componentBG, + backgroundColor: theme.componentBG, opacity: 0.8, justifyContent: 'center', alignItems: 'center', @@ -2793,12 +2793,12 @@ const styles = { }, navigatorFullScreenLoading: { - backgroundColor: themeColors.highlightBG, + backgroundColor: theme.highlightBG, opacity: 1, }, reimbursementAccountFullScreenLoading: { - backgroundColor: themeColors.componentBG, + backgroundColor: theme.componentBG, opacity: 0.8, justifyContent: 'flex-start', alignItems: 'center', @@ -2846,12 +2846,12 @@ const styles = { }), growlNotificationBox: { - backgroundColor: themeColors.inverse, + backgroundColor: theme.inverse, borderRadius: variables.componentBorderRadiusNormal, alignItems: 'center', flexDirection: 'row', justifyContent: 'space-between', - shadowColor: themeColors.shadow, + shadowColor: theme.shadow, ...spacing.p5, }, @@ -2860,12 +2860,12 @@ const styles = { fontFamily: fontFamily.EXP_NEUE, width: '90%', lineHeight: variables.fontSizeNormalHeight, - color: themeColors.textReversed, + color: theme.textReversed, ...spacing.ml4, }, blockquote: { - borderLeftColor: themeColors.border, + borderLeftColor: theme.border, borderLeftWidth: 4, paddingLeft: 12, marginVertical: 4, @@ -2917,11 +2917,11 @@ const styles = { smallEditIcon: { alignItems: 'center', - backgroundColor: themeColors.buttonHoveredBG, - borderColor: themeColors.textReversed, + backgroundColor: theme.buttonHoveredBG, + borderColor: theme.textReversed, borderRadius: 14, borderWidth: 3, - color: themeColors.textReversed, + color: theme.textReversed, height: 28, width: 28, justifyContent: 'center', @@ -2938,7 +2938,7 @@ const styles = { height: 400, borderRadius: variables.componentBorderRadiusCard, overflow: 'hidden', - backgroundColor: themeColors.heroCard, + backgroundColor: theme.heroCard, }, workspaceCardMobile: { @@ -2981,18 +2981,18 @@ const styles = { }, peopleRowBorderBottom: { - borderColor: themeColors.border, + borderColor: theme.border, borderBottomWidth: 1, ...spacing.pb2, }, peopleBadge: { - backgroundColor: themeColors.icon, + backgroundColor: theme.icon, ...spacing.ph3, }, peopleBadgeText: { - color: themeColors.textReversed, + color: theme.textReversed, fontSize: variables.fontSizeSmall, lineHeight: variables.lineHeightNormal, ...whiteSpace.noWrap, @@ -3018,7 +3018,7 @@ const styles = { flex: 1, }, text: { - color: themeColors.textSupporting, + color: theme.textSupporting, textAlignVertical: 'center', fontSize: variables.fontSizeLabel, }, @@ -3038,7 +3038,7 @@ const styles = { }, cardOverlay: { - backgroundColor: themeColors.overlay, + backgroundColor: theme.overlay, position: 'absolute', top: 0, left: 0, @@ -3055,18 +3055,18 @@ const styles = { shortTermsBorder: { borderWidth: 1, - borderColor: themeColors.border, + borderColor: theme.border, }, shortTermsHorizontalRule: { borderBottomWidth: 1, - borderColor: themeColors.border, + borderColor: theme.border, ...spacing.mh3, }, shortTermsLargeHorizontalRule: { borderWidth: 1, - borderColor: themeColors.border, + borderColor: theme.border, ...spacing.mh3, }, @@ -3089,7 +3089,7 @@ const styles = { shortTermsHeadline: { ...headlineFont, ...whiteSpace.preWrap, - color: themeColors.heading, + color: theme.heading, fontSize: variables.fontSizeXXXLarge, lineHeight: variables.lineHeightXXXLarge, }, @@ -3101,7 +3101,7 @@ const styles = { collapsibleSectionBorder: { borderBottomWidth: 2, - borderBottomColor: themeColors.border, + borderBottomColor: theme.border, }, communicationsLinkHeight: { @@ -3152,11 +3152,11 @@ const styles = { googleSearchSeparator: { height: 1, - backgroundColor: themeColors.border, + backgroundColor: theme.border, }, googleSearchText: { - color: themeColors.text, + color: theme.text, fontSize: variables.fontSizeNormal, lineHeight: variables.fontSizeNormalHeight, fontFamily: fontFamily.EXP_NEUE, @@ -3194,7 +3194,7 @@ const styles = { keyboardShortcutTableContainer: { display: 'flex', width: '100%', - borderColor: themeColors.border, + borderColor: theme.border, height: 'auto', borderRadius: variables.componentBorderRadius, borderWidth: 1, @@ -3203,7 +3203,7 @@ const styles = { keyboardShortcutTableRow: { flex: 1, flexDirection: 'row', - borderColor: themeColors.border, + borderColor: theme.border, flexBasis: 'auto', alignSelf: 'stretch', borderTopWidth: 1, @@ -3212,7 +3212,7 @@ const styles = { keyboardShortcutTablePrefix: { width: '30%', borderRightWidth: 1, - borderColor: themeColors.border, + borderColor: theme.border, }, keyboardShortcutTableFirstRow: { @@ -3220,18 +3220,18 @@ const styles = { }, iPhoneXSafeArea: { - backgroundColor: themeColors.inverse, + backgroundColor: theme.inverse, flex: 1, }, transferBalancePayment: { borderWidth: 1, borderRadius: variables.componentBorderRadiusNormal, - borderColor: themeColors.border, + borderColor: theme.border, }, transferBalanceSelectedPayment: { - borderColor: themeColors.iconSuccessFill, + borderColor: theme.iconSuccessFill, }, transferBalanceBalance: { @@ -3246,7 +3246,7 @@ const styles = { overflow: 'hidden', alignItems: 'center', justifyContent: 'center', - backgroundColor: themeColors.imageCropBackgroundColor, + backgroundColor: theme.imageCropBackgroundColor, ...cursor.cursorMove, }, @@ -3257,7 +3257,7 @@ const styles = { }, sliderKnob: { - backgroundColor: themeColors.success, + backgroundColor: theme.success, position: 'absolute', height: variables.sliderKnobSize, width: variables.sliderKnobSize, @@ -3267,7 +3267,7 @@ const styles = { }, sliderBar: { - backgroundColor: themeColors.border, + backgroundColor: theme.border, height: variables.sliderBarHeight, borderRadius: variables.sliderBarHeight / 2, alignSelf: 'stretch', @@ -3282,7 +3282,7 @@ const styles = { }, inlineSystemMessage: { - color: themeColors.textSupporting, + color: theme.textSupporting, fontSize: variables.fontSizeLabel, fontFamily: fontFamily.EXP_NEUE, marginLeft: 6, @@ -3297,17 +3297,17 @@ const styles = { }, invisibleOverlay: { - backgroundColor: themeColors.transparent, + backgroundColor: theme.transparent, zIndex: 1000, }, reportDropOverlay: { - backgroundColor: themeColors.dropUIBG, + backgroundColor: theme.dropUIBG, zIndex: 2, }, receiptDropOverlay: { - backgroundColor: themeColors.receiptDropUIBG, + backgroundColor: theme.receiptDropUIBG, zIndex: 2, }, @@ -3317,7 +3317,7 @@ const styles = { }), cardSection: { - backgroundColor: themeColors.cardBG, + backgroundColor: theme.cardBG, borderRadius: variables.componentBorderRadiusCard, marginBottom: 20, marginHorizontal: 16, @@ -3339,7 +3339,7 @@ const styles = { }, callRequestSection: { - backgroundColor: themeColors.appBG, + backgroundColor: theme.appBG, paddingHorizontal: 0, paddingBottom: 0, marginHorizontal: 0, @@ -3361,7 +3361,7 @@ const styles = { flex: 1, alignItems: 'center', justifyContent: 'center', - backgroundColor: themeColors.appBG, + backgroundColor: theme.appBG, }, deeplinkWrapperMessage: { @@ -3386,7 +3386,7 @@ const styles = { emojiReactionListHeader: { marginTop: 8, paddingBottom: 20, - borderBottomColor: themeColors.border, + borderBottomColor: theme.border, borderBottomWidth: 1, marginHorizontal: 20, }, @@ -3394,7 +3394,7 @@ const styles = { paddingVertical: 2, paddingHorizontal: 8, borderRadius: 28, - backgroundColor: themeColors.border, + backgroundColor: theme.border, alignItems: 'center', justifyContent: 'center', flexDirection: 'row', @@ -3407,7 +3407,7 @@ const styles = { paddingHorizontal: 20, }, reactionListHeaderText: { - color: themeColors.textSupporting, + color: theme.textSupporting, marginLeft: 8, alignSelf: 'center', }, @@ -3438,7 +3438,7 @@ const styles = { }, textReactionSenders: { - color: themeColors.dark, + color: theme.dark, ...wordBreak.breakWord, }, @@ -3460,7 +3460,7 @@ const styles = { }, validateCodeDigits: { - color: themeColors.text, + color: theme.text, fontFamily: fontFamily.EXP_NEUE, fontSize: variables.fontSizeXXLarge, letterSpacing: 4, @@ -3481,14 +3481,14 @@ const styles = { footerTitle: { fontSize: variables.fontSizeLarge, - color: themeColors.success, + color: theme.success, marginBottom: 16, }, footerRow: { paddingVertical: 4, marginBottom: 8, - color: themeColors.textLight, + color: theme.textLight, fontSize: variables.fontSizeMedium, }, @@ -3499,7 +3499,7 @@ const styles = { listPickerSeparator: { height: 1, - backgroundColor: themeColors.buttonDefaultBG, + backgroundColor: theme.buttonDefaultBG, }, datePickerRoot: { @@ -3508,7 +3508,7 @@ const styles = { }, datePickerPopover: { - backgroundColor: themeColors.appBG, + backgroundColor: theme.appBG, width: '100%', alignSelf: 'center', zIndex: 100, @@ -3517,7 +3517,7 @@ const styles = { loginHeroHeader: { fontFamily: fontFamily.EXP_NEW_KANSAS_MEDIUM, - color: themeColors.success, + color: theme.success, fontWeight: '500', textAlign: 'center', }, @@ -3531,14 +3531,14 @@ const styles = { loginHeroBody: { fontFamily: fontFamily.EXP_NEUE, fontSize: variables.fontSizeSignInHeroBody, - color: themeColors.textLight, + color: theme.textLight, textAlign: 'center', }, linkPreviewWrapper: { marginTop: 16, borderLeftWidth: 4, - borderLeftColor: themeColors.border, + borderLeftColor: theme.border, paddingLeft: 12, }, @@ -3560,7 +3560,7 @@ const styles = { }, whisper: { - backgroundColor: themeColors.cardBG, + backgroundColor: theme.cardBG, }, contextMenuItemPopoverMaxWidth: { @@ -3595,7 +3595,7 @@ const styles = { taskTitleDescription: { fontFamily: fontFamily.EXP_NEUE, fontSize: variables.fontSizeLabel, - color: themeColors.textSupporting, + color: theme.textSupporting, lineHeight: variables.lineHeightNormal, ...spacing.mb1, }, @@ -3607,7 +3607,7 @@ const styles = { reportHorizontalRule: { borderBottomWidth: 1, - borderColor: themeColors.border, + borderColor: theme.border, ...spacing.mh5, ...spacing.mv2, }, @@ -3638,13 +3638,13 @@ const styles = { paddingVertical: 20, borderRadius: 20, overflow: 'hidden', - borderColor: themeColors.borderFocus, + borderColor: theme.borderFocus, borderWidth: 2, - backgroundColor: themeColors.highlightBG, + backgroundColor: theme.highlightBG, }, splashScreenHider: { - backgroundColor: themeColors.splashBG, + backgroundColor: theme.splashBG, alignItems: 'center', justifyContent: 'center', }, @@ -3740,7 +3740,7 @@ const styles = { marginLeft: 8, fontFamily: isSelected ? fontFamily.EXP_NEUE_BOLD : fontFamily.EXP_NEUE, fontWeight: isSelected ? fontWeightBold : 400, - color: isSelected ? themeColors.textLight : themeColors.textSupporting, + color: isSelected ? theme.textLight : theme.textSupporting, }), /** @@ -3781,7 +3781,7 @@ const styles = { emojiPickerButtonDropdown: { justifyContent: 'center', - backgroundColor: themeColors.activeComponentBG, + backgroundColor: theme.activeComponentBG, width: 86, height: 52, borderRadius: 26, @@ -3803,15 +3803,15 @@ const styles = { }, reportPreviewBox: { - backgroundColor: themeColors.cardBG, + backgroundColor: theme.cardBG, borderRadius: variables.componentBorderRadiusLarge, maxWidth: variables.sideBarWidth, width: '100%', }, reportPreviewBoxHoverBorder: { - borderColor: themeColors.border, - backgroundColor: themeColors.border, + borderColor: theme.border, + backgroundColor: theme.border, }, reportPreviewBoxBody: { @@ -3821,7 +3821,7 @@ const styles = { reportActionItemImages: { flexDirection: 'row', borderWidth: 4, - borderColor: themeColors.transparent, + borderColor: theme.transparent, borderTopLeftRadius: variables.componentBorderRadiusLarge, borderTopRightRadius: variables.componentBorderRadiusLarge, borderBottomLeftRadius: variables.componentBorderRadiusLarge, @@ -3841,13 +3841,13 @@ const styles = { reportActionItemImageBorder: { borderRightWidth: 2, - borderColor: themeColors.cardBG, + borderColor: theme.cardBG, }, reportActionItemImagesMore: { position: 'absolute', borderRadius: 18, - backgroundColor: themeColors.cardBG, + backgroundColor: theme.cardBG, width: 36, height: 36, display: 'flex', @@ -3862,7 +3862,7 @@ const styles = { display: 'flex', justifyContent: 'center', alignItems: 'center', - backgroundColor: themeColors.border, + backgroundColor: theme.border, marginRight: 12, }, @@ -3885,7 +3885,7 @@ const styles = { sidebarStatusAvatarContainer: { height: 44, width: 84, - backgroundColor: themeColors.componentBG, + backgroundColor: theme.componentBG, flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', @@ -3905,7 +3905,7 @@ const styles = { ...spacing.mv3, overflow: 'hidden', borderWidth: 2, - borderColor: themeColors.cardBG, + borderColor: theme.cardBG, borderRadius: variables.componentBorderRadiusLarge, height: 200, maxWidth: 400, @@ -3947,7 +3947,7 @@ const styles = { }, mapPendingView: { - backgroundColor: themeColors.highlightBG, + backgroundColor: theme.highlightBG, ...flex.flex1, borderRadius: variables.componentBorderRadiusLarge, }, @@ -3959,6 +3959,9 @@ const styles = { height: 30, width: '100%', }, -}; +}); + +const defaultStyles = styles(defaultTheme); -export default styles; +export default defaultStyles; +export {styles}; From 7276e6dc8a6c7b7e800e1328ad52c1d5cf246fd6 Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Wed, 13 Sep 2023 12:53:33 +0200 Subject: [PATCH 270/284] fix: rename ThemeStylesContext --- src/styles/ThemeStylesProvider.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/styles/ThemeStylesProvider.tsx b/src/styles/ThemeStylesProvider.tsx index 0a32d2de1cf7..763b2febdaf0 100644 --- a/src/styles/ThemeStylesProvider.tsx +++ b/src/styles/ThemeStylesProvider.tsx @@ -1,7 +1,7 @@ /* eslint-disable react/jsx-props-no-spreading */ import React, {useMemo} from 'react'; import useTheme from './themes/useTheme'; -import StylesContext from './ThemeStylesContext'; +import ThemeStylesContext from './ThemeStylesContext'; import {styles as stylesUntyped} from './styles'; const styles = stylesUntyped as (theme: Record) => Record; @@ -15,7 +15,7 @@ function ThemeStylesProvider({children}: ThemeStylesProviderProps) { const themeStyles = useMemo(() => styles(theme), [theme]); - return {children}; + return {children}; } ThemeStylesProvider.displayName = 'ThemeStylesProvider'; From e3ce763548e7db5b6e86c67292ee5b87442e9e9f Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Wed, 13 Sep 2023 13:13:09 +0200 Subject: [PATCH 271/284] fix: lint errors and added TODOs for after theme switching migration --- src/styles/ThemeStylesProvider.tsx | 3 ++- src/styles/styles.js | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/styles/ThemeStylesProvider.tsx b/src/styles/ThemeStylesProvider.tsx index 763b2febdaf0..d0db784ca8ca 100644 --- a/src/styles/ThemeStylesProvider.tsx +++ b/src/styles/ThemeStylesProvider.tsx @@ -2,7 +2,8 @@ import React, {useMemo} from 'react'; import useTheme from './themes/useTheme'; import ThemeStylesContext from './ThemeStylesContext'; -import {styles as stylesUntyped} from './styles'; +// TODO: Rename this to "styles" once the app is migrated to theme switching hooks and HOCs +import {stylesGenerator as stylesUntyped} from './styles'; const styles = stylesUntyped as (theme: Record) => Record; diff --git a/src/styles/styles.js b/src/styles/styles.js index 9cc18b6c44a0..ced90e972f6a 100644 --- a/src/styles/styles.js +++ b/src/styles/styles.js @@ -3961,7 +3961,12 @@ const styles = (theme) => ({ }, }); +// For now we need to export the styles function that takes the theme as an argument +// as something named different than "styles", because a lot of files import the "defaultStyles" +// as "styles", which causes ESLint to throw an error. +// TODO: Remove this once the app is migrated to theme switching hooks and HOCs and "styles/theme/default.js" is not used anywhere anymore +const stylesGenerator = styles; const defaultStyles = styles(defaultTheme); export default defaultStyles; -export {styles}; +export {stylesGenerator}; From 7cd0eebb56ec94187dd8f6d83cb89edcdbb02c77 Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Wed, 13 Sep 2023 13:36:59 +0200 Subject: [PATCH 272/284] fix: ignore eslint instead of casting --- src/styles/StyleUtils.ts | 21 +++++++++++++++++++ .../getReportActionContextMenuStyles.ts | 2 ++ src/styles/useThemeStyles.ts | 2 ++ 3 files changed, 25 insertions(+) diff --git a/src/styles/StyleUtils.ts b/src/styles/StyleUtils.ts index 8945bc0be058..a0508090f774 100644 --- a/src/styles/StyleUtils.ts +++ b/src/styles/StyleUtils.ts @@ -259,9 +259,12 @@ function getSafeAreaMargins(insets?: EdgeInsets): ViewStyle | CSSProperties { function getZoomCursorStyle(isZoomed: boolean, isDragging: boolean): ViewStyle | CSSProperties { if (!isZoomed) { + // TODO: Remove this "eslint-disable-next" once the theme switching migration is done and styles are fully typed + // eslint-disable-next-line @typescript-eslint/no-unsafe-return return styles.cursorZoomIn; } + // eslint-disable-next-line @typescript-eslint/no-unsafe-return return isDragging ? styles.cursorGrabbing : styles.cursorZoomOut; } @@ -336,12 +339,16 @@ function getWidthStyle(width: number): ViewStyle | CSSProperties { */ function getAutoGrowHeightInputStyle(textInputHeight: number, maxHeight: number): ViewStyle | CSSProperties { if (textInputHeight > maxHeight) { + // TODO: Remove this "eslint-disable-next" once the theme switching migration is done and styles are fully typed + // eslint-disable-next-line @typescript-eslint/no-unsafe-return return { ...styles.pr0, ...styles.overflowAuto, }; } + // TODO: Remove this "eslint-disable-next" once the theme switching migration is done and styles are fully typed + // eslint-disable-next-line @typescript-eslint/no-unsafe-return return { ...styles.pr0, ...styles.overflowHidden, @@ -439,11 +446,17 @@ function getBackgroundColorWithOpacityStyle(backgroundColor: string, opacity: nu function getBadgeColorStyle(success: boolean, error: boolean, isPressed = false, isAdHoc = false): ViewStyle | CSSProperties { if (success) { if (isAdHoc) { + // TODO: Remove this "eslint-disable-next" once the theme switching migration is done and styles are fully typed + // eslint-disable-next-line @typescript-eslint/no-unsafe-return return isPressed ? styles.badgeAdHocSuccessPressed : styles.badgeAdHocSuccess; } + // TODO: Remove this "eslint-disable-next" once the theme switching migration is done and styles are fully typed + // eslint-disable-next-line @typescript-eslint/no-unsafe-return return isPressed ? styles.badgeSuccessPressed : styles.badgeSuccess; } if (error) { + // TODO: Remove this "eslint-disable-next" once the theme switching migration is done and styles are fully typed + // eslint-disable-next-line @typescript-eslint/no-unsafe-return return isPressed ? styles.badgeDangerPressed : styles.badgeDanger; } return {}; @@ -593,6 +606,8 @@ function getLoginPagePromoStyle(): ViewStyle | CSSProperties { * Generate the styles for the ReportActionItem wrapper view. */ function getReportActionItemStyle(isHovered = false, isLoading = false): ViewStyle | CSSProperties { + // TODO: Remove this "eslint-disable-next" once the theme switching migration is done and styles are fully typed + // eslint-disable-next-line @typescript-eslint/no-unsafe-return return { display: 'flex', justifyContent: 'space-between', @@ -609,6 +624,8 @@ function getReportActionItemStyle(isHovered = false, isLoading = false): ViewSty * Generate the wrapper styles for the mini ReportActionContextMenu. */ function getMiniReportActionContextMenuWrapperStyle(isReportActionItemGrouped: boolean): ViewStyle | CSSProperties { + // TODO: Remove this "eslint-disable-next" once the theme switching migration is done and styles are fully typed + // eslint-disable-next-line @typescript-eslint/no-unsafe-return return { ...(isReportActionItemGrouped ? positioning.tn8 : positioning.tn4), ...positioning.r4, @@ -1043,6 +1060,8 @@ function displayIfTrue(condition: boolean): ViewStyle | CSSProperties { function getGoogleListViewStyle(shouldDisplayBorder: boolean): ViewStyle | CSSProperties { if (shouldDisplayBorder) { + // TODO: Remove this "eslint-disable-next" once the theme switching migration is done and styles are fully typed + // eslint-disable-next-line @typescript-eslint/no-unsafe-return return { ...styles.borderTopRounded, ...styles.borderBottomRounded, @@ -1150,6 +1169,8 @@ function getDisabledLinkStyles(isDisabled = false): ViewStyle | CSSProperties { ...cursor.cursorDisabled, }; + // TODO: Remove this "eslint-disable-next" once the theme switching migration is done and styles are fully typed + // eslint-disable-next-line @typescript-eslint/no-unsafe-return return { ...styles.link, ...(isDisabled ? disabledLinkStyles : {}), diff --git a/src/styles/getReportActionContextMenuStyles.ts b/src/styles/getReportActionContextMenuStyles.ts index 17f0828ab80c..30ea9658a029 100644 --- a/src/styles/getReportActionContextMenuStyles.ts +++ b/src/styles/getReportActionContextMenuStyles.ts @@ -35,6 +35,8 @@ function getReportActionContextMenuStyles(isMini: boolean, isSmallScreenWidth: b return miniWrapperStyle; } + // TODO: Remove this "eslint-disable-next" once the theme switching migration is done and styles are fully typed + // eslint-disable-next-line @typescript-eslint/no-unsafe-return return [ ...bigWrapperStyle, diff --git a/src/styles/useThemeStyles.ts b/src/styles/useThemeStyles.ts index 77ee0edb6f95..65a2309f83b7 100644 --- a/src/styles/useThemeStyles.ts +++ b/src/styles/useThemeStyles.ts @@ -8,6 +8,8 @@ function useThemeStyles() { throw new Error('StylesContext was null! Are you sure that you wrapped the component under a ?'); } + // TODO: Remove this "eslint-disable-next" once the theme switching migration is done and styles are fully typed + // eslint-disable-next-line @typescript-eslint/no-unsafe-return return themeStyles; } From 97a3fe78f6d595c48b0616f05976a0c7ab7381d3 Mon Sep 17 00:00:00 2001 From: tienifr Date: Wed, 13 Sep 2023 02:07:34 +0700 Subject: [PATCH 273/284] fix: cannot edit money request in offline mode --- src/libs/ReportUtils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index f6f1ac234250..3b3f7b976ba6 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -2627,7 +2627,7 @@ function buildTransactionThread(reportAction, moneyRequestReportID) { participantAccountIDs, getTransactionReportName(reportAction), '', - lodashGet(getReport(reportAction.reportID), 'policyID', CONST.POLICY.OWNER_EMAIL_FAKE), + lodashGet(getReport(moneyRequestReportID), 'policyID', CONST.POLICY.OWNER_EMAIL_FAKE), CONST.POLICY.OWNER_ACCOUNT_ID_FAKE, false, '', From e5e697b4f644f2581c2433fc5f98ef9ab148e5de Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Wed, 13 Sep 2023 14:40:00 +0200 Subject: [PATCH 274/284] fix: add GH issue link to TODO comments --- src/styles/StyleUtils.ts | 20 +++++++++---------- .../getReportActionContextMenuStyles.ts | 2 +- src/styles/useThemeStyles.ts | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/styles/StyleUtils.ts b/src/styles/StyleUtils.ts index a0508090f774..0701adb83313 100644 --- a/src/styles/StyleUtils.ts +++ b/src/styles/StyleUtils.ts @@ -259,7 +259,7 @@ function getSafeAreaMargins(insets?: EdgeInsets): ViewStyle | CSSProperties { function getZoomCursorStyle(isZoomed: boolean, isDragging: boolean): ViewStyle | CSSProperties { if (!isZoomed) { - // TODO: Remove this "eslint-disable-next" once the theme switching migration is done and styles are fully typed + // TODO: Remove this "eslint-disable-next" once the theme switching migration is done and styles are fully typed (GH Issue: https://github.com/Expensify/App/issues/27337) // eslint-disable-next-line @typescript-eslint/no-unsafe-return return styles.cursorZoomIn; } @@ -339,7 +339,7 @@ function getWidthStyle(width: number): ViewStyle | CSSProperties { */ function getAutoGrowHeightInputStyle(textInputHeight: number, maxHeight: number): ViewStyle | CSSProperties { if (textInputHeight > maxHeight) { - // TODO: Remove this "eslint-disable-next" once the theme switching migration is done and styles are fully typed + // TODO: Remove this "eslint-disable-next" once the theme switching migration is done and styles are fully typed (GH Issue: https://github.com/Expensify/App/issues/27337) // eslint-disable-next-line @typescript-eslint/no-unsafe-return return { ...styles.pr0, @@ -347,7 +347,7 @@ function getAutoGrowHeightInputStyle(textInputHeight: number, maxHeight: number) }; } - // TODO: Remove this "eslint-disable-next" once the theme switching migration is done and styles are fully typed + // TODO: Remove this "eslint-disable-next" once the theme switching migration is done and styles are fully typed (GH Issue: https://github.com/Expensify/App/issues/27337) // eslint-disable-next-line @typescript-eslint/no-unsafe-return return { ...styles.pr0, @@ -446,16 +446,16 @@ function getBackgroundColorWithOpacityStyle(backgroundColor: string, opacity: nu function getBadgeColorStyle(success: boolean, error: boolean, isPressed = false, isAdHoc = false): ViewStyle | CSSProperties { if (success) { if (isAdHoc) { - // TODO: Remove this "eslint-disable-next" once the theme switching migration is done and styles are fully typed + // TODO: Remove this "eslint-disable-next" once the theme switching migration is done and styles are fully typed (GH Issue: https://github.com/Expensify/App/issues/27337) // eslint-disable-next-line @typescript-eslint/no-unsafe-return return isPressed ? styles.badgeAdHocSuccessPressed : styles.badgeAdHocSuccess; } - // TODO: Remove this "eslint-disable-next" once the theme switching migration is done and styles are fully typed + // TODO: Remove this "eslint-disable-next" once the theme switching migration is done and styles are fully typed (GH Issue: https://github.com/Expensify/App/issues/27337) // eslint-disable-next-line @typescript-eslint/no-unsafe-return return isPressed ? styles.badgeSuccessPressed : styles.badgeSuccess; } if (error) { - // TODO: Remove this "eslint-disable-next" once the theme switching migration is done and styles are fully typed + // TODO: Remove this "eslint-disable-next" once the theme switching migration is done and styles are fully typed (GH Issue: https://github.com/Expensify/App/issues/27337) // eslint-disable-next-line @typescript-eslint/no-unsafe-return return isPressed ? styles.badgeDangerPressed : styles.badgeDanger; } @@ -606,7 +606,7 @@ function getLoginPagePromoStyle(): ViewStyle | CSSProperties { * Generate the styles for the ReportActionItem wrapper view. */ function getReportActionItemStyle(isHovered = false, isLoading = false): ViewStyle | CSSProperties { - // TODO: Remove this "eslint-disable-next" once the theme switching migration is done and styles are fully typed + // TODO: Remove this "eslint-disable-next" once the theme switching migration is done and styles are fully typed (GH Issue: https://github.com/Expensify/App/issues/27337) // eslint-disable-next-line @typescript-eslint/no-unsafe-return return { display: 'flex', @@ -624,7 +624,7 @@ function getReportActionItemStyle(isHovered = false, isLoading = false): ViewSty * Generate the wrapper styles for the mini ReportActionContextMenu. */ function getMiniReportActionContextMenuWrapperStyle(isReportActionItemGrouped: boolean): ViewStyle | CSSProperties { - // TODO: Remove this "eslint-disable-next" once the theme switching migration is done and styles are fully typed + // TODO: Remove this "eslint-disable-next" once the theme switching migration is done and styles are fully typed (GH Issue: https://github.com/Expensify/App/issues/27337) // eslint-disable-next-line @typescript-eslint/no-unsafe-return return { ...(isReportActionItemGrouped ? positioning.tn8 : positioning.tn4), @@ -1060,7 +1060,7 @@ function displayIfTrue(condition: boolean): ViewStyle | CSSProperties { function getGoogleListViewStyle(shouldDisplayBorder: boolean): ViewStyle | CSSProperties { if (shouldDisplayBorder) { - // TODO: Remove this "eslint-disable-next" once the theme switching migration is done and styles are fully typed + // TODO: Remove this "eslint-disable-next" once the theme switching migration is done and styles are fully typed (GH Issue: https://github.com/Expensify/App/issues/27337) // eslint-disable-next-line @typescript-eslint/no-unsafe-return return { ...styles.borderTopRounded, @@ -1169,7 +1169,7 @@ function getDisabledLinkStyles(isDisabled = false): ViewStyle | CSSProperties { ...cursor.cursorDisabled, }; - // TODO: Remove this "eslint-disable-next" once the theme switching migration is done and styles are fully typed + // TODO: Remove this "eslint-disable-next" once the theme switching migration is done and styles are fully typed (GH Issue: https://github.com/Expensify/App/issues/27337) // eslint-disable-next-line @typescript-eslint/no-unsafe-return return { ...styles.link, diff --git a/src/styles/getReportActionContextMenuStyles.ts b/src/styles/getReportActionContextMenuStyles.ts index 30ea9658a029..9c0e159eb5fe 100644 --- a/src/styles/getReportActionContextMenuStyles.ts +++ b/src/styles/getReportActionContextMenuStyles.ts @@ -35,7 +35,7 @@ function getReportActionContextMenuStyles(isMini: boolean, isSmallScreenWidth: b return miniWrapperStyle; } - // TODO: Remove this "eslint-disable-next" once the theme switching migration is done and styles are fully typed + // TODO: Remove this "eslint-disable-next" once the theme switching migration is done and styles are fully typed (GH Issue: https://github.com/Expensify/App/issues/27337) // eslint-disable-next-line @typescript-eslint/no-unsafe-return return [ ...bigWrapperStyle, diff --git a/src/styles/useThemeStyles.ts b/src/styles/useThemeStyles.ts index 65a2309f83b7..a5b3baebbaec 100644 --- a/src/styles/useThemeStyles.ts +++ b/src/styles/useThemeStyles.ts @@ -8,7 +8,7 @@ function useThemeStyles() { throw new Error('StylesContext was null! Are you sure that you wrapped the component under a ?'); } - // TODO: Remove this "eslint-disable-next" once the theme switching migration is done and styles are fully typed + // TODO: Remove this "eslint-disable-next" once the theme switching migration is done and styles are fully typed (GH Issue: https://github.com/Expensify/App/issues/27337) // eslint-disable-next-line @typescript-eslint/no-unsafe-return return themeStyles; } From 263a6113517f88b9f14a602574ec5c2171329420 Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Wed, 13 Sep 2023 14:54:56 +0200 Subject: [PATCH 275/284] fix: add one more comment --- src/styles/styles.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/styles/styles.js b/src/styles/styles.js index ced90e972f6a..944a8a083b26 100644 --- a/src/styles/styles.js +++ b/src/styles/styles.js @@ -3964,7 +3964,7 @@ const styles = (theme) => ({ // For now we need to export the styles function that takes the theme as an argument // as something named different than "styles", because a lot of files import the "defaultStyles" // as "styles", which causes ESLint to throw an error. -// TODO: Remove this once the app is migrated to theme switching hooks and HOCs and "styles/theme/default.js" is not used anywhere anymore +// TODO: Remove this once the app is migrated to theme switching hooks and HOCs and "styles/theme/default.js" is not used anywhere anymore (GH issue: https://github.com/Expensify/App/issues/27337) const stylesGenerator = styles; const defaultStyles = styles(defaultTheme); From cc621524d4919c685d9e2f462ad41322829a01ff Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Wed, 13 Sep 2023 14:55:30 +0200 Subject: [PATCH 276/284] fix: update comment --- src/styles/styles.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/styles/styles.js b/src/styles/styles.js index 944a8a083b26..e81e03726c78 100644 --- a/src/styles/styles.js +++ b/src/styles/styles.js @@ -3964,7 +3964,7 @@ const styles = (theme) => ({ // For now we need to export the styles function that takes the theme as an argument // as something named different than "styles", because a lot of files import the "defaultStyles" // as "styles", which causes ESLint to throw an error. -// TODO: Remove this once the app is migrated to theme switching hooks and HOCs and "styles/theme/default.js" is not used anywhere anymore (GH issue: https://github.com/Expensify/App/issues/27337) +// TODO: Remove "stylesGenerator" and instead only return "styles" once the app is migrated to theme switching hooks and HOCs and "styles/theme/default.js" is not used anywhere anymore (GH issue: https://github.com/Expensify/App/issues/27337) const stylesGenerator = styles; const defaultStyles = styles(defaultTheme); From 068556a32fe503f8a948d90bdfa1b7621cf46e42 Mon Sep 17 00:00:00 2001 From: Christoph Pader Date: Wed, 13 Sep 2023 15:01:54 +0200 Subject: [PATCH 277/284] fix: remove weird change --- src/libs/ReportUtils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index 3b3f7b976ba6..f6f1ac234250 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -2627,7 +2627,7 @@ function buildTransactionThread(reportAction, moneyRequestReportID) { participantAccountIDs, getTransactionReportName(reportAction), '', - lodashGet(getReport(moneyRequestReportID), 'policyID', CONST.POLICY.OWNER_EMAIL_FAKE), + lodashGet(getReport(reportAction.reportID), 'policyID', CONST.POLICY.OWNER_EMAIL_FAKE), CONST.POLICY.OWNER_ACCOUNT_ID_FAKE, false, '', From ace654564ae5717871bb23a77661bbd5850116d3 Mon Sep 17 00:00:00 2001 From: Ana Margarida Silva Date: Wed, 13 Sep 2023 15:29:08 +0100 Subject: [PATCH 278/284] fix: regressions of flat translations --- src/components/StatePicker/index.js | 3 ++- src/pages/ReimbursementAccount/CompanyStep.js | 2 +- .../settings/Preferences/PriorityModePage.js | 12 +++++----- src/pages/settings/Preferences/ThemePage.js | 10 ++++----- .../Report/NotificationPreferencePage.js | 22 +++++++++++-------- 5 files changed, 27 insertions(+), 22 deletions(-) diff --git a/src/components/StatePicker/index.js b/src/components/StatePicker/index.js index 9653a207c1fb..8c9c3b1b8d65 100644 --- a/src/components/StatePicker/index.js +++ b/src/components/StatePicker/index.js @@ -2,6 +2,7 @@ import React, {useState} from 'react'; import {View} from 'react-native'; import PropTypes from 'prop-types'; import styles from '../../styles/styles'; +import CONST from '../../CONST'; import MenuItemWithTopDescription from '../MenuItemWithTopDescription'; import useLocalize from '../../hooks/useLocalize'; import FormHelpMessage from '../FormHelpMessage'; @@ -51,7 +52,7 @@ function StatePicker({value, errorText, onInputChange, forwardedRef, label}) { hidePickerModal(); }; - const title = value ? translate(`allStates.${value}.stateName`) : ''; + const title = value && CONST.ALL_US_ISO_STATES.includes(value) ? translate(`allStates.${value}.stateName`) : ''; const descStyle = title.length === 0 ? styles.textNormal : null; return ( diff --git a/src/pages/ReimbursementAccount/CompanyStep.js b/src/pages/ReimbursementAccount/CompanyStep.js index d76d10c9e52c..22133415cea8 100644 --- a/src/pages/ReimbursementAccount/CompanyStep.js +++ b/src/pages/ReimbursementAccount/CompanyStep.js @@ -224,7 +224,7 @@ function CompanyStep({reimbursementAccount, reimbursementAccountDraft, getDefaul ({value, label}))} + items={_.map(_.keys(CONST.INCORPORATION_TYPES), (key) => ({value: key, label: translate(`companyStep.incorporationTypes.${key}`)}))} placeholder={{value: '', label: '-'}} defaultValue={getDefaultStateForField('incorporationType')} shouldSaveDraft diff --git a/src/pages/settings/Preferences/PriorityModePage.js b/src/pages/settings/Preferences/PriorityModePage.js index b32987e242de..0c3d28fe9d81 100644 --- a/src/pages/settings/Preferences/PriorityModePage.js +++ b/src/pages/settings/Preferences/PriorityModePage.js @@ -26,12 +26,12 @@ const defaultProps = { }; function PriorityModePage(props) { - const priorityModes = _.map(props.translate('priorityModePage.priorityModes'), (mode, key) => ({ - value: key, - text: mode.label, - alternateText: mode.description, - keyForList: key, - isSelected: props.priorityMode === key, + const priorityModes = _.map(_.values(CONST.PRIORITY_MODE), (mode) => ({ + value: mode, + text: props.translate(`priorityModePage.priorityModes.${mode}.label`), + alternateText: props.translate(`priorityModePage.priorityModes.${mode}.description`), + keyForList: mode, + isSelected: props.priorityMode === mode, })); const updateMode = useCallback( diff --git a/src/pages/settings/Preferences/ThemePage.js b/src/pages/settings/Preferences/ThemePage.js index a260caa283e3..4e41d5fc7129 100644 --- a/src/pages/settings/Preferences/ThemePage.js +++ b/src/pages/settings/Preferences/ThemePage.js @@ -27,11 +27,11 @@ const defaultProps = { }; function ThemePage(props) { - const localesToThemes = _.map(props.translate('themePage.themes'), (theme, key) => ({ - value: key, - text: theme.label, - keyForList: key, - isSelected: (props.preferredTheme || CONST.THEME.DEFAULT) === key, + const localesToThemes = _.map(_.values(_.omit(CONST.THEME, 'DEFAULT')), (theme) => ({ + value: theme, + text: props.translate(`themePage.themes.${theme}.label`), + keyForList: theme, + isSelected: (props.preferredTheme || CONST.THEME.DEFAULT) === theme, })); return ( diff --git a/src/pages/settings/Report/NotificationPreferencePage.js b/src/pages/settings/Report/NotificationPreferencePage.js index 9765cf1ae0b4..17bd77a235ce 100644 --- a/src/pages/settings/Report/NotificationPreferencePage.js +++ b/src/pages/settings/Report/NotificationPreferencePage.js @@ -11,6 +11,7 @@ import withReportOrNotFound from '../../home/report/withReportOrNotFound'; import FullPageNotFoundView from '../../../components/BlockingViews/FullPageNotFoundView'; import reportPropTypes from '../../reportPropTypes'; import ROUTES from '../../../ROUTES'; +import CONST from '../../../CONST'; import * as Report from '../../../libs/actions/Report'; import * as ReportUtils from '../../../libs/ReportUtils'; import * as Expensicons from '../../../components/Icon/Expensicons'; @@ -26,17 +27,20 @@ const greenCheckmark = {src: Expensicons.Checkmark, color: themeColors.success}; function NotificationPreferencePage(props) { const shouldDisableNotificationPreferences = ReportUtils.shouldDisableSettings(props.report) || ReportUtils.isArchivedRoom(props.report); - const notificationPreferenceOptions = _.map(props.translate('notificationPreferencesPage.notificationPreferences'), (preference, key) => ({ - value: key, - text: preference, - keyForList: key, + const notificationPreferenceOptions = _.map( + _.filter(_.values(CONST.REPORT.NOTIFICATION_PREFERENCE), (pref) => pref !== CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN), + (preference) => ({ + value: preference, + text: props.translate(`notificationPreferencesPage.notificationPreferences.${preference}`), + keyForList: preference, - // Include the green checkmark icon to indicate the currently selected value - customIcon: key === props.report.notificationPreference ? greenCheckmark : null, + // Include the green checkmark icon to indicate the currently selected value + customIcon: preference === props.report.notificationPreference ? greenCheckmark : null, - // This property will make the currently selected value have bold text - boldStyle: key === props.report.notificationPreference, - })); + // This property will make the currently selected value have bold text + boldStyle: preference === props.report.notificationPreference, + }), + ); return ( From 1850aa8011e9d0df3424ce2248640fc2f3c44c92 Mon Sep 17 00:00:00 2001 From: pradeepkumar Date: Wed, 13 Sep 2023 20:05:58 +0530 Subject: [PATCH 279/284] fix --- src/libs/isReportMessageAttachment.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/isReportMessageAttachment.ts b/src/libs/isReportMessageAttachment.ts index c257e1db4191..9984259c4b6d 100644 --- a/src/libs/isReportMessageAttachment.ts +++ b/src/libs/isReportMessageAttachment.ts @@ -17,7 +17,7 @@ export default function isReportMessageAttachment({text, html, translationKey}: return false; } - if (translationKey && text === CONST.ATTACHMENT_MESSAGE_TEXT) { + if (translationKey && (text === CONST.ATTACHMENT_MESSAGE_TEXT || text === CONST.TRANSLATION_KEYS.ATTACHMENT)) { return translationKey === CONST.TRANSLATION_KEYS.ATTACHMENT; } From 3cd2e9c9ab496f53a5083a42a6a4d4ca792e3151 Mon Sep 17 00:00:00 2001 From: Ana Margarida Silva Date: Wed, 13 Sep 2023 15:37:54 +0100 Subject: [PATCH 280/284] fix: missing translate in pronouns --- src/pages/settings/Profile/PronounsPage.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/settings/Profile/PronounsPage.js b/src/pages/settings/Profile/PronounsPage.js index fe92281750cb..5f8824046d69 100644 --- a/src/pages/settings/Profile/PronounsPage.js +++ b/src/pages/settings/Profile/PronounsPage.js @@ -31,7 +31,7 @@ function PronounsPage({currentUserPersonalDetails}) { .find((_value) => _value === currentPronounsKey) .value(); - return currentPronounsText || ''; + return currentPronounsText ? translate(`pronouns.${currentPronounsText}`) : ''; }); const filteredPronounsList = useMemo(() => { From 3622c0994749907868e8508293a0d82015085db8 Mon Sep 17 00:00:00 2001 From: snyk-bot Date: Wed, 13 Sep 2023 14:50:41 +0000 Subject: [PATCH 281/284] fix: package.json & package-lock.json to reduce vulnerabilities The following vulnerabilities are fixed with an upgrade: - https://snyk.io/vuln/SNYK-JS-ELECTRON-5892810 --- package-lock.json | 14 +++++++------- package.json | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index 84fd66245b9e..a2847439e5c8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -186,7 +186,7 @@ "css-loader": "^6.7.2", "diff-so-fancy": "^1.3.0", "dotenv": "^16.0.3", - "electron": "^25.8.0", + "electron": "^25.8.1", "electron-builder": "24.6.4", "eslint": "^7.6.0", "eslint-config-airbnb-typescript": "^17.1.0", @@ -25044,9 +25044,9 @@ } }, "node_modules/electron": { - "version": "25.8.0", - "resolved": "https://registry.npmjs.org/electron/-/electron-25.8.0.tgz", - "integrity": "sha512-T3kC1a/3ntSaYMCVVfUUc9v7myPzi6J2GP0Ad/CyfWKDPp054dGyKxb2EEjKnxQQ7wfjsT1JTEdBG04x6ekVBw==", + "version": "25.8.1", + "resolved": "https://registry.npmjs.org/electron/-/electron-25.8.1.tgz", + "integrity": "sha512-GtcP1nMrROZfFg0+mhyj1hamrHvukfF6of2B/pcWxmWkd5FVY1NJib0tlhiorFZRzQN5Z+APLPr7aMolt7i2AQ==", "dev": true, "hasInstallScript": true, "dependencies": { @@ -65438,9 +65438,9 @@ } }, "electron": { - "version": "25.8.0", - "resolved": "https://registry.npmjs.org/electron/-/electron-25.8.0.tgz", - "integrity": "sha512-T3kC1a/3ntSaYMCVVfUUc9v7myPzi6J2GP0Ad/CyfWKDPp054dGyKxb2EEjKnxQQ7wfjsT1JTEdBG04x6ekVBw==", + "version": "25.8.1", + "resolved": "https://registry.npmjs.org/electron/-/electron-25.8.1.tgz", + "integrity": "sha512-GtcP1nMrROZfFg0+mhyj1hamrHvukfF6of2B/pcWxmWkd5FVY1NJib0tlhiorFZRzQN5Z+APLPr7aMolt7i2AQ==", "dev": true, "requires": { "@electron/get": "^2.0.0", diff --git a/package.json b/package.json index 3395ce7e3413..1c474362caf8 100644 --- a/package.json +++ b/package.json @@ -228,7 +228,7 @@ "css-loader": "^6.7.2", "diff-so-fancy": "^1.3.0", "dotenv": "^16.0.3", - "electron": "^25.8.0", + "electron": "^25.8.1", "electron-builder": "24.6.4", "eslint": "^7.6.0", "eslint-config-airbnb-typescript": "^17.1.0", From 03522c32db9dbf4af64eb94e00d8baadcad65285 Mon Sep 17 00:00:00 2001 From: pradeepkumar Date: Wed, 13 Sep 2023 21:17:19 +0530 Subject: [PATCH 282/284] make const changes --- src/libs/ReportActionsUtils.js | 2 +- src/libs/isReportMessageAttachment.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/ReportActionsUtils.js b/src/libs/ReportActionsUtils.js index 9cbc414bf582..3207819b5763 100644 --- a/src/libs/ReportActionsUtils.js +++ b/src/libs/ReportActionsUtils.js @@ -397,7 +397,7 @@ function getLastVisibleMessage(reportID, actionsToMerge = {}) { if (isReportMessageAttachment(message)) { return { lastMessageTranslationKey: CONST.TRANSLATION_KEYS.ATTACHMENT, - lastMessageText: CONST.TRANSLATION_KEYS.ATTACHMENT, + lastMessageText: CONST.ATTACHMENT_MESSAGE_TEXT, lastMessageHtml: CONST.TRANSLATION_KEYS.ATTACHMENT, }; } diff --git a/src/libs/isReportMessageAttachment.ts b/src/libs/isReportMessageAttachment.ts index 9984259c4b6d..c257e1db4191 100644 --- a/src/libs/isReportMessageAttachment.ts +++ b/src/libs/isReportMessageAttachment.ts @@ -17,7 +17,7 @@ export default function isReportMessageAttachment({text, html, translationKey}: return false; } - if (translationKey && (text === CONST.ATTACHMENT_MESSAGE_TEXT || text === CONST.TRANSLATION_KEYS.ATTACHMENT)) { + if (translationKey && text === CONST.ATTACHMENT_MESSAGE_TEXT) { return translationKey === CONST.TRANSLATION_KEYS.ATTACHMENT; } From 62b96d7b4e5422d652a4addcb89f053407655508 Mon Sep 17 00:00:00 2001 From: Ana Margarida Silva Date: Wed, 13 Sep 2023 17:28:09 +0100 Subject: [PATCH 283/284] fix: remove const and use from expensify-common instead --- src/CONST.ts | 55 ------------------- .../StatePicker/StateSelectorModal.js | 3 +- src/components/StatePicker/index.js | 5 +- 3 files changed, 5 insertions(+), 58 deletions(-) diff --git a/src/CONST.ts b/src/CONST.ts index ced657b06e19..2abf5f297c78 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -1684,61 +1684,6 @@ const CONST = { ZW: 'Zimbabwe', }, - ALL_US_ISO_STATES: [ - 'AK', - 'AL', - 'AR', - 'AZ', - 'CA', - 'CO', - 'CT', - 'DE', - 'FL', - 'GA', - 'HI', - 'IA', - 'ID', - 'IL', - 'IN', - 'KS', - 'KY', - 'LA', - 'MA', - 'MD', - 'ME', - 'MI', - 'MN', - 'MO', - 'MS', - 'MT', - 'NC', - 'ND', - 'NE', - 'NH', - 'NJ', - 'NM', - 'NV', - 'NY', - 'OH', - 'OK', - 'OR', - 'PA', - 'PR', - 'RI', - 'SC', - 'SD', - 'TN', - 'TX', - 'UT', - 'VA', - 'VT', - 'WA', - 'WI', - 'WV', - 'WY', - 'DC', - ], - // Sources: https://github.com/Expensify/App/issues/14958#issuecomment-1442138427 // https://github.com/Expensify/App/issues/14958#issuecomment-1456026810 COUNTRY_ZIP_REGEX_DATA: { diff --git a/src/components/StatePicker/StateSelectorModal.js b/src/components/StatePicker/StateSelectorModal.js index 0caa2db6849b..bea335840c53 100644 --- a/src/components/StatePicker/StateSelectorModal.js +++ b/src/components/StatePicker/StateSelectorModal.js @@ -1,6 +1,7 @@ import _ from 'underscore'; import React, {useMemo, useEffect} from 'react'; import PropTypes from 'prop-types'; +import {CONST as COMMON_CONST} from 'expensify-common/lib/CONST'; import CONST from '../../CONST'; import Modal from '../Modal'; import HeaderWithBackButton from '../HeaderWithBackButton'; @@ -53,7 +54,7 @@ function StateSelectorModal({currentState, isVisible, onClose, onStateSelected, const countryStates = useMemo( () => - _.map(CONST.ALL_US_ISO_STATES, (state) => { + _.map(_.keys(COMMON_CONST.STATES), (state) => { const stateName = translate(`allStates.${state}.stateName`); const stateISO = translate(`allStates.${state}.stateISO`); return { diff --git a/src/components/StatePicker/index.js b/src/components/StatePicker/index.js index 8c9c3b1b8d65..142654b82cd1 100644 --- a/src/components/StatePicker/index.js +++ b/src/components/StatePicker/index.js @@ -1,8 +1,9 @@ import React, {useState} from 'react'; import {View} from 'react-native'; import PropTypes from 'prop-types'; +import _ from 'underscore'; +import {CONST as COMMON_CONST} from 'expensify-common/lib/CONST'; import styles from '../../styles/styles'; -import CONST from '../../CONST'; import MenuItemWithTopDescription from '../MenuItemWithTopDescription'; import useLocalize from '../../hooks/useLocalize'; import FormHelpMessage from '../FormHelpMessage'; @@ -52,7 +53,7 @@ function StatePicker({value, errorText, onInputChange, forwardedRef, label}) { hidePickerModal(); }; - const title = value && CONST.ALL_US_ISO_STATES.includes(value) ? translate(`allStates.${value}.stateName`) : ''; + const title = value && _.keys(COMMON_CONST.STATES).includes(value) ? translate(`allStates.${value}.stateName`) : ''; const descStyle = title.length === 0 ? styles.textNormal : null; return ( From 3f61f61843a91dc2c4f0c3205b35b70dceb38eb7 Mon Sep 17 00:00:00 2001 From: OSBotify Date: Wed, 13 Sep 2023 19:54:31 +0000 Subject: [PATCH 284/284] Update version to 1.3.69-1 --- android/app/build.gradle | 4 ++-- ios/NewExpensify/Info.plist | 2 +- ios/NewExpensifyTests/Info.plist | 2 +- package-lock.json | 4 ++-- package.json | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index 534c1e38c958..5a4f9d2a835c 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -90,8 +90,8 @@ android { minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion multiDexEnabled rootProject.ext.multiDexEnabled - versionCode 1001036900 - versionName "1.3.69-0" + versionCode 1001036901 + versionName "1.3.69-1" } flavorDimensions "default" diff --git a/ios/NewExpensify/Info.plist b/ios/NewExpensify/Info.plist index 4d8c217ade89..c9ba137b13de 100644 --- a/ios/NewExpensify/Info.plist +++ b/ios/NewExpensify/Info.plist @@ -40,7 +40,7 @@ CFBundleVersion - 1.3.69.0 + 1.3.69.1 ITSAppUsesNonExemptEncryption LSApplicationQueriesSchemes diff --git a/ios/NewExpensifyTests/Info.plist b/ios/NewExpensifyTests/Info.plist index 54e6a723c383..e802856c4dd5 100644 --- a/ios/NewExpensifyTests/Info.plist +++ b/ios/NewExpensifyTests/Info.plist @@ -19,6 +19,6 @@ CFBundleSignature ???? CFBundleVersion - 1.3.69.0 + 1.3.69.1 diff --git a/package-lock.json b/package-lock.json index a2847439e5c8..169ef273b29b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "new.expensify", - "version": "1.3.69-0", + "version": "1.3.69-1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "new.expensify", - "version": "1.3.69-0", + "version": "1.3.69-1", "hasInstallScript": true, "license": "MIT", "dependencies": { diff --git a/package.json b/package.json index 1c474362caf8..177a6fdcfd36 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "new.expensify", - "version": "1.3.69-0", + "version": "1.3.69-1", "author": "Expensify, Inc.", "homepage": "https://new.expensify.com", "description": "New Expensify is the next generation of Expensify: a reimagination of payments based atop a foundation of chat.",