Skip to content

Commit 0946ffb

Browse files
authored
Use composite action for CI (#3561)
* Use composite action for CI * Cleanup tests
1 parent 8c5b597 commit 0946ffb

File tree

10 files changed

+217
-419
lines changed

10 files changed

+217
-419
lines changed

.github/actions/shared/action.yml

Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
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') }}

.github/workflows/ci.yml

Lines changed: 6 additions & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -61,132 +61,14 @@ jobs:
6161
- name: Checkout nimbus-eth1
6262
uses: actions/checkout@v4
6363

64-
- name: Derive environment variables
65-
run: |
66-
if [[ '${{ matrix.cpu }}' == 'amd64' ]]; then
67-
PLATFORM=x64
68-
GOARCH=amd64
69-
elif [[ '${{ matrix.cpu }}' == 'arm64' ]]; then
70-
PLATFORM=arm64
71-
GOARCH=arm64
72-
else
73-
PLATFORM=x86
74-
GOARCH=386
75-
fi
76-
echo "PLATFORM=${PLATFORM}" >> $GITHUB_ENV
77-
echo "GOARCH=${GOARCH}" >> $GITHUB_ENV
78-
79-
ncpu=''
80-
case '${{ runner.os }}' in
81-
'Linux')
82-
ncpu=$(nproc)
83-
echo "Number of cores: ${ncpu}"
84-
echo "$(grep MemTotal /proc/meminfo)"
85-
echo -e "Partition sizes:\n$(df -k -h .)"
86-
;;
87-
'macOS')
88-
ncpu=$(sysctl -n hw.ncpu)
89-
hwmemsize=$(sysctl -n hw.memsize)
90-
ramsize=$(expr $hwmemsize / $((1024**3)))
91-
echo "Number of cores: ${ncpu}"
92-
echo "Physical memory: ${ramsize} GB"
93-
echo -e "Partition sizes:\n$(df -k -h .)"
94-
;;
95-
'Windows')
96-
ncpu=${NUMBER_OF_PROCESSORS}
97-
CD=${PWD:1:1}
98-
echo "Number of cores: ${NUMBER_OF_PROCESSORS}"
99-
echo "Physical memory: $(wmic ComputerSystem get TotalPhysicalMemory)"
100-
echo -e "Partition sizes:\n$(wmic logicaldisk get name,size,freespace | grep -e "${CD^}" -e "FreeSpace")"
101-
;;
102-
esac
103-
[[ -z "$ncpu" || $ncpu -le 0 ]] && ncpu=1
104-
echo "ncpu=${ncpu}" >> $GITHUB_ENV
105-
106-
- name: Install build dependencies (Macos)
107-
# Some home brew modules were reported missing
108-
if: runner.os == 'Macos'
109-
run: |
110-
HOMEBREW_NO_INSTALL_CLEANUP=1 brew install gnu-getopt
111-
brew link --force gnu-getopt
112-
113-
- name: Restore llvm-mingw (Windows) from cache
114-
if: runner.os == 'Windows'
115-
id: windows-mingw-cache
116-
uses: actions/cache@v4
117-
with:
118-
path: external/mingw-${{ matrix.cpu }}
119-
key: 'mingw-llvm-17-${{ matrix.cpu }}'
120-
121-
- name: Install llvm-mingw dependency (Windows)
122-
if: >
123-
steps.windows-mingw-cache.outputs.cache-hit != 'true' &&
124-
runner.os == 'Windows'
125-
run: |
126-
mkdir -p external
127-
LLVM_VERSION="20250730"
128-
MINGW_BASE="https://github.com/mstorsjo/llvm-mingw/releases/download/$LLVM_VERSION"
129-
if [[ '${{ matrix.cpu }}' == 'amd64' ]]; then
130-
MINGW_URL="$MINGW_BASE/llvm-mingw-$LLVM_VERSION-ucrt-x86_64.zip"
131-
ARCH=64
132-
else
133-
MINGW_URL="$MINGW_BASE/llvm-mingw-$LLVM_VERSION-ucrt-i686.zip"
134-
ARCH=32
135-
fi
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 }}
139-
140-
- name: Path to cached dependencies (Windows)
141-
if: >
142-
runner.os == 'Windows'
143-
run: |
144-
echo '${{ github.workspace }}'"/external/mingw-${{ matrix.cpu }}/bin" >> $GITHUB_PATH
145-
146-
- name: Get latest nimbus-build-system commit hash
147-
id: versions
148-
run: |
149-
getHash() {
150-
git ls-remote "https://github.com/$1" "${2:-HEAD}" | cut -f 1
151-
}
152-
nbsHash=$(getHash status-im/nimbus-build-system)
153-
echo "nimbus_build_system=$nbsHash" >> $GITHUB_OUTPUT
154-
155-
- name: Restore prebuilt Nim from cache
156-
id: nim-cache
157-
uses: actions/cache@v4
64+
- id: shared-action
65+
uses: ./.github/actions/shared
15866
with:
159-
path: NimBinCache
160-
key: 'nim-${{ matrix.os }}-${{ matrix.cpu }}-${{ steps.versions.outputs.nimbus_build_system }}'
161-
162-
- name: Get latest nim-rocksdb commit hash
163-
id: rocksdb-versions
164-
run: |
165-
getHash() {
166-
git ls-remote "https://github.com/$1" "${2:-HEAD}" | cut -f 1
167-
}
168-
rocksHash=$(getHash status-im/nim-rocksdb)
169-
echo "nim_rocksdb=$rocksHash" >> $GITHUB_OUTPUT
67+
llvm-mingw: true
68+
nim-cache: true
69+
rocksdb-cache: true
70+
eest-cache: true
17071

171-
- name: Restore prebuilt rocksdb from cache
172-
id: rocksdb-cache
173-
uses: actions/cache@v4
174-
with:
175-
path: RocksBinCache
176-
key: 'rocks-${{ matrix.os }}-${{ matrix.cpu }}-${{ steps.rocksdb-versions.outputs.nim_rocksdb }}'
177-
178-
- name: Build Nim and Nimbus-eth1 dependencies
179-
run: |
180-
make -j${ncpu} ARCH_OVERRIDE=${PLATFORM} CI_CACHE=NimBinCache init
181-
182-
- name: Restore EEST test vectors from cache
183-
uses: actions/cache@v4
184-
with:
185-
path: tests/fixtures/eest
186-
# EEST release version contained in eest_ci_cache.sh.
187-
# Each time we bump EEST version, it should invalidate the cache too.
188-
key: eest-${{ hashFiles('scripts/eest_ci_cache.sh') }}
189-
19072
- name: Run nimbus-eth1 tests (Windows)
19173
if: runner.os == 'Windows'
19274
run: |

0 commit comments

Comments
 (0)