From ff7e8054f7f0362e878c5e53c84bebc3ac38d3f9 Mon Sep 17 00:00:00 2001 From: Riley Dixon Date: Thu, 20 Nov 2025 13:49:06 -0700 Subject: [PATCH 1/4] CI: Re-add caching for updating the 'latest' image. On pull_requests, if the Dockerfile has been modified, a new image will be build and pushed using as many cached layers as possible. Otherwise, this effectively is a no-op as the entire image is already cached. If this is triggered manually via workflow_dispatch, this gives the option of not consuming the cache to forcibly update the image packages. Regardless of this option, the resulting image is cached for future use. --- .github/workflows/update-ais-ci-image.yml | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/.github/workflows/update-ais-ci-image.yml b/.github/workflows/update-ais-ci-image.yml index c7ce5426..b5b1eba3 100644 --- a/.github/workflows/update-ais-ci-image.yml +++ b/.github/workflows/update-ais-ci-image.yml @@ -8,6 +8,12 @@ on: - develop workflow_dispatch: # Requires write access to trigger. + inputs: + pull_from_cache: + description: Build image with 'latest' cache + required: false + default: true + type: boolean concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true @@ -42,20 +48,33 @@ jobs: run: | echo "AIS_CI_IMAGE=${{ env.AIS_DOCKER_REGISTRY }}/${{ env.AIS_CI_IMAGE_NAME}}:latest" \ >> "${GITHUB_OUTPUT}" + - name: Set Docker Cache Instruction + id: use-cache + # If triggered by a pull_request, pull_from_cache will be null. Note + # however `false == null` resolves to `true`. Use empty string to check + # for 'null'. + # See: https://docs.github.com/en/actions/reference/workflows-and-actions/expressions + # for how null gets converted when compared to non-null, and converted into a string. + run: >- + echo "CACHE_FROM_CMD=${{ + ( format('{0}', inputs.pull_from_cache) == '' || inputs.pull_from_cache ) && + format('--cache-from=type=registry,ref=\"{0}-cache\"', steps.ci-image.outputs.AIS_CI_IMAGE) || + '' + }}" >> "${GITHUB_OUTPUT}" - name: Setup Docker Builder uses: docker/setup-buildx-action@v3.11.1 with: name: ais-builder driver: docker-container cache-binary: false # True uses the GHA Cache Backend. - # We won't use the cache from the previous image. - # This lets us semi-regularly pull in package updates automatically. - name: Build & Push latest image for AIS CI run: | docker buildx build \ -f ${GITHUB_WORKSPACE}/util/docker/DOCKERFILE.${{ env.AIS_CI_IMAGE_NAME }} \ --label "org.opencontainers.image.description= \ Latest AIS CI Image for ${{ matrix.supported_platforms }}." \ + --cache-to=type=registry,ref="${{ steps.ci-image.outputs.AIS_CI_IMAGE }}-cache" \ + ${{ steps.use-cache.outputs.CACHE_FROM_CMD }} \ --push \ -t ${{ steps.ci-image.outputs.AIS_CI_IMAGE }} \ ${GITHUB_WORKSPACE} \ No newline at end of file From 9fe403c08abbe6cea6fcdb63a6bd4c7404ef9e5d Mon Sep 17 00:00:00 2001 From: Riley Dixon Date: Thu, 20 Nov 2025 14:38:24 -0700 Subject: [PATCH 2/4] CI: Fix gate for updating image on workflow_dispatch. This gate missed a condition to allow a workflow_dispatch job to execute. --- .github/workflows/update-ais-ci-image.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update-ais-ci-image.yml b/.github/workflows/update-ais-ci-image.yml index b5b1eba3..3e63c62a 100644 --- a/.github/workflows/update-ais-ci-image.yml +++ b/.github/workflows/update-ais-ci-image.yml @@ -25,7 +25,7 @@ jobs: env: AIS_DOCKER_REGISTRY: ghcr.io/rocm/hipfile AIS_CI_IMAGE_NAME: ais_ci_${{ matrix.supported_platforms }} - if: ${{ github.event.pull_request.merged == true }} + if: ${{ github.event.pull_request.merged == true || github.event_name == 'workflow_dispatch' }} runs-on: [ubuntu-24.04] container: docker:28.5 strategy: From 61e7b39400e222346e4f307dbdc923c69a86de90 Mon Sep 17 00:00:00 2001 From: Riley Dixon Date: Thu, 20 Nov 2025 16:10:10 -0700 Subject: [PATCH 3/4] CI: Add additional caching to dev CI images. Dev CI image (i.e. unmerged PR's that have changed a DOCKERFILE) will now try to use caching from the latest image. This will further reduce how quickly the local docker image registry grows with new images from CI. --- .github/workflows/build-ais-ci-image.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/build-ais-ci-image.yml b/.github/workflows/build-ais-ci-image.yml index 08a84203..59dcae8b 100644 --- a/.github/workflows/build-ais-ci-image.yml +++ b/.github/workflows/build-ais-ci-image.yml @@ -38,6 +38,8 @@ jobs: run: | echo "AIS_CI_IMAGE=${{ env.AIS_DOCKER_REGISTRY }}/${{ env.AIS_CI_IMAGE_NAME}}:${AIS_CI_IMAGE_TAG}" \ >> "${GITHUB_OUTPUT}" + echo "AIS_CI_LATEST_CACHE=${{ env.AIS_DOCKER_REGISTRY }}/${{ env.AIS_CI_IMAGE_NAME}}:latest-cache" \ + >> "${GITHUB_OUTPUT}" - name: Fetching code repository... uses: actions/checkout@v5 - name: Authenticating to GitHub Container Registry. @@ -62,6 +64,7 @@ jobs: PR URL: ${{ env.AIS_PR_BASE_URL }}/${AIS_PR_NUMBER}" \ --build-arg BUILDKIT_INLINE_CACHE=1 \ --cache-from=type=registry,ref=${{ steps.ci-image.outputs.AIS_CI_IMAGE }} \ + --cache-from=type=registry,ref=${{ steps.ci-image.outcome.AIS_CI_LATEST_CACHE }} \ --push \ -t ${{ steps.ci-image.outputs.AIS_CI_IMAGE }} \ ${GITHUB_WORKSPACE} From eea5be1e2149274b0c408c77eb30810c7fe9f5e9 Mon Sep 17 00:00:00 2001 From: Riley Dixon Date: Thu, 20 Nov 2025 16:13:35 -0700 Subject: [PATCH 4/4] CI: Drop unused 'output' during the build CI image. --- .github/workflows/build-ais-ci-image.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/build-ais-ci-image.yml b/.github/workflows/build-ais-ci-image.yml index 59dcae8b..4ba23e5b 100644 --- a/.github/workflows/build-ais-ci-image.yml +++ b/.github/workflows/build-ais-ci-image.yml @@ -24,10 +24,6 @@ jobs: container: docker:28.5 outputs: new_ci_image: ${{ steps.ci-image.outputs.AIS_CI_IMAGE }} - image_tag: ${{ steps.ci-image.outputs.AIS_CI_IMAGE_TAG }} - # image_tag is a bit hacky. GitHub does not support separating outputs - # from a workflow run in a matrix. The last workflow to run will set the - # output value. `image_tag` is constant across matrix jobs so this is fine. steps: - name: Set CI environment variables run: |