From 056256f7c0880214a00428457519c78db5de6b9d Mon Sep 17 00:00:00 2001 From: Kirk Rodrigues <2454684+kirkrodrigues@users.noreply.github.com> Date: Tue, 29 Oct 2024 21:31:48 -0400 Subject: [PATCH 1/2] chore: Add Taskfile tasks to lint YAML files. --- .gitignore | 3 +++ .gitmodules | 3 +++ README.md | 39 ++++++++++++++++++++++++++++ lint-requirements.txt | 1 + lint-tasks.yaml | 58 ++++++++++++++++++++++++++++++++++++++++++ taskfile.yaml | 19 ++++++++++++++ tools/yscope-dev-utils | 1 + 7 files changed, 124 insertions(+) create mode 100644 .gitignore create mode 100644 .gitmodules create mode 100644 README.md create mode 100644 lint-requirements.txt create mode 100644 lint-tasks.yaml create mode 100644 taskfile.yaml create mode 160000 tools/yscope-dev-utils diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..79d58f8 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +# Build-related directories and files +.task/ +target/ diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..2d96d0d --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "tools/yscope-dev-utils"] + path = tools/yscope-dev-utils + url = https://github.com/y-scope/yscope-dev-utils.git diff --git a/README.md b/README.md new file mode 100644 index 0000000..c45db56 --- /dev/null +++ b/README.md @@ -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 diff --git a/lint-requirements.txt b/lint-requirements.txt new file mode 100644 index 0000000..993e8b4 --- /dev/null +++ b/lint-requirements.txt @@ -0,0 +1 @@ +yamllint>=1.35.1 diff --git a/lint-tasks.yaml b/lint-tasks.yaml new file mode 100644 index 0000000..6347f22 --- /dev/null +++ b/lint-tasks.yaml @@ -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}}" diff --git a/taskfile.yaml b/taskfile.yaml new file mode 100644 index 0000000..2678724 --- /dev/null +++ b/taskfile.yaml @@ -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}}'"] diff --git a/tools/yscope-dev-utils b/tools/yscope-dev-utils new file mode 160000 index 0000000..159768c --- /dev/null +++ b/tools/yscope-dev-utils @@ -0,0 +1 @@ +Subproject commit 159768c7d171595ed2cba17b758c10043a2efe96 From 8a2077fb367c968b9c81a25607e601d30ed04242 Mon Sep 17 00:00:00 2001 From: kirkrodrigues <2454684+kirkrodrigues@users.noreply.github.com> Date: Tue, 29 Oct 2024 22:37:56 -0400 Subject: [PATCH 2/2] Update README.md Co-authored-by: davemarco <83603688+davemarco@users.noreply.github.com> --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c45db56..1dd83b5 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # log4j2-appenders This is a repository for a set of useful [Log4j 2][log4j2] appenders. -## Contributing +# Contributing Follow the steps below to develop and contribute to the project. ## Set up