Skip to content

Commit

Permalink
chore: Add Taskfile tasks to lint YAML files.
Browse files Browse the repository at this point in the history
  • Loading branch information
kirkrodrigues committed Oct 30, 2024
1 parent 03fa657 commit 056256f
Show file tree
Hide file tree
Showing 7 changed files with 124 additions and 0 deletions.
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/
target/
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "tools/yscope-dev-utils"]
path = tools/yscope-dev-utils
url = https://github.com/y-scope/yscope-dev-utils.git
39 changes: 39 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# log4j2-appenders
This is a repository for a set of useful [Log4j 2][log4j2] appenders.

## Contributing
Follow the steps below to develop and contribute to the project.

## Set up
Initialize and update the submodules:
```shell
git submodule update --init --recursive
```

## Linting
Before submitting a pull request, ensure you’ve run the linting [commands](#running-the-linters)
below and either fixed any violations or suppressed the warnings.

### Requirements
* Python 3.10 or higher
* [Task] 3.38.0 or higher

### Adding files
Certain file types need to be added to our linting rules manually:

* If adding a **YAML** file (regardless of its extension), add it as an argument to the `yamllint`
command in [lint-tasks.yaml](lint-tasks.yaml).

### Running the linters
To run all linting checks:
```shell
task lint:check
```

To run all linting checks AND automatically fix any fixable issues:
```shell
task lint:fix
```

[log4j2]: https://logging.apache.org/log4j/2.x/index.html
[Task]: https://taskfile.dev
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
58 changes: 58 additions & 0 deletions lint-tasks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
version: "3"

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: "yml-check"

fix:
cmds:
- task: "yml-fix"

yml:
aliases:
- "yml-check"
- "yml-fix"
deps: ["venv"]
cmds:
- |-
. "{{.G_LINT_VENV_DIR}}/bin/activate"
yamllint \
--config-file "tools/yscope-dev-utils/lint-configs/.yamllint.yml" \
--strict \
.github/ \
lint-tasks.yaml \
taskfile.yaml

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}}"]
run: "once"
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}}"
19 changes: 19 additions & 0 deletions taskfile.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
version: "3"

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

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

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

init:
internal: true
silent: true
run: "once"
cmds: ["mkdir -p '{{.G_BUILD_DIR}}'"]
1 change: 1 addition & 0 deletions tools/yscope-dev-utils
Submodule yscope-dev-utils added at 159768

0 comments on commit 056256f

Please sign in to comment.