-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
83 lines (68 loc) · 2.28 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
.DEFAULT_GOAL := help
SHELL := /bin/bash
.SHELLFLAGS := -eu -o pipefail -c
PYTHONPATH=
VENV = .venv
MAKE = make
VENV_BIN=$(VENV)/bin
.venv: ## Set up virtual environment and install requirements
python3 -m venv $(VENV)
$(MAKE) requirements
.PHONY: requirements
requirements: .venv ## Install/refresh all project requirements
$(VENV_BIN)/python -m pip install --upgrade pip
$(VENV_BIN)/pip install -r requirements-dev.txt
$(VENV_BIN)/pip install -r requirements.txt
.PHONY: build
build: .venv ## Compile and install GuardBench
. $(VENV_BIN)/activate
.PHONY: fix-lint
fix-lint: .venv ## Fix linting
. $(VENV_BIN)/activate
$(VENV_BIN)/black ./guardbench
$(VENV_BIN)/isort ./guardbench
.PHONY: lint
lint: .venv ## Check linting
. $(VENV_BIN)/activate
$(VENV_BIN)/isort --check ./guardbench
$(VENV_BIN)/black --check ./guardbench
$(VENV_BIN)/blackdoc ./guardbench
$(VENV_BIN)/ruff check ./guardbench
$(VENV_BIN)/typos ./guardbench
# $(VENV_BIN)/mypy guardbench
.PHONY: test
test: .venv build ## Run unittest
$(VENV_BIN)/pytest
.PHONY: coverage
coverage: .venv build ## Run tests and report coverage
$(VENV_BIN)/pytest --cov -n auto --dist worksteal -m "not benchmark"
.PHONY: sbom
sbom: .venv build ## Generate sbom
$(VENV_BIN)/pip-licenses --with-authors > sbom.txt
.PHONY: sast
sast: .venv build ## Run SAST using Bandit https://github.com/PyCQA/bandit
$(VENV_BIN)/bandit -r ./guardbench > sast.log
$(VENV_BIN)/bandit -r ./scripts > sast-scripts.log
.PHONY: release
release: .venv build ## Release a new version
$(VENV_BIN)/python setup.py sdist bdist_wheel
$(VENV_BIN)/twine upload --repository-url https://upload.pypi.org/legacy/ dist/*
.PHONY: download-all
download-all: .venv build ## Download all GuardBench's datasets
$(VENV_BIN)/python -c "import guardbench; guardbench.download_all()"
.PHONY: clean
clean: ## Clean up caches and build artifacts
@rm -rf .venv/
@rm -rf target/
@rm -rf .pytest_cache/
@rm -rf .coverage
@rm -rf guardbench.egg-info
@rm -rf dist
@rm -rf build
@rm -rf sbom
@rm -rf sast.log
@rm -rf sast-scripts.log
.PHONY: help
help: ## Display this help screen
@echo -e "\033[1mAvailable commands:\033[0m\n"
@grep -E '^[a-z.A-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-18s\033[0m %s\n", $$1, $$2}' | sort