@@ -2,11 +2,6 @@ name: Systems test workflow, next gen, uses quickstart pipelines
22
33on :
44 workflow_call :
5- secrets :
6- DOCKERHUB_USERNAME :
7- required : false
8- DOCKERHUB_TOKEN :
9- required : false
105 inputs :
116 runner :
127 description : " GitHub runner to use"
@@ -123,25 +118,14 @@ on:
123118
124119env :
125120 SYSTEM_TEST_IMAGE : stellar/system-test:cache
126- SYSTEM_TEST_IMAGE_CACHE_REGISTRY : docker.io
127-
121+
128122jobs :
129123 prepare-config :
130124 runs-on : ubuntu-latest
131125 outputs :
132126 images-config : ${{ steps.set-config.outputs.images }}
133- system-test-image-cache-registry : ${{ env.SYSTEM_TEST_IMAGE_CACHE_REGISTRY }}
134127 system-test-image-cached : " ${{ env.SYSTEM_TEST_IMAGE}}_${{ steps.set-cache-key.outputs.cache-key }}"
135- registry_allowed : ${{ steps.check-registry.outputs.registry-allowed }}
136128 steps :
137- - id : check-registry
138- name : Check if registry access is allowed
139- run : |
140- if [ -z "${{ secrets.DOCKERHUB_TOKEN }}" ]; then
141- echo "registry-allowed=false" >> $GITHUB_OUTPUT
142- else
143- echo "registry-allowed=true" >> $GITHUB_OUTPUT
144- fi
145129 - id : set-cache-key
146130 run : |
147131 # Fetch commit SHAs for each dependency repo
@@ -216,27 +200,9 @@ jobs:
216200 images : ${{ needs.prepare-config.outputs.images-config }}
217201 archs : ' ["amd64"]'
218202
219- check-system-test-cache :
220- runs-on : ubuntu-latest
221- needs : prepare-config
222- outputs :
223- cache-hit : ${{ steps.check.outputs.exists }}
224- steps :
225- - id : check
226- name : Check if cached system-test image exists
227- run : |
228- if docker manifest inspect ${{ needs.prepare-config.outputs.system-test-image-cache-registry }}/${{ needs.prepare-config.outputs.system-test-image-cached }} > /dev/null 2>&1; then
229- echo "Image exists in registry"
230- echo "exists=true" >> $GITHUB_OUTPUT
231- else
232- echo "Image not found in registry"
233- echo "exists=false" >> $GITHUB_OUTPUT
234- fi
235-
236203 build-system-test :
237204 runs-on : ubuntu-latest-4-cores
238- needs : [prepare-config, check-system-test-cache]
239- if : needs.check-system-test-cache.outputs.cache-hit != 'true'
205+ needs : [prepare-config]
240206 env :
241207 SYSTEM_TEST_IMAGE : ${{ needs.prepare-config.outputs.system-test-image-cached }}
242208 steps :
@@ -275,34 +241,20 @@ jobs:
275241 fi
276242
277243 make \
244+ USE_GHA_CACHE=true \
278245 STELLAR_CLI_GIT_REF=$STELLAR_CLI_GIT_REF \
279246 STELLAR_CLI_CRATE_VERSION=$STELLAR_CLI_CRATE_VERSION \
280247 RUST_TOOLCHAIN_VERSION=${{ inputs.rust-toolchain-version }} \
281248 JS_STELLAR_SDK_NPM_VERSION=$JS_STELLAR_SDK_REF \
282249 SYSTEM_TEST_IMAGE=$SYSTEM_TEST_IMAGE \
283250 build
284- - name : login to registry
285- if : needs.prepare-config.outputs.registry_allowed == 'true'
286- uses : docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
287- with :
288- registry : ${{ needs.prepare-config.outputs.system-test-image-cache-registry }}
289- username : ${{ secrets.DOCKERHUB_USERNAME }}
290- password : ${{ secrets.DOCKERHUB_TOKEN }}
291- - name : Publish system-test image
292- if : needs.prepare-config.outputs.registry_allowed == 'true'
293- run : |
294- docker tag $SYSTEM_TEST_IMAGE ${{ needs.prepare-config.outputs.system-test-image-cache-registry }}/$SYSTEM_TEST_IMAGE
295- docker push ${{ needs.prepare-config.outputs.system-test-image-cache-registry }}/$SYSTEM_TEST_IMAGE
296-
297- - name : extract image to artifact when no registry
298- if : needs.prepare-config.outputs.registry_allowed != 'true'
251+ - name : extract image to file
299252 run : |
300253 docker save $SYSTEM_TEST_IMAGE -o /tmp/image.tar
301- - name : save to artifact when no registry
302- if : needs.prepare-config.outputs.registry_allowed != 'true'
303- uses : actions/upload-artifact@v4
254+ - name : save file to cache
255+ uses : actions/cache@v4
304256 with :
305- name : image-system-test
257+ key : ${{ env.SYSTEM_TEST_IMAGE }}
306258 path : /tmp/image.tar
307259
308260 integration :
@@ -324,21 +276,19 @@ jobs:
324276 artifact : image-quickstart-rpc-custom-amd64.tar
325277 tag : rpc-custom-amd64
326278 enable : core,rpc
327- - name : download system-test image
328- if : needs.build-system-test.result == 'skipped'
329- run : |
330- docker pull ${{ needs.prepare-config.outputs.system-test-image-cache-registry }}/$SYSTEM_TEST_IMAGE
331- docker tag ${{ needs.prepare-config.outputs.system-test-image-cache-registry }}/$SYSTEM_TEST_IMAGE $SYSTEM_TEST_IMAGE
332-
333- - name : download artifact if no registry
334- if : needs.build-system-test.result != 'skipped' && needs.prepare-config.outputs.registry_allowed != 'true'
335- uses : actions/download-artifact@v4
279+ - name : Get system-test image from cache
280+ id : get-system-test-image
281+ uses : actions/cache/restore/v4
336282 with :
337- name : image-system-test
338- path : /tmp/
339-
340- - name : load system-test image if no registry
341- if : needs.build-system-test.result != 'skipped' && needs.prepare-config.outputs.registry_allowed != 'true'
283+ key : ${{ env.SYSTEM_TEST_IMAGE }}
284+ path : /tmp/image.tar
285+ - name : Fail if cache not found
286+ run : |
287+ if [ "${{ steps.get-system-test-image.outputs.cache-hit }}" != "true" ]; then
288+ echo "Required cache key $SYSTEM_TEST_IMAGE not found, failing job."
289+ exit 1
290+ fi
291+ - name : load system-test image from cache file
342292 run : |
343293 docker load -i /tmp/image.tar
344294
0 commit comments