-
Notifications
You must be signed in to change notification settings - Fork 29
/
Makefile
108 lines (84 loc) · 2.66 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
# install cardano_node_tests and its dependencies into a virtual environment
.PHONY: install
install:
./setup_venv.sh
# initialize linters
.PHONY: init_linters
init_lint:
pre-commit clean
pre-commit gc
find . -path '*/.mypy_cache/*' -delete
# run linters
.PHONY: lint
lint:
pre-commit run -a
if command -v pytype >/dev/null 2>&1; then pytype cardano_node_tests; fi
# generate sphinx documentation
.PHONY: doc
doc:
mkdir -p src_docs/build
$(MAKE) -C src_docs clean
$(MAKE) -C src_docs html
# run tests
TESTS_DIR ?= cardano_node_tests/
ARTIFACTS_DIR ?= .artifacts
COVERAGE_DIR ?= .cli_coverage
REPORTS_DIR ?= .reports
ifneq ($(MARKEXPR),)
MARKEXPR := -m "$(MARKEXPR)"
endif
# it may not be always necessary to save artifacts, e.g. when running tests on local cluster
# on local machine
ifndef NO_ARTIFACTS
ARTIFACTS_ARGS := --artifacts-base-dir=$(ARTIFACTS_DIR)
endif
ifndef PYTEST_ARGS
TESTRUN_REPORT_ARGS := --html=$(REPORTS_DIR)/testrun-report.html --self-contained-html --junitxml=$(REPORTS_DIR)/testrun-report.xml
endif
ifdef DESELECT_FROM_FILE
DESELECT_FROM_FILE_ARGS := --deselect-from-file=$(DESELECT_FROM_FILE)
endif
CLEANUP := yes
RUN_SKIPS := yes
ifdef PYTEST_ARGS
CLEANUP := no
RUN_SKIPS := no
endif
ifdef DESELECT_FROM_FILE
RUN_SKIPS := no
endif
.PHONY: .dirs
.dirs:
mkdir -p $(ARTIFACTS_DIR) $(COVERAGE_DIR) $(REPORTS_DIR)
.PHONY: .run_tests
.run_tests:
# delete artifacts from previous runs
ifeq ($(CLEANUP),yes)
rm -f $(REPORTS_DIR)/{*-attachment.txt,*-result.json,*-container.json,testrun-report.*}
rm -f $(COVERAGE_DIR)/cli_coverage_*
endif
# first just skip all tests so Allure has a list of all tests that were supposed to run
ifeq ($(RUN_SKIPS),yes)
pytest -s $(TESTS_DIR) $(MARKEXPR) --skipall --alluredir=$(REPORTS_DIR) >/dev/null
endif
# run tests for real and produce Allure results
pytest $(TESTS_DIR) $(PYTEST_ARGS) $(CI_ARGS) $(MARKEXPR) $(DESELECT_FROM_FILE_ARGS) -n $(TEST_THREADS) $(ARTIFACTS_ARGS) --cli-coverage-dir=$(COVERAGE_DIR) --alluredir=$(REPORTS_DIR) $(TESTRUN_REPORT_ARGS)
# run all tests
.PHONY: tests
tests: export DbSyncAbortOnPanic=1
tests: TEST_THREADS := $(or $(TEST_THREADS),20)
tests: .dirs .run_tests
# run tests that are supposed to run on PR level
.PHONY: testpr
testpr: export TESTPR=1
testpr: export CLUSTERS_COUNT := $(or $(CLUSTERS_COUNT),5)
testpr: TEST_THREADS := $(or $(TEST_THREADS),20)
testpr: MARKEXPR := $(or $(MARKEXPR),-m "smoke")
testpr: .dirs .run_tests
# run all tests that can run on testnets
.PHONY: testnets
testnets: export CLUSTERS_COUNT=1
testnets: export FORBID_RESTART=1
testnets: TEST_THREADS := $(or $(TEST_THREADS),20)
testnets: MARKEXPR := $(or $(MARKEXPR),-m "testnets")
testnets: .dirs .run_tests