From 421dbd6922620e826160a0dc87d7d60b7c7f864b Mon Sep 17 00:00:00 2001 From: Thulasidharan V S Date: Fri, 11 Sep 2026 18:52:28 +0530 Subject: [PATCH 1/6] fix folder structure --- retrace-classify.yml => .github/workflows/retrace-classify.yml | 0 checkout.test.js => tests/checkout.test.js | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename retrace-classify.yml => .github/workflows/retrace-classify.yml (100%) rename checkout.test.js => tests/checkout.test.js (100%) diff --git a/retrace-classify.yml b/.github/workflows/retrace-classify.yml similarity index 100% rename from retrace-classify.yml rename to .github/workflows/retrace-classify.yml diff --git a/checkout.test.js b/tests/checkout.test.js similarity index 100% rename from checkout.test.js rename to tests/checkout.test.js From edb8b580b1faa61aa7867c92169845a9b9523269 Mon Sep 17 00:00:00 2001 From: Thulasidharan V S <76160415+thuluxx@users.noreply.github.com> Date: Mon, 14 Sep 2026 19:07:35 +0530 Subject: [PATCH 2/6] Fix Retrace workflow on test branch --- .github/workflows/retrace-classify.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/retrace-classify.yml b/.github/workflows/retrace-classify.yml index fd6542a..6c27578 100644 --- a/.github/workflows/retrace-classify.yml +++ b/.github/workflows/retrace-classify.yml @@ -18,7 +18,7 @@ jobs: node-version: 20 - name: Install dependencies - run: npm ci + run: npm install - name: Run tests id: run_tests From 8b52fbe092c10bf4791aab070a14a5c9745acb9a Mon Sep 17 00:00:00 2001 From: Thulasidharan V S <76160415+thuluxx@users.noreply.github.com> Date: Mon, 14 Sep 2026 19:10:04 +0530 Subject: [PATCH 3/6] Fix Retrace workflow on test branch-realrealreal --- .github/workflows/retrace-classify.yml | 37 +++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/.github/workflows/retrace-classify.yml b/.github/workflows/retrace-classify.yml index 6c27578..0139f75 100644 --- a/.github/workflows/retrace-classify.yml +++ b/.github/workflows/retrace-classify.yml @@ -1,3 +1,19 @@ +# Retrace CI integration +# +# Drop this file into a repo at: .github/workflows/retrace-classify.yml +# +# What it does: +# 1. Runs your test suite. +# 2. If tests fail, grabs the failure log. +# 3. Sends the log to your deployed Retrace API (/classify). +# 4. Posts the classification (cause, confidence, reasoning) as a PR comment. +# +# Requirements: +# - RETRACE_API_URL: set as a repo variable (Settings > Secrets and variables > +# Actions > Variables), e.g. https://your-retrace-backend.onrender.com/classify +# - No extra secrets needed for posting the comment — GITHUB_TOKEN is provided +# automatically by GitHub Actions. + name: Retrace failure classification on: @@ -9,6 +25,7 @@ jobs: permissions: pull-requests: write contents: read + steps: - uses: actions/checkout@v4 @@ -30,19 +47,31 @@ jobs: id: classify run: | LOG_CONTENT=$(tail -c 8000 test-output.log | python3 -c "import json,sys; print(json.dumps(sys.stdin.read()))") - RESPONSE=$(curl -s -X POST "${{ vars.RETRACE_API_URL }}" \ + + RESPONSE=$(curl -sS -X POST "${{ vars.RETRACE_API_URL }}" \ -H "Content-Type: application/json" \ -d "{\"log\": $LOG_CONTENT}") + + echo "Retrace response:" + echo "$RESPONSE" + echo "response=$RESPONSE" >> "$GITHUB_OUTPUT" - name: Post classification as PR comment if: steps.run_tests.outcome == 'failure' uses: actions/github-script@v7 + env: + RETRACE_RESPONSE: ${{ steps.classify.outputs.response }} with: script: | - const response = JSON.parse(`${{ steps.classify.outputs.response }}`); - const body = `**Retrace classification:** \`${response.cause}\` (${Math.round(response.confidence * 100)}% confidence)\n\n${response.reasoning}`; - github.rest.issues.createComment({ + const response = JSON.parse(process.env.RETRACE_RESPONSE); + + const body = + `**Retrace classification:** \`${response.cause}\` ` + + `(${Math.round(response.confidence * 100)}% confidence)\n\n` + + response.reasoning; + + await github.rest.issues.createComment({ owner: context.repo.owner, repo: context.repo.repo, issue_number: context.issue.number, From 9ddbb4bbaaaab22fda3d7ec997f5d3346e67096d Mon Sep 17 00:00:00 2001 From: Thulasidharan V S <76160415+thuluxx@users.noreply.github.com> Date: Mon, 14 Sep 2026 19:17:35 +0530 Subject: [PATCH 4/6] Fix formatting in retrace-classify.yml --- .github/workflows/retrace-classify.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/retrace-classify.yml b/.github/workflows/retrace-classify.yml index 0139f75..ec87933 100644 --- a/.github/workflows/retrace-classify.yml +++ b/.github/workflows/retrace-classify.yml @@ -35,7 +35,7 @@ jobs: node-version: 20 - name: Install dependencies - run: npm install + run: npm install - name: Run tests id: run_tests From ee44642a29d44683349c03e3cd8839f4021ff9ea Mon Sep 17 00:00:00 2001 From: Thulasidharan V S <76160415+thuluxx@users.noreply.github.com> Date: Mon, 14 Sep 2026 19:23:53 +0530 Subject: [PATCH 5/6] Update README with Retrace CI test information Added a note about Retrace CI test to README. --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7d0fd0b..7fbe301 100644 --- a/README.md +++ b/README.md @@ -2,5 +2,6 @@ Minimal repo used to test the Retrace GitHub Actions integration (`.github/workflows/retrace-classify.yml`). The test in `tests/checkout.test.js` -fails on purpose so the workflow has something to classify. -..... \ No newline at end of file +fails on purpose so the workflow has something to classify. +Retrace CI test +..... From 8e61abd9ac4bbcf1820ed9313837690ffe2a6d54 Mon Sep 17 00:00:00 2001 From: Thulasidharan V S <76160415+thuluxx@users.noreply.github.com> Date: Mon, 14 Sep 2026 19:34:23 +0530 Subject: [PATCH 6/6] Fix test failure detection --- .github/workflows/retrace-classify.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/retrace-classify.yml b/.github/workflows/retrace-classify.yml index d2be0de..322280b 100644 --- a/.github/workflows/retrace-classify.yml +++ b/.github/workflows/retrace-classify.yml @@ -23,7 +23,9 @@ jobs: - name: Run tests id: run_tests - run: npm test 2>&1 | tee test-output.log + run: | + set -o pipefail + npm test 2>&1 | tee test-output.log continue-on-error: true - name: Classify failure with Retrace