Skip to content

Commit

Permalink
chore: add nx monorepo tooling (#3465)
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesHenry committed Jun 9, 2021
1 parent 33b9f69 commit ced9b26
Show file tree
Hide file tree
Showing 8 changed files with 550 additions and 98 deletions.
69 changes: 27 additions & 42 deletions .github/workflows/ci.yml
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
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
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
@@ -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
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",
"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
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

0 comments on commit ced9b26

Please sign in to comment.