feat: sync linked issue labels to pull requests#1877
feat: sync linked issue labels to pull requests#1877cheese-cakee wants to merge 24 commits intohiero-ledger:mainfrom
Conversation
|
[commit-verification-bot]
View your commit verification status: Commits Tab. To achieve verified status, please read: Remember, you require a GPG key and each commit must be signed with: Thank you for contributing! From the Hiero Python SDK Team |
a30af72 to
1593e8e
Compare
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughAdds a two-stage GitHub Actions system plus a Node.js script that detect issues linked in a PR body, collect those issues' labels, and apply missing labels to the pull request; includes artifact exchange between workflows, dry-run support, bot/fork safeguards, and a small runner egress allowlist update. Changes
Sequence DiagramsequenceDiagram
actor GitHub as GitHub
participant ComputeWF as "Compute Workflow"
participant Script as "sync-issue-labels.js"
participant API as "GitHub API"
participant AddWF as "Add Workflow"
GitHub->>ComputeWF: PR opened/edited/reopened/synchronize or workflow_dispatch
ComputeWF->>ComputeWF: Harden runner, checkout repo
ComputeWF->>Script: Run script with PR number & dry_run
Script->>API: Fetch PR details (if needed)
Script->>Script: Parse PR body for linked issue numbers
Script->>API: Fetch each linked issue (skip PR refs, handle 404)
Script->>Script: Aggregate, normalize, dedupe labels
Script-->>ComputeWF: Return labels, has_labels, pr_number, dry_run
ComputeWF->>ComputeWF: Write `labels.json` and upload artifact `pr-labels-${PR_NUMBER}`
ComputeWF->>GitHub: Dispatch add workflow with artifact run id & inputs
GitHub->>AddWF: Start Add Workflow
AddWF->>AddWF: Harden runner, download artifact, read `labels.json`
AddWF->>API: Apply missing labels to target PR (unless dry-run or fork)
API-->>AddWF: Confirm labels applied
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 📋 Issue PlannerBuilt with CodeRabbit's Coding Plans for faster development and fewer bugs. View plan used: ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
ℹ️ Review info
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (4)
.github/scripts/sync-issue-labels.js.github/workflows/sync-issue-labels-add.yml.github/workflows/sync-issue-labels-compute.ymlCHANGELOG.md
exploreriii
left a comment
There was a problem hiding this comment.
@cheese-cakee I appreciate you having another go at this 🥇
Could you please test this on a fork so we see how it does with real github data
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## main #1877 +/- ##
=======================================
Coverage 93.53% 93.53%
=======================================
Files 141 141
Lines 9146 9146
=======================================
Hits 8555 8555
Misses 591 591 🚀 New features to boost your workflow:
|
|
Hi, this is MergeConflictBot. Please resolve these conflicts locally and push the changes. Quick Fix for CHANGELOG.md ConflictsIf your conflict is only in CHANGELOG.md, you can resolve it easily using the GitHub web editor:
For all other merge conflicts, please read: Thank you for contributing! |
9264396 to
89b455d
Compare
|
Hi @exploreriii. The Script Injection warning from Codacy is about the
The workflow already has security measures in place: This is a known trade off for workflows that need to read from main while responding to PR events. |
There was a problem hiding this comment.
Actionable comments posted: 5
♻️ Duplicate comments (2)
.github/workflows/sync-issue-labels-compute.yml (1)
62-62:⚠️ Potential issue | 🔴 CriticalDo not interpolate labels JSON directly into a shell-quoted
echo.Line 62 is vulnerable to quote-breaking/injection if label text contains
'. Use a quoted heredoc (or write the file ingithub-script) instead.Proposed fix
- name: Upload labels as artifact if: steps.compute.outputs.has_labels == 'true' run: | - echo '${{ steps.compute.outputs.labels }}' > labels.json + cat > labels.json <<'JSON' +${{ steps.compute.outputs.labels }} +JSON shell: bashAs per coding guidelines, “Treat all GitHub event data as potentially untrusted input… Free-form user input must not flow directly into shell commands…”.
.github/workflows/sync-issue-labels-add.yml (1)
16-16:⚠️ Potential issue | 🟠 MajorGuard this job when
workflow_run.pull_requestsis empty.Line 22 and Line 37 assume
pull_requests[0]exists. Because the upstream workflow supportsworkflow_dispatch, this can be empty and cause runtime failure.Proposed fix
jobs: add-labels: - if: ${{ github.event.workflow_run.conclusion == 'success' }} + if: ${{ github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.pull_requests[0] != null }} runs-on: ubuntu-latestFor GitHub Actions `workflow_run` events, can `github.event.workflow_run.pull_requests` be empty when the upstream workflow was triggered via `workflow_dispatch`?Also applies to: 22-23, 37-37
ℹ️ Review info
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (4)
.github/scripts/sync-issue-labels.js.github/workflows/sync-issue-labels-add.yml.github/workflows/sync-issue-labels-compute.ymlCHANGELOG.md
|
Did this one get fully tested on a fork for edge cases etc too? |
Co-authored-by: Roger Barker <roger.barker@swirldslabs.com> Signed-off-by: cheese-cakee <farzanaman99@gmail.com>
Co-authored-by: Roger Barker <roger.barker@swirldslabs.com> Signed-off-by: cheese-cakee <farzanaman99@gmail.com>
Co-authored-by: Roger Barker <roger.barker@swirldslabs.com> Signed-off-by: cheese-cakee <farzanaman99@gmail.com>
Co-authored-by: Roger Barker <roger.barker@swirldslabs.com> Signed-off-by: cheese-cakee <farzanaman99@gmail.com>
Co-authored-by: Roger Barker <roger.barker@swirldslabs.com> Signed-off-by: cheese-cakee <farzanaman99@gmail.com>
Signed-off-by: cheese-cakee <farzanaman99@gmail.com>
Signed-off-by: cheese-cakee <farzanaman99@gmail.com>
Signed-off-by: cheese-cakee <farzanaman99@gmail.com>
Signed-off-by: cheese-cakee <farzanaman99@gmail.com>
Signed-off-by: cheese-cakee <farzanaman99@gmail.com>
Signed-off-by: cheese-cakee <farzanaman99@gmail.com>
Signed-off-by: cheese-cakee <farzanaman99@gmail.com>
Signed-off-by: cheese-cakee <farzanaman99@gmail.com>
Signed-off-by: cheese-cakee <farzanaman99@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: cheese-cakee <farzanaman99@gmail.com>
Signed-off-by: cheese-cakee <farzanaman99@gmail.com>
Signed-off-by: cheese-cakee <farzanaman99@gmail.com>
0db2c7c to
30512d3
Compare
Signed-off-by: cheese-cakee <farzanaman99@gmail.com>
exploreriii
left a comment
There was a problem hiding this comment.
From what i see, you upload the artifact with read permissions on main code. You could limit how much code to read.
You download and use the json with write permissions on issues, without checking out code. We can check the artefact json is as expected, before proceeding, else exiting.
i think you have prevented this workflow from running at all on PRs coming from forks (these are most of the PRs we get), this is fine way to do it if we do not tolerate any PR risk at all @rbarker-dev
|
|
||
| - name: Checkout repository | ||
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | ||
| with: |
There was a problem hiding this comment.
i think you can narrow this to just allow checkout of certain files you need using sparse-checkout
|
Hello, this is the OfficeHourBot. This is a reminder that the Hiero Python SDK Office Hours are scheduled in approximately 4 hours (14:00 UTC). This session provides an opportunity to ask questions regarding this Pull Request. Details:
Disclaimer: This is an automated reminder. Please verify the schedule here for any changes. From, |
Description
Adds an automated GitHub workflow + bot script to sync labels from linked issues to pull requests.
When a PR body includes closing keywords (for example
Fixes #123), the workflow fetches labels from those linked issues and adds missing labels to the PR.Related issue(s)
Fixes #1716
What changed
.github/workflows/sync-issue-labels-compute.ymlpull_request_targetonopened,edited,reopened,synchronize, andready_for_reviewharden-runner, checkoutmain, pinned action SHAs)workflow_dispatchwithpr_number+dry_run.github/workflows/sync-issue-labels-add.ymlworkflow_run(notpull_request_target)actions-ecosystem-add-labelsaction to add labels.github/scripts/sync-issue-labels.jsfixes/closes/resolves)[Unreleased] -> .GithubScope note
This PR intentionally implements label sync only (additive). It does not remove labels from PRs and does not include assignee sync.
Architecture
Two separate workflows to avoid
pull_request_targetlimitations (per exploreriii feedback):sync-issue-labels-compute.yml- reads labels (runs in pull_request_target context)sync-issue-labels-add.yml- writes labels (runs in workflow_run context with write permissions)Testing
node --check .github/scripts/sync-issue-labels.jsChecklist