-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
106 lines (88 loc) · 2.96 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
# Read the current user's ID so that we can assign the same ID to "keystone" Docker user.
UID = $$(id -u)
# where's the Makefile running? Valid options: LOCAL, CI
ENV ?= LOCAL
PYTEST_REPORT ?= pytest.xml
PYLINT_REPORT ?= pylint.json
KEYSTONE_VENV_PATH ?= /opt/keystone/venv
PIP_PATH = $(KEYSTONE_VENV_PATH)/bin/pip
###############################################################################
# Setup and Install targets
###############################################################################
$(KEYSTONE_VENV_PATH):
python3 -m venv $(KEYSTONE_VENV_PATH) --prompt .
$(PIP_PATH) install -U pip setuptools wheel pip-tools
venv: $(KEYSTONE_VENV_PATH)
.PHONY: requirements.txt
requirements.txt: venv
$(PIP_PATH)-compile \
--output-file requirements.txt \
--generate-hashes \
--strip-extras \
$(if $(upgrade_package), --upgrade-package $(upgrade_package)) \
pyproject.toml
.PHONY: requirements-dev.txt
requirements-dev.txt: requirements.txt
$(PIP_PATH)-compile \
--constraint requirements.txt \
--output-file requirements-dev.txt \
--generate-hashes \
--strip-extras \
--extra dev \
$(if $(upgrade_package), --upgrade-package $(upgrade_package)) \
pyproject.toml
.PHONY: install-dev
install: venv
$(PIP_PATH)-sync requirements-dev.txt
$(PIP_PATH) install --no-deps -e .
.PHONY: install
install-prod:
$(PIP_PATH)-sync requirements.txt
$(PIP_PATH) install --no-deps -e .
###############################################################################
# Development targets
###############################################################################
.PHONY: test
test:
ifeq ($(ENV),LOCAL)
@# pass extra params on to pytest: https://stackoverflow.com/a/6273809
DJANGO_SETTINGS_MODULE=config.settings $(KEYSTONE_VENV_PATH)/bin/pytest $(filter-out $@,$(MAKECMDGOALS))
else ifeq ($(ENV),CI)
DJANGO_SETTINGS_MODULE=config.settings \
$(KEYSTONE_VENV_PATH)/bin/pytest \
--junit-xml=$(PYTEST_REPORT) \
--cov=keystone \
--cov=config \
--cov-report=xml
endif
.PHONY: lint
lint:
ifeq ($(ENV),LOCAL)
DJANGO_SETTINGS_MODULE=config.settings $(KEYSTONE_VENV_PATH)/bin/pylint keystone config
else ifeq ($(ENV),CI)
DJANGO_SETTINGS_MODULE=config.settings \
$(KEYSTONE_VENV_PATH)/bin/pylint keystone config \
--output-format=pylint_gitlab.GitlabCodeClimateReporter \
--reports=y > $(PYLINT_REPORT)
endif
.PHONY: format
format:
$(KEYSTONE_VENV_PATH)/bin/black .
.PHONY: ck-format
ck-format:
$(KEYSTONE_VENV_PATH)/bin/black --check .
###############################################################################
# Container targets
###############################################################################
.env:
cp sample.env .env
arch-shared:
mkdir -p arch-shared/in/collections;
mkdir arch-shared/log;
mkdir -p arch-shared/out/custom-collections;
mkdir arch-shared/out/datasets;
dev/arch:
git clone --branch=main git@github.com:internetarchive/arch dev/arch
.PHONY: build-images
build-images: .env dev/arch arch-shared
docker compose build --build-arg UID=$(UID)