@@ -38,6 +38,9 @@ inputs:
3838 custom_build :
3939 description : ' Type of custom release, branch tag or commit. Empty for release'
4040 required : false
41+ run_type :
42+ description : ' Run type, either release, nightly, unstable or custom'
43+ required : true
4144
4245runs :
4346 using : " composite"
@@ -105,7 +108,7 @@ runs:
105108
106109 - name : Redis release archive
107110 shell : bash
108- if : inputs.custom_build != ''
111+ if : inputs.run_type != 'release '
109112 run : |
110113 if [[ "${{ inputs.custom_build }}" == "branch" ]]; then
111114 echo "REDIS_DOWNLOAD_URL=https://github.com/redis/redis/archive/refs/heads/${{ inputs.release_tag }}.tar.gz" | tee -a "$GITHUB_ENV"
@@ -126,15 +129,66 @@ runs:
126129 load : true
127130 platforms : ${{ inputs.platform }}
128131 tags : ${{ github.sha }}:${{ steps.platform.outputs.display_name }}
129- cache-from : type=gha,scope= ${{ inputs.distribution }}-${{ steps.platform.outputs.display_name }}
130- cache-to : type=gha,mode=max,scope= ${{ inputs.distribution }}-${{ steps.platform.outputs.display_name }}
132+ cache-from : type=gha${{ inputs.run_type == 'release' && format(',scope={0}-{1}', inputs.distribution, steps.platform.outputs.display_name) || '' }}
133+ cache-to : type=gha,mode=max${{ inputs.run_type == 'release' && format(',scope={0}-{1}', inputs.distribution, steps.platform.outputs.display_name) || '' }}
131134 build-args : |
132135 REDISEARCH_VERSION=${{ inputs.redisearch_version }}
133136 REDISJSON_VERSION=${{ inputs.redisjson_version }}
134137 REDISBLOOM_VERSION=${{ inputs.redisbloom_version }}
135138 REDISTIMESERIES_VERSION=${{ inputs.redistimeseries_version }}
136- ${{ inputs.custom_build != '' && 'CUSTOM_BUILD=true' || '' }}
137- ${{ inputs.custom_build != '' && format('REDIS_DOWNLOAD_URL={0}', env.REDIS_DOWNLOAD_URL) || '' }}
139+ ${{ inputs.run_type != 'release' && 'CUSTOM_BUILD=true' || '' }}
140+ ${{ inputs.run_type != 'release' && format('REDIS_DOWNLOAD_URL={0}', env.REDIS_DOWNLOAD_URL) || '' }}
141+
142+ - name : Capture build logs on failure
143+ shell : bash
144+ if : failure() && steps.build.outcome == 'failure' && inputs.run_type == 'nightly'
145+ run : |
146+ mkdir -p /tmp/build-logs
147+
148+ echo "Build failed for ${{ inputs.distribution }} on ${{ inputs.platform }}"
149+ echo "Capturing detailed logs for troubleshooting..."
150+
151+ # Get docker history for the built image (might not exist if build failed early)
152+ docker history ${{ github.sha }}:${{ steps.platform.outputs.display_name }} > /tmp/build-logs/image-history.log 2>&1 || echo "Failed to get image history"
153+
154+ # Get docker inspect output (might not exist if build failed early)
155+ docker inspect ${{ github.sha }}:${{ steps.platform.outputs.display_name }} > /tmp/build-logs/image-inspect.json 2>&1 || echo "Failed to inspect image"
156+
157+ # Get docker build cache info
158+ docker buildx du > /tmp/build-logs/buildx-du.log 2>&1 || echo "Failed to get build cache info"
159+
160+ # Get system info
161+ uname -a > /tmp/build-logs/system-info.log 2>&1
162+ docker info > /tmp/build-logs/docker-info.log 2>&1
163+
164+ # Create a summary file
165+ {
166+ echo "Build failure summary for ${{ inputs.distribution }} on ${{ inputs.platform }}"
167+ echo "Date: $(date)"
168+ echo "GitHub SHA: ${{ github.sha }}"
169+ echo "Platform: ${{ steps.platform.outputs.display_name }}"
170+ echo "Distribution: ${{ inputs.distribution }}"
171+ } > /tmp/build-logs/failure-summary.txt
172+
173+ # Try to extract error information from the build logs
174+ echo "Analyzing build failure..."
175+
176+ # Check for common error patterns
177+ if docker buildx build --no-cache ${{ inputs.distribution }} --platform=${{ inputs.platform }} 2>&1 | tee /tmp/build-logs/build-error.log | grep -q "ERROR"; then
178+ echo "Found ERROR in build output"
179+ grep -A 10 -B 5 "ERROR" /tmp/build-logs/build-error.log > /tmp/build-logs/error-context.log || true
180+ fi
181+
182+ echo "Log capture complete"
183+
184+ - name : Upload build failure logs
185+ if : failure() && steps.build.outcome == 'failure' && inputs.run_type == 'nightly'
186+ uses : actions/upload-artifact@v4
187+ with :
188+ name : build-failure-${{ steps.platform.outputs.display_name }}-${{ inputs.distribution }}
189+ path : /tmp/build-logs/
190+ retention-days : 30
191+ if-no-files-found : warn
138192
139193 - name : Run container
140194 shell : bash
@@ -255,15 +309,15 @@ runs:
255309 shell : bash
256310 run : |
257311 # Determine tag prefix based on custom_build and release_tag
258- if [[ -z "${{ inputs.custom_build }}" ]]; then
259- # custom_build is empty, use release_tag since it's a rlease
312+ if [[ "${{ inputs.run_type }}" == "release" ]]; then
260313 tag_prefix="${{ inputs.release_tag }}"
261- elif [[ "${{ inputs.release_tag }}" == "unstable" ]]; then
262- # custom_build is not empty but release_tag is unstable, use unstable
314+ elif [[ "${{ inputs.run_type }}" == "unstable" || "${{ inputs.run_type }}" == "nightly" ]]; then
263315 tag_prefix="unstable"
264- else
265- # custom_build is not empty and release_tag is not unstable, use custom
316+ elif [[ "${{ inputs.run_type }}" == "custom" ]]; then
266317 tag_prefix="custom"
318+ else
319+ echo "Wrong run_type value, available options are release, nightly, unstable and custom"
320+ exit 1
267321 fi
268322
269323 printf "tag=%s:%s-%s-%s-%s" \
@@ -299,8 +353,8 @@ runs:
299353 REDISJSON_VERSION=${{ inputs.redisjson_version }}
300354 REDISBLOOM_VERSION=${{ inputs.redisbloom_version }}
301355 REDISTIMESERIES_VERSION=${{ inputs.redistimeseries_version }}
302- ${{ inputs.custom_build != '' && 'CUSTOM_BUILD=true' || '' }}
303- ${{ inputs.custom_build != '' && format('REDIS_DOWNLOAD_URL={0}', env.REDIS_DOWNLOAD_URL) || '' }}
356+ ${{ inputs.run_type != 'release ' && 'CUSTOM_BUILD=true' || '' }}
357+ ${{ inputs.run_type != 'release ' && format('REDIS_DOWNLOAD_URL={0}', env.REDIS_DOWNLOAD_URL) || '' }}
304358 labels : |
305359 ${{ steps.get-image-labels.outputs.image-labels }}
306360 org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
0 commit comments