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

Add option to skip downloading shellcheck on every run #108

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mislav
Copy link

@mislav mislav commented Oct 24, 2024

When reviewing this action, I was surprised that it downloads shellcheck on every run even though shellcheck comes pre-installed with GitHub Actions runner images.

With special version: system action input value, this will skip downloading shellcheck from GitHub on every run and instead use the shellcheck version that comes preinstalled. This is an alternative approach to #100

Otherwise, when shellcheck is downloaded, it is extracted into a temporary directory (as opposed to github.action_path) which is then added to PATH.

With special `version: system` action input value, this will skip downloading
shellcheck from GitHub on every run and instead use the shellcheck version
that comes preinstalled in GitHub Actions runner images.

When shellcheck is downloaded, it is extracted into a temporary directory
(as opposed to `github.action_path`) which is then added to PATH.
Copy link

coderabbitai bot commented Oct 24, 2024

📝 Walkthrough

Walkthrough

The changes in this pull request involve updates to the README.md and action.yaml files for the ShellCheck GitHub action. The README.md has been enhanced to clarify how users can specify the ShellCheck version, including the option to use a pre-installed version with the special value version: system. The action.yaml file has seen modifications in input descriptions, the deprecation of the ignore input, and changes to the logic for downloading and executing ShellCheck, streamlining the process while maintaining overall functionality.

Changes

File Change Summary
README.md Expanded section on specifying ShellCheck version; clarified options for using a pre-installed version; added note about potential outdated pre-installed versions.
action.yaml Updated input descriptions for version and deprecated ignore; modified download logic to check for 'system' version; streamlined command execution for ShellCheck.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant GitHub Action
    participant ShellCheck

    User->>GitHub Action: Trigger action
    GitHub Action->>ShellCheck: Check INPUT_VERSION
    alt version is 'system'
        ShellCheck-->>GitHub Action: Use pre-installed ShellCheck
    else version specified
        GitHub Action->>ShellCheck: Download specified version
        ShellCheck-->>GitHub Action: Return ShellCheck executable
    end
    GitHub Action->>ShellCheck: Execute ShellCheck
    ShellCheck-->>GitHub Action: Return results
    GitHub Action-->>User: Output 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.

@mislav
Copy link
Author

mislav commented Oct 24, 2024

@coderabbitai full review

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

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

📥 Commits

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

📒 Files selected for processing (2)
  • README.md (2 hunks)
  • action.yaml (3 hunks)
🔇 Additional comments (6)
README.md (2)

Line range hint 160-169: LGTM! Clear and well-structured documentation update.

The documentation clearly explains the version specification options and maintains consistency with the existing format.


170-170: LGTM! Clear documentation of the new feature.

The documentation effectively communicates the new version: system option and includes an important note about potential version differences. The link to runner images is helpful for users to verify the pre-installed version.

action.yaml (4)

44-44: LGTM! Clear and well-documented input description.

The description effectively communicates the new 'system' option while maintaining backward compatibility.


87-87: LGTM! Simplified version display.

The command is correctly simplified since shellcheck is now available in PATH.


211-216: LGTM! Consistent simplification of shellcheck execution.

The execution commands are correctly simplified while maintaining the same functionality.


64-82: Verify system shellcheck functionality.

Let's ensure the system shellcheck option works as expected across different runner environments.

✅ Verification successful

System shellcheck functionality verified successfully

The system shellcheck is available and functional in the runner environment with version 0.9.0 installed. This confirms that the system option in the action will work as expected, allowing users to utilize the pre-installed shellcheck version.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify system shellcheck availability and version across different runner environments

# Test: Check if shellcheck is pre-installed on the runner
if ! command -v shellcheck &> /dev/null; then
    echo "::warning::shellcheck not found in PATH"
    exit 1
fi

# Test: Get shellcheck version for documentation
shellcheck --version

Length of output: 184

README.md Show resolved Hide resolved
action.yaml Show resolved Hide resolved
action.yaml Show resolved Hide resolved
Comment on lines +79 to +82
curl -fsSL "https://github.com/koalaman/shellcheck/releases/download/${INPUT_VERSION}/shellcheck-${INPUT_VERSION}.${osvariant}.x86_64.tar.xz" | \
tar -xz -C "${download_dir}" --strip-components 1 -- "shellcheck-${INPUT_VERSION}/shellcheck"

tar -xf "${{ github.action_path }}/sc.tar.xz" -C "${{ github.action_path }}"
mv "${{ github.action_path }}/shellcheck-${INPUT_VERSION}/shellcheck" \
"${{ github.action_path }}/shellcheck"
echo "${download_dir}" >> "$GITHUB_PATH"
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Verify shellcheck binary after extraction.

The download and extraction should be verified to ensure we have a working shellcheck binary.

 curl -fsSL "https://github.com/koalaman/shellcheck/releases/download/${INPUT_VERSION}/shellcheck-${INPUT_VERSION}.${osvariant}.x86_64.tar.xz" | \
   tar -xz -C "${download_dir}" --strip-components 1 -- "shellcheck-${INPUT_VERSION}/shellcheck"

+if [ ! -x "${download_dir}/shellcheck" ]; then
+  echo "::error::Failed to download or extract shellcheck"
+  exit 1
+fi
+
 echo "${download_dir}" >> "$GITHUB_PATH"
📝 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
curl -fsSL "https://github.com/koalaman/shellcheck/releases/download/${INPUT_VERSION}/shellcheck-${INPUT_VERSION}.${osvariant}.x86_64.tar.xz" | \
tar -xz -C "${download_dir}" --strip-components 1 -- "shellcheck-${INPUT_VERSION}/shellcheck"
tar -xf "${{ github.action_path }}/sc.tar.xz" -C "${{ github.action_path }}"
mv "${{ github.action_path }}/shellcheck-${INPUT_VERSION}/shellcheck" \
"${{ github.action_path }}/shellcheck"
echo "${download_dir}" >> "$GITHUB_PATH"
curl -fsSL "https://github.com/koalaman/shellcheck/releases/download/${INPUT_VERSION}/shellcheck-${INPUT_VERSION}.${osvariant}.x86_64.tar.xz" | \
tar -xz -C "${download_dir}" --strip-components 1 -- "shellcheck-${INPUT_VERSION}/shellcheck"
if [ ! -x "${download_dir}/shellcheck" ]; then
echo "::error::Failed to download or extract shellcheck"
exit 1
fi
echo "${download_dir}" >> "$GITHUB_PATH"

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