-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
121 lines (94 loc) · 2.72 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
116
117
118
119
120
121
VERSION = 1.0.0
REPO = samtools-mpileup-tool
MODULE = samtools_mpileup_tool
BRANCH_NAME?=unknown
GIT_SHORT_HASH:=$(shell git rev-parse --short HEAD)
LONG_VERSION:=$(shell python3 setup.py -q capture_version --semver ${VERSION} --branch ${BRANCH_NAME})
PYPI_VERSION:=$(shell python3 setup.py -q print_version --pypi)
COMMIT_HASH:=$(shell python3 setup.py -q print_version --hash)
DOCKER_REPO := quay.io/ncigdc
DOCKER_IMAGE := ${DOCKER_REPO}/${REPO}:${LONG_VERSION}
DOCKER_IMAGE_COMMIT := ${DOCKER_REPO}/${REPO}:${COMMIT_HASH}
DOCKER_IMAGE_LATEST := ${DOCKER_REPO}/${REPO}:latest
DOCKER_IMAGE_STAGING := ${DOCKER_REPO}/${REPO}:staging
DOCKER_IMAGE_RELEASE := ${DOCKER_REPO}/${REPO}:${VERSION}
.PHONY: version version-*
version:
@echo --- VERSION: ${LONG_VERSION} ---
version-short:
@echo ${VERSION}
version-long:
@echo ${LONG_VERSION}
version-pypi:
@echo ${PYPI_VERSION}
version-docker:
@echo ${DOCKER_IMAGE}
@echo ${DOCKER_IMAGE_COMMIT}
@echo ${DOCKER_IMAGE_LATEST}
.PHONY: docker-login
docker-login:
docker login -u="${QUAY_USERNAME}" -p="${QUAY_PASSWORD}" quay.io
.PHONY: build build-* clean init init-* lint requirements run version
init: init-pip init-hooks
init-pip:
@echo
@echo -- Installing pip packages --
pip3 install --no-cache-dir -r requirements.txt
python3 setup.py develop
init-hooks:
@echo
@echo -- Installing Precommit Hooks --
pre-commit install
init-venv:
@echo
PIP_REQUIRE_VIRTUALENV=true pip3 install --upgrade pip-tools
clean:
rm -rf ./build/
rm -rf ./dist/
rm -rf ./*.egg-info/
lint:
@echo
@echo -- Lint --
python3 -m flake8 \
--ignore=E501,F401,E302,E502,E126,E731,W503,W605,F841,C901 \
${MODULE}/
run:
bin/run
requirements: init-venv
python3 setup.py -q capture_requirements --dev
pip-compile -o requirements.txt requirements.in
.PHONY: build build-*
build: build-docker
build-docker: docker-login
@echo
@echo -- Building docker --
python3 setup.py build
mkdir -p dist
cp -r build/lib/* dist/
cp -r bin/ dist/
cp -f Makefile requirements.txt README.md setup.py dist/
docker build . \
--file ./Dockerfile \
-t "${DOCKER_IMAGE_COMMIT}" \
-t "${DOCKER_IMAGE}" \
-t "${DOCKER_IMAGE_LATEST}"
.PHONY: test test-*
test: lint test-unit
test-unit:
@echo
@echo -- Unit Test --
python3 -m pytest --cov-report term-missing --cov=${MODULE} tests/
test-docker:
@echo
@echo -- Running Docker Test --
docker run --rm ${DOCKER_IMAGE_LATEST} test
.PHONY: publish publish-*
publish: docker-login
docker push ${DOCKER_IMAGE_COMMIT}
publish-staging: publish
docker tag ${DOCKER_IMAGE_LATEST} ${DOCKER_IMAGE_STAGING}
docker push ${DOCKER_IMAGE_STAGING}
docker push ${DOCKER_IMAGE}
publish-release: publish
docker tag ${DOCKER_IMAGE_LATEST} ${DOCKER_IMAGE_RELEASE}
docker push ${DOCKER_IMAGE_RELEASE}