From 4a5f0fc62606ba7b21961df56af4d96d817c2624 Mon Sep 17 00:00:00 2001 From: Branch Vincent Date: Fri, 27 Oct 2023 20:12:31 -0700 Subject: [PATCH] update --- .github/workflows/ci.yaml | 13 ++++------- README.md | 6 ++--- src/.github/workflows/ci.yaml.jinja | 21 ++++++----------- src/.pre-commit-config.yaml | 23 +++++++------------ src/pyproject.toml.jinja | 18 +++++---------- ...{% if docker %}Dockerfile{% endif %}.jinja | 8 +++---- 6 files changed, 33 insertions(+), 56 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 9e556f1..8be0be9 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -8,22 +8,19 @@ on: jobs: test: runs-on: ubuntu-latest - if: "!contains(github.event.head_commit.message, 'ci skip')" steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 - - uses: actions/cache@v2 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v4 + - uses: actions/cache@v4 with: path: ~/.cache/pip key: ${{ runner.os }}-pip - - name: Install dependencies - run: pip install poetry~=1.1 'copier>=6.0.0a6' - name: Run test run: | git config --global user.name "GitHub Action" git config --global user.email "action@github.com" - copier -f -d docker=True -d docs=True . build/ && cd build/ - poetry run task lint + pipx run copier copy -f -d docker=True -d docs=True . build/ && cd build/ + pipx run poetry run task lint - name: Push rendered project if: github.ref == 'refs/heads/main' && github.event_name == 'push' run: | diff --git a/README.md b/README.md index f197d8d..1a20872 100644 --- a/README.md +++ b/README.md @@ -9,15 +9,15 @@ A [Copier](https://github.com/copier-org/copier) template for a Python package b > **Requires**: copier>=6.0.0a7 ```sh -copier gh:branchvincent/python-template +copier copy --trust gh:branchvincent/python-template ``` ## Features - Package manager: [Poetry](https://python-poetry.org/) -- Formatting: [Black](https://black.readthedocs.io/en/stable/) and [isort](https://isort.readthedocs.io/en/latest/) +- Formatting: [Ruff](https://docs.astral.sh/ruff/formatter/) - Testing: [pytest](https://docs.pytest.org/en/latest/) -- Linting: [flake8](https://flake8.pycqa.org/) and [pre-commit](https://pre-commit.com/) +- Linting: [Ruff](https://docs.astral.sh/ruff/linter/) and [pre-commit](https://pre-commit.com/) - Typing: [mypy](https://mypy.readthedocs.io/en/stable/) - Task runner: [taskipy](https://github.com/illBeRoy/taskipy) - CI/CD: [Github Actions](https://docs.github.com/en/actions) diff --git a/src/.github/workflows/ci.yaml.jinja b/src/.github/workflows/ci.yaml.jinja index a3c6213..ed08570 100644 --- a/src/.github/workflows/ci.yaml.jinja +++ b/src/.github/workflows/ci.yaml.jinja @@ -9,21 +9,14 @@ on: jobs: build: runs-on: ubuntu-latest - if: "!contains(github.event.head_commit.message, 'ci skip')" steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 - with: - python-version: 3.9 + - uses: actions/checkout@v4 - name: Set up Poetry - run: | - pip install poetry - poetry config virtualenvs.in-project true - - name: Set up cache - uses: actions/cache@v2 + run: pipx install poetry + - uses: actions/setup-python@v4 with: - path: .venv - key: {% raw %}${{ runner.os }}-venv-py3.9-${{ hashFiles('**/poetry.lock') }}{% endraw %} + python-version: 3.12 + cache: poetry - name: Install package run: poetry install - name: Run linters @@ -36,7 +29,7 @@ jobs: runs-on: ubuntu-latest if: github.ref == 'refs/heads/main' && !contains(github.event.head_commit.message, 'cd skip') steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Bump version uses: TriPSs/conventional-changelog-action@v3 id: version @@ -58,7 +51,7 @@ jobs: {% if not private -%} - name: Publish to PyPI if: steps.version.outputs.skipped == 'false' - run: pip install poetry && poetry publish --build + run: pipx run poetry publish --build env: POETRY_PYPI_TOKEN_PYPI: {% raw %}${{ secrets.PYPI_TOKEN }}{% endraw %} {% endif -%} diff --git a/src/.pre-commit-config.yaml b/src/.pre-commit-config.yaml index 80af367..2fa6a85 100644 --- a/src/.pre-commit-config.yaml +++ b/src/.pre-commit-config.yaml @@ -1,23 +1,16 @@ repos: - - repo: https://github.com/asottile/pyupgrade - rev: v2.20.1 - hooks: - - id: pyupgrade - repo: local hooks: - - id: isort - name: isort - entry: poetry run isort - language: system - types: [python] - - id: black - name: black - entry: poetry run black + - id: ruff-format + name: ruff-format + entry: poetry run ruff format + require_serial: true language: system types: [python] - - id: flake8 - name: flake8 - entry: poetry run pflake8 + - id: ruff-check + name: ruff-check + entry: poetry run ruff check + require_serial: true language: system types: [python] - id: mypy diff --git a/src/pyproject.toml.jinja b/src/pyproject.toml.jinja index 7a96bc0..b2f97c3 100644 --- a/src/pyproject.toml.jinja +++ b/src/pyproject.toml.jinja @@ -11,20 +11,17 @@ classifiers = ["Private :: Do Not Upload"] {%- endif %} [tool.poetry.dependencies] -python = "^3.9" +python = "^3.12" -[tool.poetry.dev-dependencies] -black = "*" -flake8 = "*" -isort = "*" +[tool.poetry.group.dev.dependencies] {% if docs -%} mkdocs = "*" mkdocs-material = "*" {% endif -%} mypy = "*" pre-commit = "*" -pyproject-flake8 = "*" pytest = "*" +ruff = "*" taskipy = "*" [tool.taskipy.tasks] @@ -35,12 +32,9 @@ docs = { cmd = "mkdocs serve -f docs/mkdocs.yaml", help = "Serve documentation"} lint = { cmd = "pre-commit run --all-files", help = "Run linters and formatters" } test = { cmd = "pytest", help = "Run tests" } -[tool.flake8] -max-line-length = 88 -extend-ignore = "E203" - -[tool.isort] -profile = "black" +[tool.ruff] +fix = true +select = ["B", "E", "F", "I", "SIM", "UP"] [tool.mypy] strict = true diff --git a/src/{% if docker %}Dockerfile{% endif %}.jinja b/src/{% if docker %}Dockerfile{% endif %}.jinja index f9f24f4..946877c 100644 --- a/src/{% if docker %}Dockerfile{% endif %}.jinja +++ b/src/{% if docker %}Dockerfile{% endif %}.jinja @@ -1,20 +1,20 @@ -FROM python:3.9-alpine AS base +FROM python:3.12-alpine AS base WORKDIR /app ### Builder ### FROM base AS builder # Install poetry -RUN pip install --no-cache-dir poetry~=1.1 \ +RUN pip install --no-cache-dir poetry~=1.6 \ && poetry config virtualenvs.in-project true # Install deps COPY pyproject.toml poetry.lock ./ -RUN poetry install --no-root --no-dev +RUN poetry install --no-root --only=main # Add source COPY . . -RUN poetry install --no-dev +RUN poetry install --only=main ### Runner ### FROM base AS runner