CI: test with multiple Nim versions (#39)
This commit is contained in:
parent
11a8aa64d2
commit
37bc0db558
|
@ -1,11 +1,15 @@
|
||||||
name: CI
|
name: CI
|
||||||
on: [push, pull_request]
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
pull_request:
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
max-parallel: 20
|
|
||||||
matrix:
|
matrix:
|
||||||
target:
|
target:
|
||||||
- os: linux
|
- os: linux
|
||||||
|
@ -16,27 +20,33 @@ jobs:
|
||||||
cpu: amd64
|
cpu: amd64
|
||||||
- os: windows
|
- os: windows
|
||||||
cpu: amd64
|
cpu: amd64
|
||||||
- os: windows
|
#- os: windows
|
||||||
cpu: i386
|
#cpu: i386
|
||||||
|
branch: [version-1-2, version-1-4, version-1-6, devel]
|
||||||
include:
|
include:
|
||||||
- target:
|
- target:
|
||||||
os: linux
|
os: linux
|
||||||
builder: ubuntu-18.04
|
builder: ubuntu-18.04
|
||||||
|
shell: bash
|
||||||
- target:
|
- target:
|
||||||
os: macos
|
os: macos
|
||||||
builder: macos-10.15
|
builder: macos-10.15
|
||||||
|
shell: bash
|
||||||
- target:
|
- target:
|
||||||
os: windows
|
os: windows
|
||||||
builder: windows-2019
|
builder: windows-2019
|
||||||
|
shell: msys2 {0}
|
||||||
|
|
||||||
name: '${{ matrix.target.os }}-${{ matrix.target.cpu }}'
|
defaults:
|
||||||
|
run:
|
||||||
|
shell: ${{ matrix.shell }}
|
||||||
|
|
||||||
|
name: '${{ matrix.target.os }}-${{ matrix.target.cpu }} (Nim ${{ matrix.branch }})'
|
||||||
runs-on: ${{ matrix.builder }}
|
runs-on: ${{ matrix.builder }}
|
||||||
|
continue-on-error: ${{ matrix.branch == 'version-1-6' || matrix.branch == 'devel' }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout nim-serialization
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
with:
|
|
||||||
path: nim-serialization
|
|
||||||
submodules: false
|
|
||||||
|
|
||||||
- name: Install build dependencies (Linux i386)
|
- name: Install build dependencies (Linux i386)
|
||||||
if: runner.os == 'Linux' && matrix.target.cpu == 'i386'
|
if: runner.os == 'Linux' && matrix.target.cpu == 'i386'
|
||||||
|
@ -58,95 +68,92 @@ jobs:
|
||||||
chmod 755 external/bin/gcc external/bin/g++
|
chmod 755 external/bin/gcc external/bin/g++
|
||||||
echo '${{ github.workspace }}/external/bin' >> $GITHUB_PATH
|
echo '${{ github.workspace }}/external/bin' >> $GITHUB_PATH
|
||||||
|
|
||||||
- name: Restore MinGW-W64 (Windows) from cache
|
- name: MSYS2 (Windows i386)
|
||||||
if: runner.os == 'Windows'
|
if: runner.os == 'Windows' && matrix.target.cpu == 'i386'
|
||||||
id: windows-mingw-cache
|
uses: msys2/setup-msys2@v2
|
||||||
uses: actions/cache@v2
|
|
||||||
with:
|
with:
|
||||||
path: external/mingw-${{ matrix.target.cpu }}
|
path-type: inherit
|
||||||
key: 'mingw-${{ matrix.target.cpu }}'
|
msystem: MINGW32
|
||||||
|
install: >-
|
||||||
|
base-devel
|
||||||
|
git
|
||||||
|
mingw-w64-i686-toolchain
|
||||||
|
|
||||||
|
- name: MSYS2 (Windows amd64)
|
||||||
|
if: runner.os == 'Windows' && matrix.target.cpu == 'amd64'
|
||||||
|
uses: msys2/setup-msys2@v2
|
||||||
|
with:
|
||||||
|
path-type: inherit
|
||||||
|
install: >-
|
||||||
|
base-devel
|
||||||
|
git
|
||||||
|
mingw-w64-x86_64-toolchain
|
||||||
|
|
||||||
- name: Restore Nim DLLs dependencies (Windows) from cache
|
- name: Restore Nim DLLs dependencies (Windows) from cache
|
||||||
if: runner.os == 'Windows'
|
if: runner.os == 'Windows'
|
||||||
id: windows-dlls-cache
|
id: windows-dlls-cache
|
||||||
uses: actions/cache@v2
|
uses: actions/cache@v2
|
||||||
with:
|
with:
|
||||||
path: external/dlls-${{ matrix.target.cpu }}
|
path: external/dlls
|
||||||
key: 'dlls-${{ matrix.target.cpu }}'
|
key: 'dlls'
|
||||||
|
|
||||||
- name: Install MinGW64 dependency (Windows)
|
- name: Install DLL dependencies (Windows)
|
||||||
if: >
|
|
||||||
steps.windows-mingw-cache.outputs.cache-hit != 'true' &&
|
|
||||||
runner.os == 'Windows'
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
mkdir -p external
|
|
||||||
if [[ '${{ matrix.target.cpu }}' == 'amd64' ]]; then
|
|
||||||
MINGW_URL="https://sourceforge.net/projects/mingw-w64/files/Toolchains targetting Win64/Personal Builds/mingw-builds/8.1.0/threads-posix/seh/x86_64-8.1.0-release-posix-seh-rt_v6-rev0.7z"
|
|
||||||
ARCH=64
|
|
||||||
else
|
|
||||||
MINGW_URL="https://sourceforge.net/projects/mingw-w64/files/Toolchains targetting Win32/Personal Builds/mingw-builds/8.1.0/threads-posix/dwarf/i686-8.1.0-release-posix-dwarf-rt_v6-rev0.7z"
|
|
||||||
ARCH=32
|
|
||||||
fi
|
|
||||||
curl -L "$MINGW_URL" -o "external/mingw-${{ matrix.target.cpu }}.7z"
|
|
||||||
7z x -y "external/mingw-${{ matrix.target.cpu }}.7z" -oexternal/
|
|
||||||
mv external/mingw$ARCH external/mingw-${{ matrix.target.cpu }}
|
|
||||||
|
|
||||||
- name: Install DLLs dependencies (Windows)
|
|
||||||
if: >
|
if: >
|
||||||
steps.windows-dlls-cache.outputs.cache-hit != 'true' &&
|
steps.windows-dlls-cache.outputs.cache-hit != 'true' &&
|
||||||
runner.os == 'Windows'
|
runner.os == 'Windows'
|
||||||
shell: bash
|
|
||||||
run: |
|
run: |
|
||||||
mkdir -p external
|
mkdir external
|
||||||
curl -L "https://nim-lang.org/download/windeps.zip" -o external/windeps.zip
|
curl -L "https://nim-lang.org/download/windeps.zip" -o external/windeps.zip
|
||||||
7z x -y external/windeps.zip -oexternal/dlls-${{ matrix.target.cpu }}
|
7z x external/windeps.zip -oexternal/dlls
|
||||||
|
|
||||||
- name: Path to cached dependencies (Windows)
|
- name: Path to cached dependencies (Windows)
|
||||||
if: >
|
if: >
|
||||||
runner.os == 'Windows'
|
runner.os == 'Windows'
|
||||||
shell: bash
|
|
||||||
run: |
|
run: |
|
||||||
echo '${{ github.workspace }}'"/external/mingw-${{ matrix.target.cpu }}/bin" >> $GITHUB_PATH
|
echo '${{ github.workspace }}'"/external/dlls" >> $GITHUB_PATH
|
||||||
echo '${{ github.workspace }}'"/external/dlls-${{ matrix.target.cpu }}" >> $GITHUB_PATH
|
|
||||||
|
|
||||||
- name: Get latest nimbus-build-system commit hash
|
- name: Derive environment variables
|
||||||
id: versions
|
|
||||||
shell: bash
|
|
||||||
run: |
|
run: |
|
||||||
getHash() {
|
|
||||||
git ls-remote "https://github.com/$1" "${2:-HEAD}" | cut -f 1
|
|
||||||
}
|
|
||||||
nbsHash=$(getHash status-im/nimbus-build-system)
|
|
||||||
echo "::set-output name=nimbus_build_system::$nbsHash"
|
|
||||||
|
|
||||||
- name: Restore prebuilt Nim from cache
|
|
||||||
id: nim-cache
|
|
||||||
uses: actions/cache@v2
|
|
||||||
with:
|
|
||||||
path: NimBinaries
|
|
||||||
key: 'NimBinaries-${{ matrix.target.os }}-${{ matrix.target.cpu }}-${{ steps.versions.outputs.nimbus_build_system }}'
|
|
||||||
|
|
||||||
- name: Build Nim and associated tools
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
curl -O -L -s -S https://raw.githubusercontent.com/status-im/nimbus-build-system/master/scripts/build_nim.sh
|
|
||||||
if [[ '${{ matrix.target.cpu }}' == 'amd64' ]]; then
|
if [[ '${{ matrix.target.cpu }}' == 'amd64' ]]; then
|
||||||
PLATFORM=x64
|
PLATFORM=x64
|
||||||
else
|
else
|
||||||
PLATFORM=x86
|
PLATFORM=x86
|
||||||
fi
|
fi
|
||||||
if [[ '${{ matrix.target.os }}' == 'windows' ]]; then
|
echo "PLATFORM=$PLATFORM" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
ncpu=
|
||||||
|
MAKE_CMD="make"
|
||||||
|
case '${{ runner.os }}' in
|
||||||
|
'Linux')
|
||||||
|
ncpu=$(nproc)
|
||||||
|
;;
|
||||||
|
'macOS')
|
||||||
|
ncpu=$(sysctl -n hw.ncpu)
|
||||||
|
;;
|
||||||
|
'Windows')
|
||||||
|
ncpu=$NUMBER_OF_PROCESSORS
|
||||||
MAKE_CMD="mingw32-make"
|
MAKE_CMD="mingw32-make"
|
||||||
else
|
;;
|
||||||
MAKE_CMD="make"
|
esac
|
||||||
fi
|
[[ -z "$ncpu" || $ncpu -le 0 ]] && ncpu=1
|
||||||
env MAKE="$MAKE_CMD -j2" ARCH_OVERRIDE=$PLATFORM CC=gcc bash build_nim.sh nim csources dist/nimble NimBinaries
|
echo "ncpu=$ncpu" >> $GITHUB_ENV
|
||||||
|
echo "MAKE_CMD=${MAKE_CMD}" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Build Nim and Nimble
|
||||||
|
run: |
|
||||||
|
curl -O -L -s -S https://raw.githubusercontent.com/status-im/nimbus-build-system/master/scripts/build_nim.sh
|
||||||
|
env MAKE="${MAKE_CMD} -j${ncpu}" ARCH_OVERRIDE=${PLATFORM} NIM_COMMIT=${{ matrix.branch }} \
|
||||||
|
QUICK_AND_DIRTY_COMPILER=1 QUICK_AND_DIRTY_NIMBLE=1 CC=gcc \
|
||||||
|
bash build_nim.sh nim csources dist/nimble NimBinaries
|
||||||
echo '${{ github.workspace }}/nim/bin' >> $GITHUB_PATH
|
echo '${{ github.workspace }}/nim/bin' >> $GITHUB_PATH
|
||||||
|
|
||||||
- name: Run nim-serialization tests
|
- name: Run tests
|
||||||
shell: bash
|
|
||||||
working-directory: nim-serialization
|
|
||||||
run: |
|
run: |
|
||||||
|
if [[ "${{ matrix.target.os }}" == "windows" ]]; then
|
||||||
|
# https://github.com/status-im/nimbus-eth2/issues/3121
|
||||||
|
export NIMFLAGS="-d:nimRawSetjmp"
|
||||||
|
fi
|
||||||
|
nim --version
|
||||||
|
nimble --version
|
||||||
nimble install -y --depsOnly
|
nimble install -y --depsOnly
|
||||||
nimble test
|
nimble test
|
||||||
|
|
|
@ -13,6 +13,6 @@ requires "nim >= 1.2.0",
|
||||||
"stew"
|
"stew"
|
||||||
|
|
||||||
task test, "Run all tests":
|
task test, "Run all tests":
|
||||||
let common_args = "c -r -f --hints:off --skipParentCfg --styleCheck:usages --styleCheck:error"
|
let common_args = "c -r -f --hints:off --skipParentCfg --styleCheck:usages --styleCheck:error " & getEnv("NIMFLAGS")
|
||||||
exec "nim " & common_args & " --threads:off tests/test_all"
|
exec "nim " & common_args & " --threads:off tests/test_all"
|
||||||
exec "nim " & common_args & " --threads:on tests/test_all"
|
exec "nim " & common_args & " --threads:on tests/test_all"
|
||||||
|
|
|
@ -182,7 +182,8 @@ macro customSerialization*(field: untyped, definition): untyped =
|
||||||
template readFieldIMPL[Reader](field: type FieldTag,
|
template readFieldIMPL[Reader](field: type FieldTag,
|
||||||
reader: var Reader): untyped =
|
reader: var Reader): untyped =
|
||||||
mixin readValue
|
mixin readValue
|
||||||
reader.readValue(field.FieldType)
|
{.gcsafe.}: # needed by Nim-1.6
|
||||||
|
reader.readValue(field.FieldType)
|
||||||
|
|
||||||
template writeFieldIMPL*[Writer](writer: var Writer,
|
template writeFieldIMPL*[Writer](writer: var Writer,
|
||||||
fieldTag: type FieldTag,
|
fieldTag: type FieldTag,
|
||||||
|
|
Loading…
Reference in New Issue