blob: e50b9dd3fb7034b4cf664b28cda51980150135ce [file] [log] [blame]
Harrison Mutai19dc4f92024-05-10 16:54:29 +00001#
2# Copyright (c) 2024, Arm Limited and Contributors. All rights reserved.
3#
4# SPDX-License-Identifier: BSD-3-Clause
5
6##* Variables
7SHELL := /usr/bin/env bash
8PYTHON := python
9PYTHONPATH := `pwd`
10
11#* Docker variables
12IMAGE := tlc
13VERSION := latest
14
15#* Installation
16.PHONY: dist
17dist: clean
18 poetry build
19
20.PHONY: dev-install
21dev-install:
Charlie Bareham1a06dd22024-06-17 10:47:55 +010022 poetry lock -n --no-update && poetry export --without-hashes > requirements.txt
Harrison Mutai19dc4f92024-05-10 16:54:29 +000023 poetry install -n
24 -poetry run mypy --install-types --non-interactive ./
25
26.PHONY: install
27install: dist
28 pip install dist/*.whl
29
30.PHONY: pre-commit-install
31pre-commit-install:
32 poetry run pre-commit install
33
34#* Formatters
35.PHONY: codestyle
36codestyle:
37 poetry run pyupgrade --exit-zero-even-if-changed --py38-plus **/*.py
38 poetry run isort --settings-path pyproject.toml ./
39 poetry run black --config pyproject.toml ./
40
41.PHONY: formatting
42formatting: codestyle
43
44#* Linting
45.PHONY: test
46test:
47 PYTHONPATH=$(PYTHONPATH) poetry run pytest -c pyproject.toml --cov-report=html --cov=tlc tests/
48 poetry run coverage-badge -o assets/images/coverage.svg -f
49
50.PHONY: check-codestyle
51check-codestyle:
52 poetry run isort --diff --check-only --settings-path pyproject.toml ./
53 poetry run black --diff --check --config pyproject.toml ./
54 poetry run darglint --verbosity 2 tlc tests
55
56.PHONY: mypy
57mypy:
58 poetry run mypy --config-file pyproject.toml ./
59
60.PHONY: check-safety
61check-safety:
62 poetry check
63 poetry run safety check --full-report
64 poetry run bandit -ll --recursive tlc tests
65
66.PHONY: lint
67lint: test check-codestyle mypy check-safety
68
69.PHONY: update-dev-deps
70update-dev-deps:
71 poetry add -D bandit@latest darglint@latest "isort[colors]@latest" mypy@latest pre-commit@latest pydocstyle@latest pylint@latest pytest@latest pyupgrade@latest safety@latest coverage@latest coverage-badge@latest pytest-html@latest pytest-cov@latest
72 poetry add -D --allow-prereleases black@latest
73
74#* Docker
75.PHONY: docker-build docker-remove
76docker-build:
77 @echo Building docker $(IMAGE):$(VERSION) ...
78 docker build \
79 -t $(IMAGE):$(VERSION) . \
80 -f ./docker/Dockerfile --no-cache
81
82docker-remove:
83 @echo Removing docker $(IMAGE):$(VERSION) ...
84 docker rmi -f $(IMAGE):$(VERSION)
85
86
87#* Cleaning
88.PHONY: clean .clean-build clean-pyc clean-test
89clean: clean-build clean-pyc clean-test ## remove all build, test, coverage and Python artifacts
90
91clean-build: ## remove build artifacts
92 rm -fr build/
93 rm -fr dist/
94 rm -fr .eggs/
95 find . -name '*.egg-info' -exec rm -fr {} +
96 find . -name '*.egg' -exec rm -f {} +
97
98clean-pyc: ## remove Python file artifacts
99 find . -name '*.pyc' -exec rm -f {} +
100 find . -name '*.pyo' -exec rm -f {} +
101 find . -name '*~' -exec rm -f {} +
102 find . -name '__pycache__' -exec rm -fr {} +
103 find . | grep -E ".pytest_cache" | xargs rm -rf
104 find . | grep -E ".mypy_cache" | xargs rm -rf
105
106clean-test: ## remove test and coverage artifacts
107 rm -fr .tox/
108 rm -f .coverage
109 rm -fr htmlcov/