ci: add GitHub Actions workflow for PR validation (#26)
* ci: add GitHub Actions workflow for PR validation
Adds CI workflow that mirrors local git hooks:
- Lint: oxlint checks for code quality issues
- Typecheck: TypeScript validation (continue-on-error due to 32 baseline errors)
- Test: Full test suite with PostgreSQL 17 service
Features:
- Parallel job execution for faster feedback
- pnpm store caching for speed
- PostgreSQL service container for integration tests
- Triggers on pull requests and pushes to main
* fix: resolve all 35 TypeScript build errors
Fixes all baseline TypeScript errors blocking CI/CD builds.
**Changes:**
1. **OAuth test fixes (11 errors) - apps/appview/src/lib/__tests__/oauth-stores.test.ts:**
- Fixed NodeSavedState: dpopKey → dpopJwk, added required iss property
- Fixed TokenSet: added required iss and aud properties
- Removed invalid serverMetadata property from NodeSavedSession
2. **Lexicon generator update (23 errors) - packages/lexicon/package.json:**
- Upgraded @atproto/lex-cli: 0.5.0 → 0.9.8
- Fixes 'v is unknown' errors (now uses proper generics)
3. **TypeScript config (16 errors) - tsconfig.base.json:**
- Changed module: "Node16" → "ESNext"
- Changed moduleResolution: "Node16" → "bundler"
- Fixes missing .js extension errors in generated lexicon code
- "bundler" mode appropriate for monorepo with build tools
4. **App context fix (1 error) - apps/appview/src/lib/app-context.ts:**
- Fixed requestLock signature: fn: () => Promise<T> → fn: () => T | PromiseLike<T>
- Wrapped fn() call in Promise.resolve() to normalize return type
- Matches NodeOAuthClient's Awaitable<T> requirement
**Result:** Clean build - all 4 packages compile successfully.
Root causes: Library type definition updates (OAuth), code generator
limitations (lexicon), and type signature mismatches (app-context).
* ci: run database migrations before tests
Add database migration step to test workflow to ensure
PostgreSQL schema is created before tests run.
Fixes password authentication error that was actually caused
by missing database schema.
* fix: merge process.env with .env in vitest config
Vitest's env config was replacing process.env with .env file contents.
In CI, there's no .env file, so DATABASE_URL from GitHub Actions
wasn't reaching the tests.
Now we merge both sources, with process.env taking precedence,
so CI environment variables work correctly.
* fix: only override vitest env when .env file exists
Previous fix attempted to merge but process.env spread might
not work as expected in vitest config context.
New approach: only set env config if we found a .env file.
In CI (no .env file), vitest will use process.env naturally,
which includes DATABASE_URL from GitHub Actions workflow.
* fix: load ALL env vars with empty prefix in loadEnv
loadEnv by default only loads VITE_* prefixed variables.
Pass empty string as prefix to load all variables including
DATABASE_URL from .env file.
* fix: use vitest setup file to load .env without replacing process.env
Instead of using vitest's 'env' config (which replaces process.env),
use a setup file that loads .env into process.env using dotenv.
This way:
- Local dev: .env file is loaded into process.env
- CI: GitHub Actions env vars pass through naturally
- dotenv.config() won't override existing env vars
Add dotenv and vite as devDependencies.
Keep debug logging to verify DATABASE_URL is set.
* fix: configure Turbo to pass DATABASE_URL to test tasks
Turbo blocks environment variables by default for cache safety.
Tests were failing because DATABASE_URL wasn't being passed through.
Add DATABASE_URL to test task env configuration so it's available
to vitest in both local dev and CI.
This was the root cause all along - vitest setup, GitHub Actions config,
and migrations were all correct. Turbo was blocking the env var!
* fix: make vitest.setup.ts work in both main repo and worktrees
The .env file path resolution needs to handle two cases:
- Main repo: apps/appview -> ../../.env
- Worktree: .worktrees/branch/apps/appview -> ../../../../.env
Added fallback logic to try both paths.
* docs: add Turbo environment variable passthrough guidance to Testing Standards
Documents critical non-obvious behavior where Turbo blocks env vars by default
for cache safety. Tests requiring env vars must declare them in turbo.json.
Includes symptoms, explanation, and when to update configuration.