|
| 1 | +name: "Report: Validate" |
| 2 | +run-name: "Validate Report: ${{ github.event.issue.title }}" |
| 3 | + |
| 4 | +# Validates and structures user-submitted issue reports |
| 5 | +# Flow: |
| 6 | +# 1. User submits report → report-pending label auto-added |
| 7 | +# 2. AI validates spec/impl exists, analyzes issue, posts structured comment |
| 8 | +# 3. Labels updated: report-validated + category + report:spec/impl |
| 9 | + |
| 10 | +on: |
| 11 | + issues: |
| 12 | + types: [labeled] |
| 13 | + |
| 14 | +concurrency: |
| 15 | + group: report-validate-${{ github.event.issue.number }} |
| 16 | + cancel-in-progress: false |
| 17 | + |
| 18 | +jobs: |
| 19 | + validate: |
| 20 | + if: github.event.label.name == 'report-pending' |
| 21 | + runs-on: ubuntu-latest |
| 22 | + permissions: |
| 23 | + contents: read |
| 24 | + issues: write |
| 25 | + |
| 26 | + steps: |
| 27 | + - name: Check if already validated |
| 28 | + id: check |
| 29 | + env: |
| 30 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 31 | + run: | |
| 32 | + # Check if already has report-validated label |
| 33 | + LABELS=$(gh issue view ${{ github.event.issue.number }} --json labels -q '.labels[].name' | tr '\n' ' ') |
| 34 | + if echo "$LABELS" | grep -q "report-validated"; then |
| 35 | + echo "::notice::Skipping: Issue already validated" |
| 36 | + echo "should_run=false" >> $GITHUB_OUTPUT |
| 37 | + exit 0 |
| 38 | + fi |
| 39 | + echo "should_run=true" >> $GITHUB_OUTPUT |
| 40 | +
|
| 41 | + - name: Checkout repository |
| 42 | + if: steps.check.outputs.should_run == 'true' |
| 43 | + uses: actions/checkout@v6 |
| 44 | + |
| 45 | + - name: React with eyes emoji |
| 46 | + if: steps.check.outputs.should_run == 'true' |
| 47 | + env: |
| 48 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 49 | + run: | |
| 50 | + gh api repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/reactions \ |
| 51 | + -f content=eyes |
| 52 | +
|
| 53 | + - name: Validate with Claude |
| 54 | + if: steps.check.outputs.should_run == 'true' |
| 55 | + id: validate |
| 56 | + continue-on-error: true |
| 57 | + timeout-minutes: 10 |
| 58 | + uses: anthropics/claude-code-action@v1 |
| 59 | + with: |
| 60 | + claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} |
| 61 | + claude_args: "--model sonnet" |
| 62 | + prompt: | |
| 63 | + ## Task: Validate Issue Report |
| 64 | +
|
| 65 | + You are validating a user-submitted issue report for pyplots. |
| 66 | +
|
| 67 | + ### Issue Details |
| 68 | + - **Title:** ${{ github.event.issue.title }} |
| 69 | + - **Number:** #${{ github.event.issue.number }} |
| 70 | + - **Author:** ${{ github.event.issue.user.login }} |
| 71 | + - **Body:** |
| 72 | + ``` |
| 73 | + ${{ github.event.issue.body }} |
| 74 | + ``` |
| 75 | +
|
| 76 | + --- |
| 77 | +
|
| 78 | + ## Instructions |
| 79 | +
|
| 80 | + 1. **Read the prompt:** `prompts/workflow-prompts/report-analysis.md` |
| 81 | +
|
| 82 | + 2. **Parse the issue body** to extract: |
| 83 | + - spec_id (from "Specification ID" field) |
| 84 | + - target (Specification or Implementation) |
| 85 | + - library (if implementation) |
| 86 | + - category (Visual/Data/Functional/Other) |
| 87 | + - description |
| 88 | +
|
| 89 | + 3. **Validate the spec exists:** |
| 90 | + ```bash |
| 91 | + ls plots/{spec_id}/ |
| 92 | + ``` |
| 93 | + If NOT found: |
| 94 | + - Post comment: "Spec `{spec_id}` not found. Please check the ID." |
| 95 | + - Remove `report-pending` label |
| 96 | + - Close issue |
| 97 | + - STOP |
| 98 | +
|
| 99 | + 4. **If implementation issue, validate the library exists:** |
| 100 | + ```bash |
| 101 | + ls plots/{spec_id}/implementations/{library}.py |
| 102 | + ``` |
| 103 | + If NOT found: |
| 104 | + - Post comment: "Implementation `{library}` not found for `{spec_id}`." |
| 105 | + - Remove `report-pending` label |
| 106 | + - Close issue |
| 107 | + - STOP |
| 108 | +
|
| 109 | + 5. **Read relevant files:** |
| 110 | + - `plots/{spec_id}/specification.md` |
| 111 | + - `plots/{spec_id}/metadata/{library}.yaml` (if impl issue) |
| 112 | +
|
| 113 | + 6. **Post structured analysis comment** following the format in the prompt file. |
| 114 | +
|
| 115 | + 7. **Update issue title:** |
| 116 | + ```bash |
| 117 | + gh issue edit ${{ github.event.issue.number }} --title "[{spec_id}] {brief description}" |
| 118 | + ``` |
| 119 | +
|
| 120 | + 8. **Update labels:** |
| 121 | + ```bash |
| 122 | + # Remove pending, add validated |
| 123 | + gh issue edit ${{ github.event.issue.number }} --remove-label "report-pending" --add-label "report-validated" |
| 124 | +
|
| 125 | + # Add target label |
| 126 | + gh issue edit ${{ github.event.issue.number }} --add-label "report:spec" |
| 127 | + # OR for impl: |
| 128 | + gh issue edit ${{ github.event.issue.number }} --add-label "report:impl" --add-label "report:impl:{library}" |
| 129 | +
|
| 130 | + # Add category label (map from dropdown value) |
| 131 | + # Visual → category:visual |
| 132 | + # Data → category:data |
| 133 | + # Functional → category:functional |
| 134 | + # Other → category:other |
| 135 | + gh issue edit ${{ github.event.issue.number }} --add-label "category:{category}" |
| 136 | + ``` |
| 137 | +
|
| 138 | + ### Important |
| 139 | + - Do NOT add the `approved` label |
| 140 | + - Do NOT trigger any fixes |
| 141 | + - Keep the analysis comment concise but informative |
| 142 | +
|
| 143 | + - name: Add reaction on success |
| 144 | + if: steps.check.outputs.should_run == 'true' && steps.validate.outcome == 'success' |
| 145 | + env: |
| 146 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 147 | + run: | |
| 148 | + gh api repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/reactions \ |
| 149 | + -f content=rocket |
| 150 | +
|
| 151 | + - name: Handle failure |
| 152 | + if: steps.check.outputs.should_run == 'true' && steps.validate.outcome == 'failure' |
| 153 | + env: |
| 154 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 155 | + run: | |
| 156 | + gh issue comment ${{ github.event.issue.number }} --body "## :x: Validation Failed |
| 157 | +
|
| 158 | + The AI validation workflow encountered an error. A maintainer will review this manually. |
| 159 | +
|
| 160 | + --- |
| 161 | + :robot: *[report-validate](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})*" |
| 162 | +
|
| 163 | + gh api repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/reactions \ |
| 164 | + -f content=confused |
0 commit comments