Skip to content

Commit ff544c9

Browse files
chore: optimize turborepo (#8286)
1 parent 20510bb commit ff544c9

File tree

8 files changed

+233
-66
lines changed

8 files changed

+233
-66
lines changed

.github/workflows/pull-request-build-lint-api.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,13 @@ jobs:
2727
github.event.pull_request.draft == false &&
2828
github.event.pull_request.requested_reviewers != null
2929
steps:
30-
- uses: actions/checkout@v4
30+
- uses: actions/checkout@v6
3131
- name: Set up Python
32-
uses: actions/setup-python@v5
32+
uses: actions/setup-python@v6
3333
with:
3434
python-version: "3.12.x"
35+
cache: 'pip'
36+
cache-dependency-path: 'apps/api/requirements.txt'
3537
- name: Install Pylint
3638
run: python -m pip install ruff
3739
- name: Install API Dependencies

.github/workflows/pull-request-build-lint-web-apps.yml

Lines changed: 125 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@ concurrency:
1717
cancel-in-progress: true
1818

1919
jobs:
20-
build-and-lint:
21-
name: Build and lint web apps
20+
# Format check has no build dependencies - run immediately in parallel
21+
check-format:
22+
name: check:format
2223
runs-on: ubuntu-latest
23-
timeout-minutes: 25
24+
timeout-minutes: 10
2425
if: |
2526
github.event.pull_request.draft == false &&
2627
github.event.pull_request.requested_reviewers != null
@@ -29,28 +30,140 @@ jobs:
2930
TURBO_SCM_HEAD: ${{ github.sha }}
3031
steps:
3132
- name: Checkout code
32-
uses: actions/checkout@v4
33+
uses: actions/checkout@v6
3334
with:
3435
fetch-depth: 50
3536
filter: blob:none
3637

3738
- name: Set up Node.js
38-
uses: actions/setup-node@v4
39+
uses: actions/setup-node@v6
3940

4041
- name: Enable Corepack and pnpm
4142
run: corepack enable pnpm
4243

44+
- name: Get pnpm store directory
45+
shell: bash
46+
run: echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
47+
48+
- name: Cache pnpm store
49+
uses: actions/cache@v4
50+
with:
51+
path: ${{ env.STORE_PATH }}
52+
key: pnpm-store-${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }}
53+
restore-keys: |
54+
pnpm-store-${{ runner.os }}-
55+
4356
- name: Install dependencies
4457
run: pnpm install --frozen-lockfile
4558

46-
- name: Build Affected
59+
- name: Check formatting
60+
run: pnpm turbo run check:format --affected
61+
62+
# Build packages - required for lint and type checks
63+
build:
64+
name: Build packages
65+
runs-on: ubuntu-latest
66+
timeout-minutes: 15
67+
if: |
68+
github.event.pull_request.draft == false &&
69+
github.event.pull_request.requested_reviewers != null
70+
env:
71+
TURBO_SCM_BASE: ${{ github.event.pull_request.base.sha }}
72+
TURBO_SCM_HEAD: ${{ github.sha }}
73+
NODE_OPTIONS: "--max-old-space-size=4096"
74+
steps:
75+
- name: Checkout code
76+
uses: actions/checkout@v6
77+
with:
78+
fetch-depth: 50
79+
filter: blob:none
80+
81+
- name: Set up Node.js
82+
uses: actions/setup-node@v6
83+
84+
- name: Enable Corepack and pnpm
85+
run: corepack enable pnpm
86+
87+
- name: Get pnpm store directory
88+
shell: bash
89+
run: echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
90+
91+
- name: Cache pnpm store
92+
uses: actions/cache@v4
93+
with:
94+
path: ${{ env.STORE_PATH }}
95+
key: pnpm-store-${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }}
96+
restore-keys: |
97+
pnpm-store-${{ runner.os }}-
98+
99+
- name: Restore Turbo cache
100+
uses: actions/cache/restore@v4
101+
with:
102+
path: .turbo
103+
key: turbo-${{ runner.os }}-${{ github.event.pull_request.base.sha }}-${{ github.sha }}
104+
restore-keys: |
105+
turbo-${{ runner.os }}-${{ github.event.pull_request.base.sha }}-
106+
turbo-${{ runner.os }}-
107+
108+
- name: Install dependencies
109+
run: pnpm install --frozen-lockfile
110+
111+
- name: Build packages
47112
run: pnpm turbo run build --affected
48113

49-
- name: Lint Affected
50-
run: pnpm turbo run check:lint --affected
114+
- name: Save Turbo cache
115+
uses: actions/cache/save@v4
116+
with:
117+
path: .turbo
118+
key: turbo-${{ runner.os }}-${{ github.event.pull_request.base.sha }}-${{ github.sha }}
51119

52-
- name: Check Affected format
53-
run: pnpm turbo run check:format --affected
120+
# Lint and type checks depend on build artifacts
121+
check:
122+
name: ${{ matrix.task }}
123+
runs-on: ubuntu-latest
124+
needs: build
125+
timeout-minutes: 15
126+
strategy:
127+
fail-fast: false
128+
matrix:
129+
task: [check:lint, check:types]
130+
env:
131+
TURBO_SCM_BASE: ${{ github.event.pull_request.base.sha }}
132+
TURBO_SCM_HEAD: ${{ github.sha }}
133+
NODE_OPTIONS: "--max-old-space-size=4096"
134+
steps:
135+
- name: Checkout code
136+
uses: actions/checkout@v6
137+
with:
138+
fetch-depth: 50
139+
filter: blob:none
140+
141+
- name: Set up Node.js
142+
uses: actions/setup-node@v6
143+
144+
- name: Enable Corepack and pnpm
145+
run: corepack enable pnpm
146+
147+
- name: Get pnpm store directory
148+
shell: bash
149+
run: echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
150+
151+
- name: Cache pnpm store
152+
uses: actions/cache@v4
153+
with:
154+
path: ${{ env.STORE_PATH }}
155+
key: pnpm-store-${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }}
156+
restore-keys: |
157+
pnpm-store-${{ runner.os }}-
158+
159+
- name: Restore Turbo cache
160+
uses: actions/cache/restore@v4
161+
with:
162+
path: .turbo
163+
key: turbo-${{ runner.os }}-${{ github.event.pull_request.base.sha }}-${{ github.sha }}
164+
165+
- name: Install dependencies
166+
run: pnpm install --frozen-lockfile
54167

55-
- name: Check Affected types
56-
run: pnpm turbo run check:types --affected
168+
- name: Run ${{ matrix.task }}
169+
run: pnpm turbo run ${{ matrix.task }} --affected

eslint.config.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import promisePlugin from "eslint-plugin-promise";
1010
import reactPlugin from "eslint-plugin-react";
1111
import reactHooksPlugin from "eslint-plugin-react-hooks";
1212
import reactRefreshPlugin from "eslint-plugin-react-refresh";
13+
import turboPlugin from "eslint-plugin-turbo";
1314
import vitestPlugin from "@vitest/eslint-plugin";
1415
// import storybookPlugin from "eslint-plugin-storybook";
1516

@@ -42,6 +43,7 @@ export default defineConfig([
4243
jsxA11yPlugin.flatConfigs.recommended,
4344
reactRefreshPlugin.configs.recommended,
4445
reactRefreshPlugin.configs.vite,
46+
turboPlugin.configs["flat/recommended"],
4547
tseslint.configs.recommendedTypeChecked,
4648
vitestPlugin.configs.recommended,
4749
// TODO: enable storybook linting once issues are resolved

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
"eslint-plugin-react-hooks": "7.0.1",
3636
"eslint-plugin-react-refresh": "0.4.24",
3737
"eslint-plugin-storybook": "10.1.4",
38+
"eslint-plugin-turbo": "2.6.3",
3839
"globals": "16.5.0",
3940
"husky": "9.1.7",
4041
"lint-staged": "16.2.7",

packages/shared-state/package.json

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,20 @@
44
"license": "AGPL-3.0",
55
"description": "Shared state shared across multiple apps internally",
66
"private": true,
7-
"main": "./src/index.ts",
8-
"types": "./src/index.ts",
7+
"type": "module",
8+
"main": "./dist/index.js",
9+
"module": "./dist/index.js",
10+
"types": "./dist/index.d.ts",
11+
"exports": {
12+
".": {
13+
"types": "./dist/index.d.ts",
14+
"import": "./dist/index.js"
15+
},
16+
"./package.json": "./package.json"
17+
},
918
"scripts": {
19+
"build": "tsdown",
20+
"dev": "tsdown --watch",
1021
"check:lint": "eslint . --max-warnings=191",
1122
"check:types": "tsc --noEmit",
1223
"check:format": "prettier --check .",
@@ -28,6 +39,7 @@
2839
"@plane/typescript-config": "workspace:*",
2940
"@types/lodash-es": "catalog:",
3041
"@types/node": "catalog:",
42+
"tsdown": "catalog:",
3143
"typescript": "catalog:"
3244
}
3345
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { defineConfig } from "tsdown";
2+
3+
export default defineConfig({
4+
entry: ["src/index.ts"],
5+
format: ["esm"],
6+
dts: true,
7+
platform: "neutral",
8+
});

pnpm-lock.yaml

Lines changed: 25 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)