Skip to content

Commit 9dda2df

Browse files
authored
Centralise duplicated matrix configurations (#1284)
GitHub Actions use matrixes' to execute builds with variations - e.g. different compiler configurations. These configurations are duplicated for each platform - and instead should be centralised. [Example execution](https://github.com/hazelcast/hazelcast-cpp-client/actions/runs/15159198974).
1 parent a27b03e commit 9dda2df

File tree

6 files changed

+93
-136
lines changed

6 files changed

+93
-136
lines changed

.github/workflows/build-pr.yml

Lines changed: 33 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -115,26 +115,19 @@ jobs:
115115
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
116116
HZ_TEST_AWS_INSTANCE_PRIVATE_IP: ${{ secrets.HZ_TEST_AWS_INSTANCE_PRIVATE_IP }}
117117

118+
shared-matrix:
119+
uses: ./.github/workflows/get-shared-matrix.yml
120+
118121
Ubuntu-i386:
119-
needs: get-refs
122+
needs:
123+
- get-refs
124+
- shared-matrix
120125
strategy:
121126
fail-fast: false
122127
matrix:
123-
build_type:
124-
- Debug
125-
- Release
126-
127-
shared_libs:
128-
- toggle: OFF
129-
name: Static
130-
- toggle: ON
131-
name: Shared
132-
133-
with_openssl:
134-
- toggle: OFF
135-
name: 'noSSL'
136-
- toggle: ON
137-
name: 'SSL'
128+
build_type: ${{ fromJSON(needs.shared-matrix.outputs.build-type) }}
129+
shared_libs: ${{ fromJSON(needs.shared-matrix.outputs.shared-libs) }}
130+
with_openssl: ${{ fromJSON(needs.shared-matrix.outputs.openssl) }}
138131

139132
runs-on: ubuntu-latest
140133
container:
@@ -167,26 +160,15 @@ jobs:
167160

168161

169162
Ubuntu-x86_64:
170-
needs: get-refs
163+
needs:
164+
- get-refs
165+
- shared-matrix
171166
strategy:
172167
fail-fast: false
173168
matrix:
174-
175-
build_type:
176-
- Debug
177-
- Release
178-
179-
shared_libs:
180-
- toggle: OFF
181-
name: Static
182-
- toggle: ON
183-
name: Shared
184-
185-
with_openssl:
186-
- toggle: OFF
187-
name: noSSL
188-
- toggle: ON
189-
name: SSL
169+
build_type: ${{ fromJSON(needs.shared-matrix.outputs.build-type) }}
170+
shared_libs: ${{ fromJSON(needs.shared-matrix.outputs.shared-libs) }}
171+
with_openssl: ${{ fromJSON(needs.shared-matrix.outputs.openssl) }}
190172

191173
runs-on: ubuntu-latest
192174

@@ -213,35 +195,21 @@ jobs:
213195
HZ_TEST_AWS_INSTANCE_PRIVATE_IP: ${{ secrets.HZ_TEST_AWS_INSTANCE_PRIVATE_IP }}
214196

215197
Windows:
216-
needs: get-refs
198+
needs:
199+
- get-refs
200+
- shared-matrix
217201
strategy:
218202
fail-fast: false
219203
matrix:
220-
arch:
221-
- cmake: Win32
222-
choco_options: '--forceX86 --x86 --version 1.1.1.2100 -y'
223-
address_model: 32
224-
- cmake: x64
225-
choco_options: ''
226-
address_model: 64
227-
build_type:
228-
- Debug
229-
- Release
230-
shared_libs:
231-
- toggle: OFF
232-
name: Static
233-
- toggle: ON
234-
name: Shared
235-
with_openssl:
236-
- toggle: OFF
237-
name: 'noSSL'
238-
- toggle: ON
239-
name: 'SSL'
204+
options: ${{ fromJSON(needs.shared-matrix.outputs.windows-options) }}
205+
build_type: ${{ fromJSON(needs.shared-matrix.outputs.build-type) }}
206+
shared_libs: ${{ fromJSON(needs.shared-matrix.outputs.shared-libs) }}
207+
with_openssl: ${{ fromJSON(needs.shared-matrix.outputs.openssl) }}
240208

241209
runs-on: 'windows-latest'
242210
env:
243-
JOB_NAME: win_${{ matrix.arch.address_model }}_${{ matrix.build_type.short }}_${{ matrix.shared_libs.name }}_${{ matrix.with_openssl.name }}
244-
name: win-${{ matrix.arch.address_model }}_${{ matrix.shared_libs.name }}_${{ matrix.with_openssl.name }}
211+
JOB_NAME: win_${{ matrix.options.address_model }}_${{ matrix.build_type.short }}_${{ matrix.shared_libs.name }}_${{ matrix.with_openssl.name }}
212+
name: win-${{ matrix.options.address_model }}_${{ matrix.shared_libs.name }}_${{ matrix.with_openssl.name }}
245213
steps:
246214
- uses: actions/checkout@v4
247215
with:
@@ -256,9 +224,9 @@ jobs:
256224
BUILD_TYPE: ${{ matrix.build_type }}
257225
SHARED_LIBS_TOGGLE: ${{ matrix.shared_libs.toggle }}
258226
OPENSSL_TOGGLE: ${{ matrix.with_openssl.toggle }}
259-
ARCH_CHOCO_OPTIONS: ${{ matrix.arch.choco_options }}
260-
ARCH_ADDRESS_MODEL: ${{ matrix.arch.address_model }}
261-
ARCH_CMAKE: ${{ matrix.arch.cmake }}
227+
ARCH_CHOCO_OPTIONS: ${{ matrix.options.choco_options }}
228+
ARCH_ADDRESS_MODEL: ${{ matrix.options.address_model }}
229+
ARCH_CMAKE: ${{ matrix.options.cmake }}
262230
INSTALL_BOOST: true
263231
BOOST_URL: ${{ env.boost_url }}
264232
BOOST_ARCHIVE_NAME: ${{ env.boost_archive_name }}
@@ -272,25 +240,15 @@ jobs:
272240
HZ_TEST_AWS_INSTANCE_PRIVATE_IP: ${{ secrets.HZ_TEST_AWS_INSTANCE_PRIVATE_IP }}
273241

274242
macOS-x86_64:
275-
needs: get-refs
243+
needs:
244+
- get-refs
245+
- shared-matrix
276246
strategy:
277247
fail-fast: false
278248
matrix:
279-
build_type:
280-
- Debug
281-
- Release
282-
283-
shared_libs:
284-
- toggle: OFF
285-
name: Static
286-
- toggle: ON
287-
name: Shared
288-
289-
with_openssl:
290-
- toggle: OFF
291-
name: 'noSSL'
292-
- toggle: ON
293-
name: 'SSL'
249+
build_type: ${{ fromJSON(needs.shared-matrix.outputs.build-type) }}
250+
shared_libs: ${{ fromJSON(needs.shared-matrix.outputs.shared-libs) }}
251+
with_openssl: ${{ fromJSON(needs.shared-matrix.outputs.openssl) }}
294252

295253
runs-on: macos-latest
296254

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Get common matrix configuration
2+
3+
on:
4+
workflow_call:
5+
outputs:
6+
build-type:
7+
value: ${{ jobs.get-configurations.outputs.build-type }}
8+
shared-libs:
9+
value: ${{ jobs.get-configurations.outputs.shared-libs }}
10+
openssl:
11+
value: ${{ jobs.get-configurations.outputs.openssl }}
12+
windows-options:
13+
value: ${{ jobs.get-configurations.outputs.windows-options }}
14+
15+
jobs:
16+
get-configurations:
17+
runs-on: ubuntu-latest
18+
outputs:
19+
build-type: "['Debug', 'Release']"
20+
shared-libs: "[{'toggle': 'OFF', 'name': 'Static'}, {'toggle': 'ON', 'name': 'Shared'}]"
21+
openssl: "[{'toggle': 'OFF', 'name': 'noSSL'}, {'toggle': 'ON', 'name': 'SSL'}]"
22+
windows-options: "[{'cmake': 'Win32', 'choco_options': '--forceX86 --x86 --version 1.1.1.2100 -y', 'address_model': '32'}, {'cmake': 'x64', 'choco_options': '', 'address_model': '64'}]"
23+
steps:
24+
- run: exit 0

.github/workflows/nightly-macos-x86_64.yml

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,29 +11,20 @@ on:
1111
- cron: '0 0 * * *'
1212

1313
jobs:
14+
shared-matrix:
15+
uses: ./.github/workflows/get-shared-matrix.yml
16+
1417
nightly-macOS-x86_64:
18+
needs: shared-matrix
1519
strategy:
1620
fail-fast: false
1721
matrix:
1822
boost:
1923
- version: 1.71.0
2024
- version: 1.76.0
21-
22-
build_type:
23-
- Debug
24-
- Release
25-
26-
shared_libs:
27-
- toggle: OFF
28-
name: Static
29-
- toggle: ON
30-
name: Shared
31-
32-
with_openssl:
33-
- toggle: OFF
34-
name: 'noSSL'
35-
- toggle: ON
36-
name: 'SSL'
25+
build_type: ${{ fromJSON(needs.shared-matrix.outputs.build-type) }}
26+
shared_libs: ${{ fromJSON(needs.shared-matrix.outputs.shared-libs) }}
27+
with_openssl: ${{ fromJSON(needs.shared-matrix.outputs.openssl) }}
3728

3829
runs-on: macos-latest
3930

.github/workflows/nightly-ubuntu-i386.yml

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,20 @@ on:
1111
- cron: '0 22 * * *'
1212

1313
jobs:
14+
shared-matrix:
15+
uses: ./.github/workflows/get-shared-matrix.yml
16+
1417
nightly-Ubuntu-i386:
18+
needs: shared-matrix
1519
strategy:
1620
fail-fast: false
1721
matrix:
1822
boost:
1923
- version: 1.71.0
2024
- version: 1.76.0
21-
build_type:
22-
- Debug
23-
- Release
24-
25-
shared_libs:
26-
- toggle: OFF
27-
name: Static
28-
- toggle: ON
29-
name: Shared
30-
31-
with_openssl:
32-
- toggle: OFF
33-
name: 'noSSL'
34-
- toggle: ON
35-
name: 'SSL'
25+
build_type: ${{ fromJSON(needs.shared-matrix.outputs.build-type) }}
26+
shared_libs: ${{ fromJSON(needs.shared-matrix.outputs.shared-libs) }}
27+
with_openssl: ${{ fromJSON(needs.shared-matrix.outputs.openssl) }}
3628

3729
runs-on: ubuntu-latest
3830
container:

.github/workflows/nightly-ubuntu-x86_64.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@ on:
1111
- cron: '0 20 * * *'
1212

1313
jobs:
14+
shared-matrix:
15+
uses: ./.github/workflows/get-shared-matrix.yml
16+
1417
nightly-Ubuntu-x86_64:
18+
needs: shared-matrix
1519
strategy:
1620
fail-fast: false
1721
matrix:

.github/workflows/nightly-windows.yml

Lines changed: 18 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@ on:
1111
- cron: '0 2 * * *'
1212

1313
jobs:
14+
shared-matrix:
15+
uses: ./.github/workflows/get-shared-matrix.yml
16+
1417
nightly-Windows:
18+
needs: shared-matrix
1519
strategy:
1620
fail-fast: false
1721
matrix:
@@ -46,33 +50,17 @@ jobs:
4650
boost_archive_name: 'boost_1_80_0.tar.gz'
4751
boost_folder_name: 'boost_1_80_0'
4852
boost_include_folder: 'C:\Boost\include\boost-1_80'
49-
arch:
50-
- cmake: Win32
51-
choco_options: '--forceX86 --x86 --version 1.1.1.2100 -y'
52-
address_model: 32
53-
- cmake: x64
54-
choco_options: ''
55-
address_model: 64
56-
build_type:
57-
- Debug
58-
- Release
59-
shared_libs:
60-
- toggle: OFF
61-
name: Static
62-
- toggle: ON
63-
name: Shared
64-
with_openssl:
65-
- toggle: OFF
66-
name: 'noSSL'
67-
- toggle: ON
68-
name: 'SSL'
53+
arch: ${{ fromJSON(needs.shared-matrix.outputs.windows-options) }}
54+
build_type: ${{ fromJSON(needs.shared-matrix.outputs.build-type) }}
55+
shared_libs: ${{ fromJSON(needs.shared-matrix.outputs.shared-libs) }}
56+
with_openssl: ${{ fromJSON(needs.shared-matrix.outputs.openssl) }}
6957

7058
runs-on: ${{ matrix.vc_boost.image }}
7159
env:
72-
JOB_NAME: Windows_(${{ matrix.vc_boost.name }},${{ matrix.arch.address_model }},${{ matrix.build_type }},${{ matrix.shared_libs.name }}, ${{ matrix.with_openssl.name }})
60+
JOB_NAME: Windows_(${{ matrix.vc_boost.name }},${{ matrix.options.address_model }},${{ matrix.build_type }},${{ matrix.shared_libs.name }}, ${{ matrix.with_openssl.name }})
7361
name: >-
7462
Windows
75-
(${{ matrix.vc_boost.name }}, ${{ matrix.arch.address_model }}, ${{ matrix.build_type }}, ${{ matrix.shared_libs.name }}, ${{ matrix.with_openssl.name }})
63+
(${{ matrix.vc_boost.name }}, ${{ matrix.options.address_model }}, ${{ matrix.build_type }}, ${{ matrix.shared_libs.name }}, ${{ matrix.with_openssl.name }})
7664
7765
steps:
7866
- uses: actions/checkout@v4
@@ -82,18 +70,18 @@ jobs:
8270
uses: actions/cache@v4
8371
with:
8472
path: C:\Boost
85-
key: ${{ matrix.vc_boost.name }}-${{ matrix.arch.address_model }}-${{ matrix.build_type }}
73+
key: ${{ matrix.vc_boost.name }}-${{ matrix.options.address_model }}-${{ matrix.build_type }}
8674
restore-keys: |
87-
${{ matrix.vc_boost.name }}-${{ matrix.arch.address_model }}-${{ matrix.build_type }}
75+
${{ matrix.vc_boost.name }}-${{ matrix.options.address_model }}-${{ matrix.build_type }}
8876
8977
- name: Cache Thrift Version
9078
id: cache-thrift
9179
uses: actions/cache@v4
9280
with:
9381
path: C:\Thrift
94-
key: ${{ matrix.vc_boost.image }}-${{ matrix.arch.address_model }}-thrift-0.13-${{ matrix.build_type }}
82+
key: ${{ matrix.vc_boost.image }}-${{ matrix.options.address_model }}-thrift-0.13-${{ matrix.build_type }}
9583
restore-keys: |
96-
${{ matrix.vc_boost.image }}-${{ matrix.arch.address_model }}-thrift-0.13-${{ matrix.build_type }}
84+
${{ matrix.vc_boost.image }}-${{ matrix.options.address_model }}-thrift-0.13-${{ matrix.build_type }}
9785
9886
- uses: ./.github/actions/build-test/windows
9987
with:
@@ -103,9 +91,9 @@ jobs:
10391
BUILD_TYPE: ${{ matrix.build_type }}
10492
SHARED_LIBS_TOGGLE: ${{ matrix.shared_libs.toggle }}
10593
OPENSSL_TOGGLE: ${{ matrix.with_openssl.toggle }}
106-
ARCH_CHOCO_OPTIONS: ${{ matrix.arch.choco_options }}
107-
ARCH_ADDRESS_MODEL: ${{ matrix.arch.address_model }}
108-
ARCH_CMAKE: ${{ matrix.arch.cmake }}
94+
ARCH_CHOCO_OPTIONS: ${{ matrix.options.choco_options }}
95+
ARCH_ADDRESS_MODEL: ${{ matrix.options.address_model }}
96+
ARCH_CMAKE: ${{ matrix.options.cmake }}
10997
INSTALL_BOOST: ${{ steps.cache-boost.outputs.cache-hit != 'true' }}
11098
BOOST_URL: ${{ matrix.vc_boost.boost_url }}
11199
BOOST_ARCHIVE_NAME: ${{ matrix.vc_boost.boost_archive_name }}
@@ -121,7 +109,7 @@ jobs:
121109
- name: Verify Installation
122110
run: |
123111
cmake -S .\examples -B build-examples `
124-
-A ${{ matrix.arch.cmake }} `
112+
-A ${{ matrix.options.cmake }} `
125113
-DCMAKE_CONFIGURATION_TYPES=${{ matrix.build_type }} `
126114
-DCMAKE_PREFIX_PATH="C:\Boost;${{ github.workspace }}\destination" `
127115
-DWITH_OPENSSL=${{ matrix.with_openssl.toggle }}

0 commit comments

Comments
 (0)