Harrison Mutai | 19dc4f9 | 2024-05-10 16:54:29 +0000 | [diff] [blame] | 1 | # |
| 2 | # Copyright (c) 2024, Arm Limited and Contributors. All rights reserved. |
| 3 | # |
| 4 | # SPDX-License-Identifier: BSD-3-Clause |
| 5 | |
| 6 | ##* Variables |
| 7 | SHELL := /usr/bin/env bash |
| 8 | PYTHON := python |
| 9 | PYTHONPATH := `pwd` |
| 10 | |
| 11 | #* Docker variables |
| 12 | IMAGE := tlc |
| 13 | VERSION := latest |
| 14 | |
| 15 | #* Installation |
| 16 | .PHONY: dist |
| 17 | dist: clean |
| 18 | poetry build |
| 19 | |
| 20 | .PHONY: dev-install |
| 21 | dev-install: |
Charlie Bareham | 1a06dd2 | 2024-06-17 10:47:55 +0100 | [diff] [blame] | 22 | poetry lock -n --no-update && poetry export --without-hashes > requirements.txt |
Harrison Mutai | 19dc4f9 | 2024-05-10 16:54:29 +0000 | [diff] [blame] | 23 | poetry install -n |
| 24 | -poetry run mypy --install-types --non-interactive ./ |
| 25 | |
| 26 | .PHONY: install |
| 27 | install: dist |
| 28 | pip install dist/*.whl |
| 29 | |
| 30 | .PHONY: pre-commit-install |
| 31 | pre-commit-install: |
| 32 | poetry run pre-commit install |
| 33 | |
| 34 | #* Formatters |
| 35 | .PHONY: codestyle |
| 36 | codestyle: |
| 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 |
| 42 | formatting: codestyle |
| 43 | |
| 44 | #* Linting |
| 45 | .PHONY: test |
| 46 | test: |
| 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 |
| 51 | check-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 |
| 57 | mypy: |
| 58 | poetry run mypy --config-file pyproject.toml ./ |
| 59 | |
| 60 | .PHONY: check-safety |
| 61 | check-safety: |
| 62 | poetry check |
| 63 | poetry run safety check --full-report |
| 64 | poetry run bandit -ll --recursive tlc tests |
| 65 | |
| 66 | .PHONY: lint |
| 67 | lint: test check-codestyle mypy check-safety |
| 68 | |
| 69 | .PHONY: update-dev-deps |
| 70 | update-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 |
| 76 | docker-build: |
| 77 | @echo Building docker $(IMAGE):$(VERSION) ... |
| 78 | docker build \ |
| 79 | -t $(IMAGE):$(VERSION) . \ |
| 80 | -f ./docker/Dockerfile --no-cache |
| 81 | |
| 82 | docker-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 |
| 89 | clean: clean-build clean-pyc clean-test ## remove all build, test, coverage and Python artifacts |
| 90 | |
| 91 | clean-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 | |
| 98 | clean-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 | |
| 106 | clean-test: ## remove test and coverage artifacts |
| 107 | rm -fr .tox/ |
| 108 | rm -f .coverage |
| 109 | rm -fr htmlcov/ |