Skip to content

Commit

Permalink
Merge pull request #74 from max-pfeiffer/feature/poetry_v1_8_1_update
Browse files Browse the repository at this point in the history
Poetry 1.8.3 update
  • Loading branch information
max-pfeiffer committed May 12, 2024
2 parents e15f016 + 89a4323 commit 9f9fd30
Show file tree
Hide file tree
Showing 11 changed files with 512 additions and 561 deletions.
20 changes: 10 additions & 10 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.7.1
version: 1.8.3
virtualenvs-in-project: true
- name: Load cached venv
id: cached-poetry-dependencies
Expand All @@ -37,9 +37,9 @@ jobs:
strategy:
fail-fast: false
matrix:
python_version: ["3.10.14", "3.11.8", "3.12.2"]
python_version: ["3.10.14", "3.11.9", "3.12.3"]
os_variant: ["bookworm", "slim-bookworm"]
poetry_version: ["1.6.1", "1.7.1", "1.8.2"]
poetry_version: ["1.6.1", "1.7.1", "1.8.3"]
steps:
- name: Checkout Repository
uses: actions/checkout@v4
Expand All @@ -52,7 +52,7 @@ jobs:
- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: 1.7.1
version: 1.8.3
virtualenvs-in-project: true
- name: Load cached venv
id: cached-poetry-dependencies
Expand Down Expand Up @@ -85,9 +85,9 @@ jobs:
strategy:
fail-fast: false
matrix:
python_version: ["3.10.14", "3.11.8", "3.12.2"]
python_version: ["3.10.14", "3.11.9", "3.12.3"]
os_variant: ["bookworm", "slim-bookworm"]
poetry_version: ["1.6.1", "1.7.1", "1.8.2"]
poetry_version: ["1.6.1", "1.7.1", "1.8.3"]
steps:
- name: Checkout Repository
uses: actions/checkout@v4
Expand All @@ -100,7 +100,7 @@ jobs:
- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: 1.7.1
version: 1.8.3
virtualenvs-in-project: true
- name: Load cached venv
id: cached-poetry-dependencies
Expand Down Expand Up @@ -157,9 +157,9 @@ jobs:
strategy:
fail-fast: false
matrix:
python_version: ["3.10.14", "3.11.8", "3.12.2"]
python_version: ["3.10.14", "3.11.9", "3.12.3"]
os_variant: ["bookworm", "slim-bookworm"]
poetry_version: ["1.6.1", "1.7.1", "1.8.2"]
poetry_version: ["1.6.1", "1.7.1", "1.8.3"]
steps:
- name: Checkout Repository
uses: actions/checkout@v4
Expand All @@ -174,7 +174,7 @@ jobs:
- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: 1.7.1
version: 1.8.3
virtualenvs-in-project: true
- name: Load cached venv
id: cached-poetry-dependencies
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@
.python-version
.coverage
__pycache__
build_image_coverage_report.xml
publish_image_coverage_report.xml
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ This multi arch image supports AMD64 and ARM64 architectures.
**Poetry versions:**
* v1.6.1
* v1.7.1
* v1.8.2
* v1.8.3

**Python versions:**
* v3.10
Expand Down
737 changes: 397 additions & 340 deletions poetry.lock

Large diffs are not rendered by default.

25 changes: 8 additions & 17 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
[tool.poetry]
name = "python-poetry"
version = "1.10.0"
version = "1.11.0"
description = "A Python Docker image with Poetry installed and ready to use."
authors = ["Max Pfeiffer <[email protected]>"]
license = "MIT"

[tool.poetry.dependencies]
python = "3.11.*"
click = "8.1.7"
python-on-whales = "0.70.1"
python-on-whales = "0.71.0"

[tool.poetry.dev-dependencies]
bcrypt = "4.1.2"
coverage = "7.4.4"
bcrypt = "4.1.3"
coverage = "7.5.1"
docker-image-py = "0.1.12"
furl = "2.1.3"
pytest = "8.1.1"
pytest-cov = "4.1.0"
pytest = "8.2.0"
pytest-cov = "5.0.0"
pytest-dotenv = "0.5.2"
pre-commit = "3.7.0"
pre-commit = "3.7.1"
semver = "3.0.2"
testcontainers = "4.1.1"
testcontainers = "4.4.0"

[tool.ruff]
exclude = [".venv"]
Expand All @@ -46,15 +46,6 @@ testpaths = [
"tests",
]

# https://black.readthedocs.io/en/stable/usage_and_configuration/the_basics.html#configuration-via-a-file
[tool.black]
line-length = 80
target-version = ["py311"]

[tool.pylint.main]
errors-only = true
recursive = "y"

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
15 changes: 4 additions & 11 deletions tests/build_image/conftest.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
"""Test fixtures for image build tests."""

from os import getenv
from time import sleep

import pytest
from python_on_whales import Builder, DockerClient
from testcontainers.registry import DockerRegistryContainer

from build.constants import PLATFORMS
from build.utils import get_image_reference
from tests.constants import CONTEXT, REGISTRY_PASSWORD, REGISTRY_USERNAME
from tests.registry_container import DockerRegistryContainer


@pytest.fixture(scope="package")
Expand All @@ -18,16 +17,10 @@ def registry_container() -> DockerRegistryContainer:
:return:
"""
registry_container = DockerRegistryContainer(
with DockerRegistryContainer(
username=REGISTRY_USERNAME, password=REGISTRY_PASSWORD
).with_bind_ports(5000, 5000)
registry_container.start()

# Wait for the registry container to come up
sleep(3.0)

yield registry_container
registry_container.stop()
).with_bind_ports(5000, 5000) as registry_container:
yield registry_container


@pytest.fixture(scope="package")
Expand Down
16 changes: 1 addition & 15 deletions tests/build_image/test_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,14 @@
from furl import furl
from requests import Response, get
from requests.auth import HTTPBasicAuth
from testcontainers.registry import DockerRegistryContainer

from tests.constants import REGISTRY_PASSWORD, REGISTRY_USERNAME
from tests.registry_container import DockerRegistryContainer
from tests.utils import ImageTagComponents

BASIC_AUTH: HTTPBasicAuth = HTTPBasicAuth(REGISTRY_USERNAME, REGISTRY_PASSWORD)


def test_registry(registry_container: DockerRegistryContainer):
"""Test if registry container provides a catalog.
:param registry_container:
:return:
"""
furl_item: furl = furl(f"http://{registry_container.get_registry()}")
furl_item.path /= "v2/_catalog"

response: Response = get(furl_item.url, auth=BASIC_AUTH)

assert response.status_code == 200


def test_registry_with_images(
registry_container: DockerRegistryContainer, image_reference: str
):
Expand Down
15 changes: 15 additions & 0 deletions tests/publish_image/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,21 @@

import pytest
from click.testing import CliRunner
from testcontainers.registry import DockerRegistryContainer

from tests.constants import REGISTRY_PASSWORD, REGISTRY_USERNAME


@pytest.fixture(scope="package")
def publish_registry_container() -> DockerRegistryContainer:
"""Provide a Registry container locally for publishing the image.
:return:
"""
with DockerRegistryContainer(
username=REGISTRY_USERNAME, password=REGISTRY_PASSWORD
).with_bind_ports(5000, 5000) as registry_container:
yield registry_container


@pytest.fixture(scope="package")
Expand Down
92 changes: 44 additions & 48 deletions tests/publish_image/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@

from click.testing import CliRunner, Result
from python_on_whales import DockerException
from testcontainers.registry import DockerRegistryContainer

from build.publish import main
from tests.constants import REGISTRY_PASSWORD, REGISTRY_USERNAME
from tests.registry_container import DockerRegistryContainer


def test_registry_with_credentials(
image_version: str,
publish_registry_container: DockerRegistryContainer,
cli_runner: CliRunner,
python_version: str,
os_variant: str,
Expand All @@ -26,33 +27,31 @@ def test_registry_with_credentials(
:param poetry_version:
:return:
"""
with DockerRegistryContainer(
username=REGISTRY_USERNAME, password=REGISTRY_PASSWORD
).with_bind_ports(5000, 5000) as docker_registry:
result: Result = cli_runner.invoke(
main,
args=[
"--docker-hub-username",
REGISTRY_USERNAME,
"--docker-hub-password",
REGISTRY_PASSWORD,
"--version-tag",
image_version,
"--python-version",
python_version,
"--os-variant",
os_variant,
"--poetry-version",
poetry_version,
"--registry",
docker_registry.get_registry(),
],
)
assert result.exit_code == 0
result: Result = cli_runner.invoke(
main,
args=[
"--docker-hub-username",
REGISTRY_USERNAME,
"--docker-hub-password",
REGISTRY_PASSWORD,
"--version-tag",
image_version,
"--python-version",
python_version,
"--os-variant",
os_variant,
"--poetry-version",
poetry_version,
"--registry",
publish_registry_container.get_registry(),
],
)
assert result.exit_code == 0


def test_registry_with_wrong_credentials(
image_version: str,
publish_registry_container: DockerRegistryContainer,
cli_runner: CliRunner,
python_version: str,
os_variant: str,
Expand All @@ -69,27 +68,24 @@ def test_registry_with_wrong_credentials(
:param poetry_version:
:return:
"""
with DockerRegistryContainer(
username=REGISTRY_USERNAME, password=REGISTRY_PASSWORD
).with_bind_ports(5000, 5000) as docker_registry:
result: Result = cli_runner.invoke(
main,
args=[
"--docker-hub-username",
"bang",
"--docker-hub-password",
"boom",
"--version-tag",
image_version,
"--python-version",
python_version,
"--os-variant",
os_variant,
"--poetry-version",
poetry_version,
"--registry",
docker_registry.get_registry(),
],
)
assert result.exit_code == 1
assert isinstance(result.exception, DockerException)
result: Result = cli_runner.invoke(
main,
args=[
"--docker-hub-username",
"bang",
"--docker-hub-password",
"boom",
"--version-tag",
image_version,
"--python-version",
python_version,
"--os-variant",
os_variant,
"--poetry-version",
poetry_version,
"--registry",
publish_registry_container.get_registry(),
],
)
assert result.exit_code == 1
assert isinstance(result.exception, DockerException)
Loading

0 comments on commit 9f9fd30

Please sign in to comment.