Skip to content

fix(usage-metrics): order of actions matters#3623

Merged
mdelapenya merged 1 commit intotestcontainers:mainfrom
mdelapenya:fix-usage-metrics
Apr 1, 2026
Merged

fix(usage-metrics): order of actions matters#3623
mdelapenya merged 1 commit intotestcontainers:mainfrom
mdelapenya:fix-usage-metrics

Conversation

@mdelapenya
Copy link
Copy Markdown
Member

@mdelapenya mdelapenya commented Apr 1, 2026

What does this PR do?

Restructure the "Create or update Pull Request" step in the usage-metrics workflow to avoid a git checkout failure when the PR branch already exists on the remote.

Previously, the workflow staged the CSV changes on main with git add before attempting to switch to the existing PR branch, causing git to abort with "Your local changes would be overwritten by checkout". Now the workflow:

  1. Checks for changes with git diff --quiet (unstaged) instead of staging first
  2. Saves the CSV to /tmp before any branch operations
  3. Resets the working tree with git checkout -- docs/usage-metrics.csv so the branch switch succeeds
  4. Restores and stages the CSV after landing on the target branch

Why is it important?

When the workflow is re-triggered within the same month (e.g. to fill in versions that failed due to rate limiting), the PR branch already exists. The previous ordering caused the workflow to fail outright — no commit, no push, no updated PR — defeating the purpose of re-running it.

Related issues

@mdelapenya mdelapenya requested a review from a team as a code owner April 1, 2026 13:21
@netlify
Copy link
Copy Markdown

netlify Bot commented Apr 1, 2026

Deploy Preview for testcontainers-go ready!

Name Link
🔨 Latest commit 3534e08
🔍 Latest deploy log https://app.netlify.com/projects/testcontainers-go/deploys/69cd1be0cd8e6600086616ec
😎 Deploy Preview https://deploy-preview-3623--testcontainers-go.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 1, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 04eafef8-1b56-4017-abf4-695a02a324d8

📥 Commits

Reviewing files that changed from the base of the PR and between a34a6c9 and 3534e08.

📒 Files selected for processing (1)
  • .github/workflows/usage-metrics.yml

Summary by CodeRabbit

  • Chores
    • Updated CI/CD workflow for metrics data handling and version control operations.

Walkthrough

The workflow refactors the usage metrics generation logic to preserve the generated CSV in a temporary file, defer the staged-diff check until after branch selection, and conditionally reset the working tree when checking out an existing branch.

Changes

Cohort / File(s) Summary
GitHub Actions Workflow
.github/workflows/usage-metrics.yml
Restructured branch handling and file staging logic: removed unconditional staging, introduced unstaged comparison via git diff --quiet, added temporary CSV preservation in /tmp/usage-metrics.csv, inserted git checkout -- docs/usage-metrics.csv reset when existing branch found, and consolidated diff/staging/exit checks after branch selection.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested labels

github_actions

Poem

🐰 A workflow once tangled, now flows with grace,
Branch-switching and staging find their rightful place,
Temp files preserved in the rabbit's care,
Diffs checked at last—no premature despair!

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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 and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore Changes that do not impact the existing functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant