diff --git a/.github/workflows/README.md b/.github/workflows/README.md index 0d1db81917..2d14de0416 100644 --- a/.github/workflows/README.md +++ b/.github/workflows/README.md @@ -166,6 +166,7 @@ before deleting it. | desktop-dependency-audit.yml | `python-macos-intel` | no | no | when Desktop changes, and weekly | | desktop-replay.yml | `replay` (Patient Notes through WindowsBackend, judged from SQLite), `freerdp` (FreeRDP transport round trip over a loopback RDP session), `check-it-gtk` | when Flow or the Windows path changes, not on drafts; not required | no | nightly | | flow-mcp-compat.yml | `flow-mcp-compat` (MCP SDK 1.28.0 and 2.3.0) | when MCP-facing Flow code, its tests or the pinned requirements change, not on drafts; not required | no | every push to main that changes Flow, Types or `scripts/ci` | +| tutorial-digests.yml | `digest` (the quickstart twice on ubuntu-24.04, windows-latest and macos-latest; fails if a platform's two bundle digests differ; reports each digest for Cloud's `RECEIPT_GALLERY_SAMPLE_BUNDLE_DIGESTS`) | when the workflow itself changes; not required | no | on dispatch, for each release that changes the tutorial, the compiler or rendering | | apt-install-selftest.yml | `fallback`, `warm-cache`, `playwright-deps`, `total-outage` | when `.github/actions/apt-install` changes; not required | no | no | | apt-cache-seed.yml | `seed` (one per cached Ubuntu package set) | no | no | daily, and when the action changes | | codeql.yml | `Analyze` (Python, JavaScript/TypeScript, Rust) | per changed language | per changed language | all languages on main (one analysis at a time, newest waiting push wins) and weekly | diff --git a/.github/workflows/tutorial-digests.yml b/.github/workflows/tutorial-digests.yml new file mode 100644 index 0000000000..9017267353 --- /dev/null +++ b/.github/workflows/tutorial-digests.yml @@ -0,0 +1,90 @@ +name: Tutorial bundle digests + +# The quickstart compiles its synthetic MockMed tutorial with a fixed seed, so +# every run on one platform should produce the same bundle content digest. +# OpenAdapt Cloud pins those digests (RECEIPT_GALLERY_SAMPLE_BUNDLE_DIGESTS) to +# list published tutorial Seals in its gallery. Rendering differs by platform, +# so this runs the quickstart twice on each OS, fails if the two runs differ, +# and reports each digest. Run it on dispatch for any release that changes the +# tutorial, the compiler or rendering, and pin the new digests in Cloud. + +on: + workflow_dispatch: + pull_request: + paths: + - .github/workflows/tutorial-digests.yml + +permissions: + contents: read + +concurrency: + group: tutorial-digests-${{ github.event.pull_request.number || github.run_id }} + cancel-in-progress: true + +jobs: + digest: + name: Tutorial digest (${{ matrix.os }}) + runs-on: ${{ matrix.os }} + timeout-minutes: 45 + strategy: + fail-fast: false + matrix: + os: [ubuntu-24.04, windows-latest, macos-latest] + defaults: + run: + shell: bash + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + ref: ${{ github.event.pull_request.head.sha || github.sha }} + - uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0 + with: + python-version: "3.12" + - uses: astral-sh/setup-uv@1db35dd8eee11c5894872e0b383ae6c406cf738d # v10.4.0 + - name: Install the launcher, Flow with its browser extra, and types + run: uv pip install --system ./packages/types "./packages/flow[browser]" . + - name: Provision headless Chromium + run: python -m playwright install --with-deps chromium + - name: Run the quickstart twice + run: | + mkdir -p digests + for k in 1 2; do + openadapt quickstart --out "run$k" < /dev/null > "digests/run$k.log" 2>&1 \ + || { tail -40 "digests/run$k.log"; exit 1; } + done + - name: Compare and report the digests + run: | + python - <<'PY' + import glob, json, os, platform + rows = [] + for k in (1, 2): + manifest = json.load(open(f"run{k}/bundle/manifest.json", encoding="utf-8")) + rows.append({ + "run": k, + "digest": manifest["content_digest"], + "encrypted": bool(glob.glob(f"run{k}/bundle/*.enc")), + }) + result = { + "os": os.environ["RUNNER_OS"], + "image": os.environ.get("ImageOS", ""), + "arch": platform.machine(), + "runs": rows, + "stable": rows[0]["digest"] == rows[1]["digest"], + } + json.dump(result, open("digests/result.json", "w"), indent=2) + with open(os.environ["GITHUB_STEP_SUMMARY"], "a", encoding="utf-8") as out: + out.write(f"### {result['os']} {result['arch']}\n\n") + for row in rows: + out.write(f"- run {row['run']}: `{row['digest']}` (encrypted: {row['encrypted']})\n") + out.write(f"\nStable: **{result['stable']}**\n") + print(json.dumps(result, indent=2)) + assert result["stable"], "the two runs produced different digests" + PY + - name: Keep the digests + if: always() + uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 + with: + name: tutorial-digest-${{ matrix.os }} + path: digests/ + if-no-files-found: ignore