[llvm] [Github] Add github-automation container (PR #200704)

Tom Stellard via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 9 10:54:33 PDT 2026


https://github.com/tstellar updated https://github.com/llvm/llvm-project/pull/200704

>From 57ed8d66866720ba3f03acb4bc64de9e25760e8e Mon Sep 17 00:00:00 2001
From: Tom Stellard <tstellar at redhat.com>
Date: Sun, 31 May 2026 07:49:28 -0700
Subject: [PATCH 1/2] [Github] Add github-automation container

There are several jobs that use the pattern:
1. Checkout github-automation.py script.
2. Install dependencies for github-automation.py script.
3. Run the github-automation.py script.

We can consolidate a lot of this logic into the container and simplify
the workflows.  This may also speed them up the workflow jobs slightly,
but most of them are already pretty fast, so it may not make a big
difference.
---
 .../workflows/build-ci-container-tooling.yml  |  6 ++++++
 .../github-action-ci-tooling/Dockerfile       | 19 +++++++++++++++++++
 2 files changed, 25 insertions(+)

diff --git a/.github/workflows/build-ci-container-tooling.yml b/.github/workflows/build-ci-container-tooling.yml
index b2ba3bfe3ddc6..32cd7567f9c16 100644
--- a/.github/workflows/build-ci-container-tooling.yml
+++ b/.github/workflows/build-ci-container-tooling.yml
@@ -10,6 +10,7 @@ on:
     paths:
       - .github/workflows/build-ci-container-tooling.yml
       - '.github/workflows/containers/github-action-ci-tooling/**'
+      - llvm/utils/git/github-automation.py
       - llvm/utils/git/requirements_formatting.txt
       - llvm/utils/git/requirements_linting.txt
       - '.github/actions/build-container/**'
@@ -18,6 +19,7 @@ on:
     paths:
       - .github/workflows/build-ci-container-tooling.yml
       - '.github/workflows/containers/github-action-ci-tooling/**'
+      - llvm/utils/git/github-automation.py
       - llvm/utils/git/requirements_formatting.txt
       - llvm/utils/git/requirements_linting.txt
       - '.github/actions/build-container/**'
@@ -39,6 +41,10 @@ jobs:
           - container-name: abi-tests
             test-command: 'cd $HOME && abi-compliance-checker --help'
             target: abi-tests
+          - container-name: github-automation
+            test-command: 'true'
+            target: github-automation
+
     steps:
       - name: Checkout LLVM
         uses: actions/checkout at de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
diff --git a/.github/workflows/containers/github-action-ci-tooling/Dockerfile b/.github/workflows/containers/github-action-ci-tooling/Dockerfile
index 68a2da6de044e..82dc673f00e99 100644
--- a/.github/workflows/containers/github-action-ci-tooling/Dockerfile
+++ b/.github/workflows/containers/github-action-ci-tooling/Dockerfile
@@ -113,3 +113,22 @@ RUN apt-get update && \
     universal-ctags && \
     apt-get clean && \
     rm -rf /var/lib/apt/lists/*
+
+FROM base as ci-container-github-automation
+ARG LLVM_GIT_CHECKOUT=/home/gha/llvm-project
+ARG LLVM_GITHUB_AUTOMATION_DIR=llvm/utils/git
+ENV PATH=${LLVM_GIT_CHECKOUT}/${LLVM_GITHUB_AUTOMATION_DIR}:${PATH}
+
+RUN apt-get update && \
+    DEBIAN_FRONTEND=noninteractive apt-get install -y \
+    python3-git \
+    python3-github && \
+    apt-get clean && \
+    rm -rf /var/lib/apt/lists/*
+
+USER gha
+RUN git clone https://github.com/llvm/llvm-project --depth=1 -b main --no-checkout ${LLVM_GIT_CHECKOUT} && \
+    git -C ${LLVM_GIT_CHECKOUT} sparse-checkout init --cone && \
+    git -C ${LLVM_GIT_CHECKOUT} sparse-checkout set ${LLVM_GITHUB_AUTOMATION_DIR} && \
+    git -C ${LLVM_GIT_CHECKOUT} checkout && \
+    rm -Rf ${LLVM_GIT_CHECKOUT}/.git

>From a5b4da4bc67187e9fcbba0c616f5348d11fb515c Mon Sep 17 00:00:00 2001
From: Tom Stellard <tstellar at redhat.com>
Date: Tue, 9 Jun 2026 10:54:01 -0700
Subject: [PATCH 2/2] Don't checkout during container build

---
 .github/workflows/build-ci-container-tooling.yml       |  2 ++
 .../containers/github-action-ci-tooling/Dockerfile     | 10 ++--------
 2 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/.github/workflows/build-ci-container-tooling.yml b/.github/workflows/build-ci-container-tooling.yml
index 32cd7567f9c16..9e3ee50f9fae4 100644
--- a/.github/workflows/build-ci-container-tooling.yml
+++ b/.github/workflows/build-ci-container-tooling.yml
@@ -44,6 +44,7 @@ jobs:
           - container-name: github-automation
             test-command: 'true'
             target: github-automation
+            context: llvm/utils/git/
 
     steps:
       - name: Checkout LLVM
@@ -54,6 +55,7 @@ jobs:
             .github/workflows/containers/github-action-ci-tooling/
             llvm/utils/git/requirements_formatting.txt
             llvm/utils/git/requirements_linting.txt
+            llvm/utils/git/github-automation.py
             clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
             .github/actions/build-container
 
diff --git a/.github/workflows/containers/github-action-ci-tooling/Dockerfile b/.github/workflows/containers/github-action-ci-tooling/Dockerfile
index 82dc673f00e99..af070b226697e 100644
--- a/.github/workflows/containers/github-action-ci-tooling/Dockerfile
+++ b/.github/workflows/containers/github-action-ci-tooling/Dockerfile
@@ -115,9 +115,6 @@ RUN apt-get update && \
     rm -rf /var/lib/apt/lists/*
 
 FROM base as ci-container-github-automation
-ARG LLVM_GIT_CHECKOUT=/home/gha/llvm-project
-ARG LLVM_GITHUB_AUTOMATION_DIR=llvm/utils/git
-ENV PATH=${LLVM_GIT_CHECKOUT}/${LLVM_GITHUB_AUTOMATION_DIR}:${PATH}
 
 RUN apt-get update && \
     DEBIAN_FRONTEND=noninteractive apt-get install -y \
@@ -127,8 +124,5 @@ RUN apt-get update && \
     rm -rf /var/lib/apt/lists/*
 
 USER gha
-RUN git clone https://github.com/llvm/llvm-project --depth=1 -b main --no-checkout ${LLVM_GIT_CHECKOUT} && \
-    git -C ${LLVM_GIT_CHECKOUT} sparse-checkout init --cone && \
-    git -C ${LLVM_GIT_CHECKOUT} sparse-checkout set ${LLVM_GITHUB_AUTOMATION_DIR} && \
-    git -C ${LLVM_GIT_CHECKOUT} checkout && \
-    rm -Rf ${LLVM_GIT_CHECKOUT}/.git
+
+ADD github-automation.py /usr/local/bin/



More information about the llvm-commits mailing list