Add tests target

This commit is contained in:
Andrey Volkov 2018-10-24 14:21:09 -07:00
parent f3b55fe64d
commit 96fb4e1aba
2 changed files with 76 additions and 0 deletions

View File

@ -12,7 +12,70 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
IMAGE_PREFIX ?= airshipit
IMAGE_TAG ?= untagged
IMAGE_NAME := aptly
COMMIT ?= commit-id
DOCKER_REGISTRY ?= quay.io
PUSH_IMAGE ?= false
HELM := $(BUILD_DIR)/helm
PROXY ?= http://proxy.foo.com:8000
NO_PROXY ?= localhost,127.0.0.1,.svc.cluster.local
USE_PROXY ?= false
UBUNTU_BASE_IMAGE ?= ubuntu:16.04
IMAGE:=${DOCKER_REGISTRY}/${IMAGE_PREFIX}/$(IMAGE_NAME):${IMAGE_TAG}
.PHONY: validate
validate: lint tests
.PHONY: tests
tests: clean build
docker run -d \
--publish 8080:80 \
--volume $(shell pwd)/assets/nginx:/opt/nginx \
--name aptly \
${DOCKER_REGISTRY}/${IMAGE_PREFIX}/${IMAGE_NAME}:${IMAGE_TAG}
docker run --network host \
--name target \
--volume $(shell pwd)/tools:/opt \
$(UBUNTU_BASE_IMAGE) /opt/install_packages.sh
.PHONY: clean
clean:
docker rm -f aptly || true
docker rm -f target || true
.PHONY: lint .PHONY: lint
lint: lint:
shellcheck assets/*.sh shellcheck assets/*.sh
hadolint Dockerfile hadolint Dockerfile
.PHONY: build
build:
ifeq ($(USE_PROXY), true)
docker build --network host -t $(IMAGE) \
--label "org.opencontainers.image.revision=$(COMMIT)" \
--label "org.opencontainers.image.created=$(shell date --rfc-3339=seconds --utc)" \
--label "org.opencontainers.image.title=$(IMAGE_NAME)" \
-f Dockerfile \
--build-arg http_proxy=$(PROXY) \
--build-arg https_proxy=$(PROXY) \
--build-arg HTTP_PROXY=$(PROXY) \
--build-arg HTTPS_PROXY=$(PROXY) \
--build-arg no_proxy=$(NO_PROXY) \
--build-arg NO_PROXY=$(NO_PROXY) .
else
docker build --network host -t $(IMAGE) \
--label "org.opencontainers.image.revision=$(COMMIT)" \
--label "org.opencontainers.image.created=$(shell date --rfc-3339=seconds --utc)" \
--label "org.opencontainers.image.title=$(IMAGE_NAME)" \
-f Dockerfile .
endif
ifeq ($(PUSH_IMAGE), true)
docker push $(IMAGE)
endif

13
tools/install_packages.sh Executable file
View File

@ -0,0 +1,13 @@
#!/usr/bin/env bash
set -o pipefail
set -o errexit
set -o xtrace
apt update
apt install -y curl
curl -s localhost:8080/aptly_repo_signing.key | apt-key add -
echo 'deb http://localhost:8080 xenial main' > /etc/apt/sources.list
apt-get update
apt-cache policy accountsservice
apt-get install -y accountsservice