From 2b3195518d613685b8fcb27f166d991041ee78df Mon Sep 17 00:00:00 2001 From: "Michael Bradley, Jr" Date: Sun, 3 Jul 2022 21:37:34 -0500 Subject: [PATCH] ci: update GitHub Actions CI workflow to use msys2/setup-msys2@v2 Main goal is to update the nim-codex CI workflow to use the [`msys2/setup-msys2@v2`][setmsys2] GitHub Action, as used by the [nimbus-eth2 workflow][ne2w] per changes made to it several months ago. The `msys2/setup-msys2@v2` action has been used by other Status-org projects prior to this commit, e.g. nim-leopard, nim-datastore, nim-status. A fix is included for the failing macOS builds, related to [actions/virtual-environments#5819][ave5819]. See [L151][L151]. All builds [succeed][succeed] (with build arch-targets verified as far as possible via `ldd`, `otool`, `ntldd`), including `linux-i386` and `windows-i386`, though the `i386` builds are presently disabled (commented out). The `i386` builds can be enabled simply by uncommenting: ``` # - os: linux # cpu: i386 ... # - os: windows # cpu: i386 ``` The resulting `.github/workflows/ci.yml` is a "remix" of the current workflows for nimbus-eth2 and nim-codex (i.e. prior to this commit) along with techniques learned from developing workflows for other Status-org repos. Some comments and code-reorg help to clarify/explain what's done in the `Derive environment variables` step. `-d:limitStackUsage` has been adopted for `linux-amd64` builds from [nimbus-eth2's workflow][ne2wL155] and [related code][ne2config] has been copied into `config.nims` `-d:limitStackUsage` can easily be dropped if it's not desirable for Codex. Build targets use `-latest` for `runs-on`, i.e. `macos-latest`, `ubuntu-latest`, `windows-latest`. Through a combination of local testing and iterative pushes to GitHub, the workflow's embedded Bash scripts have been revised to include only the necessary steps for all builds to succeed, including `linux-i386` and `windows-i386`. The GitHub Actions workflow `.github/workflows/codecov.yml` has been removed, while coverage data generation/upload steps have been added to `.github/workflows/ci.yml` as the final steps conditional on `if: runner.os == 'Linux' && matrix.target.cpu == 'amd64' && matrix.nim_branch == matrix.cov_branch`. A redundant `--passC:'-m32 -mno-adx'` is used for `linux-i386` builds; the redundant flags do not affect the build, but can be helpful when eyeballing GitHub Actions builds with increased compile-time verbosity. Some variable expansions used in `github/workflows/ci.yml` could result in compilation failures if related paths include whitespace. It's not a problem for this commit but could be a problem for a user copy-pasting from the workflow; solving that problem is left as an exercise for the reader. [setmsys2]: https://github.com/msys2/setup-msys2#readme [ne2w]: https://github.com/status-im/nimbus-eth2/blob/stable/.github/workflows/ci.yml [ave5819]: https://github.com/actions/virtual-environments/pull/5819 [L151]: https://github.com/status-im/nim-codex/blob/ci/msys2/.github/workflows/ci.yml#L151 [succeed]: https://github.com/status-im/nim-codex/actions/runs/2606854455 [ne2wL155]: https://github.com/status-im/nimbus-eth2/blob/stable/.github/workflows/ci.yml#L155-L159 [ne2config]: https://github.com/status-im/nimbus-eth2/blob/stable/config.nims#L43-L49 --- .github/workflows/ci.yml | 327 ++++++++++++++++++---------------- .github/workflows/codecov.yml | 224 ----------------------- Makefile | 6 +- config.nims | 8 + 4 files changed, 183 insertions(+), 382 deletions(-) delete mode 100644 .github/workflows/codecov.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bc1ca755..1d13dfa0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,54 +10,155 @@ jobs: build: strategy: fail-fast: false - max-parallel: 20 matrix: - branch: [v1.2.18, v1.6.6] + cache_nonce: [ 0 ] # Allows for easily busting actions/cache caches target: - # Unit tests - os: linux cpu: amd64 - TEST_KIND: unit-tests + # - os: linux + # cpu: i386 - os: macos cpu: amd64 - TEST_KIND: unit-tests - os: windows cpu: amd64 - TEST_KIND: unit-tests + # - os: windows + # cpu: i386 + nim_branch: [version-1-2, version-1-6] + cov_branch: [version-1-6] include: - target: os: linux - builder: ubuntu-18.04 + builder: ubuntu-latest + shell: bash --noprofile --norc -eo pipefail - target: os: macos - builder: macos-10.15 + builder: macos-latest + shell: bash --noprofile --norc -eo pipefail - target: os: windows - builder: windows-2019 - name: '${{ matrix.target.os }}-${{ matrix.target.cpu }}-${{ matrix.branch }}' + builder: windows-latest + shell: msys2 + + defaults: + run: + shell: ${{ matrix.shell }} {0} + + name: '${{ matrix.target.os }}-${{ matrix.target.cpu }} (Nim ${{ matrix.nim_branch }})' runs-on: ${{ matrix.builder }} - timeout-minutes: 60 + timeout-minutes: 80 steps: - - name: Checkout nim-codex - uses: actions/checkout@v2 + - name: Checkout sources + uses: actions/checkout@v3 + + - name: APT (Linux amd64) + if: runner.os == 'Linux' && matrix.target.cpu == 'amd64' + run: | + sudo apt-fast update -qq + sudo DEBIAN_FRONTEND='noninteractive' apt-fast install \ + --no-install-recommends -yq lcov + + - name: APT (Linux i386) + if: runner.os == 'Linux' && matrix.target.cpu == 'i386' + run: | + sudo dpkg --add-architecture i386 + sudo apt-fast update -qq + sudo DEBIAN_FRONTEND='noninteractive' apt-fast install \ + --no-install-recommends -yq gcc-multilib g++-multilib + + - name: Homebrew (macOS) + if: runner.os == 'macOS' + run: | + brew install libomp + + - name: MSYS2 (Windows amd64) + if: runner.os == 'Windows' && matrix.target.cpu == 'amd64' + uses: msys2/setup-msys2@v2 with: - path: nim-codex - submodules: true + msystem: UCRT64 + install: > + base-devel + git + mingw-w64-ucrt-x86_64-toolchain + mingw-w64-ucrt-x86_64-cmake + mingw-w64-ucrt-x86_64-ntldd-git + + - name: MSYS2 (Windows i386) + if: runner.os == 'Windows' && matrix.target.cpu == 'i386' + uses: msys2/setup-msys2@v2 + with: + msystem: MINGW32 + install: > + base-devel + git + mingw-w64-i686-toolchain + mingw-w64-i686-cmake + mingw-w64-i686-ntldd-git - name: Derive environment variables - shell: bash run: | + quote () { + local quoted=${1//\'/\'\\\'\'}; + printf "'%s'" "$quoted" + } + if [[ '${{ matrix.target.cpu }}' == 'amd64' ]]; then - ARCH=64 PLATFORM=x64 else - ARCH=32 PLATFORM=x86 fi - echo "ARCH=$ARCH" >> $GITHUB_ENV - echo "PLATFORM=$PLATFORM" >> $GITHUB_ENV - ncpu= - ext= + echo "PLATFORM=${PLATFORM}" >> ${GITHUB_ENV} + + # Stack usage on Linux amd64 + if [[ '${{ runner.os }}' == 'Linux' && '${{ matrix.target.cpu }}' == 'amd64' ]]; then + NIMFLAGS="${NIMFLAGS} -d:limitStackUsage" + echo "NIMFLAGS=${NIMFLAGS}" >> $GITHUB_ENV + fi + + # Disable ADX on Linux i386 + if [[ '${{ runner.os }}' == 'Linux' && '${{ matrix.target.cpu }}' == 'i386' ]]; then + CFLAGS="${CFLAGS} -m32 -mno-adx" + echo "CFLAGS=${CFLAGS}" >> ${GITHUB_ENV} + CXXFLAGS="${CXXFLAGS} -m32 -mno-adx" + echo "CXXFLAGS=${CXXFLAGS}" >> ${GITHUB_ENV} + mkdir -p external/bin + cat << EOF > external/bin/gcc + #!/bin/bash + exec $(which gcc) -m32 -mno-adx "\$@" + EOF + cat << EOF > external/bin/g++ + #!/bin/bash + exec $(which g++) -m32 -mno-adx "\$@" + EOF + chmod 755 external/bin/gcc external/bin/g++ + echo "$(pwd)/external/bin" >> ${GITHUB_PATH} + NIMFLAGS="${NIMFLAGS} $(quote "--passC:'-m32 -mno-adx' -d:LeopardCmakeFlags='-DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=$(pwd)/external/bin/gcc -DCMAKE_CXX_COMPILER=$(pwd)/external/bin/g++'")" + echo "NIMFLAGS=${NIMFLAGS}" >> $GITHUB_ENV + fi + + # Disable ADX on Windows i386 + if [[ '${{ runner.os }}' == 'Windows' && '${{ matrix.target.cpu }}' == 'i386' ]]; then + CFLAGS="${CFLAGS} -mno-adx" + echo "CFLAGS=${CFLAGS}" >> ${GITHUB_ENV} + CXXFLAGS="${CXXFLAGS} -mno-adx" + echo "CXXFLAGS=${CXXFLAGS}" >> ${GITHUB_ENV} + NIMFLAGS="${NIMFLAGS} --passC:-mno-adx" + echo "NIMFLAGS=${NIMFLAGS}" >> $GITHUB_ENV + fi + + # Enable OpenMP on macOS + if [[ '${{ runner.os }}' == 'macOS' ]]; then + libomp_lib_dir="$(brew --prefix)/opt/libomp/lib" + llvm_dir="$(ls -d $(brew --prefix)/opt/llvm* | tail -1)" + llvm_bin_dir="${llvm_dir}/bin" + llvm_lib_dir="${llvm_dir}/lib" + echo "${llvm_bin_dir}" >> ${GITHUB_PATH} + echo "LDFLAGS=${LDFLAGS} -L${libomp_lib_dir} -L${llvm_lib_dir} -Wl,-rpath,${llvm_lib_dir}" >> ${GITHUB_ENV} + NIMFLAGS="${NIMFLAGS} $(quote "-d:LeopardCmakeFlags='-DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=${llvm_bin_dir}/clang -DCMAKE_CXX_COMPILER=${llvm_bin_dir}/clang++' -d:LeopardExtraCompilerlags='-fopenmp' -d:LeopardExtraLinkerFlags='-fopenmp -L${libomp_lib_dir}'")" + echo "NIMFLAGS=${NIMFLAGS}" >> $GITHUB_ENV + fi + + # Use all available CPUs for build process + ncpu="" case '${{ runner.os }}' in 'Linux') ncpu=$(nproc) @@ -66,155 +167,69 @@ jobs: ncpu=$(sysctl -n hw.ncpu) ;; 'Windows') - ncpu=$NUMBER_OF_PROCESSORS - ext=.exe + ncpu=${NUMBER_OF_PROCESSORS} ;; esac [[ -z "$ncpu" || $ncpu -le 0 ]] && ncpu=1 - echo "ncpu=$ncpu" >> $GITHUB_ENV - echo "ext=$ext" >> $GITHUB_ENV + echo "ncpu=${ncpu}" >> ${GITHUB_ENV} - - name: Install build dependencies (Linux i386) - if: runner.os == 'Linux' && matrix.target.cpu == 'i386' - run: | - sudo dpkg --add-architecture i386 - sudo apt-get update -qq - sudo DEBIAN_FRONTEND='noninteractive' apt-get install \ - --no-install-recommends -yq gcc-multilib g++-multilib \ - libssl-dev:i386 - mkdir -p external/bin - cat << EOF > external/bin/gcc - #!/bin/bash - exec $(which gcc) -m32 "\$@" - EOF - cat << EOF > external/bin/g++ - #!/bin/bash - exec $(which g++) -m32 "\$@" - EOF - chmod 755 external/bin/gcc external/bin/g++ - echo '${{ github.workspace }}/external/bin' >> $GITHUB_PATH - NIMFLAGS="-d:LeopardCmakeFlags='-DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS=-m32 -DCMAKE_CXX_FLAGS=-m32'" - quote () { - local quoted=${1//\'/\'\\\'\'}; - printf "'%s'" "$quoted" - } - echo "NIMFLAGS=$(quote "${NIMFLAGS}")" >> $GITHUB_ENV - - - name: Install build dependencies (macOS) - if: runner.os == 'macOS' - run: | - brew install libomp - echo "$(brew --prefix)/opt/llvm/bin" >> $GITHUB_PATH - echo "LDFLAGS=-L$(brew --prefix)/opt/libomp/lib -L$(brew --prefix)/opt/llvm/lib -Wl,-rpath,$(brew --prefix)/opt/llvm/lib" >> $GITHUB_ENV - NIMFLAGS="-d:LeopardCmakeFlags='-DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=$(brew --prefix)/opt/llvm/bin/clang -DCMAKE_CXX_COMPILER=$(brew --prefix)/opt/llvm/bin/clang++' -d:LeopardExtraCompilerlags='-fopenmp' -d:LeopardExtraLinkerFlags='-fopenmp -L$(brew --prefix)/opt/libomp/lib'" - quote () { - local quoted=${1//\'/\'\\\'\'}; - printf "'%s'" "$quoted" - } - echo "NIMFLAGS=$(quote "${NIMFLAGS}")" >> $GITHUB_ENV - - - name: Restore MinGW-W64 (Windows) from cache - if: runner.os == 'Windows' - id: windows-mingw-cache - uses: actions/cache@v2 - with: - path: external/mingw-${{ matrix.target.cpu }} - key: 'mingw-${{ matrix.target.cpu }}' - - - name: Restore Nim DLLs dependencies (Windows) from cache - if: runner.os == 'Windows' - id: windows-dlls-cache - uses: actions/cache@v2 - with: - path: external/dlls-${{ matrix.target.cpu }} - key: 'dlls-${{ matrix.target.cpu }}' - - - name: Install MinGW64 dependency (Windows) - if: > - steps.windows-mingw-cache.outputs.cache-hit != 'true' && - runner.os == 'Windows' - shell: bash - run: | - mkdir -p external - curl -L "https://nim-lang.org/download/mingw$ARCH.7z" -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: > - steps.windows-dlls-cache.outputs.cache-hit != 'true' && - runner.os == 'Windows' - shell: bash - run: | - mkdir -p external - curl -L "https://nim-lang.org/download/windeps.zip" -o external/windeps.zip - 7z x -y external/windeps.zip -oexternal/dlls-${{ matrix.target.cpu }} - - - name: Path to cached dependencies (Windows) - if: > - runner.os == 'Windows' - shell: bash - run: | - echo "${{ github.workspace }}/external/mingw-${{ matrix.target.cpu }}/bin" >> $GITHUB_PATH - echo "${{ github.workspace }}/external/dlls-${{ matrix.target.cpu }}" >> $GITHUB_PATH - - - name: Setup environment - shell: bash - run: echo '${{ github.workspace }}/nim/bin' >> $GITHUB_PATH - - - name: Get latest nimbus-build-system commit hash - id: versions - shell: bash - 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 binaries from cache + - name: Restore Nim toolchain binaries from cache id: nim-cache - uses: actions/cache@v2 + uses: actions/cache@v3 with: - path: nim-codex/NimBinaries - key: 'nim-${{ matrix.branch }}-${{ matrix.target.os }}-${{ matrix.target.cpu }}-${{ steps.versions.outputs.nimbus_build_system }}' - - - name: Install NodeJS - uses: actions/setup-node@v2 - with: - node-version: '14' + path: NimBinaries + key: ${{ matrix.target.os }}-${{ matrix.target.cpu }}-nim-${{ matrix.nim_branch }}-cache_nonce:${{ matrix.cache_nonce }} - name: Build Nim and Codex dependencies - shell: bash - working-directory: nim-codex run: | - if [[ "${{ runner.os }}" == "macOS" ]]; then - ulimit -n 1024 - fi - make -j$ncpu ARCH_OVERRIDE=$PLATFORM CI_CACHE=NimBinaries NIM_COMMIT="${{ matrix.branch }}" QUICK_AND_DIRTY_COMPILER=1 update + make -j${ncpu} CI_CACHE=NimBinaries NIM_COMMIT=${{ matrix.nim_branch }} ARCH_OVERRIDE=${PLATFORM} QUICK_AND_DIRTY_COMPILER=1 update + echo + ./env.sh nim --version - - name: Start Ethereum Node with Codex contracts - shell: bash - working-directory: nim-codex/vendor/dagger-contracts + # Rely on NodeJS LTS installed in GitHub Actions virtual environments + - name: Start Ethereum node with Codex contracts + working-directory: vendor/dagger-contracts run: | + if [[ '${{ runner.os }}' == 'Windows' ]]; then + export PATH="/c/Program Files/nodejs:${PATH}" + export PATH="$(cygpath -u "$(npm --location=global prefix 2>/dev/null)"):${PATH}" + fi + echo node --version + node --version + echo npm --version + npm --version 2>/dev/null + echo npm install npm start & - - name: Run nim-codex tests - shell: bash - working-directory: nim-codex + - name: Build and run Codex tests run: | - ./env.sh nim --version + make -j${ncpu} NIM_COMMIT="${{ matrix.nim_branch }}" testAll echo - make NIM_COMMIT="${{ matrix.branch }}" testAll - if [[ ${{ runner.os }} = macOS ]]; then - echo - echo otool -L build/testCodex - otool -L build/testCodex + if [[ '${{ runner.os }}' == macOS ]]; then + echo otool -L build/codex + otool -L build/codex + elif [[ '${{ runner.os }}' == 'Windows' ]]; then + echo ntldd build/codex + ntldd build/codex else - echo - echo ldd build/testCodex - ldd build/testCodex + echo ldd build/codex + ldd build/codex fi - echo "Testing TRACE log level" - ./env.sh nim c -d:chronicles_log_level=TRACE codex.nim + + - name: Generate coverage data (Linux amd64, Nim ${{ matrix.cov_branch }}) + if: runner.os == 'Linux' && matrix.target.cpu == 'amd64' && matrix.nim_branch == matrix.cov_branch + run: | + rm -rf build nimcache + make -j${ncpu} NIM_COMMIT="${{ matrix.nim_branch }}" coverage + + - name: Upload coverage data to Codecov (Linux amd64, Nim ${{ matrix.cov_branch }}) + if: runner.os == 'Linux' && matrix.target.cpu == 'amd64' && matrix.nim_branch == matrix.cov_branch + uses: codecov/codecov-action@v3 + with: + directory: ./coverage/ + fail_ci_if_error: true + files: ./coverage/coverage.f.info + flags: unittests + name: codecov-umbrella + verbose: true diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml deleted file mode 100644 index c530c659..00000000 --- a/.github/workflows/codecov.yml +++ /dev/null @@ -1,224 +0,0 @@ -name: Coverage -on: - push: - branches: - - main - pull_request: - workflow_dispatch: - -jobs: - build: - strategy: - fail-fast: false - max-parallel: 20 - matrix: - branch: [v1.6.6] - target: - # Unit tests - - os: linux - cpu: amd64 - TEST_KIND: unit-tests - # - os: macos - # cpu: amd64 - # TEST_KIND: unit-tests - # - os: windows - # cpu: amd64 - # TEST_KIND: unit-tests - include: - - target: - os: linux - builder: ubuntu-18.04 - # - target: - # os: macos - # builder: macos-10.15 - # - target: - # os: windows - # builder: windows-2019 - name: '${{ matrix.target.os }}-${{ matrix.target.cpu }}-${{ matrix.branch }}' - runs-on: ${{ matrix.builder }} - steps: - - name: Checkout nim-codex - uses: actions/checkout@v2 - with: - path: nim-codex - submodules: true - - - name: Derive environment variables - shell: bash - run: | - if [[ '${{ matrix.target.cpu }}' == 'amd64' ]]; then - ARCH=64 - PLATFORM=x64 - else - ARCH=32 - PLATFORM=x86 - fi - echo "ARCH=$ARCH" >> $GITHUB_ENV - echo "PLATFORM=$PLATFORM" >> $GITHUB_ENV - ncpu= - ext= - case '${{ runner.os }}' in - 'Linux') - ncpu=$(nproc) - ;; - 'macOS') - ncpu=$(sysctl -n hw.ncpu) - ;; - 'Windows') - ncpu=$NUMBER_OF_PROCESSORS - ext=.exe - ;; - esac - [[ -z "$ncpu" || $ncpu -le 0 ]] && ncpu=1 - echo "ncpu=$ncpu" >> $GITHUB_ENV - echo "ext=$ext" >> $GITHUB_ENV - - - name: Install coverage dependencies (Linux) - if: runner.os == 'Linux' - run: | - sudo apt-get update - sudo apt-get install -y lcov - - - name: Install build dependencies (Linux i386) - if: runner.os == 'Linux' && matrix.target.cpu == 'i386' - run: | - sudo dpkg --add-architecture i386 - sudo apt-get update -qq - sudo DEBIAN_FRONTEND='noninteractive' apt-get install \ - --no-install-recommends -yq gcc-multilib g++-multilib \ - libssl-dev:i386 - mkdir -p external/bin - cat << EOF > external/bin/gcc - #!/bin/bash - exec $(which gcc) -m32 "\$@" - EOF - cat << EOF > external/bin/g++ - #!/bin/bash - exec $(which g++) -m32 "\$@" - EOF - chmod 755 external/bin/gcc external/bin/g++ - echo '${{ github.workspace }}/external/bin' >> $GITHUB_PATH - NIMFLAGS="-d:LeopardCmakeFlags='-DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS=-m32 -DCMAKE_CXX_FLAGS=-m32'" - quote () { - local quoted=${1//\'/\'\\\'\'}; - printf "'%s'" "$quoted" - } - echo "NIMFLAGS=$(quote "${NIMFLAGS}")" >> $GITHUB_ENV - - - name: Install build dependencies (macOS) - if: runner.os == 'macOS' - run: | - brew install libomp - echo "$(brew --prefix)/opt/llvm/bin" >> $GITHUB_PATH - echo "LDFLAGS=-L$(brew --prefix)/opt/libomp/lib -L$(brew --prefix)/opt/llvm/lib -Wl,-rpath,$(brew --prefix)/opt/llvm/lib" >> $GITHUB_ENV - NIMFLAGS="-d:LeopardCmakeFlags='-DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=$(brew --prefix)/opt/llvm/bin/clang -DCMAKE_CXX_COMPILER=$(brew --prefix)/opt/llvm/bin/clang++' -d:LeopardExtraCompilerlags='-fopenmp' -d:LeopardExtraLinkerFlags='-fopenmp -L$(brew --prefix)/opt/libomp/lib'" - quote () { - local quoted=${1//\'/\'\\\'\'}; - printf "'%s'" "$quoted" - } - echo "NIMFLAGS=$(quote "${NIMFLAGS}")" >> $GITHUB_ENV - - - name: Restore MinGW-W64 (Windows) from cache - if: runner.os == 'Windows' - id: windows-mingw-cache - uses: actions/cache@v2 - with: - path: external/mingw-${{ matrix.target.cpu }} - key: 'mingw-${{ matrix.target.cpu }}' - - - name: Restore Nim DLLs dependencies (Windows) from cache - if: runner.os == 'Windows' - id: windows-dlls-cache - uses: actions/cache@v2 - with: - path: external/dlls-${{ matrix.target.cpu }} - key: 'dlls-${{ matrix.target.cpu }}' - - - name: Install MinGW64 dependency (Windows) - if: > - steps.windows-mingw-cache.outputs.cache-hit != 'true' && - runner.os == 'Windows' - shell: bash - run: | - mkdir -p external - curl -L "https://nim-lang.org/download/mingw$ARCH.7z" -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: > - steps.windows-dlls-cache.outputs.cache-hit != 'true' && - runner.os == 'Windows' - shell: bash - run: | - mkdir -p external - curl -L "https://nim-lang.org/download/windeps.zip" -o external/windeps.zip - 7z x -y external/windeps.zip -oexternal/dlls-${{ matrix.target.cpu }} - - - name: Path to cached dependencies (Windows) - if: > - runner.os == 'Windows' - shell: bash - run: | - echo "${{ github.workspace }}/external/mingw-${{ matrix.target.cpu }}/bin" >> $GITHUB_PATH - echo "${{ github.workspace }}/external/dlls-${{ matrix.target.cpu }}" >> $GITHUB_PATH - - - name: Setup environment - shell: bash - run: echo '${{ github.workspace }}/nim/bin' >> $GITHUB_PATH - - - name: Get latest nimbus-build-system commit hash - id: versions - shell: bash - 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 binaries from cache - id: nim-cache - uses: actions/cache@v2 - with: - path: nim-codex/NimBinaries - key: 'nim-${{ matrix.branch }}-${{ matrix.target.os }}-${{ matrix.target.cpu }}-${{ steps.versions.outputs.nimbus_build_system }}' - - - name: Install NodeJS - uses: actions/setup-node@v2 - with: - node-version: '14' - - - name: Build Nim and Codex dependencies - shell: bash - working-directory: nim-codex - run: | - if [[ "${{ runner.os }}" == "macOS" ]]; then - ulimit -n 1024 - fi - make -j$ncpu ARCH_OVERRIDE=$PLATFORM CI_CACHE=NimBinaries NIM_COMMIT="${{ matrix.branch }}" QUICK_AND_DIRTY_COMPILER=1 update - - - name: Start Ethereum Node with Codex contracts - shell: bash - working-directory: nim-codex/vendor/dagger-contracts - run: | - npm install - npm start & - - - name: Run nim-codex tests and generate coverage data - shell: bash - working-directory: nim-codex - run: | - ./env.sh nim --version - echo - make NIM_COMMIT="${{ matrix.branch }}" coverage - - - name: Upload coverage to Codecov - uses: codecov/codecov-action@v2 - with: - directory: ./nim-codex/coverage/ - fail_ci_if_error: true - files: ./nim-codex/coverage/coverage.f.info - flags: unittests - name: codecov-umbrella - verbose: true diff --git a/Makefile b/Makefile index 6ff3c20d..56164341 100644 --- a/Makefile +++ b/Makefile @@ -110,11 +110,13 @@ else endif coverage: - $(MAKE) NIMFLAGS="--lineDir:on --passC:-fprofile-arcs --passC:-ftest-coverage --passL:-fprofile-arcs --passL:-ftest-coverage" testAll + $(MAKE) NIMFLAGS="$(NIMFLAGS) --lineDir:on --passC:-fprofile-arcs --passC:-ftest-coverage --passL:-fprofile-arcs --passL:-ftest-coverage" testAll + cd nimcache/release/codex && rm -f *.c cd nimcache/release/testCodex && rm -f *.c cd nimcache/release/testContracts && rm -f *.c + cd nimcache/release/testIntegration && rm -f *.c mkdir -p coverage - lcov --capture --directory nimcache/release/testCodex --directory nimcache/release/testContracts --output-file coverage/coverage.info + lcov --capture --directory nimcache/release/codex --directory nimcache/release/testCodex --directory nimcache/release/testContracts --directory nimcache/release/testIntegration --output-file coverage/coverage.info shopt -s globstar && ls $$(pwd)/codex/{*,**/*}.nim shopt -s globstar && lcov --extract coverage/coverage.info $$(pwd)/codex/{*,**/*}.nim --output-file coverage/coverage.f.info echo -e $(BUILD_MSG) "coverage/report/index.html" diff --git a/config.nims b/config.nims index eae1e6b0..0523845d 100644 --- a/config.nims +++ b/config.nims @@ -5,6 +5,14 @@ if defined(release): else: switch("nimcache", joinPath(currentSourcePath.parentDir, "nimcache/debug/$projectName")) +if defined(limitStackUsage): + # This limits stack usage of each individual function to 1MB - the option is + # available on some GCC versions but not all - run with `-d:limitStackUsage` + # and look for .su files in "./build/", "./nimcache/" or $TMPDIR that list the + # stack size of each function. + switch("passC", "-fstack-usage -Werror=stack-usage=1048576") + switch("passL", "-fstack-usage -Werror=stack-usage=1048576") + if defined(windows): # https://github.com/nim-lang/Nim/pull/19891 switch("define", "nimRawSetjmp")