nimbus-eth2/.github/workflows/ci.yml

188 lines
6.0 KiB
YAML
Raw Normal View History

name: CI
on:
push:
paths-ignore: ['media/**', 'docs/**', '**/*.md']
2022-02-25 08:19:12 +00:00
branches:
- stable
- testing
- unstable
pull_request:
paths-ignore: ['media/**', 'docs/**', '**/*.md']
2022-02-25 08:19:12 +00:00
workflow_dispatch:
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
jobs:
build:
strategy:
fail-fast: false
matrix:
target:
- os: linux
cpu: amd64
- os: macos
cpu: amd64
- os: windows
cpu: amd64
branch: [version-1-6]
include:
- target:
os: linux
builder: ubuntu-20.04
2022-02-25 08:19:12 +00:00
shell: bash
- target:
os: macos
builder: macos-11
2022-02-25 08:19:12 +00:00
shell: bash
- target:
os: windows
builder: windows-2019
2022-02-25 08:19:12 +00:00
shell: msys2 {0}
defaults:
run:
shell: ${{ matrix.shell }}
name: '${{ matrix.target.os }}-${{ matrix.target.cpu }} (Nim ${{ matrix.branch }})'
runs-on: ${{ matrix.builder }}
steps:
2022-02-25 08:19:12 +00:00
- name: Checkout
2022-12-09 16:06:29 +00:00
uses: actions/checkout@v3
# Fails on nimyaml tests:
# with:
# submodules: true
2022-02-25 08:19:12 +00:00
- name: MSYS2 (Windows amd64)
if: runner.os == 'Windows' && matrix.target.cpu == 'amd64'
uses: msys2/setup-msys2@v2
with:
2022-02-25 08:19:12 +00:00
path-type: inherit
install: >-
base-devel
git
mingw-w64-x86_64-toolchain
mingw-w64-x86_64-cmake
- name: Restore Nim DLLs dependencies (Windows) from cache
if: runner.os == 'Windows'
id: windows-dlls-cache
uses: actions/cache@v3
with:
2022-12-09 16:06:29 +00:00
path: external/dlls-${{ matrix.target.cpu }}
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 }}
- name: Path to cached dependencies (Windows)
if: >
runner.os == 'Windows'
run: |
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
2022-02-25 08:19:12 +00:00
- name: Derive environment variables
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
# 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
if [[ '${{ github.sha }}' =~ ^7 ]]; then
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
echo "NIMFLAGS=${NIMFLAGS}" >> $GITHUB_ENV
fi
ncpu=""
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')
ncpu=${NUMBER_OF_PROCESSORS}
make_cmd="mingw32-make"
echo "Number of cores: ${NUMBER_OF_PROCESSORS}"
echo "Physical memory: $(wmic ComputerSystem get TotalPhysicalMemory)"
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
echo "make_cmd=${make_cmd}" >> $GITHUB_ENV
2021-02-11 19:03:29 +00:00
- name: Build Nim and Nimbus dependencies
run: |
${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
- 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)
2022-02-25 08:19:12 +00:00
echo "::set-output name=fixtures::${fixturesHash}"
- name: Build binaries (with trace logging enabled)
run: |
${make_cmd} -j ${ncpu} V=1 NIM_COMMIT=${{ matrix.branch }} LOG_LEVEL=TRACE NIMFLAGS="-u:release --opt:none"
# The Windows image runs out of disk space, so make some room
rm -rf build nimcache
- name: Restore Ethereum Foundation fixtures from cache
id: fixtures-cache
uses: actions/cache@v3
with:
2022-02-25 08:19:12 +00:00
path: fixturesCache
key: 'eth2-scenarios-${{ steps.fixtures_version.outputs.fixtures }}'
# Important: even with a cache hit, this should be run
# as it symlinks the cached items in their proper place
- name: Get the Ethereum Foundation fixtures
run: |
scripts/setup_scenarios.sh fixturesCache
2022-02-25 08:19:12 +00:00
- name: Run tests
run: |
${make_cmd} -j ${ncpu} V=1 NIM_COMMIT=${{ matrix.branch }} DISABLE_TEST_FIXTURES_SCRIPT=1 test
# The upload creates a combined report that gets posted as a comment on the PR
# https://github.com/EnricoMi/publish-unit-test-result-action
- name: Upload combined results
uses: actions/upload-artifact@v3
with:
name: Unit Test Results ${{ matrix.target.os }}-${{ matrix.target.cpu }}
2022-02-25 08:19:12 +00:00
path: build/*.xml
# https://github.com/EnricoMi/publish-unit-test-result-action
event_file:
name: "Event File"
runs-on: ubuntu-latest
steps:
- name: Upload
uses: actions/upload-artifact@v3
with:
name: Event File
path: ${{ github.event_path }}