diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..78f20185 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,67 @@ +# Web CI gate. +# +# Runs the repository quality checks (CONTRIBUTING.md) on every pull request and +# on every push to main. Vercel deploys main and pull request branches without a +# build gate, so this workflow is the check to require on main. +# +# The job name "Lint, Type-check, Test" is the status check to require. + +name: CI + +on: + pull_request: + push: + branches: + - main + +concurrency: + group: ci-${{ github.ref }} + cancel-in-progress: true + +permissions: + contents: read + +env: + # prisma generate runs on postinstall and reads DATABASE_URL from + # prisma.config.ts. The client generator does not connect, so a placeholder + # value is enough. + DATABASE_URL: postgresql://user:password@localhost:5432/cache + +jobs: + checks: + name: Lint, Type-check, Test + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0 + with: + # The checks read the tree only; they never push, so do not leave the + # workflow token in the local git config for an install script to read. + persist-credentials: false + + - name: Setup Bun + uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0 + with: + bun-version: 1.4.2 + + - name: Setup Node.js + uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 + with: + node-version-file: .nvmrc + + - name: Install dependencies + run: bun install --frozen-lockfile + + - name: Lint + run: bun run lint + + # next typegen writes next-env.d.ts and .next/types. tsc reads them to + # resolve image imports and route types, so type-check needs them first. + - name: Generate Next.js types + run: bunx next typegen + + - name: Type-check + run: bun run type-check + + - name: Test + run: bun run test diff --git a/package.json b/package.json index 8bf2c735..4d72fede 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "type": "module", "scripts": { "analyze": "next experimental-analyze", - "build": "bunx gt translate && bun run next build", + "build": "bunx gt translate --ignore-errors && bun run next build", "clean": "find . -name node_modules -o -name .next -o -name .swc -o -name tsconfig.buildinfo -type d -prune | xargs rm -rf", "db-deploy": "prisma migrate deploy", "db-migrate": "prisma migrate dev",