Skip to content

Commit be8ca40

Browse files
authored
Merge branch 'main' into feat/add-missing-fields-for-account-update-transaction
2 parents e34e8bd + 968d4cb commit be8ca40

File tree

8 files changed

+359
-103
lines changed

8 files changed

+359
-103
lines changed

.github/scripts/changelog_check.sh

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
#!/bin/bash
2+
3+
CHANGELOG="CHANGELOG.md"
4+
5+
# ANSI color codes
6+
RED="\033[31m"
7+
GREEN="\033[32m"
8+
YELLOW="\033[33m"
9+
RESET="\033[0m"
10+
11+
failed=0
12+
13+
# Fetch upstream
14+
git remote add upstream https://github.com/${GITHUB_REPOSITORY}.git
15+
git fetch upstream main >/dev/null 2>&1
16+
17+
# Get raw diff
18+
raw_diff=$(git diff upstream/main -- "$CHANGELOG")
19+
20+
# 1️⃣ Show raw diff with colors
21+
echo "=== Raw git diff of $CHANGELOG against upstream/main ==="
22+
while IFS= read -r line; do
23+
if [[ $line =~ ^\+ && ! $line =~ ^\+\+\+ ]]; then
24+
echo -e "${GREEN}$line${RESET}"
25+
elif [[ $line =~ ^- && ! $line =~ ^--- ]]; then
26+
echo -e "${RED}$line${RESET}"
27+
else
28+
echo "$line"
29+
fi
30+
done <<< "$raw_diff"
31+
echo "================================="
32+
33+
# 2️⃣ Extract added bullet lines
34+
added_bullets=()
35+
while IFS= read -r line; do
36+
[[ -n "$line" ]] && added_bullets+=("$line")
37+
done < <(echo "$raw_diff" | sed -n 's/^+//p' | grep -E '^[[:space:]]*[-*]' | sed '/^[[:space:]]*$/d')
38+
39+
# 2️⃣a Extract deleted bullet lines
40+
deleted_bullets=()
41+
while IFS= read -r line; do
42+
[[ -n "$line" ]] && deleted_bullets+=("$line")
43+
done < <(echo "$raw_diff" | grep '^\-' | grep -vE '^(--- |\+\+\+ |@@ )' | sed 's/^-//')
44+
45+
# 2️⃣b Warn if no added entries
46+
if [[ ${#added_bullets[@]} -eq 0 ]]; then
47+
echo -e "${RED}❌ No new changelog entries detected in this PR.${RESET}"
48+
echo -e "${YELLOW}⚠️ Please add an entry in [UNRELEASED] under the appropriate subheading.${RESET}"
49+
failed=1
50+
fi
51+
52+
# 3️⃣ Initialize results
53+
correctly_placed=""
54+
orphan_entries=""
55+
wrong_release_entries=""
56+
57+
# 4️⃣ Walk through changelog to classify entries
58+
current_release=""
59+
current_subtitle=""
60+
in_unreleased=0
61+
62+
while IFS= read -r line; do
63+
# Track release sections
64+
if [[ $line =~ ^##\ \[Unreleased\] ]]; then
65+
current_release="Unreleased"
66+
in_unreleased=1
67+
current_subtitle=""
68+
continue
69+
elif [[ $line =~ ^##\ \[.*\] ]]; then
70+
current_release="$line"
71+
in_unreleased=0
72+
current_subtitle=""
73+
continue
74+
elif [[ $line =~ ^### ]]; then
75+
current_subtitle="$line"
76+
continue
77+
fi
78+
79+
# Check each added bullet
80+
for added in "${added_bullets[@]}"; do
81+
if [[ "$line" == "$added" ]]; then
82+
if [[ "$in_unreleased" -eq 1 && -n "$current_subtitle" ]]; then
83+
correctly_placed+="$added (placed under $current_subtitle)"$'\n'
84+
elif [[ "$in_unreleased" -eq 1 && -z "$current_subtitle" ]]; then
85+
orphan_entries+="$added (NOT under a subtitle)"$'\n'
86+
elif [[ "$in_unreleased" -eq 0 ]]; then
87+
wrong_release_entries+="$added (added under released version $current_release)"$'\n'
88+
fi
89+
fi
90+
done
91+
done < "$CHANGELOG"
92+
93+
# 5️⃣ Display results
94+
if [[ -n "$orphan_entries" ]]; then
95+
echo -e "${RED}❌ Some CHANGELOG entries are not under a subtitle in [Unreleased]:${RESET}"
96+
echo "$orphan_entries"
97+
failed=1
98+
fi
99+
100+
if [[ -n "$wrong_release_entries" ]]; then
101+
echo -e "${RED}❌ Some changelog entries were added under a released version (should be in [Unreleased]):${RESET}"
102+
echo "$wrong_release_entries"
103+
failed=1
104+
fi
105+
106+
if [[ -n "$correctly_placed" ]]; then
107+
echo -e "${GREEN}✅ Some CHANGELOG entries are correctly placed under [Unreleased]:${RESET}"
108+
echo "$correctly_placed"
109+
fi
110+
111+
# 6️⃣ Display deleted entries
112+
if [[ ${#deleted_bullets[@]} -gt 0 ]]; then
113+
echo -e "${RED}❌ Changelog entries removed in this PR:${RESET}"
114+
for deleted in "${deleted_bullets[@]}"; do
115+
echo -e " - ${RED}$deleted${RESET}"
116+
done
117+
echo -e "${YELLOW}⚠️ Please add these entries back under the appropriate sections${RESET}"
118+
fi
119+
120+
# 7️⃣ Exit with failure if any bad entries exist
121+
if [[ $failed -eq 1 ]]; then
122+
echo -e "${RED}❌ Changelog check failed.${RESET}"
123+
exit 1
124+
else
125+
echo -e "${GREEN}✅ Changelog check passed.${RESET}"
126+
exit 0
127+
fi
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
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: 'PR Changelog Check'
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
types: [opened, reopened, edited, synchronize]
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
changelog-check:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
16+
with:
17+
fetch-depth: 0
18+
19+
- name: Harden the runner
20+
uses: step-security/harden-runner@95d9a5deda9de15063e7595e9719c11c38c90ae2 # v2.13.2
21+
with:
22+
egress-policy: audit
23+
24+
- name: Run local changelog check
25+
run: |
26+
chmod +x .github/scripts/changelog_check.sh
27+
bash .github/scripts/changelog_check.sh
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: 'PR Formatting'
2+
on:
3+
workflow_dispatch:
4+
pull_request_target:
5+
types:
6+
- opened
7+
- reopened
8+
- edited
9+
- synchronize
10+
11+
defaults:
12+
run:
13+
shell: bash
14+
15+
permissions:
16+
contents: read
17+
checks: write
18+
statuses: write
19+
20+
concurrency:
21+
group: pr-checks-${{ github.workflow }}-${{ github.head_ref || github.run_id }}
22+
cancel-in-progress: true
23+
24+
jobs:
25+
title-check:
26+
name: Title Check
27+
runs-on: ubuntu-latest
28+
if: ${{ !github.event.pull_request.base.repo.fork }}
29+
permissions:
30+
checks: write
31+
statuses: write
32+
steps:
33+
- name: Harden the runner (Audit all outbound calls)
34+
uses: step-security/harden-runner@95d9a5deda9de15063e7595e9719c11c38c90ae2 # v2.13.2
35+
with:
36+
egress-policy: audit
37+
38+
- name: Check PR Title
39+
uses: step-security/conventional-pr-title-action@cb1c5657ccf4c42f5c0a6c0708cb8251b960d902 # v3.2.5
40+
env:
41+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)