Skip to content

Commit 775d614

Browse files
authored
chore: Add Taskfile tasks to lint YAML files. (#9)
1 parent ef9ad7b commit 775d614

File tree

5 files changed

+91
-0
lines changed

5 files changed

+91
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Build-related directories and files
2+
.task
3+
build

lint-requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
yamllint>=1.35.1

taskfile.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
version: "3"
2+
3+
includes:
4+
lint: "./taskfiles/lint.yaml"
5+
utils: "tools/yscope-dev-utils/taskfiles/utils.yml"
6+
7+
vars:
8+
G_BUILD_DIR: "{{.ROOT_DIR}}/build"
9+
10+
tasks:
11+
clean:
12+
cmds:
13+
- "rm -rf '{{.G_BUILD_DIR}}'"
14+
15+
init:
16+
internal: true
17+
silent: true
18+
run: "once"
19+
cmds:
20+
- "mkdir -p '{{.G_BUILD_DIR}}'"

taskfiles/lint-yaml.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
version: "3"
2+
3+
tasks:
4+
yaml:
5+
aliases:
6+
- "yaml-check"
7+
- "yaml-fix"
8+
deps:
9+
- "venv"
10+
dir: "{{.ROOT_DIR}}"
11+
cmds:
12+
- |-
13+
. "{{.G_LINT_VENV_DIR}}/bin/activate"
14+
yamllint \
15+
--config-file "tools/yscope-dev-utils/lint-configs/.yamllint.yml" \
16+
--strict \
17+
.github \
18+
taskfile.yaml \
19+
taskfiles/

taskfiles/lint.yaml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
version: "3"
2+
3+
includes:
4+
yaml:
5+
flatten: true
6+
taskfile: "./lint-yaml.yaml"
7+
8+
vars:
9+
G_LINT_VENV_DIR: "{{.G_BUILD_DIR}}/lint-venv"
10+
G_LINT_VENV_CHECKSUM_FILE: "{{.G_BUILD_DIR}}/lint#venv.md5"
11+
12+
tasks:
13+
check:
14+
cmds:
15+
- task: "yaml-check"
16+
17+
fix:
18+
cmds:
19+
- task: "yaml-fix"
20+
21+
venv:
22+
internal: true
23+
vars:
24+
CHECKSUM_FILE: "{{.G_LINT_VENV_CHECKSUM_FILE}}"
25+
OUTPUT_DIR: "{{.G_LINT_VENV_DIR}}"
26+
sources:
27+
- "{{.ROOT_DIR}}/taskfile.yaml"
28+
- "{{.TASKFILE}}"
29+
- "lint-requirements.txt"
30+
generates:
31+
- "{{.CHECKSUM_FILE}}"
32+
deps:
33+
- ":init"
34+
- task: ":utils:validate-checksum"
35+
vars:
36+
CHECKSUM_FILE: "{{.CHECKSUM_FILE}}"
37+
DATA_DIR: "{{.OUTPUT_DIR}}"
38+
cmds:
39+
- task: ":utils:create-venv"
40+
vars:
41+
LABEL: "lint"
42+
OUTPUT_DIR: "{{.OUTPUT_DIR}}"
43+
REQUIREMENTS_FILE: "lint-requirements.txt"
44+
# This command must be last
45+
- task: ":utils:compute-checksum"
46+
vars:
47+
DATA_DIR: "{{.OUTPUT_DIR}}"
48+
OUTPUT_FILE: "{{.CHECKSUM_FILE}}"

0 commit comments

Comments
 (0)