CI: test with multiple Nim versions (#114)

* CI: test with multiple Nim versions
This commit is contained in:
Ștefan Talpalaru 2022-01-12 03:20:04 +01:00 committed by GitHub
parent 036c71d06a
commit e17113fb31
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 101 additions and 123 deletions

View File

@ -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,32 @@ 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 }}
steps: steps:
- name: Checkout nim-stint - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
with:
path: nim-stint
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 +67,94 @@ 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://github.com/brechtsanders/winlibs_mingw/releases/download/11.2.0-12.0.1-9.0.0-r1/winlibs-x86_64-posix-seh-gcc-11.2.0-mingw-w64-9.0.0-r1.7z"
ARCH=64
else
MINGW_URL="https://github.com/brechtsanders/winlibs_mingw/releases/download/11.2.0-12.0.1-9.0.0-r1/winlibs-i686-posix-dwarf-gcc-11.2.0-mingw-w64-9.0.0-r1.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
MAKE_CMD="mingw32-make"
else ncpu=
MAKE_CMD="make" MAKE_CMD="make"
fi case '${{ runner.os }}' in
env MAKE="$MAKE_CMD -j2" ARCH_OVERRIDE=$PLATFORM CC=gcc bash build_nim.sh nim csources dist/nimble NimBinaries 'Linux')
ncpu=$(nproc)
;;
'macOS')
ncpu=$(sysctl -n hw.ncpu)
;;
'Windows')
ncpu=$NUMBER_OF_PROCESSORS
MAKE_CMD="mingw32-make"
;;
esac
[[ -z "$ncpu" || $ncpu -le 0 ]] && ncpu=1
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-stint tests - name: Run tests
shell: bash
working-directory: nim-stint
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 install -y https://github.com/alehander42/nim-quicktest ttmath
env TEST_LANG="c" nimble test
#env TEST_LANG="cpp" nimble test

View File

@ -11,56 +11,29 @@ requires "nim >= 0.19",
"stew" "stew"
#, "https://github.com/alehander42/nim-quicktest >= 0.18.0", "https://github.com/status-im/nim-ttmath" #, "https://github.com/alehander42/nim-quicktest >= 0.18.0", "https://github.com/status-im/nim-ttmath"
proc test(name: string, lang: string = "c") = proc test(args, path: string) =
if not dirExists "build": if not dirExists "build":
mkDir "build" mkDir "build"
--run exec "nim " & getEnv("TEST_LANG", "c") & " " & getEnv("NIMFLAGS") & " " & args &
switch("out", ("./build/" & name)) " --outdir:build -r --hints:off --warnings:off --skipParentCfg " & path
setCommand lang, "tests/" & name & ".nim"
task test_internal_debug, "Run tests for internal procs - test implementation (StUint[64] = 2x uint32":
switch("define", "stint_test")
test "internal"
task test_internal_release, "Run tests for internal procs - prod implementation (StUint[64] = uint64":
test "internal"
task test_debug, "Run all tests - test implementation (StUint[64] = 2x uint32":
switch("define", "stint_test")
test "all_tests"
task test_release, "Run all tests - prod implementation (StUint[64] = uint64":
test "all_tests"
task test_property_debug, "Run random tests (debug mode) - test implementation (StUint[64] = 2x uint32)":
requires "https://github.com/alehander42/nim-quicktest >= 0.18.0"
switch("define", "stint_test")
test "property_based"
task test_property_release, "Run random tests (release mode) - test implementation (StUint[64] = 2x uint32)":
requires "https://github.com/alehander42/nim-quicktest >= 0.18.0"
switch("define", "stint_test")
switch("define", "release")
test "property_based"
task test_property_uint256_debug, "Run random tests Uint256 (debug mode) vs TTMath (StUint[256] = 8 x uint32)":
# TODO: another reference implementation?
requires "https://github.com/alehander42/nim-quicktest >= 0.18.0", "https://github.com/status-im/nim-ttmath"
test "property_based", "cpp"
task test_property_uint256_release, "Run random tests Uint256 (release mode) vs TTMath (StUint[256] = 4 x uint64)":
# TODO: another reference implementation?
requires "https://github.com/alehander42/nim-quicktest >= 0.18.0", "https://github.com/status-im/nim-ttmath"
switch("define", "release")
test "property_based", "cpp"
task test, "Run all tests - test and production implementation": task test, "Run all tests - test and production implementation":
exec "nimble test_internal_debug" # Run tests for internal procs - test implementation (StUint[64] = 2x uint32
exec "nimble test_internal_release" test "-d:stint_test", "tests/internal.nim"
exec "nimble test_debug" # Run tests for internal procs - prod implementation (StUint[64] = uint64
exec "nimble test_release" test "", "tests/internal.nim"
## TODO test only requirements don't work: https://github.com/nim-lang/nimble/issues/482 # Run all tests - test implementation (StUint[64] = 2x uint32
# exec "nimble test_property_debug" test "-d:stint_test", "tests/all_tests.nim"
# exec "nimble test_property_release" # Run all tests - prod implementation (StUint[64] = uint64
# exec "nimble test_property_uint256_debug" test "--threads:on", "tests/all_tests.nim"
# exec "nimble test_property_uint256_release"
## quicktest-0.20.0/quicktest.nim(277, 30) Error: cannot evaluate at compile time: BUILTIN_NAMES
##
# # Run random tests (debug mode) - test implementation (StUint[64] = 2x uint32)
# test "-d:stint_test", "tests/property_based.nim"
# # Run random tests (release mode) - test implementation (StUint[64] = 2x uint32)
# test "-d:stint_test -d:release", "tests/property_based.nim"
# # Run random tests Uint256 (debug mode) vs TTMath (StUint[256] = 8 x uint32)
# test "", "tests/property_based.nim"
# # Run random tests Uint256 (release mode) vs TTMath (StUint[256] = 4 x uint64)
# test "-d:release", "tests/property_based.nim"

View File

@ -1,3 +0,0 @@
# Ensure code is ready for threads..
--threads:on