ci: use Crabbox media previews for Mantis

This commit is contained in:
Peter Steinberger
2026-05-05 07:53:46 +01:00
parent 0e7073ad89
commit cbcca6e55f
2 changed files with 51 additions and 25 deletions

View File

@@ -411,23 +411,23 @@ jobs:
local lane="$1"
local input="$root/$lane/discord-status-reactions-tool-only-desktop.mp4"
local output="$root/$lane/discord-status-reactions-tool-only-desktop-preview.gif"
local palette="$root/$lane/discord-status-reactions-tool-only-desktop-preview-palette.png"
ffmpeg -y -i "$input" -vf "fps=4,scale=640:-1:flags=lanczos,palettegen=stats_mode=diff" -frames:v 1 -update 1 "$palette"
ffmpeg -y -i "$input" -i "$palette" -lavfi "fps=4,scale=640:-1:flags=lanczos[x];[x][1:v]paletteuse=dither=bayer:bayer_scale=3:diff_mode=rectangle" -loop 0 "$output"
rm -f "$palette"
local clip="$root/$lane/discord-status-reactions-tool-only-desktop-change.mp4"
local metadata="$root/$lane/discord-status-reactions-tool-only-desktop-preview.json"
crabbox media preview \
--input "$input" \
--output "$output" \
--trimmed-video-output "$clip" \
--json > "$metadata"
}
if ! command -v ffmpeg >/dev/null 2>&1; then
sudo apt-get update && sudo apt-get install -y ffmpeg || true
fi
if command -v ffmpeg >/dev/null 2>&1; then
if ! make_desktop_preview baseline || ! make_desktop_preview candidate; then
rm -f "$root/baseline/discord-status-reactions-tool-only-desktop-preview.gif"
rm -f "$root/candidate/discord-status-reactions-tool-only-desktop-preview.gif"
echo "::warning::Could not generate animated desktop previews; continuing with screenshots and MP4 links."
fi
else
echo "::warning::ffmpeg is unavailable; skipping animated desktop previews."
if ! make_desktop_preview baseline || ! make_desktop_preview candidate; then
rm -f "$root/baseline/discord-status-reactions-tool-only-desktop-preview.gif"
rm -f "$root/candidate/discord-status-reactions-tool-only-desktop-preview.gif"
rm -f "$root/baseline/discord-status-reactions-tool-only-desktop-change.mp4"
rm -f "$root/candidate/discord-status-reactions-tool-only-desktop-change.mp4"
rm -f "$root/baseline/discord-status-reactions-tool-only-desktop-preview.json"
rm -f "$root/candidate/discord-status-reactions-tool-only-desktop-preview.json"
echo "::warning::Could not generate motion-trimmed desktop previews; continuing with screenshots and full MP4 links."
fi
baseline_status="$(jq -r '.scenarios[0].status' "$root/baseline/discord-qa-summary.json")"
@@ -461,6 +461,12 @@ jobs:
if [[ -f "$root/candidate/discord-status-reactions-tool-only-desktop-preview.gif" ]]; then
echo "- Candidate desktop preview: \`candidate/discord-status-reactions-tool-only-desktop-preview.gif\`"
fi
if [[ -f "$root/baseline/discord-status-reactions-tool-only-desktop-change.mp4" ]]; then
echo "- Baseline desktop change clip: \`baseline/discord-status-reactions-tool-only-desktop-change.mp4\`"
fi
if [[ -f "$root/candidate/discord-status-reactions-tool-only-desktop-change.mp4" ]]; then
echo "- Candidate desktop change clip: \`candidate/discord-status-reactions-tool-only-desktop-change.mp4\`"
fi
echo "- Baseline desktop video: \`baseline/discord-status-reactions-tool-only-desktop.mp4\`"
echo "- Candidate desktop video: \`candidate/discord-status-reactions-tool-only-desktop.mp4\`"
} > "$root/mantis-report.md"
@@ -499,7 +505,7 @@ jobs:
permission-issues: write
permission-pull-requests: write
- name: Comment PR with inline QA screenshots
- name: Comment PR with inline QA evidence
if: ${{ always() && needs.resolve_request.outputs.pr_number != '' && steps.run_mantis.outputs.output_dir != '' }}
env:
GH_TOKEN: ${{ steps.mantis_app_token.outputs.token }}
@@ -557,8 +563,16 @@ jobs:
if [[ -f "$root/baseline/discord-status-reactions-tool-only-desktop-preview.gif" && -f "$root/candidate/discord-status-reactions-tool-only-desktop-preview.gif" ]]; then
cp "$root/baseline/discord-status-reactions-tool-only-desktop-preview.gif" "$artifacts_worktree/$artifact_root/baseline-desktop-preview.gif"
cp "$root/candidate/discord-status-reactions-tool-only-desktop-preview.gif" "$artifacts_worktree/$artifact_root/candidate-desktop-preview.gif"
cp "$root/baseline/discord-status-reactions-tool-only-desktop-preview.json" "$artifacts_worktree/$artifact_root/baseline-desktop-preview.json"
cp "$root/candidate/discord-status-reactions-tool-only-desktop-preview.json" "$artifacts_worktree/$artifact_root/candidate-desktop-preview.json"
has_desktop_previews="true"
fi
has_change_clips="false"
if [[ -f "$root/baseline/discord-status-reactions-tool-only-desktop-change.mp4" && -f "$root/candidate/discord-status-reactions-tool-only-desktop-change.mp4" ]]; then
cp "$root/baseline/discord-status-reactions-tool-only-desktop-change.mp4" "$artifacts_worktree/$artifact_root/baseline-desktop-change.mp4"
cp "$root/candidate/discord-status-reactions-tool-only-desktop-change.mp4" "$artifacts_worktree/$artifact_root/candidate-desktop-change.mp4"
has_change_clips="true"
fi
cp "$root/baseline/discord-status-reactions-tool-only-desktop.mp4" "$artifacts_worktree/$artifact_root/baseline-desktop.mp4"
cp "$root/candidate/discord-status-reactions-tool-only-desktop.mp4" "$artifacts_worktree/$artifact_root/candidate-desktop.mp4"
cp "$root/comparison.json" "$artifacts_worktree/$artifact_root/comparison.json"
@@ -581,12 +595,22 @@ jobs:
if [[ "$has_desktop_previews" == "true" ]]; then
preview_section="$(cat <<EOF
| Baseline animated preview | Candidate animated preview |
| Baseline motion preview | Candidate motion preview |
| --- | --- |
| <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"> |
EOF
)"
fi
change_clip_section=""
if [[ "$has_change_clips" == "true" ]]; then
change_clip_section="$(cat <<EOF
Motion-trimmed clips:
- [Baseline change MP4](${raw_base}/baseline-desktop-change.mp4)
- [Candidate change MP4](${raw_base}/candidate-desktop-change.mp4)
EOF
)"
fi
comment_file="$(mktemp)"
cat > "$comment_file" <<EOF
<!-- mantis-discord-status-reactions -->
@@ -610,6 +634,7 @@ jobs:
| --- | --- |
| <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"> |
${preview_section}
${change_clip_section}
Full videos:
- [Baseline desktop MP4](${raw_base}/baseline-desktop.mp4)
@@ -628,13 +653,13 @@ jobs:
comment_payload="$(mktemp)"
jq -n --rawfile body "$comment_file" '{ body: $body }' > "$comment_payload"
if gh api --method PATCH "repos/${GITHUB_REPOSITORY}/issues/comments/${comment_id}" --input "$comment_payload" >/dev/null; then
echo "Updated Mantis QA screenshot comment on PR #${TARGET_PR}."
echo "Updated Mantis QA evidence comment on PR #${TARGET_PR}."
else
echo "::warning::Could not update existing Mantis QA screenshot comment ${comment_id}; creating a new one."
echo "::warning::Could not update existing Mantis QA evidence comment ${comment_id}; creating a new one."
gh pr comment "$TARGET_PR" --body-file "$comment_file"
echo "Created Mantis QA screenshot comment on PR #${TARGET_PR}."
echo "Created Mantis QA evidence comment on PR #${TARGET_PR}."
fi
else
gh pr comment "$TARGET_PR" --body-file "$comment_file"
echo "Created Mantis QA screenshot comment on PR #${TARGET_PR}."
echo "Created Mantis QA evidence comment on PR #${TARGET_PR}."
fi