2023-12-01 14:17:45 +00:00
|
|
|
# Fluffy
|
2024-01-27 13:34:11 +00:00
|
|
|
# Copyright (c) 2021-2024 Status Research & Development GmbH
|
2023-11-09 12:22:51 +00:00
|
|
|
# Licensed and distributed under either of
|
|
|
|
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
|
|
|
|
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
|
|
|
|
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
|
|
|
|
2023-12-01 14:17:45 +00:00
|
|
|
name: Fluffy CI
|
2021-06-16 19:18:45 +00:00
|
|
|
on:
|
|
|
|
push:
|
2022-02-11 13:43:10 +00:00
|
|
|
paths:
|
|
|
|
- '.github/workflows/fluffy.yml'
|
|
|
|
- 'fluffy/**'
|
|
|
|
- '!fluffy/**.md'
|
|
|
|
- '!fluffy/docs/**'
|
|
|
|
- 'nimbus/rpc/hexstrings.nim'
|
|
|
|
- 'nimbus/rpc/rpc_*.nim'
|
2023-11-09 12:22:51 +00:00
|
|
|
- 'nimbus/db/**'
|
2022-02-11 13:43:10 +00:00
|
|
|
- 'vendor/**'
|
|
|
|
- 'Makefile'
|
|
|
|
- 'nimbus.nimble'
|
|
|
|
|
2021-06-16 19:18:45 +00:00
|
|
|
pull_request:
|
2022-02-11 13:43:10 +00:00
|
|
|
paths:
|
|
|
|
- '.github/workflows/fluffy.yml'
|
|
|
|
- 'fluffy/**'
|
|
|
|
- '!fluffy/**.md'
|
|
|
|
- '!fluffy/docs/**'
|
|
|
|
- 'nimbus/rpc/hexstrings.nim'
|
|
|
|
- 'nimbus/rpc/rpc_*.nim'
|
2023-11-09 12:22:51 +00:00
|
|
|
- 'nimbus/db/**'
|
2022-02-11 13:43:10 +00:00
|
|
|
- 'vendor/**'
|
|
|
|
- 'Makefile'
|
|
|
|
- 'nimbus.nimble'
|
2021-06-16 19:18:45 +00:00
|
|
|
|
|
|
|
jobs:
|
2022-02-03 12:11:54 +00:00
|
|
|
# separate job so it can run concurrently with other tests
|
|
|
|
testutp:
|
|
|
|
# whole test setup runs on ubuntu so we do not need multiple arch setup here
|
2023-02-02 03:58:03 +00:00
|
|
|
runs-on: ubuntu-22.04
|
2022-02-03 12:11:54 +00:00
|
|
|
# TODO: for now only push event as this way it is easier to get branch name
|
|
|
|
# to build container
|
|
|
|
if: github.event_name == 'push'
|
|
|
|
steps:
|
|
|
|
- name: Checkout nimbus-eth1
|
2024-01-27 13:34:11 +00:00
|
|
|
uses: actions/checkout@v4
|
2022-02-03 12:11:54 +00:00
|
|
|
|
|
|
|
- name: Install modprobe
|
|
|
|
run: |
|
|
|
|
sudo apt-get install -y kmod
|
|
|
|
|
|
|
|
# It is required to correctly run the simulation
|
|
|
|
- name: Load iptables6 kernel modules
|
|
|
|
run: |
|
|
|
|
sudo modprobe ip6table_filter
|
|
|
|
|
|
|
|
- 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)
|
2022-12-08 09:21:43 +00:00
|
|
|
echo "nimbus_build_system=$nbsHash" >> $GITHUB_OUTPUT
|
2022-02-03 12:11:54 +00:00
|
|
|
|
|
|
|
- name: Restore prebuilt Nim binaries from cache
|
|
|
|
id: nim-cache
|
2024-01-27 13:34:11 +00:00
|
|
|
uses: actions/cache@v4
|
2022-02-03 12:11:54 +00:00
|
|
|
with:
|
|
|
|
path: NimBinaries
|
2022-03-29 13:51:48 +00:00
|
|
|
key: 'nim-linux-amd64-${{ steps.versions.outputs.nimbus_build_system }}-fluffy'
|
2022-02-03 12:11:54 +00:00
|
|
|
|
|
|
|
- name: Build Nim and Nimbus-eth1 dependencies
|
|
|
|
run: |
|
2023-09-19 00:47:58 +00:00
|
|
|
make -j${ncpu} ARCH_OVERRIDE=${PLATFORM} CI_CACHE=NimBinaries update-from-ci
|
2022-02-03 12:11:54 +00:00
|
|
|
|
|
|
|
- name: build uTP test app container
|
|
|
|
run: |
|
|
|
|
docker build -t test-utp --no-cache --build-arg BRANCH_NAME=${{ github.ref_name }} fluffy/tools/utp_testing/docker
|
2022-02-11 13:43:10 +00:00
|
|
|
|
2022-02-03 12:11:54 +00:00
|
|
|
- name: run test app with simulator
|
|
|
|
run: |
|
2024-08-06 11:29:26 +00:00
|
|
|
: find / -name docker-compose -printf "%h\n%f\n%m\n\n" 2>/dev/null
|
|
|
|
PATH=$PATH$(find /usr/libexec/docker -name docker-compose -printf ":%h")
|
2022-02-03 12:11:54 +00:00
|
|
|
SCENARIO="drop-rate --delay=15ms --bandwidth=10Mbps --queue=25 --rate_to_client=10 --rate_to_server=10" docker-compose -f fluffy/tools/utp_testing/docker/docker-compose.yml up -d
|
2022-02-11 13:43:10 +00:00
|
|
|
|
2022-02-03 12:11:54 +00:00
|
|
|
- name: wait 5 seconds for containers to start
|
|
|
|
run: |
|
|
|
|
sleep 5
|
|
|
|
|
|
|
|
- name: check containers
|
|
|
|
run: |
|
|
|
|
docker ps -a
|
2022-02-11 13:43:10 +00:00
|
|
|
|
2022-02-03 12:11:54 +00:00
|
|
|
- name: run uTP test
|
|
|
|
run: |
|
|
|
|
export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:/usr/local/lib"
|
|
|
|
DEFAULT_MAKE_FLAGS="-j${ncpu}"
|
|
|
|
env CC=gcc CXX=g++ make ${DEFAULT_MAKE_FLAGS} utp-test
|
|
|
|
|
|
|
|
- name: Stop containers
|
|
|
|
if: always()
|
2024-08-06 11:29:26 +00:00
|
|
|
run: |
|
|
|
|
PATH=$PATH$(find /usr/libexec/docker -name docker-compose -printf ":%h")
|
|
|
|
docker-compose -f fluffy/tools/utp_testing/docker/docker-compose.yml down
|
2022-02-03 12:11:54 +00:00
|
|
|
|
2021-06-16 19:18:45 +00:00
|
|
|
build:
|
|
|
|
strategy:
|
|
|
|
fail-fast: false
|
|
|
|
max-parallel: 20
|
|
|
|
matrix:
|
|
|
|
target:
|
|
|
|
- os: linux
|
|
|
|
cpu: amd64
|
|
|
|
- os: macos
|
|
|
|
cpu: amd64
|
|
|
|
- os: windows
|
|
|
|
cpu: amd64
|
|
|
|
include:
|
|
|
|
- target:
|
|
|
|
os: linux
|
2023-02-02 03:58:03 +00:00
|
|
|
builder: ubuntu-22.04
|
2021-06-16 19:18:45 +00:00
|
|
|
- target:
|
|
|
|
os: macos
|
2024-10-26 06:37:29 +00:00
|
|
|
builder: macos-13
|
2021-06-16 19:18:45 +00:00
|
|
|
- target:
|
|
|
|
os: windows
|
|
|
|
builder: windows-latest
|
|
|
|
|
|
|
|
defaults:
|
|
|
|
run:
|
2023-09-08 15:10:16 +00:00
|
|
|
shell: bash
|
2021-06-16 19:18:45 +00:00
|
|
|
|
|
|
|
name: '${{ matrix.target.os }}-${{ matrix.target.cpu }}'
|
|
|
|
runs-on: ${{ matrix.builder }}
|
|
|
|
steps:
|
|
|
|
- name: Checkout nimbus-eth1
|
2024-01-27 13:34:11 +00:00
|
|
|
uses: actions/checkout@v4
|
2021-06-16 19:18:45 +00:00
|
|
|
|
|
|
|
- name: Derive environment variables
|
|
|
|
run: |
|
|
|
|
if [[ '${{ matrix.target.cpu }}' == 'amd64' ]]; then
|
|
|
|
PLATFORM=x64
|
|
|
|
else
|
|
|
|
PLATFORM=x86
|
|
|
|
fi
|
|
|
|
echo "PLATFORM=${PLATFORM}" >> $GITHUB_ENV
|
|
|
|
|
|
|
|
# libminiupnp / natpmp
|
|
|
|
if [[ '${{ runner.os }}' == 'Linux' && '${{ matrix.target.cpu }}' == 'i386' ]]; then
|
|
|
|
export CFLAGS="${CFLAGS} -m32 -mno-adx"
|
|
|
|
echo "CFLAGS=${CFLAGS}" >> $GITHUB_ENV
|
|
|
|
fi
|
|
|
|
|
|
|
|
ncpu=''
|
|
|
|
case '${{ runner.os }}' in
|
|
|
|
'Linux')
|
|
|
|
ncpu=$(nproc)
|
|
|
|
;;
|
|
|
|
'macOS')
|
|
|
|
ncpu=$(sysctl -n hw.ncpu)
|
|
|
|
;;
|
|
|
|
'Windows')
|
|
|
|
ncpu=${NUMBER_OF_PROCESSORS}
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
[[ -z "$ncpu" || $ncpu -le 0 ]] && ncpu=1
|
|
|
|
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-fast update -qq
|
|
|
|
sudo DEBIAN_FRONTEND='noninteractive' apt-fast install \
|
|
|
|
--no-install-recommends -yq gcc-multilib g++-multilib
|
|
|
|
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 "${{ github.workspace }}/external/bin" >> $GITHUB_PATH
|
|
|
|
|
2021-11-24 07:45:55 +00:00
|
|
|
# Required for running the local testnet script
|
|
|
|
- name: Install build dependencies (MacOS)
|
|
|
|
if: runner.os == 'macOS'
|
|
|
|
run: |
|
|
|
|
brew install gnu-getopt
|
|
|
|
brew link --force gnu-getopt
|
|
|
|
|
2023-09-08 15:10:16 +00:00
|
|
|
- name: Restore llvm-mingw (Windows) from cache
|
|
|
|
if: runner.os == 'Windows'
|
|
|
|
id: windows-mingw-cache
|
2024-01-27 13:34:11 +00:00
|
|
|
uses: actions/cache@v4
|
2021-06-16 19:18:45 +00:00
|
|
|
with:
|
2023-09-08 15:10:16 +00:00
|
|
|
path: external/mingw-${{ matrix.target.cpu }}
|
|
|
|
key: 'mingw-llvm-17-${{ matrix.target.cpu }}'
|
2021-06-16 19:18:45 +00:00
|
|
|
|
|
|
|
- name: Restore Nim DLLs dependencies (Windows) from cache
|
|
|
|
if: runner.os == 'Windows'
|
|
|
|
id: windows-dlls-cache
|
2024-01-27 13:34:11 +00:00
|
|
|
uses: actions/cache@v4
|
2021-06-16 19:18:45 +00:00
|
|
|
with:
|
|
|
|
path: external/dlls-${{ matrix.target.cpu }}
|
2022-03-29 13:51:48 +00:00
|
|
|
key: 'dlls-${{ matrix.target.cpu }}-fluffy'
|
2021-06-16 19:18:45 +00:00
|
|
|
|
2023-09-08 15:10:16 +00:00
|
|
|
- name: Install llvm-mingw dependency (Windows)
|
|
|
|
if: >
|
|
|
|
steps.windows-mingw-cache.outputs.cache-hit != 'true' &&
|
|
|
|
runner.os == 'Windows'
|
|
|
|
run: |
|
|
|
|
mkdir -p external
|
|
|
|
MINGW_BASE="https://github.com/mstorsjo/llvm-mingw/releases/download/20230905"
|
|
|
|
if [[ '${{ matrix.target.cpu }}' == 'amd64' ]]; then
|
|
|
|
MINGW_URL="$MINGW_BASE/llvm-mingw-20230905-ucrt-x86_64.zip"
|
|
|
|
ARCH=64
|
|
|
|
else
|
|
|
|
MINGW_URL="$MINGW_BASE/llvm-mingw-20230905-ucrt-x86_64.zip"
|
|
|
|
ARCH=32
|
|
|
|
fi
|
|
|
|
curl -L "$MINGW_URL" -o "external/mingw-${{ matrix.target.cpu }}.zip"
|
|
|
|
7z x -y "external/mingw-${{ matrix.target.cpu }}.zip" -oexternal/mingw-${{ matrix.target.cpu }}/
|
|
|
|
mv external/mingw-${{ matrix.target.cpu }}/**/* ./external/mingw-${{ matrix.target.cpu }}
|
|
|
|
|
2021-06-16 19:18:45 +00:00
|
|
|
- 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: |
|
2023-09-08 15:10:16 +00:00
|
|
|
echo '${{ github.workspace }}'"/external/mingw-${{ matrix.target.cpu }}/bin" >> $GITHUB_PATH
|
2021-06-16 19:18:45 +00:00
|
|
|
echo '${{ github.workspace }}'"/external/dlls-${{ matrix.target.cpu }}" >> $GITHUB_PATH
|
|
|
|
|
|
|
|
- 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)
|
2022-12-08 09:21:43 +00:00
|
|
|
echo "nimbus_build_system=$nbsHash" >> $GITHUB_OUTPUT
|
2021-06-16 19:18:45 +00:00
|
|
|
|
|
|
|
- name: Restore prebuilt Nim binaries from cache
|
|
|
|
id: nim-cache
|
2024-01-27 13:34:11 +00:00
|
|
|
uses: actions/cache@v4
|
2021-06-16 19:18:45 +00:00
|
|
|
with:
|
|
|
|
path: NimBinaries
|
2022-03-29 13:51:48 +00:00
|
|
|
key: 'nim-${{ matrix.target.os }}-${{ matrix.target.cpu }}-${{ steps.versions.outputs.nimbus_build_system }}-fluffy'
|
2021-06-16 19:18:45 +00:00
|
|
|
|
|
|
|
- name: Build Nim and Nimbus-eth1 dependencies
|
|
|
|
run: |
|
2023-01-31 05:13:57 +00:00
|
|
|
# use CC to make sure Nim compiler and subsequent test
|
|
|
|
# using the same glibc version.
|
2023-09-19 00:47:58 +00:00
|
|
|
env CC=gcc make -j${ncpu} ARCH_OVERRIDE=${PLATFORM} CI_CACHE=NimBinaries update-from-ci
|
2021-06-16 19:18:45 +00:00
|
|
|
|
2021-06-28 15:53:13 +00:00
|
|
|
- name: Run fluffy tests (Windows)
|
2021-06-16 19:18:45 +00:00
|
|
|
if: runner.os == 'Windows'
|
|
|
|
run: |
|
|
|
|
gcc --version
|
2023-09-15 14:21:00 +00:00
|
|
|
DEFAULT_MAKE_FLAGS="-j1"
|
2021-06-28 15:53:13 +00:00
|
|
|
mingw32-make ${DEFAULT_MAKE_FLAGS} fluffy
|
|
|
|
build/fluffy.exe --help
|
2023-05-27 13:52:48 +00:00
|
|
|
find . -type d -name ".git" -exec rm -rf {} +
|
2023-03-10 19:18:50 +00:00
|
|
|
rm -rf nimcache
|
|
|
|
mingw32-make ${DEFAULT_MAKE_FLAGS} fluffy-tools
|
|
|
|
rm -rf nimcache
|
2021-07-09 11:34:16 +00:00
|
|
|
mingw32-make ${DEFAULT_MAKE_FLAGS} fluffy-test
|
2023-03-10 19:18:50 +00:00
|
|
|
rm -rf nimcache
|
2021-06-16 19:18:45 +00:00
|
|
|
|
2021-06-28 15:53:13 +00:00
|
|
|
- name: Run fluffy tests (Linux)
|
2021-06-16 19:18:45 +00:00
|
|
|
if: runner.os == 'Linux'
|
|
|
|
run: |
|
2023-01-31 05:13:57 +00:00
|
|
|
gcc --version
|
|
|
|
./env.sh nim -v
|
|
|
|
ldd --version
|
2021-06-16 19:18:45 +00:00
|
|
|
export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:/usr/local/lib"
|
|
|
|
DEFAULT_MAKE_FLAGS="-j${ncpu}"
|
2021-06-28 15:53:13 +00:00
|
|
|
env CC=gcc make ${DEFAULT_MAKE_FLAGS} fluffy
|
|
|
|
build/fluffy --help
|
2023-03-10 19:18:50 +00:00
|
|
|
env CC=gcc make ${DEFAULT_MAKE_FLAGS} fluffy-tools
|
2021-06-16 19:18:45 +00:00
|
|
|
# CC is needed to select correct compiler 32/64 bit
|
2022-03-29 13:51:48 +00:00
|
|
|
env CC=gcc CXX=g++ make ${DEFAULT_MAKE_FLAGS} fluffy-test
|
2021-06-16 19:18:45 +00:00
|
|
|
|
2021-06-28 15:53:13 +00:00
|
|
|
- name: Run fluffy tests (Macos)
|
2021-06-16 19:18:45 +00:00
|
|
|
if: runner.os == 'Macos'
|
|
|
|
run: |
|
|
|
|
DEFAULT_MAKE_FLAGS="-j${ncpu}"
|
2021-06-28 15:53:13 +00:00
|
|
|
make ${DEFAULT_MAKE_FLAGS} fluffy
|
|
|
|
build/fluffy --help
|
2023-03-10 19:18:50 +00:00
|
|
|
make ${DEFAULT_MAKE_FLAGS} fluffy-tools
|
2021-06-16 19:18:45 +00:00
|
|
|
# "-static" option will not work for osx unless static system libraries are provided
|
2022-03-29 13:51:48 +00:00
|
|
|
make ${DEFAULT_MAKE_FLAGS} fluffy-test
|
2021-11-24 07:45:55 +00:00
|
|
|
|
|
|
|
- name: Run fluffy testnet
|
|
|
|
run: |
|
2024-09-12 08:18:24 +00:00
|
|
|
./fluffy/scripts/launch_local_testnet.sh --nodes=64 --run-tests
|
2024-02-10 13:49:34 +00:00
|
|
|
|
|
|
|
lint:
|
|
|
|
name: "Lint Fluffy"
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- name: Checkout
|
|
|
|
uses: actions/checkout@v4
|
|
|
|
with:
|
|
|
|
fetch-depth: 2 # In PR, has extra merge commit: ^1 = PR, ^2 = base
|
|
|
|
|
2024-02-28 17:31:45 +00:00
|
|
|
- name: Check nph formatting
|
|
|
|
# Pin nph to a specific version to avoid sudden style differences.
|
|
|
|
# Updating nph version should be accompanied with running the new
|
|
|
|
# version on the fluffy directory.
|
|
|
|
run: |
|
2024-07-22 12:22:45 +00:00
|
|
|
VERSION="v0.6.0"
|
2024-02-28 17:31:45 +00:00
|
|
|
ARCHIVE="nph-linux_x64.tar.gz"
|
|
|
|
curl -L "https://github.com/arnetheduck/nph/releases/download/${VERSION}/${ARCHIVE}" -o ${ARCHIVE}
|
|
|
|
tar -xzf ${ARCHIVE}
|
|
|
|
./nph fluffy/
|
|
|
|
git diff --exit-code
|
|
|
|
|
2024-02-10 13:49:34 +00:00
|
|
|
- name: Check copyright year
|
|
|
|
if: ${{ !cancelled() }} && github.event_name == 'pull_request'
|
|
|
|
run: |
|
|
|
|
bash scripts/check_copyright_year.sh
|