From fb2319e4dfd25b4e2d3b9f9004b80bd8e51d08a1 Mon Sep 17 00:00:00 2001 From: Francesco Gruosso <64712227+FrancescoCoding@users.noreply.github.com> Date: Sat, 27 Sep 2025 15:23:01 +0100 Subject: [PATCH 1/3] Added triage CI --- .github/workflows/triage-ci.yml | 113 +++++++++++++++++++++++++++++++ examples/workflows/triage-ci.yml | 113 +++++++++++++++++++++++++++++++ 2 files changed, 226 insertions(+) create mode 100644 .github/workflows/triage-ci.yml create mode 100644 examples/workflows/triage-ci.yml diff --git a/.github/workflows/triage-ci.yml b/.github/workflows/triage-ci.yml new file mode 100644 index 0000000..fb49c3e --- /dev/null +++ b/.github/workflows/triage-ci.yml @@ -0,0 +1,113 @@ +name: Auggie CI Triage + +on: + workflow_run: + workflows: + - CI # Update with the workflow name(s) you want Auggie to triage + types: + - completed + +jobs: + triage: + if: >- + ${{ github.event.workflow_run.conclusion == 'failure' }} + runs-on: ubuntu-latest + permissions: + contents: read + issues: write + pull-requests: write + steps: + - name: Abort when Auggie session auth is missing + if: ${{ !secrets.AUGMENT_SESSION_AUTH }} + run: | + echo "Skipping triage because AUGMENT_SESSION_AUTH is not configured." >> "$GITHUB_STEP_SUMMARY" + exit 0 + + - name: Checkout repository + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + fetch-depth: 0 + + - name: Set up Node.js 22 + uses: actions/setup-node@60edb5dd5019e0a72c57c00ac6c032d28fc096f4 # v4.1.0 + with: + node-version: '22' + + - name: Download failing workflow logs + id: download-logs + uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7 + with: + script: | + const fs = require('fs'); + const { owner, repo } = context.repo; + const runId = context.payload.workflow_run.id; + const result = await github.rest.actions.downloadWorkflowRunLogs({ + owner, + repo, + run_id: runId + }); + fs.writeFileSync('ci-logs.zip', Buffer.from(result.data)); + core.setOutput('zip-path', 'ci-logs.zip'); + + - name: Extract log bundle + run: unzip -q "${{ steps.download-logs.outputs.zip-path }}" -d ci-logs + + - name: Consolidate failing job logs + run: | + # Find all log files (txt, log formats) and concatenate with job context + find ci-logs -name '*.txt' -o -name '*.log' | while read -r logfile; do + echo "=== $(basename "$logfile") ===" >> ci-failure.log + cat "$logfile" >> ci-failure.log + echo "" >> ci-failure.log + done + + # Ensure we have some content to analyze + if [ ! -s ci-failure.log ]; then + echo "No log content found to analyze" > ci-failure.log + exit 1 + fi + + # Truncate to last 4000 lines to keep Auggie input manageable + tail -n 4000 ci-failure.log > ci-failure-tail.log + mv ci-failure-tail.log ci-failure.log + + - name: Install Auggie CLI + run: npm install -g @augmentcode/auggie + + - name: Run Auggie CI triage + env: + AUGMENT_SESSION_AUTH: ${{ secrets.AUGMENT_SESSION_AUTH }} + run: | + # Run Auggie triage and handle potential failures + if ! auggie --print "/triage-ci ci-failure.log" --quiet > triage-output.md; then + echo "⚠️ Auggie triage failed. Raw log analysis:" > triage-output.md + echo "\`\`\`" >> triage-output.md + head -n 100 ci-failure.log >> triage-output.md + echo "\`\`\`" >> triage-output.md + fi + + - name: Attach triage summary to workflow run + run: cat triage-output.md >> "$GITHUB_STEP_SUMMARY" + + - name: Upload triage artifact + uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0 + with: + name: auggie-triage-report + path: triage-output.md + + - name: Comment on related pull requests + if: ${{ github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.pull_requests }} + uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7 + with: + script: | + const fs = require('fs'); + const body = fs.readFileSync('triage-output.md', 'utf8'); + const { owner, repo } = context.repo; + for (const pr of context.payload.workflow_run.pull_requests) { + await github.rest.issues.createComment({ + owner, + repo, + issue_number: pr.number, + body: `🤖 Auggie CI triage report (workflow run ${context.payload.workflow_run.id})\n\n${body}` + }); + } diff --git a/examples/workflows/triage-ci.yml b/examples/workflows/triage-ci.yml new file mode 100644 index 0000000..fb49c3e --- /dev/null +++ b/examples/workflows/triage-ci.yml @@ -0,0 +1,113 @@ +name: Auggie CI Triage + +on: + workflow_run: + workflows: + - CI # Update with the workflow name(s) you want Auggie to triage + types: + - completed + +jobs: + triage: + if: >- + ${{ github.event.workflow_run.conclusion == 'failure' }} + runs-on: ubuntu-latest + permissions: + contents: read + issues: write + pull-requests: write + steps: + - name: Abort when Auggie session auth is missing + if: ${{ !secrets.AUGMENT_SESSION_AUTH }} + run: | + echo "Skipping triage because AUGMENT_SESSION_AUTH is not configured." >> "$GITHUB_STEP_SUMMARY" + exit 0 + + - name: Checkout repository + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + fetch-depth: 0 + + - name: Set up Node.js 22 + uses: actions/setup-node@60edb5dd5019e0a72c57c00ac6c032d28fc096f4 # v4.1.0 + with: + node-version: '22' + + - name: Download failing workflow logs + id: download-logs + uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7 + with: + script: | + const fs = require('fs'); + const { owner, repo } = context.repo; + const runId = context.payload.workflow_run.id; + const result = await github.rest.actions.downloadWorkflowRunLogs({ + owner, + repo, + run_id: runId + }); + fs.writeFileSync('ci-logs.zip', Buffer.from(result.data)); + core.setOutput('zip-path', 'ci-logs.zip'); + + - name: Extract log bundle + run: unzip -q "${{ steps.download-logs.outputs.zip-path }}" -d ci-logs + + - name: Consolidate failing job logs + run: | + # Find all log files (txt, log formats) and concatenate with job context + find ci-logs -name '*.txt' -o -name '*.log' | while read -r logfile; do + echo "=== $(basename "$logfile") ===" >> ci-failure.log + cat "$logfile" >> ci-failure.log + echo "" >> ci-failure.log + done + + # Ensure we have some content to analyze + if [ ! -s ci-failure.log ]; then + echo "No log content found to analyze" > ci-failure.log + exit 1 + fi + + # Truncate to last 4000 lines to keep Auggie input manageable + tail -n 4000 ci-failure.log > ci-failure-tail.log + mv ci-failure-tail.log ci-failure.log + + - name: Install Auggie CLI + run: npm install -g @augmentcode/auggie + + - name: Run Auggie CI triage + env: + AUGMENT_SESSION_AUTH: ${{ secrets.AUGMENT_SESSION_AUTH }} + run: | + # Run Auggie triage and handle potential failures + if ! auggie --print "/triage-ci ci-failure.log" --quiet > triage-output.md; then + echo "⚠️ Auggie triage failed. Raw log analysis:" > triage-output.md + echo "\`\`\`" >> triage-output.md + head -n 100 ci-failure.log >> triage-output.md + echo "\`\`\`" >> triage-output.md + fi + + - name: Attach triage summary to workflow run + run: cat triage-output.md >> "$GITHUB_STEP_SUMMARY" + + - name: Upload triage artifact + uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0 + with: + name: auggie-triage-report + path: triage-output.md + + - name: Comment on related pull requests + if: ${{ github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.pull_requests }} + uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7 + with: + script: | + const fs = require('fs'); + const body = fs.readFileSync('triage-output.md', 'utf8'); + const { owner, repo } = context.repo; + for (const pr of context.payload.workflow_run.pull_requests) { + await github.rest.issues.createComment({ + owner, + repo, + issue_number: pr.number, + body: `🤖 Auggie CI triage report (workflow run ${context.payload.workflow_run.id})\n\n${body}` + }); + } From 34ea3b260eabd3e1edaa94973e38a95e0a32fca4 Mon Sep 17 00:00:00 2001 From: Francesco Gruosso <64712227+FrancescoCoding@users.noreply.github.com> Date: Sat, 27 Sep 2025 15:28:54 +0100 Subject: [PATCH 2/3] Change workflow to triage --- .github/workflows/triage-ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/triage-ci.yml b/.github/workflows/triage-ci.yml index fb49c3e..2a38bf9 100644 --- a/.github/workflows/triage-ci.yml +++ b/.github/workflows/triage-ci.yml @@ -3,7 +3,7 @@ name: Auggie CI Triage on: workflow_run: workflows: - - CI # Update with the workflow name(s) you want Auggie to triage + - on-demand-review # Update with the workflow name(s) you want Auggie to triage types: - completed @@ -31,7 +31,7 @@ jobs: - name: Set up Node.js 22 uses: actions/setup-node@60edb5dd5019e0a72c57c00ac6c032d28fc096f4 # v4.1.0 with: - node-version: '22' + node-version: "22" - name: Download failing workflow logs id: download-logs @@ -60,13 +60,13 @@ jobs: cat "$logfile" >> ci-failure.log echo "" >> ci-failure.log done - + # Ensure we have some content to analyze if [ ! -s ci-failure.log ]; then echo "No log content found to analyze" > ci-failure.log exit 1 fi - + # Truncate to last 4000 lines to keep Auggie input manageable tail -n 4000 ci-failure.log > ci-failure-tail.log mv ci-failure-tail.log ci-failure.log From 61293d064c1ec948da1eb64de176c56027228362 Mon Sep 17 00:00:00 2001 From: Francesco Gruosso <64712227+FrancescoCoding@users.noreply.github.com> Date: Sat, 27 Sep 2025 15:31:20 +0100 Subject: [PATCH 3/3] Fix condition for checking AUGMENT_SESSION_AUTH in triage CI workflow --- .github/workflows/triage-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/triage-ci.yml b/.github/workflows/triage-ci.yml index 2a38bf9..893b8ef 100644 --- a/.github/workflows/triage-ci.yml +++ b/.github/workflows/triage-ci.yml @@ -18,7 +18,7 @@ jobs: pull-requests: write steps: - name: Abort when Auggie session auth is missing - if: ${{ !secrets.AUGMENT_SESSION_AUTH }} + if: ${{ secrets.AUGMENT_SESSION_AUTH == '' }} run: | echo "Skipping triage because AUGMENT_SESSION_AUTH is not configured." >> "$GITHUB_STEP_SUMMARY" exit 0