|
| 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