From 46ea325bd3ad815ce8949c78f1e929d78aab6e2e Mon Sep 17 00:00:00 2001 From: Alexandre Philibeaux Date: Fri, 12 Jul 2024 09:26:10 +0000 Subject: [PATCH] feat(turbo): add turbo config Signed-off-by: Alexandre Philibeaux --- .github/workflows/ci.yml | 59 ++++++++++++++-------- .github/workflows/pull_request_title.yml | 4 +- .github/workflows/size-limit.yml | 8 +-- .gitignore | 7 +++ package.json | 31 +++--------- packages/form/package.json | 2 +- packages/icons/package.json | 2 +- packages/illustrations/package.json | 2 +- packages/plus/package.json | 2 +- packages/ui/package.json | 2 +- pnpm-lock.yaml | 64 ++++++++++++++++++++++++ turbo.json | 42 ++++++++++++++++ 12 files changed, 170 insertions(+), 55 deletions(-) create mode 100644 turbo.json diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6b7d05f3ea..3e0ed7a2d0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,10 +19,12 @@ jobs: with: node-version: 20 cache: "pnpm" - - run: pnpm install - - run: pnpm run build - - run: pnpm install - - run: pnpm typecheck + - run: | + pnpm install + pnpm typecheck + env: + TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} + lint: runs-on: ubuntu-22.04 steps: @@ -33,10 +35,13 @@ jobs: with: node-version: 20 cache: "pnpm" - - run: pnpm install - - run: pnpm run build - - run: pnpm install - - run: pnpm run lint + - run: | + pnpm install + pnpm run build + pnpm run lint + env: + TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} + format: runs-on: ubuntu-22.04 steps: @@ -47,10 +52,14 @@ jobs: with: node-version: 20 cache: "pnpm" - - run: pnpm install - - run: pnpm run build - - run: pnpm install - - run: pnpm run format:ci + - run: | + pnpm install + pnpm run build + pnpm run lint + pnpm run format:ci + env: + TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} + test: runs-on: ubuntu-22.04 needs: [lint, typecheck, format] @@ -67,10 +76,12 @@ jobs: with: node-version: ${{ matrix.node }} cache: "pnpm" - - run: pnpm install - - run: pnpm run build - - run: pnpm install - - run: pnpm run test:unit:coverage + - run: | + pnpm install + pnpm run build + pnpm run test:unit:coverage + env: + TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} - uses: codecov/codecov-action@v4.5.0 with: # files: packages/**/coverage/cobertura-coverage.xmls @@ -106,8 +117,11 @@ jobs: uses: actions/setup-node@v4.0.3 with: node-version: ${{ matrix.node }} - - run: pnpm install - - run: pnpm run build + - run: | + pnpm install + pnpm run build + env: + TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} build-examples: # This will build all projects in the examples folder, it assures that all examples are working strategy: matrix: @@ -121,7 +135,8 @@ jobs: uses: actions/setup-node@v4.0.3 with: node-version: ${{ matrix.node }} - - run: pnpm install - - run: pnpm build - - run: pnpm install - - run: pnpm run build:examples + - run: | + pnpm install + pnpm run build:examples + env: + TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} diff --git a/.github/workflows/pull_request_title.yml b/.github/workflows/pull_request_title.yml index b360afb5ee..68898a6d1c 100644 --- a/.github/workflows/pull_request_title.yml +++ b/.github/workflows/pull_request_title.yml @@ -7,14 +7,14 @@ jobs: check-title: runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@v4 # v4.1.4 + - uses: actions/checkout@v4 - uses: pnpm/action-setup@v4.0.0 - name: Use Node.js uses: actions/setup-node@v4.0.3 with: node-version: 20 cache: "pnpm" - - run: pnpm install + - run: pnpm install --prod - name: Check PR title env: TITLE: ${{ github.event.pull_request.title }} diff --git a/.github/workflows/size-limit.yml b/.github/workflows/size-limit.yml index b09265c144..a559b2e20f 100644 --- a/.github/workflows/size-limit.yml +++ b/.github/workflows/size-limit.yml @@ -15,6 +15,8 @@ jobs: uses: actions/setup-node@v4.0.3 with: node-version: ${{ matrix.node }} - - run: pnpm install - - run: pnpm run build - - run: pnpm run size:packages + - run: | + pnpm install + pnpm run size + env: + TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} diff --git a/.gitignore b/.gitignore index 249ca39684..2fab8232ec 100644 --- a/.gitignore +++ b/.gitignore @@ -35,3 +35,10 @@ out #vite vite.config.ts.* vitest.config.ts.* + +# turbo +.turbo +!.turbo/config.json +examples/*/.turbo +packages/*/.turbo +tools/*/.turbo \ No newline at end of file diff --git a/package.json b/package.json index 01305bf156..ba379875e6 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "examples/*", "utils/*" ], - "packageManager": "pnpm@9.4.0", + "packageManager": "pnpm@9.5.0", "engines": { "node": ">=18.x", "pnpm": ">=9.x" @@ -17,11 +17,12 @@ "linux" ], "scripts": { - "build": "pnpm --filter '@ultraviolet/*' recursive run build", - "build:example": "pnpm --filter '@examples/*' recursive run build", + "build": "turbo build --filter='!./examples/*'", + "size": "turbo run size --filter='@ultraviolet/*'", + "build:examples": "turbo build --filter '@examples/*' ", + "typecheck": "turbo typecheck --filter='!./examples/*' ", "build:storybook": "pnpm run build && STORYBOOK_ENVIRONMENT=production storybook build", "build:storybook:stats": "pnpm run build:storybook --webpack-stats-json", - "build:examples": "pnpm --filter '{examples/**}' recursive exec -- pnpm run build", "check:deps": "npx depcheck . --skip-missing=true --ignores='bin,eslint,vite,jest,husky,@commitlint/*,@babel/*,babel-*'", "commit": "npx git-cz -a --disable-emoji", "start": "STORYBOOK_ENVIRONMENT=development storybook dev -p 6006", @@ -31,16 +32,13 @@ "lint:fix": "pnpm run lint --fix", "lint": "eslint --report-unused-disable-directives --cache .", "prebuild": "pnpm --filter '@ultraviolet/*' recursive run prebuild", - "test:unit": "pnpm --filter '@ultraviolet/*' recursive run test:unit", - "test:unit:coverage": "pnpm --filter '@ultraviolet/*' recursive run test:unit:coverage", + "test:unit": "turbo test:unit --filter='@ultraviolet/*' ", + "test:unit:coverage": "turbo test:unit:coverage --filter='@ultraviolet/*' ", "prepare": "husky", - "size": "pnpm run build && size-limit", - "size:packages": "pnpm --filter '@ultraviolet/*' recursive run size", "tokens:update": "node ./scripts/figma-synchronise-tokens.mjs && pnpm run format packages/themes/src/themes/console", "release": "pnpm build && pnpm changeset publish", "svg": "npx svgo --pretty --multipass", "svg:all": "pnpm run svg -r -f .", - "typecheck": "pnpm --filter '@ultraviolet/*' recursive run typecheck", "illustrations:update": "BUCKET_NAME=ultraviolet BUCKET_REGION=fr-par node utils/illustrations/uploadIllustrations.js && pnpm format packages/illustrations/src/" }, "lint-staged": { @@ -68,20 +66,6 @@ "@commitlint/config-conventional" ] }, - "size-limit": [ - { - "path": [ - "packages/*/dist/**/*.js", - "!packages/illustrations", - "!packages/plus", - "!packages/icons" - ], - "limit": "500 kB", - "webpack": false, - "brotli": true, - "running": false - } - ], "pnpm": { "overrides": { "vite": "$vite" @@ -179,6 +163,7 @@ "size-limit": "11.1.4", "storybook": "8.1.11", "timekeeper": "2.3.1", + "turbo": "2.0.6", "typescript": "5.5.3", "vite": "5.3.3", "vitest": "1.6.0", diff --git a/packages/form/package.json b/packages/form/package.json index 2ef94c7594..93b1410cf8 100644 --- a/packages/form/package.json +++ b/packages/form/package.json @@ -12,7 +12,7 @@ "build:profile": "npx vite-bundle-visualizer -c vite.config.ts", "build": "vite build --config vite.config.ts && pnpm run type:generate", "prebuild": "shx rm -rf dist", - "size": "pnpm run build && size-limit", + "size": "size-limit", "test:unit:coverage": "pnpm test:unit --coverage", "test:unit": "LC_ALL=en_US.UTF-8 pnpm vitest --run --config vite.config.ts", "type:generate": "tsc --declaration -p tsconfig.build.json", diff --git a/packages/icons/package.json b/packages/icons/package.json index 214210e6c0..bec9f5539b 100644 --- a/packages/icons/package.json +++ b/packages/icons/package.json @@ -16,7 +16,7 @@ "build": "vite build --config vite.config.ts && pnpm run type:generate", "build:profile": "npx vite-bundle-visualizer -c vite.config.ts", "typecheck": "tsc --noEmit", - "size": "pnpm run build && size-limit" + "size": "size-limit" }, "keywords": [ "react", diff --git a/packages/illustrations/package.json b/packages/illustrations/package.json index 0e9f7602a6..f554502fcd 100644 --- a/packages/illustrations/package.json +++ b/packages/illustrations/package.json @@ -16,7 +16,7 @@ "build": "vite build --config vite.config.ts && pnpm run type:generate", "build:profile": "npx vite-bundle-visualizer -c vite.config.ts", "typecheck": "tsc --noEmit", - "size": "pnpm run build && size-limit", + "size": "size-limit", "test:unit": "LC_ALL=en_US.UTF-8 pnpm vitest --run --config vite.config.ts", "test:unit:coverage": "pnpm test:unit --coverage" }, diff --git a/packages/plus/package.json b/packages/plus/package.json index 26242e5e30..ecfb841826 100644 --- a/packages/plus/package.json +++ b/packages/plus/package.json @@ -16,7 +16,7 @@ "build": "vite build --config vite.config.ts && pnpm run type:generate", "build:profile": "npx vite-bundle-visualizer -c vite.config.ts", "typecheck": "tsc --noEmit", - "size": "pnpm run build && size-limit", + "size": "size-limit", "test:unit": "LC_ALL=en_US.UTF-8 pnpm vitest --run --config vite.config.ts", "test:unit:coverage": "pnpm test:unit --coverage" }, diff --git a/packages/ui/package.json b/packages/ui/package.json index 64a1cb540e..4e4c9d6bcc 100644 --- a/packages/ui/package.json +++ b/packages/ui/package.json @@ -16,7 +16,7 @@ "build": "vite build --config vite.config.ts && pnpm run type:generate", "build:profile": "npx vite-bundle-visualizer -c vite.config.ts", "typecheck": "tsc --noEmit", - "size": "pnpm run build && size-limit", + "size": "size-limit", "test:unit": "LC_ALL=en_US.UTF-8 pnpm vitest --run --config vite.config.ts", "test:unit:coverage": "pnpm test:unit --coverage" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 0768a67a8c..4e9a2f9a89 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -266,6 +266,9 @@ importers: timekeeper: specifier: 2.3.1 version: 2.3.1 + turbo: + specifier: 2.0.6 + version: 2.0.6 typescript: specifier: 5.5.3 version: 5.5.3 @@ -8468,6 +8471,40 @@ packages: peerDependencies: typescript: '>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta' + turbo-darwin-64@2.0.6: + resolution: {integrity: sha512-XpgBwWj3Ggmz/gQVqXdMKXHC1iFPMDiuwugLwSzE7Ih0O13JuNtYZKhQnopvbDQnFQCeRq2Vsm5OTWabg/oB/g==} + cpu: [x64] + os: [darwin] + + turbo-darwin-arm64@2.0.6: + resolution: {integrity: sha512-RfeZYXIAkiA21E8lsvfptGTqz/256YD+eI1x37fedfvnHFWuIMFZGAOwJxtZc6QasQunDZ9TRRREbJNI68tkIw==} + cpu: [arm64] + os: [darwin] + + turbo-linux-64@2.0.6: + resolution: {integrity: sha512-92UDa0xNQQbx0HdSp9ag3YSS3xPdavhc7q9q9mxIAcqyjjD6VElA4Y85m4F/DDGE5SolCrvBz2sQhVmkOd6Caw==} + cpu: [x64] + os: [linux] + + turbo-linux-arm64@2.0.6: + resolution: {integrity: sha512-eQKu6utCVUkIH2kqOzD8OS6E0ba6COjWm6PRDTNCHQRljZW503ycaTUIdMOiJrVg1MkEjDyOReUg8s8D18aJ4Q==} + cpu: [arm64] + os: [linux] + + turbo-windows-64@2.0.6: + resolution: {integrity: sha512-+9u4EPrpoeHYCQ46dRcou9kbkSoelhOelHNcbs2d86D6ruYD/oIAHK9qgYK8LeARRz0jxhZIA/dWYdYsxJJWkw==} + cpu: [x64] + os: [win32] + + turbo-windows-arm64@2.0.6: + resolution: {integrity: sha512-rdrKL+p+EjtdDVg0wQ/7yTbzkIYrnb0Pw4IKcjsy3M0RqUM9UcEi67b94XOAyTa5a0GqJL1+tUj2ebsFGPgZbg==} + cpu: [arm64] + os: [win32] + + turbo@2.0.6: + resolution: {integrity: sha512-/Ftmxd5Mq//a9yMonvmwENNUN65jOVTwhhBPQjEtNZutYT9YKyzydFGLyVM1nzhpLWahQSMamRc/RDBv5EapzA==} + hasBin: true + type-check@0.4.0: resolution: {integrity: sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==} engines: {node: '>= 0.8.0'} @@ -18930,6 +18967,33 @@ snapshots: tslib: 1.14.1 typescript: 5.5.3 + turbo-darwin-64@2.0.6: + optional: true + + turbo-darwin-arm64@2.0.6: + optional: true + + turbo-linux-64@2.0.6: + optional: true + + turbo-linux-arm64@2.0.6: + optional: true + + turbo-windows-64@2.0.6: + optional: true + + turbo-windows-arm64@2.0.6: + optional: true + + turbo@2.0.6: + optionalDependencies: + turbo-darwin-64: 2.0.6 + turbo-darwin-arm64: 2.0.6 + turbo-linux-64: 2.0.6 + turbo-linux-arm64: 2.0.6 + turbo-windows-64: 2.0.6 + turbo-windows-arm64: 2.0.6 + type-check@0.4.0: dependencies: prelude-ls: 1.2.1 diff --git a/turbo.json b/turbo.json new file mode 100644 index 0000000000..834d91dc20 --- /dev/null +++ b/turbo.json @@ -0,0 +1,42 @@ +{ + "$schema": "https://turbo.build/schema.json", + "globalDependencies": ["tsconfig.json"], + "ui": "stream", + "globalEnv": [ + "STORYBOOK_ENVIRONMENT", + "ENVIRONMENT", + "NODE_ENV", + "VERSION", + "PROXY", + "RELEASE_NAME" + ], + "tasks": { + "build": { + "dependsOn": ["^build"], + "outputs": [ + "build/**", + "dist/**", + ".next/**", + "!.next/cache/**", + "out/**" + ] + }, + "size": { + "dependsOn": ["^build"] + }, + "size:packages": { + "dependsOn": ["^build"] + }, + "typecheck": { + "dependsOn": ["^build"] + }, + "test:unit": { + "dependsOn": ["^build"], + "passThroughEnv": ["VITEST_*"] + }, + "test:unit:coverage": { + "dependsOn": ["^build"], + "passThroughEnv": ["VITEST_*"] + } + } +}