From 1be19c1a34e21e904c38a7ef07d4b7479fe67060 Mon Sep 17 00:00:00 2001 From: Alfredo Garcia Date: Wed, 28 Aug 2019 13:06:26 -0300 Subject: [PATCH] initial travis --- .travis.yml | 28 ++++++++++++++ programs/build_helpers/build_and_test | 11 ++++++ programs/build_helpers/build_protocol | 11 ++++++ programs/build_helpers/buildstep | 55 +++++++++++++++++++++++++++ 4 files changed, 105 insertions(+) create mode 100644 .travis.yml create mode 100644 programs/build_helpers/build_and_test create mode 100644 programs/build_helpers/build_protocol create mode 100644 programs/build_helpers/buildstep diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..292d6620 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,28 @@ +language: c++ + +cache: ccache + +git: + depth: 1 + +dist: xenial + +sudo: true + +install: + - sudo apt-get install --allow-unauthenticated 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 cmake parallel + +addons: + +env: + global: + - CCACHE_COMPRESS=exists_means_true + - CCACHE_MAXSIZE=1Gi + - CCACHE_SLOPPINESS=include_file_ctime,include_file_mtime,time_macros + +jobs: + include: + - stage: build for cache + script: ./programs/build_helpers/build_protocol + - stage: build and test +script: ./programs/build_helpers/build_and_test diff --git a/programs/build_helpers/build_and_test b/programs/build_helpers/build_and_test new file mode 100644 index 00000000..9eb783cf --- /dev/null +++ b/programs/build_helpers/build_and_test @@ -0,0 +1,11 @@ +#!/bin/bash +set -e + +programs/build_helpers/buildstep -s 3500 +ccache -s +programs/build_helpers/buildstep Prepare 1 "sed -i '/tests/d' libraries/fc/CMakeLists.txt" +programs/build_helpers/buildstep cmake 5 "cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_FLAGS=--coverage -DCMAKE_CXX_FLAGS=--coverage -DBoost_USE_STATIC_LIBS=OFF -DCMAKE_CXX_OUTPUT_EXTENSION_REPLACE=ON ." +programs/build_helpers/buildstep make.fc 200 "make -j 2 fc" +programs/build_helpers/buildstep make.custom_auths 1000 "make -j 2 graphene_protocol" +programs/build_helpers/buildstep end 0 +ccache -s diff --git a/programs/build_helpers/build_protocol b/programs/build_helpers/build_protocol new file mode 100644 index 00000000..9eb783cf --- /dev/null +++ b/programs/build_helpers/build_protocol @@ -0,0 +1,11 @@ +#!/bin/bash +set -e + +programs/build_helpers/buildstep -s 3500 +ccache -s +programs/build_helpers/buildstep Prepare 1 "sed -i '/tests/d' libraries/fc/CMakeLists.txt" +programs/build_helpers/buildstep cmake 5 "cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_FLAGS=--coverage -DCMAKE_CXX_FLAGS=--coverage -DBoost_USE_STATIC_LIBS=OFF -DCMAKE_CXX_OUTPUT_EXTENSION_REPLACE=ON ." +programs/build_helpers/buildstep make.fc 200 "make -j 2 fc" +programs/build_helpers/buildstep make.custom_auths 1000 "make -j 2 graphene_protocol" +programs/build_helpers/buildstep end 0 +ccache -s diff --git a/programs/build_helpers/buildstep b/programs/build_helpers/buildstep new file mode 100644 index 00000000..44d5458a --- /dev/null +++ b/programs/build_helpers/buildstep @@ -0,0 +1,55 @@ +#!/bin/sh + +usage () { + echo Usage: + echo " ${0##*/} [-h | --help] Display this help message" + echo " ${0##*/} -s | --start Initialize timing" + echo " ${0##*/} " + echo "The last form executes build step consisting of shell " + echo "if imated time is still available, otherwise it fails fast." + echo " and must be specified in seconds." + exit $1 +} + +if [ "$#" = 0 -o "$1" = "--help" -o "$1" = "-h" ]; then + usage `test "$#" = 1; echo $?` +fi + +NOW="$(date +%s)" + +if [ "$1" = "--start" -o "$1" = "-s" ]; then + if [ "$#" != 2 ]; then + usage 1 + fi + echo "$2 $NOW" >_start_time + echo "Starting at $(date --date=@$NOW)" + exit 0 +fi + +NAME="$1" +EST="$2" +CMD="$3" + +if [ ! -r _start_time ]; then + echo "Need to initialize with '$0 -s ' first!" 1>&2 + exit 1 +fi + +read max begin prev_name prev_begin <_start_time + +if [ "$prev_name" != "" ]; then + echo "'$prev_name' took $(($NOW - $prev_begin))s" +fi + +if [ "$CMD" != "" ]; then + if [ $(($NOW - $begin + $EST)) -lt $max ]; then + echo "Running '$NAME' at $NOW..." + echo "sh -c '$CMD'" + echo "$max $begin $NAME $NOW" >_start_time + exec bash -c "$CMD" + fi + echo "$(($begin + $max - $NOW))s left - insufficient to run '$NAME', exiting!" 1>&2 + exit 1 +fi + +exit 0