Skip to content

fix(ci): set TZ=America/Sao_Paulo at workflow level#221

Merged
adm01-debug merged 1 commit into
mainfrom
fix/ci-tz-workflow-env
May 15, 2026
Merged

fix(ci): set TZ=America/Sao_Paulo at workflow level#221
adm01-debug merged 1 commit into
mainfrom
fix/ci-tz-workflow-env

Conversation

@adm01-debug
Copy link
Copy Markdown
Owner

@adm01-debug adm01-debug commented May 15, 2026

Resumo

Resolve falha persistente em CI Lint, Typecheck & Test e Test Coverage que sobreviveu ao PR #220.

13 snapshots de PriceFreshnessBadge continuam falhando em CI com:

- Expected   Hora local: 03/05/2026, 06:00   ← snapshot (BRT)
+ Received   Hora local: 03/05/2026, 09:00   ← runtime CI (UTC)

Causa-raiz (descoberta após PR #220)

A solução do PR #220 (test.env = { TZ: 'America/Sao_Paulo' } no vitest.config.ts) funciona em dev (VPS já em BRT) mas NÃO funciona em CI:

  • test.env apenas seta process.env.TZ em runtime.
  • Node cacheia Intl.DateTimeFormat e Date.prototype.toLocaleString na startup do binary, antes do worker rodar o vitest config.
  • Confirmação experimental (rodando local com TZ=UTC npx vitest):
    process.env.TZ: America/Sao_Paulo   ← env setada
    Date.now() local: 12:22 (UTC!)      ← mas Date ignora
    Intl.resolvedOptions().timeZone: UTC ← Intl ignora
    

Fix

Setar TZ no nível do workflow, herdado por todos os jobs:

env:
  TZ: America/Sao_Paulo

jobs:
  smoke: ...
  quality: ...      # Lint, Typecheck & Test
  coverage: ...     # Test Coverage
  # ... +5 outros jobs vitest

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.tsx20/20 pass
  • TZ=UTC npx vitest run ... → 13 fail (reproduz bug CI) ✅

Defesa em profundidade

Mantemos test.env = { TZ: 'America/Sao_Paulo' } no vitest.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_Paulo at the workflow level so Node starts with the correct timezone in CI. Fixes PriceFreshnessBadge snapshot mismatches and stabilizes Lint, Typecheck & Test and Test Coverage jobs.

  • Bug Fixes
    • GitHub Actions runs in UTC; Node caches timezone on startup before vitest.config.ts test.env applies.
    • Define env: TZ: America/Sao_Paulo at the workflow root so all jobs inherit it.
    • Date/Intl output now matches dev (BRT); the 13 failing snapshots pass.

Written for commit bc61a8b. Summary will update on new commits.

Summary by CodeRabbit

  • Chores
    • Ajustado a configuração do ambiente de CI para garantir consistência em processamento de datas e horários durante testes automatizados.

Review Change Stack

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).
Copilot AI review requested due to automatic review settings May 15, 2026 12:25
@vercel
Copy link
Copy Markdown

vercel Bot commented May 15, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
promo-gifts Ready Ready Preview, Comment May 15, 2026 0:26am

@supabase
Copy link
Copy Markdown

supabase Bot commented May 15, 2026

This pull request has been ignored for the connected project doufsxqlfjyuvxuezpln because there are no changes detected in supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_Paulo environment 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.

Comment thread .github/workflows/ci.yml
group: ci-${{ github.ref }}
cancel-in-progress: true

# TZ fix: GitHub Actions runners (ubuntu-latest) default a UTC. Date.prototype
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 15, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: c5c0e02a-ff70-4634-89f3-b55d9e7c66f2

📥 Commits

Reviewing files that changed from the base of the PR and between 1f237e9 and bc61a8b.

📒 Files selected for processing (1)
  • .github/workflows/ci.yml

Walkthrough

O workflow de CI agora define explicitamente a variável de ambiente TZ: America/Sao_Paulo para garantir que todos os jobs e steps executem com o mesmo fuso horário, evitando inconsistências em snapshots e comparações que dependem de toLocaleString ou timestamps.

Changes

Consistência de Timezone no CI

Layer / File(s) Resumo
Configuração de variável de ambiente TZ
.github/workflows/ci.yml
Define TZ: America/Sao_Paulo em nível de workflow com comentários explicativos sobre padronização de fuso horário em runners do GitHub Actions, garantindo consistência em operações sensíveis ao timezone durante testes.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutos

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed O título descreve precisamente a mudança principal: configurar TZ=America/Sao_Paulo no nível do workflow de CI, refletindo exatamente o que foi implementado.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/ci-tz-workflow-env

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

@adm01-debug adm01-debug merged commit 840f2ef into main May 15, 2026
24 of 27 checks passed
@adm01-debug adm01-debug deleted the fix/ci-tz-workflow-env branch May 15, 2026 12:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants