forked from hiero-ledger/hiero-sdk-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Remove chunks parameter from TopicMessage initialization #66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 9 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
bf195ce
Add CodeRabbit release gate workflow
MonaaEid f1dba68
Add release PR review comment script
MonaaEid b165f63
Create release-pr-prompt.md
MonaaEid 3bc8082
Enhance error handling in release PR coderabbit gate
MonaaEid f9f3341
Update base reference check for release tags
MonaaEid 16d0271
Refactor release PR script for improved clarity
MonaaEid 6a9bd62
Update .coderabbit.yaml
MonaaEid 1c91a34
Remove chunks parameter from TopicMessage initialization
MonaaEid 61447c2
Remove message_data from TopicMessage constructor
MonaaEid 96aa9cb
Update constructor to include message_data parameter
MonaaEid e2aad1f
Refactor TopicMessage to use string for transaction_id
MonaaEid 412baea
Update .coderabbit.yaml configuration
MonaaEid File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| hiero-sdk-python/.github/coderabbit/release-pr-prompt.md |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,133 @@ | ||
| /** | ||
| * Posts a single "@coderabbit review" comment on release PRs, embedding the | ||
| * release review prompt. Designed to run with: | ||
| * - permissions: contents: read, pull-requests: write | ||
| * | ||
| * Safety: | ||
| * - Only runs for maintainer-authored PRs (MEMBER/OWNER) | ||
| * - Dedupe via hidden marker comment | ||
| */ | ||
|
|
||
| const fs = require("fs"); | ||
| const path = require("path"); | ||
|
|
||
| const MARKER = "<!-- coderabbit-release-gate: v1 -->"; | ||
|
|
||
|
|
||
| function loadPrompt() { | ||
| const promptPath = path.join( | ||
| process.env.GITHUB_WORKSPACE || ".", | ||
| ".github/coderabbit/release-pr-prompt.md" | ||
| ); | ||
| try { | ||
| const content = fs.readFileSync(promptPath, "utf8").trim(); | ||
| if (!content) { | ||
| throw new Error("Release prompt file is empty"); | ||
| } | ||
| return content; | ||
| } catch (error) { | ||
| throw new Error(`Failed to load release prompt from ${promptPath}: ${error.message}`); | ||
| } | ||
| } | ||
|
|
||
| async function commentAlreadyExists({ github, owner, repo, issue_number }) { | ||
| try { | ||
| // Pull a bounded number of recent comments to avoid pagination complexity. | ||
| const { data } = await github.rest.issues.listComments({ | ||
| owner, | ||
| repo, | ||
| issue_number, | ||
| per_page: 100, | ||
| }); | ||
| return data.some((c) => typeof c.body === "string" && c.body.includes(MARKER)); | ||
| } | ||
| catch (error) { | ||
| console.error(`Error checking for existing comments: ${error.message}`); | ||
| return false; // Fail open: allow posting if check fails | ||
| } | ||
| } | ||
|
|
||
|
|
||
| function buildBody({ prompt, baseRef, headRef, baseLooksLikeTag }) { | ||
| // Keep it human-friendly but compact; instructions are collapsible. | ||
| const lines = [ | ||
| "@coderabbitai review", | ||
| "", | ||
| MARKER, | ||
| "", | ||
| `This is a **release-gate** review request for diff **${baseRef} → ${headRef}**.`, | ||
| "", | ||
| ]; | ||
| if (!baseLooksLikeTag) { | ||
| lines.push( | ||
| "⚠️ Warning: The base ref does not look like a release tag. For a full release diff, set base to the previous tag (e.g., release-v0.1.10).", | ||
| "" | ||
| ); | ||
| } | ||
|
|
||
| lines.push( | ||
| "<details>", | ||
| "<summary>CodeRabbit release review instructions</summary>", | ||
| "", | ||
| prompt, | ||
| "", | ||
| "</details>", | ||
| ); | ||
| return lines.join("\n"); | ||
|
|
||
| } | ||
|
|
||
| module.exports = async ({ github, context }) => { | ||
| try { | ||
| const owner = context.repo.owner; | ||
| const repo = context.repo.repo; | ||
| const pr = context.payload.pull_request; | ||
|
|
||
| if (!pr) { | ||
| console.log("No pull_request payload; exiting."); | ||
| return; | ||
| } | ||
|
|
||
| // Safety: only maintainers | ||
| const assoc = pr.author_association; | ||
| if (!(assoc === "MEMBER" || assoc === "OWNER")) { | ||
| console.log(`author_association=${assoc}; skipping.`); | ||
| return; | ||
| } | ||
|
|
||
| const title = pr.title || ""; | ||
| if (!title.toLowerCase().startsWith("chore: release v")) { | ||
| console.log("Not a release PR title; skipping."); | ||
| return; | ||
| } | ||
|
|
||
| const baseRef = pr.base?.ref || ""; | ||
| const headRef = pr.head?.ref || ""; | ||
|
|
||
| // Optional sanity check: base should look like a tag. If it doesn't, still comment but warn. | ||
| const baseLooksLikeTag = baseRef.startsWith("release-v") && /\d+\.\d+\.\d+/.test(baseRef); | ||
|
|
||
| const issue_number = pr.number; | ||
| if (await commentAlreadyExists({ github, owner, repo, issue_number })) { | ||
| console.log("Marker comment already exists; not posting again."); | ||
| return; | ||
| } | ||
|
|
||
| const prompt = loadPrompt(); | ||
|
|
||
| const body = buildBody({ prompt, baseRef, headRef, baseLooksLikeTag }); | ||
|
|
||
| await github.rest.issues.createComment({ | ||
| owner, | ||
| repo, | ||
| issue_number, | ||
| body, | ||
| }); | ||
|
|
||
| console.log("Posted CodeRabbit release-gate comment."); | ||
| console.log(`PR #${issue_number} (${headRef} → ${baseRef})`); | ||
| } catch (error) { | ||
| console.error(`Error in release PR coderabbit gate: ${error.message}`); | ||
| console.log(`PR #${issue_number || 'unknown'} (${headRef || '?'} → ${baseRef || '?'})`); | ||
| } | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| name: CodeRabbit Release Gate Comment | ||
|
|
||
| on: | ||
| pull_request: | ||
| types: [opened, reopened, synchronize, edited] | ||
|
|
||
| permissions: | ||
| contents: read | ||
| pull-requests: write | ||
|
|
||
| concurrency: | ||
| group: coderabbit-release-gate-${{ github.event.pull_request.number }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| coderabbit-release-gate: | ||
| runs-on: ubuntu-latest | ||
| # Only run for release PRs /title check as initial filter | ||
| if: | | ||
| github.event.pull_request && | ||
| (startsWith(github.event.pull_request.title, 'chore: release v') || | ||
| startsWith(github.event.pull_request.title, 'release v') || | ||
| startsWith(github.event.pull_request.title, 'Release v')) | ||
|
|
||
| steps: | ||
| - name: Harden the runner | ||
| uses: step-security/harden-runner@e3f713f2d8f53843e71c69a996d56f51aa9adfb9 # v2.14.1 | ||
| with: | ||
| egress-policy: audit | ||
|
|
||
| - name: Checkout repository | ||
| uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 #v6.0.1 | ||
| with: | ||
| sparse-checkout: | | ||
| .github/coderabbit/release-pr-prompt.md | ||
| .github/scripts/post-coderabbit-release-gate-comment.js | ||
| sparse-checkout-cone-mode: false | ||
|
|
||
| - name: Post CodeRabbit release-gate prompt comment | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd #v8.0.0 | ||
| with: | ||
| script: | | ||
| const script = require('./.github/scripts/release-pr-coderabbit-gate.js'); | ||
| await script({ github, context}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.