1
+ # Nimbus
2
+ # Copyright (c) 2025 Status Research & Development GmbH
3
+ # Licensed under either of
4
+ # * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
5
+ # http://www.apache.org/licenses/LICENSE-2.0)
6
+ # * MIT license ([LICENSE-MIT](LICENSE-MIT) or
7
+ # http://opensource.org/licenses/MIT)
8
+ # at your option. This file may not be copied, modified, or distributed except
9
+ # according to those terms.
10
+
11
+ name : ' Shared action'
12
+ description : ' Nimbus shared action'
13
+ inputs :
14
+ llvm-mingw :
15
+ description : ' Enable llvm-mingw cache'
16
+ required : false
17
+ default : false
18
+
19
+ nim-cache :
20
+ description : ' Enable nim compiler prebuilt binary cache'
21
+ required : false
22
+ default : true
23
+
24
+ rocksdb-cache :
25
+ description : ' Enable rocksdb prebuilt binary cache'
26
+ required : false
27
+ default : false
28
+
29
+ eest-cache :
30
+ description : ' Enable EEST test vectors cache'
31
+ required : false
32
+ default : false
33
+
34
+ outputs :
35
+ random-number :
36
+ description : " Random number"
37
+ value : ${{ steps.random-number-generator.outputs.random-number }}
38
+
39
+ runs :
40
+ using : " composite"
41
+ steps :
42
+ - name : Random Number Generator
43
+ id : random-number-generator
44
+ run : echo "random-number=$(echo $RANDOM)" >> $GITHUB_OUTPUT
45
+ shell : bash
46
+
47
+ - name : Derive environment variables
48
+ shell : bash
49
+ run : |
50
+ if [[ '${{ matrix.cpu }}' == 'amd64' ]]; then
51
+ PLATFORM=x64
52
+ GOARCH=amd64
53
+ elif [[ '${{ matrix.cpu }}' == 'arm64' ]]; then
54
+ PLATFORM=arm64
55
+ GOARCH=arm64
56
+ else
57
+ PLATFORM=x86
58
+ GOARCH=386
59
+ fi
60
+ echo "PLATFORM=${PLATFORM}" >> $GITHUB_ENV
61
+ echo "GOARCH=${GOARCH}" >> $GITHUB_ENV
62
+
63
+ ncpu=''
64
+ case '${{ runner.os }}' in
65
+ 'Linux')
66
+ ncpu=$(nproc)
67
+ echo "Number of cores: ${ncpu}"
68
+ echo "$(grep MemTotal /proc/meminfo)"
69
+ echo -e "Partition sizes:\n$(df -k -h .)"
70
+ ;;
71
+ 'macOS')
72
+ ncpu=$(sysctl -n hw.ncpu)
73
+ hwmemsize=$(sysctl -n hw.memsize)
74
+ ramsize=$(expr $hwmemsize / $((1024**3)))
75
+ echo "Number of cores: ${ncpu}"
76
+ echo "Physical memory: ${ramsize} GB"
77
+ echo -e "Partition sizes:\n$(df -k -h .)"
78
+ ;;
79
+ 'Windows')
80
+ ncpu=${NUMBER_OF_PROCESSORS}
81
+ CD=${PWD:1:1}
82
+ echo "Number of cores: ${NUMBER_OF_PROCESSORS}"
83
+ echo "Physical memory: $(wmic ComputerSystem get TotalPhysicalMemory)"
84
+ echo -e "Partition sizes:\n$(wmic logicaldisk get name,size,freespace | grep -e "${CD^}" -e "FreeSpace")"
85
+ ;;
86
+ esac
87
+ [[ -z "$ncpu" || $ncpu -le 0 ]] && ncpu=1
88
+ echo "ncpu=${ncpu}" >> $GITHUB_ENV
89
+
90
+ - name : Install build dependencies (Macos)
91
+ # Some home brew modules were reported missing
92
+ if : runner.os == 'Macos'
93
+ shell : bash
94
+ run : |
95
+ HOMEBREW_NO_INSTALL_CLEANUP=1 brew install gnu-getopt
96
+ brew link --force gnu-getopt
97
+
98
+ - name : Restore llvm-mingw (Windows) from cache
99
+ if : runner.os == 'Windows' && inputs.llvm-mingw == 'true'
100
+ id : windows-mingw-cache
101
+ uses : actions/cache@v4
102
+ with :
103
+ path : external/mingw-${{ matrix.cpu }}
104
+ key : ' mingw-llvm-21-${{ matrix.cpu }}'
105
+
106
+ - name : Install llvm-mingw dependency (Windows)
107
+ if : >
108
+ steps.windows-mingw-cache.outputs.cache-hit != 'true' &&
109
+ runner.os == 'Windows' && inputs.llvm-mingw == 'true'
110
+ shell : bash
111
+ run : |
112
+ mkdir -p external
113
+ LLVM_VERSION="20250730"
114
+ MINGW_BASE="https://github.com/mstorsjo/llvm-mingw/releases/download/$LLVM_VERSION"
115
+ if [[ '${{ matrix.cpu }}' == 'amd64' ]]; then
116
+ MINGW_URL="$MINGW_BASE/llvm-mingw-$LLVM_VERSION-ucrt-x86_64.zip"
117
+ ARCH=64
118
+ else
119
+ MINGW_URL="$MINGW_BASE/llvm-mingw-$LLVM_VERSION-ucrt-i686.zip"
120
+ ARCH=32
121
+ fi
122
+ curl -L "$MINGW_URL" -o "external/mingw-${{ matrix.cpu }}.zip"
123
+ 7z x -y "external/mingw-${{ matrix.cpu }}.zip" -oexternal/mingw-${{ matrix.cpu }}/
124
+ mv external/mingw-${{ matrix.cpu }}/**/* ./external/mingw-${{ matrix.cpu }}
125
+
126
+ - name : Path to cached dependencies (Windows)
127
+ if : >
128
+ runner.os == 'Windows' && inputs.llvm-mingw == 'true'
129
+ shell : bash
130
+ run : |
131
+ echo '${{ github.workspace }}'"/external/mingw-${{ matrix.cpu }}/bin" >> $GITHUB_PATH
132
+
133
+ - name : Get latest nimbus-build-system commit hash
134
+ if : inputs.nim-cache == 'true'
135
+ id : versions
136
+ shell : bash
137
+ run : |
138
+ getHash() {
139
+ git ls-remote "https://github.com/$1" "${2:-HEAD}" | cut -f 1
140
+ }
141
+ nbsHash=$(getHash status-im/nimbus-build-system)
142
+ echo "nimbus_build_system=$nbsHash" >> $GITHUB_OUTPUT
143
+
144
+ - name : Restore prebuilt Nim from cache
145
+ if : inputs.nim-cache == 'true'
146
+ id : nim-cache
147
+ uses : actions/cache@v4
148
+ with :
149
+ path : NimBinCache
150
+ key : ' nim-${{ matrix.os }}-${{ matrix.cpu }}-${{ steps.versions.outputs.nimbus_build_system }}'
151
+
152
+ - name : Build Nim and Nimbus-eth1 dependencies
153
+ if : inputs.nim-cache == 'true'
154
+ shell : bash
155
+ run : |
156
+ make -j${ncpu} ARCH_OVERRIDE=${PLATFORM} CI_CACHE=NimBinCache init
157
+
158
+ - name : Get latest nim-rocksdb commit hash
159
+ if : inputs.rocksdb-cache == 'true'
160
+ id : rocksdb-versions
161
+ shell : bash
162
+ run : |
163
+ getHash() {
164
+ git ls-remote "https://github.com/$1" "${2:-HEAD}" | cut -f 1
165
+ }
166
+ rocksHash=$(getHash status-im/nim-rocksdb)
167
+ echo "nim_rocksdb=$rocksHash" >> $GITHUB_OUTPUT
168
+
169
+ - name : Restore prebuilt rocksdb from cache
170
+ if : inputs.rocksdb-cache == 'true'
171
+ id : rocksdb-cache
172
+ uses : actions/cache@v4
173
+ with :
174
+ path : RocksBinCache
175
+ key : ' rocks-${{ matrix.os }}-${{ matrix.cpu }}-${{ steps.rocksdb-versions.outputs.nim_rocksdb }}'
176
+
177
+ - name : Restore EEST test vectors from cache
178
+ if : inputs.eest-cache == 'true'
179
+ uses : actions/cache@v4
180
+ with :
181
+ path : tests/fixtures/eest
182
+ # EEST release version contained in eest_ci_cache.sh.
183
+ # Each time we bump EEST version, it should invalidate the cache too.
184
+ key : eest-${{ hashFiles('scripts/eest_ci_cache.sh') }}
0 commit comments