Browse Source

Add tests target

Andrey Volkov 6 months ago
parent
commit
96fb4e1aba
2 changed files with 76 additions and 0 deletions
  1. 63
    0
      Makefile
  2. 13
    0
      tools/install_packages.sh

+ 63
- 0
Makefile View File

@@ -12,7 +12,70 @@
12 12
 # See the License for the specific language governing permissions and
13 13
 # limitations under the License.
14 14
 
15
+IMAGE_PREFIX               ?= airshipit
16
+IMAGE_TAG                  ?= untagged
17
+IMAGE_NAME                 := aptly
18
+COMMIT                     ?= commit-id
19
+
20
+DOCKER_REGISTRY            ?= quay.io
21
+PUSH_IMAGE                 ?= false
22
+
23
+HELM                       := $(BUILD_DIR)/helm
24
+
25
+PROXY                      ?= http://proxy.foo.com:8000
26
+NO_PROXY                   ?= localhost,127.0.0.1,.svc.cluster.local
27
+USE_PROXY                  ?= false
28
+
29
+UBUNTU_BASE_IMAGE          ?= ubuntu:16.04
30
+
31
+IMAGE:=${DOCKER_REGISTRY}/${IMAGE_PREFIX}/$(IMAGE_NAME):${IMAGE_TAG}
32
+
33
+.PHONY: validate
34
+validate: lint tests
35
+
36
+.PHONY: tests
37
+tests: clean build
38
+	docker run -d \
39
+		--publish 8080:80 \
40
+		--volume $(shell pwd)/assets/nginx:/opt/nginx \
41
+		--name aptly \
42
+		${DOCKER_REGISTRY}/${IMAGE_PREFIX}/${IMAGE_NAME}:${IMAGE_TAG}
43
+	docker run --network host \
44
+		--name target \
45
+		--volume $(shell pwd)/tools:/opt \
46
+		$(UBUNTU_BASE_IMAGE) /opt/install_packages.sh
47
+
48
+.PHONY: clean
49
+clean:
50
+	docker rm -f aptly || true
51
+	docker rm -f target || true
52
+
15 53
 .PHONY: lint
16 54
 lint:
17 55
 	shellcheck assets/*.sh
18 56
 	hadolint Dockerfile
57
+
58
+.PHONY: build
59
+build:
60
+ifeq ($(USE_PROXY), true)
61
+	docker build --network host -t $(IMAGE) \
62
+		--label "org.opencontainers.image.revision=$(COMMIT)" \
63
+		--label "org.opencontainers.image.created=$(shell date --rfc-3339=seconds --utc)" \
64
+		--label "org.opencontainers.image.title=$(IMAGE_NAME)" \
65
+		-f Dockerfile \
66
+		--build-arg http_proxy=$(PROXY) \
67
+		--build-arg https_proxy=$(PROXY) \
68
+		--build-arg HTTP_PROXY=$(PROXY) \
69
+		--build-arg HTTPS_PROXY=$(PROXY) \
70
+		--build-arg no_proxy=$(NO_PROXY) \
71
+		--build-arg NO_PROXY=$(NO_PROXY) .
72
+else
73
+	docker build --network host -t $(IMAGE) \
74
+		--label "org.opencontainers.image.revision=$(COMMIT)" \
75
+		--label "org.opencontainers.image.created=$(shell date --rfc-3339=seconds --utc)" \
76
+		--label "org.opencontainers.image.title=$(IMAGE_NAME)" \
77
+		-f Dockerfile .
78
+endif
79
+ifeq ($(PUSH_IMAGE), true)
80
+	docker push $(IMAGE)
81
+endif

+ 13
- 0
tools/install_packages.sh View File

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

Loading…
Cancel
Save