Skip to content

Commit e12873c

Browse files
authored
CI using shared workflow to generate matrix (#3549)
1 parent cbc9336 commit e12873c

File tree

4 files changed

+68
-166
lines changed

4 files changed

+68
-166
lines changed

.github/workflows/ci.yml

Lines changed: 18 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -41,45 +41,32 @@ on:
4141
workflow_dispatch:
4242

4343
jobs:
44+
matrix_config:
45+
uses: ./.github/workflows/matrix_config.yml
46+
4447
build:
48+
needs: matrix_config
49+
4550
strategy:
4651
fail-fast: false
47-
max-parallel: 20
48-
matrix:
49-
target:
50-
- os: linux
51-
cpu: amd64
52-
- os: windows
53-
cpu: amd64
54-
- os: macos
55-
cpu: arm64
56-
include:
57-
- target:
58-
os: linux
59-
builder: ubuntu-22.04
60-
- target:
61-
os: macos
62-
builder: macos-13
63-
- target:
64-
os: windows
65-
builder: windows-latest
52+
matrix: ${{ fromJSON(needs.matrix_config.outputs.matrix) }}
6653

6754
defaults:
6855
run:
6956
shell: bash
7057

71-
name: '${{ matrix.target.os }}-${{ matrix.target.cpu }}'
58+
name: '${{ matrix.os }}-${{ matrix.cpu }}'
7259
runs-on: ${{ matrix.builder }}
7360
steps:
7461
- name: Checkout nimbus-eth1
7562
uses: actions/checkout@v4
7663

7764
- name: Derive environment variables
7865
run: |
79-
if [[ '${{ matrix.target.cpu }}' == 'amd64' ]]; then
66+
if [[ '${{ matrix.cpu }}' == 'amd64' ]]; then
8067
PLATFORM=x64
8168
GOARCH=amd64
82-
elif [[ '${{ matrix.target.cpu }}' == 'arm64' ]]; then
69+
elif [[ '${{ matrix.cpu }}' == 'arm64' ]]; then
8370
PLATFORM=arm64
8471
GOARCH=arm64
8572
else
@@ -128,8 +115,8 @@ jobs:
128115
id: windows-mingw-cache
129116
uses: actions/cache@v4
130117
with:
131-
path: external/mingw-${{ matrix.target.cpu }}
132-
key: 'mingw-llvm-17-${{ matrix.target.cpu }}'
118+
path: external/mingw-${{ matrix.cpu }}
119+
key: 'mingw-llvm-17-${{ matrix.cpu }}'
133120

134121
- name: Install llvm-mingw dependency (Windows)
135122
if: >
@@ -139,22 +126,22 @@ jobs:
139126
mkdir -p external
140127
LLVM_VERSION="20250730"
141128
MINGW_BASE="https://github.com/mstorsjo/llvm-mingw/releases/download/$LLVM_VERSION"
142-
if [[ '${{ matrix.target.cpu }}' == 'amd64' ]]; then
129+
if [[ '${{ matrix.cpu }}' == 'amd64' ]]; then
143130
MINGW_URL="$MINGW_BASE/llvm-mingw-$LLVM_VERSION-ucrt-x86_64.zip"
144131
ARCH=64
145132
else
146133
MINGW_URL="$MINGW_BASE/llvm-mingw-$LLVM_VERSION-ucrt-i686.zip"
147134
ARCH=32
148135
fi
149-
curl -L "$MINGW_URL" -o "external/mingw-${{ matrix.target.cpu }}.zip"
150-
7z x -y "external/mingw-${{ matrix.target.cpu }}.zip" -oexternal/mingw-${{ matrix.target.cpu }}/
151-
mv external/mingw-${{ matrix.target.cpu }}/**/* ./external/mingw-${{ matrix.target.cpu }}
136+
curl -L "$MINGW_URL" -o "external/mingw-${{ matrix.cpu }}.zip"
137+
7z x -y "external/mingw-${{ matrix.cpu }}.zip" -oexternal/mingw-${{ matrix.cpu }}/
138+
mv external/mingw-${{ matrix.cpu }}/**/* ./external/mingw-${{ matrix.cpu }}
152139
153140
- name: Path to cached dependencies (Windows)
154141
if: >
155142
runner.os == 'Windows'
156143
run: |
157-
echo '${{ github.workspace }}'"/external/mingw-${{ matrix.target.cpu }}/bin" >> $GITHUB_PATH
144+
echo '${{ github.workspace }}'"/external/mingw-${{ matrix.cpu }}/bin" >> $GITHUB_PATH
158145
159146
- name: Get latest nimbus-build-system commit hash
160147
id: versions
@@ -170,7 +157,7 @@ jobs:
170157
uses: actions/cache@v4
171158
with:
172159
path: NimBinCache
173-
key: 'nim-${{ matrix.target.os }}-${{ matrix.target.cpu }}-${{ steps.versions.outputs.nimbus_build_system }}'
160+
key: 'nim-${{ matrix.os }}-${{ matrix.cpu }}-${{ steps.versions.outputs.nimbus_build_system }}'
174161

175162
- name: Get latest nim-rocksdb commit hash
176163
id: rocksdb-versions
@@ -186,7 +173,7 @@ jobs:
186173
uses: actions/cache@v4
187174
with:
188175
path: RocksBinCache
189-
key: 'rocks-${{ matrix.target.os }}-${{ matrix.target.cpu }}-${{ steps.rocksdb-versions.outputs.nim_rocksdb }}'
176+
key: 'rocks-${{ matrix.os }}-${{ matrix.cpu }}-${{ steps.rocksdb-versions.outputs.nim_rocksdb }}'
190177

191178
- name: Build Nim and Nimbus-eth1 dependencies
192179
run: |

.github/workflows/nimbus_verified_proxy.yml

Lines changed: 18 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -33,54 +33,39 @@ on:
3333
- 'nimbus.nimble'
3434

3535
jobs:
36+
matrix_config:
37+
uses: ./.github/workflows/matrix_config.yml
38+
3639
build:
40+
needs: matrix_config
41+
3742
strategy:
3843
fail-fast: false
39-
max-parallel: 20
40-
matrix:
41-
target:
42-
- os: linux
43-
cpu: amd64
44-
# - os: linux
45-
# cpu: i386
46-
- os: macos
47-
cpu: arm64
48-
- os: windows
49-
cpu: amd64
50-
include:
51-
- target:
52-
os: linux
53-
builder: ubuntu-22.04
54-
- target:
55-
os: macos
56-
builder: macos-13
57-
- target:
58-
os: windows
59-
builder: windows-latest
44+
matrix: ${{ fromJSON(needs.matrix_config.outputs.matrix) }}
6045

6146
defaults:
6247
run:
6348
shell: bash
6449

65-
name: '${{ matrix.target.os }}-${{ matrix.target.cpu }}'
50+
name: '${{ matrix.os }}-${{ matrix.cpu }}'
6651
runs-on: ${{ matrix.builder }}
6752
steps:
6853
- name: Checkout nimbus-eth1
6954
uses: actions/checkout@v4
7055

7156
- name: Derive environment variables
7257
run: |
73-
if [[ '${{ matrix.target.cpu }}' == 'amd64' ]]; then
58+
if [[ '${{ matrix.cpu }}' == 'amd64' ]]; then
7459
PLATFORM=x64
75-
elif [[ '${{ matrix.target.cpu }}' == 'arm64' ]]; then
60+
elif [[ '${{ matrix.cpu }}' == 'arm64' ]]; then
7661
PLATFORM=arm64
7762
else
7863
PLATFORM=x86
7964
fi
8065
echo "PLATFORM=${PLATFORM}" >> $GITHUB_ENV
8166
8267
# libminiupnp / natpmp
83-
if [[ '${{ runner.os }}' == 'Linux' && '${{ matrix.target.cpu }}' == 'i386' ]]; then
68+
if [[ '${{ runner.os }}' == 'Linux' && '${{ matrix.cpu }}' == 'i386' ]]; then
8469
export CFLAGS="${CFLAGS} -m32 -mno-adx"
8570
echo "CFLAGS=${CFLAGS}" >> $GITHUB_ENV
8671
fi
@@ -100,26 +85,6 @@ jobs:
10085
[[ -z "$ncpu" || $ncpu -le 0 ]] && ncpu=1
10186
echo "ncpu=${ncpu}" >> $GITHUB_ENV
10287
103-
- name: Install build dependencies (Linux i386)
104-
if: runner.os == 'Linux' && matrix.target.cpu == 'i386'
105-
run: |
106-
sudo dpkg --add-architecture i386
107-
sudo apt-get update -qq
108-
sudo DEBIAN_FRONTEND='noninteractive' apt-get install \
109-
--no-install-recommends -yq gcc-multilib g++-multilib \
110-
libz-dev:i386 libbz2-dev:i386 libssl-dev:i386 libpcre3-dev:i386
111-
mkdir -p external/bin
112-
cat << EOF > external/bin/gcc
113-
#!/bin/bash
114-
exec $(which gcc) -m32 "\$@"
115-
EOF
116-
cat << EOF > external/bin/g++
117-
#!/bin/bash
118-
exec $(which g++) -m32 "\$@"
119-
EOF
120-
chmod 755 external/bin/gcc external/bin/g++
121-
echo '${{ github.workspace }}/external/bin' >> $GITHUB_PATH
122-
12388
- name: Install build dependencies (Macos)
12489
# Some home brew modules were reported missing
12590
if: runner.os == 'Macos'
@@ -132,8 +97,8 @@ jobs:
13297
id: windows-mingw-cache
13398
uses: actions/cache@v4
13499
with:
135-
path: external/mingw-${{ matrix.target.cpu }}
136-
key: 'mingw-llvm-17-${{ matrix.target.cpu }}'
100+
path: external/mingw-${{ matrix.cpu }}
101+
key: 'mingw-llvm-17-${{ matrix.cpu }}'
137102

138103
- name: Install llvm-mingw dependency (Windows)
139104
if: >
@@ -143,22 +108,22 @@ jobs:
143108
mkdir -p external
144109
LLVM_VERSION="20250730"
145110
MINGW_BASE="https://github.com/mstorsjo/llvm-mingw/releases/download/$LLVM_VERSION"
146-
if [[ '${{ matrix.target.cpu }}' == 'amd64' ]]; then
111+
if [[ '${{ matrix.cpu }}' == 'amd64' ]]; then
147112
MINGW_URL="$MINGW_BASE/llvm-mingw-$LLVM_VERSION-ucrt-x86_64.zip"
148113
ARCH=64
149114
else
150115
MINGW_URL="$MINGW_BASE/llvm-mingw-$LLVM_VERSION-ucrt-i686.zip"
151116
ARCH=32
152117
fi
153-
curl -L "$MINGW_URL" -o "external/mingw-${{ matrix.target.cpu }}.zip"
154-
7z x -y "external/mingw-${{ matrix.target.cpu }}.zip" -oexternal/mingw-${{ matrix.target.cpu }}/
155-
mv external/mingw-${{ matrix.target.cpu }}/**/* ./external/mingw-${{ matrix.target.cpu }}
118+
curl -L "$MINGW_URL" -o "external/mingw-${{ matrix.cpu }}.zip"
119+
7z x -y "external/mingw-${{ matrix.cpu }}.zip" -oexternal/mingw-${{ matrix.cpu }}/
120+
mv external/mingw-${{ matrix.cpu }}/**/* ./external/mingw-${{ matrix.cpu }}
156121
157122
- name: Path to cached dependencies (Windows)
158123
if: >
159124
runner.os == 'Windows'
160125
run: |
161-
echo '${{ github.workspace }}'"/external/mingw-${{ matrix.target.cpu }}/bin" >> $GITHUB_PATH
126+
echo '${{ github.workspace }}'"/external/mingw-${{ matrix.cpu }}/bin" >> $GITHUB_PATH
162127
163128
- name: Get latest nimbus-build-system commit hash
164129
id: versions
@@ -174,7 +139,7 @@ jobs:
174139
uses: actions/cache@v4
175140
with:
176141
path: NimBinCache
177-
key: 'nim-${{ matrix.target.os }}-${{ matrix.target.cpu }}-${{ steps.versions.outputs.nimbus_build_system }}-verified-proxy'
142+
key: 'nim-${{ matrix.os }}-${{ matrix.cpu }}-${{ steps.versions.outputs.nimbus_build_system }}-verified-proxy'
178143

179144
- name: Build Nim and Nimbus-eth1 dependencies
180145
run: |

.github/workflows/portal.yml

Lines changed: 19 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -107,52 +107,39 @@ jobs:
107107
PATH=$PATH$(find /usr/libexec/docker -name docker-compose -printf ":%h")
108108
docker-compose -f portal/tools/utp_testing/docker/docker-compose.yml down
109109
110+
matrix_config:
111+
uses: ./.github/workflows/matrix_config.yml
112+
110113
build:
114+
needs: matrix_config
115+
111116
strategy:
112117
fail-fast: false
113-
max-parallel: 20
114-
matrix:
115-
target:
116-
- os: linux
117-
cpu: amd64
118-
- os: macos
119-
cpu: arm64
120-
- os: windows
121-
cpu: amd64
122-
include:
123-
- target:
124-
os: linux
125-
builder: ubuntu-22.04
126-
- target:
127-
os: macos
128-
builder: macos-13
129-
- target:
130-
os: windows
131-
builder: windows-latest
118+
matrix: ${{ fromJSON(needs.matrix_config.outputs.matrix) }}
132119

133120
defaults:
134121
run:
135122
shell: bash
136123

137-
name: '${{ matrix.target.os }}-${{ matrix.target.cpu }}'
124+
name: '${{ matrix.os }}-${{ matrix.cpu }}'
138125
runs-on: ${{ matrix.builder }}
139126
steps:
140127
- name: Checkout nimbus-eth1
141128
uses: actions/checkout@v4
142129

143130
- name: Derive environment variables
144131
run: |
145-
if [[ '${{ matrix.target.cpu }}' == 'amd64' ]]; then
132+
if [[ '${{ matrix.cpu }}' == 'amd64' ]]; then
146133
PLATFORM=x64
147-
elif [[ '${{ matrix.target.cpu }}' == 'arm64' ]]; then
134+
elif [[ '${{ matrix.cpu }}' == 'arm64' ]]; then
148135
PLATFORM=arm64
149136
else
150137
PLATFORM=x86
151138
fi
152139
echo "PLATFORM=${PLATFORM}" >> $GITHUB_ENV
153140
154141
# libminiupnp / natpmp
155-
if [[ '${{ runner.os }}' == 'Linux' && '${{ matrix.target.cpu }}' == 'i386' ]]; then
142+
if [[ '${{ runner.os }}' == 'Linux' && '${{ matrix.cpu }}' == 'i386' ]]; then
156143
export CFLAGS="${CFLAGS} -m32 -mno-adx"
157144
echo "CFLAGS=${CFLAGS}" >> $GITHUB_ENV
158145
fi
@@ -172,25 +159,6 @@ jobs:
172159
[[ -z "$ncpu" || $ncpu -le 0 ]] && ncpu=1
173160
echo "ncpu=${ncpu}" >> $GITHUB_ENV
174161
175-
- name: Install build dependencies (Linux i386)
176-
if: runner.os == 'Linux' && matrix.target.cpu == 'i386'
177-
run: |
178-
sudo dpkg --add-architecture i386
179-
sudo apt-fast update -qq
180-
sudo DEBIAN_FRONTEND='noninteractive' apt-fast install \
181-
--no-install-recommends -yq gcc-multilib g++-multilib
182-
mkdir -p external/bin
183-
cat << EOF > external/bin/gcc
184-
#!/bin/bash
185-
exec $(which gcc) -m32 -mno-adx "\$@"
186-
EOF
187-
cat << EOF > external/bin/g++
188-
#!/bin/bash
189-
exec $(which g++) -m32 -mno-adx "\$@"
190-
EOF
191-
chmod 755 external/bin/gcc external/bin/g++
192-
echo "${{ github.workspace }}/external/bin" >> $GITHUB_PATH
193-
194162
# Required for running the local testnet script
195163
- name: Install build dependencies (MacOS)
196164
if: runner.os == 'macOS'
@@ -203,8 +171,8 @@ jobs:
203171
id: windows-mingw-cache
204172
uses: actions/cache@v4
205173
with:
206-
path: external/mingw-${{ matrix.target.cpu }}
207-
key: 'mingw-llvm-17-${{ matrix.target.cpu }}'
174+
path: external/mingw-${{ matrix.cpu }}
175+
key: 'mingw-llvm-17-${{ matrix.cpu }}'
208176

209177
- name: Install llvm-mingw dependency (Windows)
210178
if: >
@@ -214,22 +182,22 @@ jobs:
214182
mkdir -p external
215183
LLVM_VERSION="20250730"
216184
MINGW_BASE="https://github.com/mstorsjo/llvm-mingw/releases/download/$LLVM_VERSION"
217-
if [[ '${{ matrix.target.cpu }}' == 'amd64' ]]; then
185+
if [[ '${{ matrix.cpu }}' == 'amd64' ]]; then
218186
MINGW_URL="$MINGW_BASE/llvm-mingw-$LLVM_VERSION-ucrt-x86_64.zip"
219187
ARCH=64
220188
else
221189
MINGW_URL="$MINGW_BASE/llvm-mingw-$LLVM_VERSION-ucrt-x86_64.zip"
222190
ARCH=32
223191
fi
224-
curl -L "$MINGW_URL" -o "external/mingw-${{ matrix.target.cpu }}.zip"
225-
7z x -y "external/mingw-${{ matrix.target.cpu }}.zip" -oexternal/mingw-${{ matrix.target.cpu }}/
226-
mv external/mingw-${{ matrix.target.cpu }}/**/* ./external/mingw-${{ matrix.target.cpu }}
192+
curl -L "$MINGW_URL" -o "external/mingw-${{ matrix.cpu }}.zip"
193+
7z x -y "external/mingw-${{ matrix.cpu }}.zip" -oexternal/mingw-${{ matrix.cpu }}/
194+
mv external/mingw-${{ matrix.cpu }}/**/* ./external/mingw-${{ matrix.cpu }}
227195
228196
- name: Path to cached dependencies (Windows)
229197
if: >
230198
runner.os == 'Windows'
231199
run: |
232-
echo '${{ github.workspace }}'"/external/mingw-${{ matrix.target.cpu }}/bin" >> $GITHUB_PATH
200+
echo '${{ github.workspace }}'"/external/mingw-${{ matrix.cpu }}/bin" >> $GITHUB_PATH
233201
234202
- name: Get latest nimbus-build-system commit hash
235203
id: versions
@@ -245,7 +213,7 @@ jobs:
245213
uses: actions/cache@v4
246214
with:
247215
path: NimBinaries
248-
key: 'nim-${{ matrix.target.os }}-${{ matrix.target.cpu }}-${{ steps.versions.outputs.nimbus_build_system }}-portal'
216+
key: 'nim-${{ matrix.os }}-${{ matrix.cpu }}-${{ steps.versions.outputs.nimbus_build_system }}-portal'
249217

250218
- name: Get latest nim-rocksdb commit hash
251219
id: rocksdb-versions
@@ -261,7 +229,7 @@ jobs:
261229
uses: actions/cache@v4
262230
with:
263231
path: RocksBinCache
264-
key: 'rocks-${{ matrix.target.os }}-${{ matrix.target.cpu }}-${{ steps.rocksdb-versions.outputs.nim_rocksdb }}'
232+
key: 'rocks-${{ matrix.os }}-${{ matrix.cpu }}-${{ steps.rocksdb-versions.outputs.nim_rocksdb }}'
265233

266234
- name: Build Nim and Nimbus-eth1 dependencies
267235
run: |

0 commit comments

Comments
 (0)