-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathcode-style.mak
More file actions
497 lines (461 loc) · 17.9 KB
/
code-style.mak
File metadata and controls
497 lines (461 loc) · 17.9 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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
# -*- makefile -*-
###########################################################################
### Documentation
###
# This Makefile fragment defines targets:
# * style-check : runs a linter on all HTML, Markdown, Python, Shell, and YAML
# files in or under the current.
# * style-fix : fixes linting problems, where possible. Not all can be fixed.
# * plume-scripts-update : updates the linting rules to the latest version.
# To use it, add these 5 lines to your Makefile:
#
# # Code style; defines `style-check` and `style-fix`.
# ifeq (,$(wildcard .plume-scripts))
# dummy := $(shell git clone --depth=1 -q https://github.com/plume-lib/plume-scripts.git .plume-scripts)
# endif
# include .plume-scripts/code-style.mak
# Environment variables (define them before the above snippet):
# * To add or remove files from style checking:
# SH_SCRIPTS_USER := dots/.aliases dots/.environment dots/.profile
# BASH_SCRIPTS_USER := dots/.bashrc dots/.bash_profile
# CODE_STYLE_EXCLUSIONS_USER := --exclude-dir apheleia --exclude-dir 'apheleia-*' --exclude-dir=mew --exclude=csail-athena-tickets.bash --exclude=conda-initialize.sh --exclude=addrfilter
# * To disable all style checking:
# CODE_STYLE_DISABLE : set to any value.
# * To change the location where to clone the plume-scripts repository:
# PLUME_SCRIPTS
# To use it in CI, copy file code-style-github-workflow.yml to
# .github/workflows/code-style.yml in your repository.
# Requirements/dependencies
#
# You need to install tools depending on what type of files your project contains:
# * must always be installed:
# * make
# * wget
# * GNU grep (for `--include` command-line argument)
# * readline that supports `--` command-line argument
# The latter two are not provided by busybox (on distributions such as Alpine Linux).
# * for HTML checking: Python, uv
# * for Markdown checking: either of these:
# * npm, markdownlint-cli2
# * Python, uv
# * for Perl checking: nothing (Perl checking is currently a no-op)
# * for Python checking: Python, uv
# * for Shell checking: shellcheck, shfmt
# * to speed up Shell checking, also: bkt
# * for YAML checking: Python, uv
# Instructions for installing these tools:
# * Python is probably already installed on your system
# * [uv](https://docs.astral.sh/uv/#installation)
# * [shellcheck](https://github.com/koalaman/shellcheck#installing)
# * [shfmt](https://webinstall.dev/shfmt/)
# * [markdownlint-cli2](https://github.com/DavidAnson/markdownlint-cli2#install)
# * [npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm)
# * [bkt](https://github.com/dimo414/bkt#installation)
# Your `.gitignore` file should contain this line:
# .plume-scripts
###########################################################################
### User-overridable variables
###
# Set the variables *before* your makefile includes `code-style.mak`.
ifndef PLUME_SCRIPTS
PLUME_SCRIPTS := .plume-scripts
endif
ifndef CODE_STYLE_EXCLUSIONS
CODE_STYLE_EXCLUSIONS := --exclude-dir=.do-like-javac --exclude-dir=.git --exclude-dir='.nfs*' --exclude-dir=${PLUME_SCRIPTS} --exclude-dir=.venv --exclude-dir=api --exclude-dir=build --exclude='.nfs*' --exclude='\#*' --exclude='*~' --exclude='*.bak' --exclude='*.tar' --exclude='*.tdy' --exclude=gradlew
endif
###########################################################################
### The code
###
.PHONY: style-fix style-check
# This "if" is closed nearly at the end of the file.
ifdef CODE_STYLE_DISABLE
style-check:
@echo 'Environment var CODE_STYLE_DISABLE is set, so `make style-check` does nothing.'
style-fix:
@echo 'Environment var CODE_STYLE_DISABLE is set, so `make style-fix` does nothing.'
else # This "else" is closed nearly at the end of the file.
# `checkbashisms` is not included by source because it uses the GPL.
ifeq (,$(wildcard ${PLUME_SCRIPTS}/checkbashisms))
dummy := $(shell cd ${PLUME_SCRIPTS} \
&& wget -q https://homes.cs.washington.edu/~mernst/software/checkbashisms \
&& chmod +x checkbashisms)
endif
# Install a git pre-commit hook if one doesn't already exist.
ifneq (,$(wildcard .git/hooks))
ifeq (,$(wildcard .git/hooks/pre-commit))
dummy := $(shell cd .git/hooks \
&& ln -s ../../${PLUME_SCRIPTS}/code-style-pre-commit pre-commit)
endif
endif
BKT_EXISTS := $(shell if command -v bkt > /dev/null 2>&1; then echo "yes"; fi)
UV_EXISTS := $(shell if command -v uv > /dev/null 2>&1; then echo "yes"; fi)
## HTML
.PHONY: html-style-fix html-style-check
style-fix: html-style-fix
style-check: html-style-check
ifneq (,${UV_EXISTS})
# Any file ending with ".html".
HTML_FILES := $(shell grep -r -l --include='*.html' ${CODE_STYLE_EXCLUSIONS} ${CODE_STYLE_EXCLUSIONS_USER} '^' .)
ifneq (,${HTML_FILES})
# HTML linters are listed in order of increasing precedence.
HTML5VALIDATOR_EXISTS_UV := $(shell if uv run html5validator --version > /dev/null 2>&1; then echo "yes"; fi)
ifdef HTML5VALIDATOR_EXISTS_UV
HTML_STYLE_FIX := uv run html5validator fix
HTML_STYLE_CHECK := uv run html5validator scan --show-warnings
HTML_STYLE_VERSION := uv run html5validator --version
endif
HTML5VALIDATOR_EXISTS_UVX := $(shell if uvx html5validator --version > /dev/null 2>&1; then echo "yes"; fi)
ifdef HTML5VALIDATOR_EXISTS_UVX
HTML_STYLE_FIX := uvx html5validator fix
HTML_STYLE_CHECK := uvx html5validator scan --show-warnings
HTML_STYLE_VERSION := uvx html5validator --version
endif
endif # ifneq (,${HTML_FILES})
endif # ifneq (,${UV_EXISTS})
html-style-fix:
ifeq (,${HTML_FILES})
@:
else
ifeq (,${UV_EXISTS})
@echo Skipping html5validator because uv is not installed.
else
ifndef HTML_STYLE_FIX
@echo Skipping html5validator because it is not installed.
-uvx html5validator --version
-uv run html5validator --version
@false
else
@${PLUME_SCRIPTS}/cronic ${HTML_STYLE_FIX} ${HTML_FILES} || (${HTML_STYLE_VERSION} && false)
endif
endif
endif # ifneq (,${HTML_FILES})
html-style-check:
ifeq (,${HTML_FILES})
@:
else
ifeq (,${UV_EXISTS})
@echo Skipping html5validator because uv is not installed.
else
ifndef HTML_STYLE_CHECK
@echo Cannot find 'uvx html5validator' or 'uv run html5validator'
-uvx html5validator --version
-uv run html5validator --version
@false
else
@${PLUME_SCRIPTS}/cronic ${HTML_STYLE_CHECK} ${HTML_FILES} || (${HTML_STYLE_VERSION} && false)
endif
endif
endif # ifeq (,${HTML_FILES})
showvars::
@echo "HTML_FILES=${HTML_FILES}"
ifneq (,${HTML_FILES})
${HTML_STYLE_VERSION}
endif
## Makefiles
# I cannot find any decent Makefile linting tool, that handles
# non-trivial Makefiles (like this one!). Three inadequate tools
# (best to worst) are:
# https://github.com/EbodShojaei/bake
# https://github.com/checkmake/checkmake
# https://crates.io/crates/unmake
## Markdown
.PHONY: markdown-style-fix markdown-style-check
style-fix: markdown-style-fix
style-check: markdown-style-check
MARKDOWN_FILES := $(shell grep -r -l --include='*.md' ${CODE_STYLE_EXCLUSIONS} ${CODE_STYLE_EXCLUSIONS_USER} '^' .)
ifneq (,${MARKDOWN_FILES})
# Markdown linters are listed in order of increasing precedence.
ifneq (,${UV_EXISTS})
PYMARKDOWNLNT_EXISTS_UV := $(shell if uv run pymarkdownlnt version > /dev/null 2>&1; then echo "yes"; fi)
ifdef PYMARKDOWNLNT_EXISTS_UV
MARKDOWN_STYLE_FIX := uv run pymarkdownlnt --config ${PLUME_SCRIPTS}/.pymarkdown fix
MARKDOWN_STYLE_CHECK := uv run pymarkdownlnt --config ${PLUME_SCRIPTS}/.pymarkdown scan
MARKDOWN_STYLE_VERSION := uv run pymarkdownlnt version
endif
PYMARKDOWNLNT_EXISTS_UVX := $(shell if uvx pymarkdownlnt version > /dev/null 2>&1; then echo "yes"; fi)
ifdef PYMARKDOWNLNT_EXISTS_UVX
MARKDOWN_STYLE_FIX := uvx pymarkdownlnt --config ${PLUME_SCRIPTS}/.pymarkdown fix
MARKDOWN_STYLE_CHECK := uvx pymarkdownlnt --config ${PLUME_SCRIPTS}/.pymarkdown scan
MARKDOWN_STYLE_VERSION := uvx pymarkdownlnt version
endif
endif # ifneq (,${UV_EXISTS})
DOCKER_EXISTS := $(shell if docker --version > /dev/null 2>&1; then echo "yes"; fi)
ifeq (yes,${DOCKER_EXISTS})
DOCKER_RUNNING := $(shell if docker version > /dev/null 2>&1; then echo "yes"; fi)
endif
ifeq (yes,${DOCKER_RUNNING})
DMDL := docker run -w /myfolder -v $$PWD:/myfolder -v $$(readlink -f ${PLUME_SCRIPTS}):/plume-scripts davidanson/markdownlint-cli2:v0.20.0
MARKDOWN_STYLE_FIX := ${DMDL} --fix --config /plume-scripts/.markdownlint-cli2.yaml "\#node_modules"
MARKDOWN_STYLE_CHECK := ${DMDL} --config /plume-scripts/.markdownlint-cli2.yaml "\#node_modules"
MARKDOWN_STYLE_VERSION := ${DMDL} --help 2>&1 | head -1
endif
MARKDOWNLINT_CLI2_EXISTS := $(shell if markdownlint-cli2 --version > /dev/null 2>&1; then echo "yes"; fi)
ifdef MARKDOWNLINT_CLI2_EXISTS
MARKDOWN_STYLE_FIX := markdownlint-cli2 --fix --config ${PLUME_SCRIPTS}/.markdownlint-cli2.yaml "\#node_modules"
MARKDOWN_STYLE_CHECK := markdownlint-cli2 --config ${PLUME_SCRIPTS}/.markdownlint-cli2.yaml "\#node_modules"
MARKDOWN_STYLE_VERSION := markdownlint-cli2 --help | head -1
endif
endif # ifneq (,${MARKDOWN_FILES})
markdown-style-fix:
ifeq (,${MARKDOWN_FILES})
@:
else
ifndef MARKDOWN_STYLE_FIX
@echo Cannot find 'uvx pymarkdownlnt' or 'uv run pymarkdownlnt' or 'markdownlint-cli2'
-uvx pymarkdownlnt version
-uv run pymarkdownlnt version
-markdownlint-cli2 --version
else
@${PLUME_SCRIPTS}/cronic ${MARKDOWN_STYLE_FIX} ${MARKDOWN_FILES} || (${MARKDOWN_STYLE_VERSION} && false)
endif
endif # ifeq (,${MARKDOWN_FILES})
markdown-style-check:
ifeq (,${MARKDOWN_FILES})
@:
else
ifndef MARKDOWN_STYLE_CHECK
@echo Cannot find 'uvx pymarkdownlnt' or 'uv run pymarkdownlnt' or 'markdownlint-cli2'
-uvx pymarkdownlnt version
-uv run pymarkdownlnt version
-command -v markdownlint-cli2
@false
else
@${PLUME_SCRIPTS}/cronic ${MARKDOWN_STYLE_CHECK} ${MARKDOWN_FILES} || (${MARKDOWN_STYLE_VERSION} && false)
endif
endif # ifeq (,${MARKDOWN_FILES})
showvars::
@echo "MARKDOWN_FILES=${MARKDOWN_FILES}"
ifneq (,${MARKDOWN_FILES})
${MARKDOWN_STYLE_VERSION}
@echo "DOCKER_EXISTS=${DOCKER_EXISTS}"
ifeq (yes,${DOCKER_EXISTS})
which docker
docker --version
@echo "DOCKER_RUNNING=${DOCKER_RUNNING}"
ifeq (yes,${DOCKER_RUNNING})
docker version
echo "DMDL=${DMDL}"
endif
endif
@echo "PYMARKDOWNLNT_EXISTS_UVX=${PYMARKDOWNLNT_EXISTS_UVX}"
@echo "PYMARKDOWNLNT_EXISTS_UV=${PYMARKDOWNLNT_EXISTS_UV}"
@echo "MARKDOWNLINT_CLI2_EXISTS=${MARKDOWNLINT_CLI2_EXISTS}"
@echo "MARKDOWN_STYLE_FIX=${MARKDOWN_STYLE_FIX}"
@echo "MARKDOWN_STYLE_CHECK=${MARKDOWN_STYLE_CHECK}"
endif
## Perl
.PHONY: perl-style-fix perl-style-check
style-fix: perl-style-fix
style-check: perl-style-check
# Any file ending with ".pl" or ".pm" or containing a Perl shebang line.
PERL_FILES := $(strip $(shell grep -r -l --include='*.pl' --include='*.pm' ${CODE_STYLE_EXCLUSIONS} ${CODE_STYLE_EXCLUSIONS_USER} '^' .) $(shell grep -r -n --exclude='*.pl' --exclude='*.pm' ${CODE_STYLE_EXCLUSIONS} ${CODE_STYLE_EXCLUSIONS_USER} '^\#! \?\(/bin/\|/usr/bin/\|/usr/bin/env \)perl' . | grep ":1:" | sed "s/:1:.*//"))
perl-style-fix:
@:
ifneq (,${PERL_FILES})
# I don't think that perltidy is an improvement.
# @perltidy -w -b -bext='/' -gnu ${PERL_FILES}
# @find . -name '*.tdy' -type f -delete
endif
perl-style-check:
@:
ifneq (,${PERL_FILES})
# I don't think that perltidy is an improvement.
# @perltidy -w ${PERL_FILES}
# @find . -name '*.tdy' -type f -delete
endif
showvars::
@echo "PERL_FILES=${PERL_FILES}"
## Python
.PHONY: python-style-fix python-style-check python-typecheck
style-fix: python-style-fix
style-check: python-style-check python-typecheck
# Any file ending with ".py" or containing a Python shebang line.
PYTHON_FILES:=$(strip $(shell grep -r -l --include='*.py' ${CODE_STYLE_EXCLUSIONS} ${CODE_STYLE_EXCLUSIONS_USER} '^' .) $(shell grep -r -n --exclude='*.py' ${CODE_STYLE_EXCLUSIONS} ${CODE_STYLE_EXCLUSIONS_USER} '^\#! \?\(/bin/\|/usr/bin/\|/usr/bin/env \)python' . | grep ":1:" | sed "s/:1:.*//"))
ifneq (,${PYTHON_FILES})
ifneq (,${UV_EXISTS})
RUFF_EXISTS_UV := $(shell if uv run ruff version > /dev/null 2>&1; then echo "yes"; fi)
ifdef RUFF_EXISTS_UV
RUFF := uv run ruff
endif
RUFF_EXISTS_UVX := $(shell if uvx ruff version > /dev/null 2>&1; then echo "yes"; fi)
ifdef RUFF_EXISTS_UVX
RUFF := uvx ruff
endif
TY_EXISTS_UV := $(shell if uv run ty version > /dev/null 2>&1; then echo "yes"; fi)
ifdef TY_EXISTS_UV
TY := uv run ty
endif
TY_EXISTS_UVX := $(shell if uvx ty version > /dev/null 2>&1; then echo "yes"; fi)
ifdef TY_EXISTS_UVX
TY := uvx ty
endif
endif # ifneq (,${UV_EXISTS})
endif # ifneq (,${PYTHON_FILES})
python-style-fix:
ifeq (,${PYTHON_FILES})
@:
else
ifeq (,${RUFF})
@echo Skipping ruff because it is not installed.
else
@${PLUME_SCRIPTS}/cronic ${RUFF} format --config ${PLUME_SCRIPTS}/.ruff.toml ${PYTHON_FILES} || (${RUFF} version && false)
@${PLUME_SCRIPTS}/cronic ${RUFF} check --fix --config ${PLUME_SCRIPTS}/.ruff.toml ${PYTHON_FILES} || (${RUFF} version && false)
endif
endif
python-style-check:
ifeq (,${PYTHON_FILES})
@:
else
ifeq (,${RUFF})
@echo Skipping ruff because it is not installed.
else
@${PLUME_SCRIPTS}/cronic ${RUFF} format --check --config ${PLUME_SCRIPTS}/.ruff.toml ${PYTHON_FILES} || (${RUFF} version && false)
@${PLUME_SCRIPTS}/cronic ${RUFF} check --config ${PLUME_SCRIPTS}/.ruff.toml ${PYTHON_FILES} || (${RUFF} version && false)
endif
endif
python-typecheck:
ifeq (,${PYTHON_FILES})
@:
else
ifeq (,${TY})
@echo Skipping ty because it is not installed.
else
# Problem: `ty` ignores files passed on the command line that do not end with `.py`.
@${PLUME_SCRIPTS}/cronic ${TY} check --error-on-warning --no-progress ${PYTHON_FILES} || (${TY} version && false)
endif
endif
showvars::
@echo "PYTHON_FILES=${PYTHON_FILES}"
ifneq (,${PYTHON_FILES})
@echo "RUFF_EXISTS_UVX=${RUFF_EXISTS_UVX}"
@echo "RUFF_EXISTS_UV=${RUFF_EXISTS_UV}"
@echo "RUFF=${RUFF}"
ifdef RUFF
${RUFF} version
endif
@echo "TY_EXISTS_UVX=${TY_EXISTS_UVX}"
@echo "TY_EXISTS_UV=${TY_EXISTS_UV}"
@echo "TY=${TY}"
ifdef TY
${TY} version
endif
endif
## Shell
.PHONY: shell-style-fix shell-style-check
style-fix: shell-style-fix
style-check: shell-style-check
# Files ending with ".sh" might be bash or Posix sh, so don't make any assumption about them.
SH_SCRIPTS := $(strip ${SH_SCRIPTS_USER} $(shell grep -r -n ${CODE_STYLE_EXCLUSIONS} ${CODE_STYLE_EXCLUSIONS_USER} '^\#! \?\(/bin/\|/usr/bin/env \)sh' . | grep ":1:" | sed "s/:1:.*//"))
# Any file ending with ".bash" or containing a bash shebang line.
BASH_SCRIPTS := $(strip ${BASH_SCRIPTS_USER} $(shell grep -r -l --include='*.bash' ${CODE_STYLE_EXCLUSIONS} ${CODE_STYLE_EXCLUSIONS_USER} '^' .) $(shell grep -r -n --exclude='*.bash' ${CODE_STYLE_EXCLUSIONS} ${CODE_STYLE_EXCLUSIONS_USER} '^\#! \?\(/bin/\|/usr/bin/env \)bash' . | grep ":1:" | sed "s/:1:.*//"))
SH_AND_BASH_SCRIPTS := $(strip ${SH_SCRIPTS} ${BASH_SCRIPTS})
ifneq (,${SH_AND_BASH_SCRIPTS})
ifneq (,${BKT_EXISTS})
SHELL_BKT_COMMAND := bkt --cwd $(patsubst %,--modtime %,${SH_AND_BASH_SCRIPTS}) --ttl 1month --
endif
SHFMT_EXISTS := $(shell if shfmt --version > /dev/null 2>&1; then echo "yes"; fi)
SHELLCHECK_EXISTS := $(shell if shellcheck --version > /dev/null 2>&1; then echo "yes"; fi)
endif # ifneq (,$SH_AND_BASH_SCRIPTS)
shell-style-fix:
ifeq (,${SH_AND_BASH_SCRIPTS})
@:
else
ifeq (,${SHFMT_EXISTS})
@echo "skipping shfmt because it is not installed"
else
@${SHELL_BKT_COMMAND} ${PLUME_SCRIPTS}/cronic shfmt -w -i 2 -ci -bn -sr ${SH_AND_BASH_SCRIPTS} || (shfmt --version && false)
endif
ifeq (,${SHELLCHECK_EXISTS})
@echo "skipping shellcheck because it is not installed"
else
@${SHELL_BKT_COMMAND} shellcheck -x -P SCRIPTDIR --format=diff ${SH_AND_BASH_SCRIPTS} | patch -p1 || (shellcheck --version && false)
endif
endif # ifeq (,${SH_AND_BASH_SCRIPTS})
shell-style-check:
ifeq (,${SH_AND_BASH_SCRIPTS})
@:
else
ifeq (,${SHFMT_EXISTS})
@echo "skipping shfmt because it is not installed"
else
@${SHELL_BKT_COMMAND} ${PLUME_SCRIPTS}/cronic shfmt -d -i 2 -ci -bn -sr ${SH_AND_BASH_SCRIPTS} || (shfmt --version && false)
endif
ifeq (,${SHELLCHECK_EXISTS})
@echo "skipping shellcheck because it is not installed"
else
@${SHELL_BKT_COMMAND} ${PLUME_SCRIPTS}/cronic shellcheck -x -P SCRIPTDIR --format=gcc ${SH_AND_BASH_SCRIPTS} || (shellcheck --version && false)
endif
endif # ifeq (,${SH_AND_BASH_SCRIPTS})
ifneq (,${SH_SCRIPTS})
@${SHELL_BKT_COMMAND} ${PLUME_SCRIPTS}/cronic ${PLUME_SCRIPTS}/checkbashisms -l ${SH_SCRIPTS}
endif
showvars::
@echo "SH_SCRIPTS=${SH_SCRIPTS}"
@echo "BASH_SCRIPTS=${BASH_SCRIPTS}"
ifneq (,${SH_AND_BASH_SCRIPTS})
@echo "SHFMT_EXISTS=${SHFMT_EXISTS}"
ifneq (,${SHFMT_EXISTS})
shfmt --version
endif
@echo "UV_EXISTS=${UV_EXISTS}"
ifneq (,${UV_EXISTS})
uv --version
endif
@echo "BKT_EXISTS=${BKT_EXISTS}"
ifneq (,${BKT_EXISTS})
bkt --version
@echo "SHELL_BKT_COMMAND=${SHELL_BKT_COMMAND}"
endif
@echo "SHELLCHECK_EXISTS=${SHELLCHECK_EXISTS}"
ifneq (,${SHELLCHECK_EXISTS})
shellcheck --version | head -2
endif
endif
## YAML
.PHONY: yaml-style-fix yaml-style-check
style-fix: yaml-style-fix
style-check: yaml-style-check
# Any file ending with ".yaml" or ".yml".
YAML_FILES := $(shell grep -r -l --include='*.yaml' --include='*.yml' ${CODE_STYLE_EXCLUSIONS} ${CODE_STYLE_EXCLUSIONS_USER} '^' .)
ifneq (,${YAML_FILES})
# YAML linters are listed in order of increasing precedence.
YAMLLINT_EXISTS := $(shell if yamllint --version > /dev/null 2>&1; then echo "yes"; fi)
ifneq (,${YAMLLINT_EXISTS})
YAMLLINT := yamllint
endif
ifneq (,${UV_EXISTS})
PYYAMLLNT_EXISTS_UV := $(shell if uv run yamllint --version > /dev/null 2>&1; then echo "yes"; fi)
ifdef PYYAMLLNT_EXISTS_UV
YAMLLINT := uv run yamllint
endif
PYYAMLLNT_EXISTS_UVX := $(shell if uvx yamllint --version > /dev/null 2>&1; then echo "yes"; fi)
ifdef PYYAMLLNT_EXISTS_UVX
YAMLLINT := uvx yamllint
endif
endif # ifneq (,${UV_EXISTS})
endif # ifneq (,${YAML_FILES})
yaml-style-fix:
ifeq (,${YAML_FILES})
@:
else
@:
endif
yaml-style-check:
ifeq (,${YAML_FILES})
@:
else
ifeq (,${YAMLLINT})
@echo "skipping yamllint because it is not installed"
else
@${PLUME_SCRIPTS}/cronic ${YAMLLINT} -c ${PLUME_SCRIPTS}/.yamllint.yaml --format parsable ${YAML_FILES} || (${YAMLLINT} --version && false)
endif
endif # ifeq (,${YAML_FILES})
showvars::
@echo "YAML_FILES=${YAML_FILES}"
@echo "YAMLLINT=${YAMLLINT}"
ifneq (,${YAMLLINT})
${YAMLLINT} --version
endif
endif # ifdef CODE_STYLE_DISABLE
plume-scripts-update update-plume-scripts:
@${PLUME_SCRIPTS}/cronic git -C ${PLUME_SCRIPTS} pull -q --ff-only