11name : Build and Test
2+ description : Build and test redis docker image
23
34inputs :
45 distribution :
@@ -19,6 +20,21 @@ inputs:
1920 registry_repository :
2021 description : ' Repository to push the image to'
2122 required : false
23+ release_tag :
24+ description : ' Release tag to build'
25+ required : false
26+ redisearch_version :
27+ description : ' Redisearch version to build'
28+ required : false
29+ redisjson_version :
30+ description : ' Redisjson version to build'
31+ required : false
32+ redisbloom_version :
33+ description : ' Redisbloom version to build'
34+ required : false
35+ redistimeseries_version :
36+ description : ' Redistimeseries version to build'
37+ required : false
2238
2339runs :
2440 using : " composite"
5470 linux/i386)
5571 plaform_name="i386"
5672 ;;
57- linux/mips64le)
58- plaform_name="mips64le"
59- ;;
6073 linux/ppc64le)
6174 plaform_name="ppc64le"
6275 ;;
@@ -88,88 +101,27 @@ runs:
88101 password : ${{ inputs.registry_password }}
89102
90103 - name : Build
91- id : build
92104 uses : docker/build-push-action@v6
93105 with :
94106 context : ${{ inputs.distribution }}
95107 push : false
96108 load : true
97109 platforms : ${{ inputs.platform }}
98110 tags : ${{ github.sha }}:${{ steps.platform.outputs.display_name }}
99- cache-from : type=gha
100- cache-to : type=gha,mode=max
101- env :
102- BUILDKIT_PROGRESS : plain
103-
104- - name : Capture build logs on failure
105- shell : bash
106- if : failure() && steps.build.outcome == 'failure'
107- run : |
108- mkdir -p /tmp/build-logs
109-
110- echo "Build failed for ${{ inputs.distribution }} on ${{ inputs.platform }}"
111- echo "Capturing detailed logs for troubleshooting..."
112-
113- # Get docker history for the built image (might not exist if build failed early)
114- docker history ${{ github.sha }}:${{ steps.platform.outputs.display_name }} > /tmp/build-logs/image-history.log 2>&1 || echo "Failed to get image history"
115-
116- # Get docker inspect output (might not exist if build failed early)
117- docker inspect ${{ github.sha }}:${{ steps.platform.outputs.display_name }} > /tmp/build-logs/image-inspect.json 2>&1 || echo "Failed to inspect image"
118-
119- # Get docker build cache info
120- docker buildx du > /tmp/build-logs/buildx-du.log 2>&1 || echo "Failed to get build cache info"
121-
122- # Get system info
123- uname -a > /tmp/build-logs/system-info.log 2>&1
124- docker info > /tmp/build-logs/docker-info.log 2>&1
125-
126- # Create a summary file
127- {
128- echo "Build failure summary for ${{ inputs.distribution }} on ${{ inputs.platform }}"
129- echo "Date: $(date)"
130- echo "GitHub SHA: ${{ github.sha }}"
131- echo "Platform: ${{ steps.platform.outputs.display_name }}"
132- echo "Distribution: ${{ inputs.distribution }}"
133- } > /tmp/build-logs/failure-summary.txt
134-
135- # Try to extract error information from the build logs
136- echo "Analyzing build failure..."
137-
138- # Check for common error patterns
139- if docker buildx build --no-cache ${{ inputs.distribution }} --platform=${{ inputs.platform }} 2>&1 | tee /tmp/build-logs/build-error.log | grep -q "ERROR"; then
140- echo "Found ERROR in build output"
141- grep -A 10 -B 5 "ERROR" /tmp/build-logs/build-error.log > /tmp/build-logs/error-context.log || true
142- fi
143-
144- echo "Log capture complete"
145-
146- - name : Upload build failure logs
147- if : failure() && steps.build.outcome == 'failure'
148- uses : actions/upload-artifact@v4
149- with :
150- name : build-failure-${{ steps.platform.outputs.display_name }}-${{ inputs.distribution }}
151- path : /tmp/build-logs/
152- retention-days : 30
153- if-no-files-found : warn
154-
155- - name : Save image
156- shell : bash
157- run : |
158- docker save -o /tmp/image-${{ steps.platform.outputs.display_name }}.tar ${{ github.sha }}:${{ steps.platform.outputs.display_name }}
159-
160- - name : Upload image
161- uses : actions/upload-artifact@v4
162- with :
163- name : ${{ steps.platform.outputs.display_name }}-${{ inputs.distribution }}-docker-image.tar
164- path : /tmp/image-${{ steps.platform.outputs.display_name }}.tar
165- retention-days : 45
111+ cache-from : type=gha,scope=${{ inputs.distribution }}-${{ steps.platform.outputs.display_name }}
112+ cache-to : type=gha,mode=max,scope=${{ inputs.distribution }}-${{ steps.platform.outputs.display_name }}
113+ build-args : |
114+ REDISEARCH_VERSION=${{ inputs.redisearch_version }}
115+ REDISJSON_VERSION=${{ inputs.redisjson_version }}
116+ REDISBLOOM_VERSION=${{ inputs.redisbloom_version }}
117+ REDISTIMESERIES_VERSION=${{ inputs.redistimeseries_version }}
166118
167119 - name : Run container
168120 shell : bash
169121 if : ${{ contains(fromJSON('["amd64", "i386", "arm64"]'), steps.platform.outputs.display_name) }}
170122 run : |
171123 docker run -d --name sanity-test-${{ steps.platform.outputs.display_name }} ${{ github.sha }}:${{ steps.platform.outputs.display_name }}
172-
124+
173125 - name : Container Logs
174126 if : ${{ contains(fromJSON('["amd64", "i386", "arm64"]'), steps.platform.outputs.display_name) }}
175127 shell : bash
@@ -182,7 +134,7 @@ runs:
182134 run : |
183135 docker exec sanity-test-${{ steps.platform.outputs.display_name }} redis-cli ping
184136 docker exec sanity-test-${{ steps.platform.outputs.display_name }} redis-cli info server
185-
137+
186138 - name : Verify installed modules
187139 if : ${{ contains(fromJSON('["amd64", "arm64"]'), steps.platform.outputs.display_name) }}
188140 shell : bash
@@ -202,7 +154,7 @@ runs:
202154 echo "The following modules are missing: ${missing_modules[*]}"
203155 exit 1
204156 fi
205-
157+
206158 - name : Test RedisBloom
207159 if : ${{ contains(fromJSON('["amd64", "arm64"]'), steps.platform.outputs.display_name) }}
208160 shell : bash
@@ -212,7 +164,7 @@ runs:
212164 [ "$(docker exec sanity-test-${{ steps.platform.outputs.display_name }} redis-cli BF.EXISTS popular_keys "redis:hash")" = "1" ] || { echo "RedisBloom test failed: 'redis:hash' not found"; exit 1; }
213165 [ "$(docker exec sanity-test-${{ steps.platform.outputs.display_name }} redis-cli BF.EXISTS popular_keys "redis:list")" = "0" ] || { echo "RedisBloom test failed: 'redis:list' found unexpectedly"; exit 1; }
214166 echo "RedisBloom test passed successfully"
215-
167+
216168 - name : Test RediSearch
217169 if : ${{ contains(fromJSON('["amd64", "arm64"]'), steps.platform.outputs.display_name) }}
218170 shell : bash
@@ -257,6 +209,7 @@ runs:
257209 echo "ReJSON test failed: expected 'allkeys-lru', got $result"
258210 exit 1
259211 fi
212+
260213 - name : Test the entrypoint
261214 id : test_entrypoint
262215 if : ${{ contains(fromJSON('["amd64", "i386", "arm64"]'), steps.platform.outputs.display_name) }}
@@ -277,12 +230,73 @@ runs:
277230 path : test/report-entrypoint.xml
278231 reporter : java-junit
279232
233+ - name : Format registry tag
234+ id : format-registry-tag
235+ shell : bash
236+ run : |
237+ printf "tag=%s:%s%s-%s-%s" \
238+ "${{ inputs.registry_repository }}" \
239+ "${{ inputs.release_tag != '' && format('{0}-', inputs.release_tag || '') }}" \
240+ "${{ github.run_id }}" \
241+ "${{ inputs.distribution }}" \
242+ "${{ steps.platform.outputs.display_name }}" \
243+ | tr '[:upper:]' '[:lower:]' >> "$GITHUB_OUTPUT"
244+
245+ - name : Image labels
246+ if : ${{ inputs.publish_image == 'true' && contains(fromJSON('["amd64", "arm64"]'), steps.platform.outputs.display_name) }}
247+ id : get-image-labels
248+ uses : ./.github/actions/create-image-labels
249+ with :
250+ redis_version : ${{ inputs.release_tag }}
251+ redisearch_version : ${{ inputs.redisearch_version }}
252+ redisjson_version : ${{ inputs.redisjson_version }}
253+ redisbloom_version : ${{ inputs.redisbloom_version }}
254+ redistimeseries_version : ${{ inputs.redistimeseries_version }}
255+
280256 - name : Push image
281257 uses : docker/build-push-action@v6
282258 if : ${{ inputs.publish_image == 'true' && contains(fromJSON('["amd64", "arm64"]'), steps.platform.outputs.display_name) }}
283259 with :
284260 context : ${{ inputs.distribution }}
285261 push : true
286- tags : ${{ inputs.registry_repository }}:${{ github.sha }}-${{ inputs.distribution }}
262+ tags : ${{ steps.format-registry-tag.outputs.tag }}
287263 cache-from : type=gha
288264 cache-to : type=gha,mode=max
265+ build-args : |
266+ REDISEARCH_VERSION=${{ inputs.redisearch_version }}
267+ REDISJSON_VERSION=${{ inputs.redisjson_version }}
268+ REDISBLOOM_VERSION=${{ inputs.redisbloom_version }}
269+ REDISTIMESERIES_VERSION=${{ inputs.redistimeseries_version }}
270+ labels : |
271+ ${{ steps.get-image-labels.outputs.image_labels }}
272+ org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
273+ org.opencontainers.image.revision=${{ github.sha }}
274+
275+ - name : Save image metadata to artifact
276+ shell : bash
277+ run : |
278+ if [[ "${{ inputs.publish_image }}" == "true" && "${{ contains(fromJSON('["amd64", "arm64"]'), steps.platform.outputs.display_name) }}" == "true" ]]; then
279+ # Create a JSON file with structured image metadata
280+ mkdir -p /tmp/image-metadata
281+ cat > "/tmp/image-metadata/${{ inputs.distribution }}-${{ steps.platform.outputs.display_name }}.json" << 'EOF'
282+ {
283+ "version": "${{ inputs.release_tag }}",
284+ "arch": "${{ steps.platform.outputs.display_name }}",
285+ "distro": "${{ inputs.distribution }}",
286+ "commit": "${{ github.sha }}",
287+ "url": "${{ steps.format-registry-tag.outputs.tag }}"
288+ }
289+ EOF
290+ echo "Image metadata saved:"
291+ cat "/tmp/image-metadata/${{ inputs.distribution }}-${{ steps.platform.outputs.display_name }}.json"
292+ else
293+ echo "Image not published for this platform/distribution combination"
294+ fi
295+
296+ - name : Upload image metadata artifact
297+ uses : actions/upload-artifact@v4
298+ if : ${{ inputs.publish_image == 'true' && contains(fromJSON('["amd64", "arm64"]'), steps.platform.outputs.display_name) }}
299+ with :
300+ name : image-metadata-${{ inputs.distribution }}-${{ steps.platform.outputs.display_name }}
301+ path : /tmp/image-metadata/${{ inputs.distribution }}-${{ steps.platform.outputs.display_name }}.json
302+ retention-days : 1
0 commit comments