summaryrefslogtreecommitdiff
path: root/.github/workflows
diff options
context:
space:
mode:
authorAiden Grossman <aidengrossman@google.com>2025-11-06 15:25:49 -0800
committerGitHub <noreply@github.com>2025-11-06 15:25:49 -0800
commite30dc12640a21a0c25a4ca60e30fb56a6745a57b (patch)
tree9d55e4b9a146ab2543471e1eb7e8246134870496 /.github/workflows
parent8b422006af02766a0e1577108260200944106530 (diff)
[NFC][Github] Move Container Composite Workflows to .github/actions (#166864)
This allows for their reuse inside llvm-zorg. Otherwise we get an error that we cannot use reusable workflows inside job steps because Github thinks that they are reuseable workflows rather than composite actions. This should be NFC inside the monorepo.
Diffstat (limited to '.github/workflows')
-rw-r--r--.github/workflows/build-ci-container-tooling.yml16
-rw-r--r--.github/workflows/build-ci-container.yml16
-rw-r--r--.github/workflows/build-container/action.yml95
-rw-r--r--.github/workflows/push-container/action.yml44
4 files changed, 16 insertions, 155 deletions
diff --git a/.github/workflows/build-ci-container-tooling.yml b/.github/workflows/build-ci-container-tooling.yml
index 46dc38fe600a..0bb8242eb35a 100644
--- a/.github/workflows/build-ci-container-tooling.yml
+++ b/.github/workflows/build-ci-container-tooling.yml
@@ -12,16 +12,16 @@ on:
- '.github/workflows/containers/github-action-ci-tooling/**'
- llvm/utils/git/requirements_formatting.txt
- llvm/utils/git/requirements_linting.txt
- - '.github/workflows/build-container/**'
- - '.github/workflows/push-container/**'
+ - '.github/actions/build-container/**'
+ - '.github/actions/push-container/**'
pull_request:
paths:
- .github/workflows/build-ci-container-tooling.yml
- '.github/workflows/containers/github-action-ci-tooling/**'
- llvm/utils/git/requirements_formatting.txt
- llvm/utils/git/requirements_linting.txt
- - '.github/workflows/build-container/**'
- - '.github/workflows/push-container/**'
+ - '.github/actions/build-container/**'
+ - '.github/actions/push-container/**'
jobs:
build-ci-container-tooling:
@@ -45,10 +45,10 @@ jobs:
llvm/utils/git/requirements_formatting.txt
llvm/utils/git/requirements_linting.txt
clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
- .github/workflows/build-container
+ .github/actions/build-container
- name: Build Container
- uses: ./.github/workflows/build-container
+ uses: ./.github/actions/build-container
with:
container-name: ci-ubuntu-24.04-${{ matrix.container-name }}
dockerfile: .github/workflows/containers/github-action-ci-tooling/Dockerfile
@@ -67,8 +67,8 @@ jobs:
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
sparse-checkout: |
- .github/workflows/push-container
+ .github/actions/push-container
- - uses: ./.github/workflows/push-container
+ - uses: ./.github/actions/push-container
with:
token: ${{ secrets.GITHUB_TOKEN }}
diff --git a/.github/workflows/build-ci-container.yml b/.github/workflows/build-ci-container.yml
index 33b4dda2b298..ddb803fb969f 100644
--- a/.github/workflows/build-ci-container.yml
+++ b/.github/workflows/build-ci-container.yml
@@ -10,14 +10,14 @@ on:
paths:
- .github/workflows/build-ci-container.yml
- '.github/workflows/containers/github-action-ci/**'
- - '.github/workflows/build-container/**'
- - '.github/workflows/push-container/**'
+ - '.github/actions/build-container/**'
+ - '.github/actions/push-container/**'
pull_request:
paths:
- .github/workflows/build-ci-container.yml
- '.github/workflows/containers/github-action-ci/**'
- - '.github/workflows/build-container/**'
- - '.github/workflows/push-container/**'
+ - '.github/actions/build-container/**'
+ - '.github/actions/push-container/**'
jobs:
build-ci-container:
@@ -40,10 +40,10 @@ jobs:
with:
sparse-checkout: |
.github/workflows/containers/github-action-ci/
- .github/workflows/build-container
+ .github/actions/build-container
- name: Build Container
- uses: ./.github/workflows/build-container
+ uses: ./.github/actions/build-container
with:
container-name: ci-ubuntu-24.04${{ matrix.container-name && format('-{0}', matrix.container-name)}}
context: .github/workflows/containers/github-action-ci/
@@ -65,8 +65,8 @@ jobs:
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
sparse-checkout: |
- .github/workflows/push-container
+ .github/actions/push-container
- - uses: ./.github/workflows/push-container
+ - uses: ./.github/actions/push-container
with:
token: ${{ secrets.GITHUB_TOKEN }}
diff --git a/.github/workflows/build-container/action.yml b/.github/workflows/build-container/action.yml
deleted file mode 100644
index 595c3f8dd207..000000000000
--- a/.github/workflows/build-container/action.yml
+++ /dev/null
@@ -1,95 +0,0 @@
-name: Build Container
-description: >-
- Build and test a container using the standard llvm naming scheme for containers.
-
-inputs:
- tag:
- description: >-
- The tag to use for this container.
- required: false
- container-name:
- description: >-
- The name for the container.
- required: true
- dockerfile:
- description: >-
- Path to docker file.
- required: false
- target:
- description: >-
- The container target to build 'passed to podman via ---target option'
- required: false
- context:
- description: >-
- Path to context for the container build.
- required: false
- test-command:
- description: >-
- Test command to run to ensure the container is working correctly.
- required: false
-
-runs:
- using: "composite"
- steps:
- # podman is not installed by default on the ARM64 images.
- - name: Install Podman
- if: runner.arch == 'ARM64'
- shell: bash
- run: |
- sudo apt-get install podman
-
- - name: Build Container
- shell: bash
- env:
- INPUT_TAG: ${{inputs.tag }}
- INPUT_CONTAINER_NAME: ${{ inputs.container-name }}
- INPUT_TARGET: ${{ inputs.target }}
- INPUT_DOCKERFILE: ${{ inputs.dockerfile }}
- INPUT_CONTEXT: ${{ inputs.context }}
- id: build
- run: |
- env
- tag="${INPUT_TAG:-$(git rev-parse --short=12 HEAD)}"
-
- case "$RUNNER_ARCH" in
- ARM64)
- container_arch="arm64v8"
- ;;
- *)
- container_arch="amd64"
- ;;
- esac
-
- container_name="ghcr.io/$GITHUB_REPOSITORY_OWNER/$container_arch/$INPUT_CONTAINER_NAME:$tag"
- container_filename="$(echo $container_name | sed -e 's/\//-/g' -e 's/:/-/g').tar"
- if [ -n "$INPUT_TARGET" ]; then
- podman_options="$podman_options --target $INPUT_TARGET"
- fi
- if [ -n "$INPUT_DOCKERFILE" ]; then
- podman_options="$podman_options -f $INPUT_DOCKERFILE"
- fi
- podman_options="$podman_options ${INPUT_CONTEXT:-.}"
- echo "Podman Options: $podman_options"
-
- podman build -t $container_name $podman_options
-
- podman save $container_name > $container_filename
-
- echo "container-full-name=$container_name" >> $GITHUB_OUTPUT
-
- - name: Create container artifact
- uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
- with:
- name: ${{ inputs.container-name }}-${{ runner.arch }}
- path: "*.tar"
- retention-days: 14
-
- - name: Test container
- shell: bash
- if: inputs.test-command
- env:
- INPUT_TEST_COMMAND: ${{ inputs.test-command }}
- CONTAINER_FULL_NAME: ${{ steps.build.outputs.container-full-name }}
- run: |
- podman run --pull=never --rm -it $CONTAINER_FULL_NAME /usr/bin/bash -x -c "$INPUT_TEST_COMMAND"
-
diff --git a/.github/workflows/push-container/action.yml b/.github/workflows/push-container/action.yml
deleted file mode 100644
index 51f4b2aa0002..000000000000
--- a/.github/workflows/push-container/action.yml
+++ /dev/null
@@ -1,44 +0,0 @@
-name: Push Container
-description: >-
- Download all container artifacts for this job and push them to the GitHub registry.
-
-inputs:
- token:
- description: >-
- Token to use to authenticate with the container registry.
- required: true
-
-runs:
- using: "composite"
- steps:
- - name: Download container
- uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0
-
- - name: Push Container
- env:
- GITHUB_TOKEN: ${{ inputs.token }}
- shell: bash
- run: |
- function push_container {
- image_name=$1
- latest_name=$(echo $image_name | sed 's/:[a-f0-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
- 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