Skip to content

Commit f46b7e9

Browse files
authored
fix: Optimizations for Turborepo setup (#6662)
1 parent 662aabc commit f46b7e9

File tree

4 files changed

+19
-44
lines changed

4 files changed

+19
-44
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ You can check the items by adding an `x` between the brackets, like this: `[x]`
2626
-->
2727

2828
- [ ] I have read the [Contributing Guidelines](https://github.com/nodejs/nodejs.org/blob/main/CONTRIBUTING.md) and made commit messages that follow the guideline.
29-
- [ ] I have run `npx turbo format` to ensure the code follows the style guide.
30-
- [ ] I have run `npx turbo test` to check if all tests are passing.
29+
- [ ] I have run `npm run format` to ensure the code follows the style guide.
30+
- [ ] I have run `npm run test` to check if all tests are passing.
3131
- [ ] I have run `npx turbo build` to check if the website builds without errors.
3232
- [ ] I've covered new added functionality with unit tests if necessary.

.github/workflows/lint-and-tests.yml

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ jobs:
6060
(github.event_name == 'pull_request_target' &&
6161
github.event.label.name == 'github_actions:pull-request')
6262
63-
name: Lint
63+
name: Quality checks
6464
runs-on: ubuntu-latest
6565
needs: [base]
6666

@@ -116,8 +116,7 @@ jobs:
116116
# We also use `npm i` instead of `npm ci` so that the node_modules/.cache folder doesn't get deleted
117117
run: npm i --no-audit --no-fund --ignore-scripts --userconfig=/dev/null
118118

119-
- name: Run `turbo lint`
120-
id: eslint-step
119+
- name: Run quality checks with `turbo`
121120
# We run the ESLint and Prettier commands on all Workflow triggers of the `Lint` job, besides if
122121
# the Pull Request comes from a Crowdin Branch, as we don't want to run ESLint and Prettier on Crowdin PRs
123122
# Note: Linting and Prettifying of files on Crowdin PRs is handled by the `translations-pr.yml` Workflow
@@ -127,13 +126,7 @@ jobs:
127126
github.event.pull_request.head.ref != 'chore/crowdin')
128127
# We want to enforce that the actual `turbo@latest` package is used instead of a possible hijack from the user
129128
# the `${{ needs.base.outputs.turbo_args }}` is a string substitution happening from the base job
130-
run: npx --package=turbo@latest -- turbo lint ${{ needs.base.outputs.turbo_args }}
131-
132-
- name: Run `turbo prettier`
133-
if: steps.eslint-step.outcome == 'success'
134-
# We want to enforce that the actual `turbo@latest` package is used instead of a possible hijack from the user
135-
# the `${{ needs.base.outputs.turbo_args }}` is a string substitution happening from the base job
136-
run: npx --package=turbo@latest -- turbo prettier ${{ needs.base.outputs.turbo_args }}
129+
run: npx --package=turbo@latest -- turbo lint:js lint:md lint:css prettier ${{ needs.base.outputs.turbo_args }}
137130

138131
- name: Run `tsc build`
139132
# We want to ensure that the whole codebase is passing and successfully compiles with TypeScript

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
"lint:js": "eslint \"**/*.{js,mjs,ts,tsx}\" --cache --cache-strategy=content --cache-location=.eslintjscache",
2424
"lint:md": "eslint \"**/*.md?(x)\" --cache --cache-strategy=content --cache-location=.eslintmdcache",
2525
"lint:css": "stylelint \"**/*.css\" --allow-empty-input --cache --cache-strategy=content --cache-location=.stylelintcache",
26-
"lint": "npm run lint:js && npm run lint:md && npm run lint:css",
27-
"lint:fix": "npm run lint:js -- --fix && npm run lint:md -- --fix && npm run lint:css -- --fix",
26+
"lint": "turbo run lint:md lint:js lint:css",
27+
"lint:fix": "turbo run lint:md lint:js lint:css --no-cache -- --fix",
2828
"prettier": "prettier \"**/*.{js,mjs,ts,tsx,md,mdx,json,yml,css}\" --check --cache --cache-strategy=content --cache-location=.prettiercache",
2929
"prettier:fix": "npm run prettier -- --write",
3030
"format": "npm run lint:fix && npm run prettier:fix",
@@ -33,7 +33,7 @@
3333
"storybook:build": "cross-env NODE_NO_WARNINGS=1 storybook build --quiet --webpack-stats-json",
3434
"test:unit": "cross-env NODE_NO_WARNINGS=1 jest",
3535
"test:unit:watch": "npm run test:unit -- --watch",
36-
"test": "npm run test:unit",
36+
"test": "turbo test:unit",
3737
"prepare": "husky"
3838
},
3939
"dependencies": {

turbo.json

Lines changed: 11 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -83,41 +83,33 @@
8383
]
8484
},
8585
"lint:js": {
86-
"cache": false,
86+
"inputs": [
87+
"{app,components,hooks,i18n,layouts,middlewares,pages,providers,types,util}/**/*.{ts,tsx,mjs}",
88+
"{next-data,scripts,i18n}/**/*.{mjs,json}",
89+
"{.storybook,public}/**/*.{ts,js,json}",
90+
"*.{json,ts,tsx}"
91+
],
8792
"outputs": [".eslintjscache"]
8893
},
8994
"lint:md": {
90-
"cache": false,
95+
"inputs": ["{app,pages}/**/*.{md,mdx}", "*.{md,mdx}"],
9196
"outputs": [".eslintmdcache"]
9297
},
9398
"lint:css": {
94-
"cache": false,
99+
"inputs": ["{app,components,layouts,pages,styles}/**/*.css"],
95100
"outputs": [".stylelintcache"]
96101
},
97-
"lint": {
98-
"cache": false,
99-
"outputs": [".eslintjscache", ".eslintmdcache", ".stylelintcache"]
100-
},
101102
"lint:fix": {
102-
"cache": false,
103-
"outputs": [".eslintjscache", ".eslintmdcache", ".stylelintcache"]
103+
"cache": false
104104
},
105105
"prettier": {
106-
"cache": false,
107106
"outputs": [".prettiercache"]
108107
},
109108
"prettier:fix": {
110-
"cache": false,
111-
"outputs": [".prettiercache"]
109+
"cache": false
112110
},
113111
"format": {
114-
"cache": false,
115-
"outputs": [
116-
".eslintjscache",
117-
".eslintmdcache",
118-
".stylelintcache",
119-
".prettiercache"
120-
]
112+
"cache": false
121113
},
122114
"storybook": {
123115
"cache": false,
@@ -143,16 +135,6 @@
143135
"*.{md,mdx,json,ts,tsx,mjs,yml}"
144136
],
145137
"outputs": ["coverage/**", "junit.xml"]
146-
},
147-
"test": {
148-
"inputs": [
149-
"{app,components,hooks,i18n,layouts,middlewares,pages,providers,types,util}/**/*.{ts,tsx,mjs}",
150-
"{app,components,layouts,pages,styles}/**/*.css",
151-
"{next-data,scripts,i18n}/**/*.{mjs,json}",
152-
"{app,pages}/**/*.{mdx,md}",
153-
"*.{md,mdx,json,ts,tsx,mjs,yml}"
154-
],
155-
"outputs": ["coverage/**", "junit.xml"]
156138
}
157139
}
158140
}

0 commit comments

Comments
 (0)