Skip to content

fix(workflow): prevent PR branch bloat and respect wontfix label#935

Merged
Flobul merged 1 commit into
masterfrom
copilot/optimize-smartthings-api-workflow
May 21, 2026
Merged

fix(workflow): prevent PR branch bloat and respect wontfix label#935
Flobul merged 1 commit into
masterfrom
copilot/optimize-smartthings-api-workflow

Conversation

Copy link
Copy Markdown

Copilot AI commented May 21, 2026

Each workflow run was merging all of master into existing PR branches (git merge master --strategy-option=theirs), causing single-file capability PRs to balloon to hundreds of unrelated files over successive runs. Additionally, files with open wontfix-labelled PRs were continuously re-processed.

Root causes

  • Branch pollution: when updating an existing PR, the old code checked out the stale remote branch then merged master into it — pulling in every file that had changed on master since the branch was created. PR Update json/pumpControlMode.json #411 (for one file) ended up with 705 changed files after 57 runs.
  • No wontfix guard: no label check existed, so every run would re-update branches the user had explicitly marked to never merge.

Changes

  • Save all API-downloaded files to /tmp upfront — decouples file content from git branch state so subsequent checkouts cannot discard it.
  • Fresh branch per capability file — replace the stale-branch-checkout + merge pattern with git checkout -B "$branch_name" master followed by applying only that one file. Force-pushes override any bloated history. Guarantees exactly 1 file changed per PR regardless of prior runs.
    # Before — merges all of master into branch, accumulates unrelated files
    git checkout -B "$branch_name" "origin/$branch_name"
    git merge master --strategy-option=theirs
    
    # After — always a clean single-file branch from master
    git checkout -B "$branch_name" master
    cp "/tmp/changed_caps/$basename_file" "$file"
    git add "$file"
  • wontfix label checkgh pr list --json labels queried before any git work; files whose open PR carries wontfix are skipped entirely.
  • Removed stash/pop — the entire stash-based approach was fragile and unnecessary once files are pre-saved to /tmp.
  • Translations/presentations and README follow the same fresh-branch pattern with --force push.

@sonarqubecloud
Copy link
Copy Markdown

@Flobul Flobul marked this pull request as ready for review May 21, 2026 11:31
Copilot AI review requested due to automatic review settings May 21, 2026 11:31
@Flobul Flobul merged commit 2ba9e69 into master May 21, 2026
7 checks passed
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the scheduled capability-generation workflow to avoid “branch pollution” by always creating clean, single-file PR branches from master, and to skip processing when an existing PR is labeled wontfix.

Changes:

  • Pre-saves all modified API-downloaded files into /tmp before any branch switching.
  • Switches to a “fresh branch from master + copy exactly the intended file” approach (force-push) to guarantee PRs don’t accumulate unrelated changes.
  • Adds a wontfix label guard for existing open PRs on per-capability branches; removes the prior stash/merge-based workflow.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +143 to +144
# Query the GitHub API; tolerate "no PR" (empty list) without hiding auth/network failures
pr_info=$(gh pr list --state open --head "$branch_name" --json number,labels | jq -c '.[0] // empty' 2>/dev/null || true)
cp "/tmp/changed_trans/$(basename "$file")" "$file"
done

git add json/*.i18n.*.json json/*Presentation.json
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.

3 participants