-
Notifications
You must be signed in to change notification settings - Fork 8
136 lines (118 loc) · 4.89 KB
/
Copy pathwizard-issue-triage.yml
File metadata and controls
136 lines (118 loc) · 4.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
name: "Wizard — issue triage"
on:
issues:
types: [opened, labeled]
workflow_dispatch:
inputs:
issue_number:
description: "Issue number to triage"
required: true
type: string
concurrency:
group: wizard-loop-1
cancel-in-progress: false
permissions:
contents: write
issues: write
pull-requests: write
jobs:
classify:
if: >
github.event_name == 'workflow_dispatch' ||
github.event.label.name == 'data-request'
runs-on: ubuntu-latest
timeout-minutes: 5
outputs:
is_dbt: ${{ steps.classify.outputs.is_dbt }}
issue_number: ${{ steps.meta.outputs.number }}
steps:
- name: Get issue metadata
id: meta
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
if [[ -n "${{ inputs.issue_number }}" ]]; then
NUM="${{ inputs.issue_number }}"
else
NUM="${{ github.event.issue.number }}"
fi
BODY=$(gh api repos/${{ github.repository }}/issues/${NUM} --jq '.title + " " + .body')
{
echo "number=${NUM}"
echo "body<<GHEOF"
echo "$BODY"
echo "GHEOF"
} >> "$GITHUB_OUTPUT"
- name: Classify issue (gpt-5.4-nano)
id: classify
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
run: |
RESPONSE=$(curl -s https://api.openai.com/v1/chat/completions \
-H "Authorization: Bearer ${OPENAI_API_KEY}" \
-H "Content-Type: application/json" \
-d "$(jq -n --arg body "${{ steps.meta.outputs.body }}" '{
model: "gpt-5.4-nano",
messages: [
{role: "system", content: "You classify GitHub issues. Respond with exactly YES or NO. Is this issue related to dbt models, SQL transformations, data quality tests, schema changes, source freshness, metrics, or data pipeline transformations?"},
{role: "user", content: $body}
],
max_tokens: 3
}')")
ANSWER=$(echo "$RESPONSE" | jq -r '.choices[0].message.content' | tr '[:lower:]' '[:upper:]' | head -c 3)
TOKENS_IN=$(echo "$RESPONSE" | jq -r '.usage.prompt_tokens // 0')
TOKENS_OUT=$(echo "$RESPONSE" | jq -r '.usage.completion_tokens // 0')
MODEL=$(echo "$RESPONSE" | jq -r '.model // "unknown"')
echo "::notice::Classifier: model=${MODEL} input_tokens=${TOKENS_IN} output_tokens=${TOKENS_OUT} result=${ANSWER}"
if [[ "$ANSWER" == "YES" ]]; then
echo "is_dbt=true" >> "$GITHUB_OUTPUT"
else
echo "is_dbt=false" >> "$GITHUB_OUTPUT"
fi
triage:
needs: classify
if: needs.classify.outputs.is_dbt == 'true'
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install dbt Wizard CLI
run: curl -fsSL https://cli.getdbt.com/install-wizard.sh | bash
- name: Scope and build (gpt-5.4-mini)
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ISSUE_NUM: ${{ needs.classify.outputs.issue_number }}
run: |
chmod +x scripts/common.sh
ISSUE_BODY=$(gh api "repos/${{ github.repository }}/issues/${ISSUE_NUM}" --jq '.title + "\n\n" + .body')
wizard exec \
-m gpt-5.4-mini \
-s workspace-write \
--json \
-o wizard-output.md \
"You are an autonomous dbt agent running in CI. Do not ask for user input.
Reference AGENTS.md for project conventions, incident triage, and fix risk levels.
Reference .claude/skills/dbt-development/dbt_skill.md for dbt patterns.
GitHub Issue #${ISSUE_NUM}:
${ISSUE_BODY}
Steps:
1. Scope this issue against the dbt project in ./dbt_project/. Identify which
domain it affects, which models need changes, and upstream/downstream impact.
2. If the issue is workable (not blocked per AGENTS.md 'Data Request Scoping'):
- Create the necessary model files, schema.yml entries, and tests.
- Run: dbt compile to verify SQL validity.
- Commit changes to a new branch feat/wizard-issue-${ISSUE_NUM}.
- Push the branch and open a PR referencing issue #${ISSUE_NUM}.
3. If blocked: post a comment on issue #${ISSUE_NUM} explaining why.
Output a summary of what you did and any token usage." \
2>&1 | tee wizard-log.jsonl
echo "::group::Wizard output"
cat wizard-output.md 2>/dev/null || echo "No output file"
echo "::endgroup::"
echo "::group::Token usage"
if [[ -f wizard-log.jsonl ]]; then
grep -o '"usage":{[^}]*}' wizard-log.jsonl | tail -5 || echo "No usage data in log"
fi
echo "::endgroup::"