From 8454f00e1668af98ef8ac9cb21edd47f56433379 Mon Sep 17 00:00:00 2001 From: rikhall1515 Date: Wed, 24 Apr 2024 13:40:24 +0200 Subject: [PATCH] build(turbo): change turbo configuration according to spec This change removes some unnecessary code by running linting tasks in parallel. It also removes unnecessary code from turbo config when caching is turned off. --- .github/PULL_REQUEST_TEMPLATE.md | 58 ++++++++++++++-------------- .github/workflows/lint-and-tests.yml | 8 +--- package.json | 6 +-- turbo.json | 32 +++++---------- 4 files changed, 43 insertions(+), 61 deletions(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index ec062a4..8b72ea0 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,3 +1,32 @@ +## Description + + + +## Validation + + + +## Related Issues + + + +### Check List + + + +- [ ] I have read the [Contributing Guidelines](/CONTRIBUTING.md) and made commit messages that follow the guideline. +- [ ] I have run `npm run format` to ensure the code follows the style guide. +- [ ] I have run `npm run test` to check if all tests are passing. +- [ ] I have run `npx turbo build` to check if the website builds without errors. +- [ ] I've covered new added functionality with unit tests if necessary. + - -## Description - - - -## Validation - - - -## Related Issues - - - -### Check List - - - -- [ ] I have read the [Contributing Guidelines](/CONTRIBUTING.md) and made commit messages that follow the guideline. -- [ ] I have run `npx turbo format` to ensure the code follows the style guide. -- [ ] I have run `npx turbo test` to check if all tests are passing. -- [ ] I have run `npx turbo build` to check if the website builds without errors. -- [ ] I've covered new added functionality with unit tests if necessary. diff --git a/.github/workflows/lint-and-tests.yml b/.github/workflows/lint-and-tests.yml index f693e88..6fa2157 100644 --- a/.github/workflows/lint-and-tests.yml +++ b/.github/workflows/lint-and-tests.yml @@ -125,7 +125,6 @@ jobs: run: CI=true pnpm i --ignore-scripts - name: Run `turbo lint` - id: eslint-step # We run the ESLint and Prettier commands on all Workflow triggers of the `Lint` job # Note: Linting and Prettifying of files on Crowdin PRs is handled by the `translations-pr.yml` Workflow if: | @@ -133,12 +132,7 @@ jobs: (github.event_name == 'pull_request_target') # 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:css prettier ${{ needs.base.outputs.turbo_args}} - name: Run `tsc build` # We want to ensure that the whole codebase is passing and successfully compiles with TypeScript diff --git a/package.json b/package.json index 46d2a13..12989a5 100644 --- a/package.json +++ b/package.json @@ -20,8 +20,8 @@ "start": "cross-env NODE_NO_WARNINGS=1 next start", "lint:js": "eslint \"**/*.{js,mjs,ts,tsx}\" --cache --cache-strategy=content --cache-location=.eslintjscache", "lint:css": "stylelint \"**/*.css\" --allow-empty-input --cache --cache-strategy=content --cache-location=.stylelintcache", - "lint": "pnpm run lint:js && pnpm run lint:css", - "lint:fix": "pnpm run lint:js --fix && pnpm run lint:css --fix", + "lint": "turbo run lint:js lint:css", + "lint:fix": "turbo run lint:js lint:css --no-cache -- --fix", "prettier": "prettier \"**/*.{js,mjs,ts,tsx,md,mdx,json,yml,css}\" --check --cache --cache-strategy=content --cache-location=.prettiercache", "prettier:fix": "pnpm run prettier --write", "format": "pnpm run lint:fix && pnpm run prettier:fix", @@ -29,7 +29,7 @@ "storybook:build": "cross-env NODE_NO_WARNINGS=1 storybook build --quiet --webpack-stats-json", "test:unit": "cross-env NODE_NO_WARNINGS=1 jest", "test:unit:watch": "pnpm run test:unit --watch", - "test": "pnpm run test:unit", + "test": "turbo test:unit", "prepare": "husky", "cm": "cz", "check-types": "tsc --noEmit --pretty" diff --git a/turbo.json b/turbo.json index 41dcaa2..74ebd45 100644 --- a/turbo.json +++ b/turbo.json @@ -49,32 +49,29 @@ ] }, "lint:js": { - "cache": false, + "inputs": [ + "{app,components,hooks,actions,db,env,layouts,middlewares,context,types,lib}/**/*.{ts,tsx,mjs}", + "{next-data,scripts,i18n}/**/*.{mjs,json}", + "{.storybook,public}/**/*.{ts,js,json}", + "*.{json,ts,tsx}" + ], "outputs": [".eslintjscache"] }, "lint:css": { - "cache": false, + "inputs": ["{app,components,layouts,styles}/**/*.css"], "outputs": [".stylelintcache"] }, - "lint": { - "cache": false, - "outputs": [".eslintjscache", ".stylelintcache"] - }, "lint:fix": { - "cache": false, - "outputs": [".eslintjscache", ".stylelintcache"] + "cache": false }, "prettier": { - "cache": false, "outputs": [".prettiercache"] }, "prettier:fix": { - "cache": false, - "outputs": [".prettiercache"] + "cache": false }, "format": { - "cache": false, - "outputs": [".eslintjscache", ".stylelintcache", ".prettiercache"] + "cache": false }, "storybook": { "cache": false, @@ -98,15 +95,6 @@ "*.{md,mdx,json,ts,tsx,mjs,yml}" ], "outputs": ["coverage/**", "junit.xml"] - }, - "test": { - "inputs": [ - "{app,components,hooks,lib,context,types}/**/*.{ts,tsx,mjs}", - "{app,components,styles}/**/*.css", - "{next-data,scripts,i18n}/**/*.{mjs,json}", - "*.{md,mdx,json,ts,tsx,mjs,yml}" - ], - "outputs": ["coverage/**", "junit.xml"] } } }