Skip to content

Commit bf07226

Browse files
authored
[libc++] Reorganize and fix the libc++ CI dockerfiles (#167530)
Instead of having one large Dockerfile building multiple images with relatively confusing inheritance, explicitly have three standalone Dockerfiles each building one image. Then, tie the three images together using the docker-compose file which explicitly versions the base image used by the Android and the Github Actions images.
1 parent b5c459d commit bf07226

File tree

8 files changed

+384
-430
lines changed

8 files changed

+384
-430
lines changed

.github/workflows/libcxx-build-containers.yml

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ on:
1515
branches:
1616
- main
1717
paths:
18-
- 'libcxx/utils/ci/**'
18+
- 'libcxx/utils/ci/docker/**'
1919
- '.github/workflows/libcxx-build-containers.yml'
2020
pull_request:
2121
paths:
22-
- 'libcxx/utils/ci/**'
22+
- 'libcxx/utils/ci/docker/**'
2323
- '.github/workflows/libcxx-build-containers.yml'
2424

2525
jobs:
@@ -40,17 +40,18 @@ jobs:
4040
echo '{ "data-root": "/mnt/docker" }' | sudo tee /etc/docker/daemon.json
4141
sudo systemctl restart docker
4242
43-
- name: Build the Linux builder image
44-
working-directory: libcxx/utils/ci
45-
run: |
46-
docker compose build builder-base
47-
docker compose build actions-builder
43+
- name: Build the base image
44+
run: docker compose --file libcxx/utils/ci/docker/docker-compose.yml build libcxx-linux-builder-base
45+
env:
46+
TAG: ${{ github.sha }}
47+
48+
- name: Build the Linux Github Actions image
49+
run: docker compose --file libcxx/utils/ci/docker/docker-compose.yml build libcxx-linux-builder
4850
env:
4951
TAG: ${{ github.sha }}
5052

5153
- name: Build the Android builder image
52-
working-directory: libcxx/utils/ci
53-
run: docker compose build android-buildkite-builder
54+
run: docker compose --file libcxx/utils/ci/docker/docker-compose.yml build libcxx-android-builder
5455
env:
5556
TAG: ${{ github.sha }}
5657

@@ -61,19 +62,21 @@ jobs:
6162
username: ${{ github.actor }}
6263
password: ${{ secrets.GITHUB_TOKEN }}
6364

64-
- name: Push the Linux builder image
65+
- name: Push the images
6566
if: github.event_name == 'push'
66-
working-directory: libcxx/utils/ci
67-
run: |
68-
docker compose push builder-base
69-
docker compose push actions-builder
70-
env:
71-
TAG: ${{ github.sha }}
67+
run: docker compose push libcxx-linux-builder-base libcxx-linux-builder libcxx-android-builder
7268

73-
- name: Push the Android builder image
74-
if: github.event_name == 'push'
75-
working-directory: libcxx/utils/ci
69+
# We create tarballs with the images and upload them as artifacts, since that's useful for testing
70+
# the images when making changes.
71+
- name: Create image tarballs
7672
run: |
77-
docker compose push android-buildkite-builder
78-
env:
79-
TAG: ${{ github.sha }}
73+
docker image save ghcr.io/llvm/libcxx-linux-builder-base:${{ github.sha }} | gzip > libcxx-linux-builder-base.tar.gz
74+
docker image save ghcr.io/llvm/libcxx-linux-builder:${{ github.sha }} | gzip > libcxx-linux-builder.tar.gz
75+
docker image save ghcr.io/llvm/libcxx-android-builder:${{ github.sha }} | gzip > libcxx-android-builder.tar.gz
76+
- uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
77+
with:
78+
name: libcxx-docker-images
79+
path: |
80+
libcxx-linux-builder-base.tar.gz
81+
libcxx-linux-builder.tar.gz
82+
libcxx-android-builder.tar.gz

libcxx/docs/Contributing.rst

Lines changed: 21 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -269,20 +269,20 @@ Updating the CI testing container images
269269
----------------------------------------
270270

271271
The libcxx linux premerge testing can run on one of three sets of runner
272-
groups. The three runner group names are "llvm-premerge-libcxx-runners",
273-
"llvm-premerge-libcxx-release-runners" and "llvm-premerge-libcxx-next-runners".
274-
Which runner set to use is controlled by the contents of
272+
groups. The three runner group names are ``llvm-premerge-libcxx-runners``,
273+
``llvm-premerge-libcxx-release-runners`` and ``llvm-premerge-libcxx-next-runners``.
274+
The runner set to use is controlled by the contents of
275275
https://github.com/llvm/llvm-project/blob/main/.github/workflows/libcxx-build-and-test.yaml.
276-
By default, it uses "llvm-premerge-libcxx-runners". To switch to one of the
277-
other runner sets, just replace all uses of "llvm-premerge-libcxx-runners" in
276+
By default, it uses ``llvm-premerge-libcxx-runners``. To switch to one of the
277+
other runner sets, just replace all uses of ``llvm-premerge-libcxx-runners`` in
278278
the yaml file with the desired runner set.
279279

280280
Which container image is used by these three runner sets is controlled
281281
and set by the variable values in
282282
https://github.com/llvm/llvm-zorg/blob/main/premerge/premerge_resources/variables.tf.
283283
The table below shows the variable names and
284284
the runner sets to which they correspond. To see their values, follow the
285-
link above (to variables.tf in llvm-zorg).
285+
link above (to ``variables.tf`` in llvm-zorg).
286286

287287
+------------------------------------+---------------------------+
288288
|Runner Set |Variable |
@@ -295,39 +295,21 @@ link above (to variables.tf in llvm-zorg).
295295
+------------------------------------+---------------------------+
296296

297297

298-
When updating the container image you can either update just the
299-
runner binary (the part the connects to Github), or you can update
300-
everything (tools, etc.). Whether to update just the runner or to update
301-
everything is controlled by the value of ``ACTIONS_BASE_IMAGE``, under
302-
``actions-builder`` in ``libcxx/utils/ci/docker-compose.yml``.
303-
304-
To update just the runner binary, change the value of ``ACTIONS_BASE_IMAGE``
305-
to be a modified version of one of the libcxx runner variable images from
306-
https://github.com/llvm/llvm-zorg/blob/main/premerge/premerge_resources/variables.tf,
307-
as follows: Find the libcxx runner image name you want to use from the
308-
variables.tf file. The name will be something like
309-
``ghcr.io/llvm/libcxx-linux-builder:<some-commit-SHA>``. Replace
310-
``libcxx-linux-builder`` with ``libcxx-linux-builder-base``. Use this new image
311-
name as the value you assign to ``ACTIONS_BASE_IMAGE``.
312-
313-
To update the entire container image, set the value of ``ACTIONS_BASE_IMAGE``
314-
to ``builder-base``. If the value is already ``builder-base`` (there
315-
have been no just-the-runner updates since the last complete update), then you
316-
need to find the line containing ``RUN echo "Last forced update executed on``
317-
in ``libcxx/utils/ci/Dockerfile`` and update the date to be the current date.
318-
319-
Once you have created and merged a PR with those changes, a new image
320-
will be created, and a link to it can be found at
321-
https://github.com/llvm/llvm-project/pkgs/container/libcxx-linux-builder,
322-
where the actual image name should be
323-
``ghcr.io/llvm/libcxx-linux-builder:<SHA-of-committed-change-from-PR>``.
324-
325-
Lastly you need to create a PR in the llvm-zorg repository,
326-
updating the the value of the appropriate libcxx runner variable in
327-
the variables.tf file mentioned above to the name of your newly created
328-
image (see above paragraph about finding the image name). Once that change
329-
has been merged, an LLVM premerge maintainer (a Google employee) must use
330-
terraform to apply the change to the running GKE cluster.
298+
When updating the container image you can either update just the runner binary (the part
299+
that connects to Github), or you can update everything (tools, etc.). To update the runner
300+
binary, bump the value of ``GITHUB_RUNNER_VERSION`` in ``libcxx/utils/ci/docker/docker-compose.yml``.
301+
To update all of the tools, bump ``BASE_IMAGE_VERSION`` to a newer version of the ``libcxx-linux-builder-base``
302+
image. You can see all versions of that image at https://github.com/llvm/llvm-project/pkgs/container/libcxx-linux-builder-base.
303+
304+
On push to ``main``, a new version of both the ``libcxx-linux-builder`` and the ``libcxx-android-builder``
305+
images will be built and pushed to https://github.com/llvm/llvm-project/packages.
306+
307+
You can then update the image used by the actual runners by changing the sha associated
308+
to ``libcxx_runner_image``, ``libcxx_release_runner_image`` or ``libcxx_next_runner_image``
309+
in `the Terraform configuration file <https://github.com/llvm/llvm-zorg/blob/main/premerge/premerge_resources/variables.tf>`_.
310+
To do so, you will need to create a PR in the llvm-zorg repository and wait for it to be
311+
merged. Once that change has been merged, an LLVM premerge maintainer (a Google employee)
312+
must use terraform to apply the change to the running GKE cluster.
331313

332314

333315
Monitoring premerge testing performance

0 commit comments

Comments
 (0)