Skip to content

workflows/build-ci-container: Add an arm64 container #120828

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Feb 3, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 35 additions & 14 deletions .github/workflows/build-ci-container.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 }}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use something better than this? Maybe the short commit SHA suffixed with the arch?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could use the short commit SHA.

I'm not sure about the arch suffix. For Fedora containers we have the arch suffix:
registry.fedoraproject.org/fedora:41-aarch64

But for ubuntu there is no suffix and the arch is in the namespace: docker.io/arm64v8/ubuntu:22.04

I really have no preference, I just want to be consistent with whatever the convention is.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, okay.

I think the short commit SHA would be better here given it makes things more easily searchable. Keeping the arch in the namespace sounds reasonable enough to me.

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
Expand All @@ -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

Expand All @@ -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
Loading