From 466f273a11a57a83a5df5756c0ee6894efc1c45f Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Fri, 20 Dec 2024 22:42:36 -0800 Subject: [PATCH 1/7] workflows/build-ci-container: Add an arm64 container This also changes the container version numbers in the tag from unix timestamps to the github run_id and run_attempt for the workflow. This ensures that the amd64 and arm64 containers have the same version number. For amd64 we now generate 4 tags: * ghcr.io/llvm/ci-ubuntu-22.04:$run_id:latest * ghcr.io/llvm/ci-ubuntu-22.04:$run_id.$run_attempt * ghcr.io/llvm/amd64/ci-ubuntu-22.04:latest * ghcr.io/llvm/amd64/ci-ubuntu-22.04:$run_id.$run_attempt For arm64 we generate 2 tags: * ghcr.io/tstellar/arm64v8/ci-ubuntu-22.04:latest * ghcr.io/tstellar/arm64v8/ci-ubuntu-22.04:$run_id.$run_attempt --- .github/workflows/build-ci-container.yml | 49 +++++++++++++++++------- 1 file changed, 35 insertions(+), 14 deletions(-) diff --git a/.github/workflows/build-ci-container.yml b/.github/workflows/build-ci-container.yml index 50729e0173506..28ba9c21fefc4 100644 --- a/.github/workflows/build-ci-container.yml +++ b/.github/workflows/build-ci-container.yml @@ -20,11 +20,16 @@ on: jobs: build-ci-container: if: github.repository_owner == 'llvm' - runs-on: depot-ubuntu-22.04-16 - outputs: - container-name: ${{ steps.vars.outputs.container-name }} - container-name-tag: ${{ steps.vars.outputs.container-name-tag }} - container-filename: ${{ steps.vars.outputs.container-filename }} + runs-on: ${{ matrix.runs-on }} + strategy: + matrix: + include: + # The arch names should match the names used on dockerhub. + # See https://github.com/docker-library/official-images#architectures-other-than-amd64 + - arch: amd64 + runs-on: depot-ubuntu-22.04-16 + - arch: arm64v8 + runs-on: depot-ubuntu-22.04-arm-16 steps: - name: Checkout LLVM uses: actions/checkout@v4 @@ -33,8 +38,8 @@ jobs: - name: Write Variables id: vars run: | - tag=`date +%s` - container_name="ghcr.io/$GITHUB_REPOSITORY_OWNER/ci-ubuntu-22.04" + tag="${{ github.run_id}}.${{ github.run_attempt }}" + container_name="ghcr.io/$GITHUB_REPOSITORY_OWNER/${{ matrix.arch }}/ci-ubuntu-22.04" echo "container-name=$container_name" >> $GITHUB_OUTPUT echo "container-name-tag=$container_name:$tag" >> $GITHUB_OUTPUT echo "container-filename=$(echo $container_name:$tag | sed -e 's/\//-/g' -e 's/:/-/g').tar" >> $GITHUB_OUTPUT @@ -53,7 +58,7 @@ jobs: - name: Upload container image uses: actions/upload-artifact@v4 with: - name: container + name: container-${{ matrix.arch }} path: ${{ steps.vars.outputs.container-filename }} retention-days: 14 @@ -75,13 +80,29 @@ jobs: steps: - name: Download container uses: actions/download-artifact@v4 - with: - name: container - name: Push Container run: | - podman load -i ${{ needs.build-ci-container.outputs.container-filename }} - podman tag ${{ needs.build-ci-container.outputs.container-name-tag }} ${{ needs.build-ci-container.outputs.container-name }}:latest + function push_container { + image_name=$1 + latest_name=$(echo $image_name | sed 's/:[.0-9]\+$/:latest/g') + podman tag $image_name $latest_name + echo "Pushing $image_name ..." + podman push $image_name + echo "Pushing $latest_name ..." + podman push $latest_name + } + podman login -u ${{ github.actor }} -p $GITHUB_TOKEN ghcr.io - podman push ${{ needs.build-ci-container.outputs.container-name-tag }} - podman push ${{ needs.build-ci-container.outputs.container-name }}:latest + for f in $(find . -iname *.tar); do + image_name=$(podman load -q -i $f | sed 's/Loaded image: //g') + push_container $image_name + + if echo $image_name | grep '/amd64/'; then + # For amd64, create an alias with the arch component removed. + # This matches the convention used on dockerhub. + default_image_name=$(echo $(dirname $(dirname $image_name))/$(basename $image_name)) + podman tag $image_name $default_image_name + push_container $default_image_name + fi + done From 77a1267d40e4dc32d7702125894885db58a615e7 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Mon, 6 Jan 2025 02:28:06 -0800 Subject: [PATCH 2/7] Use short git sha for container label --- .github/workflows/build-ci-container.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-ci-container.yml b/.github/workflows/build-ci-container.yml index 28ba9c21fefc4..1d9cd90824ea4 100644 --- a/.github/workflows/build-ci-container.yml +++ b/.github/workflows/build-ci-container.yml @@ -38,7 +38,7 @@ jobs: - name: Write Variables id: vars run: | - tag="${{ github.run_id}}.${{ github.run_attempt }}" + tag=$(git rev-parse --short=12 HEAD) container_name="ghcr.io/$GITHUB_REPOSITORY_OWNER/${{ matrix.arch }}/ci-ubuntu-22.04" echo "container-name=$container_name" >> $GITHUB_OUTPUT echo "container-name-tag=$container_name:$tag" >> $GITHUB_OUTPUT From 1d2de018c206f7dac6e1fc79d3cf68d490d06d3a Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Thu, 30 Jan 2025 14:30:26 -0800 Subject: [PATCH 3/7] Install podman --- .github/workflows/build-ci-container.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/build-ci-container.yml b/.github/workflows/build-ci-container.yml index 286c80a5a955c..41fe3087864f9 100644 --- a/.github/workflows/build-ci-container.yml +++ b/.github/workflows/build-ci-container.yml @@ -35,6 +35,9 @@ jobs: uses: actions/checkout@v4 with: sparse-checkout: .github/workflows/containers/github-action-ci/ + - name: Install Podman + run: | + apt-get install podman - name: Write Variables id: vars run: | @@ -84,6 +87,9 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} steps: + - name: Install Podman + run: | + apt-get install podman - name: Download container uses: actions/download-artifact@v4 From 62e97326746ca828553bbf0d5a4a299f6e2a214c Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Thu, 30 Jan 2025 17:22:40 -0800 Subject: [PATCH 4/7] Install podman --- .github/workflows/build-ci-container.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-ci-container.yml b/.github/workflows/build-ci-container.yml index 41fe3087864f9..4251c373eb431 100644 --- a/.github/workflows/build-ci-container.yml +++ b/.github/workflows/build-ci-container.yml @@ -37,7 +37,7 @@ jobs: sparse-checkout: .github/workflows/containers/github-action-ci/ - name: Install Podman run: | - apt-get install podman + sudo apt-get install podman - name: Write Variables id: vars run: | @@ -89,7 +89,7 @@ jobs: steps: - name: Install Podman run: | - apt-get install podman + sudo apt-get install podman - name: Download container uses: actions/download-artifact@v4 From dbbbea32633bb76b9aaf193253e17f99489cca27 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Thu, 30 Jan 2025 19:52:55 -0800 Subject: [PATCH 5/7] No podman --- .github/workflows/build-ci-container.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.github/workflows/build-ci-container.yml b/.github/workflows/build-ci-container.yml index 4251c373eb431..286c80a5a955c 100644 --- a/.github/workflows/build-ci-container.yml +++ b/.github/workflows/build-ci-container.yml @@ -35,9 +35,6 @@ jobs: uses: actions/checkout@v4 with: sparse-checkout: .github/workflows/containers/github-action-ci/ - - name: Install Podman - run: | - sudo apt-get install podman - name: Write Variables id: vars run: | @@ -87,9 +84,6 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} steps: - - name: Install Podman - run: | - sudo apt-get install podman - name: Download container uses: actions/download-artifact@v4 From d688bd2ed27b0478deb0c505fccda12f40169758 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Thu, 30 Jan 2025 19:58:28 -0800 Subject: [PATCH 6/7] Fix podman --- .github/workflows/build-ci-container.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/build-ci-container.yml b/.github/workflows/build-ci-container.yml index 286c80a5a955c..01f7edc06b117 100644 --- a/.github/workflows/build-ci-container.yml +++ b/.github/workflows/build-ci-container.yml @@ -35,6 +35,10 @@ jobs: uses: actions/checkout@v4 with: sparse-checkout: .github/workflows/containers/github-action-ci/ + - name: Install Podman + if: runner.arch == 'ARM64' + run: | + sudo apt-get install podman - name: Write Variables id: vars run: | From c3fae7da5a2a82b6f55cc19816b792d7e387f098 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Thu, 30 Jan 2025 19:58:49 -0800 Subject: [PATCH 7/7] Fix podman --- .github/workflows/build-ci-container.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build-ci-container.yml b/.github/workflows/build-ci-container.yml index 01f7edc06b117..c419986da79f2 100644 --- a/.github/workflows/build-ci-container.yml +++ b/.github/workflows/build-ci-container.yml @@ -35,6 +35,7 @@ jobs: uses: actions/checkout@v4 with: sparse-checkout: .github/workflows/containers/github-action-ci/ + # podman is not installed by default on the ARM64 images. - name: Install Podman if: runner.arch == 'ARM64' run: |