Skip to content

Commit 8496a1b

Browse files
committed
add dockerfile with binary download
1 parent d7ee503 commit 8496a1b

File tree

2 files changed

+59
-50
lines changed

2 files changed

+59
-50
lines changed

.github/workflows/build-ci-container-code-format.yml renamed to .github/workflows/build-ci-container-tooling.yml

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,43 +8,53 @@ on:
88
branches:
99
- main
1010
paths:
11-
- .github/workflows/build-ci-container-code-format.yml
12-
- '.github/workflows/containers/github-action-ci-code-format/**'
13-
- llvm/utils/git/code-format-helper.py
11+
- .github/workflows/build-ci-container-tooling.yml
12+
- '.github/workflows/containers/github-action-ci-tooling/**'
1413
- llvm/utils/git/requirements_formatting.txt
15-
- llvm/utils/git/requirements_formatting.txt.in
14+
- llvm/utils/git/requirements_linting.txt
1615
pull_request:
1716
paths:
18-
- .github/workflows/build-ci-container-code-format.yml
19-
- '.github/workflows/containers/github-action-ci-code-format/**'
20-
- llvm/utils/git/code-format-helper.py
17+
- .github/workflows/build-ci-container-tooling.yml
18+
- '.github/workflows/containers/github-action-ci-tooling/**'
2119
- llvm/utils/git/requirements_formatting.txt
22-
- llvm/utils/git/requirements_formatting.txt.in
20+
- llvm/utils/git/requirements_linting.txt
2321

2422
jobs:
25-
build-ci-container-code-format:
23+
build-ci-container-tooling:
2624
if: github.repository_owner == 'llvm'
2725
runs-on: depot-ubuntu-24.04-16
26+
strategy:
27+
matrix:
28+
target: [ci-container-code-format, ci-container-code-lint]
29+
include:
30+
- target: ci-container-code-format
31+
container_name: code-format
32+
check_line: clang-format --version | grep version
33+
- target: ci-container-code-lint
34+
container_name: code-lint
35+
check_line: clang-tidy --version | grep version
2836
steps:
2937
- name: Checkout LLVM
3038
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
3139
with:
3240
sparse-checkout: |
33-
.github/workflows/containers/github-action-ci-code-format/
41+
.github/workflows/containers/github-action-ci-tooling/
3442
llvm/utils/git/requirements_formatting.txt
43+
llvm/utils/git/requirements_linting.txt
44+
clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
3545
3646
- name: Write Variables
3747
id: vars
3848
run: |
3949
tag=$(git rev-parse --short=12 HEAD)
40-
container_name="ghcr.io/$GITHUB_REPOSITORY_OWNER/amd64/ci-ubuntu-24.04-code-format"
50+
container_name="ghcr.io/$GITHUB_REPOSITORY_OWNER/amd64/ci-ubuntu-24.04-${{ matrix.container_name }}"
4151
echo "container-name=$container_name" >> $GITHUB_OUTPUT
4252
echo "container-name-tag=$container_name:$tag" >> $GITHUB_OUTPUT
4353
echo "container-filename=$(echo $container_name:$tag | sed -e 's/\//-/g' -e 's/:/-/g').tar" >> $GITHUB_OUTPUT
4454
- name: Build container
4555
run: |
46-
podman build --target ci-container-code-format \
47-
-f .github/workflows/containers/github-action-ci-code-format/Dockerfile \
56+
podman build --target ${{ matrix.target }} \
57+
-f .github/workflows/containers/github-action-ci-tooling/Dockerfile \
4858
-t ${{ steps.vars.outputs.container-name-tag }} .
4959
5060
# Save the container so we have it in case the push fails. This also
@@ -57,21 +67,21 @@ jobs:
5767
- name: Upload container image
5868
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
5969
with:
60-
name: container-amd64
70+
name: container-amd64-${{ matrix.container_name }}
6171
path: "*.tar"
6272
retention-days: 14
6373

6474
- name: Test Container
6575
run: |
6676
for image in ${{ steps.vars.outputs.container-name-tag }}; do
6777
# Use --pull=never to ensure we are testing the just built image.
68-
podman run --pull=never --rm -it $image /usr/bin/bash -x -c 'cd $HOME && clang-format --version | grep version'
78+
podman run --pull=never --rm -it $image /usr/bin/bash -x -c 'cd $HOME && ${{ matrix.check_line }}'
6979
done
7080
7181
push-ci-container:
7282
if: github.event_name == 'push'
7383
needs:
74-
- build-ci-container-code-format
84+
- build-ci-container-tooling
7585
permissions:
7686
packages: write
7787
runs-on: ubuntu-24.04
Lines changed: 33 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,18 @@
1-
FROM docker.io/library/ubuntu:24.04 AS base
2-
ENV LLVM_SYSROOT=/opt/llvm
1+
FROM docker.io/library/ubuntu:24.04 AS llvm-downloader
32

4-
FROM base AS clang-format-toolchain
5-
ENV LLVM_VERSION=21.1.1
3+
ENV LLVM_VERSION=21.1.2
64

75
RUN apt-get update && \
8-
apt-get install -y \
9-
wget \
10-
gcc \
11-
g++ \
12-
cmake \
13-
ninja-build \
14-
python3 \
15-
git \
16-
curl \
17-
zlib1g-dev && \
18-
apt-get clean && \
19-
rm -rf /var/lib/apt/lists/*
20-
21-
RUN curl -O -L https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-$LLVM_VERSION.tar.gz && \
22-
tar -xf llvmorg-$LLVM_VERSION.tar.gz && \
23-
rm -f llvmorg-$LLVM_VERSION.tar.gz
24-
25-
WORKDIR /llvm-project-llvmorg-$LLVM_VERSION
6+
apt-get install -y wget pixz && \
7+
wget --progress=bar:force -O llvm.tar.xz https://github.com/llvm/llvm-project/releases/download/llvmorg-${LLVM_VERSION}/LLVM-${LLVM_VERSION}-Linux-X64.tar.xz && \
8+
mkdir -p /llvm-extract && \
9+
pixz -d llvm.tar.xz && \
10+
tar -xvf llvm.tar -C /llvm-extract LLVM-${LLVM_VERSION}-Linux-X64/bin/ && \
11+
rm llvm.tar
2612

27-
RUN cmake -B ./build -G Ninja ./llvm \
28-
-DCMAKE_BUILD_TYPE=Release \
29-
-DCMAKE_INSTALL_PREFIX="$LLVM_SYSROOT" \
30-
-DLLVM_ENABLE_PROJECTS="clang" \
31-
-DLLVM_DISTRIBUTION_COMPONENTS="clang-format"
32-
33-
RUN ninja -C ./build install-distribution
34-
35-
FROM base AS ci-container-code-format
13+
FROM docker.io/library/ubuntu:24.04 AS base
3614

37-
COPY --from=clang-format-toolchain $LLVM_SYSROOT $LLVM_SYSROOT
15+
ENV LLVM_SYSROOT=/opt/llvm
3816

3917
# Need nodejs for some of the GitHub actions.
4018
# Need git for git-clang-format.
@@ -53,8 +31,6 @@ RUN apt-get update && \
5331
apt-get clean && \
5432
rm -rf /var/lib/apt/lists/*
5533

56-
ENV LLVM_SYSROOT=$LLVM_SYSROOT
57-
ENV PATH=${LLVM_SYSROOT}/bin:${PATH}
5834

5935
# Create a new user to avoid test failures related to a lack of expected
6036
# permissions issues in some tests. Set the user id to 1001 as that is the
@@ -69,8 +45,31 @@ RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
6945
USER gha
7046
WORKDIR /home/gha
7147

48+
FROM base AS ci-container-code-format
49+
50+
ENV LLVM_VERSION=21.1.2
51+
52+
COPY --from=llvm-downloader /llvm-extract/LLVM-${LLVM_VERSION}-Linux-X64/bin/clang-format ${LLVM_SYSROOT}/bin/clang-format
53+
54+
ENV PATH=${LLVM_SYSROOT}/bin:${PATH}
55+
7256
# Install dependencies for 'pr-code-format.yml' job
7357
COPY llvm/utils/git/requirements_formatting.txt /home/gha/requirements_formatting.txt
7458
RUN python -m venv venv && \
7559
venv/bin/pip install -r /home/gha/requirements_formatting.txt && \
7660
rm /home/gha/requirements_formatting.txt
61+
62+
# Stage 4: clang-lint container
63+
FROM base AS ci-container-code-lint
64+
65+
ENV LLVM_VERSION=21.1.2
66+
67+
COPY --from=llvm-downloader /llvm-extract/LLVM-${LLVM_VERSION}-Linux-X64/bin/clang-tidy ${LLVM_SYSROOT}/bin/
68+
COPY clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py ${LLVM_SYSROOT}/bin/clang-tidy-diff.py
69+
70+
ENV PATH=${LLVM_SYSROOT}/bin:${PATH}
71+
72+
COPY llvm/utils/git/requirements_linting.txt /home/gha/requirements_linting.txt
73+
RUN python -m venv venv && \
74+
venv/bin/pip install -r /home/gha/requirements_linting.txt && \
75+
rm /home/gha/requirements_linting.txt

0 commit comments

Comments
 (0)