-
Notifications
You must be signed in to change notification settings - Fork 2
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. #4
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Build-related directories and files | ||
.task/ | ||
target/ |
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 |
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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
yamllint>=1.35.1 |
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}}" |
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" | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
Comment on lines
+1
to
+6
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Codebase verification Fix missing utility task file and standardize YAML file extensions The verification revealed:
Please:
🔗 Analysis chainVerify the included task file paths and standardize file extensions. The file paths need verification, and there's an inconsistency in the YAML file extensions (.yaml vs .yml). Let's verify the file paths and check for consistency: 🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Description: Verify the existence of included task files and check for YAML extension consistency
echo "Checking for included task files..."
for file in lint-tasks.yaml tools/yscope-dev-utils/taskfiles/utils.yml; do
if [ -f "$file" ]; then
echo "✓ Found: $file"
else
echo "✗ Missing: $file"
fi
done
echo -e "\nChecking YAML file extension consistency..."
fd -e yml -e yaml . -x echo "Found YAML file: {}"
Length of output: 710 |
||||||||||||||||||||||||||
vars: | ||||||||||||||||||||||||||
G_BUILD_DIR: "{{.ROOT_DIR}}/target" | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
tasks: | ||||||||||||||||||||||||||
clean: | ||||||||||||||||||||||||||
cmds: | ||||||||||||||||||||||||||
- "rm -rf '{{.G_BUILD_DIR}}'" | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
Comment on lines
+11
to
+14
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Consider adding a precondition check to the clean task. While the clean task is well-implemented, it could benefit from a precondition to verify the directory exists before attempting removal. Consider this safer implementation: clean:
cmds:
- - "rm -rf '{{.G_BUILD_DIR}}'"
+ - |
+ if [ -d "{{.G_BUILD_DIR}}" ]; then
+ rm -rf "{{.G_BUILD_DIR}}"
+ else
+ echo "Directory {{.G_BUILD_DIR}} does not exist. Nothing to clean."
+ fi 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||
init: | ||||||||||||||||||||||||||
internal: true | ||||||||||||||||||||||||||
silent: true | ||||||||||||||||||||||||||
run: "once" | ||||||||||||||||||||||||||
cmds: ["mkdir -p '{{.G_BUILD_DIR}}'"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Consider making YAML paths configurable
The list of YAML files to lint is hardcoded. Consider moving these paths to variables for better maintainability.
Here's a suggested improvement:
Add to the vars section: