-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
115 lines (96 loc) · 2.51 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
SHELL := /bin/bash
DOCKER_REPO := dankcity/dank-link-decoder
DOCKER_REPO_CI := dankcity/dank-link-decoder-ci
GIT_HASH = $(shell git rev-parse --short=7 HEAD)
GIT_TAG = $(shell git describe --tags --exact-match $(GIT_HASH) 2>/dev/null)
.PHONY: install-poetry
install-poetry:
curl -sSL https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py | python3
.PHONY: shell
shell:
docker run --rm -it --entrypoint ash $(DOCKER_REPO):local
.PHONY: package
package: clean-dist clean-pkg
ifneq ($(CIRCLECI), )
source $(HOME)/.poetry/env && poetry build --format sdist
else
poetry build --format sdist
endif
mkdir -p pkg
find . -name "dank-link-decoder*.tar.gz" -exec tar --strip-components=1 -zxvf {} -C pkg \;
.PHONY: build
build:
docker build -t $(DOCKER_REPO):local .
.PHONY: test
test: test-lint test-unit test-functional
.PHONY: test-lint
test-lint:
docker run --rm -it \
--entrypoint ash \
$(DOCKER_REPO):local \
-c ' \
set -e; \
pip install tox; \
tox -e lint; \
'
.PHONY: test-unit
test-unit:
docker run --rm -it \
--env-file <(env | grep -e "^CI") \
--entrypoint ash \
$(DOCKER_REPO):local \
-c ' \
set -e; \
pip install tox; \
tox -e unit; \
if [ -n "$$CIRCLE_SHA1" ]; \
then pip install codecov && codecov --commit=$$CIRCLE_SHA1; \
fi \
'
.PHONY: test-functional
test-functional:
echo "Not yet enabled"
# docker run --rm -it \
# -w /clocme \
# -v `pwd`:/clocme \
# -v /var/run/docker.sock:/var/run/docker.sock \
# -e IMAGE_NAME=$(DOCKER_REPO):local \
# python:alpine \
# ash -c ' \
# set -e; \
# pip install tox; \
# tox -e functional \
# '
.PHONY: tag-latest
tag-latest:
docker tag $(DOCKER_REPO):local $(DOCKER_REPO):latest
.PHONY: tag-git-tag
tag-git-tag:
docker tag $(DOCKER_REPO):$(GIT_HASH) $(DOCKER_REPO):$(GIT_TAG)
.PHONY: push-latest
push-latest:
docker push $(DOCKER_REPO):latest
.PHONY: pull-latest
pull-latest:
docker pull $(DOCKER_REPO):latest
.PHONY: tag-latest-as-local
tag-latest-as-local:
docker tag $(DOCKER_REPO):latest $(DOCKER_REPO):local
.PHONY: push-tagged
push-tagged:
docker push $(DOCKER_REPO):$(GIT_TAG)
.PHONY: push-ci
push-ci:
docker tag $(DOCKER_REPO):local $(DOCKER_REPO_CI):$(GIT_HASH)
docker push $(DOCKER_REPO_CI):$(GIT_HASH)
.PHONY: pull-ci
pull-ci:
docker pull $(DOCKER_REPO_CI):$(GIT_HASH)
docker tag $(DOCKER_REPO_CI):$(GIT_HASH) $(DOCKER_REPO):$(GIT_HASH)
docker tag $(DOCKER_REPO_CI):$(GIT_HASH) $(DOCKER_REPO):local
.PHONY: clean-dist
clean-dist:
rm -rf dist
.PHONY: clean-pkg
clean-pkg:
rm -rf pkg