Skip to content

Commit 9b09e62

Browse files
authored
ROX-29116: (fix) Use ARM GH action workflow runners for ARM builds (#2106)
* Revert "Revert GH arm changes (#2107)" * Add arm64 stable, beta, and dev channels for Google COS integration tests (#2096)
1 parent 41ae56f commit 9b09e62

File tree

7 files changed

+160
-147
lines changed

7 files changed

+160
-147
lines changed

.github/workflows/collector-builder.yml

Lines changed: 110 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,16 @@ 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
16+
1117
outputs:
1218
collector-builder-tag:
1319
description: The builder tag used by the build
14-
value: ${{ jobs.build-builder-image.outputs.collector-builder-tag || 'master' }}
20+
value: ${{ jobs.builder-needs-rebuilding.outputs.collector-builder-tag }}
1521

1622
env:
1723
COLLECTOR_TAG: ${{ inputs.collector-tag }}
@@ -23,7 +29,12 @@ jobs:
2329
name: Determine if builder image needs to be built
2430
runs-on: ubuntu-24.04
2531
outputs:
26-
build-image: ${{ steps.changed.outputs.builder-changed }}
32+
build-image: ${{ steps.builder-tag.outputs.build-image || false }}
33+
collector-builder-tag: ${{ steps.builder-tag.outputs.collector-builder-tag || 'master'}}
34+
local-exclude: ${{ steps.arch.outputs.local-exclude || '[]'}}
35+
36+
env:
37+
DEFAULT_BUILDER_TAG: master
2738

2839
steps:
2940
- uses: actions/checkout@v4
@@ -38,30 +49,50 @@ jobs:
3849
- builder/Dockerfile
3950
- .github/workflows/collector-builder.yml
4051
52+
- name: Check labels and define builder tag
53+
id: builder-tag
54+
if: |
55+
steps.changed.outputs.builder-changed == 'true' ||
56+
(github.event_name == 'push' && (
57+
github.ref_type == 'tag' || startsWith(github.ref_name, 'release-')
58+
)) ||
59+
contains(github.event.pull_request.labels.*.name, 'build-builder-image') ||
60+
github.event_name == 'schedule'
61+
run: |
62+
COLLECTOR_BUILDER_TAG="${DEFAULT_BUILDER_TAG}"
63+
if [[ "${{ github.event_name }}" == 'pull_request' || \
64+
"${{ github.ref_type }}" == 'tag' || \
65+
"${{ github.ref_name }}" =~ ^release- ]]; then
66+
COLLECTOR_BUILDER_TAG="${{ inputs.collector-tag }}"
67+
fi
68+
69+
echo "::notice::Rebuild builder image with tag ${COLLECTOR_BUILDER_TAG}"
70+
echo "collector-builder-tag=${COLLECTOR_BUILDER_TAG}" >> "$GITHUB_OUTPUT"
71+
echo "build-image=true" >> "$GITHUB_OUTPUT"
72+
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+
4178
build-builder-image:
42-
name: Build the builder image
43-
runs-on: ubuntu-24.04
79+
name: Local builder image
4480
# Multiarch builds sometimes take for eeeeeeeeeever
4581
timeout-minutes: 480
4682
needs:
4783
- builder-needs-rebuilding
4884
if: |
49-
needs.builder-needs-rebuilding.outputs.build-image == 'true' ||
50-
(github.event_name == 'push' && (
51-
github.ref_type == 'tag' || startsWith(github.ref_name, 'release-')
52-
)) ||
53-
contains(github.event.pull_request.labels.*.name, 'build-builder-image') ||
54-
github.event_name == 'schedule'
55-
outputs:
56-
collector-builder-tag: ${{ steps.builder-tag.outputs.collector-builder-tag }}
85+
needs.builder-needs-rebuilding.outputs.build-image == 'true'
5786
strategy:
58-
fail-fast: false
5987
matrix:
60-
arch: [amd64, ppc64le, s390x, arm64]
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' }}
6191

6292
env:
6393
PLATFORM: linux/${{ matrix.arch }}
6494
BUILD_TYPE: ci
95+
COLLECTOR_BUILDER_TAG: ${{ needs.builder-needs-rebuilding.outputs.collector-builder-tag }}
6596

6697
steps:
6798
- uses: actions/checkout@v4
@@ -76,6 +107,54 @@ jobs:
76107
- name: Set up Docker Buildx
77108
uses: docker/setup-buildx-action@v3
78109

110+
- name: Create ansible vars
111+
run: |
112+
cat << EOF > ${{ github.workspace }}/ansible/secrets.yml
113+
---
114+
stackrox_io_username: ${{ secrets.QUAY_STACKROX_IO_RW_USERNAME }}
115+
stackrox_io_password: ${{ secrets.QUAY_STACKROX_IO_RW_PASSWORD }}
116+
rhacs_eng_username: ${{ secrets.QUAY_RHACS_ENG_RW_USERNAME }}
117+
rhacs_eng_password: ${{ secrets.QUAY_RHACS_ENG_RW_PASSWORD }}
118+
collector_git_ref: ${{ github.ref }}
119+
collector_builder_tag: ${{ env.COLLECTOR_BUILDER_TAG }}
120+
EOF
121+
122+
- name: Build images
123+
timeout-minutes: 480
124+
run: |
125+
ansible-galaxy install -r ansible/requirements.yml
126+
ansible-playbook \
127+
--connection local \
128+
-i localhost, \
129+
--limit localhost \
130+
-e arch='${{ matrix.arch }}' \
131+
-e @'${{ github.workspace }}/ansible/secrets.yml' \
132+
ansible/ci-build-builder.yml
133+
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+
79158
- uses: actions/setup-python@v5
80159
with:
81160
python-version: "3.10"
@@ -101,57 +180,22 @@ jobs:
101180
job-tag: builder
102181

103182
- name: Create Build VMs
104-
if: |
105-
matrix.arch == 's390x' &&
106-
(github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'run-multiarch-builds'))
107183
run: |
108184
make -C "${{ github.workspace }}/ansible" create-build-vms
109185
110-
- name: Define builder tag
111-
id: builder-tag
112-
run: |
113-
COLLECTOR_BUILDER_TAG="${DEFAULT_BUILDER_TAG}"
114-
if [[ "${{ github.event_name }}" == 'pull_request' || \
115-
"${{ github.ref_type }}" == 'tag' || \
116-
"${{ github.ref_name }}" =~ ^release- ]]; then
117-
COLLECTOR_BUILDER_TAG="${{ inputs.collector-tag }}"
118-
fi
119-
120-
echo "COLLECTOR_BUILDER_TAG=${COLLECTOR_BUILDER_TAG}" >> "$GITHUB_ENV"
121-
echo "collector-builder-tag=${COLLECTOR_BUILDER_TAG}" >> "$GITHUB_OUTPUT"
122-
123186
- name: Create ansible vars
124187
run: |
125-
{
126-
echo "---"
127-
echo "stackrox_io_username: ${{ secrets.QUAY_STACKROX_IO_RW_USERNAME }}"
128-
echo "stackrox_io_password: ${{ secrets.QUAY_STACKROX_IO_RW_PASSWORD }}"
129-
echo "rhacs_eng_username: ${{ secrets.QUAY_RHACS_ENG_RW_USERNAME }}"
130-
echo "rhacs_eng_password: ${{ secrets.QUAY_RHACS_ENG_RW_PASSWORD }}"
131-
echo "collector_git_ref: ${{ github.ref }}"
132-
echo "collector_builder_tag: ${{ env.COLLECTOR_BUILDER_TAG }}"
133-
} > ${{ github.workspace }}/ansible/secrets.yml
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
134197
135198
- name: Build images
136-
if: |
137-
(github.event_name != 'pull_request' && matrix.arch != 's390x') ||
138-
matrix.arch == 'amd64' ||
139-
(contains(github.event.pull_request.labels.*.name, 'run-multiarch-builds') && matrix.arch != 's390x')
140-
timeout-minutes: 480
141-
run: |
142-
ansible-galaxy install -r ansible/requirements.yml
143-
ansible-playbook \
144-
--connection local \
145-
-i localhost, \
146-
--limit localhost \
147-
-e arch='${{ matrix.arch }}' \
148-
-e @'${{ github.workspace }}/ansible/secrets.yml' \
149-
ansible/ci-build-builder.yml
150-
151-
- name: Build s390x images
152-
if: |
153-
(github.event_name != 'pull_request' && matrix.arch == 's390x') ||
154-
(contains(github.event.pull_request.labels.*.name, 'run-multiarch-builds') && matrix.arch == 's390x')
155199
timeout-minutes: 480
156200
run: |
157201
ansible-playbook \
@@ -162,22 +206,23 @@ jobs:
162206
ansible/ci-build-builder.yml
163207
164208
- name: Destroy VMs
165-
if: always() && matrix.arch == 's390x'
209+
if: always()
166210
run: |
167211
make -C ansible destroy-vms
168212
169213
create-multiarch-manifest:
170214
needs:
215+
- builder-needs-rebuilding
171216
- build-builder-image
217+
- build-builder-image-remote-vm
172218
name: Create Multiarch manifest
173219
runs-on: ubuntu-24.04
174220
if: |
175-
github.event_name != 'pull_request' ||
176-
(needs.build-builder-image.outputs.collector-builder-tag != 'cache' &&
177-
contains(github.event.pull_request.labels.*.name, 'run-multiarch-builds'))
221+
always() && !contains(join(needs.*.result, ','), 'failure') &&
222+
needs.builder-needs-rebuilding.outputs.build-image == 'true'
178223
env:
179-
COLLECTOR_BUILDER_TAG: ${{ needs.build-builder-image.outputs.collector-builder-tag }}
180-
ARCHS: amd64 ppc64le s390x arm64
224+
COLLECTOR_BUILDER_TAG: ${{ needs.builder-needs-rebuilding.outputs.collector-builder-tag }}
225+
ARCHS: ${{ inputs.architectures }}
181226

182227
steps:
183228
- uses: actions/checkout@v4
@@ -208,45 +253,13 @@ jobs:
208253
base-image: quay.io/rhacs-eng/collector-builder:${{ env.COLLECTOR_BUILDER_TAG }}
209254
archs: ${{ env.ARCHS }}
210255

211-
retag-x86-image:
212-
needs:
213-
- build-builder-image
214-
name: Retag x86 builder image
215-
runs-on: ubuntu-24.04
216-
if: |
217-
github.event_name == 'pull_request' &&
218-
needs.build-builder-image.outputs.collector-builder-tag != 'cache' &&
219-
!contains(github.event.pull_request.labels.*.name, 'run-multiarch-builds')
220-
env:
221-
COLLECTOR_BUILDER_TAG: ${{ needs.build-builder-image.outputs.collector-builder-tag }}
222-
steps:
223-
- name: Pull image to retag
224-
run: |
225-
docker pull "quay.io/stackrox-io/collector-builder:${COLLECTOR_BUILDER_TAG}-amd64"
226-
227-
- name: Retag and push stackrox-io
228-
uses: stackrox/actions/images/retag-and-push@v1
229-
with:
230-
src-image: quay.io/stackrox-io/collector-builder:${{ env.COLLECTOR_BUILDER_TAG }}-amd64
231-
dst-image: quay.io/stackrox-io/collector-builder:${{ env.COLLECTOR_BUILDER_TAG }}
232-
username: ${{ secrets.QUAY_STACKROX_IO_RW_USERNAME }}
233-
password: ${{ secrets.QUAY_STACKROX_IO_RW_PASSWORD }}
234-
235-
- name: Retag and push rhacs-eng
236-
uses: stackrox/actions/images/retag-and-push@v1
237-
with:
238-
src-image: quay.io/stackrox-io/collector-builder:${{ env.COLLECTOR_BUILDER_TAG }}-amd64
239-
dst-image: quay.io/rhacs-eng/collector-builder:${{ env.COLLECTOR_BUILDER_TAG }}
240-
username: ${{ secrets.QUAY_RHACS_ENG_RW_USERNAME }}
241-
password: ${{ secrets.QUAY_RHACS_ENG_RW_PASSWORD }}
242-
243256
notify:
244257
runs-on: ubuntu-24.04
245258
if: always() && contains(join(needs.*.result, ','), 'failure') && github.event_name != 'pull_request'
246259
needs:
247260
- build-builder-image
261+
- build-builder-image-remote-vm
248262
- create-multiarch-manifest
249-
- retag-x86-image
250263
steps:
251264
- name: Slack notification
252265
uses: rtCamp/action-slack-notify@v2

0 commit comments

Comments
 (0)