Skip to content

Conversation

appleboy
Copy link
Owner

@appleboy appleboy commented Aug 31, 2025

  • Skip downloading the binary if it already exists, and print a message instead

fixed #202
fixed #201

Summary by CodeRabbit

  • Bug Fixes
    • Prevents unnecessary re-downloading of the client binary on subsequent runs by skipping when it already exists, improving startup speed and reducing bandwidth usage.
    • Adds a clear log message indicating when the download is skipped, providing more transparent startup output.
    • Ensures idempotent, more reliable startup behavior with no action required from users.

- Skip downloading the binary if it already exists, and print a message instead

Signed-off-by: appleboy <appleboy.tw@gmail.com>
Copy link

coderabbitai bot commented Aug 31, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

The entrypoint script now checks whether the target client binary is executable before downloading; it downloads and sets executable only if missing or non-executable, otherwise logs a skip message. Invocation of the binary (e.g., --version) remains unchanged.

Changes

Cohort / File(s) Change Summary
Entrypoint download guard
entrypoint.sh
Added guard if [[ ! -x "${TARGET}" ]]; then to download and chmod +x only when the TARGET is not executable; otherwise print a skip message and skip download.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Container as Container Runtime
  participant Entrypoint as entrypoint.sh
  participant FS as File System
  participant Net as curl

  Container->>Entrypoint: Start
  Entrypoint->>FS: test -x TARGET ?
  alt TARGET is executable
    Entrypoint-->>Container: Log "Binary ... already exists and is executable, skipping download."
  else TARGET missing or not executable
    Entrypoint->>Net: curl download CLIENT_BINARY
    Net-->>Entrypoint: Binary bytes
    Entrypoint->>FS: chmod +x TARGET
  end
  Entrypoint-->>Container: Invoke CLIENT_BINARY --version
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Assessment against linked issues

Objective Addressed Explanation
Check detect_client(${TARGET}) exist for cache (#202)
cache drone-scp (#201) The change prevents re-downloading when binary is executable, which enables caching, but PR does not modify CI/cache config to explicitly persist TARGET between builds.

Poem

I thump a paw, the burrow's sound—no need to fetch anew,
If files are set and ready, I skip the long review.
But if the burrow's empty, I fetch and make it right,
Then tidy up with chmod and hop into the night. 🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 775954b and 9b43957.

📒 Files selected for processing (1)
  • entrypoint.sh (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • entrypoint.sh
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch cache

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.
    • 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.
  • 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 the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit 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

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Summary of Changes

Hello @appleboy, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the efficiency of the entrypoint script by intelligently managing binary downloads. It ensures that the necessary client binary is only downloaded if it's not already present, thereby saving time and resources. This change also improves user experience by providing explicit feedback when a download is bypassed.

Highlights

  • Binary Download Optimization: The pull request introduces a check to prevent redundant downloads of the client binary. If the target binary file already exists, the download process is now skipped.
  • User Notification: When a binary download is skipped because the file already exists, a clear message is now printed to the console, informing the user of this action.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a check to avoid re-downloading the drone-scp binary if it already exists, which is a good optimization. My review includes a suggestion to make this check more robust by verifying not just the existence of the file, but also its execute permissions. This will prevent potential failures in edge cases where the file exists but is not executable.

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
entrypoint.sh (2)

38-41: Avoid unbound variable errors under set -u for INPUT_CURL_INSECURE.

With set -u, an unset INPUT_CURL_INSECURE will abort the script. Default it.

-INSECURE_OPTION=""
-if [[ "${INPUT_CURL_INSECURE}" == 'true' ]]; then
+INSECURE_OPTION=""
+if [[ "${INPUT_CURL_INSECURE:-false}" == 'true' ]]; then
   INSECURE_OPTION="--insecure"
 fi

52-60: Same set -u issue for INPUT_CAPTURE_STDOUT; provide a default.

Prevents unexpected exits when the input isn’t supplied.

-if [[ "${INPUT_CAPTURE_STDOUT}" == 'true' ]]; then
+if [[ "${INPUT_CAPTURE_STDOUT:-false}" == 'true' ]]; then
   {
     echo 'stdout<<EOF'
     "${TARGET}" "$@" | tee -a "${GITHUB_OUTPUT}"
     echo 'EOF'
   } >>"${GITHUB_OUTPUT}"
 else
   "${TARGET}" "$@"
 fi
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 9132c85 and 775954b.

📒 Files selected for processing (1)
  • entrypoint.sh (1 hunks)

entrypoint.sh Outdated
Comment on lines 42 to 47
if [[ ! -f "${TARGET}" ]]; then
curl -fsSL --retry 5 --keepalive-time 2 ${INSECURE_OPTION} "${DOWNLOAD_URL_PREFIX}/${CLIENT_BINARY}" -o "${TARGET}"
chmod +x "${TARGET}"
else
echo "Binary ${CLIENT_BINARY} already exists, skipping download."
fi
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Ensure executable bit when using cache; fix misleading "Downloading" log.

  • If the file exists but isn’t executable, the script will fail later. Check/repair the exec bit when reusing the cached binary.
  • The unconditional “Downloading …” log (Line 36) is printed even when skipping, which is confusing. Move it into the download branch and add a clear cache message.
-echo "Downloading ${CLIENT_BINARY} from ${DOWNLOAD_URL_PREFIX}"
+echo "Binary path: ${TARGET}"

-if [[ ! -f "${TARGET}" ]]; then
-  curl -fsSL --retry 5 --keepalive-time 2 ${INSECURE_OPTION} "${DOWNLOAD_URL_PREFIX}/${CLIENT_BINARY}" -o "${TARGET}"
-  chmod +x "${TARGET}"
-else
-  echo "Binary ${CLIENT_BINARY} already exists, skipping download."
-fi
+if [[ ! -f "${TARGET}" ]]; then
+  echo "Downloading ${CLIENT_BINARY} from ${DOWNLOAD_URL_PREFIX}"
+  curl -fsSL --retry 5 --keepalive-time 2 ${INSECURE_OPTION} \
+    "${DOWNLOAD_URL_PREFIX}/${CLIENT_BINARY}" -o "${TARGET}"
+  chmod +x "${TARGET}"
+elif [[ ! -x "${TARGET}" ]]; then
+  chmod +x "${TARGET}"
+  echo "Binary ${CLIENT_BINARY} found in cache; set executable bit."
+else
+  echo "Using cached binary ${CLIENT_BINARY}."
+fi

Also applies to: 36-36

🤖 Prompt for AI Agents
In entrypoint.sh around lines 36 and 42-47, the script currently prints a
"Downloading ..." message unconditionally and only sets the executable bit when
it actually downloads the file; fix by moving the "Downloading ..." log inside
the download branch so it only appears when curl runs, and when the file already
exists check and set the exec bit (chmod +x) before continuing and print a clear
cache message (e.g., "Using cached binary ... and ensured executable bit").
Ensure the existing branch does not skip the chmod step and updates logs
accordingly.

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@appleboy appleboy merged commit eb443bd into master Aug 31, 2025
11 checks passed
@appleboy appleboy deleted the cache branch August 31, 2025 02:35
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.

cache drone-scp

1 participant