Repository navigation
133 lines (111 loc) · 3.99 KB
/
Copy pathtests.yml
File metadata and controls
133 lines (111 loc) · 3.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
name: API Tests
on:
push:
branches: [master]
pull_request:
branches: [master]
schedule:
- cron: '0 6 * * *'
permissions:
contents: read
# O "uv sync --locked" de cada job já instala tudo a partir do uv.lock; com
# UV_NO_SYNC, os "uv run" seguintes usam esse ambiente sem tentar ajustá-lo.
env:
UV_NO_SYNC: '1'
jobs:
# Checagens que não dependem da API pública: tipos, lint, formatação,
# dependências vulneráveis e testes unitários (com requests-mock, sem rede).
# Rodam em segundos e, se falharem, a integração nem chega a rodar.
unit:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ['3.12', '3.13']
steps:
- name: Checkout código
uses: actions/checkout@v7
- name: Instalar uv e Python
uses: astral-sh/setup-uv@v10.2.0
with:
python-version: ${{ matrix.python-version }}
enable-cache: true
# --locked: instala exatamente o que está no uv.lock e falha se o lock
# estiver desatualizado em relação ao pyproject.toml.
- name: Instalar dependências
run: uv sync --locked --extra dev
- name: Checar tipos
run: uv run mypy .
- name: Lint
run: uv run ruff check .
- name: Verificar formatação
run: uv run ruff format --check .
- name: Auditar dependências
run: uv run pip-audit --skip-editable
- name: Rodar testes unitários
run: uv run pytest tests/unit --no-cov
# Suíte completa contra a restful-booker. Roda também os unitários de novo
# (custam milissegundos) para que o relatório e a cobertura continuem
# cobrindo o projeto inteiro. Uma falha aqui com o job unit verde indica
# problema na API pública ou num cenário, não no código dos clients.
integration:
needs: unit
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ['3.12', '3.13']
steps:
- name: Checkout código
uses: actions/checkout@v7
- name: Instalar uv e Python
uses: astral-sh/setup-uv@v10.2.0
with:
python-version: ${{ matrix.python-version }}
enable-cache: true
# --locked: instala exatamente o que está no uv.lock e falha se o lock
# estiver desatualizado em relação ao pyproject.toml.
- name: Instalar dependências
run: uv sync --locked --extra dev
- name: Rodar testes
run: uv run pytest
# Cobertura, relatório HTML e Pages só precisam de uma versão do Python
# gerando o artifact — rodar pras duas duplicaria o upload à toa.
- name: Enviar cobertura para o Codecov
if: always() && matrix.python-version == '3.12'
uses: codecov/codecov-action@v7
with:
files: reports/coverage.xml
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: false
- name: Publicar relatório HTML
if: always() && matrix.python-version == '3.12'
uses: actions/upload-artifact@v7
with:
name: pytest-report
path: reports/report.html
retention-days: 15
- name: Preparar página do GitHub Pages
if: matrix.python-version == '3.12' && github.ref == 'refs/heads/master' && github.event_name == 'push'
run: |
mkdir -p pages
cp reports/report.html pages/index.html
- name: Empacotar artifact do GitHub Pages
if: matrix.python-version == '3.12' && github.ref == 'refs/heads/master' && github.event_name == 'push'
uses: actions/upload-pages-artifact@v5
with:
path: pages
deploy-pages:
if: github.ref == 'refs/heads/master' && github.event_name == 'push'
needs: integration
runs-on: ubuntu-latest
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Publicar no GitHub Pages
id: deployment
uses: actions/deploy-pages@v5