From 60103b8258339fbaf1da05fa055a6b440f585a15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C8=98tefan=20Talpalaru?= Date: Tue, 8 Feb 2022 15:33:50 +0100 Subject: [PATCH] CI: test with multiple Nim versions (#133) --- .github/workflows/ci.yml | 70 +++++++++++++++++----------------------- blscurve.nimble | 10 ++---- 2 files changed, 33 insertions(+), 47 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3048627..0d0c3ad 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,11 +1,15 @@ name: CI -on: [pull_request] # [push, pull_request] +on: + push: + branches: + - master + pull_request: + workflow_dispatch: jobs: build: strategy: fail-fast: false - max-parallel: 20 matrix: target: - os: linux @@ -16,9 +20,9 @@ jobs: cpu: amd64 - os: windows cpu: amd64 - - os: windows - cpu: i386 - test_lang: [c] # "cpp" is broken + #- os: windows + #cpu: i386 + branch: [version-1-2, version-1-4, version-1-6, devel] include: - target: os: linux @@ -37,13 +41,13 @@ jobs: run: shell: ${{ matrix.shell }} - name: '${{ matrix.target.os }}-${{ matrix.target.cpu }}-${{ matrix.test_lang }}' + name: '${{ matrix.target.os }}-${{ matrix.target.cpu }} (Nim ${{ matrix.branch }})' runs-on: ${{ matrix.builder }} + continue-on-error: ${{ matrix.branch == 'version-1-6' || matrix.branch == 'devel' }} steps: - - name: Checkout nim-blscurve + - name: Checkout uses: actions/checkout@v2 with: - path: nim-blscurve submodules: true - name: Install build dependencies (Linux i386) @@ -117,16 +121,10 @@ jobs: else PLATFORM=x86 fi - echo "PLATFORM=${PLATFORM}" >> $GITHUB_ENV + echo "PLATFORM=$PLATFORM" >> $GITHUB_ENV - if [[ '${{ matrix.target.os }}' == 'windows' ]]; then - MAKE_CMD="mingw32-make" - else - MAKE_CMD="make" - fi - echo "MAKE_CMD=$MAKE_CMD" >> $GITHUB_ENV - - ncpu='' + ncpu= + MAKE_CMD="make" case '${{ runner.os }}' in 'Linux') ncpu=$(nproc) @@ -135,38 +133,30 @@ jobs: ncpu=$(sysctl -n hw.ncpu) ;; 'Windows') - ncpu=${NUMBER_OF_PROCESSORS} + ncpu=$NUMBER_OF_PROCESSORS + MAKE_CMD="mingw32-make" ;; esac [[ -z "$ncpu" || $ncpu -le 0 ]] && ncpu=1 - echo "ncpu=${ncpu}" >> $GITHUB_ENV + echo "ncpu=$ncpu" >> $GITHUB_ENV + echo "MAKE_CMD=${MAKE_CMD}" >> $GITHUB_ENV - - name: Get latest nimbus-build-system commit hash - id: versions - 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 the Nim compiler + - 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} CC=gcc bash build_nim.sh nim csources dist/nimble NimBinaries + 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 - - name: Run nim-blscurve tests - working-directory: nim-blscurve + - name: Run tests run: | - export BLS_TEST_LANG=${{ matrix.test_lang }} + 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 # Dependencies not declared in "blscurve.nimble" as they are only used # for testing: diff --git a/blscurve.nimble b/blscurve.nimble index 1dc70ec..8e5281f 100644 --- a/blscurve.nimble +++ b/blscurve.nimble @@ -16,15 +16,11 @@ requires "nim >= 1.0.4", "https://github.com/status-im/nim-taskpools.git" ### Helper functions -proc test(env, path: string) = - # Compilation language is controlled by BLS_TEST_LANG - var lang = "c" - if existsEnv"BLS_TEST_LANG": - lang = getEnv"BLS_TEST_LANG" - +proc test(args, path: string) = + # Compilation language is controlled by TEST_LANG if not dirExists "build": mkDir "build" - exec "nim " & lang & " " & env & + exec "nim " & getEnv("TEST_LANG", "c") & " " & getEnv("NIMFLAGS") & " " & args & " --outdir:build -r -f --hints:off --warnings:off --skipParentCfg " & path ### tasks