2017-02-27 11:14:39 +00:00
|
|
|
PYVERSIONS=3.5 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
|
2017-02-27 11:14:39 +00:00
|
|
|
VERSION=$(shell git describe --tags --dirty 2>/dev/null)
|
2017-02-27 10:37:43 +00:00
|
|
|
TARNAME=$(NAME)-$(VERSION).tar.gz
|
2017-02-27 19:00:09 +00:00
|
|
|
IMAGENAME=$(REPO)/$(NAME)
|
|
|
|
IMAGEWTAG=$(IMAGENAME):$(VERSION)
|
2017-03-14 18:54:33 +00:00
|
|
|
DEVPORT=5000
|
2017-02-27 11:14:39 +00:00
|
|
|
action="test-${PYMAIN}"
|
2016-09-20 18:55:59 +00:00
|
|
|
|
|
|
|
all: build run
|
|
|
|
|
2017-02-27 11:14:39 +00:00
|
|
|
.FORCE:
|
2017-02-27 10:37:43 +00:00
|
|
|
|
2017-02-27 11:14:39 +00:00
|
|
|
version: .FORCE
|
2017-02-27 10:37:43 +00:00
|
|
|
@echo $(VERSION) > $(NAME)/VERSION
|
2017-02-27 11:14:39 +00:00
|
|
|
@echo $(VERSION)
|
2017-02-27 10:37:43 +00:00
|
|
|
|
2017-01-10 09:16:45 +00:00
|
|
|
yapf:
|
|
|
|
yapf -i -r senpy
|
|
|
|
yapf -i -r tests
|
|
|
|
|
2017-02-27 11:14:39 +00:00
|
|
|
init:
|
2017-01-10 10:10:10 +00:00
|
|
|
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
|
|
|
|
2017-02-27 11:14:39 +00:00
|
|
|
build-%: version Dockerfile-%
|
2017-02-27 19:00:09 +00:00
|
|
|
docker build -t '$(IMAGEWTAG)-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-27 11:14:39 +00:00
|
|
|
dev-%:
|
2017-02-28 03:28:54 +00:00
|
|
|
@docker start $(NAME)-dev$* || (\
|
2017-02-27 10:37:43 +00:00
|
|
|
$(MAKE) build-$*; \
|
2017-03-14 18:54:33 +00:00
|
|
|
docker run -d -w /usr/src/app/ -p $(DEVPORT):5000 -v $$PWD:/usr/src/app --entrypoint=/bin/bash -ti --name $(NAME)-dev$* '$(IMAGEWTAG)-python$*'; \
|
2017-02-27 10:37:43 +00:00
|
|
|
)\
|
|
|
|
|
2017-02-28 03:28:54 +00:00
|
|
|
docker exec -ti $(NAME)-dev$* bash
|
2017-02-27 11:14:39 +00:00
|
|
|
|
|
|
|
dev: dev-$(PYMAIN)
|
|
|
|
|
|
|
|
test-all: $(addprefix test-,$(PYVERSIONS))
|
2017-01-10 09:02:14 +00:00
|
|
|
|
2017-02-27 11:14:39 +00:00
|
|
|
test-%: build-%
|
2017-02-27 19:00:09 +00:00
|
|
|
docker run --rm --entrypoint /usr/local/bin/python -w /usr/src/app $(IMAGEWTAG)-python$* setup.py test
|
2016-12-19 17:18:47 +00:00
|
|
|
|
2017-02-27 11:14:39 +00:00
|
|
|
test: test-$(PYMAIN)
|
2016-09-21 16:59:28 +00:00
|
|
|
|
2017-04-04 09:30:56 +00:00
|
|
|
dist/$(TARNAME): version
|
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-04-04 09:30:56 +00:00
|
|
|
docker run --rm -ti -v $$PWD:/usr/src/app/ -w /usr/src/app/ python:$(PYMAIN) chmod -R a+rwx dist;
|
|
|
|
|
2016-12-14 13:38:58 +00:00
|
|
|
|
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
|
|
|
|
2016-09-21 18:27:30 +00:00
|
|
|
clean:
|
2017-02-17 15:13:11 +00:00
|
|
|
@docker ps -a | awk '/$(REPO)\/$(NAME)/{ split($$2, vers, "-"); if(vers[0] != "${VERSION}"){ print $$1;}}' | xargs docker rm -v 2>/dev/null|| true
|
|
|
|
@docker images | awk '/$(REPO)\/$(NAME)/{ split($$2, vers, "-"); if(vers[0] != "${VERSION}"){ print $$1":"$$2;}}' | xargs docker rmi 2>/dev/null|| true
|
2017-02-27 11:14:39 +00:00
|
|
|
@docker rmi $(NAME)-dev 2>/dev/null || true
|
2016-09-21 18:27:30 +00:00
|
|
|
|
2017-02-27 11:14:39 +00:00
|
|
|
|
|
|
|
git_commit:
|
2016-09-21 18:29:16 +00:00
|
|
|
git commit -a
|
2017-02-27 11:14:39 +00:00
|
|
|
|
|
|
|
git_tag:
|
2016-09-21 18:29:16 +00:00
|
|
|
git tag ${VERSION}
|
2017-02-27 11:14:39 +00:00
|
|
|
|
2017-02-27 18:30:02 +00:00
|
|
|
git_push:
|
2016-09-21 18:29:16 +00:00
|
|
|
git push --tags origin master
|
2016-09-21 08:10:49 +00:00
|
|
|
|
2017-04-04 09:30:56 +00:00
|
|
|
pip_upload: pip_test
|
2016-09-21 16:59:28 +00:00
|
|
|
python setup.py sdist upload ;
|
2016-09-21 08:10:49 +00:00
|
|
|
|
2017-02-27 10:37:43 +00:00
|
|
|
run-%: build-%
|
2017-03-14 18:54:33 +00:00
|
|
|
docker run --rm -p $(DEVPORT):5000 -ti '$(IMAGEWTAG)-python$(PYMAIN)' --default-plugins
|
2017-02-27 10:37:43 +00:00
|
|
|
|
|
|
|
run: run-$(PYMAIN)
|
2016-09-20 18:55:59 +00:00
|
|
|
|
2017-02-27 11:14:39 +00:00
|
|
|
push-latest: build-$(PYMAIN)
|
2017-02-27 19:00:09 +00:00
|
|
|
docker tag '$(IMAGEWTAG)-python$(PYMAIN)' '$(IMAGEWTAG)'
|
|
|
|
docker tag '$(IMAGEWTAG)-python$(PYMAIN)' '$(IMAGENAME)'
|
2017-03-01 16:59:35 +00:00
|
|
|
docker push '$(IMAGENAME):latest'
|
2017-02-27 19:00:09 +00:00
|
|
|
docker push '$(IMAGEWTAG)'
|
2017-02-27 11:14:39 +00:00
|
|
|
|
2017-02-27 19:38:55 +00:00
|
|
|
push-%: build-%
|
|
|
|
docker push $(IMAGENAME):$(VERSION)-python$*
|
|
|
|
|
2017-03-01 17:49:52 +00:00
|
|
|
push: $(addprefix push-,$(PYVERSIONS))
|
|
|
|
docker tag '$(IMAGEWTAG)-python$(PYMAIN)' '$(IMAGEWTAG)'
|
|
|
|
docker push $(IMAGENAME):$(VERSION)
|
|
|
|
|
2017-02-27 11:14:39 +00:00
|
|
|
ci:
|
|
|
|
gitlab-runner exec docker --docker-volumes /var/run/docker.sock:/var/run/docker.sock --env CI_PROJECT_NAME=$(NAME) ${action}
|
|
|
|
|
2017-02-27 20:22:10 +00:00
|
|
|
.PHONY: test test-% test-all build-% build test pip_test run yapf push-main push-% dev ci version .FORCE
|