|
18 | 18 | - '.github/workflows/containers/github-action-ci/**'
|
19 | 19 |
|
20 | 20 | jobs:
|
21 |
| - build-ci-container: |
| 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: |
22 | 25 | if: github.repository_owner == 'llvm'
|
23 |
| - runs-on: depot-ubuntu-22.04-16 |
24 |
| - outputs: |
25 |
| - container-name: ${{ steps.vars.outputs.container-name }} |
26 |
| - container-name-agent: ${{ steps.vars.outputs.container-name-agent }} |
27 |
| - container-name-tag: ${{ steps.vars.outputs.container-name-tag }} |
28 |
| - container-name-agent-tag: ${{ steps.vars.outputs.container-name-agent-tag }} |
29 |
| - container-filename: ${{ steps.vars.outputs.container-filename }} |
30 |
| - container-agent-filename: ${{ steps.vars.outputs.container-agent-filename }} |
| 26 | + runs-on: ubuntu-latest |
31 | 27 | steps:
|
32 | 28 | - name: Checkout LLVM
|
33 | 29 | uses: actions/checkout@v4
|
34 | 30 | with:
|
35 | 31 | 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: |
36 | 59 | - name: Write Variables
|
37 | 60 | id: vars
|
38 | 61 | run: |
|
39 | 62 | tag=`date +%s`
|
40 | 63 | container_name="ghcr.io/$GITHUB_REPOSITORY_OWNER/ci-ubuntu-22.04"
|
41 | 64 | echo "container-name=$container_name" >> $GITHUB_OUTPUT
|
42 |
| - echo "container-name-agent=$container_name-agent" >> $GITHUB_OUTPUT |
43 | 65 | echo "container-name-tag=$container_name:$tag" >> $GITHUB_OUTPUT
|
44 |
| - echo "container-name-agent-tag=$container_name-agent:$tag" >> $GITHUB_OUTPUT |
45 |
| - echo "container-filename=$(echo $container_name:$tag | sed -e 's/\//-/g' -e 's/:/-/g').tar" >> $GITHUB_OUTPUT |
46 |
| - echo "container-agent-filename=$(echo $container_name-agent:$tag | sed -e 's/\//-/g' -e 's/:/-/g').tar" >> $GITHUB_OUTPUT |
47 |
| - - name: Build container |
48 |
| - working-directory: ./.github/workflows/containers/github-action-ci/ |
49 |
| - run: | |
50 |
| - podman build --target ci-container -t ${{ steps.vars.outputs.container-name-tag }} . |
51 |
| - podman build --target ci-container-agent -t ${{ steps.vars.outputs.container-name-agent-tag }} . |
52 | 66 |
|
53 |
| - # Save the container so we have it in case the push fails. This also |
54 |
| - # allows us to separate the push step into a different job so we can |
55 |
| - # maintain minimal permissions while building the container. |
56 |
| - - name: Save container image |
| 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 |
57 | 73 | run: |
|
58 |
| - podman save ${{ steps.vars.outputs.container-name-tag }} > ${{ steps.vars.outputs.container-filename }} |
59 |
| - podman save ${{ steps.vars.outputs.container-name-agent-tag }} > ${{ steps.vars.outputs.container-agent-filename }} |
| 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 |
60 | 79 |
|
61 |
| - - name: Upload container image |
62 |
| - uses: actions/upload-artifact@v4 |
| 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 |
63 | 85 | with:
|
64 |
| - name: container |
65 |
| - path: "*.tar" |
66 |
| - retention-days: 14 |
| 86 | + name: stage1-toolchain |
| 87 | + path: /mnt/podman |
| 88 | + |
| 89 | + - name: Load stage1-toolchain |
| 90 | + run: | |
| 91 | + podman load -i /mnt/podman/stage1-toolchain.tar |
| 92 | +
|
| 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 |
67 | 98 |
|
68 | 99 | - name: Test Container
|
69 | 100 | run: |
|
70 |
| - for image in ${{ steps.vars.outputs.container-name-tag }}; do |
71 |
| - # Use --pull=never to ensure we are testing the just built image. |
72 |
| - podman run --pull=never --rm -it $image /usr/bin/bash -x -c 'cd $HOME && printf '\''#include <iostream>\nint main(int argc, char **argv) { std::cout << "Hello\\n"; }'\'' | clang++ -x c++ - && ./a.out | grep Hello' |
| 101 | + for image in ${{ steps.vars.outputs.container-name-tag }} ${{ steps.vars.outputs.container-name }}; do |
| 102 | + 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' |
73 | 103 | done
|
74 | 104 |
|
75 |
| - push-ci-container: |
76 |
| - if: github.event_name == 'push' |
77 |
| - needs: |
78 |
| - - build-ci-container |
79 |
| - permissions: |
80 |
| - packages: write |
81 |
| - runs-on: ubuntu-24.04 |
82 |
| - env: |
83 |
| - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
84 |
| - steps: |
85 |
| - - name: Download container |
86 |
| - uses: actions/download-artifact@v4 |
87 |
| - with: |
88 |
| - name: container |
89 |
| - |
90 | 105 | - name: Push Container
|
| 106 | + if: github.event_name == 'push' |
| 107 | + env: |
| 108 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
91 | 109 | run: |
|
92 |
| - podman load -i ${{ needs.build-ci-container.outputs.container-filename }} |
93 |
| - podman tag ${{ needs.build-ci-container.outputs.container-name-tag }} ${{ needs.build-ci-container.outputs.container-name }}:latest |
94 | 110 | podman login -u ${{ github.actor }} -p $GITHUB_TOKEN ghcr.io
|
95 |
| - podman push ${{ needs.build-ci-container.outputs.container-name-tag }} |
96 |
| - podman push ${{ needs.build-ci-container.outputs.container-name }}:latest |
97 |
| -
|
98 |
| - podman load -i ${{ needs.build-ci-container.outputs.container-agent-filename }} |
99 |
| - podman tag ${{ needs.build-ci-container.outputs.container-name-agent-tag }} ${{ needs.build-ci-container.outputs.container-name-agent }}:latest |
100 |
| - podman push ${{ needs.build-ci-container.outputs.container-name-agent-tag }} |
101 |
| - podman push ${{ needs.build-ci-container.outputs.container-name-agent }}:latest |
| 111 | + podman push ${{ steps.vars.outputs.container-name-tag }} |
| 112 | + podman push ${{ steps.vars.outputs.container-name }}:latest |
0 commit comments