Skip to content

Commit db57e09

Browse files
committed
ci: publish Midscene reports to Pages
1 parent b50ee50 commit db57e09

4 files changed

Lines changed: 147 additions & 1 deletion

File tree

‎.github/workflows/midscene-e2e.yml‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
name: Midscene E2E · Ubuntu 22.04
2+
run-name: Ubuntu 22.04 · Midscene E2E
23

34
on:
45
push:
@@ -80,3 +81,30 @@ jobs:
8081
path: tests/midscene/midscene_run/
8182
if-no-files-found: warn
8283
retention-days: 7
84+
85+
publish-report:
86+
name: Publish HTML report
87+
if: ${{ always() }}
88+
needs: ubuntu-gtk
89+
runs-on: ubuntu-22.04
90+
permissions:
91+
contents: write
92+
concurrency:
93+
group: midscene-report-pages
94+
cancel-in-progress: false
95+
steps:
96+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
97+
with:
98+
persist-credentials: false
99+
100+
- name: Download Midscene report
101+
continue-on-error: true
102+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
103+
with:
104+
name: midscene-ubuntu-22.04-e2e-report
105+
path: .midscene-report
106+
107+
- name: Publish report and add direct link to summary
108+
env:
109+
PAGES_TOKEN: ${{ github.token }}
110+
run: tests/midscene/publish-report.sh ubuntu-22.04 .midscene-report

‎.github/workflows/midscene-experimental.yml‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
name: Midscene E2E · Omarchy 4.0.3
2+
run-name: Omarchy 4.0.3 · Midscene E2E
23

34
on: workflow_dispatch
45

@@ -94,3 +95,30 @@ jobs:
9495
path: tests/midscene/midscene_run/
9596
if-no-files-found: warn
9697
retention-days: 7
98+
99+
publish-report:
100+
name: Publish HTML report
101+
if: ${{ always() }}
102+
needs: omarchy-vm
103+
runs-on: ubuntu-latest
104+
permissions:
105+
contents: write
106+
concurrency:
107+
group: midscene-report-pages
108+
cancel-in-progress: false
109+
steps:
110+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
111+
with:
112+
persist-credentials: false
113+
114+
- name: Download Midscene report
115+
continue-on-error: true
116+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
117+
with:
118+
name: omarchy-midscene-e2e-report
119+
path: .midscene-report
120+
121+
- name: Publish report and add direct link to summary
122+
env:
123+
PAGES_TOKEN: ${{ github.token }}
124+
run: tests/midscene/publish-report.sh omarchy-4.0.3 .midscene-report

‎tests/midscene/README.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ paste, or user-settings read. Midscene verifies the automatic transition to the
5454
microphone step, visually navigates to the shortcut page, runs the fake endpoint
5555
check, verifies its visible feedback, continues to the voice page, checks that
5656
navigation reset the scroll position, and completes setup. The HTML replay is
57-
uploaded for every run.
57+
uploaded as a private workflow artifact for every run and published publicly to
58+
GitHub Pages. Each workflow summary links directly to that run's interactive
59+
HTML report; exact links for the five newest runs per distribution are retained.
5860

5961
The AI stage needs a multimodal model credential. Its `MIDSCENE_MODEL_*`
6062
configuration is stored only as GitHub Actions Secrets; tests contain only

‎tests/midscene/publish-report.sh‎

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
readonly DISTRO_SLUG="${1:?distribution slug is required}"
5+
readonly ARTIFACT_DIR="${2:?artifact directory is required}"
6+
7+
case "$DISTRO_SLUG" in
8+
ubuntu-22.04|omarchy-4.0.3) ;;
9+
*)
10+
echo "Unsupported distribution slug: $DISTRO_SLUG" >&2
11+
exit 1
12+
;;
13+
esac
14+
15+
if [[ -z "${PAGES_TOKEN:-}" || -z "${GITHUB_REPOSITORY:-}" ||
16+
-z "${GITHUB_RUN_ID:-}" ]]; then
17+
echo "GitHub Pages publishing environment is incomplete" >&2
18+
exit 1
19+
fi
20+
21+
report="$(find "$ARTIFACT_DIR" -type f -name '*.html' -print -quit 2>/dev/null || true)"
22+
if [[ -z "$report" ]]; then
23+
echo "### Midscene HTML report" >> "$GITHUB_STEP_SUMMARY"
24+
echo "No HTML report was generated for this run." >> "$GITHUB_STEP_SUMMARY"
25+
exit 0
26+
fi
27+
28+
site_dir="$(mktemp -d)"
29+
trap 'rm -rf -- "$site_dir"' EXIT
30+
remote="https://x-access-token:${PAGES_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
31+
32+
if ! git clone --quiet --depth 1 --branch gh-pages "$remote" "$site_dir"; then
33+
rm -rf -- "$site_dir"
34+
mkdir -p "$site_dir"
35+
git -C "$site_dir" init --quiet --initial-branch=gh-pages
36+
git -C "$site_dir" remote add origin "$remote"
37+
fi
38+
39+
runs_dir="$site_dir/midscene/$DISTRO_SLUG/runs"
40+
run_dir="$runs_dir/$GITHUB_RUN_ID"
41+
mkdir -p "$run_dir"
42+
cp "$report" "$run_dir/index.html"
43+
cp "$report" "$site_dir/midscene/$DISTRO_SLUG/index.html"
44+
touch "$site_dir/.nojekyll"
45+
46+
# Keep exact links for the five newest runs of each distribution. The stable
47+
# distribution URL above always points to its latest report.
48+
while IFS= read -r old_run; do
49+
[[ "$old_run" =~ ^[0-9]+$ ]] || continue
50+
rm -rf -- "$runs_dir/$old_run"
51+
done < <(find "$runs_dir" -mindepth 1 -maxdepth 1 -type d -printf '%f\n' |
52+
sort -nr | tail -n +6)
53+
54+
cat > "$site_dir/index.html" <<'EOF'
55+
<!doctype html>
56+
<html lang="en">
57+
<head>
58+
<meta charset="utf-8">
59+
<meta name="viewport" content="width=device-width, initial-scale=1">
60+
<title>Doubao Say · Midscene E2E reports</title>
61+
</head>
62+
<body>
63+
<main>
64+
<h1>Doubao Say · Midscene E2E reports</h1>
65+
<p>These synthetic test reports and their screenshots are public.</p>
66+
<ul>
67+
<li><a href="midscene/ubuntu-22.04/">Ubuntu 22.04 · latest</a></li>
68+
<li><a href="midscene/omarchy-4.0.3/">Omarchy 4.0.3 · latest</a></li>
69+
</ul>
70+
</main>
71+
</body>
72+
</html>
73+
EOF
74+
75+
git -C "$site_dir" config user.name "github-actions[bot]"
76+
git -C "$site_dir" config user.email "41898282+github-actions[bot]@users.noreply.github.com"
77+
git -C "$site_dir" add --all
78+
git -C "$site_dir" commit --quiet -m "docs: publish $DISTRO_SLUG report for run $GITHUB_RUN_ID"
79+
git -C "$site_dir" push --quiet origin gh-pages
80+
81+
repository_name="${GITHUB_REPOSITORY#*/}"
82+
report_url="https://${GITHUB_REPOSITORY_OWNER}.github.io/${repository_name}/midscene/${DISTRO_SLUG}/runs/${GITHUB_RUN_ID}/"
83+
{
84+
echo "### Midscene HTML report"
85+
echo "[Open the interactive ${DISTRO_SLUG} report](${report_url})"
86+
echo
87+
echo "The report and its screenshots are publicly accessible through GitHub Pages."
88+
} >> "$GITHUB_STEP_SUMMARY"

0 commit comments

Comments
 (0)