Skip to content

ci: guard que exige o gate de tipos como required status check (Ação B)#214

Closed
adm01-debug wants to merge 1 commit into
mainfrom
chore/ci-required-checks-guard
Closed

ci: guard que exige o gate de tipos como required status check (Ação B)#214
adm01-debug wants to merge 1 commit into
mainfrom
chore/ci-required-checks-guard

Conversation

@adm01-debug
Copy link
Copy Markdown
Owner

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

Contexto — causa-raiz das regressões de TS recorrentes

A branch protection da main está vazia: protection.enabled: false, required_status_checks.enforcement_level: "off", contexts: []. Ou seja, nenhum status check é obrigatório — o job quality ("Lint, Typecheck & Test") roda mas é consultivo, e PRs vermelhos (ex.: #202, que quebrou 13 call-sites de lazyWithRetry) mergeiam mesmo assim. Cada leva de agente reintroduz erro de tipo mais rápido do que os PRs reativos (#208/#196/#181/#178) conseguem corrigir.

O branch-protection-sentinel.yml reportava "main protegida ✅" porque o job check-protection-config só lê o booleano protectedfalso positivo que escondeu o buraco.

O que este PR faz

Adiciona .github/workflows/required-checks-guard.yml, que lê de fato /branches/main/protection (via permissions: administration:read) e FALHA (não só avisa) quando:

  • não há branch protection (HTTP 404), ou
  • o contexto obrigatório Lint, Typecheck & Test não está nos required status checks.

Também sinaliza enforce_admins=false. Roda em push para main, diariamente (cron) e via workflow_dispatch.

Optei por um guard dedicado em vez de reescrever os 12KB do sentinel — mais cirúrgico e sem risco de corromper o arquivo existente. O check-protection-config do sentinel pode ser aposentado num follow-up.

⚠️ Ordem de merge

Este guard deve entrar junto com a aplicação da branch protection (Ação A — PUT /branches/main/protection com os contexts Lint, Typecheck & Test + Production Build & Warnings Gate + Edge Functions — Deno typecheck, strict: true, enforce_admins: true). Sozinho, ele falha de propósito em main até a proteção existir — é a forcing function pretendida, mas não mergear isolado.


Summary by cubic

Adds a CI guard that enforces the Lint, Typecheck & Test job as a required status check on main. This blocks red PRs from merging by failing when branch protection is missing or misconfigured.

  • New Features

    • Adds .github/workflows/required-checks-guard.yml.
    • Reads /branches/main/protection with administration: read.
    • Fails if protection is absent or Lint, Typecheck & Test is not required.
    • Warns when enforce_admins=false and writes a brief step summary.
    • Runs on push to main, daily cron, and workflow_dispatch.
  • Migration

    • Apply branch protection on main with required checks: Lint, Typecheck & Test, Production Build & Warnings Gate, Edge Functions — Deno typecheck; set strict: true and enforce_admins: true.
    • Merge this PR together with the protection change; alone it will fail on main by design.

Written for commit 110e9b3. Summary will update on new commits. Review in cubic

Causa-raiz das regressoes de TS recorrentes (ver #208/#196/#181/#178): a
branch protection da main esta com required_status_checks vazio
(enforcement_level: off), entao PRs vermelhos mergeiam e cada leva de agente
reintroduz erro de tipo mais rapido do que e corrigido reativamente.

O job check-protection-config do branch-protection-sentinel.yml so le o
booleano `protected` e reporta "protegida" — falso positivo que escondeu o
buraco. Este guard le /branches/main/protection de fato e FALHA (nao so avisa)
quando:
  - nao ha branch protection (HTTP 404), ou
  - o contexto obrigatorio "Lint, Typecheck & Test" nao esta nos required
    status checks.

Tambem sinaliza enforce_admins=false (admins furando o gate).

Roda em push para main, diariamente (cron) e via dispatch. Requer
permissions: administration:read para ler a proteção.

NB: deve entrar JUNTO com a aplicacao da branch protection — sozinho, ele
falha de proposito em main ate a protecao existir (forcing function).
Copilot AI review requested due to automatic review settings May 24, 2026 01:41
@vercel
Copy link
Copy Markdown

vercel Bot commented May 24, 2026

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

Project Deployment Actions Updated (UTC)
we-dream-big Ready Ready Preview, Comment May 24, 2026 1:41am

@supabase
Copy link
Copy Markdown

supabase Bot commented May 24, 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 ↗︎.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 24, 2026

Warning

Review limit reached

@adm01-debug, we couldn't start this review because you've used your available PR reviews for now.

Your plan currently allows 1 review/hour. Refill in 13 minutes and 57 seconds.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more review capacity refills, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than trial, open-source, and free plans. In all cases, review capacity refills continuously over time.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 3088d290-835b-4da7-929a-157d27a27bb6

📥 Commits

Reviewing files that changed from the base of the PR and between c326e8a and 110e9b3.

📒 Files selected for processing (1)
  • .github/workflows/required-checks-guard.yml
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/ci-required-checks-guard

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

Copy link
Copy Markdown
Contributor

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

Adiciona um workflow de CI dedicado para validar (e falhar) quando a branch main não estiver protegida ou quando o check Lint, Typecheck & Test não estiver configurado como required status check, evitando merges que ignoram o gate de types/lint/tests.

Changes:

  • Cria o workflow .github/workflows/required-checks-guard.yml que consulta GET /branches/main/protection.
  • Falha quando a proteção não existe (HTTP 404) ou quando Lint, Typecheck & Test não está entre os required checks.
  • Emite warning quando enforce_admins=false e escreve um Step Summary com os contexts detectados.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +3 to +17
# Garante que o gate de tipos/lint/test e um REQUIRED status check em main.
# Sem isso, PRs vermelhos podem mergear — causa-raiz das regressoes de tipo
# recorrentes (ver #208 e a leva #196/#181/#178). Este guard FALHA (nao so
# avisa) quando a protecao esta ausente ou o contexto obrigatorio sumiu.

on:
push:
branches: [main]
schedule:
- cron: '0 9 * * *' # diario ~06:00 BRT
workflow_dispatch:

permissions:
contents: read
administration: read # necessario para ler /branches/main/protection
Comment on lines +62 to +67
if ! printf '%s\n' "$CONTEXTS" | grep -qxF "$REQUIRED"; then
echo "::error::Required status check '$REQUIRED' ausente — o gate de tipos esta apenas consultivo. Corrija a branch protection."
{
echo ""
echo "❌ **\`$REQUIRED\` nao e required.**"
} >> "$GITHUB_STEP_SUMMARY"
Copy link
Copy Markdown
Owner Author

@adm01-debug adm01-debug left a comment

Choose a reason for hiding this comment

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

Superseded by #223. The original workflow used an invalid GitHub Actions permission (administration: read); #223 recreates the guard with a valid token strategy (BRANCH_PROTECTION_READ_TOKEN || github.token) and clear 403 handling.

@adm01-debug adm01-debug deleted the chore/ci-required-checks-guard branch May 24, 2026 19:54
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