-
Notifications
You must be signed in to change notification settings - Fork 6.5k
fix: Optimizations for Turborepo setup #6662
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -60,7 +60,7 @@ jobs: | |
| (github.event_name == 'pull_request_target' && | ||
| github.event.label.name == 'github_actions:pull-request') | ||
|
|
||
| name: Lint | ||
| name: Quality checks | ||
| runs-on: ubuntu-latest | ||
| needs: [base] | ||
|
|
||
|
|
@@ -116,8 +116,7 @@ jobs: | |
| # We also use `npm i` instead of `npm ci` so that the node_modules/.cache folder doesn't get deleted | ||
| run: npm i --no-audit --no-fund --ignore-scripts --userconfig=/dev/null | ||
|
|
||
| - name: Run `turbo lint` | ||
| id: eslint-step | ||
| - name: Run quality checks with `turbo` | ||
| # We run the ESLint and Prettier commands on all Workflow triggers of the `Lint` job, besides if | ||
| # the Pull Request comes from a Crowdin Branch, as we don't want to run ESLint and Prettier on Crowdin PRs | ||
| # Note: Linting and Prettifying of files on Crowdin PRs is handled by the `translations-pr.yml` Workflow | ||
|
|
@@ -127,13 +126,7 @@ jobs: | |
| github.event.pull_request.head.ref != 'chore/crowdin') | ||
| # We want to enforce that the actual `turbo@latest` package is used instead of a possible hijack from the user | ||
| # the `${{ needs.base.outputs.turbo_args }}` is a string substitution happening from the base job | ||
| run: npx --package=turbo@latest -- turbo lint ${{ needs.base.outputs.turbo_args }} | ||
|
|
||
| - name: Run `turbo prettier` | ||
| if: steps.eslint-step.outcome == 'success' | ||
| # We want to enforce that the actual `turbo@latest` package is used instead of a possible hijack from the user | ||
| # the `${{ needs.base.outputs.turbo_args }}` is a string substitution happening from the base job | ||
| run: npx --package=turbo@latest -- turbo prettier ${{ needs.base.outputs.turbo_args }} | ||
| run: npx --package=turbo@latest -- turbo lint:js lint:md lint:css prettier ${{ needs.base.outputs.turbo_args } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. isn't it dangerous to use the latest version? what if breaking changes are made? we should use the version our website use
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I also wondered about this but wasn't going to take the liberty to question it, especially given that the comment right above describes the motivation. I figured a core team member consciously made this choice, carefully considering the tradeoffs - and that I'm not thinking about it deeply enough to understand the hijacking surface being described. I'd be interested in learning more!
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I missed that comment 😅
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right, I believe we could use commit pinning here; Bug the idea behind is, I might be wrong, that NPM checks what is the latest version on the registry, and then compares what the latest locally version is installed, so it complicates even if a tiny bit more, that the attacker must match both versions if they want to poison a GitHub Action cache.
ovflowd marked this conversation as resolved.
Outdated
|
||
|
|
||
| - name: Run `tsc build` | ||
| # We want to ensure that the whole codebase is passing and successfully compiles with TypeScript | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -83,41 +83,33 @@ | |
| ] | ||
| }, | ||
| "lint:js": { | ||
| "cache": false, | ||
| "inputs": [ | ||
| "{app,components,hooks,i18n,layouts,middlewares,pages,providers,types,util}/**/*.{ts,tsx,mjs}", | ||
| "{next-data,scripts,i18n}/**/*.{mjs,json}", | ||
| "{.storybook,public}/**/*.{ts,js,json}", | ||
| "*.{json,ts,tsx}" | ||
| ], | ||
| "outputs": [".eslintjscache"] | ||
| }, | ||
| "lint:md": { | ||
| "cache": false, | ||
| "inputs": ["{app,pages}/**/*.{md,mdx}", "*.{md,mdx}"], | ||
| "outputs": [".eslintmdcache"] | ||
| }, | ||
| "lint:css": { | ||
| "cache": false, | ||
| "inputs": ["{app,components,layouts,pages,styles}/**/*.css"], | ||
| "outputs": [".stylelintcache"] | ||
| }, | ||
| "lint": { | ||
| "cache": false, | ||
| "outputs": [".eslintjscache", ".eslintmdcache", ".stylelintcache"] | ||
| }, | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't end up needing this task because we can use the other linting tasks in parallel instead. An example of this can be found in the |
||
| "lint:fix": { | ||
| "cache": false, | ||
| "outputs": [".eslintjscache", ".eslintmdcache", ".stylelintcache"] | ||
| "cache": false | ||
| }, | ||
| "prettier": { | ||
| "cache": false, | ||
| "outputs": [".prettiercache"] | ||
| }, | ||
| "prettier:fix": { | ||
| "cache": false, | ||
| "outputs": [".prettiercache"] | ||
| "cache": false | ||
| }, | ||
| "format": { | ||
| "cache": false, | ||
| "outputs": [ | ||
| ".eslintjscache", | ||
| ".eslintmdcache", | ||
| ".stylelintcache", | ||
| ".prettiercache" | ||
| ] | ||
| "cache": false | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any time |
||
| }, | ||
| "storybook": { | ||
| "cache": false, | ||
|
|
@@ -143,16 +135,6 @@ | |
| "*.{md,mdx,json,ts,tsx,mjs,yml}" | ||
| ], | ||
| "outputs": ["coverage/**", "junit.xml"] | ||
| }, | ||
| "test": { | ||
| "inputs": [ | ||
| "{app,components,hooks,i18n,layouts,middlewares,pages,providers,types,util}/**/*.{ts,tsx,mjs}", | ||
| "{app,components,layouts,pages,styles}/**/*.css", | ||
| "{next-data,scripts,i18n}/**/*.{mjs,json}", | ||
| "{app,pages}/**/*.{mdx,md}", | ||
| "*.{md,mdx,json,ts,tsx,mjs,yml}" | ||
| ], | ||
| "outputs": ["coverage/**", "junit.xml"] | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This appears to be a duplicate of the |
||
| } | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These tasks can all be made to run in parallel, saving some time.