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

Fix discovering executable files on macOS #106

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

Conversation

mislav
Copy link

@mislav mislav commented Oct 24, 2024

macOS has BSD version of the find utility, which doesn't support the -perm /111 expression, but it does support -perm +111 (which the GNU version has since deprecated).

This allows discovering extension-less executable scripts on macOS runners.

macOS has BSD version of the find utility, which doesn't support the
`-perm /111` expression, but it does support `-perm +111` (which the
GNU version has since deprecated).
Copy link

coderabbitai bot commented Oct 24, 2024

Warning

Rate limit exceeded

@mislav has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 0 minutes and 19 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Files that changed from the base of the PR and between 550fd10 and f6ecd04.

📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough

Walkthrough

The changes in this pull request include modifications to the GitHub Actions workflow file scandir.yml, enhancing verification steps by introducing two new variables, expect1 and expect2. The action.yaml file is updated to replace a deprecated input parameter with two new parameters for better control over ignored paths. Additionally, a new Bash script file named exec has been added to the testfiles/scandir directory, which outputs a simple message.

Changes

File Path Change Summary
.github/workflows/scandir.yml Updated verification steps; added variables expect1 and expect2 for enhanced error handling.
action.yaml Added input parameters ignore_paths and ignore_names; updated deprecated ignore parameter.
testfiles/scandir/exec New Bash script created that outputs "I am executable".

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant GitHub Actions
    participant ShellCheck
    participant Bash Script

    User->>GitHub Actions: Trigger workflow
    GitHub Actions->>ShellCheck: Run ShellCheck with parameters
    ShellCheck->>GitHub Actions: Return results
    GitHub Actions->>User: Output verification results
    User->>Bash Script: Execute script
    Bash Script-->>User: Output "I am executable"
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: 3

🧹 Outside diff range comments (1)
action.yaml (1)

Line range hint 8-19: Consider improving the deprecation transition strategy.

While the deprecation notice is good, the implementation could be more migration-friendly. Instead of an if-else structure that only uses either the old or new parameters, consider merging both during the transition period.

Here's a suggested approach for the exclude paths gathering section:

 declare -a excludes
 excludes+=("! -path *./.git/*")
 excludes+=("! -path *.go")
 excludes+=("! -path */mvnw")
-if [[ -n "${INPUT_IGNORE}" ]]; then
-  for path in ${INPUT_IGNORE}; do
-    excludes+=("! -path *./$path/*")
-    excludes+=("! -path */$path/*")
-    excludes+=("! -path $path")
-  done
-else
-  for path in ${INPUT_IGNORE_PATHS}; do
-    excludes+=("! -path *./$path/*")
-    excludes+=("! -path */$path/*")
-    excludes+=("! -path $path")
-  done
-fi
+# Support both old and new parameters during transition
+for path in ${INPUT_IGNORE} ${INPUT_IGNORE_PATHS}; do
+  excludes+=("! -path *./$path/*")
+  excludes+=("! -path */$path/*")
+  excludes+=("! -path $path")
+done
📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

📥 Commits

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

📒 Files selected for processing (3)
  • .github/workflows/scandir.yml (1 hunks)
  • action.yaml (1 hunks)
  • testfiles/scandir/exec (1 hunks)
🔇 Additional comments (4)
testfiles/scandir/exec (1)

1-2: LGTM! Portable shebang line with good spacing.

The shebang line uses /usr/bin/env bash which is the recommended approach for better portability across different systems.

.github/workflows/scandir.yml (2)

34-35: LGTM! Variables properly defined for cross-platform testing

The new test variables appropriately cover both regular bash scripts and extension-less executables, using portable regex syntax.


34-42: Verify test files exist in the repository

Let's ensure the test files referenced in the workflow actually exist in the repository.

✅ Verification successful

Based on the shell script results, I can generate the final response as we have sufficient information about the test files' existence and permissions.

Test files exist and have appropriate permissions

The verification confirms that:

  • Both test files exist in the expected locations:
    • testfiles/scandir/run me.bash (with space in filename)
    • testfiles/scandir/exec
  • The exec file has executable permissions (-rwxr-xr-x)
  • The file paths and permissions align with the workflow's expectations
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if the test files exist
echo "Checking for test files..."
ls -la testfiles/scandir/run*me.bash testfiles/scandir/exec 2>/dev/null || {
  echo "Warning: Test files not found"
  exit 1
}
# Check if exec file is actually executable
if [ -f testfiles/scandir/exec ]; then
  ls -l testfiles/scandir/exec | grep -q "^-..x" || {
    echo "Warning: exec file exists but may not be executable"
  }
fi

Length of output: 358

action.yaml (1)

207-207: Verify permission check coverage for different executable scenarios.

The current permission check (-perm "$perm_executable") might miss files that are executable only for specific users or groups. Consider if this matches your intended coverage.

@@ -0,0 +1,3 @@
#!/usr/bin/env bash

echo "I am executable"
Copy link

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

💡 Codebase verification

Based on the script results, I can generate the final response as we have all the necessary information:

Add newline at end of file (permissions are correct)

The file already has the correct executable permissions (-rwxr-xr-x), but it's missing a newline at the end as verified by the script output. Please add a newline at the end of the file to follow POSIX standards.

Note: I chose the tag because while the executable permissions are correct (one part of the verification), the script confirmed the missing newline issue (the other part of the verification), which needs to be addressed.

🔗 Analysis chain

Add newline at end of file and verify executable permissions.

  1. Add a newline at the end of the file to follow POSIX standards.
  2. Ensure the file has executable permissions for testing.

Let's verify the file permissions and content:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify file permissions and content
# Expected: File should be executable and end with a newline

# Check if the file is executable
ls -l testfiles/scandir/exec

# Check if file ends with a newline
if [ -n "$(tail -c1 testfiles/scandir/exec)" ]; then
  echo "Warning: No newline at end of file"
fi

Length of output: 231

.github/workflows/scandir.yml Outdated Show resolved Hide resolved
action.yaml 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.

Caution

Inline review comments failed to post. This is likely due to GitHub's limits when posting large numbers of comments.

Actionable comments posted: 1

🛑 Comments failed to post (1)
.github/workflows/scandir.yml (1)

64-64: ⚠️ Potential issue

Fix syntax error in second verification block

The fi statement is correctly added, but it creates invalid syntax with the following elif. The elif should come before the fi.

Apply this fix:

-        fi
-        elif [[ "${{ steps.two.outputs.files }}" =~ $notexpect ]];then
+        elif [[ "${{ steps.two.outputs.files }}" =~ $notexpect ]];then
+        fi

Committable suggestion was skipped due to low confidence.

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