Skip to content

fix: use temp directory for result file#226

Merged
shenxianpeng merged 1 commit into
mainfrom
bugfix/use-temp-dir-for-result-file
Jun 29, 2026
Merged

fix: use temp directory for result file#226
shenxianpeng merged 1 commit into
mainfrom
bugfix/use-temp-dir-for-result-file

Conversation

@shenxianpeng

Copy link
Copy Markdown
Member

Summary

Replace the hardcoded "result.txt" (written to GITHUB_WORKSPACE) with a path under RUNNER_TEMP, the GitHub Actions temp directory that is auto-cleaned after each job.

Changes

  • main.py: Added get_result_path() — uses RUNNER_TEMP env var (commit-check-result.txt under it) or falls back to tempfile.gettempdir()
  • main.py: run_commit_check() and read_result_file() now call get_result_path() instead of hardcoding "result.txt"
  • main_test.py: Updated setUp/tearDown in 5 test classes to set/unset RUNNER_TEMP so tests write to the expected location
  • main_test.py: Fixed pre-existing assertion (test_pr_title_check_runs_when_enabled expected ["--message"] but actual is ["--message", "--no-banner"])

Why

Writing to the current working directory in a GitHub Action can overwrite files in the user's repository. RUNNER_TEMP is the safe, documented location for temporary files.

Closes #N/A

…rectory

Replace hardcoded 'result.txt' with get_result_path() that uses
RUNNER_TEMP (GitHub Actions) or tempfile.gettempdir() (local) to
avoid conflicting with user project files.

- Add get_result_path() helper function
- Update run_commit_check() and read_result_file() to use it
- Update tests to set RUNNER_TEMP in setUp
@shenxianpeng shenxianpeng requested a review from a team as a code owner June 29, 2026 22:31
@coderabbitai

coderabbitai Bot commented Jun 29, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@shenxianpeng, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 41 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 96318b1e-f1ae-4f53-b264-765355b1b0f9

📥 Commits

Reviewing files that changed from the base of the PR and between 00c51d4 and 15662bc.

📒 Files selected for processing (2)
  • main.py
  • main_test.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch bugfix/use-temp-dir-for-result-file

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

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

@github-actions

Copy link
Copy Markdown
Contributor

Commit-Check ✔️

@shenxianpeng shenxianpeng added the bug Something isn't working label Jun 29, 2026
@shenxianpeng shenxianpeng merged commit d6ad122 into main Jun 29, 2026
11 checks passed
@shenxianpeng shenxianpeng deleted the bugfix/use-temp-dir-for-result-file branch June 29, 2026 22:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant