Skip to content

Commit 33c68aa

Browse files
Merge branch 'main' into example-token-pause-key-clean
Signed-off-by: undefinedIsMyLife <shinetina169@gmail.com>
2 parents 8a08f76 + 46931e8 commit 33c68aa

File tree

6 files changed

+385
-11
lines changed

6 files changed

+385
-11
lines changed
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: PythonBot - Office Hour Reminder
2+
3+
on:
4+
# push:
5+
schedule:
6+
- cron: '0 10 * * 3'
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: read
11+
pull-requests: write
12+
13+
jobs:
14+
office-hour-reminder:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Harden the runner
18+
uses: step-security/harden-runner@95d9a5deda9de15063e7595e9719c11c38c90ae2
19+
with:
20+
egress-policy: audit
21+
22+
- name: Check Schedule and Notify
23+
env:
24+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
25+
run: |
26+
ANCHOR_DATE="2025-12-03"
27+
MEETING_LINK="https://zoom-lfx.platform.linuxfoundation.org/meeting/99912667426?password=5b584a0e-1ed7-49d3-b2fc-dc5ddc888338"
28+
CALENDAR_LINK="https://zoom-lfx.platform.linuxfoundation.org/meetings/hiero?view=week"
29+
30+
IS_MEETING_WEEK=$(python3 -c "from datetime import date; import os; d1=date.fromisoformat('$ANCHOR_DATE'); d2=date.today(); print('true' if (d2-d1).days % 14 == 0 else 'false')")
31+
32+
if [ "$IS_MEETING_WEEK" = "false" ]; then
33+
echo "Not a fortnightly meeting week. Skipping execution."
34+
exit 0
35+
fi
36+
37+
echo "Meeting week detected. Proceeding to notify open PRs."
38+
39+
REPO="${{ github.repository }}"
40+
PR_LIST=$(gh pr list --repo $REPO --state open --json number --jq '.[].number')
41+
42+
if [ -z "$PR_LIST" ]; then
43+
echo "No open PRs found."
44+
exit 0
45+
fi
46+
47+
COMMENT_BODY=$(cat <<EOF
48+
Hello, this is the Office Hour Bot.
49+
50+
This is a reminder that the Hiero Python SDK Office Hours are scheduled in approximately 4 hours (14:00 UTC).
51+
52+
This session provides an opportunity to ask questions regarding this Pull Request or receive assistance from a maintainer.
53+
54+
Details:
55+
- Time: 14:00 UTC
56+
- Join Link: [Zoom Meeting]($MEETING_LINK)
57+
58+
Disclaimer: This is an automated reminder. Please verify the schedule [here]($CALENDAR_LINK) to be notified of any changes.
59+
EOF
60+
)
61+
62+
for PR_NUM in $PR_LIST; do
63+
echo "Processing PR #$PR_NUM"
64+
65+
ALREADY_COMMENTED=$(gh pr view $PR_NUM --repo $REPO --json comments --jq '.comments[].body' | grep -F "Office Hour Bot" || true)
66+
67+
if [ -z "$ALREADY_COMMENTED" ]; then
68+
gh pr comment $PR_NUM --repo $REPO --body "$COMMENT_BODY"
69+
echo "Reminder posted to PR #$PR_NUM"
70+
else
71+
echo "PR #$PR_NUM already notified. Skipping."
72+
fi
73+
done

.github/workflows/bot-verified-commits.yml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,16 @@ jobs:
3838
3939
echo "Unverified commits: $UNVERIFIED_COUNT"
4040
41+
EXISTING_BOT_COMMENT_COUNT=$(gh pr view $PR_NUMBER --repo $REPO --json comments | jq '[.comments[] | select(.author.login == "github-actions" and (.body | contains("[commit-verification-bot]")))] | length')
42+
43+
echo "Existing verification commit bot comments: $EXISTING_BOT_COMMENT_COUNT"
44+
4145
if [ "$UNVERIFIED_COUNT" -gt 0 ]; then
42-
COMMENT=$(cat <<EOF
46+
if [ "$EXISTING_BOT_COMMENT_COUNT" -ge 1 ]; then
47+
echo "VerificationBot already commented. Skipping additional comments."
48+
else
49+
COMMENT=$(cat <<EOF
50+
[commit-verification-bot]
4351
Hi, this is VerificationBot.
4452
Your pull request cannot be merged as it has **unverified commits**.
4553
View your commit verification status: [Commits Tab]($COMMITS_URL).
@@ -58,9 +66,11 @@ jobs:
5866
EOF
5967
)
6068

61-
gh pr view $PR_NUMBER --repo $REPO --json comments --jq '.comments[].body' | grep -F "PythonBot" >/dev/null || \
62-
(gh pr comment $PR_NUMBER --repo $REPO --body "$COMMENT" && echo "Comment added to PR #$PR_NUMBER")
69+
gh pr comment $PR_NUMBER --repo $REPO --body "$COMMENT"
70+
echo "Comment added to PR #$PR_NUMBER"
71+
fi
72+
73+
exit 1
6374
else
6475
echo "All commits in PR #$PR_NUMBER are verified."
6576
fi
66-
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: PythonBot - Check Merge Conflicts
2+
3+
on:
4+
pull_request_target:
5+
types: [opened, synchronize, reopened]
6+
7+
permissions:
8+
contents: read
9+
pull-requests: write
10+
11+
concurrency:
12+
group: "check-conflicts-${{ github.event.pull_request.number }}"
13+
cancel-in-progress: true
14+
15+
jobs:
16+
check-conflicts:
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- name: Harden the runner (Audit all outbound calls)
21+
uses: step-security/harden-runner@95d9a5deda9de15063e7595e9719c11c38c90ae2 # v2.13.2
22+
with:
23+
egress-policy: audit
24+
25+
- name: Check for merge conflicts
26+
env:
27+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
28+
run: |
29+
PR_NUMBER=${{ github.event.pull_request.number }}
30+
REPO="${{ github.repository }}"
31+
32+
echo "Checking merge status for PR #$PR_NUMBER in repository $REPO..."
33+
34+
for i in {1..10}; do
35+
PR_JSON=$(gh api repos/$REPO/pulls/$PR_NUMBER)
36+
MERGEABLE_STATE=$(echo "$PR_JSON" | jq -r '.mergeable_state')
37+
38+
echo "Attempt $i: Current mergeable state: $MERGEABLE_STATE"
39+
40+
if [ "$MERGEABLE_STATE" != "unknown" ]; then
41+
break
42+
fi
43+
44+
echo "State is 'unknown', waiting 2 seconds..."
45+
sleep 2
46+
done
47+
48+
if [ "$MERGEABLE_STATE" = "dirty" ]; then
49+
COMMENT=$(cat <<EOF
50+
Hi, this is MergeConflictBot.
51+
Your pull request cannot be merged because it contains **merge conflicts**.
52+
53+
Please resolve these conflicts locally and push the changes.
54+
55+
To assist you, please read:
56+
- [Resolving Merge Conflicts](docs/sdk_developers/merge_conflicts.md)
57+
- [Rebasing Guide](docs/sdk_developers/rebasing.md)
58+
59+
Thank you for contributing!
60+
61+
From the Hiero Python SDK Team
62+
EOF
63+
)
64+
65+
gh pr view $PR_NUMBER --repo $REPO --json comments --jq '.comments[].body' | grep -F "MergeConflictBot" >/dev/null || \
66+
(gh pr comment $PR_NUMBER --repo $REPO --body "$COMMENT" && echo "Comment added to PR #$PR_NUMBER")
67+
68+
exit 1
69+
else
70+
echo "No merge conflicts detected (State: $MERGEABLE_STATE)."
71+
fi

.github/workflows/pr-checks.yml

Lines changed: 77 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@ jobs:
7373
# List files in the PR and check for CHANGELOG.md (root or any path ending with /CHANGELOG.md)
7474
FILES_JSON="$(gh api repos/${{ github.repository }}/pulls/${PR_NUMBER}/files --paginate)"
7575
if ! echo "${FILES_JSON}" | jq -e '.[] | select(.filename | test("(^|/)CHANGELOG\\.md$"; "i"))' >/dev/null; then
76-
echo "FAIL: CHANGELOG.md was not changed in this PR."
76+
echo "❌ FAIL: CHANGELOG.md was not changed in this PR."
77+
echo ""
78+
echo "Please add an entry to CHANGELOG.md under the [Unreleased] section."
7779
exit 1
7880
fi
7981
@@ -83,15 +85,84 @@ jobs:
8385
8486
# If no patch is returned (very large file or API omission), treat presence as sufficient
8587
if [[ -z "${PATCH_CONTENT}" ]]; then
86-
echo "CHANGELOG.md modified (no patch provided by API). Passing."
88+
echo "✅ PASS: CHANGELOG.md modified (no patch provided by API)."
8789
exit 0
8890
fi
8991
90-
# Look for actual line changes (exclude diff headers +++/---)
91-
if echo "${PATCH_CONTENT}" | awk '{print $0}' | grep -E '^[+-]' | grep -vE '^\+\+\+|^\-\-\-' >/dev/null; then
92-
echo "PASS: CHANGELOG.md contains line-level changes."
92+
# Extract only the added lines from the patch (lines starting with +, excluding +++ header)
93+
ADDED_LINES="$(echo "${PATCH_CONTENT}" | grep -E '^\+' | grep -v '^\+\+\+' || true)"
94+
95+
# Check if there are any actual additions
96+
if [[ -z "${ADDED_LINES}" ]]; then
97+
echo "❌ FAIL: No line-level additions detected in CHANGELOG.md."
98+
echo ""
99+
echo "Please add an entry to CHANGELOG.md under the [Unreleased] section."
100+
exit 1
101+
fi
102+
103+
# Check if changes are under [Unreleased]
104+
# Parse the patch to track which section we're in and validate additions
105+
IN_UNRELEASED=false
106+
IN_RELEASED_VERSION=false
107+
FOUND_VALID_ADDITION=false
108+
RELEASED_VERSION_FOUND=""
109+
110+
while IFS= read -r line; do
111+
# Check for [Unreleased] header (context line or added line)
112+
if [[ "$line" =~ \[Unreleased\] ]]; then
113+
IN_UNRELEASED=true
114+
IN_RELEASED_VERSION=false
115+
RELEASED_VERSION_FOUND=""
116+
fi
117+
118+
# Check for released version header pattern: ## [X.Y.Z] - DATE
119+
# Match both context and added lines
120+
if [[ "$line" =~ \[([0-9]+\.[0-9]+\.[0-9]+)\].*-.*[0-9]{4} ]]; then
121+
# We found a released version header
122+
RELEASED_VERSION_FOUND="${BASH_REMATCH[1]}"
123+
IN_UNRELEASED=false
124+
IN_RELEASED_VERSION=true
125+
fi
126+
127+
# Check for added lines (starting with +, not +++)
128+
if [[ "$line" =~ ^\+[^+] ]]; then
129+
# Extract the actual content (remove the leading +)
130+
ADDED_CONTENT="${line:1}"
131+
132+
# Skip empty lines and section headers
133+
if [[ -n "$ADDED_CONTENT" && ! "$ADDED_CONTENT" =~ ^###\ ]]; then
134+
if [[ "$IN_UNRELEASED" == true ]]; then
135+
FOUND_VALID_ADDITION=true
136+
elif [[ "$IN_RELEASED_VERSION" == true && -n "$RELEASED_VERSION_FOUND" ]]; then
137+
# Found an addition under a released version - this is wrong
138+
echo "❌ FAIL: Changelog entry found under a released version, not under [Unreleased]."
139+
echo ""
140+
echo "You added content under version [$RELEASED_VERSION_FOUND] instead of [Unreleased]:"
141+
echo " $ADDED_CONTENT"
142+
echo ""
143+
echo "📝 Please move your changes to the [Unreleased] section at the top of CHANGELOG.md"
144+
echo ""
145+
echo "Example structure:"
146+
echo " ## [Unreleased]"
147+
echo " ### Added"
148+
echo " - Your new feature or fix here"
149+
exit 1
150+
fi
151+
fi
152+
fi
153+
done <<< "$PATCH_CONTENT"
154+
155+
if [[ "$FOUND_VALID_ADDITION" == true ]]; then
156+
echo "✅ PASS: CHANGELOG.md contains valid additions under [Unreleased]."
93157
exit 0
94158
else
95-
echo "FAIL: No line-level changes detected in CHANGELOG.md."
159+
echo "❌ FAIL: No valid changelog entries found under [Unreleased]."
160+
echo ""
161+
echo "Please ensure your changes are added under the [Unreleased] section of CHANGELOG.md"
162+
echo ""
163+
echo "Example:"
164+
echo " ## [Unreleased]"
165+
echo " ### Added"
166+
echo " - Your feature/fix description"
96167
exit 1
97168
fi

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ This changelog is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.
88

99
### Added
1010
- Add examples/token_create_transaction_pause_key.py example demonstrating token pause/unpause behavior and pause key usage (#820)
11+
12+
- Add example demonstrating usage of `CustomFeeLimit` in `examples/transaction/custom_fee_limit.py`
13+
- Added `.github/workflows/merge-conflict-bot.yml` to automatically detect and notify users of merge conflicts in Pull Requests.
14+
- Added validation logic in `.github/workflows/pr-checks.yml` to detect when no new chnagelog entries are added under [Unreleased]
15+
1116
### Changed
1217

1318
- Removed duplicate import of transaction_pb2 in transaction.py
@@ -18,6 +23,7 @@ This changelog is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.
1823

1924
### Added
2025

26+
- Add a limit of one comment for PR to the commit verification bot. [#892]
2127
- Removed `actions/checkout@v4` from `bot-verified-commits.yml`
2228
- Add comprehensive documentation for `ReceiptStatusError` in `docs/sdk_developers/training/receipt_status_error.md`
2329
- Add practical example `examples/errors/receipt_status_error.py` demonstrating transaction error handling
@@ -68,7 +74,6 @@ This changelog is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.
6874
- changed to add concurrency to workflow bot
6975
- feat: Refactor `TokenDissociateTransaction` to use set_token_ids method and update transaction fee to Hbar, also update `transaction.py` and expand `examples/token_dissociate.py`, `tests/unit/token_dissociate.py`.
7076

71-
7277
### Fixed
7378

7479
- chore: updated solo action to avoid v5

0 commit comments

Comments
 (0)