Skip to content

CI/changelog bot#697

Open
pushpitkamboj wants to merge 4 commits intoopenwisp:masterfrom
pushpitkamboj:ci/changelog_bot
Open

CI/changelog bot#697
pushpitkamboj wants to merge 4 commits intoopenwisp:masterfrom
pushpitkamboj:ci/changelog_bot

Conversation

@pushpitkamboj
Copy link
Copy Markdown

Checklist

  • I have read the OpenWISP Contributing Guidelines.
  • I have manually tested the changes proposed in this pull request.
  • I have written new test cases for new code and/or updated existing tests for changes to existing code.
  • I have updated the documentation.

Reference to Existing Issue

Closes #696

Description of Changes

  • Add workflow template to run the bot changelog runner.
  • Ensures the changelog bot executes on approved noteworthy PRs.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 27, 2026

📝 Walkthrough

Walkthrough

Two new GitHub Actions workflows were added to implement an automated changelog bot. bot-changelog-trigger.yml fires on submitted pull request reviews, verifies approval and reviewer association, matches PR titles against a (feature|fix|change) prefix, and uploads the PR number as an artifact when matched. bot-changelog-runner.yml triggers on completion of the trigger workflow, downloads the changelog-metadata artifact, validates the PR number, and calls a reusable external workflow (openwisp/openwisp-utils/.../reusable-bot-changelog.yml@master) forwarding required secrets.

Sequence Diagram(s)

sequenceDiagram
    actor Reviewer
    participant GitHub as GitHub Events
    participant TriggerWF as Changelog Bot Trigger
    participant Artifact as Artifact Storage
    participant RunnerWF as Changelog Bot Runner
    participant ReusableWF as Reusable Changelog Workflow

    Reviewer->>GitHub: Submit review (submitted)
    GitHub->>TriggerWF: Trigger on pull_request_review
    TriggerWF->>TriggerWF: Validate approved & reviewer role
    TriggerWF->>TriggerWF: Match PR title (feature|fix|change)
    alt Title matches
        TriggerWF->>Artifact: Upload changelog-metadata (pr_number)
        Artifact-->>TriggerWF: Artifact uploaded
    end
    TriggerWF-->>GitHub: Workflow completed
    GitHub->>RunnerWF: Trigger on workflow_run completed
    RunnerWF->>Artifact: Download changelog-metadata
    Artifact-->>RunnerWF: pr_number retrieved
    RunnerWF->>RunnerWF: Validate pr_number
    RunnerWF->>ReusableWF: Call reusable workflow with pr_number + secrets
    ReusableWF-->>RunnerWF: Changelog generation finished
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

Suggested reviewers

  • nemesifier
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Title check ⚠️ Warning Title does not follow the required format of [type] with a descriptive message; it is missing the type prefix and uses a non-standard format. Update the title to follow the required format, e.g., '[ci] Add changelog bot workflow' to match the repository standards.
✅ Passed checks (4 passed)
Check name Status Explanation
Description check ✅ Passed Description is mostly complete with reference to issue #696 and a clear explanation of changes, though some checklist items remain unchecked.
Linked Issues check ✅ Passed The pull request adds the changelog bot workflow files matching issue #696 requirements: a trigger workflow for approved reviews and a runner workflow for execution.
Out of Scope Changes check ✅ Passed All changes are within scope; the two workflow files directly implement the changelog bot workflow requirements from issue #696.
Bug Fixes ✅ Passed This PR adds new GitHub Actions workflows for changelog automation rather than fixing a bug, so the bug-fix check does not apply.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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.

@pushpitkamboj pushpitkamboj changed the title Ci/changelog bot CI/changelog bot Mar 27, 2026
Copy link
Copy Markdown

@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: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/bot-changelog-trigger.yml:
- Around line 34-39: The Upload PR metadata step uses actions/upload-artifact@v4
to store changelog-metadata but relies on the default 90-day retention; add the
retention-days input to the step (e.g., retention-days: 1 or 3) so the artifact
named "changelog-metadata" uploaded from path "pr_number" is retained only
briefly for the downstream runner workflow to consume.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 3b72ae83-ce0f-4ceb-81c3-2da8d7f59f84

📥 Commits

Reviewing files that changed from the base of the PR and between b512f3a and 0d29a3c.

📒 Files selected for processing (2)
  • .github/workflows/bot-changelog-runner.yml
  • .github/workflows/bot-changelog-trigger.yml
📜 Review details
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: stktyagi
Repo: openwisp/openwisp-radius PR: 689
File: .github/workflows/bot-ci-failure.yml:60-60
Timestamp: 2026-03-06T08:48:01.200Z
Learning: In the openwisp/openwisp-radius repository (and other openwisp repositories), reusable workflow caller files (e.g., `.github/workflows/bot-ci-failure.yml`) intentionally reference upstream reusable workflows with `master` (e.g., `openwisp/openwisp-utils/.github/workflows/reusable-bot-ci-failure.ymlmaster`). This is by design so callers always use the latest changes from the master branch of openwisp-utils. Do not flag this as a security or pinning issue in code reviews.
📚 Learning: 2026-03-06T08:47:54.428Z
Learnt from: stktyagi
Repo: openwisp/openwisp-radius PR: 689
File: .github/workflows/bot-ci-failure.yml:60-60
Timestamp: 2026-03-06T08:47:54.428Z
Learning: In openwisp/openwisp-radius and similar OpenWISP repos, reusable workflow caller files intentionally reference upstream reusable workflows with master (e.g., openwisp/openwisp-utils/.github/workflows/reusable-bot-ci-failure.ymlmaster). This is by design to ensure callers always use the latest changes from the master branch of the upstream project. Do not flag such references as security or pinning issues during code reviews. If applying this pattern broadly, treat any workflow call that uses a remote reusable workflow from a different repository with master as an intentional design choice rather than a vulnerability.

Applied to files:

  • .github/workflows/bot-changelog-trigger.yml
  • .github/workflows/bot-changelog-runner.yml
🔇 Additional comments (5)
.github/workflows/bot-changelog-trigger.yml (2)

1-17: LGTM!

The workflow trigger and job conditional are well-structured. The check for approved reviews from authorized contributors (OWNER, MEMBER, COLLABORATOR) is appropriate for gating changelog generation.


18-26: LGTM!

The regex pattern ^\[(feature|fix|change)\] with case-insensitive matching correctly identifies noteworthy PRs. Using an environment variable for PR_TITLE avoids shell injection concerns.

.github/workflows/bot-changelog-runner.yml (3)

1-17: LGTM!

The workflow_run trigger correctly chains to the trigger workflow, and the permissions are appropriately scoped for the changelog operations.


18-43: LGTM!

Good defensive programming:

  • continue-on-error: true on artifact download gracefully handles cases where no artifact exists (non-noteworthy PRs).
  • Numeric validation of pr_number prevents injection of malicious input into downstream workflows.

51-54: Verify parameter names match the reusable workflow expectations.

The workflow passes secrets with parameter names OPENWISP_BOT_APP_ID and OPENWISP_BOT_PRIVATE_KEY, which differ from the naming conventions in other workflows that call different reusable workflows:

  • bot-ci-failure.yml calls reusable-bot-ci-failure.yml and uses: APP_ID, PRIVATE_KEY
  • backport.yml calls reusable-backport.yml and uses: app_id, private_key
  • bot-changelog-runner.yml calls reusable-bot-changelog.yml and uses: OPENWISP_BOT_APP_ID, OPENWISP_BOT_PRIVATE_KEY

Since different reusable workflows may have different parameter expectations, confirm that reusable-bot-changelog.yml in openwisp-utils expects parameters named OPENWISP_BOT_APP_ID and OPENWISP_BOT_PRIVATE_KEY rather than APP_ID and PRIVATE_KEY or their lowercase variants.

Comment on lines +34 to +39
- name: Upload PR metadata
if: steps.check.outputs.has_noteworthy == 'true'
uses: actions/upload-artifact@v4
with:
name: changelog-metadata
path: pr_number
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial

Consider reducing artifact retention.

The artifact is only needed briefly until the runner workflow consumes it. The default 90-day retention is excessive for this temporary handoff.

♻️ Suggested improvement
       - name: Upload PR metadata
         if: steps.check.outputs.has_noteworthy == 'true'
         uses: actions/upload-artifact@v4
         with:
           name: changelog-metadata
           path: pr_number
+          retention-days: 1
📝 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: Upload PR metadata
if: steps.check.outputs.has_noteworthy == 'true'
uses: actions/upload-artifact@v4
with:
name: changelog-metadata
path: pr_number
- name: Upload PR metadata
if: steps.check.outputs.has_noteworthy == 'true'
uses: actions/upload-artifact@v4
with:
name: changelog-metadata
path: pr_number
retention-days: 1
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/bot-changelog-trigger.yml around lines 34 - 39, The Upload
PR metadata step uses actions/upload-artifact@v4 to store changelog-metadata but
relies on the default 90-day retention; add the retention-days input to the step
(e.g., retention-days: 1 or 3) so the artifact named "changelog-metadata"
uploaded from path "pr_number" is retained only briefly for the downstream
runner workflow to consume.

@openwisp-companion
Copy link
Copy Markdown

QA and Commit Message Failures

```

Hello @pushpitkamboj,
(Analysis for commit 0d29a3c)

  • Code Style/QA: The CI failed due to Prettier issues in .github/workflows/bot-changelog-runner.yml and .github/workflows/bot-changelog-trigger.yml. Please run openwisp-qa-format to fix these.

  • Commit Message: The commit message is invalid. Please ensure your commit messages follow the OpenWISP convention:

[tag] Capitalized short title #<issue>

<description>

Fixes #<issue>

For example:

[feature] Add user profile page #123

This commit introduces the user profile page, allowing users to view and edit
their personal information.

Fixes #123

@kilo-code-bot
Copy link
Copy Markdown

kilo-code-bot bot commented Apr 12, 2026

Code Review Summary

Status: No Issues Found | Recommendation: Merge

The workflow files are correctly configured and follow GitHub Actions best practices. Minor trailing whitespace fix applied.

Files Reviewed (2 files)
  • .github/workflows/bot-changelog-trigger.yml - Triggers on PR approval, validates author association, checks for noteworthy PR titles (feature/fix/change), uploads metadata artifact
  • .github/workflows/bot-changelog-runner.yml - Runs on trigger completion, downloads and validates metadata, calls reusable changelog workflow

Reviewed by kimi-k2.5-0127 · 81,866 tokens

@openwisp-companion
Copy link
Copy Markdown

Prettier Formatting Failed

Hello @pushpitkamboj,
(Analysis for commit c6ae97a)

  • Code Style/QA: The CI failed because of Prettier formatting issues in .github/workflows/bot-changelog-trigger.yml.
  • Fix: Run openwisp-qa-format to automatically fix the formatting.

Copy link
Copy Markdown

@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: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/bot-changelog-runner.yml:
- Around line 25-33: The workflow step named "Download PR metadata" (id:
download) currently sets continue-on-error: true which silently swallows
failures; remove continue-on-error and instead add a pre-check that queries the
GitHub Actions Artifacts API (or the Workflow Run's artifacts via REST) to
confirm the artifact named "changelog-metadata" exists for
github.event.workflow_run.id before running actions/download-artifact@v4, and if
not present fail or set an output/step-status that downstream steps can
evaluate; update downstream conditionals to rely on that explicit existence
check rather than inspecting logs.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: ae771419-bda3-490b-80cf-45e29c0a36fc

📥 Commits

Reviewing files that changed from the base of the PR and between 0d29a3c and b86efd0.

📒 Files selected for processing (2)
  • .github/workflows/bot-changelog-runner.yml
  • .github/workflows/bot-changelog-trigger.yml
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (12)
  • GitHub Check: Python==3.12 | django~=4.2.0
  • GitHub Check: Python==3.12 | django~=5.2.0
  • GitHub Check: Python==3.13 | django~=5.1.0
  • GitHub Check: Python==3.12 | django~=5.1.0
  • GitHub Check: Python==3.13 | django~=5.2.0
  • GitHub Check: Python==3.11 | django~=5.2.0
  • GitHub Check: Python==3.10 | django~=4.2.0
  • GitHub Check: Python==3.11 | django~=4.2.0
  • GitHub Check: Python==3.10 | django~=5.1.0
  • GitHub Check: Python==3.11 | django~=5.1.0
  • GitHub Check: Python==3.10 | django~=5.2.0
  • GitHub Check: Kilo Code Review
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: stktyagi
Repo: openwisp/openwisp-radius PR: 689
File: .github/workflows/bot-ci-failure.yml:60-60
Timestamp: 2026-03-06T08:48:01.200Z
Learning: In the openwisp/openwisp-radius repository (and other openwisp repositories), reusable workflow caller files (e.g., `.github/workflows/bot-ci-failure.yml`) intentionally reference upstream reusable workflows with `master` (e.g., `openwisp/openwisp-utils/.github/workflows/reusable-bot-ci-failure.ymlmaster`). This is by design so callers always use the latest changes from the master branch of openwisp-utils. Do not flag this as a security or pinning issue in code reviews.
📚 Learning: 2026-03-06T08:47:54.428Z
Learnt from: stktyagi
Repo: openwisp/openwisp-radius PR: 689
File: .github/workflows/bot-ci-failure.yml:60-60
Timestamp: 2026-03-06T08:47:54.428Z
Learning: In openwisp/openwisp-radius and similar OpenWISP repos, reusable workflow caller files intentionally reference upstream reusable workflows with master (e.g., openwisp/openwisp-utils/.github/workflows/reusable-bot-ci-failure.ymlmaster). This is by design to ensure callers always use the latest changes from the master branch of the upstream project. Do not flag such references as security or pinning issues during code reviews. If applying this pattern broadly, treat any workflow call that uses a remote reusable workflow from a different repository with master as an intentional design choice rather than a vulnerability.

Applied to files:

  • .github/workflows/bot-changelog-trigger.yml
  • .github/workflows/bot-changelog-runner.yml
🔇 Additional comments (2)
.github/workflows/bot-changelog-trigger.yml (1)

12-16: Approval gating is correctly restricted to trusted reviewer associations.

This condition is well-scoped for the stated objective (approved PRs by trusted reviewers only).

.github/workflows/bot-changelog-runner.yml (1)

48-48: @master reference for the reusable workflow is aligned with OpenWISP convention.

No pinning concern here given the repository’s documented pattern.

Based on learnings: in OpenWISP repositories, remote reusable workflow calls to openwisp/openwisp-utils/...@master are intentional and should not be flagged.

Comment on lines +25 to +33
- name: Download PR metadata
id: download
uses: actions/download-artifact@v4
with:
name: changelog-metadata
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ github.event.workflow_run.id }}
continue-on-error: true

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🌐 Web query:

For actions/download-artifact@v4, what step outputs/error signals are available to distinguish “artifact not found” from transient/API failures?

💡 Result:

For actions/download-artifact@v4, there are no step outputs to distinguish "artifact not found" from transient/API failures. The only documented output is download-path, which is set to the resolved download path if successful. Both cases result in step failure (non-zero exit code) with distinct error messages in logs: - Artifact not found: "Error: Unable to download artifact(s): No artifacts found for run '' in ''" or "Artifact not found for name: " (sources 2,5,6). - Transient/API failures: "Error: Unable to download artifact(s): Unable to download and extract artifact: Artifact download failed after 5 retries." often with debug logs showing retry attempts (e.g., "Failed to download artifact after X retries due to ...") (sources 3,17,19,20). To distinguish in workflows, use if: always || success on a run: step after download-artifact to parse ${{ steps.download.outputs.download-path }} (unset on failure) or needs: download.result == 'success', but error type requires parsing runner logs via ::error:: or custom scripts, as no structured outputs exist. Official docs confirm only download-path output (sources 9,11,56,57). Source code shows uniform core.setFailed on all errors (source 58).

Citations:


Avoid silently swallowing metadata download failures.

continue-on-error: true suppresses download failures from workflow control flow, preventing subsequent steps from distinguishing "artifact doesn't exist" from transient/API failures. While error messages in logs are distinct, they are not accessible to workflow conditionals, so noteworthy PRs can silently skip changelog updates while the workflow stays green.

To harden: Explicitly check artifact existence before attempting download using the GitHub API, eliminating reliance on error message inspection:

Suggested fix
+      - name: Check PR metadata artifact exists
+        id: artifact
+        env:
+          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+          REPO: ${{ github.repository }}
+          RUN_ID: ${{ github.event.workflow_run.id }}
+        run: |
+          set -euo pipefail
+          EXISTS=$(gh api "repos/$REPO/actions/runs/$RUN_ID/artifacts" \
+            --jq '[.artifacts[] | select(.name=="changelog-metadata" and .expired==false)] | length > 0')
+          echo "exists=$EXISTS" >> "$GITHUB_OUTPUT"
+
       - name: Download PR metadata
+        if: steps.artifact.outputs.exists == 'true'
         id: download
         uses: actions/download-artifact@v4
         with:
           name: changelog-metadata
           github-token: ${{ secrets.GITHUB_TOKEN }}
           run-id: ${{ github.event.workflow_run.id }}
-        continue-on-error: true

       - name: Read PR metadata
-        if: steps.download.outcome == 'success'
+        if: steps.artifact.outputs.exists == 'true' && steps.download.outcome == 'success'
         id: metadata
         run: |
           PR_NUMBER=$(cat pr_number)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/bot-changelog-runner.yml around lines 25 - 33, The
workflow step named "Download PR metadata" (id: download) currently sets
continue-on-error: true which silently swallows failures; remove
continue-on-error and instead add a pre-check that queries the GitHub Actions
Artifacts API (or the Workflow Run's artifacts via REST) to confirm the artifact
named "changelog-metadata" exists for github.event.workflow_run.id before
running actions/download-artifact@v4, and if not present fail or set an
output/step-status that downstream steps can evaluate; update downstream
conditionals to rely on that explicit existence check rather than inspecting
logs.

@coveralls
Copy link
Copy Markdown

Coverage Status

coverage: 97.46%. remained the same — pushpitkamboj:ci/changelog_bot into openwisp:master

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.

[ci] Add changelog bot workflow

2 participants