diff --git a/.github/workflows/coverage.yaml b/.github/workflows/coverage.yaml new file mode 100644 index 0000000..167e5de --- /dev/null +++ b/.github/workflows/coverage.yaml @@ -0,0 +1,34 @@ +name: Coverage + +on: + push: + branches: [main] + workflow_dispatch: + +jobs: + coverage: + name: Coverage + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v7 + + - name: Set up Python + uses: actions/setup-python@v6 + with: + python-version-file: pyproject.toml + + - name: Install uv + uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b + + - name: Install the project + run: uv sync --frozen + + - name: Coverage + run: uv run --no-sync pytest --cov-report=xml --cov-report=term + + - name: Upload coverage to Coveralls + uses: coverallsapp/github-action@v2 + with: + format: cobertura + file: coverage.xml diff --git a/.github/workflows/deploy-docs.yaml b/.github/workflows/deploy-docs.yaml new file mode 100644 index 0000000..19f0b0b --- /dev/null +++ b/.github/workflows/deploy-docs.yaml @@ -0,0 +1,44 @@ +name: Deploy documentation to Pages + +on: + release: + types: + - published + workflow_dispatch: + +permissions: + contents: read + pages: write + id-token: write + +concurrency: + group: 'pages' + cancel-in-progress: true + +jobs: + deploy: + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v7 + + - name: Install uv + uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b + + - name: Build site + run: uv run --frozen --group docs mkdocs build + + - name: Setup Pages + uses: actions/configure-pages@v6 + + - name: Upload artifact + uses: actions/upload-pages-artifact@v5 + with: + path: ./site + + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v5 diff --git a/.github/workflows/deploy-pypi.yaml b/.github/workflows/deploy-pypi.yaml new file mode 100644 index 0000000..8fd76f8 --- /dev/null +++ b/.github/workflows/deploy-pypi.yaml @@ -0,0 +1,42 @@ +name: Deploy to PyPI + +on: + release: + types: + - published + +jobs: + build: + name: Build python packages + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v7 + with: + fetch-depth: 0 + + - name: Build + run: pipx run build + + - uses: actions/upload-artifact@v7 + with: + path: dist/* + + publish: + name: Publish to PyPI + needs: [build] + environment: + name: pypi + url: https://pypi.org/p/fastapi-caching-route + permissions: + id-token: write + runs-on: ubuntu-latest + if: github.event_name == 'release' && github.event.action == 'published' + steps: + - name: Download artifacts + uses: actions/download-artifact@v8 + with: + path: dist + + - name: Upload to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml new file mode 100644 index 0000000..e137d89 --- /dev/null +++ b/.github/workflows/pr.yaml @@ -0,0 +1,85 @@ +name: PR Checks + +on: + pull_request: + branches: + - main + +jobs: + pytest: + name: Tests Python ${{ matrix.python-version }} + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + python-version: ['3.10', '3.11', '3.12', '3.13', '3.14', '3.14t'] + steps: + - name: Checkout + uses: actions/checkout@v7 + + - uses: actions/setup-python@v6 + with: + python-version: ${{ matrix.python-version }} + + - name: Install uv + uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b + + - name: Install the project + run: uv sync --frozen + + - name: Run pytest + run: uv run --no-sync pytest --no-cov + + code-quality: + name: Code Quality + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v7 + + - name: Set up Python + uses: actions/setup-python@v6 + with: + python-version-file: pyproject.toml + + - name: Install uv + uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b + + - name: Check uv.lock + run: uv lock --check + + - name: Install the project + run: uv sync --frozen + + - name: Ruff check + id: ruff-check + continue-on-error: true + run: uv run --no-sync ruff check --output-format=github + + - name: Ruff format + id: ruff-format + continue-on-error: true + run: uv run --no-sync ruff format --check --output-format=github + + - name: Type check + id: ty + continue-on-error: true + run: uv run --no-sync ty check --output-format=github + + - name: Fail if any step failed + if: | + steps.ruff-check.outcome == 'failure' || + steps.ruff-format.outcome == 'failure' || + steps.ty.outcome == 'failure' + run: exit 1 + + summary: + name: PR Checks Summary + runs-on: ubuntu-latest + if: always() + needs: [pytest, code-quality] + steps: + - run: > + test + "${{ needs.pytest.result }}" = "success" -a + "${{ needs.code-quality.result }}" = "success" diff --git a/pyproject.toml b/pyproject.toml index c047395..561b58b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -21,18 +21,20 @@ dependencies = [ [dependency-groups] dev = [ "fastapi~=0.138", - "griffe-typingdoc~=0.3", "httpx2~=2.5", - "markdown-include~=0.8", - "mkdocs-material~=9.7", - "mkdocstrings[python]~=1.0", - "mkdocs~=1.6", "pytest-cov~=7.1", "pytest~=9.1", "ruff~=0.15", "ty>=0.0.56", "uvicorn[standard]~=0.49", ] +docs = [ + "griffe-typingdoc~=0.3", + "markdown-include~=0.8", + "mkdocs-material~=9.7", + "mkdocstrings[python]~=1.0", + "mkdocs~=1.6", +] [project.urls] Homepage = "https://github.com/mentaljam/fastapi-caching-route" diff --git a/uv.lock b/uv.lock index 65b2fc7..816a893 100644 --- a/uv.lock +++ b/uv.lock @@ -341,18 +341,20 @@ dependencies = [ [package.dev-dependencies] dev = [ { name = "fastapi" }, - { name = "griffe-typingdoc" }, { name = "httpx2" }, - { name = "markdown-include" }, - { name = "mkdocs" }, - { name = "mkdocs-material" }, - { name = "mkdocstrings", extra = ["python"] }, { name = "pytest" }, { name = "pytest-cov" }, { name = "ruff" }, { name = "ty" }, { name = "uvicorn", extra = ["standard"] }, ] +docs = [ + { name = "griffe-typingdoc" }, + { name = "markdown-include" }, + { name = "mkdocs" }, + { name = "mkdocs-material" }, + { name = "mkdocstrings", extra = ["python"] }, +] [package.metadata] requires-dist = [{ name = "aiocache", specifier = ">=0.12,<1.0" }] @@ -360,18 +362,20 @@ requires-dist = [{ name = "aiocache", specifier = ">=0.12,<1.0" }] [package.metadata.requires-dev] dev = [ { name = "fastapi", specifier = "~=0.138" }, - { name = "griffe-typingdoc", specifier = "~=0.3" }, { name = "httpx2", specifier = "~=2.5" }, - { name = "markdown-include", specifier = "~=0.8" }, - { name = "mkdocs", specifier = "~=1.6" }, - { name = "mkdocs-material", specifier = "~=9.7" }, - { name = "mkdocstrings", extras = ["python"], specifier = "~=1.0" }, { name = "pytest", specifier = "~=9.1" }, { name = "pytest-cov", specifier = "~=7.1" }, { name = "ruff", specifier = "~=0.15" }, { name = "ty", specifier = ">=0.0.56" }, { name = "uvicorn", extras = ["standard"], specifier = "~=0.49" }, ] +docs = [ + { name = "griffe-typingdoc", specifier = "~=0.3" }, + { name = "markdown-include", specifier = "~=0.8" }, + { name = "mkdocs", specifier = "~=1.6" }, + { name = "mkdocs-material", specifier = "~=9.7" }, + { name = "mkdocstrings", extras = ["python"], specifier = "~=1.0" }, +] [[package]] name = "ghp-import"