forked from hellt/markdown-footnote-sorter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
87 lines (72 loc) · 1.94 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
.RECIPEPREFIX = >
VENV ?= .venv/bin/activate
RUFF_IMG := ghcr.io/astral-sh/ruff
RUFF_VER := 0.7.2
MDLINT_IMG := davidanson/markdownlint-cli2
MDLINT_VER := v0.14.0
YAMLLINT_IMG := cytopia/yamllint
YAMLLINT_VER := latest
all: lint test
.PHONY: all
.PHONY: clean
clean:
> @docker rmi ${RUFF_IMG}:${RUFF_VER} \
> ${MDLINT_IMG}:${MDLINT_VER} \
> ${YAMLLINT_IMG}:${YAMLLINT_VER}
# run all the linting operations
.PHONY: lint
lint: ruff mdlint yamllint
# markdown linting
# Note: Local security access control (ex: SELinux) will temporarily need to
# be disabled for the Docker bind mounts to function.
.PHONY: mdlint
mdlint:
> @docker run --rm -v ${PWD}:/workdir ${MDLINT_IMG}:${MDLINT_VER}
# Python linting and formatting
.PHONY: ruff
ruff:
> @docker run --rm -v ${PWD}:/workdir ${RUFF_IMG}:${RUFF_VER} \
> check /workdir
> @docker run --rm -v ${PWD}:/workdir ${RUFF_IMG}:${RUFF_VER} \
> format --check --diff /workdir
# Python unit tests
.PHONY: test
test:
> @python -m unittest discover -s tests -v
# yaml linting
.PHONY: yamllint
yamllint:
> @docker run --rm -v ${PWD}:/data ${YAMLLINT_IMG}:${YAMLLINT_VER} .
### LOCAL DEVELOPMENT ###
# (non-containerized)
# clean up caches (ruff, node, py)
.PHONY: localclean
localclean:
> @rm -rf .venv node_modules .ruff_cache __pycache__ tests/__pycache__
# set up the LOCAL testing environment
.PHONY: localinit
.ONESHELL:
localinit:
> @uv venv
> @source .venv/bin/activate
> @uv pip install ruff yamllint
> @deactivate
> @npm install markdownlint-cli2 --save-dev
# remains as an artifact for those who want to use local linting
# LOCAL markdown linting
.PHONY: localmdl
localmdl:
> @./node_modules/.bin/markdownlint-cli2
# LOCAL Python linting and formatting
.PHONY: localruff
localruff:
> @source $(VENV)
> @uv run ruff check
> @uv run ruff format --check --diff
> @deactivate
# LOCAL yaml linting
.PHONY: localyaml
localyaml:
> @source $(VENV)
> @uv run yamllint .
> @deactivate