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. #4

Merged
merged 2 commits into from
Oct 30, 2024

Conversation

kirkrodrigues
Copy link
Member

@kirkrodrigues kirkrodrigues commented Oct 30, 2024

Description

NOTE: The files in this PR (README.md, lint-requirements.txt, lint-tasks.yaml, taskfile.yaml) are mostly a copy of those in clp-ffi-js.

Validation performed

  • task lint:check validated the existing YAML files.
  • task lint:fix did the same.
  • task lint:yml did the same.
  • task lint:yml-check did the same.
  • task lint:yml-fix did the same.
  • Unquoted a string in Taskfile.yml and re-ran the steps above to ensure they detected the violation.
  • task clean cleaned any generated output.

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Added a new submodule for development utilities.
    • Introduced a comprehensive linting setup with tasks for checking and fixing YAML files.
  • Documentation

    • Updated the README to include sections on Log4j 2 appenders, contributing guidelines, setup instructions, and linting requirements.
  • Chores

    • Updated .gitignore to exclude build-related files.
    • Added a new dependency for YAML linting.
    • Introduced structured task management configurations.

Copy link

coderabbitai bot commented Oct 30, 2024

Caution

Review failed

The pull request is closed.

Walkthrough

This pull request introduces several changes across multiple files. The .gitignore file is updated to exclude specific build-related directories. A new submodule is added in the .gitmodules file. The README.md is enhanced with new sections for contributing, setup, and linting. The lint-requirements.txt file now includes a dependency for yamllint. A new configuration file, lint-tasks.yaml, is created to manage linting tasks, while taskfile.yaml introduces task management configurations. Lastly, a new subproject commit is added to the tools/yscope-dev-utils directory.

Changes

File Change Summary
.gitignore Added entries: .task/, target/
.gitmodules Added submodule: tools/yscope-dev-utils with URL https://github.com/y-scope/yscope-dev-utils.git
README.md Added sections: log4j2-appenders, Contributing, Set up, Linting, Requirements, Adding files, Running the linters
lint-requirements.txt Added dependency: yamllint>=1.35.1
lint-tasks.yaml Added tasks: check, fix, yml, venv; added variables: G_LINT_VENV_DIR, G_LINT_VENV_CHECKSUM_FILE
taskfile.yaml Added variable: G_BUILD_DIR; added tasks: clean, init
tools/yscope-dev-utils Added subproject commit: 159768c7d171595ed2cba17b758c10043a2efe96

Possibly related PRs

Suggested reviewers

  • jackluo923
  • anlowee

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 03fa657 and 056256f.

📒 Files selected for processing (7)
  • .gitignore (1 hunks)
  • .gitmodules (1 hunks)
  • README.md (1 hunks)
  • lint-requirements.txt (1 hunks)
  • lint-tasks.yaml (1 hunks)
  • taskfile.yaml (1 hunks)
  • tools/yscope-dev-utils (1 hunks)
✅ Files skipped from review due to trivial changes (4)
  • .gitignore
  • .gitmodules
  • lint-requirements.txt
  • tools/yscope-dev-utils
🧰 Additional context used
🪛 LanguageTool
README.md

[style] ~33-~33: Consider using a different verb for a more formal wording.
Context: ...un all linting checks AND automatically fix any fixable issues: ```shell task lint:...

(FIX_RESOLVE)

🔇 Additional comments (6)
taskfile.yaml (2)

7-9: LGTM! Well-structured variable definition.

The variable definition follows proper conventions with:

  • Clear global variable naming (G_ prefix)
  • Proper templating syntax
  • Safe path handling with quotes

15-19: LGTM! Well-configured initialization task.

The init task is properly configured with:

  • Appropriate internal and silent flags
  • Single-run configuration
  • Safe directory creation using -p flag
lint-tasks.yaml (4)

31-58: Well-structured virtual environment management

The venv task implementation is robust with:

  • Proper isolation using internal: true
  • Efficient caching using checksums
  • Clear dependency management
  • Good variable usage for configuration

25-25: Verify yamllint config file location

The yamllint configuration path assumes the submodule is present at a specific location.

Let's verify the config file exists:

#!/bin/bash
# Description: Check if yamllint config exists
test -f tools/yscope-dev-utils/lint-configs/.yamllint.yml && echo "Config exists" || echo "Config missing"

1-5: Verify G_BUILD_DIR variable definition

The tasks rely on G_BUILD_DIR which should be defined in a parent Taskfile.

Let's verify the variable definition:


8-15: Verify yml-check and yml-fix task definitions

The check and fix tasks reference yml-check and yml-fix tasks that aren't defined in this file.

Let's verify these task definitions:

✅ Verification successful

Let me try a different search strategy to locate these task definitions.


Let me check the content of both yaml files to understand the task definitions.


Task references are correctly defined through aliases

The yml-check and yml-fix tasks are actually aliases of the yml task defined in the same file. The yml task is properly defined with the necessary dependencies and commands for YAML linting. The task structure is valid and will work as expected.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search for yml-check and yml-fix task definitions
rg -l 'yml-(check|fix):' --type yaml

Length of output: 98


Script:

#!/bin/bash
# Search for task definitions in Taskfiles
fd "Taskfile" --type f --exec rg -l "yml-|yaml" {}

Length of output: 52


Script:

#!/bin/bash
# Search for any yaml/yml related task definitions
rg -l "task:.*ya?ml" --type yaml

Length of output: 50


Script:

#!/bin/bash
# List all yaml files to understand the task structure
fd -e yml -e yaml

Length of output: 49


Script:

#!/bin/bash
# Display content of both yaml files
echo "=== lint-tasks.yaml ==="
cat lint-tasks.yaml
echo -e "\n=== taskfile.yaml ==="
cat taskfile.yaml

Length of output: 1838

Comment on lines +11 to +14
clean:
cmds:
- "rm -rf '{{.G_BUILD_DIR}}'"

Copy link

Choose a reason for hiding this comment

The 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

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
clean:
cmds:
- "rm -rf '{{.G_BUILD_DIR}}'"
clean:
cmds:
- |
if [ -d "{{.G_BUILD_DIR}}" ]; then
rm -rf "{{.G_BUILD_DIR}}"
else
echo "Directory {{.G_BUILD_DIR}} does not exist. Nothing to clean."
fi

Comment on lines +1 to +6
version: "3"

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

Copy link

Choose a reason for hiding this comment

The 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:

  • lint-tasks.yaml exists and is correctly referenced
  • tools/yscope-dev-utils/taskfiles/utils.yml is missing
  • Inconsistent YAML extensions in the project (both .yaml and .yml are used)

Please:

  • Ensure the yscope-dev-utils submodule is properly initialized and updated
  • Consider standardizing to .yaml extension for consistency with existing files
🔗 Analysis chain

Verify 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 executed

The 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

Comment on lines +16 to +30
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

Copy link

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:

-          .github/ \
-          lint-tasks.yaml \
-          taskfile.yaml
+          {{.YAML_PATHS}}

Add to the vars section:

vars:
  YAML_PATHS: .github/ lint-tasks.yaml taskfile.yaml

davemarco
davemarco previously approved these changes Oct 30, 2024
Copy link
Contributor

@davemarco davemarco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I looked through the code, and looks very similar to clp-ffi-js. I did not test myself given urgency. I would consider adding the github workflow from clp-ffi-js, but am also happy to just do that in another PR.

README.md Outdated Show resolved Hide resolved
Co-authored-by: davemarco <[email protected]>
@kirkrodrigues kirkrodrigues merged commit e2552bd into y-scope:main Oct 30, 2024
1 check was pending
@kirkrodrigues kirkrodrigues deleted the add-yamllint branch October 30, 2024 02:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants