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

ci: fix EACCES on renovatebot/github-action #978

Closed
wants to merge 2 commits into from

Conversation

korosuke613
Copy link
Owner

@korosuke613 korosuke613 commented Nov 18, 2024

ref: renovatebot/github-action#646 (comment)

DEBUG: Using platform gitAuthor: kiba-renovate[bot] <154907007+kiba-renovate[bot]@users.noreply.github.com>
DEBUG: Adding token authentication for api.github.com (hostType=github) to hostRules
DEBUG: Using baseDir: /tmp/renovate
DEBUG: Using cacheDir: /tmp/renovate/cache
DEBUG: Using containerbaseDir: /tmp/renovate/cache/containerbase
FATAL: Fatal error: EACCES: permission denied, mkdir '/tmp/renovate/cache/containerbase'
       "err": {
         "errno": -13,
         "code": "EACCES",
         "syscall": "mkdir",
         "path": "/tmp/renovate/cache/containerbase",
         "message": "EACCES: permission denied, mkdir '/tmp/renovate/cache/containerbase'",
         "stack": "Error: EACCES: permission denied, mkdir '/tmp/renovate/cache/containerbase'"
       }
 INFO: Renovate is exiting with a non-zero code due to the following logged errors
       "loggerErrors": [
         {
           "name": "renovate",
           "level": 60,
           "logContext": "f9smkP2QF64Uoz2kYhyHI",
           "err": {
             "errno": -13,
             "code": "EACCES",
             "syscall": "mkdir",
             "path": "/tmp/renovate/cache/containerbase",
             "message": "EACCES: permission denied, mkdir '/tmp/renovate/cache/containerbase'",
             "stack": "Error: EACCES: permission denied, mkdir '/tmp/renovate/cache/containerbase'"
           },
           "msg": "Fatal error: EACCES: permission denied, mkdir '/tmp/renovate/cache/containerbase'"
         }
       ]
Error: The process '/usr/bin/docker' failed with exit code 1
    at ExecState._setResult (/home/runner/work/_actions/renovatebot/github-action/180db1547505e30c02d41959fe65ada1523ee207/dist/index.js:1702:25)
    at ExecState.CheckComplete (/home/runner/work/_actions/renovatebot/github-action/180db1547505e30c02d41959fe65ada1523ee207/dist/index.js:1685:18)
    at ChildProcess.<anonymous> (/home/runner/work/_actions/renovatebot/github-action/180db1547505e30c02d41959fe65ada1523ee207/dist/index.js:1579:27)
    at ChildProcess.emit (node:events:519:28)
    at maybeClose (node:internal/child_process:1105:16)
    at ChildProcess._handle.onexit (node:internal/child_process:305:5)

Summary by CodeRabbit

  • New Features

    • Introduced a repoCache input option for enhanced cache management during workflow execution.
    • Added a step to determine and output the current user and group IDs for better user permissions handling.
    • Implemented new parameters for the renovatebot/github-action to improve Docker integration and volume mapping.
  • Improvements

    • Refined caching mechanism to optimize performance and prevent cache bloat.

ref: renovatebot/github-action#646 (comment)

```log
DEBUG: Using platform gitAuthor: kiba-renovate[bot] <154907007+kiba-renovate[bot]@users.noreply.github.com>
DEBUG: Adding token authentication for api.github.com (hostType=github) to hostRules
DEBUG: Using baseDir: /tmp/renovate
DEBUG: Using cacheDir: /tmp/renovate/cache
DEBUG: Using containerbaseDir: /tmp/renovate/cache/containerbase
FATAL: Fatal error: EACCES: permission denied, mkdir '/tmp/renovate/cache/containerbase'
       "err": {
         "errno": -13,
         "code": "EACCES",
         "syscall": "mkdir",
         "path": "/tmp/renovate/cache/containerbase",
         "message": "EACCES: permission denied, mkdir '/tmp/renovate/cache/containerbase'",
         "stack": "Error: EACCES: permission denied, mkdir '/tmp/renovate/cache/containerbase'"
       }
 INFO: Renovate is exiting with a non-zero code due to the following logged errors
       "loggerErrors": [
         {
           "name": "renovate",
           "level": 60,
           "logContext": "f9smkP2QF64Uoz2kYhyHI",
           "err": {
             "errno": -13,
             "code": "EACCES",
             "syscall": "mkdir",
             "path": "/tmp/renovate/cache/containerbase",
             "message": "EACCES: permission denied, mkdir '/tmp/renovate/cache/containerbase'",
             "stack": "Error: EACCES: permission denied, mkdir '/tmp/renovate/cache/containerbase'"
           },
           "msg": "Fatal error: EACCES: permission denied, mkdir '/tmp/renovate/cache/containerbase'"
         }
       ]
Error: The process '/usr/bin/docker' failed with exit code 1
    at ExecState._setResult (/home/runner/work/_actions/renovatebot/github-action/180db1547505e30c02d41959fe65ada1523ee207/dist/index.js:1702:25)
    at ExecState.CheckComplete (/home/runner/work/_actions/renovatebot/github-action/180db1547505e30c02d41959fe65ada1523ee207/dist/index.js:1685:18)
    at ChildProcess.<anonymous> (/home/runner/work/_actions/renovatebot/github-action/180db1547505e30c02d41959fe65ada1523ee207/dist/index.js:1579:27)
    at ChildProcess.emit (node:events:519:28)
    at maybeClose (node:internal/child_process:1105:16)
    at ChildProcess._handle.onexit (node:internal/child_process:305:5)
```
Copy link

coderabbitai bot commented Nov 18, 2024

Walkthrough

The pull request modifies the GitHub Actions workflow in .github/workflows/renovate.yaml. It introduces a new input option repoCache for the workflow_dispatch event, allowing cache management. Additionally, a new step determines the current user and group IDs, which are used in the renovatebot/github-action step. The caching mechanism is refined to limit cache usage to the first execution of the day. The structure of the workflow remains intact while enhancing control over caching and user permissions.

Changes

File Change Summary
.github/workflows/renovate.yaml - Added new input repoCache for cache management.
- Introduced a step to determine current user and group IDs.
- Added docker-user parameter in renovatebot/github-action step.
- Added docker-volumes parameter in renovatebot/github-action step.
- Refined caching mechanism to use cache only during the first execution of the day.

Possibly related PRs

Poem

In the garden where the workflows play,
A rabbit hops, brightening the day.
With repoCache to manage with care,
And user IDs floating in the air.
Caches refined, no bloat in sight,
Hooray for changes, everything feels right! 🐇✨


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

codecov bot commented Nov 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 66.92%. Comparing base (1f9b7d0) to head (c4f5593).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #978   +/-   ##
=======================================
  Coverage   66.92%   66.92%           
=======================================
  Files          21       21           
  Lines        1179     1179           
  Branches      109      109           
=======================================
  Hits          789      789           
  Misses        385      385           
  Partials        5        5           
Flag Coverage Δ
unittests 66.92% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@github-actions github-actions bot added the no changes ✅ No changes of archive label Nov 18, 2024
Copy link
Contributor

github-actions bot commented Nov 18, 2024

✅ No changes to the artifacts

building commit: 93ac29bcf50b77df05404c3e831fd4e479d453d8

SHA256
Recent deployed e504993fcce236f72c4c6605f72b19d8ae200b515758e4e5257db1eb5316606f
This build e504993fcce236f72c4c6605f72b19d8ae200b515758e4e5257db1eb5316606f

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

🧹 Outside diff range and nitpick comments (1)
.github/workflows/renovate.yaml (1)

Line range hint 39-46: Consider translating comments to English

The caching strategy is well-implemented, but consider translating the Japanese comments to English for better maintainability across international contributors.

-      - name: Renovate CLI のキャッシュディレクトリを定義
+      - name: Define Renovate CLI cache directory
       id: renovate-cache
       run: |
         echo "date=$(date --iso-8601)" >> $GITHUB_OUTPUT

-      - name: Renovate CLI の結果をキャッシュ
+      - name: Cache Renovate CLI results
       uses: actions/cache@v4
       with:
         path: ${{ env.BASE_DIR }}
-        # Cache の肥大化を防ぐため、その日初めての実行のみキャッシュする&前日以前のキャッシュは利用しない
+        # Only cache the first execution of the day & ignore previous days' caches to prevent cache bloat
🧰 Tools
🪛 actionlint

68-68: shellcheck reported issue in this script: SC2086:info:1:25: Double quote to prevent globbing and word splitting

(shellcheck)


68-68: shellcheck reported issue in this script: SC2086:info:2:26: Double quote to prevent globbing and word splitting

(shellcheck)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 63f247f and c4f5593.

📒 Files selected for processing (1)
  • .github/workflows/renovate.yaml (1 hunks)
🧰 Additional context used
🪛 actionlint
.github/workflows/renovate.yaml

68-68: shellcheck reported issue in this script: SC2086:info:1:25: Double quote to prevent globbing and word splitting

(shellcheck)


68-68: shellcheck reported issue in this script: SC2086:info:2:26: Double quote to prevent globbing and word splitting

(shellcheck)

🔇 Additional comments (3)
.github/workflows/renovate.yaml (3)

Line range hint 8-14: LGTM! Well-structured cache control input

The new repoCache input parameter provides good flexibility for cache management with clear options.

🧰 Tools
🪛 actionlint

68-68: shellcheck reported issue in this script: SC2086:info:1:25: Double quote to prevent globbing and word splitting

(shellcheck)


68-68: shellcheck reported issue in this script: SC2086:info:2:26: Double quote to prevent globbing and word splitting

(shellcheck)


Line range hint 48-53: LGTM! Effective permission fix

The directory creation and permission setting effectively address the EACCES issue by ensuring proper ownership.

🧰 Tools
🪛 actionlint

68-68: shellcheck reported issue in this script: SC2086:info:1:25: Double quote to prevent globbing and word splitting

(shellcheck)


68-68: shellcheck reported issue in this script: SC2086:info:2:26: Double quote to prevent globbing and word splitting

(shellcheck)


73-77: LGTM! Complete solution for permission issues

The configuration effectively addresses the permission issues by:

  1. Using the correct user/group IDs via docker-user
  2. Properly mounting the cache directory via docker-volumes

Comment on lines +66 to +71
- name: Determine current user
id: id
run: |
echo "user=$(id -u)" >> $GITHUB_OUTPUT
echo "group=$(id -g)" >> $GITHUB_OUTPUT

Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add quotes to prevent word splitting in shell script

The shell script should use quotes around command substitutions to prevent potential word splitting issues.

       id: id
       run: |
-          echo "user=$(id -u)" >> $GITHUB_OUTPUT
-          echo "group=$(id -g)" >> $GITHUB_OUTPUT
+          echo "user=$(id -u)" >> "$GITHUB_OUTPUT"
+          echo "group=$(id -g)" >> "$GITHUB_OUTPUT"
📝 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
- name: Determine current user
id: id
run: |
echo "user=$(id -u)" >> $GITHUB_OUTPUT
echo "group=$(id -g)" >> $GITHUB_OUTPUT
- name: Determine current user
id: id
run: |
echo "user=$(id -u)" >> "$GITHUB_OUTPUT"
echo "group=$(id -g)" >> "$GITHUB_OUTPUT"
🧰 Tools
🪛 actionlint

68-68: shellcheck reported issue in this script: SC2086:info:1:25: Double quote to prevent globbing and word splitting

(shellcheck)


68-68: shellcheck reported issue in this script: SC2086:info:2:26: Double quote to prevent globbing and word splitting

(shellcheck)

Comment on lines +76 to +77
docker-user: "${{ steps.id.outputs.user }}:${{ steps.id.outputs.group }}"
docker-volumes: /tmp/renovate:/tmp/renovate
Copy link

Choose a reason for hiding this comment

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

💡 Codebase verification

Permission issues still persist in the cache directory

The current solution is not fully resolving the EACCES permission issues. The logs show that while we're setting permissions for /tmp/renovate, the containerbase cache directory (/tmp/renovate/cache/containerbase) is still experiencing permission denied errors. The workflow needs to ensure permissions are set for all subdirectories that Renovate might create.

Key points to fix:

  • Update the Change permissions step to recursively create and set permissions for all required cache subdirectories:
    - name: Change permissions
      run: |
        mkdir -p $BASE_DIR/cache/containerbase
        mkdir -p $CACHE_DIR
        sudo chown -R runneradmin:root /tmp/renovate/
        ls -R $BASE_DIR
🔗 Analysis chain

Verify the permission fix in action

The solution looks correct, but let's verify it resolves the EACCES issue completely.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the workflow runs successfully without permission errors

# Check recent workflow runs for this file
gh run list --workflow=renovate.yaml --limit 5 --json conclusion,databaseId,createdAt \
  | jq '.[] | select(.conclusion=="success" or .conclusion=="failure") | {conclusion, databaseId, createdAt}'

# Check logs for EACCES errors in recent runs
for run in $(gh run list --workflow=renovate.yaml --limit 5 --json databaseId --jq '.[].databaseId'); do
  echo "Checking run $run for EACCES errors..."
  gh run view $run --log | grep -i "EACCES"
done

Length of output: 9565


Script:

#!/bin/bash
# Let's check the workflow file to understand the full context of permissions setup
cat .github/workflows/renovate.yaml

# Also check if there are any other related configuration files
fd -t f -e json renovate
fd -t f -e json5 renovate

Length of output: 2389

@korosuke613
Copy link
Owner Author

actions/cache 使うなって書いてたわ。

      # This third party action allows you to download the cache artifact from different workflow runs
      # Note that actions/cache doesn't work well because the cache key would need to be computed from
      # a file within the cache, meaning there would never be any data to restore. With other keys, the
      # cache wouldn't necessarily upload when it changes. actions/download-artifact also doesn't work
      # because it only handles artifacts uploaded in the same run, and we want to restore from the
      # previous successful run.

https://github.com/renovatebot/github-action/blob/2bf094e443096eb94135ae977f878172e47c76cd/README.md#L478-L483

@korosuke613 korosuke613 deleted the fix-renovate-permission-error branch November 18, 2024 07:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no changes ✅ No changes of archive
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant