Compare commits

...
Author SHA1 Message Date
feder-cr 455d5619e5 hunt: record the page-bytes reference of the core 64.71.0 on Windows and Linux (2 launches each)
Hunt only, never merged. One workflow on a push to its own branch: windows-2022 and ubuntu-24.04
(xvfb), two at a time, installs this checkout with the core of its pin (checked to be 64.71.0),
fetches the published engine, launches the persona of the e2e twice, reads the page-bytes probe,
and writes tests/data/page_bytes_<os>.json with every key equal in both launches (PNG keys on
decoded pixels). Unstable keys are listed apart and left out. The log carries the reference between
RECORD-BEGIN and RECORD-END, and the artifact the file to copy.
2026-11-15 02:04:44 +01:00
2 changed files with 207 additions and 0 deletions

No files matched your search

@@ -0,0 +1,92 @@
# ─────────────────────────────────────────────────────────────────────────────
# page-bytes-reference-hunt.yml - HUNT ONLY, never merged: record the "before" reference of what a page reads, per operating system.
#
# The e2e tests/test_software_compositing_is_declared_e2e.py (branch tests/software-compositing-declared) compares what a page reads (the
# probe tests/page_bytes_probe.js: canvas 2D, WebGL 1 and 2, WebGPU, text, the declared values) with tests/data/page_bytes_<os>.json. That
# reference is the bytes of the engine BEFORE the core declares software compositing, so it must be recorded with the core the release
# branch pins today (invisible-core 64.71.0), by a run of GitHub and not by hand.
#
# One job per system (windows-2022, ubuntu-24.04 under xvfb as e2e.yml runs it), two at a time: install this checkout (the core of its pin),
# fetch the published engine, launch the browser twice with the persona of the test (seed 42, en-US, Europe/Rome), read the probe, and write
# page_bytes_<os>.json with every key that is equal in both launches; a key that is not is listed apart (unstable.json, summary.txt, the job
# summary) and left out. The log carries the reference between RECORD-BEGIN <os> and RECORD-END; the artifact holds the file to copy into
# tests/data/ and the raw values of each launch.
#
# Nothing of the product is changed. Starts on a push to its own branch only.
# ─────────────────────────────────────────────────────────────────────────────
name: page bytes reference hunt
on:
push:
branches: [hunt/page-bytes-reference]
permissions:
contents: read
concurrency:
group: page-bytes-reference-hunt-${{ github.ref }}
cancel-in-progress: true
# Engine and GeoIP downloads go through the release API with this token (as in e2e.yml).
env:
GITHUB_TOKEN: ${{ github.token }}
jobs:
hunt:
name: "hunt (${{ matrix.os }}, page bytes of the core 64.71.0, 2 launches)"
runs-on: ${{ matrix.os }}
timeout-minutes: 40
strategy:
fail-fast: false
max-parallel: 2
matrix:
os: [windows-2022, ubuntu-24.04]
defaults:
run:
shell: bash
env:
PYTHONUNBUFFERED: "1"
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with: { fetch-depth: 1 }
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
with: { python-version: '3.11' }
- name: Install the wrapper (and its core, by the pin of this checkout)
run: |
python -m pip install --upgrade pip
python -m pip install ".[dev]"
# Playwright ONLY as a system tool, for `playwright install-deps firefox` on Linux (as e2e.yml does).
python -m pip install "playwright==$(cat scripts/playwright_pin.txt)"
- name: The core is the one this reference is for (invisible-core 64.71.0, the pin of the release branch)
run: |
PIN=$(grep -oE 'invisible_core==[0-9.]+' pyproject.toml | head -1 | cut -d= -f3)
GOT=$(python -c "from importlib.metadata import version; print(version('invisible-core'))")
echo "pyproject pins invisible-core $PIN, installed $GOT"
test "$PIN" = "$GOT"
test "$GOT" = "64.71.0"
- name: System deps (xvfb + Firefox runtime libs)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y xvfb
sudo "$(which python)" -m playwright install-deps firefox
- name: Fetch the published firefox binary
run: echo "FF=$(cd "$RUNNER_TEMP" && python -m invisible_playwright fetch | tail -1)" >> "$GITHUB_ENV"
- name: The GeoIP database (made by the repository, same bytes every run)
run: python scripts/ci_lab_geoip.py build
- name: Record the page bytes (2 launches)
run: |
if [ "$RUNNER_OS" = "Linux" ]; then RUN="xvfb-run -a"; else RUN=""; fi
$RUN python -u scripts/hunt_page_bytes_reference.py --binary "$FF" --launches 2 --out "$RUNNER_TEMP/pbref"
- name: Close every Firefox left
if: always()
run: |
if [ "$RUNNER_OS" = "Windows" ]; then taskkill //F //IM firefox.exe //T > /dev/null 2>&1 || true; else pkill -9 firefox || true; fi
- name: Upload the reference
if: always()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: page-bytes-reference-${{ matrix.os }}-${{ github.run_id }}-${{ github.run_attempt }}
path: ${{ runner.temp }}/pbref
if-no-files-found: warn
retention-days: 14
+115
View File
@@ -0,0 +1,115 @@
"""HUNT ONLY (branch hunt/page-bytes-reference, never merged): record the reference of what a page reads, per operating system.
python scripts/hunt_page_bytes_reference.py --binary "$FF" --out DIR [--launches 2]
It does what test 3 of tests/test_software_compositing_is_declared_e2e.py does (the same launch, the same page, the same probe
tests/page_bytes_probe.js), `--launches` times, in the engine and with the core this checkout installed, and instead of comparing with
tests/data/page_bytes_<os>.json it WRITES that file:
* every key whose entry (tests/_page_bytes.entry_of: the string, or hash and length; for a PNG key the length and the decoded pixels)
is the same in every launch goes to the reference;
* every key that is not (an unstable key) is listed apart, with its entries, and left out of the reference: a reference holds nothing
that changes by itself.
Out, in DIR: page_bytes_<os>.json (the reference, in the form the test reads: copy it to tests/data/), unstable.json, launch-<n>.json.gz
(the raw probe values of each launch) and summary.txt. The log gets the reference between RECORD-BEGIN <os> and RECORD-END.
"""
from __future__ import annotations
import argparse
import gzip
import json
import os
import re
import sys
from importlib import metadata
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(ROOT / "tests"))
import _page_bytes as pb # noqa: E402
import test_software_compositing_is_declared_e2e as t # noqa: E402 (LAUNCH, the page server, OS_NAME: what test 3 uses)
def one_launch(binary: str) -> dict:
from invisible_playwright import InvisiblePlaywright
expression = (ROOT / "tests" / "page_bytes_probe.js").read_text(encoding="utf-8")
server, url = t._a_page_server("<!doctype html><meta charset=utf-8><title>probe</title><body></body>")
try:
with InvisiblePlaywright(binary_path=binary, **t.LAUNCH) as browser:
page = browser.new_page()
page.goto(url, wait_until="load", timeout=60000)
return page.evaluate(expression)
finally:
server.shutdown()
def main() -> int:
ap = argparse.ArgumentParser()
ap.add_argument("--binary", default=os.environ.get("INVPW_BINARY_PATH", ""))
ap.add_argument("--out", type=Path, required=True)
ap.add_argument("--launches", type=int, default=2)
args = ap.parse_args()
if not args.binary:
ap.error("--binary (or INVPW_BINARY_PATH)")
args.out.mkdir(parents=True, exist_ok=True)
launches = []
for n in range(1, args.launches + 1):
data = one_launch(args.binary)
with gzip.open(args.out / ("launch-%d.json.gz" % n), "wt", encoding="utf-8") as f:
json.dump(data, f)
launches.append(data)
print("launch %d: %d keys, %d scene error(s)%s" % (n, len(data), len([k for k in data if k.endswith(".error")]),
(": " + ", ".join("%s=%s" % (k, data[k].get("s")) for k in sorted(data) if k.endswith(".error")))
if any(k.endswith(".error") for k in data) else ""))
sys.stdout.flush()
keys = sorted(set().union(*[set(d) for d in launches]))
stable, pngs, unstable = {}, {}, {}
for key in keys:
if any(key not in d for d in launches):
unstable[key] = ["missing in launch %d" % (i + 1) for i, d in enumerate(launches) if key not in d]
continue
entries = [pb.entry_of(key, d[key]) for d in launches]
if any(e != entries[0] for e in entries) or "undecodable" in entries[0] or (pb.is_png_key(key) and "sha256" not in entries[0]):
unstable[key] = entries
continue
(pngs if pb.is_png_key(key) else stable)[key] = entries[0]
engine = re.search(r"firefox-\d+_[\d.]+_\d+", args.binary.replace("\\", "/"))
reference = {
"os": t.OS_NAME,
"source": ("GitHub Actions run %s (workflow page-bytes-reference-hunt, runner image %s %s), wrapper commit %s, invisible-core %s, engine %s, seed %d, "
"locale %s, timezone %s, headless=True; %d launches, every key below is equal in all of them. `pngs`: the PNG keys, compared on their "
"length and decoded pixels because every PNG carries a per-launch chunk."
% (os.environ.get("GITHUB_RUN_ID", "?"), os.environ.get("ImageOS", "?"), os.environ.get("ImageVersion", "?"),
os.environ.get("GITHUB_SHA", "?")[:10], metadata.version("invisible-core"), engine.group(0) if engine else "?",
t.LAUNCH["seed"], t.LAUNCH["locale"], t.LAUNCH["timezone"], args.launches)),
"keys": stable,
"pngs": pngs,
}
path = args.out / ("page_bytes_%s.json" % t.OS_NAME)
path.write_text(json.dumps(reference, indent=1) + "\n", encoding="utf-8", newline="\n")
(args.out / "unstable.json").write_text(json.dumps(unstable, indent=1) + "\n", encoding="utf-8", newline="\n")
lines = ["page bytes on %s, %d launches, invisible-core %s: %d keys read, %d stable (%d of them PNG), %d UNSTABLE"
% (t.OS_NAME, args.launches, metadata.version("invisible-core"), len(keys), len(stable) + len(pngs), len(pngs), len(unstable))]
lines += [" unstable: %s %s" % (k, json.dumps(v)[:300]) for k, v in unstable.items()]
lines += [" scene error: %s = %s" % (k, stable[k].get("s")) for k in sorted(stable) if k.endswith(".error")]
summary = "\n".join(lines)
(args.out / "summary.txt").write_text(summary + "\n", encoding="utf-8", newline="\n")
print(summary)
print("RECORD-BEGIN %s" % t.OS_NAME)
print(json.dumps({"keys": stable, "pngs": pngs}, sort_keys=True))
print("RECORD-END")
if os.environ.get("GITHUB_STEP_SUMMARY"):
with open(os.environ["GITHUB_STEP_SUMMARY"], "a", encoding="utf-8") as f:
f.write("### Page bytes, %s\n\n```\n%s\n```\n" % (t.OS_NAME, summary))
return 0
if __name__ == "__main__":
sys.exit(main())