Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
276 changes: 65 additions & 211 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: CI

on:
push:
branches:
Expand All @@ -14,159 +15,17 @@

jobs:
build:
strategy:
fail-fast: false
matrix:
target:
- os: linux
cpu: amd64
- os: linux
cpu: i386
- os: macos
cpu: arm64
- os: windows
cpu: amd64
branch: [version-2-0, version-2-2, devel]
include:
- target:
os: linux
builder: ubuntu-latest
shell: bash
- target:
os: macos
cpu: arm64
builder: macos-latest
shell: bash
- target:
os: windows
builder: windows-latest
shell: msys2 {0}

defaults:
run:
shell: ${{ matrix.shell }}

name: '${{ matrix.target.os }}-${{ matrix.target.cpu }} (Nim ${{ matrix.branch }})'
runs-on: ${{ matrix.builder }}
continue-on-error: ${{ matrix.branch == 'devel' }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true

- 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

- name: MSYS2 (Windows i386)
if: runner.os == 'Windows' && matrix.target.cpu == 'i386'
uses: msys2/setup-msys2@v2
with:
path-type: inherit
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
if: runner.os == 'Windows'
id: windows-dlls-cache
uses: actions/cache@v4
with:
path: external/dlls-${{ matrix.target.cpu }}
key: 'dlls-${{ matrix.target.cpu }}'

- name: Install DLLs dependencies (Windows)
if: >
steps.windows-dlls-cache.outputs.cache-hit != 'true' &&
runner.os == 'Windows'
run: |
DLLPATH=external/dlls-${{ matrix.target.cpu }}
mkdir -p external
curl -L "https://nim-lang.org/download/windeps.zip" -o external/windeps.zip
7z x -y external/windeps.zip -o"$DLLPATH"

- name: Path to cached dependencies (Windows)
if: >
runner.os == 'Windows'
run: |
echo '${{ github.workspace }}'"/external/dlls-${{ matrix.target.cpu }}" >> $GITHUB_PATH

- name: Derive environment variables
run: |
if [[ '${{ matrix.target.cpu }}' == 'amd64' ]]; then
PLATFORM=x64
elif [[ '${{ matrix.target.cpu }}' == 'arm64' ]]; then
PLATFORM=arm64
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
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

- name: Run tests
run: |
nim --version
nimble --version
nimble install -y --depsOnly
nimble test
env NIMFLAGS="--mm:refc" nimble test
uses: status-im/nimbus-common-workflow/.github/workflows/common.yml@main
with:
nim-versions: '["version-2-0", "version-2-2", "devel"]'
test-command: |
nim --version
nimble --version
nimble install -y --depsOnly
nimble test
env NIMFLAGS="--mm:refc" nimble test

autobahn-test:

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {}
if: github.event_name == 'push' # || github.event_name == 'pull_request'
name: "Autobahn test suite"
runs-on: ubuntu-latest

Expand All @@ -175,7 +34,7 @@
max-parallel: 20
matrix:
websock: [ws, wsc, wss, wssc]
branch: [version-1-6, version-2-0, devel]
branch: [version-2-0, version-2-2, devel]

defaults:
run:
Expand All @@ -184,82 +43,56 @@
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Get latest nimbus-build-system commit hash
id: versions
run: |
nbsHash=$(git ls-remote "https://github.com/status-im/nimbus-build-system" "${2:-HEAD}" | cut -f 1 )
echo "nimbus_build_system=$nbsHash" >> $GITHUB_OUTPUT

- name: Restore prebuilt Nim from cache
uses: actions/cache@v4
with:
submodules: true
path: NimBinCache
key: 'nim-${{ matrix.branch }}-${{ steps.versions.outputs.nimbus_build_system }}'

- 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 -j$(nproc)" 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
bash build_nim.sh nim csources dist/nimble NimBinCache
echo '${{ github.workspace }}/nim/bin' >> $GITHUB_PATH

- name: Setup Python version
uses: actions/setup-python@v5
- name: Get docker image cache key
id: cache_key
run: |
dockerHash=$(docker buildx imagetools inspect crossbario/autobahn-testsuite | grep "Digest" | cut -d':' -f 3)
echo "cache_key=$dockerHash" >> $GITHUB_OUTPUT

- name: Cache Docker image
id: cache-docker-image
uses: actions/cache@v4
with:
python-version: pypy-2.7
path: /var/lib/docker # Or the specific path where your image is stored
key: ${{ runner.os }}-docker-image-${{ steps.cache_key.outputs.cache_key }}

- name: Setup Autobahn.
run: |
sudo apt-get install -y python2.7-dev
pip install virtualenv
pip install markdown2
virtualenv --python=/usr/bin/python2.7 autobahn
source autobahn/bin/activate
pip install autobahntestsuite txaio==2.1.0 autobahn[twisted,accelerate]==0.10.9 jinja2==2.6 markupsafe==0.19 Werkzeug==0.9.6 klein==0.2.3 pyopenssl service_identity==14.0.0 unittest2==1.1.0 wsaccel==0.6.2
pip freeze
nimble install -y --depsOnly
- name: Pull Docker image if not cached
if: steps.cache-docker-image.outputs.cache-hit != 'true'
run: docker pull crossbario/autobahn-testsuite:latest

- name: Generate index.html
if: matrix.websock == 'ws'
# Run this step only once for all matrix combinations
if: matrix.websock == 'ws' && matrix.branch == 'devel'
run: |
mkdir autobahn/reports
sed -i "s/COMMIT_SHA_SHORT/${GITHUB_SHA::7}/g" autobahn/index.md
sed -i "s/COMMIT_SHA/$GITHUB_SHA/g" autobahn/index.md
markdown2 autobahn/index.md > autobahn/reports/index.html
cp -a autobahn/index.md > autobahn/reports/index.md

- name: Run Autobahn test suite.
- name: Run Autobahn test suite
run: |
source autobahn/bin/activate
case '${{ matrix.websock }}' in
ws)
nim c -d:release examples/server.nim
examples/server &
server=$!

cd autobahn
wstest --mode fuzzingclient --spec fuzzingclient.json
;;
wsc)
nim c -d:tls -d:release -o:examples/tls_server examples/server.nim
examples/tls_server &
server=$!

cd autobahn
wstest --mode fuzzingclient --spec fuzzingclient_tls.json
;;
wss)
cd autobahn
wstest --webport=0 --mode fuzzingserver --spec fuzzingserver.json &
server=$!

cd ..
nim c -d:release examples/autobahn_client
examples/autobahn_client
;;
wssc)
cd autobahn
wstest --webport=0 --mode fuzzingserver --spec fuzzingserver_tls.json &
server=$!

cd ..
nim c -d:tls -d:release -o:examples/autobahn_tlsclient examples/autobahn_client
examples/autobahn_tlsclient
;;
esac

kill $server
bash scripts/${{ matrix.websock }}.sh ${{ matrix.branch }}

- name: Upload Autobahn result
uses: actions/upload-artifact@v4
Expand All @@ -281,23 +114,44 @@
pattern: autobahn-artifact-*

deploy-test:
name: "Deplay Autobahn results"
name: "Deploy Autobahn results"
needs: merge-autobahn-artifact
runs-on: ubuntu-latest

defaults:
run:
shell: bash

steps:
- name: Download Autobahn reports
uses: actions/download-artifact@v4
with:
name: autobahn-report
path: ./autobahn_reports

- name: Deploy autobahn report.
- name: Setup Python version
uses: actions/setup-python@v5
with:
python-version: pypy-3.10

- name: Setup dependencies
run: |
pip install markdown2
nimble install -y --depsOnly

- name: Setup dependencies
run: |
cat autobahn/reports/*.txt >> autobahn/reports/index.md
markdown2 autobahn/reports/index.md > autobahn/reports/index.html

- name: Deploy autobahn report
uses: peaceiris/actions-gh-pages@v4
with:
personal_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./autobahn_reports

- name: Delete artefacts
uses: geekyeggo/delete-artifact@v5
with:
failOnError: false
name: autobahn-report
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
nimcache
nimble.develop
nimble.paths
reports/
4 changes: 2 additions & 2 deletions autobahn/fuzzingserver_tls.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"url": "wss://127.0.0.1:9002",
"key": "tls/server.key",
"cert": "tls/server.crt",
"key": "/config/tls/server.key",
"cert": "/config/tls/server.crt",

"options": {"failByDrop": false},
"outdir": "./reports/client_tls",
Expand Down
4 changes: 0 additions & 4 deletions autobahn/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,3 @@

Generated by commit [COMMIT_SHA_SHORT](https://github.com/status-im/nim-websock/commit/COMMIT_SHA).

* [ws server summary report](server/index.html)
* [wss server summary report](server_tls/index.html)
* [ws client summary report](client/index.html)
* [wss client summary report](client_tls/index.html)
38 changes: 38 additions & 0 deletions scripts/ws.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env bash

# Copyright (c) 2025 Status Research & Development GmbH.
# Licensed under either of:
# - Apache License, version 2.0
# - MIT license
# at your option.

# prevent issue https://github.com/status-im/nimbus-eth1/issues/3661

set -e

# script arguments
[[ $# -ne 1 ]] && { echo "Usage: $0 NIM_VERSION"; }
NIM_VERSION="$1"

cd "$(dirname "${BASH_SOURCE[0]}")"/..

REPO_DIR="${PWD}"

nim c -d:release examples/server
examples/server &
server=$!

mkdir -p autobahn/reports

docker run \
-v ${REPO_DIR}/autobahn:/config \
-v ${REPO_DIR}/autobahn/reports:/reports \
--network=host \
--name fuzzingclient \
crossbario/autobahn-testsuite wstest --mode fuzzingclient --spec /config/fuzzingclient.json

kill $server

mv autobahn/reports/server autobahn/reports/server-${NIM_VERSION}

echo "* [Nim-${NIM_VERSION} ws server summary report](server-${NIM_VERSION}/index.html)" > "autobahn/reports/server-${NIM_VERSION}.txt"
Loading