forked from anchore/yardstick
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
120 lines (81 loc) · 2.6 KB
/
Copy pathMakefile
File metadata and controls
120 lines (81 loc) · 2.6 KB
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
TOOL_DIR = .tool
# Command templates #################################
BINNY = $(TOOL_DIR)/binny
CHRONICLE = $(TOOL_DIR)/chronicle
GLOW = $(TOOL_DIR)/glow
ENV = uv run
# Formatting variables #################################
BOLD := $(shell tput -T linux bold)
PURPLE := $(shell tput -T linux setaf 5)
GREEN := $(shell tput -T linux setaf 2)
CYAN := $(shell tput -T linux setaf 6)
RED := $(shell tput -T linux setaf 1)
RESET := $(shell tput -T linux sgr0)
TITLE := $(BOLD)$(PURPLE)
SUCCESS := $(BOLD)$(GREEN)
ERROR := $(BOLD)$(RED)
.DEFAULT_GOAL := all
.PHONY: all
all: static-analysis test ## Run all validations
.PHONY: static-analysis
static-analysis: ## Run all static analyses
$(ENV) pre-commit run -a --hook-stage push
.PHONY: test
test: unit integration cli ## Run all tests
## Bootstrapping targets #################################
$(TOOL_DIR):
mkdir -p $(TOOL_DIR)
.PHONY: tools
tools: $(TOOL_DIR) ## Download and install all tooling dependencies
@[ -f .tool/binny ] || curl -sSfL https://raw.githubusercontent.com/anchore/binny/main/install.sh | sh -s -- -b $(TOOL_DIR)
@$(BINNY) install -v
## Static analysis targets #################################
.PHONY: lint
lint: ## Show linting issues (ruff)
$(ENV) ruff check src
.PHONY: lint-fix
lint-fix: ## Fix linting issues (ruff)
$(ENV) ruff check src --fix
format: ## Format code (ruff format)
$(ENV) ruff format src tests
.PHONY: check-types
check-types: ## Run type checks (mypy)
$(ENV) mypy --config-file ./pyproject.toml src/yardstick
## Testing targets #################################
.PHONY: unit
unit: ## Run unit tests
$(ENV) pytest --cov-report html --cov yardstick -v tests/unit/
.PHONY: integration
integration: ## Run integration tests
$(ENV) pytest -v tests/integration/
.PHONY: cli
cli: ## Run CLI tests
cd ./tests/cli && make
## Build-related targets #################################
.PHONY: build
build: clean-dist ## Run build assets
git fetch --tags
rm -rf dist
uv build -v
## Release #################################
.PHONY: changelog
changelog:
@$(CHRONICLE) -vvv -n --version-file VERSION > CHANGELOG.md
@$(GLOW) CHANGELOG.md
.PHONY: release
release:
@.github/scripts/trigger-release.sh
.PHONY: ci-check
ci-check:
@.github/scripts/ci-check.sh
.PHONY: ci-publish-pypi
ci-publish-pypi: ci-check build
uv publish
## Cleanup #################################
.PHONY: clean-dist
clean-dist:
rm -rf dist
## Halp! #################################
.PHONY: help
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "$(BOLD)$(CYAN)%-25s$(RESET)%s\n", $$1, $$2}'