Skip to content

Commit ae5c427

Browse files
authored
Merge pull request #95 from smkent/container-version
Fix container build with updated poetry-dynamic-versioning
2 parents 41468dd + a813ce2 commit ae5c427

4 files changed

Lines changed: 14 additions & 4 deletions

File tree

β€Žtests/test_new_cookie.pyβ€Ž

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ def test_new_cookie_create(temp_dir: str) -> None:
2323
"github_user": "ness.unittest.example",
2424
"project_description": "Unit test project",
2525
"project_name": "unit-test-1",
26+
"enable_container_publish": "yes",
2627
}
2728
),
2829
]
@@ -45,3 +46,7 @@ def test_new_cookie_create(temp_dir: str) -> None:
4546
subprocess.check_call(["poetry", "install"], cwd=project_dir)
4647
# Run rendered project's tests
4748
subprocess.check_call(["poetry", "run", "poe", "test"], cwd=project_dir)
49+
# Build container for rendered project
50+
subprocess.check_call(
51+
["docker", "build", ".", "--no-cache"], cwd=project_dir
52+
)

β€Ž{{cookiecutter.project_name}}/.github/workflows/actions/python-poetry/action.ymlβ€Ž

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ runs:
2626
python-version: ${{ "{{" }} inputs.python_version }}
2727
cache: poetry
2828

29-
- name: πŸ› οΈ Install project dependencies
29+
- name: πŸ› οΈ Install project and dependencies
3030
shell: bash
3131
env:
3232
# https://github.com/python-poetry/poetry/issues/1917
@@ -35,8 +35,10 @@ runs:
3535
run: |
3636
poetry install
3737
poetry lock --check
38-
[ "$(poetry version -s)" != "0.0.0" ] \
38+
PROJECT_VERSION=$(poetry version -s)
39+
[ "${PROJECT_VERSION}" != "0.0.0" ] \
3940
|| { echo "Versioning broken"; exit 1; }
41+
echo "PROJECT_VERSION=${PROJECT_VERSION}" >> $GITHUB_ENV
4042
4143
- name: πŸͺ Cache pre-commit hooks
4244
uses: actions/cache@v3

β€Ž{{cookiecutter.project_name}}/.github/workflows/container.ymlβ€Ž

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636

3737
- name: πŸ“‘ Collect image metadata
3838
id: meta
39-
uses: docker/metadata-action@v4.1.1
39+
uses: docker/metadata-action@v4.3.0
4040
with:
4141
images: ${{ "{{" }} env.REGISTRY }}/${{ "{{" }} env.IMAGE_NAME }}
4242
tags: |
@@ -57,9 +57,11 @@ jobs:
5757
run: poetry run poe test
5858

5959
- name: πŸ“¦ Build and publish container image
60-
uses: docker/build-push-action@v3.2.0
60+
uses: docker/build-push-action@v4.0.0
6161
with:
6262
context: .
6363
push: ${{ "{{" }} github.event_name != 'pull_request' }}
6464
tags: ${{ "{{" }} steps.meta.outputs.tags }}
6565
labels: ${{ "{{" }} steps.meta.outputs.labels }}
66+
build-args: |
67+
"POETRY_DYNAMIC_VERSIONING_BYPASS=${{ "{{" }} env.PROJECT_VERSION }}"

β€Ž{{cookiecutter.project_name}}/Dockerfileβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
FROM python:3-alpine
2+
ARG POETRY_DYNAMIC_VERSIONING_BYPASS="0.0.0"
23
RUN apk add --no-cache tini
34
COPY docker/entrypoint /
45

0 commit comments

Comments
Β (0)