Skip to content

Commit 13afb8e

Browse files
committed
ci: guard TKE builder fallback and isolate caches
1 parent 95d9633 commit 13afb8e

1 file changed

Lines changed: 21 additions & 6 deletions

File tree

.github/workflows/merge-trigger-tke.yaml

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,20 @@ jobs:
8484
BASIC_IMAGE: ccr.ccs.tencentyun.com/matrixone-dev/matrixone:ci-builder-amd64
8585
run: |
8686
set +e
87-
if timeout 300 docker pull "${BASIC_IMAGE}"; then
88-
digest=$(docker image inspect --format '{{index .RepoDigests 0}}' "${BASIC_IMAGE}")
87+
PREBUILT_DOCKERFILE="$GITHUB_WORKSPACE/matrixone/optools/images/Dockerfile.prebuilt"
88+
if [ ! -f "${PREBUILT_DOCKERFILE}" ]; then
89+
echo "::notice::Dockerfile.prebuilt is not present in this checkout; using the source Dockerfile fallback"
90+
echo "ref=" >> "$GITHUB_OUTPUT"
91+
echo "tag=" >> "$GITHUB_OUTPUT"
92+
exit 0
93+
fi
94+
# TCR is an optional optimization mirror. Keep a registry outage
95+
# from adding minutes to every post-merge regression before the
96+
# source Dockerfile fallback takes over.
97+
if timeout 90 docker pull "${BASIC_IMAGE}"; then
98+
repository="${BASIC_IMAGE%%:*}"
99+
digest=$(docker image inspect --format '{{range .RepoDigests}}{{println .}}{{end}}' "${BASIC_IMAGE}" |
100+
awk -v prefix="${repository}@" 'index($0, prefix) == 1 { print; exit }')
89101
if [ -n "${digest}" ]; then
90102
echo "ref=${digest}" >> "$GITHUB_OUTPUT"
91103
echo "tag=${BASIC_IMAGE}" >> "$GITHUB_OUTPUT"
@@ -180,8 +192,11 @@ jobs:
180192
tags: ${{ steps.prep.outputs.tags }}
181193
file-path: ${{ github.workspace }}/matrixone/optools/images/Dockerfile.prebuilt
182194
context: ${{ github.workspace }}/mo-runtime
183-
cache-from: type=registry,ref=${{ steps.prep.outputs.docker_image }}:cache-${{ github.base_ref }}
184-
cache-to: type=registry,ref=${{ steps.prep.outputs.docker_image }}:cache-${{ github.base_ref }},mode=max
195+
# Keep the tiny prebuilt image cache separate from the expensive
196+
# source-build cache. Otherwise a successful cached build erases the
197+
# source layers needed by the fallback path.
198+
cache-from: type=registry,ref=${{ steps.prep.outputs.docker_image }}:cache-prebuilt-${{ github.base_ref }}
199+
cache-to: type=registry,ref=${{ steps.prep.outputs.docker_image }}:cache-prebuilt-${{ github.base_ref }},mode=max
185200
platform: linux/amd64
186201
build-args: |
187202
RUNTIME_IMAGE=ccr.ccs.tencentyun.com/mo-infra/ubuntu:22.04
@@ -213,8 +228,8 @@ jobs:
213228
tags: ${{ steps.prep.outputs.tags }}
214229
file-path: ${{ github.workspace }}/matrixone/optools/images/Dockerfile
215230
context: ${{ github.workspace }}/matrixone
216-
cache-from: type=registry,ref=${{ steps.prep.outputs.docker_image }}:cache-${{ github.base_ref }}
217-
cache-to: type=registry,ref=${{ steps.prep.outputs.docker_image }}:cache-${{ github.base_ref }},mode=max
231+
cache-from: type=registry,ref=${{ steps.prep.outputs.docker_image }}:cache-source-${{ github.base_ref }}
232+
cache-to: type=registry,ref=${{ steps.prep.outputs.docker_image }}:cache-source-${{ github.base_ref }},mode=max
218233
platform: linux/amd64
219234
build-args: |
220235
GOPROXY=http://goproxy.goproxy.svc.cluster.local|https://goproxy.cn|direct

0 commit comments

Comments
 (0)