Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/bot-ai-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,10 @@ jobs:
LIBRARY="${{ steps.metadata.outputs.library }}"
fi

# Extract sub-issue from PR body if not in metadata
# Extract sub-issue from PR body if not in metadata (format: **Sub-Issue:** #NUM)
SUB_ISSUE="${{ steps.metadata.outputs.sub_issue_number }}"
if [ -z "$SUB_ISSUE" ]; then
SUB_ISSUE=$(echo "$PR_BODY" | grep -oP 'Sub-Issue: #\K\d+' | head -1 || echo "")
SUB_ISSUE=$(echo "$PR_BODY" | grep -oP '\*\*Sub-Issue:\*\* #\K\d+' | head -1 || echo "")
fi

echo "spec_id=$SPEC_ID" >> $GITHUB_OUTPUT
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/bot-auto-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ jobs:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
PR_BODY="${{ github.event.pull_request.body }}"
SUB_ISSUE=$(echo "$PR_BODY" | grep -oP 'Sub-Issue: #\K\d+' | head -1 || echo "")
SUB_ISSUE=$(echo "$PR_BODY" | grep -oP '\*\*Sub-Issue:\*\* #\K\d+' | head -1 || echo "")
echo "number=$SUB_ISSUE" >> $GITHUB_OUTPUT

- name: React with rocket emoji
Expand Down Expand Up @@ -154,8 +154,8 @@ jobs:
LIBRARY=$(echo "$BRANCH" | cut -d'/' -f3)

# Extract issues from PR body
SUB_ISSUE=$(echo "$PR_BODY" | grep -oP 'Sub-Issue: #\K\d+' | head -1 || echo "")
MAIN_ISSUE=$(echo "$PR_BODY" | grep -oP 'Parent Issue: #\K\d+' | head -1 || echo "")
SUB_ISSUE=$(echo "$PR_BODY" | grep -oP '\*\*Sub-Issue:\*\* #\K\d+' | head -1 || echo "")
MAIN_ISSUE=$(echo "$PR_BODY" | grep -oP '\*\*Parent Issue:\*\* #\K\d+' | head -1 || echo "")

# Fallback: search for main issue
if [ -z "$MAIN_ISSUE" ]; then
Expand Down Expand Up @@ -231,7 +231,7 @@ jobs:
fi

# Get all sub-issues for this main issue
SUB_ISSUES=$(gh issue list --search "Parent: #$MAIN_ISSUE in:body" --json number,labels -q '.')
SUB_ISSUES=$(gh issue list --search "**Parent Issue:** #$MAIN_ISSUE in:body" --json number,labels -q '.')

# Count statuses
TOTAL=$(echo "$SUB_ISSUES" | jq 'length')
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/bot-sync-status.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
if echo "$LABELS" | grep -q "sub-issue"; then
# Find parent from issue body
BODY=$(gh issue view $ISSUE_NUM --json body -q '.body')
PARENT_NUM=$(echo "$BODY" | grep -oP 'Parent: #\K\d+' | head -1 || echo "")
PARENT_NUM=$(echo "$BODY" | grep -oP '\*\*Parent Issue:\*\* #\K\d+' | head -1 || echo "")

if [ -n "$PARENT_NUM" ]; then
echo "parent_number=$PARENT_NUM" >> $GITHUB_OUTPUT
Expand All @@ -58,7 +58,7 @@ jobs:
PR_BODY="${{ github.event.pull_request.body }}"

# Extract parent issue from PR body
PARENT_NUM=$(echo "$PR_BODY" | grep -oP 'Parent Issue: #\K\d+' | head -1 || echo "")
PARENT_NUM=$(echo "$PR_BODY" | grep -oP '\*\*Parent Issue:\*\* #\K\d+' | head -1 || echo "")

if [ -n "$PARENT_NUM" ]; then
echo "parent_number=$PARENT_NUM" >> $GITHUB_OUTPUT
Expand All @@ -84,7 +84,7 @@ jobs:
PARENT_NUM="${{ steps.parent.outputs.parent_number }}"

# Get all sub-issues for this parent
# Using GitHub's sub-issues API or searching for issues with "Parent: #N" in body
# Using GitHub's sub-issues API or searching for issues with "Parent Issue: #N" in body
SUB_ISSUES=$(gh api graphql -f query='
query($owner: String!, $repo: String!, $parent: Int!) {
repository(owner: $owner, name: $repo) {
Expand All @@ -103,9 +103,9 @@ jobs:
}
}' -f owner="${{ github.repository_owner }}" -f repo="${{ github.event.repository.name }}" -F parent="$PARENT_NUM" 2>/dev/null || echo '{"data":{"repository":{"issue":{"subIssues":{"nodes":[]}}}}}')

# Fallback: search for issues with "Parent: #N" in body
# Fallback: search for issues with "Parent Issue: #N" in body
if [ "$(echo "$SUB_ISSUES" | jq '.data.repository.issue.subIssues.nodes | length')" == "0" ]; then
SUB_ISSUES_SEARCH=$(gh issue list --search "Parent: #$PARENT_NUM in:body" --json number,title,labels,state)
SUB_ISSUES_SEARCH=$(gh issue list --search "**Parent Issue:** #$PARENT_NUM in:body" --json number,title,labels,state)
echo "$SUB_ISSUES_SEARCH" > /tmp/sub_issues.json
else
echo "$SUB_ISSUES" | jq '.data.repository.issue.subIssues.nodes' > /tmp/sub_issues.json
Expand Down
25 changes: 19 additions & 6 deletions .github/workflows/gen-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,24 +125,35 @@ jobs:
CHANGED_ARRAY=$(echo "$CHANGED_FILES" | jq -R -s -c 'split("\n") | map(select(length > 0))')
echo "changed_files=$CHANGED_ARRAY" >> $GITHUB_OUTPUT

- name: Extract issue number from PR
- name: Extract issue number and metadata from PR
id: get_issue
if: steps.check.outputs.should_run == 'true' && steps.changed_plots.outputs.has_plots == 'true' && steps.get_pr.outputs.pr_number != ''
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
PR_BODY=$(gh pr view ${{ steps.get_pr.outputs.pr_number }} --json body -q '.body')
ISSUE_NUM=$(echo "$PR_BODY" | grep -oP '#\K\d+' | head -1 || echo "")
PR_DATA=$(gh pr view ${{ steps.get_pr.outputs.pr_number }} --json body,headRefName)
PR_BODY=$(echo "$PR_DATA" | jq -r '.body')
BRANCH=$(echo "$PR_DATA" | jq -r '.headRefName')

# Extract parent issue from PR body (format: **Parent Issue:** #NUM)
ISSUE_NUM=$(echo "$PR_BODY" | grep -oP '\*\*Parent Issue:\*\* #\K\d+' | head -1 || echo "")

# Extract sub-issue from PR body (format: **Sub-Issue:** #NUM)
SUB_ISSUE_NUM=$(echo "$PR_BODY" | grep -oP '\*\*Sub-Issue:\*\* #\K\d+' | head -1 || echo "")

# Extract library from branch name (format: auto/{spec-id}/{library})
LIBRARY=$(echo "$BRANCH" | cut -d'/' -f3)

if [ -z "$ISSUE_NUM" ]; then
# Try to find issue by branch name
BRANCH=$(gh pr view ${{ steps.get_pr.outputs.pr_number }} --json headRefName -q '.headRefName')
SPEC_ID=$(echo "$BRANCH" | sed 's/auto\///')
SPEC_ID=$(echo "$BRANCH" | cut -d'/' -f2)
ISSUE_NUM=$(gh issue list --label plot-request --search "$SPEC_ID in:title" --json number -q '.[0].number' || echo "")
fi

echo "issue_num=$ISSUE_NUM" >> $GITHUB_OUTPUT
echo "Found issue: #$ISSUE_NUM"
echo "sub_issue_num=$SUB_ISSUE_NUM" >> $GITHUB_OUTPUT
echo "library=$LIBRARY" >> $GITHUB_OUTPUT
echo "Found issue: #$ISSUE_NUM, sub-issue: #$SUB_ISSUE_NUM, library: $LIBRARY"

- name: Setup Google Cloud authentication
if: steps.check.outputs.should_run == 'true' && steps.changed_plots.outputs.has_plots == 'true'
Expand Down Expand Up @@ -327,6 +338,8 @@ jobs:
{
"pr_number": ${{ steps.get_pr.outputs.pr_number }},
"issue_number": "${{ steps.get_issue.outputs.issue_num }}",
"sub_issue_number": "${{ steps.get_issue.outputs.sub_issue_num }}",
"library": "${{ steps.get_issue.outputs.library }}",
"bucket": "${GCS_BUCKET}",
"base_path": "plots",
"timestamp": "${TIMESTAMP}",
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/gen-update-plot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ jobs:
SPEC_ID=$(echo "$BRANCH" | cut -d'/' -f2)
LIBRARY=$(echo "$BRANCH" | cut -d'/' -f3)

# Extract sub-issue from PR body
SUB_ISSUE=$(echo "$PR_BODY" | grep -oP 'Sub-Issue: #\K\d+' | head -1 || echo "")
# Extract sub-issue from PR body (format: **Sub-Issue:** #NUM)
SUB_ISSUE=$(echo "$PR_BODY" | grep -oP '\*\*Sub-Issue:\*\* #\K\d+' | head -1 || echo "")

# Extract main issue from PR body
MAIN_ISSUE=$(echo "$PR_BODY" | grep -oP 'Parent Issue: #\K\d+' | head -1 || echo "")
# Extract main issue from PR body (format: **Parent Issue:** #NUM)
MAIN_ISSUE=$(echo "$PR_BODY" | grep -oP '\*\*Parent Issue:\*\* #\K\d+' | head -1 || echo "")

echo "spec_id=$SPEC_ID" >> $GITHUB_OUTPUT
echo "library=$LIBRARY" >> $GITHUB_OUTPUT
Expand Down
Loading