Skip to content

Commit fb2319e

Browse files
Added triage CI
1 parent f0eb431 commit fb2319e

2 files changed

Lines changed: 226 additions & 0 deletions

File tree

.github/workflows/triage-ci.yml

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
name: Auggie CI Triage
2+
3+
on:
4+
workflow_run:
5+
workflows:
6+
- CI # Update with the workflow name(s) you want Auggie to triage
7+
types:
8+
- completed
9+
10+
jobs:
11+
triage:
12+
if: >-
13+
${{ github.event.workflow_run.conclusion == 'failure' }}
14+
runs-on: ubuntu-latest
15+
permissions:
16+
contents: read
17+
issues: write
18+
pull-requests: write
19+
steps:
20+
- name: Abort when Auggie session auth is missing
21+
if: ${{ !secrets.AUGMENT_SESSION_AUTH }}
22+
run: |
23+
echo "Skipping triage because AUGMENT_SESSION_AUTH is not configured." >> "$GITHUB_STEP_SUMMARY"
24+
exit 0
25+
26+
- name: Checkout repository
27+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
28+
with:
29+
fetch-depth: 0
30+
31+
- name: Set up Node.js 22
32+
uses: actions/setup-node@60edb5dd5019e0a72c57c00ac6c032d28fc096f4 # v4.1.0
33+
with:
34+
node-version: '22'
35+
36+
- name: Download failing workflow logs
37+
id: download-logs
38+
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7
39+
with:
40+
script: |
41+
const fs = require('fs');
42+
const { owner, repo } = context.repo;
43+
const runId = context.payload.workflow_run.id;
44+
const result = await github.rest.actions.downloadWorkflowRunLogs({
45+
owner,
46+
repo,
47+
run_id: runId
48+
});
49+
fs.writeFileSync('ci-logs.zip', Buffer.from(result.data));
50+
core.setOutput('zip-path', 'ci-logs.zip');
51+
52+
- name: Extract log bundle
53+
run: unzip -q "${{ steps.download-logs.outputs.zip-path }}" -d ci-logs
54+
55+
- name: Consolidate failing job logs
56+
run: |
57+
# Find all log files (txt, log formats) and concatenate with job context
58+
find ci-logs -name '*.txt' -o -name '*.log' | while read -r logfile; do
59+
echo "=== $(basename "$logfile") ===" >> ci-failure.log
60+
cat "$logfile" >> ci-failure.log
61+
echo "" >> ci-failure.log
62+
done
63+
64+
# Ensure we have some content to analyze
65+
if [ ! -s ci-failure.log ]; then
66+
echo "No log content found to analyze" > ci-failure.log
67+
exit 1
68+
fi
69+
70+
# Truncate to last 4000 lines to keep Auggie input manageable
71+
tail -n 4000 ci-failure.log > ci-failure-tail.log
72+
mv ci-failure-tail.log ci-failure.log
73+
74+
- name: Install Auggie CLI
75+
run: npm install -g @augmentcode/auggie
76+
77+
- name: Run Auggie CI triage
78+
env:
79+
AUGMENT_SESSION_AUTH: ${{ secrets.AUGMENT_SESSION_AUTH }}
80+
run: |
81+
# Run Auggie triage and handle potential failures
82+
if ! auggie --print "/triage-ci ci-failure.log" --quiet > triage-output.md; then
83+
echo "⚠️ Auggie triage failed. Raw log analysis:" > triage-output.md
84+
echo "\`\`\`" >> triage-output.md
85+
head -n 100 ci-failure.log >> triage-output.md
86+
echo "\`\`\`" >> triage-output.md
87+
fi
88+
89+
- name: Attach triage summary to workflow run
90+
run: cat triage-output.md >> "$GITHUB_STEP_SUMMARY"
91+
92+
- name: Upload triage artifact
93+
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
94+
with:
95+
name: auggie-triage-report
96+
path: triage-output.md
97+
98+
- name: Comment on related pull requests
99+
if: ${{ github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.pull_requests }}
100+
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7
101+
with:
102+
script: |
103+
const fs = require('fs');
104+
const body = fs.readFileSync('triage-output.md', 'utf8');
105+
const { owner, repo } = context.repo;
106+
for (const pr of context.payload.workflow_run.pull_requests) {
107+
await github.rest.issues.createComment({
108+
owner,
109+
repo,
110+
issue_number: pr.number,
111+
body: `🤖 Auggie CI triage report (workflow run ${context.payload.workflow_run.id})\n\n${body}`
112+
});
113+
}

examples/workflows/triage-ci.yml

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
name: Auggie CI Triage
2+
3+
on:
4+
workflow_run:
5+
workflows:
6+
- CI # Update with the workflow name(s) you want Auggie to triage
7+
types:
8+
- completed
9+
10+
jobs:
11+
triage:
12+
if: >-
13+
${{ github.event.workflow_run.conclusion == 'failure' }}
14+
runs-on: ubuntu-latest
15+
permissions:
16+
contents: read
17+
issues: write
18+
pull-requests: write
19+
steps:
20+
- name: Abort when Auggie session auth is missing
21+
if: ${{ !secrets.AUGMENT_SESSION_AUTH }}
22+
run: |
23+
echo "Skipping triage because AUGMENT_SESSION_AUTH is not configured." >> "$GITHUB_STEP_SUMMARY"
24+
exit 0
25+
26+
- name: Checkout repository
27+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
28+
with:
29+
fetch-depth: 0
30+
31+
- name: Set up Node.js 22
32+
uses: actions/setup-node@60edb5dd5019e0a72c57c00ac6c032d28fc096f4 # v4.1.0
33+
with:
34+
node-version: '22'
35+
36+
- name: Download failing workflow logs
37+
id: download-logs
38+
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7
39+
with:
40+
script: |
41+
const fs = require('fs');
42+
const { owner, repo } = context.repo;
43+
const runId = context.payload.workflow_run.id;
44+
const result = await github.rest.actions.downloadWorkflowRunLogs({
45+
owner,
46+
repo,
47+
run_id: runId
48+
});
49+
fs.writeFileSync('ci-logs.zip', Buffer.from(result.data));
50+
core.setOutput('zip-path', 'ci-logs.zip');
51+
52+
- name: Extract log bundle
53+
run: unzip -q "${{ steps.download-logs.outputs.zip-path }}" -d ci-logs
54+
55+
- name: Consolidate failing job logs
56+
run: |
57+
# Find all log files (txt, log formats) and concatenate with job context
58+
find ci-logs -name '*.txt' -o -name '*.log' | while read -r logfile; do
59+
echo "=== $(basename "$logfile") ===" >> ci-failure.log
60+
cat "$logfile" >> ci-failure.log
61+
echo "" >> ci-failure.log
62+
done
63+
64+
# Ensure we have some content to analyze
65+
if [ ! -s ci-failure.log ]; then
66+
echo "No log content found to analyze" > ci-failure.log
67+
exit 1
68+
fi
69+
70+
# Truncate to last 4000 lines to keep Auggie input manageable
71+
tail -n 4000 ci-failure.log > ci-failure-tail.log
72+
mv ci-failure-tail.log ci-failure.log
73+
74+
- name: Install Auggie CLI
75+
run: npm install -g @augmentcode/auggie
76+
77+
- name: Run Auggie CI triage
78+
env:
79+
AUGMENT_SESSION_AUTH: ${{ secrets.AUGMENT_SESSION_AUTH }}
80+
run: |
81+
# Run Auggie triage and handle potential failures
82+
if ! auggie --print "/triage-ci ci-failure.log" --quiet > triage-output.md; then
83+
echo "⚠️ Auggie triage failed. Raw log analysis:" > triage-output.md
84+
echo "\`\`\`" >> triage-output.md
85+
head -n 100 ci-failure.log >> triage-output.md
86+
echo "\`\`\`" >> triage-output.md
87+
fi
88+
89+
- name: Attach triage summary to workflow run
90+
run: cat triage-output.md >> "$GITHUB_STEP_SUMMARY"
91+
92+
- name: Upload triage artifact
93+
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
94+
with:
95+
name: auggie-triage-report
96+
path: triage-output.md
97+
98+
- name: Comment on related pull requests
99+
if: ${{ github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.pull_requests }}
100+
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7
101+
with:
102+
script: |
103+
const fs = require('fs');
104+
const body = fs.readFileSync('triage-output.md', 'utf8');
105+
const { owner, repo } = context.repo;
106+
for (const pr of context.payload.workflow_run.pull_requests) {
107+
await github.rest.issues.createComment({
108+
owner,
109+
repo,
110+
issue_number: pr.number,
111+
body: `🤖 Auggie CI triage report (workflow run ${context.payload.workflow_run.id})\n\n${body}`
112+
});
113+
}

0 commit comments

Comments
 (0)