Skip to content

Commit

Permalink
feat: ✨ add turbo for caching and task parallelization (#105)
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmy-guzman authored Aug 22, 2024
1 parent 9d7ca78 commit a6d5442
Show file tree
Hide file tree
Showing 8 changed files with 94 additions and 36 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ jobs:
e2e:
if: github.event.deployment_status.state == 'success'
runs-on: ubuntu-latest
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ vars.TURBO_TEAM }}

steps:
- name: 🏗 Setup Repository
Expand All @@ -18,6 +21,6 @@ jobs:
run: bunx playwright install --with-deps

- name: ✅ e2e
run: bun run e2e
run: bun turbo e2e
env:
BASE_URL: ${{ github.event.deployment_status.environment_url }}
24 changes: 6 additions & 18 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ name: pull_request
on: [pull_request]

jobs:
validate:
check:
runs-on: ubuntu-latest
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ vars.TURBO_TEAM }}

steps:
- name: 🏗 Setup Repository
Expand All @@ -13,20 +16,5 @@ jobs:
- name: 📦 Install
uses: ./.github/actions/install

- name: 🚨 Lint
run: bun run lint

- name: 🎨 Format
run: bun run format

- name: 🏷️ Check Types
run: bun run typecheck

- name: ✅ Test
run: bun run coverage

- name: 🧱 Build
run: bun run build

- name: 🧱 Stories Build
run: bun run sb:build
- name: 🚨 Check
run: bun check
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,6 @@ storybook-static

# env
.env*

# turbo
.turbo
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"tailwindcss",
"tanstack",
"tiged",
"turborepo",
"typecheck",
"vite",
"vitest",
Expand Down
44 changes: 27 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- 🩺 [eslint][eslint] for static analysis.
- 🎨 [prettier][prettier] for formatting.
- 🩺 [lefthook][lefthook] for fast Git hooks management.
- 👷 [Turborepo](https://turbo.build/repo/docs) for caching and task parallelization.
- 👷 [GitHub Actions][GitHub Actions] for easy workflow automation.

## 🛠️ Usage
Expand Down Expand Up @@ -45,7 +46,7 @@ bun install
Or if you already have `bun` installed you upgrade, by running the following command:

```
bun upgrade --stable
bun upgrade --stable
```

And to download new browsers for Playwright, run the following command:
Expand All @@ -54,31 +55,40 @@ And to download new browsers for Playwright, run the following command:
bunx playwright install
```

And install Turborepo, run the following command:

```
bun install --global turbo
```

Then to run the development server, run the following command:

```
bun dev
turbo dev
```

Your application will be available at http://localhost:5173/ ❤️

## 🧞 Available Tasks

| Command | Action |
| :------------------- | :------------------------------------------------------- |
| `bun install` | Installs dependencies |
| `bun run dev` | Starts local dev server at http://localhost:5173/ |
| `bun run build` | Build your production site to `./dist/` |
| `bun run preview` | Preview your build locally, before deploying |
| `bun run test` | Unit tests your code with vitest |
| `bun run e2e` | E2E tests your code with playwright |
| `bun run lint` | Lints everything with eslint |
| `bun run lint:fix` | Fixes lint errors with eslint |
| `bun run format` | Checks formatting with prettier |
| `bun run format:fix` | Fixes formatting errors with prettier |
| `bun run typecheck` | Checks types with TypeScript |
| `bun run sb` | Starts storybook at http://localhost:6006 |
| `bun run sb:build` | Build your production storybook to `./storybook-static/` |
| Command | Action |
| :----------------- | :------------------------------------------------------- |
| `bun install` | Installs dependencies |
| `turbo dev` | Starts local dev server at http://localhost:5173/ |
| `turbo build` | Build your production site to `./dist/` |
| `turbo preview` | Preview your build locally, before deploying |
| `turbo test` | Unit tests your code with vitest |
| `turbo e2e` | E2E tests your code with playwright |
| `turbo lint` | Lints everything with eslint |
| `turbo lint:fix` | Fixes lint errors with eslint |
| `turbo format` | Checks formatting with prettier |
| `turbo format:fix` | Fixes formatting errors with prettier |
| `turbo typecheck` | Checks types with TypeScript |
| `turbo sb` | Starts storybook at http://localhost:6006 |
| `turbo sb:build` | Build your production storybook to `./storybook-static/` |
| `turbo check` | Checks everything |

_You can also run all tasks with `bun run`, i.e `bun run dev`_

## 💡 Recommendations

Expand Down
Binary file modified bun.lockb
Binary file not shown.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"type": "module",
"scripts": {
"build": "bunx --bun vite build",
"check": "turbo format lint typecheck coverage build sb:build",
"coverage": "vitest run --coverage",
"dev": "vite",
"e2e": "playwright test",
Expand Down Expand Up @@ -74,6 +75,7 @@
"prettier": "3.3.3",
"storybook": "8.2.9",
"tailwindcss": "3.4.10",
"turbo": "2.0.14",
"typescript": "5.4.5",
"vite": "5.4.2",
"vite-tsconfig-paths": "5.0.1",
Expand Down
51 changes: 51 additions & 0 deletions turbo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
"$schema": "https://turbo.build/schema.v2.json",
"tasks": {
"build": {
"outputs": ["dist/**"]
},
"typecheck": {
"dependsOn": ["^typecheck"]
},
"format": {
"dependsOn": ["^format"]
},
"format:fix": {
"dependsOn": ["^format:fix"]
},
"lint": {
"dependsOn": ["^lint"]
},
"lint:fix": {
"dependsOn": ["^lint:fix"]
},
"test": {
"persistent": true,
"cache": false
},
"coverage": {
"outputs": ["coverage/**"],
"dependsOn": ["^coverage"]
},
"preview": {
"persistent": true,
"cache": false
},
"dev": {
"persistent": true,
"cache": false
},
"sb": {
"persistent": true,
"cache": false
},
"sb:build": {
"outputs": ["storybook-static/**"]
},
"e2e": {
"env": ["BASE_URL"],
"passThroughEnv": ["BASE_URL"],
"outputs": ["playwright-report/**", "test-results/**"]
}
}
}

0 comments on commit a6d5442

Please sign in to comment.