forked from canonical/rockcraft
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
145 lines (119 loc) · 3.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
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
RUFF := $(shell ruff --version 2> /dev/null)
.PHONY: help
help: ## Show this help.
@printf "%-40s %s\n" "Target" "Description"
@printf "%-40s %s\n" "------" "-----------"
@fgrep " ## " $(MAKEFILE_LIST) | fgrep -v grep | awk -F ': .*## ' '{$$1 = sprintf("%-40s", $$1)} 1'
.PHONY: autoformat
autoformat: ## Run automatic code formatters.
ifndef RUFF
$(error "Ruff not installed. Install it with `sudo snap install ruff` or using the official installation instructions: https://docs.astral.sh/ruff/installation/")
endif
autoflake rockcraft/ tests/
black .
ruff check --fix-only rockcraft tests
.PHONY: clean
clean: ## Clean artefacts from building, testing, etc.
rm -rf build/
rm -rf dist/
rm -rf .eggs/
find . -name '*.egg-info' -exec rm -rf {} +
find . -name '*.egg' -exec rm -f {} +
rm -rf docs/_build/
rm -f docs/rockcraft.*
rm -f docs/modules.rst
rm -rf docs/reference/commands
find . -name '*.pyc' -exec rm -f {} +
find . -name '*.pyo' -exec rm -f {} +
find . -name '*~' -exec rm -f {} +
find . -name '__pycache__' -exec rm -rf {} +
rm -rf .tox/
rm -f .coverage
rm -rf htmlcov/
rm -rf .pytest_cache
$(MAKE) -C docs clean
rm -rf .mypy_cache
.PHONY: coverage
coverage: ## Run pytest with coverage report.
coverage run --source rockcraft -m pytest tests/unit
coverage report -m
coverage html
coverage xml -o results/coverage-unit.xml
.PHONY: installdocs
installdocs:
$(MAKE) -C docs install
.PHONY: docs
docs: ## Generate documentation.
rm -f docs/rockcraft.rst
rm -f docs/modules.rst
$(MAKE) -C docs clean-doc
$(MAKE) -C docs html
.PHONY: rundocs
rundocs: ## start a documentation runserver
$(MAKE) -C docs run
.PHONY: dist
dist: clean ## Build python package.
python setup.py sdist
python setup.py bdist_wheel
ls -l dist
.PHONY: freeze-requirements
freeze-requirements: ## Re-freeze requirements.
tools/freeze-requirements.sh
.PHONY: install
install: clean ## Install python package.
python setup.py install
.PHONY: lint
lint: test-black test-codespell test-flake8 test-mypy test-pydocstyle test-pyright test-ruff test-sphinx-lint test-shellcheck ## Run all linting tests.
.PHONY: release
release: dist ## Release with twine.
twine upload dist/*
.PHONY: test-black
test-black:
black --check --diff .
.PHONY: test-codespell
test-codespell:
codespell rockcraft tests
.PHONY: test-flake8
test-flake8:
flake8 rockcraft tests
.PHONY: test-ruff
test-ruff:
ifndef RUFF
$(error "Ruff not installed. Install it with `sudo snap install ruff` or using the official installation instructions: https://docs.astral.sh/ruff/installation/")
endif
ruff check rockcraft tests
.PHONY: test-integrations
test-integrations: ## Run integration tests.
pytest tests/integration
.PHONY: test-mypy
test-mypy:
mypy rockcraft tests
.PHONY: test-pydocstyle
test-pydocstyle:
pydocstyle rockcraft
.PHONY: test-pylint
test-pylint:
echo "rockcraft has replaced pylint with ruff. Please use `make test-ruff` instead."
make test-ruff
.PHONY: test-pyright
test-pyright:
pyright .
.PHONY: test-shellcheck
test-shellcheck:
# shellcheck for shell scripts
git ls-files | file --mime-type -Nnf- | grep shellscript | cut -f1 -d: | xargs shellcheck
# shellcheck for bash commands inside spread task.yaml files
tools/external/utils/spread-shellcheck tests/spread/ spread.yaml
.PHONY: test-sphinx-lint
test-sphinx-lint:
sphinx-lint --ignore docs/sphinx-starter-pack/ --ignore docs/_build --ignore docs/env --max-line-length 80 -e all docs/*
.PHONY: test-units
test-units: ## Run unit tests.
pytest tests/unit
.PHONY: test-docs
test-docs: installdocs ## Run docs tests.
$(MAKE) -C docs linkcheck
$(MAKE) -C docs woke
$(MAKE) -C docs spelling
.PHONY: tests
tests: lint test-integrations test-units test-docs ## Run all tests.