Skip to content

Commit 0a1841e

Browse files
Added matrix for multiple pytohn versions also to docker
1 parent 8cc5656 commit 0a1841e

File tree

2 files changed

+27
-19
lines changed

2 files changed

+27
-19
lines changed

.github/workflows/ci-cd.yml

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -68,41 +68,46 @@ jobs:
6868
docker:
6969
needs: test
7070
runs-on: ubuntu-latest
71+
strategy:
72+
matrix:
73+
python-version: ["3.9", "3.10", "3.11", "3.12"]
7174
steps:
7275
- name: Checkout
7376
uses: actions/checkout@v4
7477

7578
- name: Set up Docker Buildx
7679
uses: docker/setup-buildx-action@v3
7780

78-
- name: Build Docker Image
81+
- name: Build Docker Image - Python ${{ matrix.python-version }}
7982
uses: docker/build-push-action@v5
8083
with:
8184
context: .
8285
load: true
83-
tags: gpt-po-translator:test
86+
tags: gpt-po-translator:py${{ matrix.python-version }}
87+
build-args: |
88+
PYTHON_VERSION=${{ matrix.python-version }}
8489
cache-from: type=gha
8590
cache-to: type=gha,mode=max
8691

8792
- name: Test Docker Image - Help Text
8893
run: |
8994
# Run Docker image to verify it works
90-
docker run gpt-po-translator:test --version
95+
docker run gpt-po-translator:py${{ matrix.python-version }} --version
9196
9297
# Check help output (should exit with 0)
93-
docker run gpt-po-translator:test --help
98+
docker run gpt-po-translator:py${{ matrix.python-version }} --help
9499
95-
echo "✅ Basic Docker image tests passed"
100+
echo "✅ Basic Docker image tests passed for Python ${{ matrix.python-version }}"
96101
97102
- name: Test Docker Image - CLI Options and Tests
98103
run: |
99104
# Test with --list-models (doesn't require API key)
100-
docker run -e OPENAI_API_KEY="dummy-key" gpt-po-translator:test --provider openai --list-models
105+
docker run -e OPENAI_API_KEY="dummy-key" gpt-po-translator:py${{ matrix.python-version }} --provider openai --list-models
101106
102107
# Run the Python tests inside the container
103-
docker run gpt-po-translator:test python -m pytest
108+
docker run gpt-po-translator:py${{ matrix.python-version }} python -m pytest
104109
105-
echo "✅ CLI option test and pytest passed"
110+
echo "✅ CLI option test and pytest passed for Python ${{ matrix.python-version }}"
106111
107112
- name: Test Docker Image with Sample PO file
108113
run: |
@@ -114,17 +119,17 @@ jobs:
114119
docker run \
115120
-v $(pwd)/test-po-files:/test \
116121
-e OPENAI_API_KEY="dummy-key" \
117-
gpt-po-translator:test \
122+
gpt-po-translator:py${{ matrix.python-version }} \
118123
--folder /test --lang de --provider openai --model gpt-3.5-turbo-instruct --list-models
119124
120125
# Check if the tool can access the mounted files
121126
echo "Verifying test file is accessible..."
122127
docker run \
123128
-v $(pwd)/test-po-files:/test \
124-
gpt-po-translator:test \
129+
gpt-po-translator:py${{ matrix.python-version }} \
125130
--folder /test --help
126131
127-
echo "✅ Docker volume mount test passed"
132+
echo "✅ Docker volume mount test passed for Python ${{ matrix.python-version }}"
128133
129134
- name: Login to GitHub Container Registry
130135
if: github.event_name != 'pull_request' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/'))
@@ -141,13 +146,13 @@ jobs:
141146
images: |
142147
ghcr.io/${{ github.repository }}
143148
tags: |
144-
type=ref,event=branch
145-
type=semver,pattern={{version}}
146-
type=semver,pattern={{major}}.{{minor}}
147-
type=semver,pattern={{major}}
148-
type=sha,format=short
149+
type=ref,event=branch,suffix=-py${{ matrix.python-version }}
150+
type=semver,pattern={{version}}-py${{ matrix.python-version }}
151+
type=semver,pattern={{major}}.{{minor}}-py${{ matrix.python-version }}
152+
type=semver,pattern={{major}}-py${{ matrix.python-version }}
153+
type=sha,format=short,suffix=-py${{ matrix.python-version }}
149154
flavor: |
150-
latest=true
155+
latest=${{ matrix.python-version == '3.11' }}
151156
152157
- name: Build and Push Docker Image
153158
if: github.event_name != 'pull_request' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/'))
@@ -157,5 +162,7 @@ jobs:
157162
push: true
158163
tags: ${{ steps.meta.outputs.tags }}
159164
labels: ${{ steps.meta.outputs.labels }}
165+
build-args: |
166+
PYTHON_VERSION=${{ matrix.python-version }}
160167
cache-from: type=gha
161168
cache-to: type=gha,mode=max

Dockerfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
FROM python:3.11-slim
1+
ARG PYTHON_VERSION=3.11
2+
FROM python:${PYTHON_VERSION}-slim
23

34
WORKDIR /app
45

@@ -16,4 +17,4 @@ RUN pip install .
1617
COPY docker-entrypoint.sh /usr/local/bin/
1718
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
1819

19-
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
20+
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]

0 commit comments

Comments
 (0)