Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Add Taskfile tasks to lint YAML files. #9

Merged
merged 7 commits into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Build-related directories and files
.task
build
1 change: 1 addition & 0 deletions lint-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
yamllint>=1.35.1
20 changes: 20 additions & 0 deletions taskfile.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
version: "3"

includes:
lint: "./taskfiles/lint.yaml"
utils: "tools/yscope-dev-utils/taskfiles/utils.yml"

vars:
G_BUILD_DIR: "{{.ROOT_DIR}}/build"

tasks:
clean:
cmds:
- "rm -rf '{{.G_BUILD_DIR}}'"

init:
internal: true
silent: true
run: "once"
cmds:
- "mkdir -p '{{.G_BUILD_DIR}}'"
19 changes: 19 additions & 0 deletions taskfiles/lint-yaml.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
version: "3"

tasks:
yaml:
aliases:
- "yaml-check"
- "yaml-fix"
deps:
- "venv"
dir: "{{.ROOT_DIR}}"
cmds:
- |-
. "{{.G_LINT_VENV_DIR}}/bin/activate"
yamllint \
--config-file "tools/yscope-dev-utils/lint-configs/.yamllint.yml" \
--strict \
.github \
taskfile.yaml \
taskfiles/
48 changes: 48 additions & 0 deletions taskfiles/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
version: "3"

includes:
yaml:
flatten: true
taskfile: "./lint-yaml.yaml"

vars:
G_LINT_VENV_DIR: "{{.G_BUILD_DIR}}/lint-venv"
G_LINT_VENV_CHECKSUM_FILE: "{{.G_BUILD_DIR}}/lint#venv.md5"

tasks:
check:
cmds:
- task: "yaml-check"

fix:
cmds:
- task: "yaml-fix"

venv:
internal: true
vars:
CHECKSUM_FILE: "{{.G_LINT_VENV_CHECKSUM_FILE}}"
OUTPUT_DIR: "{{.G_LINT_VENV_DIR}}"
sources:
- "{{.ROOT_DIR}}/taskfile.yaml"
- "{{.TASKFILE}}"
- "lint-requirements.txt"
generates:
- "{{.CHECKSUM_FILE}}"
deps:
- ":init"
- task: ":utils:validate-checksum"
vars:
CHECKSUM_FILE: "{{.CHECKSUM_FILE}}"
DATA_DIR: "{{.OUTPUT_DIR}}"
cmds:
- task: ":utils:create-venv"
vars:
LABEL: "lint"
OUTPUT_DIR: "{{.OUTPUT_DIR}}"
REQUIREMENTS_FILE: "lint-requirements.txt"
# This command must be last
- task: ":utils:compute-checksum"
vars:
DATA_DIR: "{{.OUTPUT_DIR}}"
OUTPUT_FILE: "{{.CHECKSUM_FILE}}"