-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from max-pfeiffer/feature/base_image_update_and…
…_multi_arch Feature/base image update and multi arch
- Loading branch information
Showing
29 changed files
with
2,731 additions
and
1,964 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
PYTHON_VERSION=3.12.2 | ||
OS_VARIANT=slim-bookworm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,15 +7,15 @@ jobs: | |
runs-on: ubuntu-20.04 | ||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v3 | ||
uses: actions/checkout@v4 | ||
- name: Setup Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: 3.9 | ||
python-version: 3.11 | ||
- name: Install Poetry | ||
uses: snok/install-poetry@v1 | ||
with: | ||
version: 1.4.1 | ||
version: 1.8.2 | ||
virtualenvs-in-project: true | ||
- name: Load cached venv | ||
id: cached-poetry-dependencies | ||
|
@@ -27,28 +27,31 @@ jobs: | |
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' | ||
run: | | ||
poetry install --no-interaction --no-root | ||
- name: Run pylint and black | ||
- name: Run pre-commit hooks | ||
run: | | ||
source .venv/bin/activate | ||
pylint build tests | ||
black --check . | ||
poetry run pre-commit run -a | ||
run-tests: | ||
run-build-image-tests: | ||
needs: code-quality | ||
runs-on: ubuntu-20.04 | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
python_version: ["3.10.14", "3.11.8", "3.12.2"] | ||
os_variant: ["bookworm", "slim-bookworm"] | ||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v3 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
uses: actions/checkout@v4 | ||
- name: Expose GitHub Runtime | ||
uses: crazy-max/ghaction-github-runtime@v3 | ||
- name: Setup Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: 3.9 | ||
python-version: 3.11 | ||
- name: Install Poetry | ||
uses: snok/install-poetry@v1 | ||
with: | ||
version: 1.4.1 | ||
version: 1.8.2 | ||
virtualenvs-in-project: true | ||
- name: Load cached venv | ||
id: cached-poetry-dependencies | ||
|
@@ -60,35 +63,112 @@ jobs: | |
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' | ||
run: | | ||
poetry install --no-interaction --no-root | ||
- name: Run all tests with pytest | ||
- name: Run tests for image builds with pytest | ||
env: | ||
PYTHON_VERSION: ${{ matrix.python_version }} | ||
OS_VARIANT: ${{ matrix.os_variant }} | ||
POETRY_VERSION: ${{ matrix.poetry_version }} | ||
run: | | ||
source .venv/bin/activate | ||
pytest --cov | ||
poetry run pytest tests/build_image --cov --cov-report=xml:build_image_coverage_report.xml | ||
- name: Upload coverage report to artifactory | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: build-image-coverage-report-${{ matrix.python_version }}-${{ matrix.os_variant }}-${{ matrix.poetry_version }} | ||
path: build_image_coverage_report.xml | ||
if-no-files-found: error | ||
retention-days: 1 | ||
|
||
run-publish-image-tests: | ||
needs: code-quality | ||
runs-on: ubuntu-20.04 | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
python_version: [ "3.10.14", "3.11.8", "3.12.2" ] | ||
os_variant: [ "bookworm", "slim-bookworm" ] | ||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v4 | ||
- name: Expose GitHub Runtime | ||
uses: crazy-max/ghaction-github-runtime@v3 | ||
- name: Setup Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: 3.11 | ||
- name: Install Poetry | ||
uses: snok/install-poetry@v1 | ||
with: | ||
version: 1.8.2 | ||
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 tests for image publishing with pytest | ||
env: | ||
PYTHON_VERSION: ${{ matrix.python_version }} | ||
OS_VARIANT: ${{ matrix.os_variant }} | ||
POETRY_VERSION: ${{ matrix.poetry_version }} | ||
run: | | ||
poetry run pytest tests/publish_image --cov --cov-report=xml:publish_image_coverage_report.xml | ||
- name: Upload coverage report to artifactory | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: publish-image-coverage-report-${{ matrix.python_version }}-${{ matrix.os_variant }}-${{ matrix.poetry_version }} | ||
path: publish_image_coverage_report.xml | ||
if-no-files-found: error | ||
retention-days: 1 | ||
|
||
upload-test-coverage-reports: | ||
needs: | ||
- run-build-image-tests | ||
- run-publish-image-tests | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v4 | ||
- name: Download coverage reports from artifactory | ||
uses: actions/download-artifact@v3 | ||
- name: Compile the relevant reports | ||
run: | | ||
find . -name "*.xml" -exec cp {} . \; | ||
- name: Upload coverage to Codecov | ||
uses: codecov/codecov-action@v3 | ||
with: | ||
files: ./build_image_coverage_report.xml,./publish_image_coverage_report.xml | ||
fail_ci_if_error: true | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
|
||
publish-all-images: | ||
needs: run-tests | ||
needs: upload-test-coverage-reports | ||
if: startsWith(github.ref, 'refs/tags/') | ||
runs-on: ubuntu-20.04 | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
python_version: ["3.10.14", "3.11.8", "3.12.2"] | ||
os_variant: ["bookworm", "slim-bookworm"] | ||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v3 | ||
uses: actions/checkout@v4 | ||
- name: Expose GitHub Runtime | ||
uses: crazy-max/ghaction-github-runtime@v3 | ||
- name: Get Git Commit Tag Name | ||
uses: olegtarasov/[email protected] | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
- name: Setup Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: 3.9 | ||
python-version: 3.11 | ||
- name: Install Poetry | ||
uses: snok/install-poetry@v1 | ||
with: | ||
version: 1.4.1 | ||
version: 1.8.2 | ||
virtualenvs-in-project: true | ||
- name: Load cached venv | ||
id: cached-poetry-dependencies | ||
|
@@ -104,6 +184,9 @@ jobs: | |
env: | ||
DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }} | ||
DOCKER_HUB_PASSWORD: ${{ secrets.DOCKER_HUB_PASSWORD }} | ||
PYTHON_VERSION: ${{ matrix.python_version }} | ||
OS_VARIANT: ${{ matrix.os_variant }} | ||
POETRY_VERSION: ${{ matrix.poetry_version }} | ||
run: | | ||
source .venv/bin/activate | ||
python -m build.publish |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
.env | ||
.venv | ||
.env | ||
.idea | ||
.vscode | ||
.pytest_cache | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,7 @@ | ||
UVICORN_GUNICORN_POETRY_IMAGE_NAME = "pfeiffermax/uvicorn-gunicorn-poetry" | ||
FAST_API_SINGLESTAGE_IMAGE_NAME: str = "fast-api-singlestage-build" | ||
FAST_API_MULTISTAGE_IMAGE_NAME = "fast-api-multistage-build" | ||
TARGET_ARCHITECTURES: list[str] = [ | ||
"python3.9.16-bullseye", | ||
"python3.9.16-slim-bullseye", | ||
"python3.10.11-bullseye", | ||
"python3.10.11-slim-bullseye", | ||
"python3.11.3-bullseye", | ||
"python3.11.3-slim-bullseye", | ||
] | ||
BASE_IMAGES: dict = { | ||
TARGET_ARCHITECTURES[ | ||
0 | ||
]: "pfeiffermax/python-poetry:1.3.0-poetry1.5.0-python3.9.16-bullseye@sha256:b5859d3d2308999853db2b14647b0ff155b86bf6b9f5799366c01c465ebb532a", | ||
TARGET_ARCHITECTURES[ | ||
1 | ||
]: "pfeiffermax/python-poetry:1.3.0-poetry1.5.0-python3.9.16-slim-bullseye@sha256:9f35b4d878d5a3d421a21e388653e55cce0c09b3736c9b835c0fbbafeb1d1757", | ||
TARGET_ARCHITECTURES[ | ||
2 | ||
]: "pfeiffermax/python-poetry:1.3.0-poetry1.5.0-python3.10.11-bullseye@sha256:d789d7e7a386e70da132ee0015dd7ece073a486b5db39a1aad22c1a59270b461", | ||
TARGET_ARCHITECTURES[ | ||
3 | ||
]: "pfeiffermax/python-poetry:1.3.0-poetry1.5.0-python3.10.11-slim-bullseye@sha256:4a4b89205389d95f77868e574c796c8335447ad18204f1d041987c710c2ec423", | ||
TARGET_ARCHITECTURES[ | ||
4 | ||
]: "pfeiffermax/python-poetry:1.3.0-poetry1.5.0-python3.11.3-bullseye@sha256:42909a19b117146153344ddea0c5332d807d26bb7a63ab5c5fd08a0879a3623c", | ||
TARGET_ARCHITECTURES[ | ||
5 | ||
]: "pfeiffermax/python-poetry:1.3.0-poetry1.5.0-python3.11.3-slim-bullseye@sha256:47905681d13ca8c1c044dbdadfbe882f1633f524755406cb50a7bc2a2b80a422", | ||
} | ||
PYTHON_VERSIONS: dict = { | ||
TARGET_ARCHITECTURES[0]: "3.9.16", | ||
TARGET_ARCHITECTURES[1]: "3.9.16", | ||
TARGET_ARCHITECTURES[2]: "3.10.11", | ||
TARGET_ARCHITECTURES[3]: "3.10.11", | ||
TARGET_ARCHITECTURES[4]: "3.11.3", | ||
TARGET_ARCHITECTURES[5]: "3.11.3", | ||
} | ||
"""Constants for image build.""" | ||
|
||
# As we are running the server with an unprivileged user, we need to use | ||
# a high port. | ||
APPLICATION_SERVER_PORT: str = "8000" | ||
|
||
PLATFORMS: list[str] = ["linux/amd64", "linux/arm64/v8"] |
Oops, something went wrong.