diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 00000000..9cefeef3 --- /dev/null +++ b/.gitlab-ci.yml @@ -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/'" diff --git a/Makefile b/Makefile index 2709d73b..37ab8062 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/build/docker/bin/Makefile b/build/docker/bin/Makefile index dbe44e16..6a446a31 100644 --- a/build/docker/bin/Makefile +++ b/build/docker/bin/Makefile @@ -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 diff --git a/tests/integration.go b/tests/integration.go index e0483472..56a73ddb 100644 --- a/tests/integration.go +++ b/tests/integration.go @@ -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")