Skip to content

Commit bcdf930

Browse files
committed
ci: add test and lint workflow and documentation
1 parent 1b8709e commit bcdf930

2 files changed

Lines changed: 139 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
types:
9+
- opened
10+
- synchronize
11+
- reopened
12+
13+
concurrency:
14+
group: ci-${{ github.ref }}
15+
cancel-in-progress: true
16+
17+
permissions:
18+
contents: read
19+
20+
jobs:
21+
backend:
22+
name: Backend (go vet + go test)
23+
runs-on: ubuntu-latest
24+
steps:
25+
- name: Checkout code
26+
uses: actions/checkout@v4
27+
28+
- name: Set up Go
29+
uses: actions/setup-go@v5
30+
with:
31+
go-version-file: .go-version
32+
cache: true
33+
34+
- name: go vet
35+
run: go vet ./...
36+
37+
- name: go test
38+
run: go test ./...
39+
40+
frontend-lint:
41+
name: Frontend (ESLint)
42+
runs-on: ubuntu-latest
43+
steps:
44+
- name: Checkout code
45+
uses: actions/checkout@v4
46+
47+
- name: Set up Node
48+
uses: actions/setup-node@v4
49+
with:
50+
node-version: 20
51+
cache: yarn
52+
cache-dependency-path: frontend/yarn.lock
53+
54+
- name: Install dependencies
55+
working-directory: frontend
56+
run: yarn install --frozen-lockfile
57+
58+
- name: Lint
59+
working-directory: frontend
60+
run: yarn lint

documentacao/testes_devops.md

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# Testes e DevOps — listmonk
2+
3+
Seção de DevOps/CI do Tópico 7. A seção de Testes está na branch `trabalho/testes`.
4+
5+
## Pipeline atual (GitHub Actions)
6+
7+
| Workflow | Gatilho | Função |
8+
|----------|---------|--------|
9+
| `build-sanity.yml` | `pull_request: [opened]` | `make dist` — verifica só se compila |
10+
| `release.yml` | tag `v*` | GoReleaser: binários + imagens Docker + release |
11+
| `nightly.yml` | cron diário | Build noturno, imagens `:nightly` |
12+
| `hodor-review.yml` | PR com label | Revisão por IA, não é gate funcional |
13+
| `github-pages.yml` | push em `docs/**` | Publica o site de documentação |
14+
| `issues.yml` | cron diário | Fecha issues/PRs inativos |
15+
16+
## Problemas
17+
18+
1. Nenhum teste roda na CI: existe `make test` com `go test ./...` e 11 specs Cypress, mas nenhum workflow os executa.
19+
2. Sem análise estática de Go como `go vet` ou `golangci-lint`.
20+
3. Gatilho incompleto em `build-sanity.yml`: só dispara em `opened`, então novos pushes a um PR via `synchronize` e reaberturas via `reopened` não re-verificam o build.
21+
4. Sem lint de frontend na CI; o ESLint só roda no `prebuild` local.
22+
5. Sem cobertura, SonarQube, CodeQL ou scan de dependências.
23+
24+
## Melhorias propostas
25+
26+
| Prioridade | Melhoria |
27+
|------------|----------|
28+
| Implementada | `ci.yml` rodando `go vet` + `go test` + `yarn lint` em push/PR |
29+
| Alta | Incluir `synchronize`/`reopened` no gatilho do `build-sanity.yml` |
30+
| Média | Rodar Cypress na CI com serviço Postgres + MailHog |
31+
| Média | Adicionar `golangci-lint` |
32+
| Baixa | Cobertura via `-coverprofile`, CodeQL, Trivy |
33+
34+
## Melhoria implementada — `.github/workflows/ci.yml`
35+
36+
Cobre os problemas 1, 2, 3 e 4: um workflow de testes e lint que roda em `push` na `master` e em `pull_request` nos tipos `opened`, `synchronize` e `reopened`.
37+
38+
```yaml
39+
on:
40+
push:
41+
branches: [master]
42+
pull_request:
43+
types: [opened, synchronize, reopened]
44+
45+
concurrency:
46+
group: ci-${{ github.ref }}
47+
cancel-in-progress: true
48+
49+
permissions:
50+
contents: read
51+
52+
jobs:
53+
backend:
54+
runs-on: ubuntu-latest
55+
steps:
56+
- uses: actions/checkout@v4
57+
- uses: actions/setup-go@v5
58+
with: { go-version-file: .go-version, cache: true }
59+
- run: go vet ./...
60+
- run: go test ./...
61+
62+
frontend-lint:
63+
runs-on: ubuntu-latest
64+
steps:
65+
- uses: actions/checkout@v4
66+
- uses: actions/setup-node@v4
67+
with: { node-version: 20, cache: yarn, cache-dependency-path: frontend/yarn.lock }
68+
- working-directory: frontend
69+
run: yarn install --frozen-lockfile
70+
- working-directory: frontend
71+
run: yarn lint
72+
```
73+
74+
### Justificativa
75+
76+
- Aditivo e de baixo risco: não altera release/nightly e usa alvos já existentes como `go test ./...` e `yarn lint`.
77+
- `go-version-file: .go-version`: a CI acompanha a versão declarada pelo projeto, sem o `1.26.1` fixo do `build-sanity.yml`.
78+
- `concurrency` e jobs paralelos: feedback rápido e sem execuções obsoletas.
79+
- Escalável: dá pra somar Cypress, cobertura e segurança depois sem reescrever.

0 commit comments

Comments
 (0)