Merge branch 'ci'

This commit is contained in:
Jakub Matys 2018-10-16 13:02:28 +02:00
commit 942276ec86
4 changed files with 48 additions and 10 deletions

27
.gitlab-ci.yml Normal file
View File

@ -0,0 +1,27 @@
stages:
- build
- test
build:
stage: build
only:
- master
tags:
- blockbook
script: make build
unit-test:
stage: test
only:
- master
tags:
- blockbook
script: make test
integration-test:
stage: test
only:
- schedules
tags:
- blockbook
script: make test-integration ARGS="-run='TestIntegration/(bcash|bgold|bitcoin|dash|dogecoin|litecoin|vertcoin|zcash)=main/'"

View File

@ -39,17 +39,20 @@ $(addprefix all-, $(TARGETS)): all-%: clean-deb build-images deb-%
all: clean-deb build-images $(addprefix deb-, $(TARGETS))
build-images:
rm -f .bin-image .deb-image
build-images: clean-images
$(MAKE) .bin-image .deb-image
.bin-image:
docker build --no-cache=$(NO_CACHE) -t $(BIN_IMAGE) build/docker/bin
@ docker images -q $(BIN_IMAGE) > $@
@if [ -z "$(shell docker images --quiet --filter=reference=$(BIN_IMAGE):latest)" ]; then \
echo "Building image $(BIN_IMAGE)..."; \
docker build --no-cache=$(NO_CACHE) -t $(BIN_IMAGE) build/docker/bin; \
fi
.deb-image: .bin-image
docker build --no-cache=$(NO_CACHE) -t $(DEB_IMAGE) build/docker/deb
@ docker images -q $(DEB_IMAGE) > $@
@if [ -z "$(shell docker images --quiet --filter=reference=$(DEB_IMAGE):latest)" ]; then \
echo "Building image $(DEB_IMAGE)..."; \
docker build --no-cache=$(NO_CACHE) -t $(DEB_IMAGE) build/docker/deb; \
fi
clean: clean-bin clean-deb
@ -66,8 +69,6 @@ clean-images: clean-bin-image clean-deb-image
clean-bin-image:
- docker rmi $(BIN_IMAGE)
@ rm -f .bin-image
clean-deb-image:
- docker rmi $(DEB_IMAGE)
@ rm -f .deb-image

View File

@ -34,7 +34,7 @@ test-all: prepare-sources generate-data
prepare-sources:
@ [ -n "`ls /src 2> /dev/null`" ] || (echo "/src doesn't exist or is empty" 1>&2 && exit 1)
[ -d $(BLOCKBOOK_SRC) ] && rm -rf $(BLOCKBOOK_SRC)
rm -rf $(BLOCKBOOK_SRC)
cp -r /src $(BLOCKBOOK_SRC)
$(MAKE) prepare-vendor

View File

@ -17,6 +17,7 @@ import (
"path/filepath"
"reflect"
"sort"
"strings"
"testing"
"github.com/jakm/btcutil/chaincfg"
@ -45,7 +46,8 @@ func runIntegrationTests(t *testing.T) {
for _, coin := range keys {
cfg := tests[coin]
t.Run(coin, func(t *testing.T) { runTests(t, coin, cfg) })
name := getMatchableName(coin)
t.Run(name, func(t *testing.T) { runTests(t, coin, cfg) })
}
}
@ -60,6 +62,14 @@ func loadTests(path string) (map[string]map[string]json.RawMessage, error) {
return v, err
}
func getMatchableName(coin string) string {
if idx := strings.Index(coin, "_testnet"); idx != -1 {
return coin[:idx] + "=test"
} else {
return coin + "=main"
}
}
func runTests(t *testing.T, coin string, cfg map[string]json.RawMessage) {
if cfg == nil || len(cfg) == 0 {
t.Skip("No tests to run")