@@ -135,6 +135,7 @@ jobs:
135135 # region Free up disk space
136136
137137 - name : Free up additional disk space
138+ uses : ./.github/actions/free-up-disk-space
138139 uses : ./.github/actions/free-up-disk-space
139140 # https://docs.github.com/en/actions/learn-github-actions/expressions
140141 # NOTE: the arm64 GitHub hosted runner does not have the /mnt-mounted scratch disk
@@ -192,50 +193,59 @@ jobs:
192193 fi
193194 echo "${{ secrets.AIPCC_QUAY_BOT_PASSWORD }}" | podman login quay.io/aipcc -u "${{ secrets.AIPCC_QUAY_BOT_USERNAME }}" --password-stdin
194195
195- - name : Compute extra podman build args
196- id : extra-podman-build-args
197- run : |
198- set -Eeuxo pipefail
199-
200- EXTRA_PODMAN_BUILD_ARGS=""
201- if [[ "${{ inputs.platform }}" == "linux/s390x" ]]; then
202- # workaround for known issue https://github.com/zeromq/libzmq/pull/4486
203- # In qemu-user, CACHELINE_SIZE probe is undefined
204- # Compiling pyzmq through UV needs this in CFLAGS
205- EXTRA_PODMAN_BUILD_ARGS+='--env=CFLAGS=-Dundefined=64 --env=CXXFLAGS=-Dundefined=64 --unsetenv=CFLAGS --unsetenv=CXXFLAGS'
206- fi
207- echo "EXTRA_PODMAN_BUILD_ARGS=$EXTRA_PODMAN_BUILD_ARGS" >> $GITHUB_OUTPUT
208-
209196 # https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#push
210197 # https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request
211198
212- - name : " push|schedule|workflow_dispatch: make ${{ inputs.target }}"
213- id : push-make-target
199+ # We use `CONTAINER_BUILD_CACHE_ARGS` to smuggle in various misc `podman build` args, not just cache-related ones
200+ - name : Compute CONTAINER_BUILD_CACHE_ARGS
201+ id : extra-container-build-args
202+ shell : python
203+ # language=python
214204 run : |
215- # print running stats on disk occupancy
216- (while true; do df -h | grep "${HOME}/.local/share/containers"; sleep 30; done) &
217-
218- make ${{ inputs.target }}
219- if : ${{ fromJson(inputs.github).event_name == 'push' ||
220- fromJson(inputs.github).event_name == 'schedule' ||
221- fromJson(inputs.github).event_name == 'workflow_dispatch' }}
222- env :
223- IMAGE_TAG : " ${{ steps.calculated_vars.outputs.IMAGE_TAG }}"
224- CONTAINER_BUILD_CACHE_ARGS : " ${{ steps.extra-podman-build-args.outputs.EXTRA_PODMAN_BUILD_ARGS }} --cache-from ${{ env.CACHE }} --cache-to ${{ env.CACHE }}"
225- - name : " pull_request: make ${{ inputs.target }}"
226- id : pr-make-target
205+ import os
206+ import sys
207+ from typing import Literal
208+
209+ extra_podman_build_args = ""
210+ if "${{ inputs.platform }}" == "linux/s390x":
211+ # workaround for known issue https://github.com/zeromq/libzmq/pull/4486
212+ # In qemu-user, CACHELINE_SIZE probe is undefined
213+ # Compiling pyzmq through UV needs this in CFLAGS
214+ extra_podman_build_args += '--env=CFLAGS=-Dundefined=64 --env=CXXFLAGS=-Dundefined=64 --unsetenv=CFLAGS --unsetenv=CXXFLAGS'
215+
216+ event_name: Literal['push', 'pull_request', 'schedule', 'workflow_dispatch'] = "${{ fromJson(inputs.github).event_name }}"
217+ cache = "${{ env.CACHE }}"
218+
219+ if event_name == "schedule":
220+ # For schedule events, skip --cache-from to regenerate cache
221+ cache_args = f"--cache-to {cache}"
222+ print("Regenerating cache (schedule event)", file=sys.stderr)
223+ elif event_name == "push" or event_name == "workflow_dispatch":
224+ # push or workflow_dispatch: use and update cache
225+ cache_args = f"--cache-from {cache} --cache-to {cache}"
226+ print("Using and updating cache", file=sys.stderr)
227+ elif event_name == "pull_request":
228+ # pull_request: use cache, but we don't have write access, so we can't update even if we wanted to
229+ cache_args = f"--cache-from {cache}"
230+ print("Using cache", file=sys.stderr)
231+ else:
232+ raise ValueError(f"Unexpected event name: {event_name}")
233+
234+ with open(os.environ["GITHUB_OUTPUT"], "a") as f:
235+ f.write(f"CONTAINER_BUILD_CACHE_ARGS={extra_podman_build_args} {cache_args}\n")
236+
237+ - name : " Build: make ${{ inputs.target }}"
238+ id : make-target
227239 run : |
228240 # print running stats on disk occupancy
229241 (while true; do df -h | grep "${HOME}/.local/share/containers"; sleep 30; done) &
230242
231243 make ${{ inputs.target }}
232- if : " ${{ fromJson(inputs.github).event_name == 'pull_request' ||
233- fromJson(inputs.github).event_name == 'pull_request_target' }}"
234244 env :
235245 IMAGE_TAG : " ${{ steps.calculated_vars.outputs.IMAGE_TAG }}"
236- CONTAINER_BUILD_CACHE_ARGS : " ${{ steps.extra-podman -build-args.outputs.EXTRA_PODMAN_BUILD_ARGS }} --cache-from ${{ env.CACHE }}"
237- # We don't have access to image registry, so disable pushing
238- PUSH_IMAGES : " no "
246+ CONTAINER_BUILD_CACHE_ARGS : " ${{ steps.extra-container -build-args.outputs.CONTAINER_BUILD_CACHE_ARGS }}"
247+ # We don't have access to image registry for PRs , so disable pushing
248+ PUSH_IMAGES : " ${{ (fromJson(inputs.github).event_name == 'pull_request' || fromJson(inputs.github).event_name == 'pull_request_target') && 'no' || 'yes' }} "
239249
240250 - name : " Show podman images information"
241251 run : podman images --digests
@@ -429,7 +439,7 @@ jobs:
429439 # we leave little free disk space after we mount LVM for podman storage
430440 # not enough to install playwright; running playwright in podman uses the space we have
431441 - name : Run Playwright tests
432- if : ${{ !cancelled() && contains(inputs.target, 'codeserver') && ( steps.push- make-target.outcome == 'success' || steps.pr-make-target.outcome == 'success') }}
442+ if : ${{ !cancelled() && contains(inputs.target, 'codeserver') && steps.make-target.outcome == 'success' }}
433443 # --ipc=host because Microsoft says so in Playwright docs
434444 # --net=host because testcontainers connects to the Reaper container's exposed port
435445 # we need to pass through the relevant environment variables
0 commit comments