-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
135 lines (113 loc) · 3.78 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
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# Builds module artifacts
.PHONY: build
build: dist
.PHONY: container
container:
podman build . --tag boardwalk:$$(poetry version --short)
# Cleans up temporary data that might get created during normal development
.PHONY: clean
clean:
set -o pipefail
@echo '[.] Removing built packages and documentation ...'
rm -rf dist/
make --directory=./docs/ clean
@echo '[.] Cleaning __pycache__ directories ...'
find . -type d -name '__pycache__' | xargs rm -rf
@echo '[.] Cleaning .boardwalk and .boardwalkd directories ...'
find . -type d -name '.boardwalk' -or -name '.boardwalkd' | xargs rm -rf
@echo '[.] Cleaning pytest and ruff caches ...'
find . -type d -name '.pytest_cache' -or -name '.ruff_cache' | xargs rm -rf
@echo '[.] Removing podman images for localhost/boardwalk ...'
podman image rm $$(podman images 'localhost/boardwalk' --quiet) || :
# Installs modules in editable mode
.PHONY: develop
develop:
poetry install
.PHONY: develop-server
develop-server: develop
ifdef BOARDWALKD_SLACK_WEBHOOK_URL
poetry run boardwalkd serve \
--develop \
--host-header-pattern="(localhost|127\.0\.0\.1)" \
--port=8888 \
--url='http://localhost:8888'
else
poetry run boardwalkd serve \
--develop \
--host-header-pattern="(localhost|127\.0\.0\.1)" \
--port=8888 \
--url='http://localhost:8888'
endif
dist: clean
poetry build
# Builds the Sphinx HTML documentation -- Shortcut for `cd docs && make html`
.PHONY: docs
docs: develop
poetry install --with=docs --sync
poetry run make --directory=./docs/ html
# Applies fixable errors, and formats code
.PHONY: format
format:
poetry run ruff check --fix
poetry run ruff format
# Installs modules to the local system (via pipx; will need Ansible injected)
.PHONY: install
install: build
pipx install --pip-args=--upgrade ./dist/boardwalk-$(poetry version --short)-py3-none-any.whl
echo "Boardwalk $(poetry version --short) installed via pipx; execute the following to inject Ansible"
echo " pipx inject boardwalk ansible"
# Installs/updates JS/CSS dependencies in boardwalkd
BOOTSTRAP_VERSION := 5.2.2
HTMX_VERSION := 1.8.2
.PHONY: install-web-deps
install-web-deps:
curl "https://unpkg.com/htmx.org@$(HTMX_VERSION)/dist/htmx.min.js" -o src/boardwalkd/static/htmx.min.js
curl "https://cdn.jsdelivr.net/npm/bootstrap@$(BOOTSTRAP_VERSION)/dist/css/bootstrap.min.css" -o src/boardwalkd/static/bootstrap.min.css
curl "https://cdn.jsdelivr.net/npm/bootstrap@$(BOOTSTRAP_VERSION)/dist/js/bootstrap.bundle.min.js" -o src/boardwalkd/static/bootstrap.bundle.min.js
# Render all d2 diagrams in ./diagrams to PNG
.PHONY: render-d2
render-d2:
for file in $$(find ./diagrams -type f -name '*.d2' -not -name '_*.d2'); \
do \
d2 $$file $${file%.*}.png; \
done
# Runs all available tests
.PHONY: test
test: test-pytest test-ruff test-pyright test-semgrep
# Run pytest verbosely if we're running manually, but normally if we're in a CI environment.
.PHONY: test-pytest
test-pytest: develop
ifndef CI
poetry run pytest --verbose
else
poetry run pytest
endif
# Run all available Ruff checks
.PHONY: test-ruff
test-ruff: test-ruff-linters test-ruff-formatting
# Run all available Ruff linter checks
.PHONY: test-ruff-linters
test-ruff-linters: develop
poetry run ruff check
# Run all available Ruff formatting checks
.PHONY: test-ruff-formatting
test-ruff-formatting: develop
poetry run ruff format --check
# Perform type analysis
.PHONY: test-pyright
test-pyright: develop
export PYRIGHT_PYTHON_FORCE_VERSION=latest
poetry run pyright
# Perform security static analysis
.PHONY: test-semgrep
test-semgrep: develop
ifndef GITHUB_ACTIONS
poetry run semgrep \
--config test/semgrep-rules.yml \
--config "p/r2c-security-audit" \
--config "p/r2c-bug-scan" \
--config "p/secrets" \
--config "p/dockerfile"
else
echo Semgrep will run in its own GitHub Actions job.
endif