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
This commit is contained in:
Michael Bradley, Jr 2022-07-03 21:37:34 -05:00 committed by Michael Bradley
parent 8f0bc54fba
commit 2b3195518d
4 changed files with 183 additions and 382 deletions

View File

@ -10,54 +10,155 @@ jobs:
build: build:
strategy: strategy:
fail-fast: false fail-fast: false
max-parallel: 20
matrix: matrix:
branch: [v1.2.18, v1.6.6] cache_nonce: [ 0 ] # Allows for easily busting actions/cache caches
target: target:
# Unit tests
- os: linux - os: linux
cpu: amd64 cpu: amd64
TEST_KIND: unit-tests # - os: linux
# cpu: i386
- os: macos - os: macos
cpu: amd64 cpu: amd64
TEST_KIND: unit-tests
- os: windows - os: windows
cpu: amd64 cpu: amd64
TEST_KIND: unit-tests # - os: windows
# cpu: i386
nim_branch: [version-1-2, version-1-6]
cov_branch: [version-1-6]
include: include:
- target: - target:
os: linux os: linux
builder: ubuntu-18.04 builder: ubuntu-latest
shell: bash --noprofile --norc -eo pipefail
- target: - target:
os: macos os: macos
builder: macos-10.15 builder: macos-latest
shell: bash --noprofile --norc -eo pipefail
- target: - target:
os: windows os: windows
builder: windows-2019 builder: windows-latest
name: '${{ matrix.target.os }}-${{ matrix.target.cpu }}-${{ matrix.branch }}' shell: msys2
defaults:
run:
shell: ${{ matrix.shell }} {0}
name: '${{ matrix.target.os }}-${{ matrix.target.cpu }} (Nim ${{ matrix.nim_branch }})'
runs-on: ${{ matrix.builder }} runs-on: ${{ matrix.builder }}
timeout-minutes: 60 timeout-minutes: 80
steps: steps:
- name: Checkout nim-codex - name: Checkout sources
uses: actions/checkout@v2 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: with:
path: nim-codex msystem: UCRT64
submodules: true 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 - name: Derive environment variables
shell: bash
run: | run: |
quote () {
local quoted=${1//\'/\'\\\'\'};
printf "'%s'" "$quoted"
}
if [[ '${{ matrix.target.cpu }}' == 'amd64' ]]; then if [[ '${{ matrix.target.cpu }}' == 'amd64' ]]; then
ARCH=64
PLATFORM=x64 PLATFORM=x64
else else
ARCH=32
PLATFORM=x86 PLATFORM=x86
fi fi
echo "ARCH=$ARCH" >> $GITHUB_ENV echo "PLATFORM=${PLATFORM}" >> ${GITHUB_ENV}
echo "PLATFORM=$PLATFORM" >> $GITHUB_ENV
ncpu= # Stack usage on Linux amd64
ext= 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 case '${{ runner.os }}' in
'Linux') 'Linux')
ncpu=$(nproc) ncpu=$(nproc)
@ -66,155 +167,69 @@ jobs:
ncpu=$(sysctl -n hw.ncpu) ncpu=$(sysctl -n hw.ncpu)
;; ;;
'Windows') 'Windows')
ncpu=$NUMBER_OF_PROCESSORS ncpu=${NUMBER_OF_PROCESSORS}
ext=.exe
;; ;;
esac esac
[[ -z "$ncpu" || $ncpu -le 0 ]] && ncpu=1 [[ -z "$ncpu" || $ncpu -le 0 ]] && ncpu=1
echo "ncpu=$ncpu" >> $GITHUB_ENV echo "ncpu=${ncpu}" >> ${GITHUB_ENV}
echo "ext=$ext" >> $GITHUB_ENV
- name: Install build dependencies (Linux i386) - name: Restore Nim toolchain binaries from cache
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 id: nim-cache
uses: actions/cache@v2 uses: actions/cache@v3
with: with:
path: nim-codex/NimBinaries path: NimBinaries
key: 'nim-${{ matrix.branch }}-${{ matrix.target.os }}-${{ matrix.target.cpu }}-${{ steps.versions.outputs.nimbus_build_system }}' key: ${{ matrix.target.os }}-${{ matrix.target.cpu }}-nim-${{ matrix.nim_branch }}-cache_nonce:${{ matrix.cache_nonce }}
- name: Install NodeJS
uses: actions/setup-node@v2
with:
node-version: '14'
- name: Build Nim and Codex dependencies - name: Build Nim and Codex dependencies
shell: bash
working-directory: nim-codex
run: | run: |
if [[ "${{ runner.os }}" == "macOS" ]]; then make -j${ncpu} CI_CACHE=NimBinaries NIM_COMMIT=${{ matrix.nim_branch }} ARCH_OVERRIDE=${PLATFORM} QUICK_AND_DIRTY_COMPILER=1 update
ulimit -n 1024 echo
fi ./env.sh nim --version
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 # Rely on NodeJS LTS installed in GitHub Actions virtual environments
shell: bash - name: Start Ethereum node with Codex contracts
working-directory: nim-codex/vendor/dagger-contracts working-directory: vendor/dagger-contracts
run: | 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 install
npm start & npm start &
- name: Run nim-codex tests - name: Build and run Codex tests
shell: bash
working-directory: nim-codex
run: | run: |
./env.sh nim --version make -j${ncpu} NIM_COMMIT="${{ matrix.nim_branch }}" testAll
echo echo
make NIM_COMMIT="${{ matrix.branch }}" testAll if [[ '${{ runner.os }}' == macOS ]]; then
if [[ ${{ runner.os }} = macOS ]]; then echo otool -L build/codex
echo otool -L build/codex
echo otool -L build/testCodex elif [[ '${{ runner.os }}' == 'Windows' ]]; then
otool -L build/testCodex echo ntldd build/codex
ntldd build/codex
else else
echo echo ldd build/codex
echo ldd build/testCodex ldd build/codex
ldd build/testCodex
fi 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

View File

@ -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

View File

@ -110,11 +110,13 @@ else
endif endif
coverage: 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/testCodex && rm -f *.c
cd nimcache/release/testContracts && rm -f *.c cd nimcache/release/testContracts && rm -f *.c
cd nimcache/release/testIntegration && rm -f *.c
mkdir -p coverage 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 && ls $$(pwd)/codex/{*,**/*}.nim
shopt -s globstar && lcov --extract coverage/coverage.info $$(pwd)/codex/{*,**/*}.nim --output-file coverage/coverage.f.info 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" echo -e $(BUILD_MSG) "coverage/report/index.html"

View File

@ -5,6 +5,14 @@ if defined(release):
else: else:
switch("nimcache", joinPath(currentSourcePath.parentDir, "nimcache/debug/$projectName")) 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): if defined(windows):
# https://github.com/nim-lang/Nim/pull/19891 # https://github.com/nim-lang/Nim/pull/19891
switch("define", "nimRawSetjmp") switch("define", "nimRawSetjmp")