Skip to content

Commit df4c5d5

Browse files
authored
workflows: Rewrite build-ci-container to work on larger runners (#117353)
Also switch them over to the new depot runners.
1 parent e665e78 commit df4c5d5

File tree

6 files changed

+102
-153
lines changed

6 files changed

+102
-153
lines changed

.github/workflows/build-ci-container.yml

+40-65
Original file line numberDiff line numberDiff line change
@@ -18,95 +18,70 @@ on:
1818
- '.github/workflows/containers/github-action-ci/**'
1919

2020
jobs:
21-
# TODO(boomanaiden154): Switch this back to a single stage build when we can
22-
# run this on the self-hosted runners and don't have to do it this way to
23-
# avoid timeouts.
24-
build-ci-container-stage1:
21+
build-ci-container:
2522
if: github.repository_owner == 'llvm'
26-
runs-on: ubuntu-latest
23+
runs-on: depot-ubuntu-22.04-16
24+
outputs:
25+
container-name: ${{ steps.vars.outputs.container-name }}
26+
container-name-tag: ${{ steps.vars.outputs.container-name-tag }}
27+
container-filename: ${{ steps.vars.outputs.container-filename }}
2728
steps:
2829
- name: Checkout LLVM
2930
uses: actions/checkout@v4
3031
with:
3132
sparse-checkout: .github/workflows/containers/github-action-ci/
32-
- name: Change podman Root Direcotry
33-
run: |
34-
mkdir -p ~/.config/containers
35-
sudo mkdir -p /mnt/podman
36-
sudo chown `whoami`:`whoami` /mnt/podman
37-
cp ./.github/workflows/containers/github-action-ci/storage.conf ~/.config/containers/storage.conf
38-
podman info
39-
- name: Build container stage1
40-
working-directory: ./.github/workflows/containers/github-action-ci/
41-
run: |
42-
podman build -t stage1-toolchain --target stage1-toolchain -f stage1.Dockerfile .
43-
- name: Save container image
44-
run: |
45-
podman save stage1-toolchain > stage1-toolchain.tar
46-
- name: Upload container image
47-
uses: actions/upload-artifact@v4
48-
with:
49-
name: stage1-toolchain
50-
path: stage1-toolchain.tar
51-
retention-days: 1
52-
build-ci-container-stage2:
53-
if: github.repository_owner == 'llvm'
54-
runs-on: ubuntu-latest
55-
needs: build-ci-container-stage1
56-
permissions:
57-
packages: write
58-
steps:
5933
- name: Write Variables
6034
id: vars
6135
run: |
6236
tag=`date +%s`
6337
container_name="ghcr.io/$GITHUB_REPOSITORY_OWNER/ci-ubuntu-22.04"
6438
echo "container-name=$container_name" >> $GITHUB_OUTPUT
6539
echo "container-name-tag=$container_name:$tag" >> $GITHUB_OUTPUT
66-
67-
- name: Checkout LLVM
68-
uses: actions/checkout@v4
69-
with:
70-
sparse-checkout: .github/workflows/containers/github-action-ci/
71-
72-
- name: Change podman Root Direcotry
40+
echo "container-filename=$(echo $container_name:$tag | sed -e 's/\//-/g' -e 's/:/-/g').tar" >> $GITHUB_OUTPUT
41+
- name: Build container
42+
working-directory: ./.github/workflows/containers/github-action-ci/
7343
run: |
74-
mkdir -p ~/.config/containers
75-
sudo mkdir -p /mnt/podman
76-
sudo chown `whoami`:`whoami` /mnt/podman
77-
cp ./.github/workflows/containers/github-action-ci/storage.conf ~/.config/containers/storage.conf
78-
podman info
44+
podman build -t ${{ steps.vars.outputs.container-name-tag }} .
7945
80-
# Download the container image into /mnt/podman rather than
81-
# $GITHUB_WORKSPACE to avoid space limitations on the default drive
82-
# and use the permissions setup for /mnt/podman.
83-
- name: Download stage1-toolchain
84-
uses: actions/download-artifact@v4
85-
with:
86-
name: stage1-toolchain
87-
path: /mnt/podman
88-
89-
- name: Load stage1-toolchain
46+
# Save the container so we have it in case the push fails. This also
47+
# allows us to separate the push step into a different job so we can
48+
# maintain minimal permissions while building the container.
49+
- name: Save container image
9050
run: |
91-
podman load -i /mnt/podman/stage1-toolchain.tar
51+
podman save ${{ steps.vars.outputs.container-name-tag }} > ${{ steps.vars.outputs.container-filename }}
9252
93-
- name: Build Container
94-
working-directory: ./.github/workflows/containers/github-action-ci/
95-
run: |
96-
podman build -t ${{ steps.vars.outputs.container-name-tag }} -f stage2.Dockerfile .
97-
podman tag ${{ steps.vars.outputs.container-name-tag }} ${{ steps.vars.outputs.container-name }}:latest
53+
- name: Upload container image
54+
uses: actions/upload-artifact@v4
55+
with:
56+
name: container
57+
path: ${{ steps.vars.outputs.container-filename }}
58+
retention-days: 14
9859

9960
- name: Test Container
10061
run: |
10162
for image in ${{ steps.vars.outputs.container-name-tag }} ${{ steps.vars.outputs.container-name }}; do
10263
podman run --rm -it $image /usr/bin/bash -x -c 'printf '\''#include <iostream>\nint main(int argc, char **argv) { std::cout << "Hello\\n"; }'\'' | clang++ -x c++ - && ./a.out | grep Hello'
10364
done
10465
66+
push-ci-container:
67+
if: github.event_name == 'push'
68+
needs:
69+
- build-ci-container
70+
permissions:
71+
packages: write
72+
runs-on: ubuntu-24.04
73+
env:
74+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
75+
steps:
76+
- name: Download container
77+
uses: actions/download-artifact@v4
78+
with:
79+
name: container
80+
10581
- name: Push Container
106-
if: github.event_name == 'push'
107-
env:
108-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
10982
run: |
83+
podman load -i ${{ needs.build-ci-container.outptus.container-filename }}
84+
podman tag ${{ steps.vars.outputs.container-name-tag }} ${{ steps.vars.outputs.container-name }}:latest
11085
podman login -u ${{ github.actor }} -p $GITHUB_TOKEN ghcr.io
111-
podman push ${{ steps.vars.outputs.container-name-tag }}
112-
podman push ${{ steps.vars.outputs.container-name }}:latest
86+
podman push ${{ needs.build-ci-container.outputs.container-name-tag }}
87+
podman push ${{ needs.build-ci-container.outputs.container-name }}:latest
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
FROM docker.io/library/ubuntu:22.04 as base
2+
ENV LLVM_SYSROOT=/opt/llvm
3+
4+
FROM base as stage1-toolchain
5+
ENV LLVM_VERSION=19.1.2
6+
7+
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+
18+
RUN curl -O -L https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-$LLVM_VERSION.tar.gz && tar -xf llvmorg-$LLVM_VERSION.tar.gz
19+
20+
WORKDIR /llvm-project-llvmorg-$LLVM_VERSION
21+
22+
# Patch to enable better PGO profile data.
23+
# TODO: Remove this for llvm 20
24+
ADD https://github.com/llvm/llvm-project/commit/738250989ce516f02f809bdfde474a039c77e81f.patch .
25+
26+
RUN patch -p1 < 738250989ce516f02f809bdfde474a039c77e81f.patch
27+
28+
RUN cmake -B ./build -G Ninja ./llvm \
29+
-C ./clang/cmake/caches/BOLT-PGO.cmake \
30+
-DBOOTSTRAP_LLVM_ENABLE_LLD=ON \
31+
-DBOOTSTRAP_BOOTSTRAP_LLVM_ENABLE_LLD=ON \
32+
-DPGO_INSTRUMENT_LTO=Thin \
33+
-DLLVM_ENABLE_RUNTIMES="compiler-rt" \
34+
-DCMAKE_INSTALL_PREFIX="$LLVM_SYSROOT" \
35+
-DLLVM_ENABLE_PROJECTS="bolt;clang;lld;clang-tools-extra" \
36+
-DLLVM_DISTRIBUTION_COMPONENTS="lld;compiler-rt;clang-format;scan-build" \
37+
-DCLANG_DEFAULT_LINKER="lld"
38+
39+
RUN ninja -C ./build stage2-clang-bolt stage2-install-distribution && ninja -C ./build install-distribution
40+
41+
FROM base
42+
43+
COPY --from=stage1-toolchain $LLVM_SYSROOT $LLVM_SYSROOT
44+
45+
# Need to install curl for hendrikmuhs/ccache-action
46+
# Need nodejs for some of the GitHub actions.
47+
# Need perl-modules for clang analyzer tests.
48+
# Need git for SPIRV-Tools tests.
49+
RUN apt-get update && \
50+
apt-get install -y \
51+
binutils \
52+
cmake \
53+
curl \
54+
git \
55+
libstdc++-11-dev \
56+
ninja-build \
57+
nodejs \
58+
perl-modules \
59+
python3-psutil
60+
61+
ENV LLVM_SYSROOT=$LLVM_SYSROOT
62+
ENV PATH=${LLVM_SYSROOT}/bin:${PATH}

.github/workflows/containers/github-action-ci/bootstrap.patch

-13
This file was deleted.

.github/workflows/containers/github-action-ci/stage1.Dockerfile

-42
This file was deleted.

.github/workflows/containers/github-action-ci/stage2.Dockerfile

-29
This file was deleted.

.github/workflows/containers/github-action-ci/storage.conf

-4
This file was deleted.

0 commit comments

Comments
 (0)