From 9b5afb1b5f8d63e7a03b97a7e03a62bedb695099 Mon Sep 17 00:00:00 2001 From: Harrison Healey Date: Thu, 23 Mar 2023 14:23:56 -0400 Subject: [PATCH] Run tests for all web app packages in CI (#22579) * Run tests for all web app packages in CI * Test specific packages instead of all of them * Revert back to using test-ci scripts and rely on Jest to count the number of CPU cores * Revert more changes made to the web app CI tests * Fix path to client package tests --- .github/workflows/channels-ci.yml | 13 +++++++------ webapp/boards/package.json | 2 +- webapp/channels/package.json | 2 +- webapp/platform/client/package.json | 1 + webapp/playbooks/jest.config.js | 18 ++++++++++++++++++ webapp/playbooks/package.json | 2 +- 6 files changed, 29 insertions(+), 9 deletions(-) create mode 100644 webapp/playbooks/jest.config.js diff --git a/.github/workflows/channels-ci.yml b/.github/workflows/channels-ci.yml index 63a227fdff..cc18459178 100644 --- a/.github/workflows/channels-ci.yml +++ b/.github/workflows/channels-ci.yml @@ -111,7 +111,7 @@ jobs: - name: ci/lint run: | npm run check-types - tests: + test: runs-on: ubuntu-22.04 needs: [check-types, check-i18n, check-lint] permissions: @@ -143,13 +143,14 @@ jobs: run: | make node_modules # make channels/e2e/playwright/node_modules - - name: ci/detect-cpu-core - id: cpu-cores - uses: SimenB/github-actions-cpu-cores@c508d404ab007faae80a014072fd8c0e17792118 # v1.1.0 - name: ci/test - working-directory: webapp/channels + env: + NODE_OPTIONS: --max_old_space_size=5120 run: | - npm run test-ci -- --maxWorkers=${{ steps.cpu-cores.outputs.count }} + # npm run test-ci --workspace=boards + npm run test-ci --workspace=channels + npm run test-ci --workspace=platform/client + npm run test-ci --workspace=playbooks - name: ci/publish-test-results uses: EnricoMi/publish-unit-test-result-action@a3caf02865c0604ad3dc1ecfcc5cdec9c41b7936 # v2.3.0 if: always() diff --git a/webapp/boards/package.json b/webapp/boards/package.json index 6d2f3031d2..a66ffcfc34 100644 --- a/webapp/boards/package.json +++ b/webapp/boards/package.json @@ -22,7 +22,7 @@ "test": "jest --forceExit --detectOpenHandles --verbose", "test:watch": "jest --watch", "test:updatesnapshot": "jest --updateSnapshot", - "test-ci": "jest --forceExit --detectOpenHandles --maxWorkers=2", + "test-ci": "jest --ci --forceExit --detectOpenHandles --maxWorkers=100%", "clean": "rm -rf node_modules .eslintcache" }, "dependencies": { diff --git a/webapp/channels/package.json b/webapp/channels/package.json index 29e37ffc35..cdbd790a37 100644 --- a/webapp/channels/package.json +++ b/webapp/channels/package.json @@ -224,7 +224,7 @@ "run": "webpack --progress --watch", "dev-server": "webpack serve --mode development", "test": "cross-env TZ=Etc/UTC jest --maxWorkers=50%", - "test-ci": "cross-env NODE_OPTIONS=--max_old_space_size=5120 TZ=Etc/UTC jest --ci", + "test-ci": "cross-env TZ=Etc/UTC jest --ci --maxWorkers=100%", "clean": "rm -rf dist node_modules .eslintcache .stylelintcache tsconfig.tsbuildinfo", "stats": "cross-env NODE_ENV=production webpack --profile --json > webpack_stats.json", "updatesnapshot": "cross-env TZ=Etc/UTC jest --updateSnapshot", diff --git a/webapp/platform/client/package.json b/webapp/platform/client/package.json index 59bf96638e..60c3d8fbfb 100644 --- a/webapp/platform/client/package.json +++ b/webapp/platform/client/package.json @@ -39,6 +39,7 @@ "build": "tsc --build --verbose", "run": "tsc --watch --preserveWatchOutput", "test": "jest", + "test-ci": "jest --ci --forceExit --detectOpenHandles --maxWorkers=100%", "clean": "rm -rf lib node_modules tsconfig.tsbuildinfo" } } diff --git a/webapp/playbooks/jest.config.js b/webapp/playbooks/jest.config.js new file mode 100644 index 0000000000..1c9eae985f --- /dev/null +++ b/webapp/playbooks/jest.config.js @@ -0,0 +1,18 @@ +// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. +// See LICENSE.txt for license information. + +/** @type {import('jest').Config} */ + +const config = { + moduleDirectories: ['src', 'node_modules'], + moduleNameMapper: { + '^@mattermost/(components)$': '/../platform/$1/src', + '^@mattermost/(client)$': '/../platform/$1/src', + '^@mattermost/(types)/(.*)$': '/../platform/$1/src/$2', + '^reselect$': '/../channels/src/packages/reselect/src', + '^src/(.*)$': '/src/$1', + }, + testEnvironment: 'jsdom', +}; + +module.exports = config; \ No newline at end of file diff --git a/webapp/playbooks/package.json b/webapp/playbooks/package.json index 685f24abb2..5d47d35030 100644 --- a/webapp/playbooks/package.json +++ b/webapp/playbooks/package.json @@ -126,7 +126,7 @@ "fix": "eslint --ignore-pattern node_modules --ignore-pattern dist --ext .js --ext .jsx --ext tsx --ext ts . --quiet --fix --cache", "test": "jest --forceExit --detectOpenHandles --verbose", "test:watch": "jest --watch", - "test-ci": "jest --forceExit --detectOpenHandles --maxWorkers=2", + "test-ci": "jest --ci --forceExit --detectOpenHandles --maxWorkers=100%", "check-types": "tsc -b", "extract": "formatjs extract 'src/**/*.{ts,tsx}' --out-file i18n/temp.json --id-interpolation-pattern '[sha512:contenthash:base64:6]' && formatjs compile 'i18n/temp.json' --out-file i18n/en.json && rm i18n/temp.json", "graphql": "graphql-codegen --config graphql_gen.ts",