Skip to content

Commit f5ef2aa

Browse files
committed
A few optimizations for Turborepo setup.
1 parent 62274cb commit f5ef2aa

3 files changed

Lines changed: 14 additions & 27 deletions

File tree

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

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -32,23 +32,13 @@ jobs:
3232
base:
3333
name: Base Tasks
3434
runs-on: ubuntu-latest
35-
outputs:
36-
turbo_args: ${{ steps.turborepo_arguments.outputs.turbo_args }}
3735

3836
steps:
3937
- name: Harden Runner
4038
uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0
4139
with:
4240
egress-policy: audit
4341

44-
- name: Provide Turborepo Arguments
45-
# This step is responsible for providing a reusable string that can be used within other steps and jobs
46-
# that use the `turbo` cli command as a way of easily providing shared arguments to the `turbo` command
47-
id: turborepo_arguments
48-
# See https://turbo.build/repo/docs/reference/command-line-reference/run#--cache-dir
49-
# See https://turbo.build/repo/docs/reference/command-line-reference/run#--force
50-
run: echo "turbo_args=--force=true --cache-dir=.turbo/cache" >> "$GITHUB_OUTPUT"
51-
5242
lint:
5343
# This Job should run either on `merge_groups` or `push` events
5444
# or `pull_request_target` event with a `labeled` action with a label named `github_actions:pull-request`
@@ -60,7 +50,7 @@ jobs:
6050
(github.event_name == 'pull_request_target' &&
6151
github.event.label.name == 'github_actions:pull-request')
6252
63-
name: Lint
53+
name: Quality checks
6454
runs-on: ubuntu-latest
6555
needs: [base]
6656

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

119-
- name: Run `turbo lint`
120-
id: eslint-step
109+
- name: Run quality checks with `turbo`
110+
id: quality-checks
121111
# We run the ESLint and Prettier commands on all Workflow triggers of the `Lint` job, besides if
122112
# the Pull Request comes from a Crowdin Branch, as we don't want to run ESLint and Prettier on Crowdin PRs
123113
# Note: Linting and Prettifying of files on Crowdin PRs is handled by the `translations-pr.yml` Workflow
@@ -127,13 +117,7 @@ jobs:
127117
github.event.pull_request.head.ref != 'chore/crowdin')
128118
# We want to enforce that the actual `turbo@latest` package is used instead of a possible hijack from the user
129119
# 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 }}
120+
run: npx --package=turbo@latest -- turbo lint:js lint:md lint:css prettier test:unit:ci --cache-dir=.turbo/cache
137121

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

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
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",
26+
"lint": "turbo run lint:md lint:js lint:css",
2727
"lint:fix": "npm run lint:js -- --fix && npm run lint:md -- --fix && npm run lint:css -- --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",
@@ -33,7 +33,6 @@
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",
3736
"prepare": "husky"
3837
},
3938
"dependencies": {

turbo.json

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,27 +83,31 @@
8383
]
8484
},
8585
"lint:js": {
86-
"cache": false,
86+
"inputs": [
87+
"!styles/**/*.css",
88+
"!components/**/*.css",
89+
"!layouts/**/*.css",
90+
"!*.md",
91+
"!pages/**/*.{md,mdx}"
92+
],
8793
"outputs": [".eslintjscache"]
8894
},
8995
"lint:md": {
90-
"cache": false,
96+
"inputs": ["*.md", "pages/**/*.{md,mdx}"],
9197
"outputs": [".eslintmdcache"]
9298
},
9399
"lint:css": {
94-
"cache": false,
100+
"inputs": ["styles/**/*.css", "components/**/*.css", "layouts/**/*.css"],
95101
"outputs": [".stylelintcache"]
96102
},
97103
"lint": {
98-
"cache": false,
99104
"outputs": [".eslintjscache", ".eslintmdcache", ".stylelintcache"]
100105
},
101106
"lint:fix": {
102107
"cache": false,
103108
"outputs": [".eslintjscache", ".eslintmdcache", ".stylelintcache"]
104109
},
105110
"prettier": {
106-
"cache": false,
107111
"outputs": [".prettiercache"]
108112
},
109113
"prettier:fix": {

0 commit comments

Comments
 (0)