This repository has been archived by the owner on Jul 25, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 37
/
Makefile
executable file
·155 lines (123 loc) · 4.42 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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
NAME := iml-manager
MODULE_SUBDIR = chroma_manager
DEVELOP_DEPS := version
DEVELOP_POST := ./manage.py dev_setup
DIST_DEPS := version $(COPR_REPO_TARGETS)
RPM_OPTS = -D "_topdir $(CURDIR)/_topdir"
ifdef RPM_DIST
RPM_OPTS += -D "dist ${RPM_DIST}"
endif
# SET MFL_COPR_REPO in .copr/Makefile
TAGS_ARGS := --exclude=chroma-manager/_topdir \
--exclude=chroma-\*/myenv\* \
--exclude=chroma_test_env \
--exclude=chroma-manager/chroma_test_env \
--exclude=chroma_unit_test_env \
--exclude=workspace
# Always nuke the DB when running tests?
ALWAYS_NUKE_DB ?= false
# Always nuke logs when running tests?
ALWAYS_NUKE_LOGS ?= false
# Misc test config
DB_NAME ?= chroma
DB_USER ?= $(DB_NAME)
TEST_HTTPD_PORT ?= 8000
DEV_USERNAME = admin
DEV_PASSWORD = lustre
# Test runner options
BEHAVE_ARGS ?= -q --stop
NOSE_ARGS ?= --stop
ZIP_TYPE := $(shell if [ "$(ZIP_DEV)" == "true" ]; then echo '-dev'; else echo ''; fi)
all: copr-rpms rpms device-scanner-rpms iml-gui-rpm docker-rpms
local:
$(MAKE) RPM_DIST="0.$(shell date '+%s')" all
check:
black --check ./
cargo fmt --all -- --check
cargo check --locked --all-targets
cargo clippy -- -W warnings
cargo check --locked --manifest-path iml-system-rpm-tests/Cargo.toml --tests
cargo clippy --manifest-path iml-system-rpm-tests/Cargo.toml --tests -- -W warnings
cargo check --locked --manifest-path iml-system-docker-tests/Cargo.toml --tests
cargo clippy --manifest-path iml-system-docker-tests/Cargo.toml --tests -- -W warnings
fmt:
black ./
cargo fmt --all
cargo fmt --all --manifest-path iml-system-rpm-tests/Cargo.toml
cargo fmt --all --manifest-path iml-system-docker-tests/Cargo.toml
iml-gui-rpm:
$(MAKE) -f .copr/Makefile iml-gui-srpm outdir=.
rpmbuild --rebuild ${RPM_OPTS} _topdir/SRPMS/rust-iml-gui-*.src.rpm
rpms:
$(MAKE) -f .copr/Makefile iml-srpm outdir=.
rpmbuild --rebuild ${RPM_OPTS} _topdir/SRPMS/python-iml-manager-*.src.rpm
copr-rpms:
$(MAKE) -f .copr/Makefile srpm outdir=.
rpmbuild --rebuild ${RPM_OPTS} _topdir/SRPMS/rust-iml-*.src.rpm
docker-rpms:
$(MAKE) -C docker save
$(MAKE) -f .copr/Makefile iml-docker-srpm outdir=.
rpmbuild --rebuild ${RPM_OPTS} _topdir/SRPMS/iml-docker-*.src.rpm
device-scanner-rpms:
$(MAKE) -f .copr/Makefile device-scanner-srpm outdir=.
rpmbuild --rebuild ${RPM_OPTS} _topdir/SRPMS/iml-device-scanner-*.src.rpm
cleandist:
rm -rf dist
mkdir dist
nuke_db:
echo "Wiping $(DB_NAME) DB..."; \
dropdb $(DB_NAME); \
createdb -O $(DB_USER) $(DB_NAME)
migrate_db:
psql chroma -c "CREATE EXTENSION IF NOT EXISTS btree_gist;"
@./manage.py migrate
cargo sqlx migrate run
nuke_logs:
@$(ALWAYS_NUKE_LOGS) && { \
echo "Scrubbing devel logs..."; \
rm -f $(CURDIR)/*{.,_}log; \
} || true
dev_setup: nuke_db nuke_logs
@./manage.py dev_setup || exit $$?
service_tests: dev_setup
@echo "Running service tests..."
@PYTHONPATH=. nosetests $(NOSE_ARGS) tests/services 2>&1 | tee test-services.log; \
exit $${PIPESTATUS[0]}
unit_tests unit-tests:
@echo "Running standard unit tests..."
@./manage.py test $(NOSE_ARGS) tests/unit 2>&1 | tee unit.log; \
exit $${PIPESTATUS[0]}
feature_tests:
@echo "Running behave features tests..."
@for feature in tests/feature/*; do \
[ -d $$feature ] || continue; \
logname=feature-$$(basename $$feature); \
stdout=$$logname.stdout; stderr=$$logname.stderr; \
behave $(BEHAVE_ARGS) $${feature}/features 2>$$stderr | tee $$stdout; \
brc=$${PIPESTATUS[0]}; \
[ $$brc -eq 0 ] || { \
echo "$$feature failed, logs: $$stdout, $$stderr"; \
break; \
} && true; \
done; \
exit $$brc
tests test: unit_tests feature_tests integration_tests service_tests
install_requirements: requirements.txt
echo "jenkins_fold:start:Install Python requirements"
pip install --upgrade pip; \
pip install --upgrade setuptools; \
pip install -Ur requirements.txt
echo "jenkins_fold:end:Install Python requirements"
download: install_requirements
substs:
$(MAKE) -f .copr/Makefile substs outdir=.
clean_substs:
if [ -n "$(SUBSTS)" ]; then \
rm -f $(SUBSTS); \
fi
chroma_test_env: chroma_test_env/bin/activate
chroma_test_env/bin/activate: chroma-manager/requirements.txt
test -d chroma_test_env || virtualenv --no-site-packages chroma_test_env
chroma_test_env/bin/pip install -r chroma-manager/requirements.txt
touch chroma_test_env/bin/activate
.PHONY: download substs