-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
96 lines (72 loc) · 2.68 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
MAKEFLAGS += --no-builtin-rules
MAKEFLAGS += --no-builtin-variables
# allow overriding the name of the venv directory
VENV_DIR ?= venv
# use a default prefix for coverage data files
COVERAGE_FILE ?= .coverage
# use different coverage data file per coverage run, otherwise combine complains
TESTS_COVERAGE_FILE = ${COVERAGE_FILE}.tests
# make tasks run all commands in a single shell
.ONESHELL:
# these targets don't produce files:
.PHONY: clean filecheck pytest pytest-nb tests-toy tests rerun-notebooks precommit-install precommit black pyright
.PHONY: coverage coverage-tests coverage-filecheck-tests coverage-report-html coverage-report-md
# remove all caches and the venv
clean:
rm -rf ${VENV_DIR} .pytest_cache *.egg-info .coverage.*
# run filecheck tests
filecheck:
lit -vv tests/filecheck --order=smart
# run pytest tests
pytest:
pytest tests -W error -vv
# run pytest on notebooks
pytest-nb:
pytest -W error --nbval -vv docs --ignore=docs/mlir_interoperation.ipynb --nbval-current-env
# run tests for Toy tutorial
filecheck-toy:
lit -v docs/Toy/examples --order=smart
pytest-toy:
pytest docs/Toy/toy/tests
tests-toy: filecheck-toy pytest-toy
# run all tests
tests: pytest tests-toy filecheck pytest-nb pyright
@echo test
# re-generate the output from all jupyter notebooks in the docs directory
rerun-notebooks:
jupyter nbconvert --ClearMetadataPreprocessor.enabled=True --inplace --to notebook --execute docs/*.ipynb
# set up all precommit hooks
precommit-install:
pre-commit install
# run all precommit hooks and apply them
precommit:
pre-commit run --all
# run pyright on all files in the current git commit
pyright:
pyright $(shell git diff --staged --name-only -- '*.py')
# run black on all files currently staged
black:
staged_files="$(shell git diff --staged --name-only)"
# run black on all of xdsl if no staged files exist
black $${staged_files:-xdsl}
# run coverage over all tests and combine data files
coverage: coverage-tests coverage-filecheck-tests
coverage combine --append
# run coverage over tests
coverage-tests:
COVERAGE_FILE=${TESTS_COVERAGE_FILE} pytest -W error --cov --cov-config=.coveragerc
# run coverage over filecheck tests
coverage-filecheck-tests:
lit -v tests/filecheck/ -DCOVERAGE
# generate html coverage report
coverage-report-html:
coverage html
# generate markdown coverage report
coverage-report-md:
coverage report --format=markdown
# set up the venv with all dependencies for development
venv: requirements-optional.txt requirements.txt
python3 -m venv ${VENV_DIR}
source ${VENV_DIR}/bin/activate
python3 -m pip --require-virtualenv install -r requirements-optional.txt -r requirements.txt
python3 -m pip --require-virtualenv install -e ".[extras]"