Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GitHub Actions auto-build workflow #2062

Merged
merged 18 commits into from Feb 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
318 changes: 318 additions & 0 deletions .github/workflows/build-and-test.yml
@@ -0,0 +1,318 @@
name: Github Autobuild
on: [ push, pull_request ]
env:
CCACHE_COMPRESS: exists means true
CCACHE_SLOPPINESS: include_file_ctime,include_file_mtime,time_macros
# The following are for windows cross-build only:
BOOST_VERSION: 1_69_0
BOOST_DOTTED_VERSION: 1.69.0
CURL_VERSION: 7.67.0
OPENSSL_VERSION: 1.1.1d
ZLIB_VERSION: 1.2.11
jobs:
test-release:
name: Build and run tests in Release mode
runs-on: ubuntu-latest
services:
elasticsearch:
image: docker://elasticsearch:7.4.2
options: --env discovery.type=single-node --publish 9200:9200 --publish 9300:9300
steps:
- name: Install dependencies
run: |
sudo apt-get install -y \
ccache \
parallel \
libboost-thread-dev \
libboost-iostreams-dev \
libboost-date-time-dev \
libboost-system-dev \
libboost-filesystem-dev \
libboost-program-options-dev \
libboost-chrono-dev \
libboost-test-dev \
libboost-context-dev \
libboost-regex-dev \
libboost-coroutine-dev \
libcurl4-openssl-dev
- uses: actions/checkout@v1
with:
submodules: recursive
- name: Configure
run: |
mkdir -p _build
pushd _build
cmake -D CMAKE_BUILD_TYPE=Release \
-D CMAKE_CXX_OUTPUT_EXTENSION_REPLACE=ON \
-D CMAKE_C_COMPILER=gcc \
-D CMAKE_C_COMPILER_LAUNCHER=ccache \
-D CMAKE_CXX_COMPILER=g++ \
-D CMAKE_CXX_COMPILER_LAUNCHER=ccache \
..
popd
- name: Load Cache
uses: actions/cache@v1
with:
path: ccache
key: ccache-release-${{ github.ref }}-${{ github.sha }}
restore-keys: |
ccache-release-${{ github.ref }}-
ccache-release-
- name: Build
run: |
export CCACHE_DIR="$GITHUB_WORKSPACE/ccache"
mkdir -p "$CCACHE_DIR"
make -j 2 -C _build
- name: Unit-Tests
run: |
_build/tests/app_test
libraries/fc/tests/run-parallel-tests.sh _build/tests/chain_test
libraries/fc/tests/run-parallel-tests.sh _build/tests/cli_test
libraries/fc/tests/run-parallel-tests.sh _build/tests/es_test
- name: Node-Test
run: |
pushd _build
../programs/build_helpers/run-node-test
test-debug:
name: Build and run tests in Debug mode
runs-on: ubuntu-latest
services:
elasticsearch:
image: docker://elasticsearch:7.4.2
options: --env discovery.type=single-node --publish 9200:9200 --publish 9300:9300
steps:
- name: Install dependencies
run: |
sudo apt-get install -y \
ccache \
parallel \
libboost-thread-dev \
libboost-iostreams-dev \
libboost-date-time-dev \
libboost-system-dev \
libboost-filesystem-dev \
libboost-program-options-dev \
libboost-chrono-dev \
libboost-test-dev \
libboost-context-dev \
libboost-regex-dev \
libboost-coroutine-dev \
libcurl4-openssl-dev
- uses: actions/checkout@v1
with:
submodules: recursive
- name: Configure
run: |
mkdir -p _build
pushd _build
cmake -D CMAKE_BUILD_TYPE=Debug \
-D CMAKE_CXX_OUTPUT_EXTENSION_REPLACE=ON \
-D CMAKE_C_COMPILER=gcc \
-D CMAKE_C_COMPILER_LAUNCHER=ccache \
-D CMAKE_CXX_COMPILER=g++ \
-D CMAKE_CXX_COMPILER_LAUNCHER=ccache \
..
popd
- name: Load Cache
uses: actions/cache@v1
with:
path: ccache
key: ccache-debug-${{ github.ref }}-${{ github.sha }}
restore-keys: |
ccache-debug-${{ github.ref }}-
ccache-debug-
- name: Build
run: |
export CCACHE_DIR="$GITHUB_WORKSPACE/ccache"
mkdir -p "$CCACHE_DIR"
make -j 2 -C _build
- name: Unit-Tests
run: |
_build/tests/app_test
libraries/fc/tests/run-parallel-tests.sh _build/tests/chain_test
libraries/fc/tests/run-parallel-tests.sh _build/tests/cli_test
libraries/fc/tests/run-parallel-tests.sh _build/tests/es_test
- name: Node-Test
run: |
pushd _build
../programs/build_helpers/run-node-test
prepare-mingw64-libs:
name: Build 3rd-party libraries required for windows cross-build
runs-on: ubuntu-latest
steps:
- name: Load Cache
id: cache-libs
uses: actions/cache@v1
with:
path: libs
key: mingw64-libs-${{ env.BOOST_VERSION }}_${{ env.CURL_VERSION }}_${{ env.OPENSSL_VERSION }}_${{ env.ZLIB_VERSION }}
- name: Install dependencies
if: steps.cache-libs.outputs.cache-hit != 'true'
run: |
sudo apt-get install -y \
g++-mingw-w64-x86-64 \
mingw-w64-tools
- name: Download library sources
if: steps.cache-libs.outputs.cache-hit != 'true'
run: |
curl -LO https://dl.bintray.com/boostorg/release/${{ env.BOOST_DOTTED_VERSION }}/source/boost_${{ env.BOOST_VERSION }}.tar.bz2
curl -LO https://curl.haxx.se/download/curl-${{ env.CURL_VERSION }}.tar.bz2
curl -LO https://www.openssl.org/source/openssl-${{ env.OPENSSL_VERSION }}.tar.gz
curl -LO https://zlib.net/zlib-${{ env.ZLIB_VERSION }}.tar.gz
- name: Build zlib
if: steps.cache-libs.outputs.cache-hit != 'true'
run: |
LIBS="`pwd`/libs"
ZLIB="`echo zlib-*`"
tar xfz "$ZLIB"
pushd "${ZLIB%.tar.gz}"
CROSS_PREFIX=x86_64-w64-mingw32- ./configure --prefix="$LIBS" --static --64
make install
- name: Build openssl
if: steps.cache-libs.outputs.cache-hit != 'true'
run: |
LIBS="`pwd`/libs"
OPENSSL="`echo openssl-*`"
tar xfz "$OPENSSL"
pushd "${OPENSSL%.tar.gz}"
./Configure --prefix="$LIBS" --cross-compile-prefix=x86_64-w64-mingw32- \
no-shared zlib threads \
mingw64
make CPPFLAGS="-I$LIBS/include" LDFLAGS="-L$LIBS/lib" build_libs
make -j 2 install_dev
- name: Build curl
if: steps.cache-libs.outputs.cache-hit != 'true'
run: |
LIBS="`pwd`/libs"
CURL="`echo curl-*`"
tar xfj "$CURL"
pushd "${CURL%.tar.bz2}"
sed -i 's=-lgdi32=-lcrypt32 \0=' configure
PKG_CONFIG_PATH="$LIBS/lib/pkgconfig" ./configure --host=x86_64-w64-mingw32 \
--prefix="$LIBS" \
--disable-shared \
--disable-tftpf \
--disable-ldap \
--with-zlib \
--without-ssl --with-winssl \
--disable-tftp \
--disable-ldap
make -j 2 install
- name: Build boost
if: steps.cache-libs.outputs.cache-hit != 'true'
run: |
LIBS="`pwd`/libs"
BOOST="`echo boost_*`"
tar xfj "$BOOST"
pushd "${BOOST%.tar.bz2}"
# See https://github.com/boostorg/context/issues/101
sed -i '/os.\(name\|platform\)/d;/local tmp = /s=elf=pe=;/local tmp = /s=sysv=ms=' libs/context/build/Jamfile.v2
./bootstrap.sh --prefix=$LIBS
echo "using gcc : mingw32 : x86_64-w64-mingw32-g++ ;" > user-config.jam
./b2 --user-config=user-config.jam \
--without-python \
toolset=gcc-mingw32 \
target-os=windows \
variant=release \
link=static \
threading=multi \
runtime-link=static \
address-model=64 \
abi=ms \
install
build-mingw64:
name: Cross-build for windows using mingw
runs-on: ubuntu-latest
needs: prepare-mingw64-libs
steps:
- name: Install dependencies
run: |
sudo apt-get install -y \
ccache \
g++-mingw-w64-x86-64 \
mingw-w64-tools
- uses: actions/checkout@v1
with:
submodules: recursive
- name: Load external libraries
uses: actions/cache@v1
with:
path: libs
id: cache-libs
key: mingw64-libs-${{ env.BOOST_VERSION }}_${{ env.CURL_VERSION }}_${{ env.OPENSSL_VERSION }}_${{ env.ZLIB_VERSION }}
- name: Configure
run: |
LIBS="`pwd`/libs"
mkdir -p _build
pushd _build
cmake -D CMAKE_BUILD_TYPE=Release \
-D CMAKE_C_COMPILER=/usr/bin/x86_64-w64-mingw32-gcc-posix \
-D CMAKE_CXX_COMPILER_LAUNCHER=ccache \
-D CMAKE_CXX_COMPILER=/usr/bin/x86_64-w64-mingw32-g++-posix \
-D CMAKE_CXX_FLAGS=-Wa,-mbig-obj \
-D CMAKE_SYSTEM_NAME=Windows \
-D CURL_STATICLIB=ON \
-D CMAKE_EXE_LINKER_FLAGS=--static \
-D CMAKE_FIND_ROOT_PATH="/usr/lib/gcc/x86_64-w64-mingw32/7.3-win32/;$LIBS" \
-D CMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER \
-D CMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY \
-D CMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY \
..
- name: Load Cache
uses: actions/cache@v1
with:
path: ccache
key: ccache-mingw64-${{ github.ref }}-${{ github.sha }}
restore-keys: |
ccache-mingw64-${{ github.ref }}-
ccache-mingw64-
- name: Build
run: |
export CCACHE_DIR="$GITHUB_WORKSPACE/ccache"
mkdir -p "$CCACHE_DIR"
make -j 2 -C _build witness_node cli_wallet
build-osx:
name: Build and run tests on OSX
runs-on: macos-latest
steps:
- name: Install dependencies
run: |
brew install autoconf automake libtool
brew install ccache
brew search boost
brew install boost@1.60
- uses: actions/checkout@v1
with:
submodules: recursive
- name: Configure
run: |
mkdir -p _build
pushd _build
cmake -D CMAKE_BUILD_TYPE=Release \
-D CMAKE_C_COMPILER_LAUNCHER=ccache \
-D CMAKE_CXX_COMPILER_LAUNCHER=ccache \
-D BOOST_ROOT=/usr/local/opt/boost@1.60 \
-D OPENSSL_ROOT_DIR=/usr/local/opt/openssl \
..
- name: Load Cache
uses: actions/cache@v1
with:
path: ccache
key: ccache-osx-${{ github.ref }}-${{ github.sha }}
restore-keys: |
ccache-osx-${{ github.ref }}-
ccache-osx-
- name: Build
run: |
export CCACHE_DIR="$GITHUB_WORKSPACE/ccache"
mkdir -p "$CCACHE_DIR"
make -j 2 -C _build witness_node cli_wallet app_test cli_test chain_test
- name: Unit-Tests
run: |
_build/tests/app_test
libraries/fc/tests/run-parallel-tests.sh _build/tests/chain_test
libraries/fc/tests/run-parallel-tests.sh _build/tests/cli_test
- name: Node-Test
run: |
pushd _build
../programs/build_helpers/run-node-test
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -6,7 +6,7 @@ BitShares Core
`master` | `develop` | `hardfork` | `testnet` | `bitshares-fc`
--- | --- | --- | --- | ---
[![](https://travis-ci.org/bitshares/bitshares-core.svg?branch=master)](https://travis-ci.org/bitshares/bitshares-core) | [![](https://travis-ci.org/bitshares/bitshares-core.svg?branch=develop)](https://travis-ci.org/bitshares/bitshares-core) | [![](https://travis-ci.org/bitshares/bitshares-core.svg?branch=hardfork)](https://travis-ci.org/bitshares/bitshares-core) | [![](https://travis-ci.org/bitshares/bitshares-core.svg?branch=testnet)](https://travis-ci.org/bitshares/bitshares-core) | [![](https://travis-ci.org/bitshares/bitshares-fc.svg?branch=master)](https://travis-ci.org/bitshares/bitshares-fc)

[![](https://github.com/bitshares/bitshares-core/workflows/Github%20Autobuild/badge.svg?branch=master)](https://github.com/bitshares/bitshares-core/actions?query=branch%3Amaster) | [![](https://github.com/bitshares/bitshares-core/workflows/Github%20Autobuild/badge.svg?branch=develop)](https://github.com/bitshares/bitshares-core/actions?query=branch%3Adevelop) | [![](https://github.com/bitshares/bitshares-core/workflows/Github%20Autobuild/badge.svg?branch=hardfork)](https://github.com/bitshares/bitshares-core/actions?query=branch%3Ahardfork) | [![](https://github.com/bitshares/bitshares-core/workflows/Github%20Autobuild/badge.svg?branch=testnet)](https://github.com/bitshares/bitshares-core/actions?query=branch%3Atestnet) | [https://github.com/bitshares/bitshares-fc/workflows/Github%20Autobuild/badge.svg?branch=master](https://github.com/bitshares/bitshares-fc/actions?query=branch%3Amaster)

* [Getting Started](#getting-started)
* [Support](#support)
Expand Down
7 changes: 6 additions & 1 deletion libraries/plugins/elasticsearch/elasticsearch_plugin.cpp
Expand Up @@ -584,7 +584,12 @@ vector<operation_history_object> elasticsearch_plugin::get_account_history(
variant variant_response = fc::json::from_string(response);

const auto hits = variant_response["hits"]["total"];
const auto size = std::min(static_cast<uint32_t>(hits.as_uint64()), limit);
uint32_t size;
if( hits.is_object() ) // ES-7 ?
size = static_cast<uint32_t>(hits["value"].as_uint64());
else // probably ES-6
size = static_cast<uint32_t>(hits.as_uint64());
size = std::min( size, limit );

for(unsigned i=0; i<size; i++)
{
Expand Down
54 changes: 54 additions & 0 deletions programs/build_helpers/run-node-test
@@ -0,0 +1,54 @@
#!/bin/sh

DATA_DIR="`mktemp -d`"

cleanup () {
kill -9 $NODE_PID $CLI_PID
if [ "$1" != 0 ]; then
echo "----- node.log -----"
cat node.log
echo "----- cli.log -----"
cat cli.log
fi
rm -rf node.log cli.log "$DATA_DIR"
exit $1
}

echo "Starting witness node..." 1>&2
programs/witness_node/witness_node --data-dir "$DATA_DIR" \
--checkpoint '[131072,"0000000000000000000000000000000000000001"]' \
--rpc-endpoint 127.0.0.1:8090 >node.log 2>&1 &
NODE_PID=$!

echo "Waiting for cli_wallet start..." 1>&2 &
CLI_PID=$!
sleep 1
_START="`date +%s`"
while ! ps -p "$CLI_PID" >/dev/null && [ $((`date +%s` - _START)) -lt 120 ]; do
programs/cli_wallet/cli_wallet -s ws://127.0.0.1:8090 -d -H 127.0.0.1:8091 >cli.log 2>&1 &
CLI_PID=$!
sleep 2
done

if ! ps -p "$CLI_PID" >/dev/null; then
echo "Failed to start?!" 1>&2
cleanup 1
fi

echo "Waiting for head_block 131071..." 1>&2
touch "$DATA_DIR"/info.json
_START="`date +%s`"
while [ $(( "`date +%s`" - $_START )) -lt 180 ]; do
sleep 2
curl --silent -o "$DATA_DIR"/info.json --data '{"id":0,"method":"info","params":[]}' \
http://127.0.0.1:8091/rpc
tr , '\n' <"$DATA_DIR"/info.json | grep head_block_num
if tr , '\n' <"$DATA_DIR"/info.json | grep head_block_num.*131071; then
echo "Success!" 1>&2
cleanup 0
fi
done

echo "Failed to sync?!" 1>&2

cleanup 1