1212 - ' .github/workflows/containers/github-action-ci-tooling/**'
1313 - llvm/utils/git/requirements_formatting.txt
1414 - llvm/utils/git/requirements_linting.txt
15+ - ' .github/workflows/build-container/**'
16+ - ' .github/workflows/push-container/**'
1517 pull_request :
1618 paths :
1719 - .github/workflows/build-ci-container-tooling.yml
1820 - ' .github/workflows/containers/github-action-ci-tooling/**'
1921 - llvm/utils/git/requirements_formatting.txt
2022 - llvm/utils/git/requirements_linting.txt
23+ - ' .github/workflows/build-container/**'
24+ - ' .github/workflows/push-container/**'
2125
2226jobs :
2327 build-ci-container-tooling :
2428 if : github.repository_owner == 'llvm'
2529 runs-on : ubuntu-24.04
30+ strategy :
31+ fail-fast : false
32+ matrix :
33+ include :
34+ - container-name : code-format
35+ test-command : ' cd $HOME && clang-format --version | grep version && git-clang-format -h | grep usage && black --version | grep black'
36+ - container-name : code-lint
37+ test-command : ' cd $HOME && clang-tidy --version | grep version && clang-tidy-diff.py -h | grep usage'
2638 steps :
2739 - name : Checkout LLVM
2840 uses : actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
@@ -32,48 +44,16 @@ jobs:
3244 llvm/utils/git/requirements_formatting.txt
3345 llvm/utils/git/requirements_linting.txt
3446 clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
47+ .github/workflows/build-container
3548
36- - name : Write Variables
37- id : vars
38- run : |
39- tag=$(git rev-parse --short=12 HEAD)
40- container_name="ghcr.io/$GITHUB_REPOSITORY_OWNER/amd64/ci-ubuntu-24.04"
41- echo "container-name-format=$container_name-code-format" >> $GITHUB_OUTPUT
42- echo "container-name-lint=$container_name-code-lint" >> $GITHUB_OUTPUT
43- echo "container-name-format-tag=$container_name-format:$tag" >> $GITHUB_OUTPUT
44- echo "container-name-lint-tag=$container_name-lint:$tag" >> $GITHUB_OUTPUT
45- echo "container-format-filename=$(echo $container_name-format:$tag | sed -e 's/\//-/g' -e 's/:/-/g').tar" >> $GITHUB_OUTPUT
46- echo "container-lint-filename=$(echo $container_name-lint:$tag | sed -e 's/\//-/g' -e 's/:/-/g').tar" >> $GITHUB_OUTPUT
47-
48- - name : Build container
49- run : |
50- podman build --target ci-container-code-format \
51- -f .github/workflows/containers/github-action-ci-tooling/Dockerfile \
52- -t ${{ steps.vars.outputs.container-name-format-tag }} .
53- podman build --target ci-container-code-lint \
54- -f .github/workflows/containers/github-action-ci-tooling/Dockerfile \
55- -t ${{ steps.vars.outputs.container-name-lint-tag }} .
56-
57- # Save the container so we have it in case the push fails. This also
58- # allows us to separate the push step into a different job so we can
59- # maintain minimal permissions while building the container.
60- - name : Save container image
61- run : |
62- podman save ${{ steps.vars.outputs.container-name-format-tag }} > ${{ steps.vars.outputs.container-format-filename }}
63- podman save ${{ steps.vars.outputs.container-name-lint-tag }} > ${{ steps.vars.outputs.container-lint-filename }}
64-
65- - name : Upload container image
66- uses : actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
49+ - name : Build Container
50+ uses : ./.github/workflows/build-container
6751 with :
68- name : container-amd64
69- path : " *.tar"
70- retention-days : 14
71-
72- - name : Test Container
73- run : |
74- # Use --pull=never to ensure we are testing the just built image.
75- podman run --pull=never --rm -it ${{ steps.vars.outputs.container-name-format-tag }} /usr/bin/bash -x -c 'cd $HOME && clang-format --version | grep version && git-clang-format -h | grep usage && black --version | grep black'
76- podman run --pull=never --rm -it ${{ steps.vars.outputs.container-name-lint-tag }} /usr/bin/bash -x -c 'cd $HOME && clang-tidy --version | grep version && clang-tidy-diff.py -h | grep usage'
52+ container-name : ci-ubuntu-24.04-${{ matrix.container-name }}
53+ context : .github/workflows/containers/github-action-ci/
54+ dockerfile : .github/workflows/containers/github-action-ci/Dockerfile
55+ target : ci-container-${{ matrix.container-name }}
56+ test-command : ${{ matrix.test-command }}
7757
7858 push-ci-container :
7959 if : github.event_name == 'push'
@@ -82,34 +62,13 @@ jobs:
8262 permissions :
8363 packages : write
8464 runs-on : ubuntu-24.04
85- env :
86- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
8765 steps :
88- - name : Download container
89- uses : actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
90-
91- - name : Push Container
92- run : |
93- function push_container {
94- image_name=$1
95- latest_name=$(echo $image_name | sed 's/:[a-f0-9]\+$/:latest/g')
96- podman tag $image_name $latest_name
97- echo "Pushing $image_name ..."
98- podman push $image_name
99- echo "Pushing $latest_name ..."
100- podman push $latest_name
101- }
102-
103- podman login -u ${{ github.actor }} -p $GITHUB_TOKEN ghcr.io
104- for f in $(find . -iname '*.tar'); do
105- image_name=$(podman load -q -i $f | sed 's/Loaded image: //g')
106- push_container $image_name
66+ - name : Checkout LLVM
67+ uses : actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
68+ with :
69+ sparse-checkout : |
70+ .github/workflows/push-container
10771
108- if echo $image_name | grep '/amd64/'; then
109- # For amd64, create an alias with the arch component removed.
110- # This matches the convention used on dockerhub.
111- default_image_name=$(echo $(dirname $(dirname $image_name))/$(basename $image_name))
112- podman tag $image_name $default_image_name
113- push_container $default_image_name
114- fi
115- done
72+ - uses : ./.github/workflows/push-container
73+ with :
74+ token : ${{ secrets.GITHUB_TOKEN }}
0 commit comments