Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(805): nx and rspack on existing project structure #847

Merged
merged 19 commits into from
Apr 28, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
chore(805): add experimental test commands
  • Loading branch information
JohnTParsons authored and JohnTParsons committed Apr 27, 2023
commit 7ef67d34454b41ebda720d6b26b2fd153e5d4bb2
30 changes: 27 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ jobs:
at: ~/project
- run:
name: Unit Testing
command: yarn test:unit:comps2
command: yarn test:unit:comps:experimental
environment:
JEST_JUNIT_OUTPUT_DIR: ./reports/junit/
- store_test_results:
Expand Down Expand Up @@ -660,6 +660,27 @@ jobs:
- slack/notify:
<<: *slack_notify

test_unit_docs2:
executor: node-xlarge
steps:
- checkout
- attach_workspace:
at: ~/project
- run:
name: Unit Testing
command: yarn test:unit:docs:experimental
environment:
JEST_JUNIT_OUTPUT_DIR: ./reports/junit/
- run:
name: Check component statuses match code tags
command: yarn test:comp-statuses
- store_test_results:
path: ./reports/junit/
- store_artifacts:
path: ./reports/junit
- slack/notify:
<<: *slack_notify

lint:
executor: node
steps:
Expand Down Expand Up @@ -1252,10 +1273,13 @@ workflows:
- lint:
requires:
- build_icons
- test_unit_comps:
- test_unit_comps2:
requires:
- build_icons
- test_unit_comps2:
- test_unit_docs2:
requires:
- build_icons
- test_unit_comps:
requires:
- build_icons
- test_unit_docs:
Expand Down
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,19 @@
"lint:next": "nx exec -- next lint site",
"lint:packages": "npx nx report",
"lint": "scripts/assert-files-and-folders.js && concurrently --names \"markdown,next,comps,docs\" \"yarn lint:markdown\" \"yarn lint:next\" \"yarn lint:code:comps\" \"yarn lint:code:docs\"",
"test": "yarn lint && yarn test:unit:dev",
"test": "yarn lint && yarn test:unit:dev --forceExit",
"test:unit:node": "node --max-old-space-size=8192 --expose-gc ./node_modules/.bin/jest --logHeapUsage --coverage --coverageReporters=lcov --coverageReporters=text",
"test:unit:watch": "yarn test:unit:node --maxWorkers=50% --watch",
"test:unit:run": "NODE_OPTIONS=\"--max-old-space-size=8192\" nx exec -- jest --logHeapUsage --coverage --coverageReporters=lcov --coverageReporters=text",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

given you've bumped the CI instance size should this memory size go up also?

"test:unit:run:local": "yarn test:unit:run --maxWorkers=50% --coveragePathIgnorePatterns=/src/icons/",
"test:unit:dev": "yarn build:icons && concurrently --names \"docs,comps\" \"yarn test:unit:docs\" \"yarn test:unit:comps\"",
"test:unit:ci": "yarn test:unit:node --maxWorkers=2 --ci --reporters=default --reporters=jest-junit",
"test:unit:comps": "yarn test:unit:run:local --maxWorkers=50% --projects=src",
"test:unit:comps2": "npx nx test newskit-ui --codeCoverage --logHeapUsage --coverage --coverageReporters=lcov --coverageReporters=text",
"test:unit:comps:experimental": "NODE_OPTIONS=\"--max-old-space-size=8192\" npx nx test newskit-ui --codeCoverage --logHeapUsage --coverage --coverageReporters=lcov --coverageReporters=text",
Vanals marked this conversation as resolved.
Show resolved Hide resolved
"test:unit:docs": "yarn test:unit:run:local --maxWorkers=50% --projects=site",
"test:unit:comps:ci": "yarn test:unit:node --maxWorkers=4 --projects=src --ci --reporters=default --reporters=jest-junit",
"test:unit:docs:ci": "yarn test:unit:node --maxWorkers=3 --projects=site --ci --reporters=default --reporters=jest-junit",
"test:unit:docs:experimental": "NODE_OPTIONS=\"--max-old-space-size=8192\" npx nx test site --codeCoverage --logHeapUsage --coverage --coverageReporters=lcov --coverageReporters=text",
"test:unit:comps:ci": "yarn test:unit:node --forceExit --maxWorkers=4 --projects=src --ci --reporters=default --reporters=jest-junit",
"test:unit:docs:ci": "yarn test:unit:node --forceExit --maxWorkers=3 --projects=site --ci --reporters=default --reporters=jest-junit",
"test:comp-statuses": "node scripts/component-status.js",
"test:visual:comps:ci:percy": "STORYBOOK_IS_VISUAL_TEST=true start-server-and-test dev:storybook 6006 'percy:run'",
"test:visual:comps:ci:percy:skip": "PERCY_PARTIAL_BUILD=1 STORYBOOK_SKIP_PERCY_CHECK=true start-server-and-test dev:storybook 6006 percy:run",
Expand Down
4 changes: 2 additions & 2 deletions site/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
process.env.TZ = 'GMT';

const {pathsToModuleNameMapper} = require('ts-jest');
const {compilerOptions} = require('./tsconfig.jest.json');
const {compilerOptions} = require('./tsconfig.spec.json');

const paths = pathsToModuleNameMapper(compilerOptions.paths, {
prefix: '<rootDir>/',
Expand All @@ -24,7 +24,7 @@ module.exports = {
'ts-jest',
{
diagnostics: true,
tsconfig: '<rootDir>/tsconfig.jest.json',
tsconfig: '<rootDir>/tsconfig.spec.json',
},
],
},
Expand Down
10 changes: 10 additions & 0 deletions site/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,16 @@
"options": {
"lintFilePatterns": ["site/**/*.{ts,tsx,js,jsx}"]
}
},
"test": {
"executor": "@nrwl/jest:jest",
"outputs": ["{workspaceRoot}/coverage/{projectName}"],
"options": {
"jestConfig": "site/jest.config.js",
"passWithNoTests": true
},
"configurations": {
}
}
},
"tags": []
Expand Down
31 changes: 0 additions & 31 deletions site/tsconfig.base.json

This file was deleted.

2 changes: 1 addition & 1 deletion site/tsconfig.jest.json → site/tsconfig.spec.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"isolatedModules": false,
"isolatedModules": true,
"jsx": "react",
"paths": {
"newskit": [
Expand Down
4 changes: 0 additions & 4 deletions src/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@
"passWithNoTests": true
},
"configurations": {
"ci": {
"ci": true,
"codeCoverage": true
}
}
}
}
Expand Down
22 changes: 22 additions & 0 deletions src/tsconfig.spec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"extends": "../tsconfig.common.json",
"compilerOptions": {
"isolatedModules": true,
"jsx": "react",
"outDir": "../dist/cjs",
"module": "commonjs",
"types": ["jest", "node"]
},
"include": [
"jest.config.js",
"src/**/*.test.ts",
"src/**/*.spec.ts",
"src/**/*.test.tsx",
"src/**/*.spec.tsx",
"src/**/*.test.js",
"src/**/*.spec.js",
"src/**/*.test.jsx",
"src/**/*.spec.jsx",
Comment on lines +12 to +19
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"src/**/*.test.ts",
"src/**/*.spec.ts",
"src/**/*.test.tsx",
"src/**/*.spec.tsx",
"src/**/*.test.js",
"src/**/*.spec.js",
"src/**/*.test.jsx",
"src/**/*.spec.jsx",
"src/**/*.{test,spec}.{ts,tsx,js,jsx}"

"src/**/*.d.ts"
]
}
31 changes: 0 additions & 31 deletions tsconfig.base.json

This file was deleted.

22 changes: 17 additions & 5 deletions tsconfig.common.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,31 @@
{
"compileOnSave": false,
"compilerOptions": {
"rootDir": ".",
"sourceMap": true,
"declaration": true,
"declarationMap": true,
"moduleResolution": "node",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why all these new rules 🤔 ?

Copy link
Collaborator Author

@JohnTParsons JohnTParsons Apr 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are what the command to migrate to nx (npx add-nx-to-monorepo) added

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it might be wise to do some testing on a pre-release to check that these changes haven't had any impact on the built package.

"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"importHelpers": true,
"target": "es5",
"module": "commonjs",
"lib": ["DOM", "ES2019"],
"skipLibCheck": true,
"skipDefaultLibCheck": true,
"baseUrl": ".",
"paths": {
"@newskit/newskit/ui": ["src/index.ts"]
},
"jsx": "react",
"sourceMap": true,
"strict": true,
"strictNullChecks": true,
"moduleResolution": "node",
"esModuleInterop": true,
"preserveSymlinks": true,
"noImplicitAny": true,
"resolveJsonModule": true,
"isolatedModules": true,
"lib": ["DOM", "ES2019"]
}
"isolatedModules": true
},
"exclude": ["node_modules", "tmp"]
}