-
Notifications
You must be signed in to change notification settings - Fork 25
/
Makefile
115 lines (100 loc) · 3.89 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
.PHONY: hokusai test integration integration-local pyinstaller-build-onefile pyinstaller-build-onedir publish-to-s3 publish-to-s3-canonical build-docker-image publish-to-dockerhub-beta publish-to-dockerhub-canonical-and-latest publish-to-pip publish-to-github clean
# a var passed in as an argument to 'make' command moots its ?= assgiment
AWS ?= $(shell which aws)
DIST_DIR ?= dist/
PROJECT = github.com/artsy/hokusai
VERSION ?= $(shell cat hokusai/VERSION)
MINOR_VERSION ?= $(shell cat hokusai/VERSION | awk -F"." '{ print $$1"."$$2 }')
RELEASE_MINOR_VERSION ?= $(shell cat hokusai/VERSION | awk -F"." '{ print $$1"."$$2 }')
ARTIFACT_LABEL ?= $(shell cat hokusai/VERSION)
BINARY_SUFFIX ?= -$(ARTIFACT_LABEL)-$(shell uname -s)-$(shell uname -m)
hokusai:
pip install --upgrade pip
# pin version due to https://github.com/python-poetry/poetry/issues/7184
pip install poetry==1.2.2 --quiet --ignore-installed
poetry --version
poetry install
test:
coverage run -m pytest test/unit
integration:
coverage run -m pytest test/integration
integration-local:
scripts/integration_test_local.sh
pyinstaller-build-onefile: # for linux
pyinstaller \
--distpath=$(DIST_DIR) \
--workpath=/tmp/build/ \
hokusai_onefile.spec
mkdir -p $(DIST_DIR)hokusai$(BINARY_SUFFIX)
cp $(DIST_DIR)hokusai $(DIST_DIR)hokusai$(BINARY_SUFFIX)/hokusai
tar cfvz $(DIST_DIR)hokusai$(BINARY_SUFFIX).tar.gz -C $(DIST_DIR)hokusai$(BINARY_SUFFIX) .
rm -rf $(DIST_DIR)hokusai$(BINARY_SUFFIX)
mv $(DIST_DIR)hokusai $(DIST_DIR)hokusai$(BINARY_SUFFIX)
# for mac (because build-onefile's binary runs too slow on mac)
pyinstaller-build-onedir:
pyinstaller \
--target-architecture=x86_64 \
--distpath=$(DIST_DIR) \
--workpath=/tmp/build/ \
hokusai_onedir.spec
mv $(DIST_DIR)hokusai $(DIST_DIR)hokusai$(BINARY_SUFFIX)
tar cfvz $(DIST_DIR)hokusai$(BINARY_SUFFIX).tar.gz -C $(DIST_DIR)hokusai$(BINARY_SUFFIX) .
rm -rf $(DIST_DIR)hokusai$(BINARY_SUFFIX)
publish-to-s3: # for 'beta' and 'latest'
$(AWS) s3 cp \
--acl public-read \
--recursive \
--exclude "*" \
--include "hokusai-$(ARTIFACT_LABEL)-*" \
dist/ s3://artsy-provisioning-public/hokusai/
publish-to-s3-canonical:
if [ "$(shell curl -I --silent https://s3.amazonaws.com/artsy-provisioning-public/hokusai/hokusai-$(BINARY_SUFFIX) --output /dev/null --write-out %{http_code})" -eq 403 ]; then \
$(AWS) s3 cp \
--acl public-read \
--recursive \
--exclude "*" \
--include "hokusai-$(ARTIFACT_LABEL)-*" \
dist/ s3://artsy-provisioning-public/hokusai/; \
else \
echo "Version $(ARTIFACT_LABEL) already published"; \
exit 0; \
fi
build-docker-image:
poetry build
docker build . \
--tag hokusai
publish-to-dockerhub-beta:
docker tag hokusai:latest artsy/hokusai:beta
docker push artsy/hokusai:beta
publish-to-dockerhub-canonical-and-latest:
if [ "$(shell curl --silent https://hub.docker.com/v2/namespaces/artsy/repositories/hokusai/tags/$(ARTIFACT_LABEL) --output /dev/null --write-out %{http_code})" -eq 404 ]; then \
docker tag hokusai:latest artsy/hokusai:$(ARTIFACT_LABEL) && \
docker push artsy/hokusai:$(ARTIFACT_LABEL) && \
docker tag hokusai:latest artsy/hokusai:$(RELEASE_MINOR_VERSION) && \
docker push artsy/hokusai:$(RELEASE_MINOR_VERSION) && \
docker tag hokusai:latest artsy/hokusai:latest && \
docker push artsy/hokusai:latest; \
else \
echo "Version $(ARTIFACT_LABEL) already published"; \
exit 0; \
fi
publish-to-pip:
pip install --upgrade wheel
poetry version $(RELEASE_VERSION) # bump version in pyproject.toml
poetry build
twine upload --skip-existing dist/* --verbose
publish-to-github:
$(AWS) s3 cp \
--acl public-read \
--recursive \
--exclude "*" \
--include "hokusai-$(ARTIFACT_LABEL)-*" \
s3://artsy-provisioning-public/hokusai/ dist/; \
ghr \
--username artsy \
--repository hokusai \
--name v$(ARTIFACT_LABEL) \
--soft \
v$(ARTIFACT_LABEL) dist/
clean:
sudo $(RM) -r ./dist