Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

fix(ci): stop puppeteer E2E from spamming fork PRs named main (#4332)

LearningCircuit9778ade7d324
diff --git a/.github/workflows/puppeteer-e2e-tests.yml b/.github/workflows/puppeteer-e2e-tests.yml
index c4dcd72878..411b00c5ca 100644
--- a/.github/workflows/puppeteer-e2e-tests.yml
+++ b/.github/workflows/puppeteer-e2e-tests.yml
@@ -309,23 +309,36 @@ jobs:
REPO: ${{ github.repository }}
run: |
if [ "$EVENT_NAME" == "pull_request" ]; then
+ # Labeled PR run — the primary, correct path. Real branches targeting main.
echo "pr_number=$PR_NUM" >> "$GITHUB_OUTPUT"
- else
- # For workflow_dispatch/schedule, find PR from branch
- PR_NUMBER=$(gh pr list --head "$REF_NAME" --repo "$REPO" --json number --jq '.[0].number // empty')
+ elif [ "$EVENT_NAME" == "workflow_dispatch" ] && [ "$REF_NAME" != "main" ]; then
+ # Manual run on a feature branch. Map branch -> its open PR, but only a
+ # UNIQUE, SAME-REPO match: cross-repo (fork) PRs and ambiguous matches are
+ # skipped so we never post to the wrong PR (e.g. a fork PR'd from `main`).
+ PR_NUMBER=$(gh pr list --head "$REF_NAME" --state open --repo "$REPO" \
+ --json number,isCrossRepository \
+ --jq '[.[] | select(.isCrossRepository == false)]
+ | if length == 1 then .[0].number | tostring else "" end')
echo "pr_number=${PR_NUMBER}" >> "$GITHUB_OUTPUT"
+ else
+ # release.yml workflow_call (event=push) and the weekly schedule both run
+ # on the default branch. There is never a PR from main, so any
+ # `gh pr list --head main` match is a coincidental fork PR — skip
+ # entirely (results still go to the Actions step summary). See #3884.
+ echo "pr_number=" >> "$GITHUB_OUTPUT"
+ echo "event=$EVENT_NAME ref=$REF_NAME has no associated PR — skipping comment"
fi
- - name: Post test results
+ - name: Build PR comment
if: always() && steps.find-pr.outputs.pr_number != ''
# zizmor: ignore[template-injection] — env.TEST_EXIT_CODE/TESTS_PASSING/TESTS_FAILING are set by this workflow, not user input
env:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- PR_NUMBER: ${{ steps.find-pr.outputs.pr_number }}
- REPO: ${{ github.repository }}
EVENT_NAME: ${{ github.event_name }}
run: |
{
+ # Hidden marker — the "Post or update PR comment" step finds this
+ # comment by this marker so re-runs edit it in place (see #3884).
+ echo '<!-- puppeteer-e2e-results -->'
echo "## 🧪 Puppeteer E2E Test Results"
echo ""
if [ "$TEST_EXIT_CODE" == "0" ]; then
@@ -393,7 +406,48 @@ jobs:
echo "_Triggered by: \`${EVENT_NAME}\` (label: \`${LABEL_NAME}\`)_"
} > comment.md
- gh pr comment "$PR_NUMBER" --repo "$REPO" -F comment.md
+ - name: Post or update PR comment
+ if: always() && steps.find-pr.outputs.pr_number != ''
+ continue-on-error: true # required release gate must not fail on a GitHub API hiccup
+ uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
+ env:
+ PR_NUMBER: ${{ steps.find-pr.outputs.pr_number }}
+ with:
+ retries: 3
+ script: |
+ const fs = require('fs');
+ const issue_number = Number(process.env.PR_NUMBER);
+ const marker = '<!-- puppeteer-e2e-results -->';
+ const body = fs.readFileSync('comment.md', 'utf8');
+
+ // Paginate — on a long-lived PR the existing comment may be past the
+ // first page (default 30), which would otherwise create a new comment
+ // every run and reintroduce the spam this fix removes (#3884).
+ const comments = await github.paginate(github.rest.issues.listComments, {
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ issue_number,
+ per_page: 100,
+ });
+ const existing = comments.find(
+ (c) => c.user.type === 'Bot' && c.body.includes(marker)
+ );
+
+ if (existing) {
+ await github.rest.issues.updateComment({
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ comment_id: existing.id,
+ body,
+ });
+ } else {
+ await github.rest.issues.createComment({
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ issue_number,
+ body,
+ });
+ }
- name: Remove label for re-triggering
if: always() && github.event_name == 'pull_request'