Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions .github/workflows/typecheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Typecheck

# Runs `yarn typecheck` from the repository root, which invokes
# `tsc --noEmit` in every TypeScript workspace. Complements the existing
# Lint and Test workflows (which do not run tsc) and catches type errors in
# seconds instead of waiting for the slow Docker-image build in pr-gate.yml.
#
# The web workspace is excluded here because `tsc --noEmit` in `packages/web`
# depends on `.next/types/**/*.ts` (declared in its tsconfig.json `include`)
# being generated by `next build`. Web is already type-checked transitively
# via the Docker build in pr-gate.yml. See issue #1437.

on:
pull_request:
branches: ["main"]


jobs:
typecheck:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: "true"

- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: '20.x'
cache: 'yarn'
cache-dependency-path: '**/yarn.lock'

- name: Install
run: yarn install --frozen-lockfile

# Build the type-source-of-truth workspaces first (schemas, db, shared,
# query-language) so their generated .d.ts files are fresh. Without
# this step, downstream workspaces see stale types and `tsc --noEmit`
# surfaces drift as errors.
- name: Build dependencies
run: yarn build:deps

# The db workspace's generated Prisma client must exist before its
# typecheck runs. Without this step, db's typecheck reports errors
# because the source-of-truth schema is newer than the generated client.
- name: Generate Prisma client
run: yarn workspace @sourcebot/db prisma:generate

# Excludes @sourcebot/web (see comment above). Runs tsc --noEmit in
# each remaining workspace in topological order.
- name: Typecheck
run: yarn workspaces foreach --all --topological --exclude @sourcebot/web run typecheck
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"build": "cross-env SKIP_ENV_VALIDATION=1 yarn workspaces foreach --all --topological run build",
"test": "yarn workspaces foreach --all --topological run test",
"lint": "yarn workspaces foreach --all --topological run lint",
"typecheck": "yarn workspaces foreach --all --topological run typecheck",
Comment thread
Harsh23Kashyap marked this conversation as resolved.
"dev": "concurrently --kill-others --names \"zoekt,worker,web,schemas\" 'yarn dev:zoekt' 'yarn dev:backend' 'yarn dev:web' 'yarn watch:schemas'",
"with-env": "cross-env PATH=\"$PWD/bin:$PATH\" dotenv -e .env.development -c --",
"dev:zoekt": "yarn with-env zoekt-webserver -index .sourcebot/index -rpc",
Expand Down
1 change: 1 addition & 0 deletions packages/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"dev:watch": "tsc-watch --preserveWatchOutput --onSuccess \"yarn dev\"",
"dev": "node ./dist/index.js",
"build": "tsc",
"typecheck": "tsc --noEmit",
"test": "cross-env SKIP_ENV_VALIDATION=1 vitest --config ./vitest.config.ts"
},
"devDependencies": {
Expand Down
1 change: 1 addition & 0 deletions packages/db/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"private": true,
"scripts": {
"build": "yarn prisma:generate && tsc",
"typecheck": "tsc --noEmit",
Comment thread
Harsh23Kashyap marked this conversation as resolved.
"postinstall": "yarn build",
"prisma:generate": "prisma generate",
"prisma:generate:watch": "prisma generate --watch",
Expand Down
1 change: 1 addition & 0 deletions packages/schemas/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"private": true,
"scripts": {
"build": "yarn generate && tsc",
"typecheck": "tsc --noEmit",
Comment thread
Harsh23Kashyap marked this conversation as resolved.
"generate": "tsx tools/generate.ts",
"watch": "nodemon --watch ../../schemas -e json -x 'yarn build'",
"postinstall": "yarn build"
Expand Down
1 change: 1 addition & 0 deletions packages/shared/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"private": true,
"scripts": {
"build": "tsc",
"typecheck": "tsc --noEmit",
"build:watch": "tsc-watch --preserveWatchOutput",
"postinstall": "yarn build",
"test": "vitest --config ./vitest.config.ts",
Expand Down
1 change: 1 addition & 0 deletions packages/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"build": "cross-env SKIP_ENV_VALIDATION=1 next build",
"start": "next start",
"lint": "cross-env SKIP_ENV_VALIDATION=1 eslint .",
"typecheck": "tsc --noEmit",
"test": "cross-env SKIP_ENV_VALIDATION=1 vitest",
"openapi:generate": "tsx tools/generateOpenApi.ts",
"generate:protos": "proto-loader-gen-types --includeComments --longs=Number --enums=String --defaults --oneofs --grpcLib=@grpc/grpc-js --keepCase --includeDirs=../../vendor/zoekt/grpc/protos --outDir=src/proto zoekt/webserver/v1/webserver.proto zoekt/webserver/v1/query.proto",
Expand Down