chore: optimize turborepo (#8286)

This commit is contained in:
Aaron 2025-12-10 18:35:14 +07:00 committed by GitHub
parent 20510bb2dd
commit ff544c98b7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 235 additions and 68 deletions

View file

@ -27,11 +27,13 @@ jobs:
github.event.pull_request.draft == false && github.event.pull_request.draft == false &&
github.event.pull_request.requested_reviewers != null github.event.pull_request.requested_reviewers != null
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v6
- name: Set up Python - name: Set up Python
uses: actions/setup-python@v5 uses: actions/setup-python@v6
with: with:
python-version: "3.12.x" python-version: "3.12.x"
cache: 'pip'
cache-dependency-path: 'apps/api/requirements.txt'
- name: Install Pylint - name: Install Pylint
run: python -m pip install ruff run: python -m pip install ruff
- name: Install API Dependencies - name: Install API Dependencies

View file

@ -17,10 +17,11 @@ concurrency:
cancel-in-progress: true cancel-in-progress: true
jobs: jobs:
build-and-lint: # Format check has no build dependencies - run immediately in parallel
name: Build and lint web apps check-format:
name: check:format
runs-on: ubuntu-latest runs-on: ubuntu-latest
timeout-minutes: 25 timeout-minutes: 10
if: | if: |
github.event.pull_request.draft == false && github.event.pull_request.draft == false &&
github.event.pull_request.requested_reviewers != null github.event.pull_request.requested_reviewers != null
@ -29,28 +30,140 @@ jobs:
TURBO_SCM_HEAD: ${{ github.sha }} TURBO_SCM_HEAD: ${{ github.sha }}
steps: steps:
- name: Checkout code - name: Checkout code
uses: actions/checkout@v4 uses: actions/checkout@v6
with: with:
fetch-depth: 50 fetch-depth: 50
filter: blob:none filter: blob:none
- name: Set up Node.js - name: Set up Node.js
uses: actions/setup-node@v4 uses: actions/setup-node@v6
- name: Enable Corepack and pnpm - name: Enable Corepack and pnpm
run: corepack enable pnpm run: corepack enable pnpm
- name: Get pnpm store directory
shell: bash
run: echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- name: Cache pnpm store
uses: actions/cache@v4
with:
path: ${{ env.STORE_PATH }}
key: pnpm-store-${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
pnpm-store-${{ runner.os }}-
- name: Install dependencies - name: Install dependencies
run: pnpm install --frozen-lockfile run: pnpm install --frozen-lockfile
- name: Build Affected - name: Check formatting
run: pnpm turbo run build --affected
- name: Lint Affected
run: pnpm turbo run check:lint --affected
- name: Check Affected format
run: pnpm turbo run check:format --affected run: pnpm turbo run check:format --affected
- name: Check Affected types # Build packages - required for lint and type checks
run: pnpm turbo run check:types --affected build:
name: Build packages
runs-on: ubuntu-latest
timeout-minutes: 15
if: |
github.event.pull_request.draft == false &&
github.event.pull_request.requested_reviewers != null
env:
TURBO_SCM_BASE: ${{ github.event.pull_request.base.sha }}
TURBO_SCM_HEAD: ${{ github.sha }}
NODE_OPTIONS: "--max-old-space-size=4096"
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 50
filter: blob:none
- name: Set up Node.js
uses: actions/setup-node@v6
- name: Enable Corepack and pnpm
run: corepack enable pnpm
- name: Get pnpm store directory
shell: bash
run: echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- name: Cache pnpm store
uses: actions/cache@v4
with:
path: ${{ env.STORE_PATH }}
key: pnpm-store-${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
pnpm-store-${{ runner.os }}-
- name: Restore Turbo cache
uses: actions/cache/restore@v4
with:
path: .turbo
key: turbo-${{ runner.os }}-${{ github.event.pull_request.base.sha }}-${{ github.sha }}
restore-keys: |
turbo-${{ runner.os }}-${{ github.event.pull_request.base.sha }}-
turbo-${{ runner.os }}-
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build packages
run: pnpm turbo run build --affected
- name: Save Turbo cache
uses: actions/cache/save@v4
with:
path: .turbo
key: turbo-${{ runner.os }}-${{ github.event.pull_request.base.sha }}-${{ github.sha }}
# Lint and type checks depend on build artifacts
check:
name: ${{ matrix.task }}
runs-on: ubuntu-latest
needs: build
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
task: [check:lint, check:types]
env:
TURBO_SCM_BASE: ${{ github.event.pull_request.base.sha }}
TURBO_SCM_HEAD: ${{ github.sha }}
NODE_OPTIONS: "--max-old-space-size=4096"
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 50
filter: blob:none
- name: Set up Node.js
uses: actions/setup-node@v6
- name: Enable Corepack and pnpm
run: corepack enable pnpm
- name: Get pnpm store directory
shell: bash
run: echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- name: Cache pnpm store
uses: actions/cache@v4
with:
path: ${{ env.STORE_PATH }}
key: pnpm-store-${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
pnpm-store-${{ runner.os }}-
- name: Restore Turbo cache
uses: actions/cache/restore@v4
with:
path: .turbo
key: turbo-${{ runner.os }}-${{ github.event.pull_request.base.sha }}-${{ github.sha }}
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Run ${{ matrix.task }}
run: pnpm turbo run ${{ matrix.task }} --affected

View file

@ -10,6 +10,7 @@ import promisePlugin from "eslint-plugin-promise";
import reactPlugin from "eslint-plugin-react"; import reactPlugin from "eslint-plugin-react";
import reactHooksPlugin from "eslint-plugin-react-hooks"; import reactHooksPlugin from "eslint-plugin-react-hooks";
import reactRefreshPlugin from "eslint-plugin-react-refresh"; import reactRefreshPlugin from "eslint-plugin-react-refresh";
import turboPlugin from "eslint-plugin-turbo";
import vitestPlugin from "@vitest/eslint-plugin"; import vitestPlugin from "@vitest/eslint-plugin";
// import storybookPlugin from "eslint-plugin-storybook"; // import storybookPlugin from "eslint-plugin-storybook";
@ -42,6 +43,7 @@ export default defineConfig([
jsxA11yPlugin.flatConfigs.recommended, jsxA11yPlugin.flatConfigs.recommended,
reactRefreshPlugin.configs.recommended, reactRefreshPlugin.configs.recommended,
reactRefreshPlugin.configs.vite, reactRefreshPlugin.configs.vite,
turboPlugin.configs["flat/recommended"],
tseslint.configs.recommendedTypeChecked, tseslint.configs.recommendedTypeChecked,
vitestPlugin.configs.recommended, vitestPlugin.configs.recommended,
// TODO: enable storybook linting once issues are resolved // TODO: enable storybook linting once issues are resolved

View file

@ -35,6 +35,7 @@
"eslint-plugin-react-hooks": "7.0.1", "eslint-plugin-react-hooks": "7.0.1",
"eslint-plugin-react-refresh": "0.4.24", "eslint-plugin-react-refresh": "0.4.24",
"eslint-plugin-storybook": "10.1.4", "eslint-plugin-storybook": "10.1.4",
"eslint-plugin-turbo": "2.6.3",
"globals": "16.5.0", "globals": "16.5.0",
"husky": "9.1.7", "husky": "9.1.7",
"lint-staged": "16.2.7", "lint-staged": "16.2.7",

View file

@ -4,9 +4,20 @@
"license": "AGPL-3.0", "license": "AGPL-3.0",
"description": "Shared state shared across multiple apps internally", "description": "Shared state shared across multiple apps internally",
"private": true, "private": true,
"main": "./src/index.ts", "type": "module",
"types": "./src/index.ts", "main": "./dist/index.js",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js"
},
"./package.json": "./package.json"
},
"scripts": { "scripts": {
"build": "tsdown",
"dev": "tsdown --watch",
"check:lint": "eslint . --max-warnings=191", "check:lint": "eslint . --max-warnings=191",
"check:types": "tsc --noEmit", "check:types": "tsc --noEmit",
"check:format": "prettier --check .", "check:format": "prettier --check .",
@ -28,6 +39,7 @@
"@plane/typescript-config": "workspace:*", "@plane/typescript-config": "workspace:*",
"@types/lodash-es": "catalog:", "@types/lodash-es": "catalog:",
"@types/node": "catalog:", "@types/node": "catalog:",
"tsdown": "catalog:",
"typescript": "catalog:" "typescript": "catalog:"
} }
} }

View file

@ -0,0 +1,8 @@
import { defineConfig } from "tsdown";
export default defineConfig({
entry: ["src/index.ts"],
format: ["esm"],
dts: true,
platform: "neutral",
});

31
pnpm-lock.yaml generated
View file

@ -166,6 +166,9 @@ importers:
eslint-plugin-storybook: eslint-plugin-storybook:
specifier: 10.1.4 specifier: 10.1.4
version: 10.1.4(eslint@9.39.1(jiti@2.6.1))(storybook@9.1.10(@testing-library/dom@10.4.0)(prettier@3.7.4)(vite@7.1.11(@types/node@22.12.0)(jiti@2.6.1)(terser@5.44.1)(yaml@2.8.2)))(typescript@5.8.3) version: 10.1.4(eslint@9.39.1(jiti@2.6.1))(storybook@9.1.10(@testing-library/dom@10.4.0)(prettier@3.7.4)(vite@7.1.11(@types/node@22.12.0)(jiti@2.6.1)(terser@5.44.1)(yaml@2.8.2)))(typescript@5.8.3)
eslint-plugin-turbo:
specifier: 2.6.3
version: 2.6.3(eslint@9.39.1(jiti@2.6.1))(turbo@2.6.3)
globals: globals:
specifier: 16.5.0 specifier: 16.5.0
version: 16.5.0 version: 16.5.0
@ -1231,6 +1234,9 @@ importers:
'@types/node': '@types/node':
specifier: 'catalog:' specifier: 'catalog:'
version: 22.12.0 version: 22.12.0
tsdown:
specifier: 'catalog:'
version: 0.16.0(typescript@5.8.3)
typescript: typescript:
specifier: 5.8.3 specifier: 5.8.3
version: 5.8.3 version: 5.8.3
@ -4865,9 +4871,6 @@ packages:
resolution: {integrity: sha512-xlx1yCK2Oc1APsPXDL2LdlNP6+uu8OCDdhOBSVT279M/S+y75O30C2VuD8T2ogdePBBl7PfPF4504tnLgX3zfw==} resolution: {integrity: sha512-xlx1yCK2Oc1APsPXDL2LdlNP6+uu8OCDdhOBSVT279M/S+y75O30C2VuD8T2ogdePBBl7PfPF4504tnLgX3zfw==}
engines: {node: '>=14.16'} engines: {node: '>=14.16'}
caniuse-lite@1.0.30001756:
resolution: {integrity: sha512-4HnCNKbMLkLdhJz3TToeVWHSnfJvPaq6vu/eRP0Ahub/07n484XHhBF5AJoSGHdVrS8tKFauUQz8Bp9P7LVx7A==}
caniuse-lite@1.0.30001759: caniuse-lite@1.0.30001759:
resolution: {integrity: sha512-Pzfx9fOKoKvevQf8oCXoyNRQ5QyxJj+3O0Rqx2V5oxT61KGx8+n6hV/IUyJeifUci2clnmmKVpvtiqRzgiWjSw==} resolution: {integrity: sha512-Pzfx9fOKoKvevQf8oCXoyNRQ5QyxJj+3O0Rqx2V5oxT61KGx8+n6hV/IUyJeifUci2clnmmKVpvtiqRzgiWjSw==}
@ -5431,6 +5434,10 @@ packages:
dot-case@3.0.4: dot-case@3.0.4:
resolution: {integrity: sha512-Kv5nKlh6yRrdrGvxeJ2e5y2eRUpkUosIW4A2AS38zwSz27zu7ufDwQPi5Jhs3XAlGNetl3bmnGhQsMtkKJnj3w==} resolution: {integrity: sha512-Kv5nKlh6yRrdrGvxeJ2e5y2eRUpkUosIW4A2AS38zwSz27zu7ufDwQPi5Jhs3XAlGNetl3bmnGhQsMtkKJnj3w==}
dotenv@16.0.3:
resolution: {integrity: sha512-7GO6HghkA5fYG9TYnNxi14/7K9f5occMlp3zXAuSxn7CKCxt9xbNWG7yF8hTCSUchlfWSe3uLmlPfigevRItzQ==}
engines: {node: '>=12'}
dotenv@16.6.1: dotenv@16.6.1:
resolution: {integrity: sha512-uBq4egWHTcTt33a72vpSG0z3HnPuIl6NqYcTrKEg2azoEyl2hpW0zqlxysq2pK9HlDIHyHyakeYaYnSAwd8bow==} resolution: {integrity: sha512-uBq4egWHTcTt33a72vpSG0z3HnPuIl6NqYcTrKEg2azoEyl2hpW0zqlxysq2pK9HlDIHyHyakeYaYnSAwd8bow==}
engines: {node: '>=12'} engines: {node: '>=12'}
@ -5718,6 +5725,12 @@ packages:
eslint: '>=8' eslint: '>=8'
storybook: ^10.1.4 storybook: ^10.1.4
eslint-plugin-turbo@2.6.3:
resolution: {integrity: sha512-91WZ+suhT/pk+qNS0/rqT43xLUlUblsa3a8jKmAStGhkJCmR2uX0oWo/e0Edb+It8MdnteXuYpCkvsK4Vw8FtA==}
peerDependencies:
eslint: '>6.6.0'
turbo: '>2.0.0'
eslint-scope@5.1.1: eslint-scope@5.1.1:
resolution: {integrity: sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==} resolution: {integrity: sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==}
engines: {node: '>=8.0.0'} engines: {node: '>=8.0.0'}
@ -13120,8 +13133,6 @@ snapshots:
camelcase@7.0.1: {} camelcase@7.0.1: {}
caniuse-lite@1.0.30001756: {}
caniuse-lite@1.0.30001759: {} caniuse-lite@1.0.30001759: {}
capital-case@1.0.4: capital-case@1.0.4:
@ -13659,6 +13670,8 @@ snapshots:
no-case: 3.0.4 no-case: 3.0.4
tslib: 2.8.1 tslib: 2.8.1
dotenv@16.0.3: {}
dotenv@16.6.1: {} dotenv@16.6.1: {}
dotenv@17.2.3: {} dotenv@17.2.3: {}
@ -14059,6 +14072,12 @@ snapshots:
- supports-color - supports-color
- typescript - typescript
eslint-plugin-turbo@2.6.3(eslint@9.39.1(jiti@2.6.1))(turbo@2.6.3):
dependencies:
dotenv: 16.0.3
eslint: 9.39.1(jiti@2.6.1)
turbo: 2.6.3
eslint-scope@5.1.1: eslint-scope@5.1.1:
dependencies: dependencies:
esrecurse: 4.3.0 esrecurse: 4.3.0
@ -15908,7 +15927,7 @@ snapshots:
dependencies: dependencies:
'@next/env': 16.0.7 '@next/env': 16.0.7
'@swc/helpers': 0.5.15 '@swc/helpers': 0.5.15
caniuse-lite: 1.0.30001756 caniuse-lite: 1.0.30001759
postcss: 8.4.31 postcss: 8.4.31
react: 18.3.1 react: 18.3.1
react-dom: 18.3.1(react@18.3.1) react-dom: 18.3.1(react@18.3.1)

View file

@ -1,85 +1,95 @@
{ {
"$schema": "https://turbo.build/schema.json", "$schema": "https://turborepo.com/schema.json",
"globalDependencies": [".npmrc"],
"globalEnv": [ "globalEnv": [
"APP_VERSION",
"DEV",
"LOG_LEVEL",
"NODE_ENV", "NODE_ENV",
"VITE_API_BASE_URL", "SENTRY_DSN",
"VITE_ADMIN_BASE_URL", "SENTRY_ENVIRONMENT",
"SENTRY_TRACES_SAMPLE_RATE",
"VITE_ADMIN_BASE_PATH", "VITE_ADMIN_BASE_PATH",
"VITE_SPACE_BASE_URL", "VITE_ADMIN_BASE_URL",
"VITE_SPACE_BASE_PATH", "VITE_API_BASE_PATH",
"VITE_WEB_BASE_URL", "VITE_API_BASE_URL",
"VITE_LIVE_BASE_URL", "VITE_APP_VERSION",
"VITE_LIVE_BASE_PATH",
"VITE_ENABLE_SESSION_RECORDER", "VITE_ENABLE_SESSION_RECORDER",
"VITE_SESSION_RECORDER_KEY", "VITE_LIVE_BASE_PATH",
"VITE_POSTHOG_KEY", "VITE_LIVE_BASE_URL",
"VITE_POSTHOG_HOST",
"VITE_POSTHOG_DEBUG", "VITE_POSTHOG_DEBUG",
"VITE_SUPPORT_EMAIL", "VITE_POSTHOG_HOST",
"ENABLE_EXPERIMENTAL_COREPACK", "VITE_POSTHOG_KEY",
"VITE_SENTRY_DSN", "VITE_SENTRY_DSN",
"VITE_SENTRY_ENVIRONMENT", "VITE_SENTRY_ENVIRONMENT",
"VITE_SENTRY_PROFILES_SAMPLE_RATE",
"VITE_SENTRY_REPLAYS_ON_ERROR_SAMPLE_RATE",
"VITE_SENTRY_REPLAYS_SESSION_SAMPLE_RATE",
"VITE_SENTRY_SEND_DEFAULT_PII", "VITE_SENTRY_SEND_DEFAULT_PII",
"VITE_SENTRY_TRACES_SAMPLE_RATE", "VITE_SENTRY_TRACES_SAMPLE_RATE",
"VITE_SENTRY_PROFILES_SAMPLE_RATE", "VITE_SESSION_RECORDER_KEY",
"VITE_SENTRY_REPLAYS_SESSION_SAMPLE_RATE", "VITE_SPACE_BASE_PATH",
"VITE_SENTRY_REPLAYS_ON_ERROR_SAMPLE_RATE", "VITE_SPACE_BASE_URL",
"VITE_APP_VERSION" "VITE_SUPPORT_EMAIL",
"VITE_WEB_BASE_PATH",
"VITE_WEB_BASE_URL",
"VITE_WEBSITE_URL"
], ],
"globalDependencies": ["pnpm-lock.yaml", "pnpm-workspace.yaml", ".npmrc"], "remoteCache": {
"enabled": false
},
"tasks": { "tasks": {
"build": { "build": {
"dependsOn": ["^build"], "dependsOn": ["^build"],
"outputs": ["dist/**", "build/**"] "inputs": ["$TURBO_DEFAULT$", ".env*"],
"outputs": ["dist/**", "build/**", ".react-router/**"]
}, },
"build-storybook": { "build-storybook": {
"dependsOn": ["^build"], "dependsOn": ["^build"],
"outputs": ["storybook-static/**"] "outputs": ["storybook-static/**"]
}, },
"dev": { "check": {
"dependsOn": ["check:format", "check:lint", "check:types"]
},
"check:format": {
"inputs": ["$TURBO_DEFAULT$"],
"outputs": []
},
"check:lint": {
"dependsOn": ["^build"], "dependsOn": ["^build"],
"cache": false, "inputs": ["$TURBO_DEFAULT$", "!**/*.md"],
"persistent": true "outputs": []
}, },
"check:types": { "check:types": {
"dependsOn": ["^build"], "dependsOn": ["^build"],
"inputs": ["$TURBO_DEFAULT$", "!**/*.md"],
"outputs": []
},
"clean": {
"cache": false "cache": false
}, },
"lint": { "dev": {
"cache": false, "cache": false,
"inputs": ["**/*.{js,ts,tsx,mjs,jsx}", "!**/node_modules/**", "!**/build/**", "!**/dist/**"] "dependsOn": ["^build"],
"persistent": true
}, },
"check:lint": { "fix": {
"dependsOn": ["lint"],
"cache": false, "cache": false,
"inputs": ["**/*.{js,ts,tsx,mjs,jsx}", "!**/build/**", "!**/dist/**"] "dependsOn": ["fix:format", "fix:lint"]
}, },
"check:format": { "fix:format": {
"cache": false
},
"check": {
"dependsOn": ["check:format", "check:lint", "check:types"],
"cache": false "cache": false
}, },
"fix:lint": { "fix:lint": {
"cache": false "cache": false
}, },
"fix:format": { "start": {
"cache": false "cache": false,
}, "persistent": true
"fix": {
"dependsOn": ["fix:format", "fix:lint"],
"cache": false
}, },
"test": { "test": {
"dependsOn": ["^build"], "dependsOn": ["^build"],
"outputs": [] "outputs": []
},
"start": {
"cache": false
},
"clean": {
"cache": false
} }
} }
} }