-
Notifications
You must be signed in to change notification settings - Fork 47
/
Makefile
84 lines (69 loc) · 2.61 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
# Makefile for acronyms
# Tested with GNU Make 3.81
MAKEFLAGS += --warn-undefined-variables
SHELL := /usr/bin/env bash -e
.DEFAULT_GOAL := help
INSTALL_STAMP := .install.stamp
POETRY := $(shell command -v poetry 2> /dev/null)
# cribbed from https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html and https://news.ycombinator.com/item?id=11195539
help: ## Prints out documentation for available commands
@awk -F ':|##' \
'/^[^\t].+?:.*?##/ {\
printf "\033[36m%-30s\033[0m %s\n", $$1, $$NF \
}' $(MAKEFILE_LIST)
install: $(INSTALL_STAMP) ## Install dependencies
$(INSTALL_STAMP): pyproject.toml poetry.lock
@echo $(POETRY)
@if [ -z $(POETRY) ]; then echo "Poetry could not be found. See https://python-poetry.org/docs/"; exit 2; fi
"$(POETRY)" --version
"$(POETRY)" install
touch $(INSTALL_STAMP)
## Test targets
.PHONY: test
test: $(INSTALL_STAMP) unit-test lint ## Run tests and lint checks
.PHONY: unit-test
unit-test: $(INSTALL_STAMP) ## Run python unit tests
"$(POETRY)" run pytest -v --cov --cov-report term --cov-report html
.PHONY: lint
lint: $(INSTALL_STAMP) ## Lint code base
"$(POETRY)" run ruff check
"$(POETRY)" run ruff format --check
.PHONY: format
format: $(INSTALL_STAMP) ## Format code base
"$(POETRY)" run ruff check --fix
"$(POETRY)" run ruff format
.PHONY: format-acronyms
format-acronyms: ## Formats acronyms file, cleaning up smart quotes and capitalization. Results written to STDOUT
@"$(POETRY)" run format_acronyms
#Ruby
.PHONY: csvlint-install
csvlint-install: ## Install csvlint
bundle install
.PHONY: csvlint
csvlint: ## Runs csvlint on acronyms file
@bundle exec csvlint acronyms.csv
# Other tools
.PHONY: dupe-acronyms
dupe-acronyms: $(INSTALL_STAMP) ## prints out duplicated acronyms
@cd scripts; \
./print-dupe-acronyms.sh
.PHONY: dupe-definitions
dupe-definitions: $(INSTALL_STAMP) ## prints out duplicated definitions
@cd scripts; \
./print-dupe-definitions.sh
.PHONY: sort-acronyms
sort-acronyms: $(INSTALL_STAMP) ## Sorts acronyms file by first and second field
"$(POETRY)" run csvsort --ignore-case --columns "Title,Meaning" acronyms.csv | uniq -i > sorted.csv
# spelling
.PHONY: spelling-tool-install
spelling-tool-install: ## Installs spelling tools (only works on OSX for now)
./scripts/install-spelling-tools.sh
.PHONY: spelling-check
spelling-check: ## Checks spelling with hunspell
@cd scripts; \
./check-spelling.sh
.PHONY: clean
clean: ## Delete any directories, files or logs that are auto-generated and python packages
rm -rf results .ruff_cache .pytest_cache
rm -f $(INSTALL_STAMP) .coverage
find . -type d -name "__pycache__" | xargs rm -rf {};