diff --git a/.github/workflows/bumpversion.yml b/.github/workflows/bumpversion.yml new file mode 100644 index 0000000..a9de547 --- /dev/null +++ b/.github/workflows/bumpversion.yml @@ -0,0 +1,30 @@ +name: Bump version + +on: + push: + branches: + - main + +jobs: + bump-version: + if: "!startsWith(github.event.head_commit.message, 'bump:')" + runs-on: ubuntu-latest + name: "Bump version and create changelog with commitizen" + steps: + - name: Check out + uses: actions/checkout@v3 + with: + token: "${{ secrets.PERSONAL_ACCESS_TOKEN }}" + fetch-depth: 0 + - name: Create bump and changelog + uses: commitizen-tools/commitizen-action@master + with: + github_token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} + changelog_increment_filename: body.md + - name: Release + uses: softprops/action-gh-release@v1 + with: + body_path: "body.md" + tag_name: ${{ env.REVISION }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index 7cd269c..0378ae9 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -41,7 +41,7 @@ jobs: - name: Run Ruff run: poetry run ruff check . - name: Run Mypy - run: poetry run mypy app + run: poetry run mypy app - name: Test with pytest run: poetry run pytest --cov=app --cov-report=xml - name: Upload coverage reports to Codecov diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d0bd707..54aba7e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,22 +1,25 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 + rev: v4.5.0 hooks: - id: check-yaml - id: end-of-file-fixer - id: trailing-whitespace - repo: https://github.com/pre-commit/mirrors-mypy - rev: "v1.5.1" + rev: "v1.7.1" hooks: - id: mypy args: [--ignore-missing-imports] additional_dependencies: ["types-redis"] - repo: https://github.com/astral-sh/ruff-pre-commit - # Ruff version. - rev: v0.1.5 + rev: v0.1.6 hooks: - # Run the linter. - id: ruff args: [--fix] - # Run the formatter. - id: ruff-format + - repo: https://github.com/commitizen-tools/commitizen + rev: 3.12.0 + hooks: + - id: commitizen + - id: commitizen-branch + stages: [push] diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..e69de29 diff --git a/dockerfile b/dockerfile new file mode 100644 index 0000000..257b2d9 --- /dev/null +++ b/dockerfile @@ -0,0 +1,21 @@ +FROM python:3.11-slim-bookworm as builder + +RUN pip install poetry==1.7.1 + +ENV POETRY_NO_INTERACTION=1 \ + POETRY_VIRTUALENVS_IN_PROJECT=1 \ + POETRY_VIRTUALENVS_CREATE=1 \ + POETRY_CACHE_DIR=/tmp/poetry_cache + +COPY pyproject.toml poetry.lock ./ + +RUN poetry install --no-dev --no-root && rm -rf $POETRY_CACHE_DIR + + +FROM python:3.11-slim-bookworm as runtime + +COPY --from=builder .venv .venv + +COPY app ./app + +CMD [".venv/bin/uvicorn", "app.main:app", "--timeout-graceful-shutdown", "1"] diff --git a/pyproject.toml b/pyproject.toml index 79841af..6e8b0f0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -30,7 +30,6 @@ types-redis = "^4.6.0.7" asgi-lifespan = "^2.1.0" asyncpg-stubs = "^0.28.0" - [tool.aerich] tortoise_orm = "db.settings.TORTOISE_ORM" location = "./migrations" @@ -91,3 +90,7 @@ exclude_also = [ # Don't complain about abstract methods, they aren't run: "@(abc\\.)?abstractmethod", ] + +[tool.commitizen] +update_changelog_on_bump = true +version_provider = "poetry"