2021-05-31 20:21:17 +00:00
|
|
|
name: CI
|
2020-12-23 00:12:02 +00:00
|
|
|
on: [push, pull_request]
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
build:
|
|
|
|
strategy:
|
|
|
|
fail-fast: false
|
|
|
|
max-parallel: 20
|
|
|
|
matrix:
|
|
|
|
target:
|
|
|
|
# Unit tests
|
|
|
|
- os: linux
|
|
|
|
cpu: amd64
|
|
|
|
- os: linux
|
|
|
|
cpu: i386
|
|
|
|
- os: macos
|
|
|
|
cpu: amd64
|
|
|
|
- os: windows
|
|
|
|
cpu: i386
|
|
|
|
- os: windows
|
|
|
|
cpu: amd64
|
|
|
|
include:
|
|
|
|
- target:
|
|
|
|
os: linux
|
2021-03-15 05:50:36 +00:00
|
|
|
builder: ubuntu-20.04
|
2020-12-23 00:12:02 +00:00
|
|
|
- target:
|
|
|
|
os: macos
|
|
|
|
builder: macos-10.15
|
|
|
|
- target:
|
|
|
|
os: windows
|
|
|
|
builder: windows-2019
|
2021-05-31 20:21:17 +00:00
|
|
|
|
|
|
|
defaults:
|
|
|
|
run:
|
|
|
|
shell: bash
|
|
|
|
|
|
|
|
name: '${{ matrix.target.os }}-${{ matrix.target.cpu }}'
|
2020-12-23 00:12:02 +00:00
|
|
|
runs-on: ${{ matrix.builder }}
|
|
|
|
steps:
|
|
|
|
- name: Checkout nim-libp2p
|
|
|
|
uses: actions/checkout@v2
|
|
|
|
with:
|
|
|
|
submodules: true
|
2021-05-21 16:27:01 +00:00
|
|
|
|
|
|
|
- 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=
|
2021-05-31 20:21:17 +00:00
|
|
|
MAKE_CMD="make"
|
2021-05-21 16:27:01 +00:00
|
|
|
case '${{ runner.os }}' in
|
|
|
|
'Linux')
|
|
|
|
ncpu=$(nproc)
|
|
|
|
;;
|
|
|
|
'macOS')
|
|
|
|
ncpu=$(sysctl -n hw.ncpu)
|
|
|
|
;;
|
|
|
|
'Windows')
|
|
|
|
ncpu=$NUMBER_OF_PROCESSORS
|
|
|
|
ext=.exe
|
2021-05-31 20:21:17 +00:00
|
|
|
MAKE_CMD="mingw32-make"
|
2021-05-21 16:27:01 +00:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
[[ -z "$ncpu" || $ncpu -le 0 ]] && ncpu=1
|
|
|
|
echo "ncpu=$ncpu" >> $GITHUB_ENV
|
|
|
|
echo "ext=$ext" >> $GITHUB_ENV
|
2021-05-31 20:21:17 +00:00
|
|
|
echo "MAKE_CMD=${MAKE_CMD}" >> $GITHUB_ENV
|
2021-05-21 16:27:01 +00:00
|
|
|
|
2020-12-23 00:12:02 +00:00
|
|
|
- name: Install build dependencies (Linux i386)
|
|
|
|
if: runner.os == 'Linux' && matrix.target.cpu == 'i386'
|
|
|
|
run: |
|
|
|
|
sudo dpkg --add-architecture i386
|
2021-03-15 05:50:36 +00:00
|
|
|
sudo apt-get update -qq
|
|
|
|
sudo DEBIAN_FRONTEND='noninteractive' apt-get install \
|
2020-12-23 00:12:02 +00:00
|
|
|
--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
|
|
|
|
|
2021-05-21 16:27:01 +00:00
|
|
|
- name: Restore MinGW-W64 (Windows) from cache
|
2020-12-23 00:12:02 +00:00
|
|
|
if: runner.os == 'Windows'
|
2021-05-21 16:27:01 +00:00
|
|
|
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'
|
2020-12-23 00:12:02 +00:00
|
|
|
run: |
|
2021-05-21 16:27:01 +00:00
|
|
|
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'
|
|
|
|
run: |
|
|
|
|
mkdir -p external
|
2020-12-23 00:12:02 +00:00
|
|
|
curl -L "https://nim-lang.org/download/windeps.zip" -o external/windeps.zip
|
2021-05-21 16:27:01 +00:00
|
|
|
7z x -y external/windeps.zip -oexternal/dlls-${{ matrix.target.cpu }}
|
|
|
|
|
|
|
|
- name: Path to cached dependencies (Windows)
|
|
|
|
if: >
|
|
|
|
runner.os == 'Windows'
|
|
|
|
run: |
|
|
|
|
echo "${{ github.workspace }}/external/mingw-${{ matrix.target.cpu }}/bin" >> $GITHUB_PATH
|
|
|
|
echo "${{ github.workspace }}/external/dlls-${{ matrix.target.cpu }}" >> $GITHUB_PATH
|
2020-12-23 00:12:02 +00:00
|
|
|
|
|
|
|
- name: Get latest Nim commit hash
|
|
|
|
id: versions
|
|
|
|
run: |
|
|
|
|
getHash() {
|
|
|
|
git ls-remote "https://github.com/$1" "${2:-HEAD}" | cut -f 1
|
|
|
|
}
|
2021-05-31 20:21:17 +00:00
|
|
|
nbsHash=$(getHash status-im/nimbus-build-system)
|
|
|
|
echo "::set-output name=nimbus_build_system::$nbsHash"
|
2020-12-23 00:12:02 +00:00
|
|
|
|
|
|
|
- name: Restore prebuilt Nim from cache
|
|
|
|
id: nim-cache
|
2021-05-31 20:21:17 +00:00
|
|
|
uses: actions/cache@v2
|
2020-12-23 00:12:02 +00:00
|
|
|
with:
|
2021-05-31 20:21:17 +00:00
|
|
|
path: NimBinaries
|
|
|
|
key: 'NimBinaries-${{ matrix.target.os }}-${{ matrix.target.cpu }}-${{ steps.versions.outputs.nimbus_build_system }}'
|
2020-12-23 00:12:02 +00:00
|
|
|
|
|
|
|
- name: Build Nim and associated tools
|
|
|
|
run: |
|
2021-05-31 20:21:17 +00:00
|
|
|
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
|
|
|
|
echo '${{ github.workspace }}/nim/bin' >> $GITHUB_PATH
|
2020-12-23 00:12:02 +00:00
|
|
|
|
|
|
|
- name: Setup Go
|
|
|
|
uses: actions/setup-go@v2
|
|
|
|
with:
|
|
|
|
go-version: '^1.15.5'
|
|
|
|
|
|
|
|
- name: Install p2pd
|
|
|
|
run: |
|
|
|
|
V=1 bash scripts/build_p2pd.sh p2pdCache v0.3.0
|
|
|
|
|
|
|
|
- name: Run nim-libp2p tests
|
|
|
|
run: |
|
|
|
|
nimble install -y --depsOnly
|
|
|
|
nimble test
|
2021-03-16 00:31:06 +00:00
|
|
|
|
|
|
|
bumpNBC-stable:
|
2021-03-22 13:13:00 +00:00
|
|
|
if: github.ref == 'refs/heads/master'
|
2021-03-16 00:31:06 +00:00
|
|
|
needs: build
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- uses: status-im/github-app-token@v1
|
|
|
|
name: Generate token
|
|
|
|
id: generate-token
|
|
|
|
with:
|
|
|
|
app_id: ${{ secrets.BUMP_BOT_APP_ID }}
|
|
|
|
private_key: ${{ secrets.BUMP_BOT_APP_PRIVATE_KEY }}
|
|
|
|
|
|
|
|
- name: Clone NBC
|
|
|
|
uses: actions/checkout@v2
|
|
|
|
with:
|
|
|
|
repository: status-im/nimbus-eth2
|
2021-03-23 07:46:24 +00:00
|
|
|
ref: unstable
|
2021-03-16 00:31:06 +00:00
|
|
|
path: nbc
|
|
|
|
submodules: true
|
|
|
|
fetch-depth: 0
|
|
|
|
|
|
|
|
- name: Checkout this ref
|
|
|
|
run: |
|
|
|
|
cd nbc/vendor/nim-libp2p
|
|
|
|
git checkout $GITHUB_SHA
|
|
|
|
|
|
|
|
- name: Commit this bump
|
|
|
|
run: |
|
|
|
|
cd nbc
|
|
|
|
git config --global user.email "${{ github.actor }}@users.noreply.github.com"
|
|
|
|
git config --global user.name = "${{ github.actor }}"
|
|
|
|
git commit -a -m "auto-bump nim-libp2p"
|
|
|
|
|
|
|
|
- name: Make PR
|
|
|
|
uses: peter-evans/create-pull-request@v3.5.0
|
|
|
|
with:
|
|
|
|
branch: nim-libp2p-auto-bump
|
|
|
|
path: nbc
|
|
|
|
token: ${{ steps.generate-token.outputs.token }}
|
|
|
|
title: nim-libp2p auto bump
|
|
|
|
|
|
|
|
bumpNBC-unstable:
|
2021-03-22 13:13:00 +00:00
|
|
|
if: github.ref == 'refs/heads/unstable'
|
2021-03-16 00:31:06 +00:00
|
|
|
needs: build
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- uses: status-im/github-app-token@v1
|
|
|
|
name: Generate token
|
|
|
|
id: generate-token
|
|
|
|
with:
|
|
|
|
app_id: ${{ secrets.BUMP_BOT_APP_ID }}
|
|
|
|
private_key: ${{ secrets.BUMP_BOT_APP_PRIVATE_KEY }}
|
|
|
|
|
|
|
|
- name: Clone NBC
|
|
|
|
uses: actions/checkout@v2
|
|
|
|
with:
|
|
|
|
repository: status-im/nimbus-eth2
|
|
|
|
ref: unstable
|
|
|
|
path: nbc
|
|
|
|
submodules: true
|
|
|
|
fetch-depth: 0
|
|
|
|
|
|
|
|
- name: Checkout this ref
|
|
|
|
run: |
|
|
|
|
cd nbc/vendor/nim-libp2p
|
|
|
|
git checkout $GITHUB_SHA
|
|
|
|
|
|
|
|
- name: Commit this bump
|
|
|
|
run: |
|
|
|
|
cd nbc
|
|
|
|
git config --global user.email "${{ github.actor }}@users.noreply.github.com"
|
|
|
|
git config --global user.name = "${{ github.actor }}"
|
|
|
|
git commit -a -m "auto-bump nim-libp2p"
|
|
|
|
|
|
|
|
- name: Make PR
|
|
|
|
uses: peter-evans/create-pull-request@v3.5.0
|
|
|
|
with:
|
|
|
|
branch: nim-libp2p-auto-bump-unstable
|
|
|
|
path: nbc
|
|
|
|
token: ${{ steps.generate-token.outputs.token }}
|
|
|
|
title: nim-libp2p unstable auto bump
|
|
|
|
draft: true
|