Skip to content

Commit

Permalink
Merge pull request #4 from max-pfeiffer/feature/configurable_python_v…
Browse files Browse the repository at this point in the history
…ersion

Made python version and OS variant configurable
  • Loading branch information
max-pfeiffer authored Dec 18, 2023
2 parents c1efb0e + a8b5211 commit 364064d
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 2 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,37 @@ name: Pipeline
on: push

jobs:
code-quality:
runs-on: ubuntu-20.04
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: 3.11
- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: 1.7.1
virtualenvs-in-project: true
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: |
poetry install --no-interaction --no-root
- name: Run pylint and black
run: |
source .venv/bin/activate
black --check .
run-tests:
needs: code-quality
runs-on: ubuntu-20.04
steps:
- name: Checkout Repository
Expand Down
2 changes: 2 additions & 0 deletions cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,7 @@
"project_description": "",
"author_name": "",
"author_email": "",
"python_version": ["3.12.0", "3.10.13", "3.10.13"],
"operating_system_variant": ["slim-bookworm", "bookworm"],
"_extensions": ["cookiecutter.extensions.SlugifyExtension"]
}
13 changes: 12 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pre-commit = "3.6.0"
pytest-cookies = "0.7.0"
pytest-cov = "4.1.0"
toml = "0.10.2"
dockerfile-parse = "2.0.1"

# https://docs.pytest.org/en/latest/reference/customize.html
[tool.pytest.ini_options]
Expand Down
8 changes: 8 additions & 0 deletions tests/test_custom_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import toml
from pytest_cookies.plugin import Result
from dockerfile_parse import DockerfileParser


def test_custom_config(cookies) -> None:
Expand All @@ -17,6 +18,8 @@ def test_custom_config(cookies) -> None:
"project_description": "A project description which does make a lot of sense.",
"author_name": "Jane Doe",
"author_email": "jane.doe@unknown.com",
"python_version": "3.10.13",
"operating_system_variant": "bookworm",
}
)

Expand All @@ -35,3 +38,8 @@ def test_custom_config(cookies) -> None:
assert toml_data["tool"]["poetry"]["authors"] == [
"Jane Doe <jane.doe@unknown.com>"
]

dockerfile: Path = result.project_path / "Dockerfile"
dfp = DockerfileParser(path=str(dockerfile))

assert "3.10.13-bookworm" in dfp.baseimage
6 changes: 6 additions & 0 deletions tests/test_default_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import toml
from pytest_cookies.plugin import Result
from dockerfile_parse import DockerfileParser


def test_default_config(cookies) -> None:
Expand All @@ -22,3 +23,8 @@ def test_default_config(cookies) -> None:
assert toml_data["tool"]["poetry"]["version"] == "0.0.0"
assert toml_data["tool"]["poetry"]["description"] == ""
assert toml_data["tool"]["poetry"]["authors"] == []

dockerfile: Path = result.project_path / "Dockerfile"
dfp = DockerfileParser(path=str(dockerfile))

assert "3.12.0-slim-bookworm" in dfp.baseimage
2 changes: 1 addition & 1 deletion {{cookiecutter.project_slug}}/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Be aware that you need to specify these arguments before the first FROM
# see: https://docs.docker.com/engine/reference/builder/#understand-how-arg-and-from-interact
FROM pfeiffermax/uvicorn-poetry:3.2.0-python3.11.6-slim-bookworm
FROM pfeiffermax/uvicorn-poetry:3.2.0-python{{ cookiecutter.python_version }}-{{ cookiecutter.operating_system_variant }}

# install [tool.poetry.dependencies]
# this will install virtual environment into /.venv because of POETRY_VIRTUALENVS_IN_PROJECT=true
Expand Down

0 comments on commit 364064d

Please sign in to comment.