Skip to content

Commit 97d0158

Browse files
committed
X-Smart-Squash: Squashed 18 commits:
1179d57 Squash 835342e rn 8430368 update f54326c unit e9fc780 merge builder 9515346 split d7b2d89 workflow 19f9fc9 update f220584 always 1af882d unit 6a5d9a7 comment a22a493 unit 9424110 unit 83bb60f enable builder 4c01e09 arch 4f0df21 clean d07cefc arch 50aec13c9 typo
1 parent 2813005 commit 97d0158

File tree

7 files changed

+152
-150
lines changed

7 files changed

+152
-150
lines changed

.github/workflows/collector-builder.yml

+19-50
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ on:
88
required: true
99
description: |
1010
The tag used to build the collector image
11+
include-arch-json:
12+
type: string
13+
required: true
14+
description: |
15+
JSON for matrix.include to select architectures and runners to build
1116
outputs:
1217
collector-builder-tag:
1318
description: The builder tag used by the build
@@ -40,7 +45,6 @@ jobs:
4045
4146
build-builder-image:
4247
name: Build the builder image
43-
runs-on: ubuntu-24.04
4448
# Multiarch builds sometimes take for eeeeeeeeeever
4549
timeout-minutes: 480
4650
needs:
@@ -55,9 +59,9 @@ jobs:
5559
outputs:
5660
collector-builder-tag: ${{ steps.builder-tag.outputs.collector-builder-tag }}
5761
strategy:
58-
fail-fast: false
5962
matrix:
60-
arch: [amd64, ppc64le, s390x, arm64]
63+
include: ${{ fromJSON(inputs.include-arch-json) }}
64+
runs-on: ${{ matrix.runner }}
6165

6266
env:
6367
PLATFORM: linux/${{ matrix.arch }}
@@ -69,24 +73,30 @@ jobs:
6973
submodules: true
7074

7175
- name: Set up QEMU
76+
if: matrix.remote != true
7277
uses: docker/setup-qemu-action@v3
7378
with:
7479
image: tonistiigi/binfmt:qemu-v8.1.5
7580

7681
- name: Set up Docker Buildx
82+
if: matrix.remote != true
7783
uses: docker/setup-buildx-action@v3
7884

7985
- uses: actions/setup-python@v5
86+
if: matrix.remote
8087
with:
8188
python-version: "3.10"
8289

8390
- uses: 'google-github-actions/auth@v2'
91+
if: matrix.remote
8492
with:
8593
credentials_json: '${{ secrets.GOOGLE_CREDENTIALS_COLLECTOR_SVC_ACCT }}'
8694

8795
- uses: 'google-github-actions/setup-gcloud@v2'
96+
if: matrix.remote
8897

8998
- uses: ./.github/actions/setup-vm-creds
99+
if: matrix.remote
90100
with:
91101
gcp-ssh-key: ${{ secrets.GCP_SSH_KEY }}
92102
gcp-ssh-key-pub: ${{ secrets.GCP_SSH_KEY_PUB }}
@@ -101,9 +111,7 @@ jobs:
101111
job-tag: builder
102112

103113
- 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'))
114+
if: matrix.remote
107115
run: |
108116
make -C "${{ github.workspace }}/ansible" create-build-vms
109117
@@ -133,10 +141,7 @@ jobs:
133141
} > ${{ github.workspace }}/ansible/secrets.yml
134142
135143
- 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')
144+
if: matrix.remote != true
140145
timeout-minutes: 480
141146
run: |
142147
ansible-galaxy install -r ansible/requirements.yml
@@ -149,9 +154,7 @@ jobs:
149154
ansible/ci-build-builder.yml
150155
151156
- 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')
157+
if: matrix.remote
155158
timeout-minutes: 480
156159
run: |
157160
ansible-playbook \
@@ -162,7 +165,7 @@ jobs:
162165
ansible/ci-build-builder.yml
163166
164167
- name: Destroy VMs
165-
if: always() && matrix.arch == 's390x'
168+
if: always() && matrix.remote
166169
run: |
167170
make -C ansible destroy-vms
168171
@@ -173,11 +176,10 @@ jobs:
173176
runs-on: ubuntu-24.04
174177
if: |
175178
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'))
179+
needs.build-builder-image.outputs.collector-builder-tag != 'cache'
178180
env:
179181
COLLECTOR_BUILDER_TAG: ${{ needs.build-builder-image.outputs.collector-builder-tag }}
180-
ARCHS: amd64 ppc64le s390x arm64
182+
ARCHS: ${{ join(fromJSON(inputs.include-arch-json).*.arch, ' ') }}
181183

182184
steps:
183185
- uses: actions/checkout@v4
@@ -208,45 +210,12 @@ jobs:
208210
base-image: quay.io/rhacs-eng/collector-builder:${{ env.COLLECTOR_BUILDER_TAG }}
209211
archs: ${{ env.ARCHS }}
210212

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-
243213
notify:
244214
runs-on: ubuntu-24.04
245215
if: always() && contains(join(needs.*.result, ','), 'failure') && github.event_name != 'pull_request'
246216
needs:
247217
- build-builder-image
248218
- create-multiarch-manifest
249-
- retag-x86-image
250219
steps:
251220
- name: Slack notification
252221
uses: rtCamp/action-slack-notify@v2

.github/workflows/collector.yml

+22-79
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ on:
1818
required: true
1919
description: |
2020
The builder tag to use in the build
21+
include-arch-json:
22+
type: string
23+
required: true
24+
description: |
25+
JSON for matrix.include to select architectures and runners to build
2126
2227
env:
2328
COLLECTOR_TAG: ${{ inputs.collector-tag }}
@@ -30,11 +35,10 @@ env:
3035
jobs:
3136
build-collector-image:
3237
name: Build Collector
33-
runs-on: ubuntu-24.04
3438
strategy:
35-
fail-fast: false
3639
matrix:
37-
arch: [amd64, ppc64le, arm64]
40+
include: ${{ fromJSON(inputs.include-arch-json) }}
41+
runs-on: ${{ matrix.runner }}
3842

3943
env:
4044
PLATFORM: linux/${{ matrix.arch }}
@@ -46,11 +50,13 @@ jobs:
4650
submodules: true
4751

4852
- name: Set up QEMU
53+
if: matrix.remote != true
4954
uses: docker/setup-qemu-action@v3
5055
with:
5156
image: tonistiigi/binfmt:qemu-v8.1.5
5257

5358
- name: Set up Docker Buildx
59+
if: matrix.remote != true
5460
uses: docker/setup-buildx-action@v3
5561

5662
- name: Create ansible vars
@@ -62,6 +68,7 @@ jobs:
6268
rhacs_eng_username: ${{ secrets.QUAY_RHACS_ENG_RW_USERNAME }}
6369
rhacs_eng_password: ${{ secrets.QUAY_RHACS_ENG_RW_PASSWORD }}
6470
collector_git_ref: ${{ github.ref }}
71+
collector_git_sha: ${{ github.sha }}
6572
collector_builder_tag: ${{ env.COLLECTOR_BUILDER_TAG }}
6673
disable_profiling: ${{ matrix.arch != 'amd64' && matrix.arch != 'arm64' }}
6774
rhacs_eng_image: ${{ env.RHACS_ENG_IMAGE }}
@@ -71,11 +78,8 @@ jobs:
7178
driver_version: ${DRIVER_VERSION}
7279
EOF
7380
74-
- name: Build images
75-
if: |
76-
github.event_name != 'pull_request' ||
77-
matrix.arch == 'amd64' ||
78-
contains(github.event.pull_request.labels.*.name, 'run-multiarch-builds')
81+
- name: Build ${{ matrix.arch }} image locally
82+
if: matrix.remote != true
7983
timeout-minutes: 480
8084
run: |
8185
ansible-playbook \
@@ -86,32 +90,21 @@ jobs:
8690
-e @'${{ github.workspace }}/ansible/secrets.yml' \
8791
ansible/ci-build-collector.yml
8892
89-
build-collector-image-remote-vm:
90-
name: Build Collector on a remote VM
91-
runs-on: ubuntu-24.04
92-
if: github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'run-multiarch-builds')
93-
strategy:
94-
fail-fast: false
95-
matrix:
96-
arch: [s390x]
97-
98-
env:
99-
PLATFORM: linux/${{ matrix.arch }}
100-
101-
steps:
102-
- uses: actions/checkout@v4
103-
10493
- uses: actions/setup-python@v5
94+
if: matrix.remote
10595
with:
10696
python-version: "3.10"
10797

10898
- uses: 'google-github-actions/auth@v2'
99+
if: matrix.remote
109100
with:
110101
credentials_json: '${{ secrets.GOOGLE_CREDENTIALS_COLLECTOR_SVC_ACCT }}'
111102

112103
- uses: 'google-github-actions/setup-gcloud@v2'
104+
if: matrix.remote
113105

114106
- uses: ./.github/actions/setup-vm-creds
107+
if: matrix.remote
115108
with:
116109
gcp-ssh-key: ${{ secrets.GCP_SSH_KEY }}
117110
gcp-ssh-key-pub: ${{ secrets.GCP_SSH_KEY_PUB }}
@@ -126,28 +119,12 @@ jobs:
126119
job-tag: builder
127120

128121
- name: Create Build VMs
122+
if: matrix.remote
129123
run: |
130124
make -C "${{ github.workspace }}/ansible" create-build-vms
131125
132-
- name: Create ansible vars
133-
run: |
134-
cat << EOF > ${{ github.workspace }}/ansible/secrets.yml
135-
---
136-
stackrox_io_username: ${{ secrets.QUAY_STACKROX_IO_RW_USERNAME }}
137-
stackrox_io_password: ${{ secrets.QUAY_STACKROX_IO_RW_PASSWORD }}
138-
rhacs_eng_username: ${{ secrets.QUAY_RHACS_ENG_RW_USERNAME }}
139-
rhacs_eng_password: ${{ secrets.QUAY_RHACS_ENG_RW_PASSWORD }}
140-
collector_git_ref: ${{ github.ref }}
141-
collector_git_sha: ${{ github.sha }}
142-
collector_builder_tag: ${{ env.COLLECTOR_BUILDER_TAG }}
143-
disable_profiling: ${{ matrix.arch != 'amd64' && matrix.arch != 'arm64' }}
144-
rhacs_eng_image: ${{ env.RHACS_ENG_IMAGE }}
145-
collector_image: ${{ inputs.collector-image }}
146-
collector_tag: ${{ inputs.collector-tag }}
147-
debug_mode: ${{ github.event_name == 'pull_request' }}
148-
EOF
149-
150-
- name: Build ${{ matrix.arch }} image
126+
- name: Build ${{ matrix.arch }} image remotely
127+
if: matrix.remote
151128
timeout-minutes: 480
152129
run: |
153130
ansible-playbook \
@@ -158,21 +135,18 @@ jobs:
158135
ansible/ci-build-collector.yml
159136
160137
- name: Destroy Build VMs
161-
if: always()
138+
if: always() && matrix.remote
162139
run: |
163140
make -C ansible destroy-vms
164141
165142
create-multiarch-manifest:
166143
needs:
167144
- build-collector-image
168-
- build-collector-image-remote-vm
169145
name: Create Multiarch manifest
170146
runs-on: ubuntu-24.04
171-
if: |
172-
github.event_name != 'pull_request' ||
173-
contains(github.event.pull_request.labels.*.name, 'run-multiarch-builds')
147+
if: always() && !contains(join(needs.*.result, ','), 'failure')
174148
env:
175-
ARCHS: amd64 ppc64le s390x arm64
149+
ARCHS: ${{ join(fromJSON(inputs.include-arch-json).*.arch, ' ') }}
176150

177151
steps:
178152
- uses: actions/checkout@v4
@@ -203,43 +177,12 @@ jobs:
203177
base-image: quay.io/rhacs-eng/collector:${{ inputs.collector-tag }}
204178
archs: ${{ env.ARCHS }}
205179

206-
retag-x86-image:
207-
needs:
208-
- build-collector-image
209-
name: Retag x86 image
210-
runs-on: ubuntu-24.04
211-
if: |
212-
github.event_name == 'pull_request' &&
213-
!contains(github.event.pull_request.labels.*.name, 'run-multiarch-builds')
214-
steps:
215-
- name: Pull image to retag
216-
run: |
217-
docker pull ${{ inputs.collector-image }}-amd64
218-
219-
- name: Retag and push stackrox-io
220-
uses: stackrox/actions/images/retag-and-push@v1
221-
with:
222-
src-image: ${{ inputs.collector-image }}-amd64
223-
dst-image: ${{ inputs.collector-image }}
224-
username: ${{ secrets.QUAY_STACKROX_IO_RW_USERNAME }}
225-
password: ${{ secrets.QUAY_STACKROX_IO_RW_PASSWORD }}
226-
227-
- name: Retag and push rhacs-eng
228-
uses: stackrox/actions/images/retag-and-push@v1
229-
with:
230-
src-image: ${{ inputs.collector-image }}-amd64
231-
dst-image: ${{ env.RHACS_ENG_IMAGE }}
232-
username: ${{ secrets.QUAY_RHACS_ENG_RW_USERNAME }}
233-
password: ${{ secrets.QUAY_RHACS_ENG_RW_PASSWORD }}
234-
235180
notify:
236181
runs-on: ubuntu-24.04
237182
if: always() && contains(join(needs.*.result, ','), 'failure') && github.event_name != 'pull_request'
238183
needs:
239184
- build-collector-image
240-
- build-collector-image-remote-vm
241185
- create-multiarch-manifest
242-
- retag-x86-image
243186
steps:
244187
- name: Slack notification
245188
uses: rtCamp/action-slack-notify@v2

0 commit comments

Comments
 (0)