Skip to content

Commit e40a197

Browse files
committed
skip docker image rebuild
1 parent 155643a commit e40a197

File tree

2 files changed

+43
-23
lines changed

2 files changed

+43
-23
lines changed

.github/workflows/release_branches.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
# cd "$GITHUB_WORKSPACE/tests/ci"
3636
# python3 docker_images_check.py --suffix aarch64
3737
# - name: Upload images files to artifacts
38-
# uses: actions/upload-artifact@v2
38+
# uses: actions/download-artifact@v4
3939
# with:
4040
# name: changed_images_aarch64
4141
# path: ${{ runner.temp }}/docker_images_check/changed_images_aarch64.json
@@ -82,7 +82,7 @@ jobs:
8282
# cd "$GITHUB_WORKSPACE/tests/ci"
8383
# python3 docker_manifests_merge.py --suffix amd64 --suffix aarch64
8484
# - name: Upload images files to artifacts
85-
# uses: actions/upload-artifact@v2
85+
# uses: actions/download-artifact@v4
8686
# with:
8787
# name: changed_images
8888
# path: ${{ runner.temp }}/changed_images.json
@@ -201,7 +201,7 @@ jobs:
201201
# cp -r "$GITHUB_WORKSPACE" "$TEMP_PATH"
202202
# cd "$REPO_COPY/tests/ci" && python3 build_check.py "$BUILD_NAME"
203203
# - name: Upload build URLs to artifacts
204-
# uses: actions/upload-artifact@v2
204+
# uses: actions/download-artifact@v4
205205
# with:
206206
# name: ${{ env.BUILD_URLS }}
207207
# path: ${{ runner.temp }}/build_check/${{ env.BUILD_URLS }}.json
@@ -230,9 +230,9 @@ jobs:
230230
- name: Check docker altinity/clickhouse-server building
231231
run: |
232232
cd "$GITHUB_WORKSPACE/tests/ci"
233-
python3 docker_server.py --release-type head --push \
233+
python3 docker_server.py --release-type head \
234234
--image-repo altinity/clickhouse-server --image-path docker/server
235-
python3 docker_server.py --release-type head --push \
235+
python3 docker_server.py --release-type head \
236236
--image-repo altinity/clickhouse-keeper --image-path docker/keeper
237237
- name: Cleanup
238238
if: always()
@@ -672,7 +672,7 @@ jobs:
672672
cd "$GITHUB_WORKSPACE/tests/ci"
673673
python3 sign_release.py
674674
- name: Upload signed hashes
675-
uses: actions/upload-artifact@v2
675+
uses: actions/upload-artifact@v4
676676
with:
677677
name: signed-hashes
678678
path: ${{ env.TEMP_PATH }}/*.gpg

tests/ci/docker_images_check.py

Lines changed: 37 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -106,23 +106,43 @@ def get_changed_docker_images(
106106
str(files_changed),
107107
)
108108

109-
# Rebuild all images
110-
changed_images = [DockerImage(dockerfile_dir, image_description["name"], image_description.get("only_amd64", False)) for dockerfile_dir, image_description in images_dict.items()]
111-
112-
# for dockerfile_dir, image_description in images_dict.items():
113-
# for f in files_changed:
114-
# if f.startswith(dockerfile_dir):
115-
# name = image_description["name"]
116-
# only_amd64 = image_description.get("only_amd64", False)
117-
# logging.info(
118-
# "Found changed file '%s' which affects "
119-
# "docker image '%s' with path '%s'",
120-
# f,
121-
# name,
122-
# dockerfile_dir,
123-
# )
124-
# changed_images.append(DockerImage(dockerfile_dir, name, only_amd64))
125-
# break
109+
# Find changed images
110+
all_images = []
111+
changed_images = []
112+
for dockerfile_dir, image_description in images_dict.items():
113+
all_images.append(DockerImage(dockerfile_dir, image_description["name"], image_description.get("only_amd64", False)))
114+
for f in files_changed:
115+
if f.startswith(dockerfile_dir):
116+
name = image_description["name"]
117+
only_amd64 = image_description.get("only_amd64", False)
118+
logging.info(
119+
"Found changed file '%s' which affects "
120+
"docker image '%s' with path '%s'",
121+
f,
122+
name,
123+
dockerfile_dir,
124+
)
125+
changed_images.append(DockerImage(dockerfile_dir, name, only_amd64))
126+
break
127+
128+
# Rebuild all images on push, release, or scheduled run
129+
if pr_info.number in [0,1]:
130+
changed_images = all_images
131+
132+
else:
133+
# Rebuild all on opened PR
134+
if pr_info.event['action'] in ['opened', 'reopened']:
135+
changed_images = all_images
136+
137+
# Check that image for the PR exists
138+
elif pr_info.event['action'] == 'synchronize':
139+
unchanged_images = [
140+
image for image in all_images if image not in changed_images
141+
]
142+
logging.info(f"Unchanged images: {unchanged_images}")
143+
for image in unchanged_images:
144+
if subprocess.run(f"docker manifest inspect {image.repo}:{pr_info.number}", shell=True).returncode != 0:
145+
changed_images.append(image)
126146

127147
# The order is important: dependents should go later than bases, so that
128148
# they are built with updated base versions.

0 commit comments

Comments
 (0)