Skip to content

Commit

Permalink
Merge branch 'main' into feature/poetry_v1_8_1_update
Browse files Browse the repository at this point in the history
  • Loading branch information
max-pfeiffer committed Feb 29, 2024
2 parents f3d563c + a5aa52c commit 9ee9881
Show file tree
Hide file tree
Showing 26 changed files with 587 additions and 580 deletions.
5 changes: 0 additions & 5 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "pip"
Expand Down
13 changes: 6 additions & 7 deletions .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: 1.6.1
version: 1.7.1
virtualenvs-in-project: true
- name: Load cached venv
id: cached-poetry-dependencies
Expand All @@ -27,11 +27,10 @@ jobs:
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: |
poetry install --no-interaction --no-root
- name: Run pylint and black
- name: Run ruff
run: |
source .venv/bin/activate
pylint build tests
black --check .
ruff check --config pyproject.toml .
run-build-image-tests:
needs: code-quality
Expand All @@ -54,7 +53,7 @@ jobs:
- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: 1.6.1
version: 1.7.1
virtualenvs-in-project: true
- name: Load cached venv
id: cached-poetry-dependencies
Expand Down Expand Up @@ -103,7 +102,7 @@ jobs:
- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: 1.6.1
version: 1.7.1
virtualenvs-in-project: true
- name: Load cached venv
id: cached-poetry-dependencies
Expand Down Expand Up @@ -177,7 +176,7 @@ jobs:
- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: 1.6.1
version: 1.7.1
virtualenvs-in-project: true
- name: Load cached venv
id: cached-poetry-dependencies
Expand Down
25 changes: 6 additions & 19 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,10 @@ repos:
- id: check-merge-conflict
- id: detect-private-key
- id: check-added-large-files
- repo: https://github.com/psf/black
rev: 23.11.0
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.3.0
hooks:
- id: black
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
name: isort (python)
- repo: local
hooks:
- id: pylint
name: pylint
entry: .venv/bin/pylint
language: system
types: [python]
args:
- build
- tests

- id: ruff
args: ["--fix", "--config", "pyproject.toml", "."]
- id: ruff-format
args: ["--config", "pyproject.toml", "."]
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
[![Poetry](https://img.shields.io/endpoint?url=https://python-poetry.org/badge/v0.json)](https://python-poetry.org/)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![Imports: isort](https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336)](https://pycqa.github.io/isort/)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
[![codecov](https://codecov.io/gh/max-pfeiffer/python-poetry/branch/main/graph/badge.svg?token=WQI2SJJLZN)](https://codecov.io/gh/max-pfeiffer/python-poetry)
![pipeline workflow](https://github.com/max-pfeiffer/python-poetry/actions/workflows/pipeline.yml/badge.svg)
![Docker Image Size (latest semver)](https://img.shields.io/docker/image-size/pfeiffermax/python-poetry?sort=semver)
Expand Down
1 change: 1 addition & 0 deletions build/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Build package."""
2 changes: 2 additions & 0 deletions build/constants.py
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
"""Constants."""

PLATFORMS: list[str] = ["linux/amd64", "linux/arm64/v8"]
30 changes: 20 additions & 10 deletions build/publish.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
"""Publish CLI."""

from os import getenv
from pathlib import Path

import click
from build.constants import PLATFORMS
from python_on_whales import Builder, DockerClient

from build.constants import PLATFORMS
from build.utils import get_context, get_image_reference
from pathlib import Path
from python_on_whales import DockerClient, Builder
from os import getenv


@click.command()
Expand All @@ -18,9 +21,7 @@
envvar="DOCKER_HUB_PASSWORD",
help="Docker Hub password",
)
@click.option(
"--version-tag", envvar="GIT_TAG_NAME", required=True, help="Version tag"
)
@click.option("--version-tag", envvar="GIT_TAG_NAME", required=True, help="Version tag")
@click.option(
"--python-version",
envvar="PYTHON_VERSION",
Expand Down Expand Up @@ -51,6 +52,17 @@ def main(
os_variant: str,
registry: str,
) -> None:
"""Build and publish image to Docker Hub.
:param docker_hub_username:
:param docker_hub_password:
:param version_tag:
:param poetry_version:
:param python_version:
:param os_variant:
:param registry:
:return:
"""
github_ref_name: str = getenv("GITHUB_REF_NAME")
context: Path = get_context()
image_reference: str = get_image_reference(
Expand All @@ -59,9 +71,7 @@ def main(
cache_scope: str = f"{poetry_version}-{python_version}-{os_variant}"

if github_ref_name:
cache_to: str = (
f"type=gha,mode=max,scope={github_ref_name}-{cache_scope}"
)
cache_to: str = f"type=gha,mode=max,scope={github_ref_name}-{cache_scope}"
cache_from: str = f"type=gha,scope={github_ref_name}-{cache_scope}"
else:
cache_to = f"type=local,mode=max,dest=/tmp,scope={cache_scope}"
Expand Down
20 changes: 19 additions & 1 deletion build/utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
"""Build utilities."""

from pathlib import Path


def get_context() -> Path:
"""Docker build context.
:return:
"""
return Path(__file__).parent.resolve()


Expand All @@ -12,5 +18,17 @@ def get_image_reference(
python_version: str,
os_variant: str,
) -> str:
reference: str = f"{registry}/pfeiffermax/python-poetry:{image_version}-poetry{poetry_version}-python{python_version}-{os_variant}"
"""Docker Hub image reference.
:param registry:
:param image_version:
:param poetry_version:
:param python_version:
:param os_variant:
:return:
"""
reference: str = (
f"{registry}/pfeiffermax/python-poetry:"
f"{image_version}-poetry{poetry_version}-python{python_version}-{os_variant}"
)
return reference
Loading

0 comments on commit 9ee9881

Please sign in to comment.