2023-04-27 15:55:11 +00:00
|
|
|
# beacon_chain
|
2024-01-03 00:34:39 +00:00
|
|
|
# Copyright (c) 2020-2024 Status Research & Development GmbH
|
2023-04-27 15:55:11 +00:00
|
|
|
# Licensed and distributed under either of
|
|
|
|
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
|
|
|
|
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
|
|
|
|
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
|
|
|
|
2021-04-28 16:41:02 +00:00
|
|
|
name: CI
|
2021-04-30 20:22:37 +00:00
|
|
|
on:
|
|
|
|
push:
|
|
|
|
paths-ignore: ['media/**', 'docs/**', '**/*.md']
|
2022-02-25 08:19:12 +00:00
|
|
|
branches:
|
|
|
|
- stable
|
|
|
|
- testing
|
|
|
|
- unstable
|
2021-04-30 20:22:37 +00:00
|
|
|
pull_request:
|
|
|
|
paths-ignore: ['media/**', 'docs/**', '**/*.md']
|
2024-05-01 19:30:03 +00:00
|
|
|
branches-ignore:
|
|
|
|
- stable
|
2022-02-25 08:19:12 +00:00
|
|
|
workflow_dispatch:
|
2020-09-24 11:45:34 +00:00
|
|
|
|
2022-12-09 16:06:29 +00:00
|
|
|
concurrency: # Cancel stale PR builds (but not push builds)
|
|
|
|
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
|
|
|
|
cancel-in-progress: true
|
|
|
|
|
2020-09-24 11:45:34 +00:00
|
|
|
jobs:
|
|
|
|
build:
|
|
|
|
strategy:
|
|
|
|
fail-fast: false
|
|
|
|
matrix:
|
|
|
|
target:
|
|
|
|
- os: linux
|
|
|
|
cpu: amd64
|
|
|
|
- os: macos
|
|
|
|
cpu: amd64
|
2023-09-12 04:57:20 +00:00
|
|
|
- os: windows
|
|
|
|
cpu: amd64
|
2024-09-16 23:14:29 +00:00
|
|
|
branch: [~]
|
2020-09-24 11:45:34 +00:00
|
|
|
include:
|
|
|
|
- target:
|
|
|
|
os: linux
|
2023-10-11 20:28:09 +00:00
|
|
|
builder: ['self-hosted','ubuntu-22.04']
|
2020-09-24 11:45:34 +00:00
|
|
|
- target:
|
|
|
|
os: macos
|
2024-02-16 04:53:13 +00:00
|
|
|
builder: macos-12
|
2023-09-12 04:57:20 +00:00
|
|
|
- target:
|
|
|
|
os: windows
|
|
|
|
builder: windows-2019
|
2022-02-25 08:19:12 +00:00
|
|
|
|
|
|
|
defaults:
|
|
|
|
run:
|
2024-01-13 09:45:20 +00:00
|
|
|
shell: bash
|
2022-02-25 08:19:12 +00:00
|
|
|
|
2023-09-06 19:00:15 +00:00
|
|
|
name: ${{ matrix.target.os }}-${{ matrix.target.cpu }}${{ matrix.branch != '' && ' (Nim ' || '' }}${{ matrix.branch-short }}${{ matrix.branch != '' && ')' || '' }}
|
2020-09-24 11:45:34 +00:00
|
|
|
runs-on: ${{ matrix.builder }}
|
|
|
|
steps:
|
2022-02-25 08:19:12 +00:00
|
|
|
- name: Checkout
|
2024-02-28 18:04:34 +00:00
|
|
|
uses: actions/checkout@v4
|
2023-04-27 15:55:11 +00:00
|
|
|
|
2024-01-13 09:45:20 +00:00
|
|
|
- name: Restore llvm-mingw (Windows) from cache
|
|
|
|
if: runner.os == 'Windows'
|
|
|
|
id: windows-mingw-cache
|
2024-02-28 18:04:34 +00:00
|
|
|
uses: actions/cache@v4
|
2020-09-24 11:45:34 +00:00
|
|
|
with:
|
2024-01-13 09:45:20 +00:00
|
|
|
path: external/mingw-${{ matrix.target.cpu }}
|
|
|
|
key: 'mingw-llvm-17-${{ matrix.target.cpu }}'
|
|
|
|
|
|
|
|
- name: Install llvm-mingw dependency (Windows)
|
|
|
|
if: >
|
|
|
|
steps.windows-mingw-cache.outputs.cache-hit != 'true' &&
|
|
|
|
runner.os == 'Windows'
|
|
|
|
run: |
|
|
|
|
mkdir -p external
|
|
|
|
MINGW_BASE="https://github.com/mstorsjo/llvm-mingw/releases/download/20230905"
|
|
|
|
MINGW_URL="$MINGW_BASE/llvm-mingw-20230905-ucrt-x86_64.zip"
|
|
|
|
curl -L "$MINGW_URL" -o "external/mingw-${{ matrix.target.cpu }}.zip"
|
|
|
|
7z x -y "external/mingw-${{ matrix.target.cpu }}.zip" -oexternal/mingw-${{ matrix.target.cpu }}/
|
|
|
|
mv external/mingw-${{ matrix.target.cpu }}/**/* ./external/mingw-${{ matrix.target.cpu }}
|
2020-09-24 11:45:34 +00:00
|
|
|
|
|
|
|
- name: Restore Nim DLLs dependencies (Windows) from cache
|
|
|
|
if: runner.os == 'Windows'
|
|
|
|
id: windows-dlls-cache
|
2024-02-28 18:04:34 +00:00
|
|
|
uses: actions/cache@v4
|
2020-09-24 11:45:34 +00:00
|
|
|
with:
|
2022-12-09 16:06:29 +00:00
|
|
|
path: external/dlls-${{ matrix.target.cpu }}
|
2020-09-24 11:45:34 +00:00
|
|
|
key: 'dlls-${{ matrix.target.cpu }}'
|
|
|
|
|
|
|
|
- name: Install DLLs dependencies (Windows)
|
|
|
|
if: >
|
|
|
|
steps.windows-dlls-cache.outputs.cache-hit != 'true' &&
|
|
|
|
runner.os == 'Windows'
|
|
|
|
run: |
|
|
|
|
mkdir -p external
|
|
|
|
curl -L "https://nim-lang.org/download/windeps.zip" -o external/windeps.zip
|
2022-12-09 16:06:29 +00:00
|
|
|
7z x -y external/windeps.zip -oexternal/dlls-${{ matrix.target.cpu }}
|
2020-09-25 16:53:17 +00:00
|
|
|
|
|
|
|
- name: Path to cached dependencies (Windows)
|
|
|
|
if: >
|
|
|
|
runner.os == 'Windows'
|
|
|
|
run: |
|
2024-01-13 09:45:20 +00:00
|
|
|
echo '${{ github.workspace }}'"/external/mingw-${{ matrix.target.cpu }}/bin" >> $GITHUB_PATH
|
2022-12-09 16:06:29 +00:00
|
|
|
echo "${{ github.workspace }}/external/dlls-${{ matrix.target.cpu }}" >> $GITHUB_PATH
|
2022-02-25 08:19:12 +00:00
|
|
|
# for miniupnp that runs "wingenminiupnpcstrings.exe" from the current dir
|
|
|
|
echo "." >> $GITHUB_PATH
|
2020-09-24 11:45:34 +00:00
|
|
|
|
2022-02-25 08:19:12 +00:00
|
|
|
- name: Derive environment variables
|
2020-09-24 11:45:34 +00:00
|
|
|
run: |
|
2022-02-25 08:19:12 +00:00
|
|
|
if [[ '${{ matrix.target.cpu }}' == 'amd64' ]]; then
|
|
|
|
PLATFORM=x64
|
|
|
|
else
|
|
|
|
PLATFORM=x86
|
|
|
|
fi
|
2022-12-09 16:06:29 +00:00
|
|
|
echo "PLATFORM=$PLATFORM" >> $GITHUB_ENV
|
2022-02-16 11:41:50 +00:00
|
|
|
|
2023-03-23 14:45:13 +00:00
|
|
|
# Stack usage test and UBSAN on recent enough gcc:
|
2022-02-25 08:19:12 +00:00
|
|
|
if [[ '${{ runner.os }}' == 'Linux' && '${{ matrix.target.cpu }}' == 'amd64' ]]; then
|
2023-04-03 16:27:07 +00:00
|
|
|
if [[ '${{ github.sha }}' =~ ^7 ]]; then
|
2023-08-16 16:56:05 +00:00
|
|
|
export WITH_UBSAN=1
|
|
|
|
echo "WITH_UBSAN=1" >> $GITHUB_ENV
|
2023-04-03 16:27:07 +00:00
|
|
|
export NIMFLAGS="${NIMFLAGS} -d:limitStackUsage --passC:-fsanitize=undefined --passL:-fsanitize=undefined"
|
|
|
|
else
|
|
|
|
export NIMFLAGS="${NIMFLAGS} -d:limitStackUsage"
|
|
|
|
fi
|
2022-02-25 08:19:12 +00:00
|
|
|
fi
|
|
|
|
|
2024-05-02 06:54:32 +00:00
|
|
|
if [[ '${{ runner.os }}' == 'Windows' ]]; then
|
|
|
|
export NIMFLAGS="${NIMFLAGS} --cc:clang"
|
|
|
|
fi
|
|
|
|
|
2023-09-06 19:00:15 +00:00
|
|
|
export NIMFLAGS="${NIMFLAGS} ${{ matrix.nimflags-extra }}"
|
|
|
|
echo "NIMFLAGS=${NIMFLAGS}" >> $GITHUB_ENV
|
|
|
|
|
2022-02-25 08:19:12 +00:00
|
|
|
ncpu=""
|
2022-03-05 14:40:08 +00:00
|
|
|
make_cmd="make"
|
2022-02-25 08:19:12 +00:00
|
|
|
case '${{ runner.os }}' in
|
|
|
|
'Linux')
|
|
|
|
ncpu=$(nproc)
|
|
|
|
;;
|
|
|
|
'macOS')
|
|
|
|
ncpu=$(sysctl -n hw.ncpu)
|
|
|
|
;;
|
|
|
|
'Windows')
|
2023-01-13 13:22:35 +00:00
|
|
|
ncpu=${NUMBER_OF_PROCESSORS}
|
2022-03-05 14:40:08 +00:00
|
|
|
make_cmd="mingw32-make"
|
2023-01-13 21:42:08 +00:00
|
|
|
echo "Number of cores: ${NUMBER_OF_PROCESSORS}"
|
|
|
|
echo "Physical memory: $(wmic ComputerSystem get TotalPhysicalMemory)"
|
2023-01-14 21:48:01 +00:00
|
|
|
echo "Partition sizes: $(wmic partition get name,size,type)"
|
2022-02-25 08:19:12 +00:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
[[ -z "$ncpu" || $ncpu -le 0 ]] && ncpu=1
|
|
|
|
echo "ncpu=${ncpu}" >> $GITHUB_ENV
|
2022-03-05 14:40:08 +00:00
|
|
|
echo "make_cmd=${make_cmd}" >> $GITHUB_ENV
|
2020-09-24 11:45:34 +00:00
|
|
|
|
2021-02-11 19:03:29 +00:00
|
|
|
- name: Build Nim and Nimbus dependencies
|
2020-09-24 11:45:34 +00:00
|
|
|
run: |
|
2022-03-05 14:40:08 +00:00
|
|
|
${make_cmd} -j ${ncpu} NIM_COMMIT=${{ matrix.branch }} ARCH_OVERRIDE=${PLATFORM} QUICK_AND_DIRTY_COMPILER=1 update
|
2022-02-25 08:19:12 +00:00
|
|
|
./env.sh nim --version
|
2020-09-24 11:45:34 +00:00
|
|
|
|
|
|
|
- name: Get latest fixtures commit hash
|
|
|
|
id: fixtures_version
|
|
|
|
run: |
|
|
|
|
getHash() {
|
|
|
|
git ls-remote "https://github.com/$1" "${2:-HEAD}" | cut -f 1
|
|
|
|
}
|
|
|
|
fixturesHash=$(getHash status-im/nim-eth2-scenarios)
|
2024-01-11 03:14:32 +00:00
|
|
|
echo "fixtures=${fixturesHash}" >> $GITHUB_OUTPUT
|
2020-09-24 11:45:34 +00:00
|
|
|
|
2023-01-15 08:43:50 +00:00
|
|
|
- name: Build binaries (with trace logging enabled)
|
|
|
|
run: |
|
2024-05-02 06:54:32 +00:00
|
|
|
${make_cmd} -j ${ncpu} V=1 NIM_COMMIT=${{ matrix.branch }} LOG_LEVEL=TRACE NIMFLAGS="-u:release --opt:none ${NIMFLAGS}"
|
2023-01-15 08:43:50 +00:00
|
|
|
# The Windows image runs out of disk space, so make some room
|
|
|
|
rm -rf build nimcache
|
|
|
|
|
2020-09-24 11:45:34 +00:00
|
|
|
- name: Restore Ethereum Foundation fixtures from cache
|
|
|
|
id: fixtures-cache
|
2024-02-28 18:04:34 +00:00
|
|
|
uses: actions/cache@v4
|
2020-09-24 11:45:34 +00:00
|
|
|
with:
|
2022-02-25 08:19:12 +00:00
|
|
|
path: fixturesCache
|
2020-09-25 14:05:29 +00:00
|
|
|
key: 'eth2-scenarios-${{ steps.fixtures_version.outputs.fixtures }}'
|
2020-09-24 11:45:34 +00:00
|
|
|
|
2020-09-25 16:13:46 +00:00
|
|
|
# Important: even with a cache hit, this should be run
|
|
|
|
# as it symlinks the cached items in their proper place
|
2020-09-24 11:45:34 +00:00
|
|
|
- name: Get the Ethereum Foundation fixtures
|
|
|
|
run: |
|
2021-10-12 11:36:52 +00:00
|
|
|
scripts/setup_scenarios.sh fixturesCache
|
2020-09-24 11:45:34 +00:00
|
|
|
|
2022-02-25 08:19:12 +00:00
|
|
|
- name: Run tests
|
|
|
|
run: |
|
2023-01-19 17:55:39 +00:00
|
|
|
${make_cmd} -j ${ncpu} V=1 NIM_COMMIT=${{ matrix.branch }} DISABLE_TEST_FIXTURES_SCRIPT=1 test
|
2020-09-24 11:45:34 +00:00
|
|
|
|
2021-04-28 16:41:02 +00:00
|
|
|
# The upload creates a combined report that gets posted as a comment on the PR
|
2021-10-26 22:49:35 +00:00
|
|
|
# https://github.com/EnricoMi/publish-unit-test-result-action
|
2021-04-28 16:41:02 +00:00
|
|
|
- name: Upload combined results
|
2023-01-17 15:45:04 +00:00
|
|
|
uses: actions/upload-artifact@v3
|
2021-04-28 16:41:02 +00:00
|
|
|
with:
|
|
|
|
name: Unit Test Results ${{ matrix.target.os }}-${{ matrix.target.cpu }}
|
2022-02-25 08:19:12 +00:00
|
|
|
path: build/*.xml
|
2021-04-28 16:41:02 +00:00
|
|
|
|
2024-02-07 00:11:51 +00:00
|
|
|
devbuild:
|
|
|
|
name: "Developer builds"
|
2024-05-29 13:45:44 +00:00
|
|
|
runs-on: ['self-hosted','ubuntu-22.04']
|
2024-02-07 00:11:51 +00:00
|
|
|
steps:
|
|
|
|
- name: Checkout
|
2024-02-28 18:04:34 +00:00
|
|
|
uses: actions/checkout@v4
|
2024-02-07 00:11:51 +00:00
|
|
|
with:
|
|
|
|
fetch-depth: 1
|
|
|
|
|
|
|
|
- name: Build with developer flags
|
|
|
|
run: |
|
|
|
|
make -j nimbus_beacon_node LOG_LEVEL=TRACE NIMFLAGS="-d:has_deposit_root_checks=1"
|
|
|
|
|
2024-02-07 19:26:29 +00:00
|
|
|
- name: Build files with isMainModule
|
|
|
|
run: |
|
2024-06-23 23:35:56 +00:00
|
|
|
executables=(
|
|
|
|
"beacon_chain/el/deposit_contract"
|
|
|
|
"beacon_chain/fork_choice/fork_choice"
|
|
|
|
"beacon_chain/fork_choice/proto_array"
|
|
|
|
"beacon_chain/networking/network_metadata_downloads"
|
|
|
|
"beacon_chain/era_db"
|
|
|
|
"beacon_chain/trusted_node_sync"
|
|
|
|
"benchmarks/rest_api_benchmark"
|
|
|
|
"tests/mocking/mock_genesis"
|
|
|
|
)
|
2024-02-07 19:26:29 +00:00
|
|
|
source env.sh
|
2024-06-23 23:35:56 +00:00
|
|
|
for executable in "${executables[@]}"; do
|
|
|
|
nim c --passC:-fsyntax-only --noLinking:on -d:chronicles_log_level=TRACE "${executable}"
|
|
|
|
done
|
2024-02-07 19:26:29 +00:00
|
|
|
|
2023-07-19 11:55:23 +00:00
|
|
|
lint:
|
|
|
|
name: "Lint"
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- name: Checkout
|
2024-02-28 18:04:34 +00:00
|
|
|
uses: actions/checkout@v4
|
2023-07-19 11:55:23 +00:00
|
|
|
with:
|
|
|
|
fetch-depth: 2 # In PR, has extra merge commit: ^1 = PR, ^2 = base
|
|
|
|
submodules: 'recursive'
|
|
|
|
|
|
|
|
- name: Check copyright year
|
|
|
|
if: ${{ !cancelled() }} && github.event_name == 'pull_request'
|
|
|
|
run: |
|
|
|
|
excluded_files="config.yaml"
|
2024-04-06 22:10:15 +00:00
|
|
|
excluded_extensions="ans|cfg|json|json\\.template|md|png|service|ssz|txt|lock|nix"
|
2023-07-19 11:55:23 +00:00
|
|
|
|
|
|
|
current_year=$(date +"%Y")
|
2024-02-19 10:02:36 +00:00
|
|
|
problematic_files=()
|
2023-07-19 11:55:23 +00:00
|
|
|
while read -r file; do
|
|
|
|
if ! grep -qE 'Copyright \(c\) .*'$current_year' Status Research & Development GmbH' "$file"; then
|
2024-02-19 10:02:36 +00:00
|
|
|
problematic_files+=("$file")
|
2023-07-19 11:55:23 +00:00
|
|
|
fi
|
|
|
|
done < <(git diff --name-only --diff-filter=AM --ignore-submodules HEAD^ HEAD | grep -vE '(\.('$excluded_extensions')|'$excluded_files')$' || true)
|
|
|
|
|
2024-02-19 10:02:36 +00:00
|
|
|
if (( ${#problematic_files[@]} )); then
|
2023-07-19 11:55:23 +00:00
|
|
|
echo "The following files do not have an up-to-date copyright year:"
|
2024-02-19 10:02:36 +00:00
|
|
|
for file in "${problematic_files[@]}"; do
|
2023-07-19 11:55:23 +00:00
|
|
|
echo "- $file"
|
|
|
|
done
|
|
|
|
exit 2
|
|
|
|
fi
|
|
|
|
|
2024-02-19 10:02:36 +00:00
|
|
|
- name: Check exception tracking
|
|
|
|
if: ${{ !cancelled() }} && github.event_name == 'pull_request'
|
|
|
|
run: |
|
|
|
|
problematic_files=()
|
|
|
|
while read -r file; do
|
2024-02-22 10:03:09 +00:00
|
|
|
if ! grep -qE '^{\.push raises: \[\]\.}$' "$file"; then
|
2024-02-19 10:02:36 +00:00
|
|
|
problematic_files+=("$file")
|
|
|
|
fi
|
|
|
|
done < <(git diff --name-only --diff-filter=AM --ignore-submodules HEAD^ HEAD | grep -E '\.nim$' || true)
|
|
|
|
|
|
|
|
if (( ${#problematic_files[@]} )); then
|
2024-02-22 10:03:09 +00:00
|
|
|
echo "The following files do not have '{.push raises: [].}':"
|
2024-02-19 10:02:36 +00:00
|
|
|
for file in "${problematic_files[@]}"; do
|
|
|
|
echo "- $file"
|
|
|
|
done
|
|
|
|
echo "See https://status-im.github.io/nim-style-guide/errors.exceptions.html"
|
|
|
|
exit 2
|
|
|
|
fi
|
|
|
|
|
2023-07-19 11:55:23 +00:00
|
|
|
- name: Check submodules
|
|
|
|
if: ${{ !cancelled() }} && github.event_name == 'pull_request'
|
|
|
|
run: |
|
|
|
|
while read -r file; do
|
|
|
|
commit="$(git -C "$file" rev-parse HEAD)"
|
2024-01-03 00:34:39 +00:00
|
|
|
commit_date=$(TZ=UTC0 git -C "$file" show -s --format='%cd' --date=iso-local HEAD)
|
2023-07-19 11:55:23 +00:00
|
|
|
if ! branch="$(git config -f .gitmodules --get "submodule.$file.branch")"; then
|
|
|
|
echo "Submodule '$file': '.gitmodules' lacks 'branch' entry"
|
|
|
|
exit 2
|
|
|
|
fi
|
2023-08-24 18:23:05 +00:00
|
|
|
# Without the `--depth=1` fetch, may run into 'error processing shallow info: 4'
|
|
|
|
if ! error="$(git -C "$file" fetch -q --depth=1 origin "+refs/heads/${branch}:refs/remotes/origin/${branch}")"; then
|
2023-09-06 18:52:31 +00:00
|
|
|
echo "Submodule '$file': Failed to fetch '$branch': $error (1)"
|
|
|
|
exit 2
|
|
|
|
fi
|
2024-01-03 00:34:39 +00:00
|
|
|
branch_commit_date=$(TZ=UTC0 git -C "$file" show -s --format='%cd' --date=iso-local "refs/remotes/origin/${branch}")
|
2023-09-06 18:52:31 +00:00
|
|
|
if [[ "${commit_date}" > "${branch_commit_date}" ]]; then
|
|
|
|
echo "Submodule '$file': '$commit' ($commit_date) is more recent than latest '$branch' ($branch_commit_date) (branch config: '.gitmodules')"
|
2023-08-24 18:23:05 +00:00
|
|
|
exit 2
|
|
|
|
fi
|
|
|
|
if ! error="$(git -C "$file" fetch -q --shallow-since="$commit_date" origin "+refs/heads/${branch}:refs/remotes/origin/${branch}")"; then
|
2023-09-06 18:52:31 +00:00
|
|
|
echo "Submodule '$file': Failed to fetch '$branch': $error (2)"
|
2023-07-19 11:55:23 +00:00
|
|
|
exit 2
|
|
|
|
fi
|
2023-08-19 20:49:52 +00:00
|
|
|
if ! git -C "$file" merge-base --is-ancestor "$commit" "refs/remotes/origin/$branch"; then
|
2023-09-06 18:52:31 +00:00
|
|
|
echo "Submodule '$file': '$commit' is not on '$branch' as of $commit_date (branch config: '.gitmodules')"
|
2023-07-19 11:55:23 +00:00
|
|
|
exit 2
|
|
|
|
fi
|
|
|
|
done < <(git diff --name-only --diff-filter=AM HEAD^ HEAD | grep -f <(git config --file .gitmodules --get-regexp path | awk '{ print $2 }') || true)
|
|
|
|
|
2021-10-26 22:49:35 +00:00
|
|
|
# https://github.com/EnricoMi/publish-unit-test-result-action
|
|
|
|
event_file:
|
|
|
|
name: "Event File"
|
2021-04-28 16:41:02 +00:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
2023-07-19 11:55:23 +00:00
|
|
|
- name: Upload
|
|
|
|
uses: actions/upload-artifact@v3
|
|
|
|
with:
|
|
|
|
name: Event File
|
|
|
|
path: ${{ github.event_path }}
|