Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
150 changes: 80 additions & 70 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
name: CI/CD
name: CI/CD Pipeline

on:
push:
branches: [ main, master, develop ]
tags: [ 'v*' ]
branches: [ main, develop ]
pull_request:
branches: [ main, master, develop ]
branches: [ main ]

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: [3.8, 3.9, "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v4
Expand All @@ -31,7 +30,20 @@ jobs:
run: |
uv sync --all-extras --dev

- name: Run tests with pytest
- name: Lint with Ruff
run: |
uv run ruff check src/ tests/
uv run ruff format --check src/ tests/

- name: Type check with MyPy
run: |
uv run mypy src/

- name: Security scan with Bandit
run: |
uv run bandit -r src/

- name: Run tests
run: |
uv run pytest tests/ -v --cov=src/fastapi_versioner --cov-report=xml --cov-report=html

Expand All @@ -41,146 +53,144 @@ jobs:
file: ./coverage.xml
flags: unittests
name: codecov-umbrella
fail_ci_if_error: false

lint:
performance-test:
runs-on: ubuntu-latest
needs: test

steps:
- uses: actions/checkout@v4

- name: Set up Python
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: "3.11"

- name: Install uv
uses: astral-sh/setup-uv@v2
with:
version: "latest"

- name: Install dependencies
run: |
uv sync --all-extras --dev

- name: Run ruff linter
- name: Run performance tests
run: |
uv run ruff check --fix src/ tests/ examples/
uv run pytest tests/performance/ -v

- name: Run ruff formatter
run: |
uv run ruff format src/ tests/ examples/

- name: Run mypy
run: |
uv run mypy src/fastapi_versioner/

security:
integration-test:
runs-on: ubuntu-latest
needs: test

steps:
- uses: actions/checkout@v4

- name: Set up Python
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: "3.11"

- name: Install uv
uses: astral-sh/setup-uv@v2
with:
version: "latest"

- name: Install dependencies
run: |
uv sync --all-extras --dev

- name: Run bandit security linter
- name: Run integration tests
run: |
uv run bandit -r src/ -f json -o bandit-report.json || true
uv run pytest tests/integration/ -v

- name: Upload bandit report
uses: actions/upload-artifact@v4
if: always()
with:
name: bandit-report
path: bandit-report.json
- name: Test examples
run: |
cd examples/basic && python -m pytest -v || true
cd ../advanced && python -m pytest -v || true
cd ../enterprise && python -m pytest -v || true
cd ../performance && python -m pytest -v || true
cd ../testing && python -m pytest -v || true

build:
runs-on: ubuntu-latest
needs: [test, lint, security]
if: startsWith(github.ref, 'refs/tags/v')
needs: [test, performance-test, integration-test]

steps:
- uses: actions/checkout@v4

- name: Set up Python
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: "3.11"

- name: Install uv
uses: astral-sh/setup-uv@v2
with:
version: "latest"

- name: Build package
run: |
uv build

- name: Upload build artifacts
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v3
with:
name: dist
path: dist/

publish:
release:
runs-on: ubuntu-latest
needs: build
if: startsWith(github.ref, 'refs/tags/v')
environment: release
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
if: github.event_name == 'push' && github.ref == 'refs/heads/main'

steps:
- uses: actions/checkout@v4

- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: "3.11"

- name: Install uv
uses: astral-sh/setup-uv@v2

- name: Download build artifacts
uses: actions/download-artifact@v4
uses: actions/download-artifact@v3
with:
name: dist
path: dist/

- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
# Alternatively, use trusted publishing (recommended):
# Remove the password line above and uncomment the line below
# repository-url: https://upload.pypi.org/legacy/
- name: Publish to PyPI
if: startsWith(github.ref, 'refs/tags/')
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: |
uv tool install twine
uv tool run twine upload dist/*

release:
docs:
runs-on: ubuntu-latest
needs: publish
if: startsWith(github.ref, 'refs/tags/v')
permissions:
contents: write
needs: test

steps:
- uses: actions/checkout@v4

- name: Create GitHub Release
uses: softprops/action-gh-release@v1
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
tag_name: ${{ github.ref_name }}
name: Release ${{ github.ref_name }}
draft: false
prerelease: false
body: |
## Changes
python-version: "3.11"

- name: Install uv
uses: astral-sh/setup-uv@v2

See [CHANGELOG.md](CHANGELOG.md) for details.
- name: Install dependencies
run: |
uv sync --all-extras --dev

## Installation
- name: Generate documentation
run: |
# Add documentation generation commands here
echo "Documentation generation would go here"

```bash
pip install fastapi-versioner==${{ github.ref_name }}
```
- name: Deploy to GitHub Pages
if: github.ref == 'refs/heads/main'
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs/_build/html
Loading
Loading