forked from balena-os/leviathan
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
51 lines (42 loc) · 1.22 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
SHELL = /bin/bash
DOCKER_IMAGE = balena-tests
ifndef CI
DOCKER_TTY = '--tty'
DOCKER_INTERACTIVE = '--interactive'
endif
ifdef BALENA_TESTS_DISK
DEVICE = '--device=$(BALENA_TESTS_DISK)'
endif
build-docker-image: Dockerfile
$(info Building docker image "$(DOCKER_IMAGE)"...)
@docker build --rm --tag $(DOCKER_IMAGE) .
test: build-docker-image
$(info Starting tests inside container...)
@docker run --rm \
--env "CI=$(CI)" \
--env "GITHUB_TOKEN=$(GITHUB_TOKEN)" \
--privileged \
$(foreach variable, $(shell compgen -e | grep BALENA_TESTS), \
--env "$(addsuffix =$(value $(variable)), $(variable))") \
$(DOCKER_TTY) \
$(DOCKER_INTERACTIVE) \
$(DEVICE) \
$(DOCKER_IMAGE)
enter:
ifndef id
$(error Mandatory argument "id" not defined)
endif
ifeq ("$(shell docker inspect -f '{{.State.Running}}' $(id) 2>/dev/null)","true")
$(info You are inside container "$(id)")
@docker exec -it $(id) bash
else
$(error Container "$(id)" is not running!)
endif
code-check: build-docker-image
$(info Checking coding style...)
@docker run --rm $(DOCKER_IMAGE) npm test
clean:
$(info Removing docker image "$(DOCKER_IMAGE)"...)
@docker rmi $(DOCKER_IMAGE)
.PHONY: build-docker-image test enter code-check clean
.DEFAULT_GOAL = test