Skip to content

Commit

Permalink
feat: multiple jobs for circleci (#37)
Browse files Browse the repository at this point in the history
closes #6

Add workflows
localnet ci enabled
  • Loading branch information
kfangw authored Sep 4, 2019
1 parent df53d1d commit b3df232
Show file tree
Hide file tree
Showing 2 changed files with 143 additions and 10 deletions.
112 changes: 102 additions & 10 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,110 @@
#
# Check https://circleci.com/docs/2.0/language-go/ for more details
version: 2

defaults: &linux_defaults
working_directory: /go/src/github.com/link-chain/link
docker:
- image: circleci/golang:1.12
environment:
GO111MODULE: 'on'


jobs:
build:
docker:
- image: circleci/golang:1.12
setup_dependencies:
<<: *linux_defaults
steps:
- run: mkdir -p /tmp/workspace/bin
- run: mkdir -p /tmp/workspace/profiles
- checkout
- restore_cache:
keys:
- dependency-cache-mod-{{ checksum "go.sum" }}
- run:
name: binaries
command: |
export PATH=/tmp/workspace/bin:$PATH
make go-mod-cache
make install
- save_cache:
key: dependency-cache-mod-{{ checksum "go.sum" }}
paths:
- "/go/pkg/mod"
- run:
name: tools
command: |
make get-tools
- persist_to_workspace:
root: /tmp/workspace
paths:
- bin
unit_test:
<<: *linux_defaults
parallelism: 2
steps:
- attach_workspace:
at: /tmp/workspace
- checkout
- restore_cache:
keys:
- dependency-cache-mod-{{ checksum "go.sum" }}

working_directory: /go/src/github.com/link-chain/link
- run:
name: Test unittest
command: |
make check-unit
integration_test:
<<: *linux_defaults
parallelism: 1
steps:
- attach_workspace:
at: /tmp/workspace
- checkout
- restore_cache:
keys:
- dependency-cache-mod-{{ checksum "go.sum" }}
- run:
name: Test cli
command: |
export BUILDDIR=`pwd`/build
make check-build
localnet:
working_directory: /home/circleci/.go_workspace/src/github.com/link-chain/link
machine:
image: circleci/classic:latest
environment:
GOPATH: /home/circleci/.go_workspace/
GOOS: linux
GOARCH: amd64
GO_VERSION: "1.12.5"
parallelism: 1
steps:
- checkout
- run:
name: run localnet and exit on failure
command: |
pushd /tmp
wget https://dl.google.com/go/go$GO_VERSION.linux-amd64.tar.gz
sudo tar -xvf go$GO_VERSION.linux-amd64.tar.gz
sudo rm -rf /usr/local/go
sudo mv go /usr/local
popd
set -x
make get-tools
make build-linux
make build-docker-linkdnode
make localnet-start
./contrib/localnet-blocks-test.sh 40 5 10 localhost
# specify any bash command here prefixed with `run: `
- run: make get-tools
- run: make install
- run: make check-unit
- run: make check-race
- run: make check-build
workflows:
version: 2
build_and_test:
jobs:
- setup_dependencies
- unit_test:
requires:
- setup_dependencies
- integration_test:
requires:
- setup_dependencies
- localnet
41 changes: 41 additions & 0 deletions contrib/localnet-blocks-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/bash

CNT=0
ITER=$1
SLEEP=$2
NUMBLOCKS=$3
NODEADDR=$4

if [ -z "$1" ]; then
echo "Need to input number of iterations to run..."
exit 1
fi

if [ -z "$2" ]; then
echo "Need to input number of seconds to sleep between iterations"
exit 1
fi

if [ -z "$3" ]; then
echo "Need to input block height to declare completion..."
exit 1
fi

if [ -z "$4" ]; then
echo "Need to input node address to poll..."
exit 1
fi

while [ ${CNT} -lt $ITER ]; do
var=$(curl -s $NODEADDR:26657/status | jq -r '.result.sync_info.latest_block_height')
echo "Number of Blocks: ${var}"
if [ ! -z ${var} ] && [ ${var} -gt ${NUMBLOCKS} ]; then
echo "Number of blocks reached, exiting success..."
exit 0
fi
let CNT=CNT+1
sleep $SLEEP
done

echo "Timeout reached, exiting failure..."
exit 1

0 comments on commit b3df232

Please sign in to comment.