feat(ci): testes automatizados (Vitest) e workflow no GitHub Actions#6
Merged
Merged
Conversation
- Extrai createJobsApiApp para testar Express sem subir porta - Testes de getConfig e rotas /api (health, jobs, 404) - Scripts npm test, validate e validate:ci - Workflow CI em pull_request e push (master, develop) - README: secao Testes e CI e estrutura do projeto Made-with: Cursor
guimelotto
force-pushed
the
feature/ci-testes-e-github-actions
branch
from
March 20, 2026 16:19
4fe71b8 to
e919a84
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resumo
Este PR adiciona testes automatizados (Vitest + Supertest), scripts locais para validar o mesmo que o CI, e um workflow GitHub Actions que roda em PRs e em push para
masteredevelop.Base:
develop. A branch foi rebaseada emdevelopapós o merge da PR #5, então o diff deste PR contém apenas o trabalho de CI/testes.O que mudou no código
src/jobsApiApp.jscomcreateJobsApiApp({ outputDir });src/server.jssó carregadotenv, instancia o app e fazlisten.test/config.test.js— contrato degetConfig(paths, keywords,TIME_FILTER).test/jobsApi.test.js— HTTP em memória com diretório temporário (health, 404, leitura de.xlsx).npm test,npm run test:watch,npm run validate,npm run validate:ci(espelho do CI comnpm ci)..github/workflows/ci.yml: Node 22,npm cina raiz → testes →npm ci --prefix frontend→ lint → build.Nenhuma alteração de comportamento das rotas em produção além da extração da fábrica do app.
Como validar localmente (antes de aprovar)
Com dependências já instaladas:
Espelho completo do que o runner do GitHub faz (reinstala com lockfile):
Configurações no GitHub (para o dono do repositório)
Siga na ordem. Caminhos usam a interface web atual do GitHub (podem mudar levemente de nome).
1. Garantir que o workflow rode ao menos uma vez
2. Exigir o check do CI antes do merge (recomendado)
develop(e repita paramasterse quiser o mesmo rigor no release).Se usar Branch protection rules (clássico):
developdevelopdefasado).Se usar Rulesets:
develop(ref:refs/heads/develop).3. Permissões do
GITHUB_TOKEN(se o CI falhar por permissão)Em Settings → Actions → General → Workflow permissions:
npm ci/test/build.4. Opcional: merge queue / conversas
Depois do merge
develop(e pushes listados noon:do YAML) disparam o CI automaticamente.npm run validateantes de abrir PR para evitar falhas no runner.Referências rápidas