forked from apache/airflow
-
Notifications
You must be signed in to change notification settings - Fork 0
150 lines (150 loc) · 6.43 KB
/
push-image-cache.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
---
name: Push image cache
on: # yamllint disable-line rule:truthy
workflow_call:
inputs:
cache-type:
description: "Type of cache to push (Early / Regular)."
required: true
type: string
include-prod-images:
description: "Whether to include prod images in the cache (true/false)."
required: true
type: string
push-latest-images:
description: "Whether to also push latest images (true/false)."
required: true
type: string
debian-version:
description: "Base Debian distribution to use for the build (bookworm/bullseye)"
type: string
default: "bookworm"
install-mysql-client-type:
description: "MySQL client type to use during build (mariadb/mysql)"
type: string
default: "mariadb"
use-uv:
description: "Whether to use uv to build the image (true/false)"
required: true
type: string
image-tag:
description: "Tag to set for the image"
required: true
type: string
python-versions:
description: "JSON-formatted array of Python versions to build images from"
required: true
type: string
branch:
description: "Branch used to run the CI jobs in (main/v2_*_test)."
required: true
type: string
breeze-python-version:
description: <
Which version of python should be used to install Breeze (3.9 is minimum for reproducible builds)
required: true
type: string
constraints-branch:
description: "Branch used to construct constraints URL from."
required: true
type: string
docker-cache:
description: "Docker cache specification to build the image (registry, local, disabled)."
required: true
type: string
jobs:
push-ci-image-cache:
runs-on: ["self-hosted", "Linux", "X64"]
strategy:
fail-fast: false
matrix:
python: ${{fromJson(inputs.python-versions)}}
env:
RUNS_ON: '["self-hosted", "Linux", "X64"]'
DEBIAN_VERSION: ${{ inputs.debian-version }}
INSTALL_MYSQL_CLIENT_TYPE: ${{ inputs.install-mysql-client-type }}
USE_UV: ${{ inputs.use-uv }}
IMAGE_TAG: ${{ inputs.image-tag }}
DEFAULT_BRANCH: ${{ inputs.branch }}
DEFAULT_CONSTRAINTS_BRANCH: ${{ inputs.constraints-branch }}
UPGRADE_TO_NEWER_DEPENDENCIES: "false"
DOCKER_CACHE: ${{ inputs.docker-cache }}
VERSION_SUFFIX_FOR_PYPI: "dev0"
PLATFORM: "linux/amd64,linux/arm64"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COMMIT_SHA: ${{ github.sha }}
steps:
- name: "Cleanup repo"
shell: bash
run: docker run -v "${GITHUB_WORKSPACE}:/workspace" -u 0:0 bash -c "rm -rf /workspace/*"
- name: "Checkout ${{ github.ref }} ( ${{ github.sha }} )"
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Cleanup docker
uses: ./.github/actions/cleanup-docker
- name: "Install Breeze"
uses: ./.github/actions/breeze
with:
python-version: ${{ inputs.breeze-python-version }}
- name: "Cleanup dist and context file"
run: rm -fv ./dist/* ./docker-context-files/*
if: inputs.include-prod-images == 'true'
- name: "Prepare airflow package for PROD build"
run: breeze release-management prepare-airflow-package --package-format wheel
if: inputs.include-prod-images == 'true'
- name: "Prepare providers packages for PROD build"
run: >
breeze release-management prepare-provider-packages
--package-list-file ./prod_image_installed_providers.txt
--package-format wheel
if: inputs.include-prod-images == 'true'
- name: "Copy dist packages to docker-context files"
run: cp -v --no-preserve=mode,ownership ./dist/*.whl ./docker-context-files
if: inputs.include-prod-images == 'true'
- name: "Start ARM instance"
run: ./scripts/ci/images/ci_start_arm_instance_and_connect_to_docker.sh
- name: "Push CI ${{ inputs.cache-type }} cache: ${{ matrix.python }} (AMD/ARM)"
run: >
breeze ci-image build --builder airflow_cache
--prepare-buildx-cache --run-in-parallel --platform "linux/amd64,linux/arm64"
--python ${{ matrix.python }}
- name: "Push PROD ${{ inputs.cache-type }} cache: ${{ matrix.python-version }} (AMD/ARM)"
run: >
breeze prod-image build --builder airflow_cache
--prepare-buildx-cache --run-in-parallel --platform "linux/amd64,linux/arm64"
--install-packages-from-context --airflow-constraints-mode constraints-source-providers
--python ${{ matrix.python }}
if: inputs.include-prod-images == 'true'
- name: "Stop ARM instance"
run: ./scripts/ci/images/ci_stop_arm_instance.sh
if: always()
# We only push "AMD" images as it is really only needed for any kind of automated builds in CI
# and currently there is not an easy way to make multi-platform image from two separate builds
# and we can do it after we stopped the ARM instance as it is not needed anymore
- name: "Push CI latest images: ${{ matrix.python }} (AMD ONLY)"
run: >
breeze ci-image build --tag-as-latest --push --python "${{matrix.python}}" --platform "linux/amd64"
if: inputs.push-latest-images == 'true'
- name: "Push PROD latest image: ${{ matrix.python }} (AMD ONLY)"
run: >
breeze prod-image build --tag-as-latest --install-packages-from-context
--push --python ${{ matrix.python}} --platform "linux/amd64"
if: inputs.push-latest-images == 'true'