Skip to content

chore: add nx monorepo tooling #3465

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

Merged
merged 9 commits into from
Jun 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
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
69 changes: 27 additions & 42 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ on:
push:
branches:
- master
# TODO - delete this before merging v4 into master
- v4
pull_request:
branches:
- '**'

env:
PRIMARY_NODE_VERSION: 12
NX_BRANCH: ${{ github.event.number }}
NX_RUN_GROUP: ${{ github.run_id }}

jobs:
typecheck:
Expand Down Expand Up @@ -43,7 +43,7 @@ jobs:
- name: Install dependencies
run: |
yarn --ignore-engines --frozen-lockfile --ignore-scripts
yarn check:clean-workspace-after-install
yarn check-clean-workspace-after-install

- name: Build
run: |
Expand Down Expand Up @@ -85,57 +85,49 @@ jobs:
- name: Install dependencies
run: |
yarn --ignore-engines --frozen-lockfile --ignore-scripts
yarn check:clean-workspace-after-install
yarn check-clean-workspace-after-install

- name: Build
run: |
yarn build

- name: Run unit tests for typescript-estree
run: yarn test
working-directory: packages/typescript-estree
run: npx nx test @typescript-eslint/typescript-estree
env:
CI: true

- name: Run unit tests for visitor-keys
run: yarn test
working-directory: packages/visitor-keys
run: npx nx test @typescript-eslint/visitor-keys
env:
CI: true

- name: Run unit tests for scope-manager
run: yarn test
working-directory: packages/scope-manager
run: npx nx test @typescript-eslint/scope-manager
env:
CI: true

- name: Run unit tests for experimental-utils
run: yarn test
working-directory: packages/experimental-utils
run: npx nx test @typescript-eslint/experimental-utils
env:
CI: true

- name: Run unit tests for parser
run: yarn test
working-directory: packages/parser
run: npx nx test @typescript-eslint/parser
env:
CI: true

- name: Run unit tests for eslint-plugin
run: yarn test
working-directory: packages/eslint-plugin
run: npx nx test @typescript-eslint/eslint-plugin
env:
CI: true

- name: Run unit tests for eslint-plugin-tslint
run: yarn test
working-directory: packages/eslint-plugin-tslint
run: npx nx test @typescript-eslint/eslint-plugin-tslint
env:
CI: true

- name: Run unit tests for eslint-plugin-internal
run: yarn test
working-directory: packages/eslint-plugin-internal
run: npx nx test @typescript-eslint/eslint-plugin-internal
env:
CI: true

Expand Down Expand Up @@ -171,23 +163,23 @@ jobs:
- name: Install dependencies
run: |
yarn --ignore-engines --frozen-lockfile --ignore-scripts
yarn check:clean-workspace-after-install
yarn check-clean-workspace-after-install

- name: Build
run: |
yarn build

- name: Check code formatting
run: yarn check:format
run: yarn check-format

- name: Lint code
run: yarn lint

- name: Lint markdown
run: yarn lint:markdown
run: yarn lint-markdown

- name: Check spelling
run: yarn check:spelling
run: yarn check-spelling

integration_tests:
name: Run integration tests on primary Node.js version
Expand All @@ -214,14 +206,14 @@ jobs:
- name: Install dependencies
run: |
yarn --ignore-engines --frozen-lockfile --ignore-scripts
yarn check:clean-workspace-after-install
yarn check-clean-workspace-after-install

- name: Build
run: |
yarn build

- name: Run integrations tests
run: yarn test:integration
run: yarn test-integration
env:
CI: true

Expand Down Expand Up @@ -253,51 +245,44 @@ jobs:
- name: Install dependencies
run: |
yarn --ignore-engines --frozen-lockfile --ignore-scripts
yarn check:clean-workspace-after-install
yarn check-clean-workspace-after-install

- name: Build
run: |
yarn build

- name: Run unit tests for typescript-estree
run: yarn test
working-directory: packages/typescript-estree
run: npx nx test @typescript-eslint/typescript-estree
env:
CI: true

- name: Run unit tests for visitor-keys
run: yarn test
working-directory: packages/visitor-keys
run: npx nx test @typescript-eslint/visitor-keys
env:
CI: true

- name: Run unit tests for scope-manager
run: yarn test
working-directory: packages/scope-manager
run: npx nx test @typescript-eslint/scope-manager
env:
CI: true

- name: Run unit tests for experimental-utils
run: yarn test
working-directory: packages/experimental-utils
run: npx nx test @typescript-eslint/experimental-utils
env:
CI: true

- name: Run unit tests for parser
run: yarn test
working-directory: packages/parser
run: npx nx test @typescript-eslint/parser
env:
CI: true

- name: Run unit tests for eslint-plugin
run: yarn test
working-directory: packages/eslint-plugin
run: npx nx test @typescript-eslint/eslint-plugin
env:
CI: true

- name: Run unit tests for eslint-plugin-tslint
run: yarn test
working-directory: packages/eslint-plugin-tslint
run: npx nx test @typescript-eslint/eslint-plugin-tslint
env:
CI: true

Expand Down Expand Up @@ -335,7 +320,7 @@ jobs:
- name: Install dependencies
run: |
yarn --ignore-engines --frozen-lockfile --ignore-scripts
yarn check:clean-workspace-after-install
yarn check-clean-workspace-after-install

- name: Build
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/generate-contributors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
yarn --ignore-engines --frozen-lockfile --ignore-scripts

- name: Generate contributors
run: yarn generate:contributors
run: yarn generate-contributors

- name: Create Pull Request
uses: peter-evans/create-pull-request@v3
Expand Down
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ We have a sophisticated CI process setup which gets run on every PR. You must pa
- Coverage reports should automatically be generated locally, and the `codecov` bot should also comment on your PR with the percentage, as well as links to the line-by-line coverage of each file touched by your PR.
- Ensure you have no lint errors.
- You can run `yarn lint` in any package or in the root.
- You can run `yarn lint:markdown` in the root.
- You can run `yarn lint-markdown` in the root.
- If you have made changes to any markdown documentation, ensure there are no spelling errors
- You can run `yarn check:spelling` in the root.
- You can run `yarn check-spelling` in the root.
- Or if you are using vscode, you can use [`Code Spell Checker`](https://marketplace.visualstudio.com/items?itemName=streetsidesoftware.code-spell-checker) plugin.
- If you have made changes within the `eslint-plugin` package, ensure the configs and documentation are valid.
- You can run `yarn check:configs` and `yarn check:docs` in the root, or in the `eslint-plugin` folder.
- You can run `yarn check-configs` and `yarn check-docs` in the root, or in the `eslint-plugin` folder.

### Raising a PR

Expand Down
66 changes: 66 additions & 0 deletions nx.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{
"npmScope": "typescript-eslint",
"implicitDependencies": {
"workspace.json": "*",
"package.json": {
"dependencies": "*",
"devDependencies": "*"
},
"nx.json": "*",
".github/workflows/ci.yml": "*"
},
"workspaceLayout": {
"libsDir": "packages"
},
"tasksRunnerOptions": {
"default": {
"runner": "@nrwl/nx-cloud",
"options": {
"cacheableOperations": ["build", "test", "package", "prepare"],
"strictlyOrderedTargets": ["build", "package", "prepare"],
"accessToken": "YjFjNTBhOWUtY2JmNy00ZDhiLWE5N2UtZjliNDAwNmIzOTdjfHJlYWQtd3JpdGU=",
"canTrackAnalytics": false,
"showUsageWarnings": true,
"runtimeCacheInputs": ["node -v"]
}
}
},
"projects": {
"@typescript-eslint/ast-spec": {
"implicitDependencies": []
},
"@typescript-eslint/eslint-plugin": {
"implicitDependencies": []
},
"@typescript-eslint/eslint-plugin-internal": {
"implicitDependencies": []
},
"@typescript-eslint/eslint-plugin-tslint": {
"implicitDependencies": []
},
"@typescript-eslint/experimental-utils": {
"implicitDependencies": []
},
"@typescript-eslint/parser": {
"implicitDependencies": []
},
"@typescript-eslint/scope-manager": {
"implicitDependencies": []
},
"@typescript-eslint/shared-fixtures": {
"implicitDependencies": []
},
"@typescript-eslint/types": {
"implicitDependencies": ["@typescript-eslint/ast-spec"]
},
"@typescript-eslint/typescript-estree": {
"implicitDependencies": []
},
"@typescript-eslint/visitor-keys": {
"implicitDependencies": []
}
},
"affected": {
"defaultBase": "master"
}
}
34 changes: 19 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,27 @@
"url": "https://github.com/typescript-eslint/typescript-eslint/issues"
},
"scripts": {
"build": "lerna run build --ignore ast-spec",
"check:clean-workspace-after-install": "git diff --quiet --exit-code",
"check:configs": "lerna run check:configs",
"check:docs": "lerna run check:docs",
"check:format": "prettier --list-different \"./**/*.{ts,js,json,md}\"",
"check:spelling": "cspell --config=.cspell.json \"**/*.{md,ts,js}\"",
"build": "npx nx prebuild @typescript-eslint/types && nx run-many --target=build --all --parallel",
Copy link
Member Author

Choose a reason for hiding this comment

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

For now, we need to include an explicit reference to the prebuild script of @typescript-eslint/types because it is unusual in that it has a side-effect on disk outside of dist/ or build/ (the common output locations Nx checks for) and it therefore does not play well with the automated caching behavior based on simplistic npm scripts (it would be configurable if we moved to full Nx targets in workspace.json).

Feel free to ping me on slack if you want to cover this in more detail and I can walk you through where this is today vs how it can be configured

"check-clean-workspace-after-install": "git diff --quiet --exit-code",
"check-configs": "nx run-many --target=check-configs --all --parallel",
"check-docs": "nx run-many --target=check-docs --all --parallel",
"check-format": "prettier --list-different \"./**/*.{ts,js,json,md}\"",
"check-spelling": "cspell --config=.cspell.json \"**/*.{md,ts,js}\"",
"clean": "lerna clean && lerna run clean",
"cz": "git-cz",
"format": "prettier --write \"./**/*.{ts,js,json,md}\"",
"generate:contributors": "yarn ts-node --transpile-only ./tools/generate-contributors.ts && yarn all-contributors generate",
"lint:fix": "eslint . --ext .js,.ts --fix",
"lint:markdown:fix": "yarn lint:markdown --fix",
"lint:markdown": "markdownlint \"**/*.md\" --config=.markdownlint.json --ignore-path=.markdownlintignore",
"generate-contributors": "yarn ts-node --transpile-only ./tools/generate-contributors.ts && yarn all-contributors generate",
"lint-fix": "eslint . --ext .js,.ts --fix",
"lint-markdown-fix": "yarn lint-markdown --fix",
"lint-markdown": "markdownlint \"**/*.md\" --config=.markdownlint.json --ignore-path=.markdownlintignore",
"lint": "eslint . --ext .js,.ts",
"postinstall": "yarn husky install && yarn build",
"pre-commit": "yarn lint-staged",
"pre-push": "yarn check:format",
"test": "lerna run test --concurrency 1",
"test:integration": "./tests/integration/run-all-tests.sh",
"test:kill-integration-containers": "docker-compose -f tests/integration/docker-compose.yml down -v --rmi local",
"typecheck": "lerna run typecheck"
"pre-push": "yarn check-format",
"test": "nx run-many --target=test --all --parallel",
"test-integration": "./tests/integration/run-all-tests.sh",
"test-kill-integration-containers": "docker-compose -f tests/integration/docker-compose.yml down -v --rmi local",
"typecheck": "nx run-many --target=typecheck --all --parallel"
},
"config": {
"commitizen": {
Expand Down Expand Up @@ -77,6 +77,10 @@
"@commitlint/cli": "^12.1.4",
"@commitlint/config-conventional": "^12.1.4",
"@commitlint/config-lerna-scopes": "^12.1.4",
"@nrwl/cli": "^12.3.5",
"@nrwl/nx-cloud": "^12.1.3",
"@nrwl/tao": "^12.3.5",
"@nrwl/workspace": "^12.3.5",
"@types/babel__code-frame": "^7.0.2",
"@types/debug": "^4.1.5",
"@types/eslint-visitor-keys": "^1.0.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/eslint-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
"types": "index.d.ts",
"scripts": {
"build": "tsc -b tsconfig.build.json",
"check:docs": "jest tests/docs.test.ts --runTestsByPath --silent --runInBand",
"check:configs": "jest tests/configs.test.ts --runTestsByPath --silent --runInBand",
"check-docs": "jest tests/docs.test.ts --runTestsByPath --silent --runInBand",
"check-configs": "jest tests/configs.test.ts --runTestsByPath --silent --runInBand",
"clean": "tsc -b tsconfig.build.json --clean",
"postclean": "rimraf dist && rimraf coverage",
"format": "prettier --write \"./**/*.{ts,js,json,md}\" --ignore-path ../../.prettierignore",
Expand Down
Loading