Skip to content

Commit be55fb8

Browse files
committed
Add Turbo cache and update workflows to use Turbo commands
1 parent 6435a89 commit be55fb8

File tree

5 files changed

+84
-12
lines changed

5 files changed

+84
-12
lines changed

.github/workflows/algolia-index.yml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,23 @@ jobs:
3636
- run: yarn install --frozen-lockfile
3737
if: steps.cache.outputs.cache-hit != 'true'
3838

39+
# Setup Turbo cache with better cache keys for builds
40+
- name: Setup Turbo cache
41+
uses: actions/cache@v4
42+
with:
43+
path: .turbo
44+
key: ${{ runner.os }}-turbo-algolia-${{ hashFiles('**/package.json', '**/turbo.json', '**/next.config.*', '**/tsconfig.json', 'docs/**', 'includes/**', 'platform-includes/**', 'develop-docs/**') }}-${{ github.sha }}
45+
restore-keys: |
46+
${{ runner.os }}-turbo-algolia-${{ hashFiles('**/package.json', '**/turbo.json', '**/next.config.*', '**/tsconfig.json') }}-
47+
${{ runner.os }}-turbo-algolia-
48+
${{ runner.os }}-turbo-build-
49+
${{ runner.os }}-turbo-
50+
3951
# bun seems to be the most straightforward way to run a TypeScript script
4052
# without introducing another dependency like ts-node or tsx for everyone else
4153

4254
- name: Build index for user docs
43-
run: yarn build && bun ./scripts/algolia.ts
55+
run: yarn turbo run build && bun ./scripts/algolia.ts
4456
if: steps.filter.outputs.docs == 'true'
4557
env:
4658
ALGOLIA_APP_ID: ${{ secrets.ALGOLIA_APP_ID }}
@@ -52,7 +64,7 @@ jobs:
5264
NEXT_PUBLIC_SENTRY_DSN: https://[email protected]/0
5365

5466
- name: Build index for developer docs
55-
run: yarn build:developer-docs && bun ./scripts/algolia.ts
67+
run: yarn turbo run build:developer-docs && bun ./scripts/algolia.ts
5668
if: steps.filter.outputs.dev-docs == 'true'
5769
env:
5870
ALGOLIA_APP_ID: ${{ secrets.ALGOLIA_APP_ID }}

.github/workflows/lint-404s.yml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,24 @@ jobs:
3838
- run: yarn install --frozen-lockfile
3939
if: steps.cache.outputs.cache-hit != 'true'
4040

41-
- run: yarn build
41+
# Setup Turbo cache with better cache keys for builds
42+
- name: Setup Turbo cache
43+
uses: actions/cache@v4
44+
with:
45+
path: .turbo
46+
key: ${{ runner.os }}-turbo-build-${{ hashFiles('**/package.json', '**/turbo.json', '**/next.config.*', '**/tsconfig.json', 'docs/**', 'includes/**', 'platform-includes/**', 'develop-docs/**') }}-${{ github.sha }}
47+
restore-keys: |
48+
${{ runner.os }}-turbo-build-${{ hashFiles('**/package.json', '**/turbo.json', '**/next.config.*', '**/tsconfig.json') }}-
49+
${{ runner.os }}-turbo-build-
50+
${{ runner.os }}-turbo-
51+
52+
- run: yarn turbo run build
4253
if: steps.filter.outputs.docs == 'true'
4354
env:
4455
SENTRY_DSN: https://[email protected]/0
4556
NEXT_PUBLIC_SENTRY_DSN: https://[email protected]/0
4657

47-
- run: yarn build:developer-docs
58+
- run: yarn turbo run build:developer-docs
4859
if: steps.filter.outputs.dev-docs == 'true'
4960
env:
5061
SENTRY_DSN: https://[email protected]/0

.github/workflows/test.yml

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,28 @@ jobs:
3131
with:
3232
path: ${{ github.workspace }}/node_modules
3333
key: node-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
34+
3435
- run: yarn install --frozen-lockfile
3536
if: steps.cache.outputs.cache-hit != 'true'
3637

37-
# Additional checks
38-
- run: yarn lint:ts
39-
- run: yarn lint:docs
38+
# Setup Turbo cache with better cache keys
39+
- name: Setup Turbo cache
40+
uses: actions/cache@v4
41+
with:
42+
path: .turbo
43+
key: ${{ runner.os }}-turbo-lint-${{ hashFiles('**/package.json', '**/turbo.json', '**/.eslintrc*', '**/tsconfig.json') }}-${{ github.sha }}
44+
restore-keys: |
45+
${{ runner.os }}-turbo-lint-${{ hashFiles('**/package.json', '**/turbo.json', '**/.eslintrc*', '**/tsconfig.json') }}-
46+
${{ runner.os }}-turbo-lint-
47+
${{ runner.os }}-turbo-
48+
49+
# Additional checks using Turbo
50+
- run: yarn turbo run lint:ts
51+
- run: yarn turbo run lint:docs
4052

41-
# Run automatic fixes (run prettier apart from eslint to also fix mdx files)
42-
- run: yarn lint:prettier:fix
43-
- run: yarn lint:eslint:fix
53+
# Run automatic fixes using Turbo (run prettier apart from eslint to also fix mdx files)
54+
- run: yarn turbo run lint:prettier:fix
55+
- run: yarn turbo run lint:eslint:fix
4456

4557
# Check (and error) for dirty working tree for forks
4658
# Reason being we need a different token to auto commit changes and
@@ -73,5 +85,17 @@ jobs:
7385
key: node-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
7486
- run: yarn install --frozen-lockfile
7587
if: steps.cache.outputs.cache-hit != 'true'
88+
89+
# Setup Turbo cache with better cache keys
90+
- name: Setup Turbo cache
91+
uses: actions/cache@v4
92+
with:
93+
path: .turbo
94+
key: ${{ runner.os }}-turbo-test-${{ hashFiles('**/package.json', '**/turbo.json', '**/*.{ts,tsx,js,jsx}', '**/tsconfig.json') }}-${{ github.sha }}
95+
restore-keys: |
96+
${{ runner.os }}-turbo-test-${{ hashFiles('**/package.json', '**/turbo.json', '**/*.{ts,tsx,js,jsx}', '**/tsconfig.json') }}-
97+
${{ runner.os }}-turbo-test-
98+
${{ runner.os }}-turbo-
99+
76100
- name: Run Tests
77-
run: yarn test
101+
run: yarn turbo run test

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,3 +101,4 @@ yalc.lock
101101

102102
# turborepo
103103
.turbo
104+
.turborc

turbo.json

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,37 @@
1212
],
1313
"env": [
1414
"NODE_ENV",
15-
"NEXT_PUBLIC_*"
15+
"NEXT_PUBLIC_*",
16+
"SENTRY_DSN"
17+
]
18+
},
19+
"build:developer-docs": {
20+
"dependsOn": [
21+
"^build"
22+
],
23+
"outputs": [
24+
".next/**",
25+
"!.next/cache/**",
26+
"dist/**"
27+
],
28+
"env": [
29+
"NODE_ENV",
30+
"NEXT_PUBLIC_*",
31+
"SENTRY_DSN",
32+
"NEXT_PUBLIC_DEVELOPER_DOCS"
1633
]
1734
},
1835
"dev": {
1936
"cache": false,
2037
"persistent": true
2138
},
39+
"dev:developer-docs": {
40+
"cache": false,
41+
"persistent": true,
42+
"env": [
43+
"NEXT_PUBLIC_DEVELOPER_DOCS"
44+
]
45+
},
2246
"start": {
2347
"dependsOn": [
2448
"build"

0 commit comments

Comments
 (0)