-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
98 lines (75 loc) · 2 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
.DEFAULT_GOAL := build-local
####################
# CONSTANTS
####################
REGISTRY := ethyca
IMAGE_TAG := $(shell git fetch --force --tags && git describe --tags --dirty --always)
IMAGE_NAME := fideslog
IMAGE := $(REGISTRY)/$(IMAGE_NAME):$(IMAGE_TAG)
IMAGE_LOCAL := $(REGISTRY)/$(IMAGE_NAME):local
IMAGE_LATEST := $(REGISTRY)/$(IMAGE_NAME):latest
# Disable TTY to perserve output within Github Actions logs
# CI env variable is always set to true in Github Actions
ifeq "$(CI)" "true"
CI_ARGS:=--no-TTY
endif
# Run in Compose
RUN_NO_DEPS = docker compose run --no-deps --rm $(CI_ARGS) $(IMAGE_NAME)
####################
# Docker
####################
build:
docker build --tag $(IMAGE) .
build-local:
docker build --tag $(IMAGE_LOCAL) .
rebuild-local:
docker build --no-cache --tag $(IMAGE_LOCAL) .
push: build
docker tag $(IMAGE) $(IMAGE_LATEST)
docker push $(IMAGE)
docker push $(IMAGE_LATEST)
####################
# Dev
####################
.PHONY: api
api: build-local
@echo "Spinning up the webserver..."
@docker compose up $(IMAGE_NAME)
@make teardown
####################
# CI
####################
check-all: build-local isort black pylint mypy xenon pytest
@echo "Running formatter, linter, typechecker and tests..."
black:
@$(RUN_NO_DEPS) black --check --exclude="sdk/python/_version\.py" fideslog/ tests/
isort:
$(RUN_NO_DEPS) isort --check fideslog/ tests/
mypy:
@$(RUN_NO_DEPS) mypy
pylint:
@$(RUN_NO_DEPS) pylint fideslog/
pytest:
@docker compose up -d $(IMAGE_NAME)
@$(RUN_NO_DEPS) pytest
xenon:
@$(RUN_NO_DEPS) \
xenon fideslog \
--max-absolute B \
--max-modules B \
--max-average A \
--ignore "tests" \
--exclude "fideslog/sdk/python/_version.py"
####################
# Utils
####################
.PHONY: clean
clean:
@echo "Cleaning project temporary files and installed dependencies..."
@docker system prune -a --volumes
@echo "Clean complete!"
.PHONY: teardown
teardown:
@echo "Tearing down the dev environment..."
@docker compose down
@echo "Teardown complete"