Guide 18: Setting Up CI
Setting Up CI
Section titled “Setting Up CI”This guide documents setting up GitHub Actions for continuous integration with proper Turborepo task dependencies and Vercel deployment.
What We Did
Section titled “What We Did”Added a GitHub Actions CI workflow that runs type checking, linting, formatting, and tests on every push to main and pull request.
GitHub Actions Workflow
Section titled “GitHub Actions Workflow”Created .github/workflows/ci.yml with two parallel jobs:
name: CI
on: push: branches: [main] pull_request: branches: [main]
concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true
jobs: quality: name: Code Quality runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: oven-sh/setup-bun@v2 - run: bun install --frozen-lockfile - run: bun run check-types - run: bun run lint - run: bun run format:check
test: name: Tests runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: oven-sh/setup-bun@v2 - run: bun install --frozen-lockfile - run: bun run testTurborepo Configuration
Section titled “Turborepo Configuration”The key to making CI work was configuring turbo.json correctly:
{ "tasks": { "build": { "dependsOn": ["^build"], "outputs": [".next/**", "!.next/cache/**", "dist/**"] }, "check-types": { "dependsOn": ["^check-types", "^transit"] }, "test": { "dependsOn": ["transit"] }, "transit": { "dependsOn": ["^transit"] } }}Why transit Task?
Section titled “Why transit Task?”The vitest-config package exports TypeScript that needs to be compiled before other packages can use it. The transit task runs tsc to build these dependencies.
check-typesdepends on^transitso config packages are built firsttestdepends ontransitso vitest can load the compiled configbuildoutputs includedist/**for Astro builds (needed for Vercel caching)
Prettierignore Updates
Section titled “Prettierignore Updates”Added ignores for auto-generated files that conflict with formatting:
**/convex/_generated**/convex/**/_generated**/next-env.d.tsNext.js regenerates next-env.d.ts with semicolons, which conflicts with our Prettier config (no semicolons).
Vercel Deployment
Section titled “Vercel Deployment”The dist/** in turbo.json build outputs is critical for Vercel deployment:
- Vercel uses Turborepo caching
- When cache hits, outputs must be restored correctly
- Without
dist/**, the Astro docs build output wasn’t restored
Files Changed
Section titled “Files Changed”| Action | Files |
|---|---|
| Created | .github/workflows/ci.yml |
| Modified | turbo.json |
| Modified | .prettierignore |
| Created | apps/docs/vercel.json |
| Modified | packages/vitest-config/* |
Verification
Section titled “Verification”# Run all CI checks locallybun run check-typesbun run lintbun run format:checkbun run testContext for AI
Section titled “Context for AI”When CI fails:
- Type errors: Check if
transittask ran first (turbo check-typeshandles this) - Format errors: Run
bun formatto fix, check.prettierignorefor generated files - Test errors: Ensure
vitest-configis built (turbo testhandles this) - Vercel build fails: Check
turbo.jsonoutputs include the build directory