diff --git a/.github/workflows/bot-ai-review.yml b/.github/workflows/bot-ai-review.yml index 7c7846d196..0cb275a6f7 100644 --- a/.github/workflows/bot-ai-review.yml +++ b/.github/workflows/bot-ai-review.yml @@ -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 diff --git a/.github/workflows/bot-auto-merge.yml b/.github/workflows/bot-auto-merge.yml index 740c594eba..5f308c2137 100644 --- a/.github/workflows/bot-auto-merge.yml +++ b/.github/workflows/bot-auto-merge.yml @@ -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 @@ -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 @@ -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') diff --git a/.github/workflows/bot-sync-status.yml b/.github/workflows/bot-sync-status.yml index 116af4d02d..6752c4511b 100644 --- a/.github/workflows/bot-sync-status.yml +++ b/.github/workflows/bot-sync-status.yml @@ -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 @@ -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 @@ -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) { @@ -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 diff --git a/.github/workflows/gen-preview.yml b/.github/workflows/gen-preview.yml index dab52b0753..932ba2b184 100644 --- a/.github/workflows/gen-preview.yml +++ b/.github/workflows/gen-preview.yml @@ -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' @@ -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}", diff --git a/.github/workflows/gen-update-plot.yml b/.github/workflows/gen-update-plot.yml index df9f21e4a7..202800563f 100644 --- a/.github/workflows/gen-update-plot.yml +++ b/.github/workflows/gen-update-plot.yml @@ -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