Skip to content

Commit

Permalink
test-multiple-images-versions
Browse files Browse the repository at this point in the history
  • Loading branch information
ademariag committed Sep 15, 2023
1 parent 98dafed commit ce52349
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 15 deletions.
50 changes: 37 additions & 13 deletions .github/workflows/test-build-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ jobs:
if: success() || failure() # Continue running if other jobs fail
strategy:
matrix:
python-version: [3.8, 3.9]
python-version:
- "3.8"
- "3.9"
- "3.10"

steps:
- name: Checkout kapitan recursively
Expand Down Expand Up @@ -76,7 +79,7 @@ jobs:
make test_coverage
build:
name: build ${{ matrix.platform }} image
name: build py${{ matrix.python-version }}-${{ matrix.platform }}
if: success() || failure() # Continue running if other jobs fail
runs-on: ubuntu-latest
strategy:
Expand All @@ -85,6 +88,10 @@ jobs:
platform:
- linux/amd64
- linux/arm64
python-version:
- "3.8"
- "3.9"
- "3.10"
steps:
- name: Checkout kapitan recursively
uses: actions/checkout@v4
Expand All @@ -106,17 +113,19 @@ jobs:
platforms: ${{ matrix.platform }}
load: True
file: Dockerfile
tags: local-test-${{ matrix.platform }}
cache-from: type=gha,scope=$GITHUB_REF_NAME-${{ matrix.platform }}
cache-to: type=gha,mode=max,scope=$GITHUB_REF_NAME-${{ matrix.platform }}
tags: local-test-py${{ matrix.python-version }}-${{ matrix.platform }}
build-args:
PYTHONVERSION=${{ matrix.python-version }}
cache-from: type=gha,scope=$GITHUB_REF_NAME-py${{ matrix.python-version }}-${{ matrix.platform }}
cache-to: type=gha,mode=max,scope=$GITHUB_REF_NAME-py${{ matrix.python-version }}-${{ matrix.platform }}

- name: Test Kapitan for ${{ matrix.platform }}
- name: Test Kapitan for py${{ matrix.python-version }}-${{ matrix.platform }}
run: |
docker run -t --rm local-test-${{ matrix.platform }} --version
docker run -t --rm local-test-py${{ matrix.python-version }}-${{ matrix.platform }} --version
publish:
name: publish platform images
name: publish platform images for py${{ matrix.python-version }}
# Only starts if everything else is successful
needs: [lint, test, build]
if: github.event_name != 'pull_request'
Expand All @@ -127,6 +136,10 @@ jobs:
platform:
- linux/amd64
- linux/arm64
python-version:
- "3.8"
- "3.9"
- "3.10"
steps:
- name: Checkout kapitan recursively
uses: actions/checkout@v4
Expand Down Expand Up @@ -166,7 +179,7 @@ jobs:
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
flavor: |
suffix=-${{ matrix.platform }}
suffix=-py${{ matrix.python-version }}-${{ matrix.platform }}
- name: Build and push by digest
id: push-digest
Expand All @@ -178,16 +191,25 @@ jobs:
platforms: ${{ matrix.platform }}
push: true
tags: ${{ steps.meta.outputs.tags }}
build-args:
PYTHONVERSION=${{ matrix.python-version }}
labels: ${{steps.meta.output.labels}}
cache-from: type=gha,scope=$GITHUB_REF_NAME-${{ matrix.platform }}
cache-to: type=gha,mode=max,scope=$GITHUB_REF_NAME-${{ matrix.platform }}
cache-from: type=gha,scope=$GITHUB_REF_NAME-py${{ matrix.python-version }}-${{ matrix.platform }}
cache-to: type=gha,mode=max,scope=$GITHUB_REF_NAME-py${{ matrix.python-version }}-${{ matrix.platform }}

build-multi-architecture:
name: combine platform images
name: combine platform images for py${{ matrix.python-version }}
needs:
- publish
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
python-version:
- "3.8"
- "3.9"
- "3.10"
steps:
# Setup QEMU and Buildx to build multi-platform image
# This was inspired by this example : https://docs.docker.com/build/ci/github-actions/examples/#multi-platform-images
Expand Down Expand Up @@ -221,7 +243,9 @@ jobs:
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
flavor: |
suffix=-py${{ matrix.python-version }}
- uses: int128/docker-manifest-create-action@v1
with:
tags: ${{ steps.meta.outputs.tags }}
Expand Down
6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Build the virtualenv for Kapitan
FROM python:3.8-slim AS python-builder
ARG PYTHONVERSION 3.8
FROM python:${PYTHONVERSION}-slim AS python-builder
ARG TARGETARCH
ENV TARGETARCH=${TARGETARCH:-amd64}

Expand Down Expand Up @@ -44,7 +45,8 @@ RUN pip install --editable .[test] \


# Final image with virtualenv built in previous step
FROM python:3.8-slim
ARG PYTHONVERSION 3.8
FROM python:${PYTHONVERSION}-slim

ENV PATH="/opt/venv/bin:${PATH}"
ENV HELM_CACHE_HOME=".cache/helm"
Expand Down

0 comments on commit ce52349

Please sign in to comment.