-
Notifications
You must be signed in to change notification settings - Fork 20
/
Makefile
123 lines (105 loc) · 3.41 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
122
123
ifeq ($(origin .RECIPEPREFIX), undefined)
$(error This Make does not support .RECIPEPREFIX. Please use GNU Make 4.0 or later)
endif
.DEFAULT_GOAL = help
.DELETE_ON_ERROR:
.ONESHELL:
.SHELLFLAGS := -eu -o pipefail -c
.SILENT:
MAKEFLAGS += --no-builtin-rules
MAKEFLAGS += --warn-undefined-variables
SHELL = bash
DATAPATH = $(CURDIR)/tests/data
DOCKER_IMAGE = eliostvs/$(PACKAGE)
OBS_API_URL = https://api.opensuse.org/trigger/runservice
PACKAGE = tomate
PYTHON ?= python3
PLUGINPATH = $(CURDIR)/data/plugins
PYTEST ?= pytest-3
PYTHONPATH = PYTHONPATH=$(CURDIR):$(PLUGINPATH)
TESTARGS ?=
VERSION = `cat .bumpversion.cfg | grep current_version | awk '{print $$3}'`
WORKDIR = /code
XDGPATH = XDG_CONFIG_HOME=$(DATAPATH) XDG_DATA_HOME=$(DATAPATH) XDG_DATA_DIRS=$(DATAPATH)
ifeq ($(shell which xvfb-run 1> /dev/null && echo yes),yes)
ARGS = xvfb-run -a
else
ARGS ?=
endif
## help: print this help message
help:
echo 'Usage:'
sed -n 's/^##//p' ${MAKEFILE_LIST} | column -t -s ':' | sed -e 's/^/ /' | sort
.PHONY: help
## clean: clean development files
clean:
find . \( -iname "__pycache__" \) -print0 | xargs -0 rm -rf
rm -rf .eggs *.egg-info/ .coverage build/ .cache .pytest_cache tests/data/mime/mime.cache venv
.PHONY: clean
## venv: create develop environment
venv:
python3 -m venv --system-site-package --upgrade-deps --prompt "." venv
source venv/bin/activate
pip install \
black \
isort \
pytest \
pytest-cov \
pytest-flake8 \
pytest-mock \
python-dbusmock \
ruff
## mime: generate test mine index
mime: clean
$(XDGPATH) update-mime-database tests/data/mime
rm -rf tests/data/mime/{image,aliases,generic-icons,globs,globs2,icons,magic,subclasses,treemagic,types,version,XMLnamespaces}
.PHONY: mime
## format: run code formatter
format:
black $(PACKAGE) tests/ $(PLUGINPATH)
isort $(PACKAGE) tests/ $(PLUGINPATH)
.PHONY: format
## lint: run lint
lint:
ruff check $(ARGS) $(PACKAGE) tests/ $(PLUGINPATH)
.PHONY: lint
## test: run tests
test:
$(XDGPATH) $(PYTHONPATH) $(ARGS) $(PYTEST) $(TESTARGS) -v --cov=$(PACKAGE)
.PHONY: test
## run: run app locally
run:
$(XDGPATH) $(PYTHONPATH) TOMATE_DEBUG=true $(PYTHON) -m $(PACKAGE) -v
.PHONY: run
## release-[major|minor|patch]: create release
release-%:
git flow init -d
@grep -q '\[Unreleased\]' CHANGELOG.md || (echo 'Create the [Unreleased] section in the changelog first!' && exit)
bumpversion --verbose --commit $*
git flow release start $(VERSION)
GIT_MERGE_AUTOEDIT=no git flow release finish -m "Merge branch release/$(VERSION)" -T $(VERSION) $(VERSION) -p
## trigger-build: trigger obs build
trigger-build:
curl -X POST -H "Authorization: Token $(TOKEN)" $(OBS_API_URL)
.PHONY: trigger-build
## docker: create docker image
docker:
docker built -t $(DOCKER_IMAGE) .
## docker: push image to docker hub
docker-push:
docker image push $(DOCKER_IMAGE):latest
## docker-run: run app inside
docker-run:
docker run --rm -it -e DISPLAY --net=host \
-v $(CURDIR):/$(WORKDIR) \
-v $(HOME)/.Xauthority:/root/.Xauthority \
$(DOCKER_IMAGE) run
.PHONY: docker-run
## docker-test: run tests inside docker
docker-test:
docker run --rm -it -v $(CURDIR):$(WORKDIR) --workdir $(WORKDIR) $(DOCKER_IMAGE) mime test
.PHONY: docker-test
## docker-enter: open terminal inside docker environment
docker-enter:
docker run --rm -v $(CURDIR):$(WORKDIR) -it --workdir $(WORKDIR) --entrypoint="bash" $(DOCKER_IMAGE)
.PHONY: docker-enter