fix(ci): early-exit do types:gen no CI sem SUPABASE_PROJECT_ID#122
Conversation
Bug pré-existente que vinha quebrando o CI test step (Build) há vários PRs: $ bash scripts/validate-supabase-types.sh⚠️ SUPABASE_PROJECT_ID not set 🔄 Generating Supabase types... WARN: no seed files matched pattern: supabase/seed.sql Missing required field in config: project_id error: script "types:gen" exited with code 1 Causa raiz: em CI, sem SUPABASE_PROJECT_ID setada, o script caía no branch 'elif [ -d supabase ] && docker ps' (pasta supabase/ existe + GitHub Actions runner tem docker), tentando 'supabase gen types typescript --local'. Mas --local exige uma instância Supabase rodando localmente (com 'supabase start') que não existe no CI runner. Resultado: falha 'Missing required field in config: project_id' e build aborted. Fix: early-exit no script quando CI=true e SUPABASE_PROJECT_ID não está setada. Confia no types.ts commitado (gerado localmente via --db-url, source-of-truth do projeto self-hosted). Padrão coerente com supabase/config.toml que já documenta o setup self-hosted desde a Onda 6 (PR #115). Comportamentos validados localmente: ✅ CI=true sem PROJECT_ID (cenário do bug) → exit 0 (usa types.ts commitado) ✅ CI=true --check --summary (check-mode) → exit 0 (valida arquivo presente) ✅ Dev local (CI unset) → fluxo antigo preservado ✅ CI=true bun run prebuild (full) → exit 0 + component registry OK Resolve a 1ª das 3 pendências mapeadas após Onda 8 fechada. Refs: - Onda 6 PR #115 (config.toml self-hosted): 0f10ab4 - Onda 8 PR #121 (lint passing): 21fba6f - Falhas em main desde antes do PR #114 (todos os builds falhavam por isso)
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
WalkthroughO script de validação de tipos Supabase agora inclui um branch antecipado em CI quando credenciais não estão disponíveis. Sem AlteraçõesLógica de Saída Antecipada em CI
Estimativa de Esforço de Review🎯 2 (Simples) | ⏱️ ~8 minutos 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@scripts/validate-supabase-types.sh`:
- Around line 58-64: The gen-mode early-exit currently uses a plain -f check
against TYPES_FILE which lets an empty/corrupt types.ts pass; change the
condition to test both existence and non-empty content (use -s "$TYPES_FILE") so
the CI prebuild path only succeeds when TYPES_FILE has size >0. Update the if
branch that checks "$TYPES_FILE" (the gen-mode block) to use -s instead of -f
and keep the same success/failure echo and exit behavior so downstream steps
won’t be masked by an empty file.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: a1f21c33-3e3c-4ea9-8fe3-f4ee592479d0
📒 Files selected for processing (1)
scripts/validate-supabase-types.sh
| # gen-mode (prebuild): trust committed file, skip generation | ||
| if [ -f "$TYPES_FILE" ]; then | ||
| echo "ℹ️ CI without SUPABASE_PROJECT_ID — using committed $TYPES_FILE (self-hosted setup, types are committed)." | ||
| exit 0 | ||
| else | ||
| echo "❌ Error: $TYPES_FILE not found in CI and no SUPABASE_PROJECT_ID set." | ||
| exit 1 |
There was a problem hiding this comment.
Evite aceitar types.ts vazio no early-exit de gen-mode
No fluxo de prebuild em CI, o bloco de Line 59 valida só -f. Se types.ts existir mas estiver vazio/corrompido, o script sai com sucesso e pode esconder problema até etapas posteriores. Alinhe com o check-mode exigindo também -s.
Patch sugerido
- if [ -f "$TYPES_FILE" ]; then
+ if [ -f "$TYPES_FILE" ] && [ -s "$TYPES_FILE" ]; then
echo "ℹ️ CI without SUPABASE_PROJECT_ID — using committed $TYPES_FILE (self-hosted setup, types are committed)."
exit 0
else
- echo "❌ Error: $TYPES_FILE not found in CI and no SUPABASE_PROJECT_ID set."
+ echo "❌ Error: $TYPES_FILE missing or empty in CI and no SUPABASE_PROJECT_ID set."
exit 1
fi📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| # gen-mode (prebuild): trust committed file, skip generation | |
| if [ -f "$TYPES_FILE" ]; then | |
| echo "ℹ️ CI without SUPABASE_PROJECT_ID — using committed $TYPES_FILE (self-hosted setup, types are committed)." | |
| exit 0 | |
| else | |
| echo "❌ Error: $TYPES_FILE not found in CI and no SUPABASE_PROJECT_ID set." | |
| exit 1 | |
| # gen-mode (prebuild): trust committed file, skip generation | |
| if [ -f "$TYPES_FILE" ] && [ -s "$TYPES_FILE" ]; then | |
| echo "ℹ️ CI without SUPABASE_PROJECT_ID — using committed $TYPES_FILE (self-hosted setup, types are committed)." | |
| exit 0 | |
| else | |
| echo "❌ Error: $TYPES_FILE missing or empty in CI and no SUPABASE_PROJECT_ID set." | |
| exit 1 | |
| fi |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@scripts/validate-supabase-types.sh` around lines 58 - 64, The gen-mode
early-exit currently uses a plain -f check against TYPES_FILE which lets an
empty/corrupt types.ts pass; change the condition to test both existence and
non-empty content (use -s "$TYPES_FILE") so the CI prebuild path only succeeds
when TYPES_FILE has size >0. Update the if branch that checks "$TYPES_FILE" (the
gen-mode block) to use -s instead of -f and keep the same success/failure echo
and exit behavior so downstream steps won’t be masked by an empty file.
There was a problem hiding this comment.
Pull request overview
This PR fixes a CI failure in the prebuild pipeline by preventing scripts/validate-supabase-types.sh from attempting local Supabase type generation on CI runners when SUPABASE_PROJECT_ID isn’t configured (self-hosted setup), and instead trusting the committed src/integrations/supabase/types.ts.
Changes:
- Add an early-exit branch for
CI=true+ missingSUPABASE_PROJECT_ID, skipping type generation. - In
--checkmode on CI, validate that the committed types file exists and is non-empty before exiting successfully.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if [ -f "$TYPES_FILE" ]; then | ||
| echo "ℹ️ CI without SUPABASE_PROJECT_ID — using committed $TYPES_FILE (self-hosted setup, types are committed)." | ||
| exit 0 | ||
| else | ||
| echo "❌ Error: $TYPES_FILE not found in CI and no SUPABASE_PROJECT_ID set." |
| if [ -f "$TYPES_FILE" ]; then | ||
| echo "ℹ️ CI without SUPABASE_PROJECT_ID — using committed $TYPES_FILE (self-hosted setup, types are committed)." | ||
| exit 0 | ||
| else | ||
| echo "❌ Error: $TYPES_FILE not found in CI and no SUPABASE_PROJECT_ID set." |
There was a problem hiding this comment.
| if [ -f "$TYPES_FILE" ]; then | |
| echo "ℹ️ CI without SUPABASE_PROJECT_ID — using committed $TYPES_FILE (self-hosted setup, types are committed)." | |
| exit 0 | |
| else | |
| echo "❌ Error: $TYPES_FILE not found in CI and no SUPABASE_PROJECT_ID set." | |
| if [ -f "$TYPES_FILE" ] && [ -s "$TYPES_FILE" ]; then | |
| echo "ℹ️ CI without SUPABASE_PROJECT_ID — using committed $TYPES_FILE (self-hosted setup, types are committed)." | |
| exit 0 | |
| else | |
| echo "❌ Error: $TYPES_FILE not found or empty in CI and no SUPABASE_PROJECT_ID set." |
GEN_MODE in validate-supabase-types.sh only checks if file exists, not if it's non-empty, allowing empty types.ts to be accepted during CI prebuild
🔍 Descoberta importante: este PR expôs SEGUNDO bug pré-existenteApós o fix do prebuild, o CI test agora avança até o step Vitest (Unit & Fuzz), onde falha com: Causa raiz: version mismatch entre Tentei alinhar localmente ( 95 test files com erros (provavelmente import/setup/snapshot drift acumulado). Decisão: PR mantido cirúrgicoRevertido o update do Vitest. Este PR fica APENAS com o fix do prebuild (1 arquivo, 26 linhas). Próximas pendências mapeadas (atualizadas)
Status do CI test após este PR
CI test ainda red mas avançou 2 etapas. |
🎯 Objetivo
Resolver o bug pré-existente do
prebuildque vinha falhando embun run buildno CI test step, há vários PRs (todos os runs em main desde antes do #114). Padrão atual era contornar via--admin --squash.🐛 Bug
🔍 Causa raiz
No
validate-supabase-types.sh, o script tem 3 branches:--project-id(Supabase Cloud)-d supabase+docker ps→ gen via--local(Supabase Cloud local)No GitHub Actions runner:
[ -d "supabase" ]é true (pasta existe)docker ps &> /dev/nullé true (runner tem docker daemon)Cai no branch 2 → tenta
supabase gen types typescript --local→ falha porque não há instância Supabase rodando localmente (supabase startnunca foi chamado,config.tomlnão temproject_id— intencional desde a Onda 6 PR #115 do setup self-hosted).✅ Fix (cirúrgico)
Early-exit no script quando
CI=trueeSUPABASE_PROJECT_IDnão está setada.Faz sentido porque:
supabase/config.tomldocumenta isso desde a Onda 6)types.tsé gerado localmente viasupabase gen types typescript --db-url $SUPABASE_DB_URLe commitado (468KB, atualizado)🛡️ Validações locais
CI=truesemPROJECT_ID(cenário do bug)CI=true --check --summary(check-mode)CIsetadaCI=true bun run prebuild(full)📝 Diff
Apenas adição de bloco no script bash. Zero impacto em arquivos TS, build, ou design system.
🎯 Resolve
1ª das 3 pendências mapeadas após Onda 8 fechada (#121):
prebuild(SUPABASE_PROJECT_ID) ← este PRwhatsapp_reconcile_dispatch(pgsodium) — legado Onda 7🤖 Generated with Claude Code
Summary by CodeRabbit
Notas de Lançamento