Repository navigation
Reduz a duplicação nos steps do pytest-bdd #63
Workflow file for this run
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
| name: API Tests | |
| on: | |
| push: | |
| branches: [master] | |
| pull_request: | |
| branches: [master] | |
| schedule: | |
| - cron: '0 6 * * *' | |
| permissions: | |
| contents: read | |
| 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: Configurar Python | |
| uses: actions/setup-python@v7 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| cache: 'pip' | |
| - name: Instalar dependências | |
| run: | | |
| pip install --upgrade pip | |
| pip install -e ".[dev]" | |
| - name: Checar tipos | |
| run: mypy . | |
| - name: Lint | |
| run: ruff check . | |
| - name: Verificar formatação | |
| run: ruff format --check . | |
| - name: Auditar dependências | |
| run: pip-audit | |
| - name: Rodar testes unitários | |
| 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: Configurar Python | |
| uses: actions/setup-python@v7 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| cache: 'pip' | |
| - name: Instalar dependências | |
| run: | | |
| pip install --upgrade pip | |
| pip install -e ".[dev]" | |
| - name: Rodar testes | |
| 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 |