fix(ci): set TZ=America/Sao_Paulo at workflow level#221
Conversation
GitHub Actions runners default to UTC. Node caches Intl/Date TZ on worker startup, before vitest.config.test.env can take effect. Solution: set TZ at workflow env level → all 8 jobs inherit → Node startups with correct TZ → toLocaleString consistent with dev (VPS BRT). Fixes: snapshot mismatches in PriceFreshnessBadge that survived PR #220 (test.env in vitest.config.ts works in dev but not in CI because of Node startup ordering).
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
There was a problem hiding this comment.
Pull request overview
This PR pins the GitHub Actions workflow timezone to America/Sao_Paulo so Node/Vitest processes start with the same timezone used by the snapshot expectations, reducing CI-only date formatting drift.
Changes:
- Adds a workflow-level
TZ: America/Sao_Pauloenvironment variable. - Documents why the setting must happen before Node starts rather than only inside Vitest config.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| group: ci-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| # TZ fix: GitHub Actions runners (ubuntu-latest) default a UTC. Date.prototype |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughO workflow de CI agora define explicitamente a variável de ambiente ChangesConsistência de Timezone no CI
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 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 unit tests (beta)
Comment |
Resumo
Resolve falha persistente em CI
Lint, Typecheck & TesteTest Coverageque sobreviveu ao PR #220.13 snapshots de
PriceFreshnessBadgecontinuam falhando em CI com:Causa-raiz (descoberta após PR #220)
A solução do PR #220 (
test.env = { TZ: 'America/Sao_Paulo' }novitest.config.ts) funciona em dev (VPS já em BRT) mas NÃO funciona em CI:test.envapenas setaprocess.env.TZem runtime.Intl.DateTimeFormateDate.prototype.toLocaleStringna startup do binary, antes do worker rodar o vitest config.TZ=UTC npx vitest):Fix
Setar
TZno nível do workflow, herdado por todos os jobs:Resultado: Node nasce em CI já com
TZ=America/Sao_Paulo→ Intl/Date cacheiam BRT corretamente → snapshots batem.Validação local
TZ='America/Sao_Paulo' npx vitest run src/components/products/PriceFreshnessBadge.snapshots.test.tsx→ 20/20 pass ✅TZ=UTC npx vitest run ...→ 13 fail (reproduz bug CI) ✅Defesa em profundidade
Mantemos
test.env = { TZ: 'America/Sao_Paulo' }novitest.config.ts(PR #220) — funciona como fallback para dev local sem TZ no shell.Risco
Mínimo. Apenas workflow YAML — sem mudança em código de produção, dependências ou testes.
Próximos passos
Se CI passar, fechar definitivamente os 88 + 13 = 101 testes de regressão que travavam o pipeline desde 06/mai/2026.
Summary by cubic
Set
TZ=America/Sao_Pauloat the workflow level so Node starts with the correct timezone in CI. Fixes PriceFreshnessBadge snapshot mismatches and stabilizesLint, Typecheck & TestandTest Coveragejobs.vitest.config.tstest.envapplies.env: TZ: America/Sao_Pauloat the workflow root so all jobs inherit it.Written for commit bc61a8b. Summary will update on new commits.
Summary by CodeRabbit