-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathlint-sh.yaml
More file actions
66 lines (63 loc) · 1.9 KB
/
lint-sh.yaml
File metadata and controls
66 lines (63 loc) · 1.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
version: "3"
tasks:
sh:
# NOTE: shellcheck does not have the ability to fix errors.
aliases:
- "sh-check"
- "sh-fix"
desc: "Runs the shell script linters. Only checks for warnings and violations."
vars:
SHELLCHECK_FLAGS: "--enable=all --severity=style --external-sources --norc"
sources:
- "{{.G_LINT_VENV_CHECKSUM_FILE}}"
- "{{.G_SCRIPT_DIR}}/**/*.sh"
- "{{.TASKFILE}}"
deps:
- "venv"
cmds:
- task: "linux-shellcheck"
vars:
FLAGS: "{{.SHELLCHECK_FLAGS}}"
SRC_PATHS:
ref: ".G_LINT_SH_DIRS"
VENV_DIR: "{{.G_LINT_VENV_DIR}}"
- task: "macos-shellcheck"
vars:
FLAGS: "{{.SHELLCHECK_FLAGS}}"
SRC_PATHS:
ref: ".G_LINT_SH_DIRS"
VENV_DIR: "{{.G_LINT_VENV_DIR}}"
linux-shellcheck:
internal: true
vars:
EXCLUDES:
- "**/macos"
- "**/centos-stream-9"
requires:
vars: ["FLAGS", "SRC_PATHS", "VENV_DIR"]
platforms: ["linux"] # Requires raw strings and cannot interpret variable substitutions
cmd: |-
. "{{.VENV_DIR}}/bin/activate"
find {{- range .SRC_PATHS}} "{{.}}" {{- end}} \
\( {{- range $i, $path := .EXCLUDES }}{{if $i}} -o {{end}} -path '{{ $path }}'{{end}} \) \
-prune -o \
-type f -iname "*.sh" \
-print0 | \
xargs -0 shellcheck {{.FLAGS}}
macos-shellcheck:
internal: true
vars:
EXCLUDES:
- "**/linux"
- "**/centos-stream-9"
requires:
vars: ["FLAGS", "SRC_PATHS", "VENV_DIR"]
platforms: ["darwin"]
cmd: |-
. "{{.VENV_DIR}}/bin/activate"
find {{- range .SRC_PATHS}} "{{.}}" {{- end}} \
\( {{- range $i, $path := .EXCLUDES }}{{if $i}} -o {{end}} -path '{{ $path }}'{{end}} \) \
-prune -o \
-type f -iname "*.sh" \
-print0 | \
xargs -0 shellcheck {{.FLAGS}}