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

Added option to ignore / include symlinks #104

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Root-Core
Copy link

  • Added option to ignore / include symlinks
  • Automated tests are in place
  • Fixed trailing whitespaces
  • Fixed error message in ignore_names.yml

- Automated tests are in place
- Fixed trailing whitespaces
- Fixed error message in ignore_names.yml
Copy link

coderabbitai bot commented Oct 18, 2024

📝 Walkthrough
📝 Walkthrough

Walkthrough

The pull request introduces several modifications to GitHub Actions workflow files, enhancing their configuration and functionality. Key changes include the alignment of triggers for pull requests under the push directive in multiple workflow files, consistent formatting adjustments, and the addition of a new workflow for handling symbolic links. The action.yaml file has been updated to include a new optional input parameter for ignoring symbolic links, along with a deprecation notice for an existing parameter. Additionally, new shell script files have been created to facilitate testing.

Changes

File Path Change Summary
.github/workflows/additional_files.yml Modified on section for trigger alignment, updated formatting in Verify check step.
.github/workflows/check_together.yml Adjusted on section indentation and reformatted Verify check step for consistency.
.github/workflows/ignore_names.yml Aligned on section, added ignore_names parameter, updated error message in Verify check step.
.github/workflows/ignore_symlinks.yml Introduced new workflow for symbolic link handling, with multiple ShellCheck execution steps.
action.yaml Added ignore_symlinks parameter, updated ignore parameter with deprecation notice, modified logic.
testfiles/ignore/symlink.sh Created new shell script defining a variable and echoing its value.
testfiles/symlink.sh Added new shell script with a variable declaration and echo command, missing newline at end.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant GitHub Actions
    participant ShellCheck

    User->>GitHub Actions: Trigger push/pull request
    GitHub Actions->>ShellCheck: Run ShellCheck with ignore_symlinks
    ShellCheck->>ShellCheck: Check files with/without symbolic links
    ShellCheck->>GitHub Actions: Return results
    GitHub Actions->>User: Notify results
Loading

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:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

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

🧹 Outside diff range comments (4)
testfiles/symlink.sh (2)

Line range hint 1-4: Consider adding a shebang line

While not strictly necessary for sourced scripts, it's generally good practice to include a shebang line at the beginning of shell scripts. This improves clarity and allows for direct execution if needed.

Consider adding the following as the first line of the script:

+#!/bin/sh
 ignore/symlink.sh
 test="test"
 echo "$test"

Line range hint 4-4: Add a newline at the end of the file

The file is missing a newline at the end. This is considered bad practice and can cause issues with some tools. Please add a newline at the end of the file.

 ignore/symlink.sh
 test="test"
 echo "$test"
+
.github/workflows/ignore_names.yml (1)

Line range hint 29-30: LGTM: Added ignore_names parameter

The addition of the ignore_names parameter with the value ignore_single_file.sh aligns with the PR objective of adding an option to ignore/include specific files. This change allows for more granular control over which files are checked by ShellCheck.

Consider adding a comment explaining why ignore_single_file.sh is being ignored, to improve maintainability:

with:
  ignore_paths: ignore
  ignore_names: ignore_single_file.sh  # Ignore this file as it's used for testing the ignore functionality
🧰 Tools
🪛 yamllint

[warning] 3-3: truthy value should be one of [false, true]

(truthy)

.github/workflows/additional_files.yml (1)

Line range hint 35-47: Address shellcheck warning and add newline at end of file

  1. The expect variable on line 36 is declared but never used. Consider removing it if it's not needed, or use it in the script if it serves a purpose.
  2. Add a newline at the end of the file to comply with POSIX standards.

Here's a suggested fix:

      run: |
-        expect="testfiles/scandir/run"
+        # expect="testfiles/scandir/run"  # Uncomment and use if needed

        if [[ ! "${{ steps.check.outputs.files }}" =~ testfiles/scandir/run ]];then
          echo "::error:: Expected file testfiles/scandir/run not found in ${{ steps.check.outputs.files }}"
          exit 1
        elif [[ ! "${{ steps.check.outputs.files }}" =~ testfiles/scandir/finish ]];then
          echo "::error:: Expected file testfiles/scandir/finish not found in ${{ steps.check.outputs.files }}"
          exit 1
        elif [[ ! "${{ steps.check.outputs.files }}" =~ testfiles/scandir/discovery ]];then
          echo "::error:: Expected file testfiles/scandir/discovery not found in ${{ steps.check.outputs.files }}"
          exit 1
        fi
+

This change comments out the unused expect variable (you can uncomment and use it if needed) and adds a newline at the end of the file.

🧰 Tools
🪛 actionlint

35-35: shellcheck reported issue in this script: SC2034:warning:1:1: expect appears unused. Verify use (or export if used externally)

(shellcheck)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

📥 Commits

Files that changed from the base of the PR and between 00b27aa and 84f096c.

📒 Files selected for processing (7)
  • .github/workflows/additional_files.yml (3 hunks)
  • .github/workflows/check_together.yml (3 hunks)
  • .github/workflows/ignore_names.yml (2 hunks)
  • .github/workflows/ignore_symlinks.yml (1 hunks)
  • action.yaml (4 hunks)
  • testfiles/ignore/symlink.sh (1 hunks)
  • testfiles/symlink.sh (1 hunks)
🧰 Additional context used
🪛 yamllint
.github/workflows/additional_files.yml

[warning] 3-3: truthy value should be one of [false, true]

(truthy)


[error] 47-47: no new line character at the end of file

(new-line-at-end-of-file)

.github/workflows/check_together.yml

[warning] 3-3: truthy value should be one of [false, true]

(truthy)


[error] 44-44: no new line character at the end of file

(new-line-at-end-of-file)

.github/workflows/ignore_names.yml

[warning] 3-3: truthy value should be one of [false, true]

(truthy)

.github/workflows/ignore_symlinks.yml

[warning] 3-3: truthy value should be one of [false, true]

(truthy)


[error] 23-23: wrong indentation: expected 6 but found 4

(indentation)

🪛 actionlint
.github/workflows/additional_files.yml

35-35: shellcheck reported issue in this script: SC2034:warning:1:1: expect appears unused. Verify use (or export if used externally)

(shellcheck)

.github/workflows/ignore_symlinks.yml

52-52: step ID "check" duplicates. previously defined at line:28,col:11. step ID must be unique within a job. note that step ID is case insensitive

(id)

🔇 Additional comments (17)
testfiles/ignore/symlink.sh (1)

1-1: LGTM: Appropriate shebang for a portable shell script.

The use of #!/bin/sh is correct for a POSIX-compliant shell script, ensuring good portability across different Unix-like systems.

testfiles/symlink.sh (2)

Line range hint 1-4: Verify the intended use of this file for symlink testing

Given the PR's objective to add an option for ignoring/including symlinks, please confirm that this file is intended to be used as a test case for symlink handling. If so, consider adding a comment at the beginning of the file to explain its purpose and how it should be used in tests.

For example:

+# This file is used as a test case for symlink handling.
+# It should be symlinked to test the ignore/include symlink option.
 ignore/symlink.sh
 test="test"
 echo "$test"

This will help other developers understand the file's purpose and how it fits into the testing strategy.

To check if this file is referenced in test scripts:

#!/bin/bash
# Search for references to this file in test scripts
rg --type sh 'testfiles/symlink\.sh' tests/

1-1: 🧹 Nitpick (assertive)

Clarify the purpose of the first line

The first line ignore/symlink.sh appears to be a path or filename. If this is intentional (perhaps for symlink testing), please add a comment explaining its purpose. If it's not intentional, consider removing it.

To check if this line is present in other test files:

.github/workflows/check_together.yml (2)

3-3: Improved formatting enhances readability.

The changes to the on section and the run command in the "Verify check" step improve the overall formatting and consistency of the file. This makes the workflow more readable and maintainable.

Also applies to: 34-44

🧰 Tools
🪛 yamllint

[warning] 3-3: truthy value should be one of [false, true]

(truthy)


Line range hint 3-44: Changes align with PR objectives for code quality.

While this file doesn't directly implement the new symlink feature, the formatting improvements contribute to the overall code quality enhancements mentioned in the PR objectives. These changes help in fixing trailing whitespaces and improving code readability.

.github/workflows/ignore_names.yml (3)

Line range hint 3-9: LGTM: Improved workflow trigger configuration

The changes in the on section improve the readability and correctness of the workflow trigger configuration. Both push and pull_request events are now properly defined for the "master" branch, which aligns with best practices for GitHub Actions workflows.

🧰 Tools
🪛 yamllint

[warning] 3-3: truthy value should be one of [false, true]

(truthy)


34-44: LGTM: Improved error message and code formatting

The changes in the Verify check step improve both the accuracy of the workflow feedback and the overall code quality:

  1. The error message for an unexpected file has been correctly updated from "Expected file" to "Unexpected file", which more accurately describes the condition being checked.
  2. The indentation has been standardized, and an extraneous space before the closing fi statement has been removed, improving code readability.

These changes enhance the maintainability and clarity of the workflow.


3-3: Note on static analysis warning

The yamllint tool reports a warning for line 3: "truthy value should be one of [false, true]". This is a false positive in the context of GitHub Actions workflows. The on key is correctly used here to specify events that trigger the workflow, not as a boolean value. No changes are needed for this line.

🧰 Tools
🪛 yamllint

[warning] 3-3: truthy value should be one of [false, true]

(truthy)

.github/workflows/additional_files.yml (3)

Line range hint 3-9: LGTM: Improved workflow trigger configuration

The restructuring of the on section improves clarity and correctness. Both push and pull_request events are now properly aligned and associated with the "master" branch, which is a best practice for GitHub Actions workflows.

🧰 Tools
🪛 yamllint

[warning] 3-3: truthy value should be one of [false, true]

(truthy)


Line range hint 35-47: LGTM: Improved formatting in the Verify check step

The addition of a newline before the closing fi statement improves readability and follows good formatting practices.

🧰 Tools
🪛 actionlint

35-35: shellcheck reported issue in this script: SC2034:warning:1:1: expect appears unused. Verify use (or export if used externally)

(shellcheck)


Line range hint 1-47: Summary of changes in additional_files.yml

The changes in this file improve the workflow configuration and formatting:

  1. The on section now correctly aligns push and pull_request events.
  2. Formatting in the Verify check step has been improved.

These changes align with the PR objectives of fixing trailing whitespaces and improving code quality. However, there are minor issues to address:

  1. An unused variable in the Verify check step.
  2. A missing newline at the end of the file.

Once these small issues are resolved, the changes in this file will be fully compliant with best practices.

🧰 Tools
🪛 actionlint

35-35: shellcheck reported issue in this script: SC2034:warning:1:1: expect appears unused. Verify use (or export if used externally)

(shellcheck)

.github/workflows/ignore_symlinks.yml (2)

1-11: LGTM: Workflow configuration looks good

The workflow name is descriptive, and the trigger configuration is appropriate. Setting permissions to an empty object follows the principle of least privilege, which is a good security practice.

🧰 Tools
🪛 yamllint

[warning] 3-3: truthy value should be one of [false, true]

(truthy)


13-21: LGTM: Job configuration and matrix strategy are well-defined

The job configuration is clear and consistent with the workflow name. Using a matrix strategy to test on both Ubuntu and macOS is an excellent approach to ensure cross-platform compatibility.

action.yaml (4)

22-25: LGTM: New ignore_symlinks input parameter added successfully.

The new ignore_symlinks input parameter has been added correctly, aligning with the PR objective. It's optional, has a clear description, and the default value of "true" ensures backward compatibility.


93-93: LGTM: Proper implementation of ignore_symlinks option.

The changes correctly implement the ignore_symlinks option:

  1. The INPUT_IGNORE_SYMLINKS environment variable is set from the input.
  2. When INPUT_IGNORE_SYMLINKS is not "true", the -L option is added to file_options.

This implementation ensures that symlinks are followed only when explicitly requested by the user.

Also applies to: 101-103


159-159: LGTM: Correct integration of ignore_symlinks option in the find command.

The changes in the "Run the check" step properly integrate the ignore_symlinks option:

  1. The INPUT_FILE_OPTIONS environment variable is set from the previous step's output.
  2. The find command now includes ${INPUT_FILE_OPTIONS} before the directory argument.

This implementation ensures that the -L option (when set) is correctly passed to the find command, enabling symlink following when requested.

Also applies to: 172-174


22-25: Summary: Excellent implementation of the ignore_symlinks option.

The changes in this file successfully implement the new ignore_symlinks option, meeting the PR objective. Key points:

  1. A new input parameter is added with clear documentation.
  2. The option is properly integrated into the workflow's logic.
  3. The find command is updated to respect the new option.
  4. Backward compatibility is maintained with the default value of "true".

These changes provide users with fine-grained control over symlink behavior in the ShellCheck action while maintaining the existing functionality for current users.

Also applies to: 93-93, 101-103, 159-159, 172-174

testfiles/ignore/symlink.sh Show resolved Hide resolved
testfiles/ignore/symlink.sh Show resolved Hide resolved
testfiles/ignore/symlink.sh Show resolved Hide resolved
.github/workflows/check_together.yml Outdated Show resolved Hide resolved
.github/workflows/ignore_symlinks.yml Outdated Show resolved Hide resolved
.github/workflows/ignore_symlinks.yml Outdated Show resolved Hide resolved
.github/workflows/ignore_symlinks.yml Outdated Show resolved Hide resolved
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: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

📥 Commits

Files that changed from the base of the PR and between 84f096c and 2789fc2.

📒 Files selected for processing (1)
  • action.yaml (5 hunks)
🧰 Additional context used
🔇 Additional comments (4)
action.yaml (4)

22-25: LGTM: New ignore_symlinks parameter added successfully.

The new ignore_symlinks parameter has been implemented correctly. It aligns with the PR objectives, maintains backward compatibility with its default value, and has a clear description.


159-159: LGTM: New environment variable for file options added.

The new INPUT_FILE_OPTIONS environment variable correctly references the output from the "Set options" step, allowing the find command to use the symlink option if set.


Line range hint 1-238: Summary: PR objectives successfully implemented with minor suggestions.

The new ignore_symlinks option has been successfully implemented, meeting the PR objectives. The changes are well-integrated into the existing workflow and maintain backward compatibility. A few minor suggestions were made:

  1. Verify the usage of the "-L" option for including symlinks in the find command.
  2. Consider reviewing the slight indentation changes to ensure they align with your project's formatting guidelines.

Overall, the implementation is solid and ready for merging after addressing these minor points.


93-93: Verify the -L option for including symlinks.

The implementation of the ignore_symlinks option looks correct. However, please verify that "-L" is the correct option for including symlinks in the find command used later in the script.

To verify the usage of the "-L" option, you can run the following command:

This should show that "-L" or "--follow" is indeed the correct option for following symbolic links.

Also applies to: 101-103

✅ Verification successful

Verified the -L option correctly includes symlinks in the find command.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

find --help | grep -E "\-L|\-\-follow"

Length of output: 115

action.yaml Show resolved Hide resolved
@Root-Core
Copy link
Author

@ludeeus Any chance to get this (and other PRs) merged?

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.

1 participant