-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
70 lines (54 loc) · 2.57 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
NAME=slack011y-bus
VERSION=$(shell git rev-parse HEAD)
SEMVER_VERSION=$(shell git describe --abbrev=0 --tags)
REQUIREMENTS_HASH=$(shell sha1sum poetry.lock Dockerfile-requirements | sha1sum | cut -d' ' -f1)
REQUIREMENTS_TAG=requirements-$(REQUIREMENTS_HASH)
DOCKER_REPO_HOST=
DOCKER_REPO_ORG=
MAX_LINE_LENGTH=125
run-%:
./run.sh --$*
clean:
find . -name "*.py[cod]" -delete
format:
black .
isort .
lint:
flake8 --max-line-length $(MAX_LINE_LENGTH) --ignore=E203,W503 --extend-exclude venv
black . --check
isort . --check-only
typecheck:
MYPYPATH=src mypy -p src
setup-poetry:
python -m pip install --upgrade pip
install: setup-poetry
poetry install --no-ansi
build-requirements: clean
@if docker run -e DOCKER_REPO=$(DOCKER_REPO_ORG)/$(REQUIREMENTS_NAME) -e DOCKER_TAG=$(REQUIREMENTS_TAG) $(DOCKER_REPO_HOST)/$(DOCKER_REPO_ORG)/tag-exists; \
then echo "Requirements image tag $(REQUIREMENTS_TAG) already exists, skipping the build"; \
else \
docker build -t $(DOCKER_REPO_HOST)/$(DOCKER_REPO_ORG)/$(NAME):$(REQUIREMENTS_TAG) -f Dockerfile-requirements .; \
docker push $(DOCKER_REPO_HOST)/$(DOCKER_REPO_ORG)/$(NAME):$(REQUIREMENTS_TAG); \
fi
build: build-requirements
docker build --build-arg REQUIREMENTS_TAG=$(REQUIREMENTS_TAG) -t $(DOCKER_REPO_HOST)/$(DOCKER_REPO_ORG)/$(NAME):$(VERSION) .
docker push $(DOCKER_REPO_HOST)/$(DOCKER_REPO_ORG)/$(NAME):$(VERSION)
test-unit:
pytest -vvv -p monkeypatch --mypy --cov src/code --cov-report xml --cov-report term src/tests
test-unit-dev:
pytest -vvv -p monkeypatch --mypy --cov src/code --cov-report html --cov-report term src/tests
test-integration:
tag-latest:
docker tag $(DOCKER_REPO_HOST)/$(DOCKER_REPO_ORG)/$(NAME):$(VERSION) $(DOCKER_REPO_HOST)/$(DOCKER_REPO_ORG)/$(NAME):latest
docker push $(DOCKER_REPO_HOST)/$(DOCKER_REPO_ORG)/$(NAME):$(VERSION)
docker push $(DOCKER_REPO_HOST)/$(DOCKER_REPO_ORG)/$(NAME):latest
tag-semver:
@if docker run -e DOCKER_REPO=$(DOCKER_REPO_ORG)/$(NAME) -e DOCKER_TAG=$(SEMVER_VERSION) $(DOCKER_REPO_HOST)/$(DOCKER_REPO_ORG)/tag-exists; \
then echo "Tag $(SEMVER_VERSION) already exists!" && exit 1 ; \
else \
docker tag $(DOCKER_REPO_HOST)/$(DOCKER_REPO_ORG)/$(NAME):$(VERSION) $(DOCKER_REPO_HOST)/$(DOCKER_REPO_ORG)/$(NAME):$(SEMVER_VERSION); \
docker push $(DOCKER_REPO_HOST)/$(DOCKER_REPO_ORG)/$(NAME):$(SEMVER_VERSION); \
fi
docker-pull:
docker pull $(DOCKER_REPO_HOST)/$(DOCKER_REPO_ORG)/$(NAME):$(VERSION)
.PHONY: run clean format lint typecheck setup-poetry install build-requirements build test test-unit test-integration tag-latest docker-pull tag-semver local-redis stop-local-redis