@@ -420,6 +420,9 @@ jobs:
420420 --json > "$metadata"
421421 }
422422
423+ if ! command -v ffmpeg >/dev/null 2>&1 || ! command -v ffprobe >/dev/null 2>&1; then
424+ sudo apt-get update && sudo apt-get install -y ffmpeg || true
425+ fi
423426 if ! make_desktop_preview baseline || ! make_desktop_preview candidate; then
424427 rm -f "$root/baseline/discord-status-reactions-tool-only-desktop-preview.gif"
425428 rm -f "$root/candidate/discord-status-reactions-tool-only-desktop-preview.gif"
@@ -471,6 +474,40 @@ jobs:
471474 echo "- Candidate desktop video: \`candidate/discord-status-reactions-tool-only-desktop.mp4\`"
472475 } > "$root/mantis-report.md"
473476
477+ jq -n \
478+ --arg baseline_status "$baseline_status" \
479+ --arg candidate_status "$candidate_status" \
480+ --arg baseline_sha "${{ needs.validate_refs.outputs.baseline_revision }}" \
481+ --arg candidate_sha "${{ needs.validate_refs.outputs.candidate_revision }}" \
482+ '{
483+ schemaVersion: 1,
484+ id: "discord-status-reactions",
485+ title: "Mantis Discord Status Reactions QA",
486+ summary: "Mantis reran Discord status reactions against the known queued-only baseline and the candidate ref. The baseline reproduced the bug, while the candidate showed the expected queued -> thinking -> done reaction sequence.",
487+ scenario: "discord-status-reactions-tool-only",
488+ comparison: {
489+ baseline: { sha: $baseline_sha, expected: "queued-only", status: $baseline_status, reproduced: ($baseline_status == "fail") },
490+ candidate: { sha: $candidate_sha, expected: "queued -> thinking -> done", status: $candidate_status, fixed: ($candidate_status == "pass") },
491+ pass: (($baseline_status == "fail") and ($candidate_status == "pass"))
492+ },
493+ artifacts: [
494+ { kind: "timeline", lane: "baseline", label: "Baseline queued-only", path: "baseline/discord-status-reactions-tool-only-timeline.png", targetPath: "baseline.png", alt: "Baseline Discord status reaction timeline", width: 420 },
495+ { kind: "timeline", lane: "candidate", label: "Candidate queued -> thinking -> done", path: "candidate/discord-status-reactions-tool-only-timeline.png", targetPath: "candidate.png", alt: "Candidate Discord status reaction timeline", width: 420 },
496+ { kind: "desktopScreenshot", lane: "baseline", label: "Baseline desktop/VNC browser", path: "baseline/discord-status-reactions-tool-only-desktop.png", targetPath: "baseline-desktop.png", alt: "Baseline Mantis desktop browser screenshot", width: 420 },
497+ { kind: "desktopScreenshot", lane: "candidate", label: "Candidate desktop/VNC browser", path: "candidate/discord-status-reactions-tool-only-desktop.png", targetPath: "candidate-desktop.png", alt: "Candidate Mantis desktop browser screenshot", width: 420 },
498+ { kind: "motionPreview", lane: "baseline", label: "Baseline motion preview", path: "baseline/discord-status-reactions-tool-only-desktop-preview.gif", targetPath: "baseline-desktop-preview.gif", alt: "Animated baseline desktop preview", width: 420, required: false },
499+ { kind: "motionPreview", lane: "candidate", label: "Candidate motion preview", path: "candidate/discord-status-reactions-tool-only-desktop-preview.gif", targetPath: "candidate-desktop-preview.gif", alt: "Animated candidate desktop preview", width: 420, required: false },
500+ { kind: "motionClip", lane: "baseline", label: "Baseline change MP4", path: "baseline/discord-status-reactions-tool-only-desktop-change.mp4", targetPath: "baseline-desktop-change.mp4", required: false },
501+ { kind: "motionClip", lane: "candidate", label: "Candidate change MP4", path: "candidate/discord-status-reactions-tool-only-desktop-change.mp4", targetPath: "candidate-desktop-change.mp4", required: false },
502+ { kind: "fullVideo", lane: "baseline", label: "Baseline desktop MP4", path: "baseline/discord-status-reactions-tool-only-desktop.mp4", targetPath: "baseline-desktop.mp4" },
503+ { kind: "fullVideo", lane: "candidate", label: "Candidate desktop MP4", path: "candidate/discord-status-reactions-tool-only-desktop.mp4", targetPath: "candidate-desktop.mp4" },
504+ { kind: "metadata", lane: "baseline", label: "Baseline preview metadata", path: "baseline/discord-status-reactions-tool-only-desktop-preview.json", targetPath: "baseline-desktop-preview.json", required: false },
505+ { kind: "metadata", lane: "candidate", label: "Candidate preview metadata", path: "candidate/discord-status-reactions-tool-only-desktop-preview.json", targetPath: "candidate-desktop-preview.json", required: false },
506+ { kind: "metadata", lane: "run", label: "Comparison JSON", path: "comparison.json", targetPath: "comparison.json" },
507+ { kind: "report", lane: "run", label: "Mantis report", path: "mantis-report.md", targetPath: "mantis-report.md" }
508+ ]
509+ }' > "$root/mantis-evidence.json"
510+
474511 cat "$root/mantis-report.md" >> "$GITHUB_STEP_SUMMARY"
475512
476513 if [[ "$baseline_status" != "fail" ]]; then
@@ -511,155 +548,17 @@ jobs:
511548 GH_TOKEN : ${{ steps.mantis_app_token.outputs.token }}
512549 TARGET_PR : ${{ needs.resolve_request.outputs.pr_number }}
513550 ARTIFACT_URL : ${{ steps.upload_artifact.outputs.artifact-url }}
514- BASELINE_SHA : ${{ needs.validate_refs.outputs.baseline_revision }}
515- CANDIDATE_SHA : ${{ needs.validate_refs.outputs.candidate_revision }}
516551 REQUEST_SOURCE : ${{ needs.resolve_request.outputs.request_source }}
517552 shell : bash
518553 run : |
519554 set -euo pipefail
520555
521- if [[ ! "$TARGET_PR" =~ ^[0-9]+$ ]]; then
522- echo "pr_number must be numeric, got '${TARGET_PR}'." >&2
523- exit 1
524- fi
525-
526556 root=".artifacts/qa-e2e/mantis/discord-status-reactions"
527- for required in \
528- "$root/comparison.json" \
529- "$root/baseline/discord-status-reactions-tool-only-timeline.png" \
530- "$root/candidate/discord-status-reactions-tool-only-timeline.png" \
531- "$root/baseline/discord-status-reactions-tool-only-desktop.png" \
532- "$root/candidate/discord-status-reactions-tool-only-desktop.png" \
533- "$root/baseline/discord-status-reactions-tool-only-desktop.mp4" \
534- "$root/candidate/discord-status-reactions-tool-only-desktop.mp4"
535- do
536- if [[ ! -f "$required" ]]; then
537- echo "Missing required QA evidence file: $required" >&2
538- exit 1
539- fi
540- done
541-
542- gh api "repos/${GITHUB_REPOSITORY}/pulls/${TARGET_PR}" --jq '.number' >/dev/null
543-
544- artifact_root="mantis/discord-status-reactions/pr-${TARGET_PR}/run-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}"
545- artifacts_worktree="$(mktemp -d)"
546- git init --quiet "$artifacts_worktree"
547- git -C "$artifacts_worktree" config user.name "github-actions[bot]"
548- git -C "$artifacts_worktree" config user.email "41898282+github-actions[bot]@users.noreply.github.com"
549- git -C "$artifacts_worktree" remote add origin "https://x-access-token:${GH_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
550-
551- if git -C "$artifacts_worktree" fetch --quiet origin qa-artifacts; then
552- git -C "$artifacts_worktree" checkout --quiet -B qa-artifacts FETCH_HEAD
553- else
554- git -C "$artifacts_worktree" checkout --quiet --orphan qa-artifacts
555- fi
556-
557- mkdir -p "$artifacts_worktree/$artifact_root"
558- cp "$root/baseline/discord-status-reactions-tool-only-timeline.png" "$artifacts_worktree/$artifact_root/baseline.png"
559- cp "$root/candidate/discord-status-reactions-tool-only-timeline.png" "$artifacts_worktree/$artifact_root/candidate.png"
560- cp "$root/baseline/discord-status-reactions-tool-only-desktop.png" "$artifacts_worktree/$artifact_root/baseline-desktop.png"
561- cp "$root/candidate/discord-status-reactions-tool-only-desktop.png" "$artifacts_worktree/$artifact_root/candidate-desktop.png"
562- has_desktop_previews="false"
563- if [[ -f "$root/baseline/discord-status-reactions-tool-only-desktop-preview.gif" && -f "$root/candidate/discord-status-reactions-tool-only-desktop-preview.gif" ]]; then
564- cp "$root/baseline/discord-status-reactions-tool-only-desktop-preview.gif" "$artifacts_worktree/$artifact_root/baseline-desktop-preview.gif"
565- cp "$root/candidate/discord-status-reactions-tool-only-desktop-preview.gif" "$artifacts_worktree/$artifact_root/candidate-desktop-preview.gif"
566- cp "$root/baseline/discord-status-reactions-tool-only-desktop-preview.json" "$artifacts_worktree/$artifact_root/baseline-desktop-preview.json"
567- cp "$root/candidate/discord-status-reactions-tool-only-desktop-preview.json" "$artifacts_worktree/$artifact_root/candidate-desktop-preview.json"
568- has_desktop_previews="true"
569- fi
570- has_change_clips="false"
571- if [[ -f "$root/baseline/discord-status-reactions-tool-only-desktop-change.mp4" && -f "$root/candidate/discord-status-reactions-tool-only-desktop-change.mp4" ]]; then
572- cp "$root/baseline/discord-status-reactions-tool-only-desktop-change.mp4" "$artifacts_worktree/$artifact_root/baseline-desktop-change.mp4"
573- cp "$root/candidate/discord-status-reactions-tool-only-desktop-change.mp4" "$artifacts_worktree/$artifact_root/candidate-desktop-change.mp4"
574- has_change_clips="true"
575- fi
576- cp "$root/baseline/discord-status-reactions-tool-only-desktop.mp4" "$artifacts_worktree/$artifact_root/baseline-desktop.mp4"
577- cp "$root/candidate/discord-status-reactions-tool-only-desktop.mp4" "$artifacts_worktree/$artifact_root/candidate-desktop.mp4"
578- cp "$root/comparison.json" "$artifacts_worktree/$artifact_root/comparison.json"
579- cp "$root/mantis-report.md" "$artifacts_worktree/$artifact_root/mantis-report.md"
580-
581- git -C "$artifacts_worktree" add "$artifact_root"
582- if git -C "$artifacts_worktree" diff --cached --quiet; then
583- echo "No QA screenshot/video artifact changes to publish."
584- else
585- git -C "$artifacts_worktree" commit --quiet -m "qa: publish Mantis Discord evidence for PR ${TARGET_PR}"
586- git -C "$artifacts_worktree" push --quiet origin HEAD:qa-artifacts
587- fi
588-
589- encoded_artifact_root="${artifact_root// /%20}"
590- raw_base="https://raw.githubusercontent.com/${GITHUB_REPOSITORY}/qa-artifacts/${encoded_artifact_root}"
591- baseline_status="$(jq -r '.baseline.status' "$root/comparison.json")"
592- candidate_status="$(jq -r '.candidate.status' "$root/comparison.json")"
593- pass="$(jq -r '.pass' "$root/comparison.json")"
594- preview_section=""
595- if [[ "$has_desktop_previews" == "true" ]]; then
596- preview_section="$(cat <<EOF
597-
598- | Baseline motion preview | Candidate motion preview |
599- | --- | --- |
600- | <img src="${raw_base}/baseline-desktop-preview.gif" width="420" alt="Animated baseline desktop preview"> | <img src="${raw_base}/candidate-desktop-preview.gif" width="420" alt="Animated candidate desktop preview"> |
601- EOF
602- )"
603- fi
604- change_clip_section=""
605- if [[ "$has_change_clips" == "true" ]]; then
606- change_clip_section="$(cat <<EOF
607-
608- Motion-trimmed clips:
609- - [Baseline change MP4](${raw_base}/baseline-desktop-change.mp4)
610- - [Candidate change MP4](${raw_base}/candidate-desktop-change.mp4)
611- EOF
612- )"
613- fi
614- comment_file="$(mktemp)"
615- cat > "$comment_file" <<EOF
616- <!-- mantis-discord-status-reactions -->
617- ## Mantis Discord Status Reactions QA
618-
619- Summary: Mantis reran Discord status reactions against the known queued-only baseline and the candidate ref. The baseline reproduced the bug, while the candidate showed the expected queued -> thinking -> done reaction sequence.
620-
621- - Scenario: \`discord-status-reactions-tool-only\`
622- - Trigger: \`${REQUEST_SOURCE}\`
623- - Run: https://github.com/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}
624- - Artifact: ${ARTIFACT_URL}
625- - Baseline: \`${baseline_status}\` at \`${BASELINE_SHA}\`
626- - Candidate: \`${candidate_status}\` at \`${CANDIDATE_SHA}\`
627- - Overall: \`${pass}\`
628-
629- | Baseline queued-only | Candidate queued -> thinking -> done |
630- | --- | --- |
631- | <img src="${raw_base}/baseline.png" width="420" alt="Baseline Discord status reaction timeline"> | <img src="${raw_base}/candidate.png" width="420" alt="Candidate Discord status reaction timeline"> |
632-
633- | Baseline desktop/VNC browser | Candidate desktop/VNC browser |
634- | --- | --- |
635- | <img src="${raw_base}/baseline-desktop.png" width="420" alt="Baseline Mantis desktop browser screenshot"> | <img src="${raw_base}/candidate-desktop.png" width="420" alt="Candidate Mantis desktop browser screenshot"> |
636- ${preview_section}
637- ${change_clip_section}
638-
639- Full videos:
640- - [Baseline desktop MP4](${raw_base}/baseline-desktop.mp4)
641- - [Candidate desktop MP4](${raw_base}/candidate-desktop.mp4)
642-
643- Raw QA files: https://github.com/${GITHUB_REPOSITORY}/tree/qa-artifacts/${artifact_root}
644- EOF
645-
646- comment_id="$(
647- gh api --paginate "repos/${GITHUB_REPOSITORY}/issues/${TARGET_PR}/comments" \
648- --jq '.[] | select(.body | contains("<!-- mantis-discord-status-reactions -->")) | .id' \
649- | tail -n 1
650- )"
651-
652- if [[ -n "$comment_id" ]]; then
653- comment_payload="$(mktemp)"
654- jq -n --rawfile body "$comment_file" '{ body: $body }' > "$comment_payload"
655- if gh api --method PATCH "repos/${GITHUB_REPOSITORY}/issues/comments/${comment_id}" --input "$comment_payload" >/dev/null; then
656- echo "Updated Mantis QA evidence comment on PR #${TARGET_PR}."
657- else
658- echo "::warning::Could not update existing Mantis QA evidence comment ${comment_id}; creating a new one."
659- gh pr comment "$TARGET_PR" --body-file "$comment_file"
660- echo "Created Mantis QA evidence comment on PR #${TARGET_PR}."
661- fi
662- else
663- gh pr comment "$TARGET_PR" --body-file "$comment_file"
664- echo "Created Mantis QA evidence comment on PR #${TARGET_PR}."
665- fi
557+ node scripts/mantis/publish-pr-evidence.mjs \
558+ --manifest "$root/mantis-evidence.json" \
559+ --target-pr "$TARGET_PR" \
560+ --artifact-root "mantis/discord-status-reactions/pr-${TARGET_PR}/run-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}" \
561+ --marker "<!-- mantis-discord-status-reactions -->" \
562+ --artifact-url "$ARTIFACT_URL" \
563+ --run-url "https://github.com/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}" \
564+ --request-source "$REQUEST_SOURCE"
0 commit comments