Skip to content

Commit 12bbefe

Browse files
authored
Use P and Z GHA runners (#2215) (#2253)
* Use P and Z GHA runners (#2215) * Use go cross-compilation to speed up test builds on CI (#2210) After adding Arm runners on GHA, we made it so the Arm test image is always built. Unfortunately, because we use QEMU to build the images, the build has gotten quite slow. In order to speed up the build, this change makes it so we cross-compile the binaries for all our supported platforms locally and the image build simply copies the binaries into the final image.
1 parent a22fd06 commit 12bbefe

File tree

11 files changed

+69
-315
lines changed

11 files changed

+69
-315
lines changed

.github/workflows/collector-builder.yml

Lines changed: 16 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,6 @@ on:
88
required: true
99
description: |
1010
The tag used to build the collector image
11-
architectures:
12-
type: string
13-
required: true
14-
description: |
15-
Space-separated list of architectures to build
1611
1712
outputs:
1813
collector-builder-tag:
@@ -31,7 +26,6 @@ jobs:
3126
outputs:
3227
build-image: ${{ steps.builder-tag.outputs.build-image || false }}
3328
collector-builder-tag: ${{ steps.builder-tag.outputs.collector-builder-tag || 'master'}}
34-
local-exclude: ${{ steps.arch.outputs.local-exclude || '[]'}}
3529

3630
env:
3731
DEFAULT_BUILDER_TAG: master
@@ -70,24 +64,23 @@ jobs:
7064
echo "collector-builder-tag=${COLLECTOR_BUILDER_TAG}" >> "$GITHUB_OUTPUT"
7165
echo "build-image=true" >> "$GITHUB_OUTPUT"
7266
73-
- name: Check arches for local build
74-
if: ${{ ! contains(inputs.architectures, 'ppc64le') }}
75-
id: arch
76-
run: echo 'local-exclude=[{"arch":"ppc64le"}]' >> "$GITHUB_OUTPUT"
77-
7867
build-builder-image:
79-
name: Local builder image
80-
# Multiarch builds sometimes take for eeeeeeeeeever
81-
timeout-minutes: 480
68+
name: Build builder image
8269
needs:
8370
- builder-needs-rebuilding
8471
if: |
8572
needs.builder-needs-rebuilding.outputs.build-image == 'true'
8673
strategy:
8774
matrix:
88-
arch: [amd64, arm64, ppc64le]
89-
exclude: ${{ fromJSON(needs.builder-needs-rebuilding.outputs.local-exclude) }}
90-
runs-on: ${{ (matrix.arch == 'arm64' && 'ubuntu-24.04-arm') || 'ubuntu-24.04' }}
75+
arch:
76+
- amd64
77+
- arm64
78+
- ppc64le
79+
- s390x
80+
runs-on: ${{ (matrix.arch == 'arm64' && 'ubuntu-24.04-arm') ||
81+
(matrix.arch == 'ppc64le' && 'ubuntu-24.04-ppc64le') ||
82+
(matrix.arch == 's390x' && 'ubuntu-24.04-s390x') ||
83+
'ubuntu-24.04' }}
9184

9285
env:
9386
PLATFORM: linux/${{ matrix.arch }}
@@ -99,14 +92,14 @@ jobs:
9992
with:
10093
submodules: true
10194

102-
- name: Set up QEMU
103-
uses: docker/setup-qemu-action@v3
104-
with:
105-
image: tonistiigi/binfmt:qemu-v8.1.5
106-
10795
- name: Set up Docker Buildx
10896
uses: docker/setup-buildx-action@v3
10997

98+
- name: Install ansible on P&Z runners
99+
if: matrix.arch == 'ppc64le' || matrix.arch == 's390x'
100+
run: |
101+
sudo apt-get install -y ansible
102+
110103
- name: Create ansible vars
111104
run: |
112105
cat << EOF > ${{ github.workspace }}/ansible/secrets.yml
@@ -120,7 +113,6 @@ jobs:
120113
EOF
121114
122115
- name: Build images
123-
timeout-minutes: 480
124116
run: |
125117
ansible-galaxy install -r ansible/requirements.yml
126118
ansible-playbook \
@@ -131,98 +123,18 @@ jobs:
131123
-e @'${{ github.workspace }}/ansible/secrets.yml' \
132124
ansible/ci-build-builder.yml
133125
134-
build-builder-image-remote-vm:
135-
name: Remote builder image
136-
# Multiarch builds sometimes take for eeeeeeeeeever
137-
timeout-minutes: 480
138-
needs:
139-
- builder-needs-rebuilding
140-
if: |
141-
needs.builder-needs-rebuilding.outputs.build-image == 'true' &&
142-
contains(inputs.architectures, 's390x')
143-
strategy:
144-
matrix:
145-
arch: [s390x]
146-
runs-on: ubuntu-24.04
147-
148-
env:
149-
PLATFORM: linux/${{ matrix.arch }}
150-
BUILD_TYPE: ci
151-
COLLECTOR_BUILDER_TAG: ${{ needs.builder-needs-rebuilding.outputs.collector-builder-tag }}
152-
153-
steps:
154-
- uses: actions/checkout@v4
155-
with:
156-
submodules: true
157-
158-
- uses: actions/setup-python@v5
159-
with:
160-
python-version: "3.10"
161-
162-
- uses: 'google-github-actions/auth@v2'
163-
with:
164-
credentials_json: '${{ secrets.GOOGLE_CREDENTIALS_COLLECTOR_SVC_ACCT }}'
165-
166-
- uses: 'google-github-actions/setup-gcloud@v2'
167-
168-
- uses: ./.github/actions/setup-vm-creds
169-
with:
170-
gcp-ssh-key: ${{ secrets.GCP_SSH_KEY }}
171-
gcp-ssh-key-pub: ${{ secrets.GCP_SSH_KEY_PUB }}
172-
s390x-ssh-key: ${{ secrets.IBM_CLOUD_S390X_SSH_PRIVATE_KEY }}
173-
ppc64le-ssh-key: ${{ secrets.IBM_CLOUD_POWER_SSH_PRIVATE_KEY }}
174-
ppc64le-ssh-key-pub: ${{ secrets.IBM_CLOUD_POWER_SSH_PUBLIC_KEY }}
175-
s390x-key: ${{ secrets.IBM_CLOUD_S390x_API_KEY }}
176-
ppc64le-key: ${{ secrets.IBM_CLOUD_POWER_API_KEY }}
177-
redhat-username: ${{ secrets.REDHAT_USERNAME }}
178-
redhat-password: ${{ secrets.REDHAT_PASSWORD }}
179-
vm-type: all
180-
job-tag: builder
181-
182-
- name: Create Build VMs
183-
run: |
184-
make -C "${{ github.workspace }}/ansible" create-build-vms
185-
186-
- name: Create ansible vars
187-
run: |
188-
cat << EOF > ${{ github.workspace }}/ansible/secrets.yml
189-
---
190-
stackrox_io_username: ${{ secrets.QUAY_STACKROX_IO_RW_USERNAME }}
191-
stackrox_io_password: ${{ secrets.QUAY_STACKROX_IO_RW_PASSWORD }}
192-
rhacs_eng_username: ${{ secrets.QUAY_RHACS_ENG_RW_USERNAME }}
193-
rhacs_eng_password: ${{ secrets.QUAY_RHACS_ENG_RW_PASSWORD }}
194-
collector_git_ref: ${{ github.ref }}
195-
collector_builder_tag: ${{ needs.builder-needs-rebuilding.outputs.collector-builder-tag }}
196-
EOF
197-
198-
- name: Build images
199-
timeout-minutes: 480
200-
run: |
201-
ansible-playbook \
202-
-i ansible/ci \
203-
-e build_hosts='job_id_${{ env.JOB_ID }}' \
204-
-e arch='${{ matrix.arch }}' \
205-
-e @'${{ github.workspace }}/ansible/secrets.yml' \
206-
ansible/ci-build-builder.yml
207-
208-
- name: Destroy VMs
209-
if: always()
210-
run: |
211-
make -C ansible destroy-vms
212-
213126
create-multiarch-manifest:
214127
needs:
215128
- builder-needs-rebuilding
216129
- build-builder-image
217-
- build-builder-image-remote-vm
218130
name: Create Multiarch manifest
219131
runs-on: ubuntu-24.04
220132
if: |
221133
always() && !contains(join(needs.*.result, ','), 'failure') &&
222134
needs.builder-needs-rebuilding.outputs.build-image == 'true'
223135
env:
224136
COLLECTOR_BUILDER_TAG: ${{ needs.builder-needs-rebuilding.outputs.collector-builder-tag }}
225-
ARCHS: ${{ inputs.architectures }}
137+
ARCHS: amd64 arm64 ppc64le s390x
226138

227139
steps:
228140
- uses: actions/checkout@v4
@@ -258,7 +170,6 @@ jobs:
258170
if: always() && contains(join(needs.*.result, ','), 'failure') && github.event_name != 'pull_request'
259171
needs:
260172
- build-builder-image
261-
- build-builder-image-remote-vm
262173
- create-multiarch-manifest
263174
steps:
264175
- name: Slack notification

.github/workflows/collector.yml

Lines changed: 16 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,6 @@ on:
1818
required: true
1919
description: |
2020
The builder tag to use in the build
21-
architectures:
22-
type: string
23-
required: true
24-
description: |
25-
Space-separated list of architectures to build
2621
2722
env:
2823
COLLECTOR_TAG: ${{ inputs.collector-tag }}
@@ -33,26 +28,19 @@ env:
3328
ADDRESS_SANITIZER: ${{ contains(github.event.pull_request.labels.*.name, 'address-sanitizer') }}
3429

3530
jobs:
36-
prepare-build-collector:
37-
name: Prepare builders for collector
38-
runs-on: ubuntu-24.04
39-
outputs:
40-
local-exclude: ${{ steps.arch.outputs.local-exclude || '[]' }}
41-
42-
steps:
43-
- name: Check arches for local build
44-
if: ${{ ! contains(inputs.architectures, 'ppc64le') }}
45-
id: arch
46-
run: echo 'local-exclude=[{"arch":"ppc64le"}]' >> "$GITHUB_OUTPUT"
47-
4831
build-collector-image:
49-
name: Local collector image ${{ matrix.arch }}
50-
needs: prepare-build-collector
32+
name: Build collector image ${{ matrix.arch }}
5133
strategy:
5234
matrix:
53-
arch: [amd64, arm64, ppc64le]
54-
exclude: ${{ fromJSON(needs.prepare-build-collector.outputs.local-exclude) }}
55-
runs-on: ${{ (matrix.arch == 'arm64' && 'ubuntu-24.04-arm') || 'ubuntu-24.04' }}
35+
arch:
36+
- amd64
37+
- arm64
38+
- ppc64le
39+
- s390x
40+
runs-on: ${{ (matrix.arch == 'arm64' && 'ubuntu-24.04-arm') ||
41+
(matrix.arch == 'ppc64le' && 'ubuntu-24.04-ppc64le') ||
42+
(matrix.arch == 's390x' && 'ubuntu-24.04-s390x') ||
43+
'ubuntu-24.04' }}
5644

5745
env:
5846
PLATFORM: linux/${{ matrix.arch }}
@@ -63,14 +51,14 @@ jobs:
6351
with:
6452
submodules: true
6553

66-
- name: Set up QEMU
67-
uses: docker/setup-qemu-action@v3
68-
with:
69-
image: tonistiigi/binfmt:qemu-v8.1.5
70-
7154
- name: Set up Docker Buildx
7255
uses: docker/setup-buildx-action@v3
7356

57+
- name: Install ansible on P&Z runners
58+
if: matrix.arch == 'ppc64le' || matrix.arch == 's390x'
59+
run: |
60+
sudo apt-get install -y ansible
61+
7462
- name: Create ansible vars
7563
run: |
7664
cat << EOF > ${{ github.workspace }}/ansible/secrets.yml
@@ -91,7 +79,6 @@ jobs:
9179
EOF
9280
9381
- name: Build ${{ matrix.arch }} image locally
94-
timeout-minutes: 480
9582
run: |
9683
ansible-playbook \
9784
--connection local \
@@ -101,90 +88,14 @@ jobs:
10188
-e @'${{ github.workspace }}/ansible/secrets.yml' \
10289
ansible/ci-build-collector.yml
10390
104-
build-collector-image-remote-vm:
105-
name: Remote collector image
106-
runs-on: ubuntu-24.04
107-
if: contains(inputs.architectures, 's390x')
108-
strategy:
109-
matrix:
110-
arch: [s390x]
111-
112-
env:
113-
PLATFORM: linux/${{ matrix.arch }}
114-
115-
steps:
116-
- uses: actions/checkout@v4
117-
118-
- uses: actions/setup-python@v5
119-
with:
120-
python-version: "3.10"
121-
122-
- uses: 'google-github-actions/auth@v2'
123-
with:
124-
credentials_json: '${{ secrets.GOOGLE_CREDENTIALS_COLLECTOR_SVC_ACCT }}'
125-
126-
- uses: 'google-github-actions/setup-gcloud@v2'
127-
128-
- uses: ./.github/actions/setup-vm-creds
129-
with:
130-
gcp-ssh-key: ${{ secrets.GCP_SSH_KEY }}
131-
gcp-ssh-key-pub: ${{ secrets.GCP_SSH_KEY_PUB }}
132-
s390x-ssh-key: ${{ secrets.IBM_CLOUD_S390X_SSH_PRIVATE_KEY }}
133-
ppc64le-ssh-key: ${{ secrets.IBM_CLOUD_POWER_SSH_PRIVATE_KEY }}
134-
ppc64le-ssh-key-pub: ${{ secrets.IBM_CLOUD_POWER_SSH_PUBLIC_KEY }}
135-
s390x-key: ${{ secrets.IBM_CLOUD_S390x_API_KEY }}
136-
ppc64le-key: ${{ secrets.IBM_CLOUD_POWER_API_KEY }}
137-
redhat-username: ${{ secrets.REDHAT_USERNAME }}
138-
redhat-password: ${{ secrets.REDHAT_PASSWORD }}
139-
vm-type: rhel-${{ matrix.arch }}
140-
job-tag: builder
141-
142-
- name: Create Build VMs
143-
run: |
144-
make -C "${{ github.workspace }}/ansible" create-build-vms
145-
146-
- name: Create ansible vars
147-
run: |
148-
cat << EOF > ${{ github.workspace }}/ansible/secrets.yml
149-
---
150-
stackrox_io_username: ${{ secrets.QUAY_STACKROX_IO_RW_USERNAME }}
151-
stackrox_io_password: ${{ secrets.QUAY_STACKROX_IO_RW_PASSWORD }}
152-
rhacs_eng_username: ${{ secrets.QUAY_RHACS_ENG_RW_USERNAME }}
153-
rhacs_eng_password: ${{ secrets.QUAY_RHACS_ENG_RW_PASSWORD }}
154-
collector_git_ref: ${{ github.ref }}
155-
collector_git_sha: ${{ github.sha }}
156-
collector_builder_tag: ${{ env.COLLECTOR_BUILDER_TAG }}
157-
disable_profiling: ${{ matrix.arch != 'amd64' && matrix.arch != 'arm64' }}
158-
rhacs_eng_image: ${{ env.RHACS_ENG_IMAGE }}
159-
collector_image: ${{ inputs.collector-image }}
160-
collector_tag: ${{ inputs.collector-tag }}
161-
debug_mode: ${{ github.event_name == 'pull_request' }}
162-
EOF
163-
164-
- name: Build ${{ matrix.arch }} image
165-
timeout-minutes: 480
166-
run: |
167-
ansible-playbook \
168-
-i ansible/ci \
169-
-e arch='${{ matrix.arch }}' \
170-
-e build_hosts='job_id_${{ env.JOB_ID }}' \
171-
-e @'${{ github.workspace }}/ansible/secrets.yml' \
172-
ansible/ci-build-collector.yml
173-
174-
- name: Destroy Build VMs
175-
if: always()
176-
run: |
177-
make -C ansible destroy-vms
178-
17991
create-multiarch-manifest:
18092
needs:
18193
- build-collector-image
182-
- build-collector-image-remote-vm
18394
name: Create Multiarch manifest
18495
runs-on: ubuntu-24.04
18596
if: always() && !contains(join(needs.*.result, ','), 'failure')
18697
env:
187-
ARCHS: ${{ inputs.architectures }}
98+
ARCHS: amd64 arm64 ppc64le s390x
18899

189100
steps:
190101
- uses: actions/checkout@v4
@@ -220,7 +131,6 @@ jobs:
220131
if: always() && contains(join(needs.*.result, ','), 'failure') && github.event_name != 'pull_request'
221132
needs:
222133
- build-collector-image
223-
- build-collector-image-remote-vm
224134
- create-multiarch-manifest
225135
steps:
226136
- name: Slack notification

.github/workflows/init.yml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,6 @@ on:
5858
description: |
5959
Trigger rebuild of QA containers
6060
value: ${{ jobs.common-variables.outputs.rebuild-qa-containers }}
61-
architectures:
62-
description: |
63-
Space-separated list of architectures to build
64-
value: |
65-
${{ ((github.event_name != 'pull_request' ||
66-
contains(github.event.pull_request.labels.*.name, 'run-multiarch-builds')) &&
67-
'amd64 arm64 ppc64le s390x') || 'amd64 arm64' }}
6861

6962
jobs:
7063
common-variables:

0 commit comments

Comments
 (0)