Skip to content

Commit

Permalink
Simplify caching mechanisms for CI and PROD images
Browse files Browse the repository at this point in the history
  • Loading branch information
potiuk committed Dec 28, 2024
1 parent 6020a26 commit 84da531
Show file tree
Hide file tree
Showing 104 changed files with 1,076 additions and 2,651 deletions.
81 changes: 0 additions & 81 deletions .github/actions/checkout_target_commit/action.yml

This file was deleted.

22 changes: 13 additions & 9 deletions .github/actions/prepare_breeze_and_image/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
# under the License.
#
---
name: 'Prepare breeze && current python image'
description: 'Installs breeze and pulls current python image'
name: 'Prepare breeze && current image (CI/PROD)'
description: 'Installs breeze and recreates current python image from artifact'
inputs:
pull-image-type:
description: 'Which image to pull'
description: 'Which image to create'
default: CI
outputs:
host-python-version:
Expand All @@ -35,11 +35,15 @@ runs:
- name: Login to ghcr.io
shell: bash
run: echo "${{ env.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Pull CI image ${{ env.PYTHON_MAJOR_MINOR_VERSION }}:${{ env.IMAGE_TAG }}
shell: bash
run: breeze ci-image pull --tag-as-latest
- name: Restore CI image ${{ env.PYTHON_MAJOR_MINOR_VERSION }}
uses: actions/download-artifact@v4
with:
name: "ci-image-docker-dump-${{ inputs.platform }}-${{ matrix.python-version }}"
path: "/tmp/docker"
if: inputs.pull-image-type == 'CI'
- name: Pull PROD image ${{ env.PYTHON_MAJOR_MINOR_VERSION }}:${{ env.IMAGE_TAG }}
shell: bash
run: breeze prod-image pull --tag-as-latest
- name: Restore PROD image ${{ env.PYTHON_MAJOR_MINOR_VERSION }}
uses: actions/download-artifact@v4
with:
name: "prod-image-docker-dump-${{ inputs.platform }}-${{ matrix.python-version }}"
path: "/tmp/docker/"
if: inputs.pull-image-type == 'PROD'
9 changes: 1 addition & 8 deletions .github/workflows/additional-ci-image-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ on: # yamllint disable-line rule:truthy
description: "The array of labels (in json form) determining self-hosted runners."
required: true
type: string
image-tag:
description: "Tag to set for the image"
required: true
type: string
python-versions:
description: "The list of python versions (stringified JSON array) to run the tests on."
required: true
Expand Down Expand Up @@ -103,8 +99,6 @@ jobs:
contents: read
# This write is only given here for `push` events from "apache/airflow" repo. It is not given for PRs
# from forks. This is to prevent malicious PRs from creating images in the "apache/airflow" repo.
# For regular build for PRS this "build-prod-images" workflow will be skipped anyway by the
# "in-workflow-build" condition
packages: write
secrets: inherit
with:
Expand Down Expand Up @@ -159,7 +153,7 @@ jobs:
# # There is no point in running this one in "canary" run, because the above step is doing the
# # same build anyway.
# build-ci-arm-images:
# name: Build CI ARM images (in-workflow)
# name: Build CI ARM images
# uses: ./.github/workflows/ci-image-build.yml
# permissions:
# contents: read
Expand All @@ -169,7 +163,6 @@ jobs:
# push-image: "false"
# runs-on-as-json-public: ${{ inputs.runs-on-as-json-public }}
# runs-on-as-json-self-hosted: ${{ inputs.runs-on-as-json-self-hosted }}
# image-tag: ${{ inputs.image-tag }}
# python-versions: ${{ inputs.python-versions }}
# platform: "linux/arm64"
# branch: ${{ inputs.branch }}
Expand Down
26 changes: 6 additions & 20 deletions .github/workflows/additional-prod-image-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ on: # yamllint disable-line rule:truthy
description: "Branch used to construct constraints URL from."
required: true
type: string
image-tag:
description: "Tag to set for the image"
required: true
type: string
upgrade-to-newer-dependencies:
description: "Whether to upgrade to newer dependencies (true/false)"
required: true
Expand Down Expand Up @@ -70,7 +66,6 @@ jobs:
default-python-version: ${{ inputs.default-python-version }}
branch: ${{ inputs.default-branch }}
use-uv: "false"
image-tag: ${{ inputs.image-tag }}
build-provider-packages: ${{ inputs.default-branch == 'main' }}
upgrade-to-newer-dependencies: ${{ inputs.upgrade-to-newer-dependencies }}
chicken-egg-providers: ${{ inputs.chicken-egg-providers }}
Expand All @@ -88,7 +83,6 @@ jobs:
default-python-version: ${{ inputs.default-python-version }}
branch: ${{ inputs.default-branch }}
use-uv: "false"
image-tag: ${{ inputs.image-tag }}
build-provider-packages: ${{ inputs.default-branch == 'main' }}
upgrade-to-newer-dependencies: ${{ inputs.upgrade-to-newer-dependencies }}
chicken-egg-providers: ${{ inputs.chicken-egg-providers }}
Expand Down Expand Up @@ -122,11 +116,10 @@ jobs:
- name: Login to ghcr.io
shell: bash
run: echo "${{ env.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Pull PROD image ${{ inputs.default-python-version}}:${{ inputs.image-tag }}
run: breeze prod-image pull --tag-as-latest
- name: Pull PROD image ${{ inputs.default-python-version}}
run: breeze prod-image pull
env:
PYTHON_MAJOR_MINOR_VERSION: "${{ inputs.default-python-version }}"
IMAGE_TAG: "${{ inputs.image-tag }}"
- name: "Setup python"
uses: actions/setup-python@v5
with:
Expand All @@ -138,15 +131,14 @@ jobs:
cd ./docker_tests && \
python -m pip install -r requirements.txt && \
TEST_IMAGE=\"ghcr.io/${{ github.repository }}/${{ inputs.default-branch }}\
/prod/python${{ inputs.default-python-version }}:${{ inputs.image-tag }}\" \
/prod/python${{ inputs.default-python-version }}\" \
python -m pytest test_examples_of_prod_image_building.py -n auto --color=yes"

test-docker-compose-quick-start:
timeout-minutes: 60
name: "Docker-compose quick start with PROD image verifying"
runs-on: ${{ fromJSON(inputs.runs-on-as-json-public) }}
env:
IMAGE_TAG: "${{ inputs.image-tag }}"
PYTHON_MAJOR_MINOR_VERSION: "${{ inputs.default-python-version }}"
GITHUB_REPOSITORY: ${{ github.repository }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -161,14 +153,8 @@ jobs:
with:
fetch-depth: 2
persist-credentials: false
- name: "Cleanup docker"
run: ./scripts/ci/cleanup_docker.sh
- name: "Install Breeze"
uses: ./.github/actions/breeze
- name: Login to ghcr.io
shell: bash
run: echo "${{ env.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: "Pull image ${{ inputs.default-python-version}}:${{ inputs.image-tag }}"
run: breeze prod-image pull --tag-as-latest
- name: "Prepare breeze & CI image: ${{ inputs.default-python-version}}"
uses: ./.github/actions/prepare_breeze_and_image
id: breeze
- name: "Test docker-compose quick start"
run: breeze testing docker-compose-tests
1 change: 0 additions & 1 deletion .github/workflows/basic-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,6 @@ jobs:
runs-on: ${{ fromJSON(inputs.runs-on-as-json-public) }}
env:
PYTHON_MAJOR_MINOR_VERSION: "${{ inputs.default-python-version }}"
IMAGE_TAG: ${{ inputs.image-tag }}
GITHUB_REPOSITORY: ${{ github.repository }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_USERNAME: ${{ github.actor }}
Expand Down
Loading

0 comments on commit 84da531

Please sign in to comment.