Skip to content

Commit 1dff1bc

Browse files
committed
Copy screenshots and reftests properly to website
1 parent d2c2fcb commit 1dff1bc

File tree

6 files changed

+107
-82
lines changed

6 files changed

+107
-82
lines changed

.github/workflows/rust.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,27 @@ jobs:
618618
name: reftest-results
619619
path: artifacts-reftest
620620

621+
- name: Download Linux screenshots
622+
uses: actions/download-artifact@v4
623+
continue-on-error: true
624+
with:
625+
name: screenshots-ubuntu-22.04
626+
path: artifacts-screenshots-linux
627+
628+
- name: Download macOS screenshots
629+
uses: actions/download-artifact@v4
630+
continue-on-error: true
631+
with:
632+
name: screenshots-macos-14
633+
path: artifacts-screenshots-macos
634+
635+
- name: Download Windows screenshots
636+
uses: actions/download-artifact@v4
637+
continue-on-error: true
638+
with:
639+
name: screenshots-windows-2022
640+
path: artifacts-screenshots-windows
641+
621642
- name: Debug - Tree after download
622643
run: |
623644
sudo apt-get update && sudo apt-get install -y tree
@@ -669,6 +690,31 @@ jobs:
669690
fi
670691
fi
671692
693+
# Copy screenshots to website images directory
694+
# Screenshots are named like "hello-world-linux.png" and need to be renamed to "hello-world.linux.png"
695+
mkdir -p website/images
696+
for screenshot_dir in artifacts-screenshots-linux artifacts-screenshots-macos artifacts-screenshots-windows; do
697+
if [ -d "$screenshot_dir" ]; then
698+
for png in "$screenshot_dir"/*.png; do
699+
if [ -f "$png" ]; then
700+
filename=$(basename "$png")
701+
# Extract OS from directory name
702+
case "$screenshot_dir" in
703+
*linux*) os="linux" ;;
704+
*macos*) os="mac" ;;
705+
*windows*) os="windows" ;;
706+
esac
707+
# Convert "hello-world-linux.png" to "hello-world.linux.png"
708+
# The filename already has the OS in it, so we just rename
709+
newname=$(echo "$filename" | sed "s/-${os}/.${os}/")
710+
cp "$png" "website/images/$newname"
711+
echo " [OK] Copied screenshot: $newname"
712+
fi
713+
done
714+
fi
715+
done
716+
ls -la website/images/ || echo "No images directory"
717+
672718
# Update file sizes in release HTML
673719
# The HTML contains "N/A" or placeholder sizes that need to be replaced with real sizes
674720
if [ -d "$RELEASE_DIR" ]; then

doc/src/reftest/mod.rs

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,9 +240,62 @@ pub fn run_reftests(config: RunRefTestsConfig) -> anyhow::Result<()> {
240240
/// Generate a reftest HTML page without running any tests.
241241
/// If test_dir exists and contains tests, it will show "X tests found (not run)".
242242
/// If test_dir doesn't exist or is empty, it will show "0 tests found".
243+
///
244+
/// This function also copies existing reftest results and images from the standard
245+
/// reftest output directory (doc/target/reftest) if they exist.
243246
pub fn generate_reftest_page(output_dir: &Path, test_dir: Option<&Path>) -> anyhow::Result<()> {
244247
fs::create_dir_all(output_dir)?;
245248

249+
// Check if we have existing reftest results to copy
250+
// The reftest command outputs to doc/target/reftest, so look for results there
251+
let manifest_dir = Path::new(env!("CARGO_MANIFEST_DIR"));
252+
let existing_reftest_dir = manifest_dir.join("target").join("reftest");
253+
let existing_results_json = existing_reftest_dir.join("results.json");
254+
let existing_index_html = existing_reftest_dir.join("index.html");
255+
let existing_reftest_img = existing_reftest_dir.join("reftest_img");
256+
257+
// If we have existing results, copy them instead of generating empty page
258+
if existing_results_json.exists() && existing_index_html.exists() {
259+
println!(" Found existing reftest results, copying...");
260+
261+
// Copy index.html
262+
fs::copy(&existing_index_html, output_dir.join("index.html"))?;
263+
println!(" Copied index.html");
264+
265+
// Copy results.json
266+
fs::copy(&existing_results_json, output_dir.join("results.json"))?;
267+
println!(" Copied results.json");
268+
269+
// Copy reftest_img directory if it exists
270+
if existing_reftest_img.exists() && existing_reftest_img.is_dir() {
271+
let dest_img_dir = output_dir.join("reftest_img");
272+
fs::create_dir_all(&dest_img_dir)?;
273+
274+
let mut img_count = 0;
275+
for entry in fs::read_dir(&existing_reftest_img)? {
276+
let entry = entry?;
277+
let path = entry.path();
278+
if path.is_file() {
279+
let filename = path.file_name().unwrap();
280+
fs::copy(&path, dest_img_dir.join(filename))?;
281+
img_count += 1;
282+
}
283+
}
284+
println!(" Copied {} reftest images", img_count);
285+
}
286+
287+
// Also copy to reftest.html in parent directory
288+
if output_dir.file_name().map(|n| n == "reftest").unwrap_or(false) {
289+
if let Some(parent) = output_dir.parent() {
290+
fs::copy(output_dir.join("index.html"), parent.join("reftest.html"))?;
291+
}
292+
}
293+
294+
println!(" [OK] Reftest results copied from existing run");
295+
return Ok(());
296+
}
297+
298+
// No existing results, generate placeholder page
246299
// Count tests if directory provided
247300
let test_count = test_dir
248301
.and_then(|dir| find_test_files(dir).ok())

doc/src/reftest/report_template.html

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -272,15 +272,16 @@ <h1 style="display:none;">Azul GUI Framework</h1>
272272
<a href="https://azul.rs"><img src="https://azul.rs/logo.svg" alt="Azul Logo" style="width:100px;height:100px;"></a>
273273
</header>
274274
<nav>
275-
<ul>
275+
<ul class='nav-grid'>
276276
<li><a href='https://azul.rs'>overview</a></li>
277-
<li><a href='https://azul.rs/releases'>releases</a></li>
277+
<li><a href='https://azul.rs/releases.html'>releases</a></li>
278278
<li><a href='https://github.com/fschutt/azul'>code</a></li>
279279
<li><a href='https://discord.gg/V96ZGKqQvn'>discord</a></li>
280-
<li><a href='https://azul.rs/guide'>guide</a></li>
281-
<li><a href='https://azul.rs/api'>api</a></li>
282-
<li class="active"><a href='https://azul.rs/reftest'>reftests</a></li>
283-
<li><a href='https://azul.rs/donate'>donate</a></li>
280+
<li><a href='https://azul.rs/guide.html'>guide</a></li>
281+
<li><a href='https://azul.rs/api.html'>api</a></li>
282+
<li class="active"><a href='https://azul.rs/reftest.html'>reftests</a></li>
283+
<li><a href='https://azul.rs/blog.html'>blog</a></li>
284+
<li><a href='https://azul.rs/donate.html'>donate</a></li>
284285
</ul>
285286
</nav>
286287
</aside>

examples/c/minimal_test.c

Lines changed: 0 additions & 73 deletions
This file was deleted.

scripts/build_all.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,6 @@ else
161161
"calc"
162162
"hello-world"
163163
"infinity"
164-
"minimal_test"
165164
"opengl"
166165
"widgets"
167166
"xhtml"

scripts/screenshot.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,8 +332,7 @@ else
332332

333333
# Skip examples that are not suitable for screenshots
334334
case "$example_name" in
335-
minimal_test|infinity|opengl)
336-
# minimal_test: not a real example
335+
infinity|opengl)
337336
# infinity: runs indefinitely
338337
# opengl: requires specific OpenGL setup
339338
echo -e "${YELLOW}Skipping ${example_name} (not suitable for automated screenshots)${NC}"

0 commit comments

Comments
 (0)