2017-02-02 15:35:58 +00:00
|
|
|
PYVERSIONS=3.5 3.4 2.7
|
2016-09-21 16:59:28 +00:00
|
|
|
PYMAIN=$(firstword $(PYVERSIONS))
|
2016-09-20 18:55:59 +00:00
|
|
|
NAME=senpy
|
|
|
|
REPO=gsiupm
|
|
|
|
VERSION=$(shell cat $(NAME)/VERSION)
|
2017-01-10 15:59:28 +00:00
|
|
|
TARNAME=$(NAME)-$(subst -,.,$(VERSION)).tar.gz
|
2017-02-08 20:55:17 +00:00
|
|
|
IMAGENAME=$(REPO)/$(NAME):$(VERSION)
|
2017-02-13 11:04:29 +00:00
|
|
|
TEST_COMMAND=gitlab-runner exec docker --cache-dir=/tmp/gitlabrunner --docker-volumes /tmp/gitlabrunner:/tmp/gitlabrunner --env CI_PROJECT_NAME=$(NAME)
|
2016-09-20 18:55:59 +00:00
|
|
|
|
|
|
|
all: build run
|
|
|
|
|
2017-01-10 09:16:45 +00:00
|
|
|
yapf:
|
|
|
|
yapf -i -r senpy
|
|
|
|
yapf -i -r tests
|
|
|
|
|
2017-01-10 10:10:10 +00:00
|
|
|
dev:
|
|
|
|
pip install --user pre-commit
|
|
|
|
pre-commit install
|
|
|
|
|
2016-09-20 18:55:59 +00:00
|
|
|
dockerfiles: $(addprefix Dockerfile-,$(PYVERSIONS))
|
2017-02-02 15:35:58 +00:00
|
|
|
@unlink Dockerfile >/dev/null
|
2016-12-19 17:18:47 +00:00
|
|
|
ln -s Dockerfile-$(PYMAIN) Dockerfile
|
2016-09-20 18:55:59 +00:00
|
|
|
|
|
|
|
Dockerfile-%: Dockerfile.template
|
|
|
|
sed "s/{{PYVERSION}}/$*/" Dockerfile.template > Dockerfile-$*
|
|
|
|
|
2017-02-08 20:55:17 +00:00
|
|
|
quick_build: $(addprefix build-, $(PYMAIN))
|
2016-09-21 16:59:28 +00:00
|
|
|
|
2017-02-08 20:55:17 +00:00
|
|
|
build: $(addprefix build-, $(PYVERSIONS))
|
2016-09-20 18:55:59 +00:00
|
|
|
|
|
|
|
build-%: Dockerfile-%
|
2017-02-08 20:55:17 +00:00
|
|
|
docker build -t '$(IMAGENAME)-python$*' -f Dockerfile-$* .;
|
2016-09-20 18:55:59 +00:00
|
|
|
|
2017-02-08 20:55:17 +00:00
|
|
|
quick_test: $(addprefix test-,$(PYMAIN))
|
2017-01-10 09:02:14 +00:00
|
|
|
|
2017-02-08 20:55:17 +00:00
|
|
|
test: $(addprefix test-,$(PYVERSIONS))
|
2016-09-20 18:55:59 +00:00
|
|
|
|
2017-02-02 15:35:58 +00:00
|
|
|
debug-%:
|
2017-02-08 20:55:17 +00:00
|
|
|
(docker start $(NAME)-debug && docker attach $(NAME)-debug) || docker run -w /usr/src/app/ -v $$PWD:/usr/src/app --entrypoint=/bin/bash -ti --name $(NAME)-debug '$(IMAGENAME)-python$*'
|
2017-01-10 09:02:14 +00:00
|
|
|
|
|
|
|
debug: debug-$(PYMAIN)
|
2016-12-19 17:18:47 +00:00
|
|
|
|
2017-02-13 11:04:29 +00:00
|
|
|
test-%:
|
|
|
|
$(TEST_COMMAND) test-$*
|
2016-09-21 16:59:28 +00:00
|
|
|
|
2017-01-10 15:59:28 +00:00
|
|
|
dist/$(TARNAME):
|
2016-12-14 13:38:58 +00:00
|
|
|
docker run --rm -ti -v $$PWD:/usr/src/app/ -w /usr/src/app/ python:$(PYMAIN) python setup.py sdist;
|
|
|
|
|
2017-01-10 15:59:28 +00:00
|
|
|
sdist: dist/$(TARNAME)
|
2016-12-14 13:38:58 +00:00
|
|
|
|
|
|
|
pip_test-%: sdist
|
2017-01-10 15:59:28 +00:00
|
|
|
docker run --rm -v $$PWD/dist:/dist/ -ti python:$* pip install /dist/$(TARNAME);
|
2016-12-14 13:38:58 +00:00
|
|
|
|
|
|
|
pip_test: $(addprefix pip_test-,$(PYVERSIONS))
|
2016-09-21 16:59:28 +00:00
|
|
|
|
|
|
|
upload-%: test-%
|
2017-02-08 20:55:17 +00:00
|
|
|
docker push '$(IMAGENAME)-python$*'
|
2016-09-20 18:55:59 +00:00
|
|
|
|
2017-02-08 20:55:17 +00:00
|
|
|
upload: test $(addprefix upload-,$(PYVERSIONS))
|
|
|
|
docker tag '$(IMAGENAME)-python$(PYMAIN)' '$(IMAGENAME)'
|
|
|
|
docker tag '$(IMAGENAME)-python$(PYMAIN)' '$(REPO)/$(NAME)'
|
|
|
|
docker push '$(IMAGENAME)'
|
|
|
|
docker push '$(REPO)/$(NAME)'
|
2016-09-21 18:27:30 +00:00
|
|
|
|
|
|
|
clean:
|
|
|
|
@docker ps -a | awk '/$(REPO)\/$(NAME)/{ split($$2, vers, "-"); if(vers[1] != "${VERSION}"){ print $$1;}}' | xargs docker rm 2>/dev/null|| true
|
|
|
|
@docker images | awk '/$(REPO)\/$(NAME)/{ split($$2, vers, "-"); if(vers[1] != "${VERSION}"){ print $$1":"$$2;}}' | xargs docker rmi 2>/dev/null|| true
|
2017-01-10 09:02:14 +00:00
|
|
|
@docker rmi $(NAME)-debug 2>/dev/null || true
|
2016-09-21 18:27:30 +00:00
|
|
|
|
2016-09-21 18:29:16 +00:00
|
|
|
upload_git:
|
|
|
|
git commit -a
|
|
|
|
git tag ${VERSION}
|
|
|
|
git push --tags origin master
|
2016-09-21 08:10:49 +00:00
|
|
|
|
2016-09-21 16:59:28 +00:00
|
|
|
pip_upload:
|
|
|
|
python setup.py sdist upload ;
|
2016-09-21 08:10:49 +00:00
|
|
|
|
2016-09-21 16:59:28 +00:00
|
|
|
pip_test: $(addprefix pip_test-,$(PYVERSIONS))
|
2016-09-21 08:10:49 +00:00
|
|
|
|
2016-09-21 16:59:28 +00:00
|
|
|
run: build
|
2017-02-08 20:55:17 +00:00
|
|
|
docker run --rm -p 5000:5000 -ti '$(IMAGENAME)-python$(PYMAIN)'
|
2016-09-20 18:55:59 +00:00
|
|
|
|
2017-01-10 15:59:28 +00:00
|
|
|
.PHONY: test test-% build-% build test pip_test run yapf dev
|