CI: test with multiple Nim versions by default (#684)

* CI: test with 1.2 & devel by default
* Skip buggy windows websocket test
This commit is contained in:
Ștefan Talpalaru 2022-01-10 12:29:52 +01:00 committed by GitHub
parent 388b92d58f
commit e72d03bc78
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 161 additions and 147 deletions

View File

@ -9,78 +9,49 @@ on:
jobs: jobs:
build: build:
timeout-minutes: 90
strategy: strategy:
fail-fast: false fail-fast: false
max-parallel: 20
matrix: matrix:
target: target:
# Unit tests
- os: linux - os: linux
cpu: amd64 cpu: amd64
- os: linux - os: linux
cpu: i386 cpu: i386
- os: macos - os: macos
cpu: amd64 cpu: amd64
- os: windows
cpu: i386
- os: windows - os: windows
cpu: amd64 cpu: amd64
#- os: windows
#cpu: i386
branch: [version-1-2, devel]
include: include:
- target: - target:
os: linux os: linux
builder: ubuntu-20.04 builder: ubuntu-20.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}
defaults: defaults:
run: run:
shell: bash shell: ${{ matrix.shell }}
name: '${{ matrix.target.os }}-${{ matrix.target.cpu }}' 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-libp2p - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
with: with:
submodules: true submodules: true
- name: Derive environment variables
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=
MAKE_CMD="make"
case '${{ runner.os }}' in
'Linux')
ncpu=$(nproc)
;;
'macOS')
ncpu=$(sysctl -n hw.ncpu)
;;
'Windows')
ncpu=$NUMBER_OF_PROCESSORS
ext=.exe
MAKE_CMD="mingw32-make"
;;
esac
[[ -z "$ncpu" || $ncpu -le 0 ]] && ncpu=1
echo "ncpu=$ncpu" >> $GITHUB_ENV
echo "ext=$ext" >> $GITHUB_ENV
echo "MAKE_CMD=${MAKE_CMD}" >> $GITHUB_ENV
- 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'
run: | run: |
@ -101,68 +72,83 @@ 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'
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: > if: >
steps.windows-dlls-cache.outputs.cache-hit != 'true' && steps.windows-dlls-cache.outputs.cache-hit != 'true' &&
runner.os == 'Windows' runner.os == 'Windows'
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'
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 Nim commit hash - name: Derive environment variables
id: versions
run: | run: |
getHash() { if [[ '${{ matrix.target.cpu }}' == 'amd64' ]]; then
git ls-remote "https://github.com/$1" "${2:-HEAD}" | cut -f 1 PLATFORM=x64
} else
nbsHash=$(getHash status-im/nimbus-build-system) PLATFORM=x86
echo "::set-output name=nimbus_build_system::$nbsHash" fi
echo "PLATFORM=$PLATFORM" >> $GITHUB_ENV
- name: Restore prebuilt Nim from cache ncpu=
id: nim-cache MAKE_CMD="make"
uses: actions/cache@v2 case '${{ runner.os }}' in
with: 'Linux')
path: NimBinaries ncpu=$(nproc)
key: 'NimBinaries-${{ matrix.target.os }}-${{ matrix.target.cpu }}-${{ steps.versions.outputs.nimbus_build_system }}' ;;
'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 associated tools - name: Build Nim and Nimble
run: | run: |
curl -O -L -s -S https://raw.githubusercontent.com/status-im/nimbus-build-system/master/scripts/build_nim.sh 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 echo '${{ github.workspace }}/nim/bin' >> $GITHUB_PATH
- name: Setup Go - name: Setup Go
@ -174,8 +160,14 @@ jobs:
run: | run: |
V=1 bash scripts/build_p2pd.sh p2pdCache 124530a3 V=1 bash scripts/build_p2pd.sh p2pdCache 124530a3
- name: Run nim-libp2p tests - name: Run tests
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_pinned nimble install_pinned
nimble test nimble test

View File

@ -6,6 +6,7 @@ on:
jobs: jobs:
build: build:
timeout-minutes: 120
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
@ -16,69 +17,39 @@ jobs:
cpu: i386 cpu: i386
- os: macos - os: macos
cpu: amd64 cpu: amd64
#- os: windows
#cpu: i386
- os: windows - os: windows
cpu: amd64 cpu: amd64
#- os: windows
#cpu: i386
branch: [version-1-2, version-1-4, version-1-6, devel] branch: [version-1-2, version-1-4, version-1-6, devel]
include: include:
- target: - target:
os: linux os: linux
builder: ubuntu-20.04 builder: ubuntu-20.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}
defaults: defaults:
run: run:
shell: bash shell: ${{ matrix.shell }}
name: '${{ matrix.target.os }}-${{ matrix.target.cpu }} (Nim ${{ matrix.branch }})' 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' }} continue-on-error: ${{ matrix.branch == 'version-1-6' || matrix.branch == 'devel' }}
steps: steps:
- name: Checkout nim-libp2p - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
with: with:
ref: master ref: unstable
submodules: true submodules: true
- name: Derive environment variables
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=
MAKE_CMD="make"
case '${{ runner.os }}' in
'Linux')
ncpu=$(nproc)
;;
'macOS')
ncpu=$(sysctl -n hw.ncpu)
;;
'Windows')
ncpu=$NUMBER_OF_PROCESSORS
ext=.exe
MAKE_CMD="mingw32-make"
;;
esac
[[ -z "$ncpu" || $ncpu -le 0 ]] && ncpu=1
echo "ncpu=$ncpu" >> $GITHUB_ENV
echo "ext=$ext" >> $GITHUB_ENV
echo "MAKE_CMD=${MAKE_CMD}" >> $GITHUB_ENV
- 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'
run: | run: |
@ -99,47 +70,76 @@ 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'
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: > if: >
steps.windows-dlls-cache.outputs.cache-hit != 'true' && steps.windows-dlls-cache.outputs.cache-hit != 'true' &&
runner.os == 'Windows' runner.os == 'Windows'
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'
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: Derive environment variables
run: |
if [[ '${{ matrix.target.cpu }}' == 'amd64' ]]; then
PLATFORM=x64
else
PLATFORM=x86
fi
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"
;;
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 - name: Build Nim and Nimble
run: | run: |
@ -149,12 +149,27 @@ jobs:
bash build_nim.sh nim csources dist/nimble NimBinaries 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-libp2p tests - name: Setup Go
uses: actions/setup-go@v2
with:
go-version: '^1.15.5'
- name: Install p2pd
run: | run: |
V=1 bash scripts/build_p2pd.sh p2pdCache 124530a3
- name: Run tests
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_slim nimble test
if [[ "${{ matrix.branch }}" == "version-1-6" || "${{ matrix.branch }}" == "devel" ]]; then if [[ "${{ matrix.branch }}" == "version-1-6" || "${{ matrix.branch }}" == "devel" ]]; then
echo -e "\nTesting with '--gc:orc':\n" echo -e "\nTesting with '--gc:orc':\n"
export NIMFLAGS="--gc:orc" export NIMFLAGS="${NIMFLAGS} --gc:orc"
nimble test_slim nimble test
fi fi

View File

@ -27,9 +27,8 @@ const nimflags =
proc runTest(filename: string, verify: bool = true, sign: bool = true, proc runTest(filename: string, verify: bool = true, sign: bool = true,
moreoptions: string = "") = moreoptions: string = "") =
let env_nimflags = getEnv("NIMFLAGS")
var excstr = "nim c --opt:speed -d:debug -d:libp2p_agents_metrics -d:libp2p_protobuf_metrics -d:libp2p_network_protocols_metrics " var excstr = "nim c --opt:speed -d:debug -d:libp2p_agents_metrics -d:libp2p_protobuf_metrics -d:libp2p_network_protocols_metrics "
excstr.add(" " & env_nimflags & " ") excstr.add(" " & getEnv("NIMFLAGS") & " ")
excstr.add(" " & nimflags & " ") excstr.add(" " & nimflags & " ")
excstr.add(" -d:libp2p_pubsub_sign=" & $sign) excstr.add(" -d:libp2p_pubsub_sign=" & $sign)
excstr.add(" -d:libp2p_pubsub_verify=" & $verify) excstr.add(" -d:libp2p_pubsub_verify=" & $verify)
@ -91,7 +90,7 @@ task test, "Runs the test suite":
exec "nimble testfilter" exec "nimble testfilter"
exec "nimble examples_build" exec "nimble examples_build"
task test_slim, "Runs the test suite": task test_slim, "Runs the (slimmed down) test suite":
exec "nimble testnative" exec "nimble testnative"
exec "nimble testpubsub_slim" exec "nimble testpubsub_slim"
exec "nimble testfilter" exec "nimble testfilter"

View File

@ -137,6 +137,10 @@ proc commonTransportTest*(name: string, prov: TransportProvider, ma: string) =
await transport1.stop() await transport1.stop()
asyncTest "e2e should allow multiple local addresses": asyncTest "e2e should allow multiple local addresses":
when defined(windows):
# this randomly locks the Windows CI job
skip()
return
let addrs = @[MultiAddress.init(ma).tryGet(), let addrs = @[MultiAddress.init(ma).tryGet(),
MultiAddress.init(ma).tryGet()] MultiAddress.init(ma).tryGet()]

View File

@ -841,6 +841,10 @@ suite "Switch":
switch2.peerStore.protoBook.get(switch1.peerInfo.peerId) == switch1.peerInfo.protocols.toHashSet() switch2.peerStore.protoBook.get(switch1.peerInfo.peerId) == switch1.peerInfo.protocols.toHashSet()
asyncTest "e2e should allow multiple local addresses": asyncTest "e2e should allow multiple local addresses":
when defined(windows):
# this randomly locks the Windows CI job
skip()
return
proc handle(conn: Connection, proto: string) {.async, gcsafe.} = proc handle(conn: Connection, proto: string) {.async, gcsafe.} =
try: try:
let msg = string.fromBytes(await conn.readLp(1024)) let msg = string.fromBytes(await conn.readLp(1024))