Skip to content

Commit

Permalink
fix(cache) push if successful (#256)
Browse files Browse the repository at this point in the history
* fix(cache) only push a cache image if the tests succeeded

* fix(cache) only update the cache images if the tests pass
  • Loading branch information
hutchic authored Apr 9, 2020
1 parent adf0477 commit 2a3cc8f
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ endif
--build-arg RESTY_IMAGE_TAG="$(RESTY_IMAGE_TAG)" \
--build-arg RESTY_IMAGE_BASE=$(RESTY_IMAGE_BASE) \
-t $(DOCKER_REPOSITORY):$(RESTY_IMAGE_BASE)-$(RESTY_IMAGE_TAG)-$(DOCKER_BASE_SUFFIX) . )
-$(UPDATE_CACHE_COMMAND) $(DOCKER_REPOSITORY):$(RESTY_IMAGE_BASE)-$(RESTY_IMAGE_TAG)-$(DOCKER_BASE_SUFFIX)

build-golang:
ifeq ($(RESTY_IMAGE_BASE),src)
Expand All @@ -167,7 +166,6 @@ else
--build-arg DOCKER_BASE_SUFFIX=$(DOCKER_BASE_SUFFIX) \
--build-arg DEBUG=$(DEBUG) \
-t $(DOCKER_REPOSITORY):go-plugin-tool-$(RESTY_IMAGE_BASE)-$(RESTY_IMAGE_TAG)-$(DOCKER_GO_SUFFIX) . )
-$(UPDATE_CACHE_COMMAND) $(DOCKER_REPOSITORY):go-plugin-tool-$(RESTY_IMAGE_BASE)-$(RESTY_IMAGE_TAG)-$(DOCKER_GO_SUFFIX)
endif

build-openresty:
Expand Down Expand Up @@ -195,7 +193,6 @@ else
--build-arg OPENRESTY_PATCHES=$(OPENRESTY_PATCHES) \
--build-arg DEBUG=$(DEBUG) \
-t $(DOCKER_REPOSITORY):openresty-$(RESTY_IMAGE_BASE)-$(RESTY_IMAGE_TAG)-$(DOCKER_OPENRESTY_SUFFIX) . )
-$(UPDATE_CACHE_COMMAND) $(DOCKER_REPOSITORY):openresty-$(RESTY_IMAGE_BASE)-$(RESTY_IMAGE_TAG)-$(DOCKER_OPENRESTY_SUFFIX)
endif

ifeq ($(RESTY_IMAGE_BASE),src)
Expand Down Expand Up @@ -261,13 +258,11 @@ actual-build-kong:
--build-arg DOCKER_OPENRESTY_SUFFIX=$(DOCKER_OPENRESTY_SUFFIX) \
--build-arg DOCKER_GO_SUFFIX=$(DOCKER_GO_SUFFIX) \
-t $(DOCKER_REPOSITORY):kong-$(RESTY_IMAGE_BASE)-$(RESTY_IMAGE_TAG)-$(DOCKER_KONG_SUFFIX) . )
-$(UPDATE_CACHE_COMMAND) $(DOCKER_REPOSITORY):kong-$(RESTY_IMAGE_BASE)-$(RESTY_IMAGE_TAG)-$(DOCKER_KONG_SUFFIX)

kong-test-container:
ifneq ($(RESTY_IMAGE_BASE),src)
-rm -rf kong
-cp -R $(KONG_SOURCE_LOCATION) kong

$(CACHE_COMMAND) $(DOCKER_REPOSITORY):test-$(DOCKER_OPENRESTY_SUFFIX) || \
( $(MAKE) build-openresty && \
docker tag $(DOCKER_REPOSITORY):openresty-$(RESTY_IMAGE_BASE)-$(RESTY_IMAGE_TAG)-$(DOCKER_OPENRESTY_SUFFIX) \
Expand All @@ -287,14 +282,14 @@ ifneq ($(RESTY_IMAGE_BASE),src)
-t $(DOCKER_REPOSITORY):test-$(DOCKER_TEST_SUFFIX) .
docker tag $(DOCKER_REPOSITORY):test-$(DOCKER_TEST_SUFFIX) $(DOCKER_REPOSITORY):test
docker tag $(DOCKER_REPOSITORY):test-$(DOCKER_TEST_SUFFIX) $(DOCKER_REPOSITORY):test-$(DOCKER_OPENRESTY_SUFFIX)

-$(UPDATE_CACHE_COMMAND) $(DOCKER_REPOSITORY):test-$(DOCKER_OPENRESTY_SUFFIX)
endif

test-kong: kong-test-container
docker-compose up -d
bash -c 'while [[ "$$(docker-compose ps | grep healthy | wc -l)" != "3" ]]; do docker-compose ps && sleep 5; done'
docker exec kong /kong/.ci/run_tests.sh
docker exec kong /kong/.ci/run_tests.sh && make update-cache-images

release-kong: test
ARCHITECTURE=amd64 \
Expand Down Expand Up @@ -347,7 +342,7 @@ ifneq ($(RESTY_IMAGE_BASE),src)
KONG_PROXY_URI="http://$(TEST_HOST):$(TEST_PROXY_PORT)" \
TEST_COMPOSE_PATH=$(TEST_COMPOSE_PATH) \
DOCKER_GO_BUILDER=$(DOCKER_REPOSITORY):go-plugin-tool-$(RESTY_IMAGE_BASE)-$(RESTY_IMAGE_TAG)-$(DOCKER_GO_SUFFIX) \
./test/run_tests.sh
./test/run_tests.sh && make update-cache-images
endif

develop-tests:
Expand Down Expand Up @@ -386,10 +381,15 @@ cleanup-tests:
ifneq ($(RESTY_IMAGE_BASE),src)
docker-compose -f test/kong-tests-compose.yaml down
docker-compose -f test/kong-tests-compose.yaml rm -f

endif

cleanup: cleanup-tests cleanup-build
-rm -rf kong
-rm -rf docker-kong
-rm -rf output/*

update-cache-images:
-$(UPDATE_CACHE_COMMAND) $(DOCKER_REPOSITORY):$(RESTY_IMAGE_BASE)-$(RESTY_IMAGE_TAG)-$(DOCKER_BASE_SUFFIX)
-$(UPDATE_CACHE_COMMAND) $(DOCKER_REPOSITORY):openresty-$(RESTY_IMAGE_BASE)-$(RESTY_IMAGE_TAG)-$(DOCKER_OPENRESTY_SUFFIX)
-$(UPDATE_CACHE_COMMAND) $(DOCKER_REPOSITORY):go-plugin-tool-$(RESTY_IMAGE_BASE)-$(RESTY_IMAGE_TAG)-$(DOCKER_GO_SUFFIX)
-$(UPDATE_CACHE_COMMAND) $(DOCKER_REPOSITORY):kong-$(RESTY_IMAGE_BASE)-$(RESTY_IMAGE_TAG)-$(DOCKER_KONG_SUFFIX)

0 comments on commit 2a3cc8f

Please sign in to comment.