-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
54 lines (47 loc) · 1.25 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
52
53
54
-include $(shell [ -e .build-harness ] || curl -sSL -o .build-harness "https://git.io/fjZtV"; echo .build-harness)
.DEFAULT_GOAL = all
all: fmt vet test
.PHONY: fmt
fmt:
go fmt ./...
.PHONY: vet
vet:
go vet ./...
.PHONY: recover
recover:
@set -o pipefail; ( \
([ ! -z "$$(docker container ls -aq)" ] && docker container stop $$(docker container ls -aq)) && \
([ ! -z "$$(docker container ls -aq)" ] && docker container rm $$(docker container ls -aq)) && \
docker network prune -f && \
exit 1 \
)
.PHONY: test
test:
@mkdir -p testdata/tmp
set -o pipefail; go test ./... -v || $(MAKE) recover
@rm -rf testdata/tmp
.PHONY: test-docker
test-docker:
@mkdir -p testdata/tmp
set -o pipefail; \
docker run --rm \
-v /var/run/docker.sock:/var/run/docker.sock \
-v $$PWD:$$PWD \
--workdir $$PWD \
golang:1.18 \
go test ./... -v || $(MAKE) recover
@rm -rf testdata/tmp
.PHONY: test-docker-network
test-docker-network:
@mkdir -p testdata/tmp
docker network create bridge-fixtures
set -o pipefail; \
docker run --rm \
--network=bridge-fixtures \
-v /var/run/docker.sock:/var/run/docker.sock \
-v $$PWD:$$PWD \
--workdir $$PWD \
-e HOST_NETWORK_NAME=bridge-fixtures \
golang:1.18 \
go test ./... -v || $(MAKE) recover
@rm -rf testdata/tmp