ci: Use turbo remote cache (#4666)

* Use a turbo remote cache server for CI

`rharkor/caching-for-turbo` uses github actions cache to provide a remote cache server for turbo, so we can use previuously created cache if available and requested by turbo, and this doesn't have the downside of having the cache growing indefinitely like with normal github actions cache as since the single caches are uploaded to the github actions cache, github can evict the old cache when it's not used or there is no space left.

Also add turbo to website so we can cache the build

* Use turbo for website build & build:doc

* fix typo, tubo -> turbo

---------

Co-authored-by: Skillz4Killz <23035000+Skillz4Killz@users.noreply.github.com>
This commit is contained in:
Fleny
2026-01-07 20:40:27 +01:00
committed by GitHub
parent 86c5601d5e
commit 011f0fe0dc
10 changed files with 143 additions and 107 deletions

View File

@@ -22,21 +22,13 @@ jobs:
node-version: 20 node-version: 20
cache: yarn cache: yarn
- run: yarn install --immutable - run: yarn install --immutable
- name: Turbo Cache - name: Cache for Turbo
id: turbo-cache uses: rharkor/caching-for-turbo@v2.3.5
uses: actions/cache@v5
with: with:
path: .turbo cache-prefix: turbo-cache-
key: ${{ runner.os }}-turbo-test:e2e-${{ inputs.package }}-${{ github.sha }}
- name: Build dist cache
if: steps.turbo-cache.outputs.cache-hit != 'true'
uses: actions/cache@v5
with:
path: .turbo
key: ${{ runner.os }}-turbo-build-${{ github.sha }}
- name: E2E Test - name: E2E Test
if: ${{ inputs.event_name != 'pull_request' }} if: ${{ inputs.event_name != 'pull_request' }}
run: yarn test:e2e --cache-dir=".turbo" --filter=./packages/${{ inputs.package }} run: yarn test:e2e --filter=./packages/${{ inputs.package }}
timeout-minutes: 5 timeout-minutes: 5
env: env:
DISCORD_TOKEN: ${{ secrets.DISCORD_TOKEN }} DISCORD_TOKEN: ${{ secrets.DISCORD_TOKEN }}

View File

@@ -19,20 +19,12 @@ jobs:
node-version: 20 node-version: 20
cache: yarn cache: yarn
- run: yarn install --immutable - run: yarn install --immutable
- name: Turbo Cache - name: Cache for Turbo
id: turbo-cache uses: rharkor/caching-for-turbo@v2.3.5
uses: actions/cache@v5
with: with:
path: .turbo cache-prefix: turbo-cache-
key: ${{ runner.os }}-turbo-test:integration-${{ inputs.package }}-${{ github.sha }}
- name: Build dist cache
if: steps.turbo-cache.outputs.cache-hit != 'true'
uses: actions/cache@v5
with:
path: .turbo
key: ${{ runner.os }}-turbo-build-${{ github.sha }}
- name: Integration Test - name: Integration Test
run: yarn test:integration --cache-dir=".turbo" --filter=./packages/${{ inputs.package }} run: yarn test:integration --filter=./packages/${{ inputs.package }}
timeout-minutes: 3 timeout-minutes: 3
- name: Collect and upload the coverage report - name: Collect and upload the coverage report
uses: codecov/codecov-action@v5 uses: codecov/codecov-action@v5

View File

@@ -6,8 +6,6 @@ on:
push: push:
branches: branches:
- main - main
paths-ignore:
- 'website/**'
merge_group: merge_group:
jobs: jobs:
@@ -21,14 +19,12 @@ jobs:
node-version: 20 node-version: 20
cache: yarn cache: yarn
- run: yarn install --immutable - run: yarn install --immutable
- name: Turbo Cache - name: Cache for Turbo
id: turbo-cache uses: rharkor/caching-for-turbo@v2.3.5
uses: actions/cache@v5
with: with:
path: .turbo cache-prefix: turbo-cache-
key: ${{ runner.os }}-turbo-build:type-${{ github.sha }}
- name: Build Types - name: Build Types
run: yarn build:type --cache-dir=".turbo" run: yarn build:type
build-dist: build-dist:
name: Build Dist name: Build Dist
@@ -40,14 +36,12 @@ jobs:
node-version: 20 node-version: 20
cache: yarn cache: yarn
- run: yarn install --immutable - run: yarn install --immutable
- name: Turbo Cache - name: Cache for Turbo
id: turbo-cache uses: rharkor/caching-for-turbo@v2.3.5
uses: actions/cache@v5
with: with:
path: .turbo cache-prefix: turbo-cache-
key: ${{ runner.os }}-turbo-build-${{ github.sha }} - name: Build Dist
- name: Type Test run: yarn build
run: yarn build --cache-dir=".turbo"
format: format:
name: Format name: Format
@@ -60,13 +54,12 @@ jobs:
node-version: 20 node-version: 20
cache: yarn cache: yarn
- run: yarn install --immutable - run: yarn install --immutable
- name: Build type cache - name: Cache for Turbo
uses: actions/cache@v5 uses: rharkor/caching-for-turbo@v2.3.5
with: with:
path: .turbo cache-prefix: turbo-cache-
key: ${{ runner.os }}-turbo-build:type-${{ github.sha }}
- name: Build Types - name: Build Types
run: yarn build:type --cache-dir=".turbo" run: yarn build:type
- name: Check Formatting - name: Check Formatting
run: yarn biome ci --reporter=github run: yarn biome ci --reporter=github
@@ -81,20 +74,12 @@ jobs:
node-version: 20 node-version: 20
cache: yarn cache: yarn
- run: yarn install --immutable - run: yarn install --immutable
- name: Turbo Cache - name: Cache for Turbo
id: turbo-cache uses: rharkor/caching-for-turbo@v2.3.5
uses: actions/cache@v5
with: with:
path: .turbo cache-prefix: turbo-cache-
key: ${{ runner.os }}-turbo-unit-and-integration-test:test-type-${{ github.sha }}
- name: Build type cache
if: steps.turbo-cache.outputs.cache-hit != 'true'
uses: actions/cache@v5
with:
path: .turbo
key: ${{ runner.os }}-turbo-build:type-${{ github.sha }}
- name: Test Type Test - name: Test Type Test
run: yarn test:test-type --cache-dir=".turbo" run: yarn test:test-type
# Not using matrix because test later on cant needs a specific job # Not using matrix because test later on cant needs a specific job
bot-unit-test: bot-unit-test:

View File

@@ -22,20 +22,12 @@ jobs:
with: with:
deno-version: 'v2.1.x' deno-version: 'v2.1.x'
- run: yarn install --immutable - run: yarn install --immutable
- name: Turbo Cache - name: Cache for Turbo
id: turbo-cache uses: rharkor/caching-for-turbo@v2.3.5
uses: actions/cache@v5
with: with:
path: .turbo cache-prefix: turbo-cache-
key: ${{ runner.os }}-turbo-test:deno-unit-${{ inputs.package }}-${{ github.sha }}
- name: Build dist cache
if: steps.turbo-cache.outputs.cache-hit != 'true'
uses: actions/cache@v5
with:
path: .turbo
key: ${{ runner.os }}-turbo-build-${{ github.sha }}
- name: Deno Unit Test - name: Deno Unit Test
run: yarn test:deno-unit --cache-dir=".turbo" --filter=./packages/${{ inputs.package }} run: yarn test:deno-unit --filter=./packages/${{ inputs.package }}
bun-unit-test: bun-unit-test:
name: Bun Unit Test name: Bun Unit Test
runs-on: ubuntu-latest runs-on: ubuntu-latest
@@ -49,18 +41,10 @@ jobs:
with: with:
bun-version: '1.1.42' bun-version: '1.1.42'
- run: yarn install --immutable - run: yarn install --immutable
- name: Turbo Cache - name: Cache for Turbo
id: turbo-cache uses: rharkor/caching-for-turbo@v2.3.5
uses: actions/cache@v5
with: with:
path: .turbo cache-prefix: turbo-cache-
key: ${{ runner.os }}-turbo-test:bun-unit-${{ inputs.package }}-${{ github.sha }}
- name: Build dist cache
if: steps.turbo-cache.outputs.cache-hit != 'true'
uses: actions/cache@v5
with:
path: .turbo
key: ${{ runner.os }}-turbo-build-${{ github.sha }}
- name: Bun Unit Test - name: Bun Unit Test
run: yarn test:bun-unit --cache-dir=".turbo" --filter=./packages/${{ inputs.package }} run: yarn test:bun-unit --filter=./packages/${{ inputs.package }}
timeout-minutes: 1 timeout-minutes: 1

View File

@@ -4,12 +4,6 @@ permissions:
on: on:
push: push:
branches: ['main'] branches: ['main']
paths:
- 'website/**'
- '.github/workflows/site.yml'
- 'typedoc.json'
- 'package.json'
- 'packages/**'
pull_request: pull_request:
workflow_dispatch: workflow_dispatch:
@@ -31,10 +25,19 @@ jobs:
website/yarn.lock website/yarn.lock
- name: yarn install (root) - name: yarn install (root)
run: yarn install --immutable run: yarn install --immutable
- name: Cache for Turbo
uses: rharkor/caching-for-turbo@v2.3.5
with:
cache-prefix: turbo-cache-
- name: Cache for Turbo
uses: rharkor/caching-for-turbo@v2.3.5
with:
cache-prefix: turbo-cache-website-
server-port: 41231 # The default is 41230, but we use a different cache key so we need a different port
- name: Build all pkg - name: Build all pkg
run: yarn release-build run: yarn release-build
- name: Build docs - name: Build docs
run: yarn build:doc run: yarn turbo build:doc --single-package
- run: yarn install --immutable - run: yarn install --immutable
working-directory: ./website working-directory: ./website
- name: Restore bundler cache - name: Restore bundler cache
@@ -45,8 +48,10 @@ jobs:
restore-keys: | restore-keys: |
${{ runner.os }}-docusaurus-bundler- ${{ runner.os }}-docusaurus-bundler-
- name: Build website - name: Build website
run: yarn build run: yarn turbo build
working-directory: ./website working-directory: ./website
env:
TURBO_API: http://localhost:41231
- name: Upload artifact - name: Upload artifact
uses: actions/upload-pages-artifact@v4 uses: actions/upload-pages-artifact@v4
with: with:
@@ -64,10 +69,14 @@ jobs:
website/yarn.lock website/yarn.lock
- name: yarn install (root) - name: yarn install (root)
run: yarn install --immutable run: yarn install --immutable
- name: Cache for Turbo
uses: rharkor/caching-for-turbo@v2.3.5
with:
cache-prefix: turbo-cache-
- name: Build all pkg - name: Build all pkg
run: yarn release-build run: yarn release-build
- name: Build docs - name: Build docs
run: yarn build:doc run: yarn turbo build:doc --single-package
- run: yarn install --immutable - run: yarn install --immutable
working-directory: ./website working-directory: ./website
- run: yarn typecheck - run: yarn typecheck

View File

@@ -19,26 +19,12 @@ jobs:
node-version: 20 node-version: 20
cache: yarn cache: yarn
- run: yarn install --immutable - run: yarn install --immutable
- name: Turbo Cache - name: Cache for Turbo
id: turbo-cache uses: rharkor/caching-for-turbo@v2.3.5
uses: actions/cache@v5
with: with:
path: .turbo cache-prefix: turbo-cache-
key: ${{ runner.os }}-turbo-test:unit-${{ inputs.package }}-${{ github.sha }}
- name: Build dist cache
if: steps.turbo-cache.outputs.cache-hit != 'true'
uses: actions/cache@v5
with:
path: .turbo
key: ${{ runner.os }}-turbo-build-${{ github.sha }}
- name: Build type cache
if: steps.turbo-cache.outputs.cache-hit != 'true'
uses: actions/cache@v5
with:
path: .turbo
key: ${{ runner.os }}-turbo-build:type-${{ github.sha }}
- name: Unit Test - name: Unit Test
run: yarn test:unit --cache-dir=".turbo" --filter=./packages/${{ inputs.package }} run: yarn test:unit --filter=./packages/${{ inputs.package }}
timeout-minutes: 1 timeout-minutes: 1
- name: Collect and upload the coverage report - name: Collect and upload the coverage report
uses: codecov/codecov-action@v5 uses: codecov/codecov-action@v5

View File

@@ -38,6 +38,11 @@
"check": { "check": {
"dependsOn": ["build:type"], "dependsOn": ["build:type"],
"cache": false "cache": false
},
"build:doc": {
// NOTE: This task can only be run with "--singe-package" in the flags to turbo, as it is defined only in the root package.json
"inputs": ["packages/**/src/**/*.ts"],
"outputs": ["website/api_reference/generated/**/*"]
} }
} }
} }

View File

@@ -1,6 +1,7 @@
{ {
"name": "website", "name": "website",
"version": "0.0.0", "version": "0.0.0",
"packageManager": "yarn@4.12.0",
"private": true, "private": true,
"scripts": { "scripts": {
"docusaurus": "docusaurus", "docusaurus": "docusaurus",
@@ -35,6 +36,7 @@
"@docusaurus/tsconfig": "^3.9.2", "@docusaurus/tsconfig": "^3.9.2",
"@docusaurus/types": "^3.9.2", "@docusaurus/types": "^3.9.2",
"@types/react": "^19.2.7", "@types/react": "^19.2.7",
"turbo": "^2.7.2",
"typescript": "5.9.3", "typescript": "5.9.3",
"webpack": "5.104.1" "webpack": "5.104.1"
}, },

9
website/turbo.json Normal file
View File

@@ -0,0 +1,9 @@
{
"$schema": "https://turbo.build/schema.json",
"tasks": {
"build": {
"outputs": ["build/**"],
"inputs": ["src/**/*", "static/**/*", "blog/**/*", "docs/**/*", "api_reference/**/*", "docusaurus.config.ts", "sidebars.ts"]
}
}
}

View File

@@ -19935,6 +19935,77 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"turbo-darwin-64@npm:2.7.2":
version: 2.7.2
resolution: "turbo-darwin-64@npm:2.7.2"
conditions: os=darwin & cpu=x64
languageName: node
linkType: hard
"turbo-darwin-arm64@npm:2.7.2":
version: 2.7.2
resolution: "turbo-darwin-arm64@npm:2.7.2"
conditions: os=darwin & cpu=arm64
languageName: node
linkType: hard
"turbo-linux-64@npm:2.7.2":
version: 2.7.2
resolution: "turbo-linux-64@npm:2.7.2"
conditions: os=linux & cpu=x64
languageName: node
linkType: hard
"turbo-linux-arm64@npm:2.7.2":
version: 2.7.2
resolution: "turbo-linux-arm64@npm:2.7.2"
conditions: os=linux & cpu=arm64
languageName: node
linkType: hard
"turbo-windows-64@npm:2.7.2":
version: 2.7.2
resolution: "turbo-windows-64@npm:2.7.2"
conditions: os=win32 & cpu=x64
languageName: node
linkType: hard
"turbo-windows-arm64@npm:2.7.2":
version: 2.7.2
resolution: "turbo-windows-arm64@npm:2.7.2"
conditions: os=win32 & cpu=arm64
languageName: node
linkType: hard
"turbo@npm:^2.7.2":
version: 2.7.2
resolution: "turbo@npm:2.7.2"
dependencies:
turbo-darwin-64: "npm:2.7.2"
turbo-darwin-arm64: "npm:2.7.2"
turbo-linux-64: "npm:2.7.2"
turbo-linux-arm64: "npm:2.7.2"
turbo-windows-64: "npm:2.7.2"
turbo-windows-arm64: "npm:2.7.2"
dependenciesMeta:
turbo-darwin-64:
optional: true
turbo-darwin-arm64:
optional: true
turbo-linux-64:
optional: true
turbo-linux-arm64:
optional: true
turbo-windows-64:
optional: true
turbo-windows-arm64:
optional: true
bin:
turbo: bin/turbo
checksum: 10c0/390937a32070ac52120af56705006e831de2edf8e22a2b0146006d07740cd413b3a36335339e7617b57cf74b008f4b15931cf56e1c7c0c03808f028ed937c4de
languageName: node
linkType: hard
"type-fest@npm:^0.21.3": "type-fest@npm:^0.21.3":
version: 0.21.3 version: 0.21.3
resolution: "type-fest@npm:0.21.3" resolution: "type-fest@npm:0.21.3"
@@ -20803,6 +20874,7 @@ __metadata:
prism-react-renderer: "npm:^2.4.1" prism-react-renderer: "npm:^2.4.1"
react: "npm:^19.2.3" react: "npm:^19.2.3"
react-dom: "npm:^19.2.3" react-dom: "npm:^19.2.3"
turbo: "npm:^2.7.2"
typescript: "npm:5.9.3" typescript: "npm:5.9.3"
webpack: "npm:5.104.1" webpack: "npm:5.104.1"
languageName: unknown languageName: unknown