Skip to content

The animation engine for agents: blazingly fast math and 3D videos with Manim's Python API, on a Rust GPU core.

Python

Add test and docs CI workflows

apoogdkde84696dcda5
diff --git a/.github/dependabot.yml b/.github/dependabot.yml
new file mode 100644
index 00000000..fbd5d245
--- /dev/null
+++ b/.github/dependabot.yml
@@ -0,0 +1,83 @@
+# One pull request per ecosystem, grouping its updates. A release waits a week first: most
+# compromised releases are caught within days. Security updates don't wait.
+version: 2
+updates:
+ # The workflows pin their actions by commit; Dependabot moves the pins to new releases. A
+ # pinned action gets no security alerts, so its updates are checked every week.
+ - package-ecosystem: github-actions
+ directory: /
+ schedule:
+ interval: weekly
+ cooldown:
+ default-days: 7
+ groups:
+ actions:
+ patterns: ["*"]
+
+ # uv.lock follows new releases; a requirement in pyproject.toml changes only when a new
+ # release falls outside it
+ - package-ecosystem: uv
+ directory: /
+ schedule:
+ interval: monthly
+ versioning-strategy: increase-if-necessary
+ cooldown:
+ default-days: 7
+ groups:
+ python:
+ patterns: ["*"]
+
+ # the engine's crates
+ - package-ecosystem: cargo
+ directory: /rust
+ schedule:
+ interval: monthly
+ cooldown:
+ default-days: 7
+ groups:
+ rust:
+ patterns: ["*"]
+
+ # the hooks' repositories (the local hooks run the locked tools, and are skipped)
+ - package-ecosystem: pre-commit
+ directory: /
+ schedule:
+ interval: monthly
+ cooldown:
+ default-days: 7
+ groups:
+ pre-commit:
+ patterns: ["*"]
+
+ # the Docker image's base and its uv (docker/Dockerfile)
+ - package-ecosystem: docker
+ directory: /docker
+ schedule:
+ interval: monthly
+ cooldown:
+ default-days: 7
+ groups:
+ docker:
+ patterns: ["*"]
+
+ # the browser package's compiler, bundler types, and formatter
+ - package-ecosystem: bun
+ directory: /browser
+ schedule:
+ interval: monthly
+ cooldown:
+ default-days: 7
+ groups:
+ browser-package:
+ patterns: ["*"]
+
+ # the corpus review panel's web app
+ - package-ecosystem: bun
+ directory: /tests/integration/review/web
+ schedule:
+ interval: monthly
+ cooldown:
+ default-days: 7
+ groups:
+ review-panel:
+ patterns: ["*"]
diff --git a/.github/deploy/coverage.jsonc b/.github/deploy/coverage.jsonc
new file mode 100644
index 00000000..db42f20f
--- /dev/null
+++ b/.github/deploy/coverage.jsonc
@@ -0,0 +1,16 @@
+{
+ "$schema": "https://www.unpkg.com/wrangler/config-schema.json",
+ // The tests' coverage report (`just combine-coverage` writes it to htmlcov/, the Test workflow
+ // publishes it), served as static assets: no Worker script runs
+ "name": "manimgx-coverage",
+ "compatibility_date": "2026-09-25",
+ "assets": { "directory": "../../htmlcov" },
+ // main's report
+ "workers_dev": false,
+ "routes": [{ "pattern": "coverage.manimgx.academa.ai", "custom_domain": true }],
+ // each commit's report is a deployment in the preview "main" or "pr-<number>", at
+ // <preview>-manimgx-coverage.<account subdomain>.workers.dev; a Worker keeps its 100 most
+ // recently used previews, and each preview its last 100 deployments
+ "preview_urls": true,
+ "previews": {}
+}
diff --git a/.github/deploy/docs.jsonc b/.github/deploy/docs.jsonc
new file mode 100644
index 00000000..a8b6a2e6
--- /dev/null
+++ b/.github/deploy/docs.jsonc
@@ -0,0 +1,22 @@
+{
+ "$schema": "https://www.unpkg.com/wrangler/config-schema.json",
+ // The docs site (`just build-docs` writes it to docs/site/), served as static assets: no Worker
+ // script runs, every request is answered from the files
+ "name": "manimgx-docs",
+ "compatibility_date": "2026-09-25",
+ "assets": {
+ "directory": "../../docs/site",
+ // pages are directories (guide/index.html): /guide redirects to /guide/
+ "html_handling": "auto-trailing-slash",
+ // a path that matches nothing gets the nearest 404.html, with status 404
+ "not_found_handling": "404-page"
+ },
+ // the site's domain (as `site_url` in docs/zensical.toml)
+ "workers_dev": false,
+ "routes": [{ "pattern": "manimgx.academa.ai", "custom_domain": true }],
+ // a pull request is previewed at pr-<number>-manimgx-docs.<account subdomain>.workers.dev
+ // (set explicitly: it defaults to `workers_dev`)
+ "preview_urls": true,
+ "previews": {},
+ "observability": { "enabled": true }
+}
diff --git a/.github/workflows/benchmark.yaml b/.github/workflows/benchmark.yaml
new file mode 100644
index 00000000..d895e3ad
--- /dev/null
+++ b/.github/workflows/benchmark.yaml
@@ -0,0 +1,83 @@
+# The timed benchmarks (`just bench`): a pull request's manimgx against its base's, and each
+# push to main against the commit before it, rendered in turns on one Linux runner. A workload
+# that became slower fails the job; every workload's change is in the run's summary. Time is
+# only compared on one machine at one time, so this is the one job that measures it; the laws
+# of cost run with the tests, on every system.
+
+name: Benchmark
+
+on:
+ push:
+ branches: [main]
+ paths:
+ - src/**
+ - fonts/**
+ - rust/**
+ - examples/**
+ - tests/benchmarks/**
+ - pyproject.toml
+ - uv.lock
+ pull_request:
+ paths:
+ - src/**
+ - fonts/**
+ - rust/**
+ - examples/**
+ - tests/benchmarks/**
+ - pyproject.toml
+ - uv.lock
+ workflow_dispatch:
+ inputs:
+ against:
+ description: The commit, branch or tag to compare with
+ required: true
+ default: main
+
+permissions: {}
+
+concurrency:
+ group: benchmark-${{ github.event.pull_request.number || github.ref }}
+ # a newer commit supersedes a pull request's run; main's runs all finish
+ cancel-in-progress: ${{ github.event_name == 'pull_request' }}
+
+jobs:
+ benchmark:
+ name: Benchmark against the base
+ runs-on: ubuntu-24.04
+ timeout-minutes: 120
+ permissions:
+ contents: read
+ steps:
+ # all of history: the commit compared with is made from it
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
+ with:
+ persist-credentials: false
+ fetch-depth: 0
+
+ - uses: taiki-e/install-action@4cef1412cce204788f482e778a0b9187f9626a29 # v2.87.21
+ with:
+ tool: just
+
+ # the GPU the benchmarks draw with, on the CPU: Mesa's lavapipe
+ - name: Install a GPU driver
+ run: |
+ sudo apt-get update
+ sudo apt-get install --yes --no-install-recommends libvulkan1 mesa-vulkan-drivers
+
+ - uses: astral-sh/setup-uv@c18668ad3cf93ea998bef934396af7bb5c839dc7 # v10.2.0
+
+ # the engine's dependencies, compiled; the base's engine, when built, reuses them too
+ - uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2
+ with:
+ workspaces: rust
+ shared-key: engine
+ save-if: ${{ github.ref == 'refs/heads/main' }}
+
+ # a pull request is checked out merged into its base: the merge's first parent is the base
+ - name: Benchmark
+ run: just bench "${AGAINST}"
+ env:
+ AGAINST: >-
+ ${{ github.event_name == 'pull_request' && 'HEAD^1'
+ || github.event_name == 'push' && github.event.before
+ || inputs.against }}
diff --git a/.github/workflows/deploy-docs.yaml b/.github/workflows/deploy-docs.yaml
new file mode 100644
index 00000000..1b4e1f0c
--- /dev/null
+++ b/.github/workflows/deploy-docs.yaml
@@ -0,0 +1,162 @@
+# The docs site, on Cloudflare Workers (.github/deploy/docs.jsonc): built on every push and
+# pull request, deployed from main to https://manimgx.academa.ai, and previewed per pull request.
+# The build runs the repository's code and gets no secrets; the jobs that get them never run
+# it, they upload what the build made.
+
+name: Deploy docs
+
+on:
+ push:
+ branches: [main]
+ pull_request:
+ types: [opened, synchronize, reopened, closed]
+ workflow_dispatch:
+
+permissions: {}
+
+concurrency:
+ group: docs-${{ github.event.pull_request.number || github.ref }}
+ # a newer commit supersedes a pull request's run; a deploy always finishes
+ cancel-in-progress: ${{ github.event_name == 'pull_request' }}
+
+env:
+ WRANGLER_VERSION: "4.141.0"
+
+jobs:
+ build:
+ name: Build
+ if: github.event.action != 'closed'
+ runs-on: ubuntu-24.04
+ timeout-minutes: 45
+ permissions:
+ contents: read
+ steps:
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
+ with:
+ persist-credentials: false
+
+ - uses: taiki-e/install-action@4cef1412cce204788f482e778a0b9187f9626a29 # v2.87.21
+ with:
+ tool: just
+
+ # the GPU the examples' videos are drawn with, on the CPU: Mesa's lavapipe (the narrated
+ # examples speak from docs/voice/, where what they say is kept)
+ - name: Install a GPU driver
+ run: |
+ sudo apt-get update
+ sudo apt-get install --yes --no-install-recommends libvulkan1 mesa-vulkan-drivers
+
+ - uses: astral-sh/setup-uv@c18668ad3cf93ea998bef934396af7bb5c839dc7 # v10.2.0
+
+ - uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2
+ with:
+ workspaces: rust
+ shared-key: engine
+ save-if: ${{ github.ref == 'refs/heads/main' }}
+
+ - name: Build the site
+ run: just build-docs
+
+ - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
+ with:
+ name: docs
+ path: |
+ docs/site/
+ .github/deploy/docs.jsonc
+ # the deployment config lives in .github/, a hidden directory
+ include-hidden-files: true
+ if-no-files-found: error
+ retention-days: 7
+
+ deploy:
+ name: Deploy
+ needs: build
+ if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request'
+ runs-on: ubuntu-24.04
+ timeout-minutes: 10
+ permissions: {}
+ environment:
+ name: docs
+ url: https://manimgx.academa.ai
+ steps:
+ - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
+ with:
+ name: docs
+
+ - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
+
+ - name: Deploy the site
+ run: >-
+ bunx "wrangler@${WRANGLER_VERSION}" deploy --config .github/deploy/docs.jsonc
+ --message "${GITHUB_SHA}"
+ env:
+ CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
+ CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
+
+ preview:
+ name: Preview
+ needs: build
+ # pull requests from forks and from Dependabot get no secrets: they are built, not previewed
+ if: >-
+ github.event_name == 'pull_request'
+ && github.event.pull_request.head.repo.full_name == github.repository
+ && github.actor != 'dependabot[bot]'
+ runs-on: ubuntu-24.04
+ timeout-minutes: 10
+ permissions: {}
+ environment:
+ name: docs-preview
+ url: ${{ steps.preview.outputs.url }}
+ steps:
+ - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
+ with:
+ name: docs
+
+ - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
+
+ - name: Preview the site
+ id: preview
+ run: |
+ bunx "wrangler@${WRANGLER_VERSION}" preview --config .github/deploy/docs.jsonc \
+ --name "pr-${PR_NUMBER}" --message "${HEAD_SHA}"
+ url="$(jq -er 'select(.type == "preview") | .preview_urls[0]' "${WRANGLER_OUTPUT_FILE_PATH}")"
+ echo "url=${url}" >> "${GITHUB_OUTPUT}"
+ env:
+ CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
+ CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
+ WRANGLER_OUTPUT_FILE_PATH: ${{ runner.temp }}/wrangler.ndjson
+ PR_NUMBER: ${{ github.event.pull_request.number }}
+ HEAD_SHA: ${{ github.event.pull_request.head.sha }}
+
+ delete-preview:
+ name: Delete the preview
+ if: >-
+ github.event.action == 'closed'
+ && github.event.pull_request.head.repo.full_name == github.repository
+ && github.actor != 'dependabot[bot]'
+ runs-on: ubuntu-24.04
+ timeout-minutes: 5
+ permissions:
+ contents: read
+ environment:
+ name: docs-preview
+ deployment: false
+ steps:
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
+ with:
+ persist-credentials: false
+ sparse-checkout: .github/deploy/docs.jsonc
+ sparse-checkout-cone-mode: false
+
+ - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
+
+ - name: Delete the preview
+ # a pull request that was never previewed has none to delete
+ continue-on-error: true
+ run: >-
+ bunx "wrangler@${WRANGLER_VERSION}" preview delete --config .github/deploy/docs.jsonc
+ --name "pr-${PR_NUMBER}" --skip-confirmation
+ env:
+ CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
+ CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
+ PR_NUMBER: ${{ github.event.pull_request.number }}
diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml
new file mode 100644
index 00000000..6c33cab5
--- /dev/null
+++ b/.github/workflows/test.yaml
@@ -0,0 +1,232 @@
+# The checks every change must pass: the pre-commit checks, and the tests on each OS and Python
+# manimgx supports. Their coverage is combined into one report on Cloudflare: main's at
+# https://coverage.manimgx.academa.ai, a pull request's on its preview URL, and each commit's
+# linked from its "coverage" status. The release runs this workflow before it builds anything.
+
+name: Test
+
+on:
+ push:
+ branches: [main]
+ pull_request:
+ workflow_call:
+ workflow_dispatch:
+
+permissions: {}
+
+concurrency:
+ group: test-${{ github.event.pull_request.number || github.ref }}
+ # a newer commit supersedes a pull request's run; main's runs all finish
+ cancel-in-progress: ${{ github.event_name == 'pull_request' }}
+
+env:
+ WRANGLER_VERSION: "4.141.0"
+
+jobs:
+ pre-commit:
+ name: Run pre-commit checks
+ runs-on: ubuntu-24.04
+ timeout-minutes: 30
+ permissions:
+ contents: read
+ steps:
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
+ with:
+ persist-credentials: false
+
+ - uses: taiki-e/install-action@4cef1412cce204788f482e778a0b9187f9626a29 # v2.87.21
+ with:
+ tool: just
+
+ - uses: astral-sh/setup-uv@c18668ad3cf93ea998bef934396af7bb5c839dc7 # v10.2.0
+
+ # the engine's dependencies, compiled; only main's runs save them, for everyone's runs
+ - uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2
+ with:
+ workspaces: rust
+ shared-key: engine
+ save-if: ${{ github.ref == 'refs/heads/main' }}
+
+ - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
+
+ - name: Run pre-commit checks
+ run: just check
+
+ typescript:
+ name: Test the browser package
+ runs-on: ubuntu-24.04
+ timeout-minutes: 10
+ permissions:
+ contents: read
+ steps:
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
+ with:
+ persist-credentials: false
+
+ - uses: taiki-e/install-action@4cef1412cce204788f482e778a0b9187f9626a29 # v2.87.21
+ with:
+ tool: just
+
+ - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
+
+ - name: Test the browser package
+ run: just test-typescript
+
+ test:
+ name: Test with Python ${{ matrix.python-version }} on ${{ matrix.os }}
+ strategy:
+ fail-fast: false
+ matrix:
+ os: [ubuntu-24.04, macos-26, windows-2025]
+ python-version: ["3.13", "3.14"]
+ runs-on: ${{ matrix.os }}
+ timeout-minutes: 120
+ permissions:
+ contents: read
+ env:
+ # the job's coverage data, named after the job (its subprocesses add suffixes)
+ COVERAGE_FILE: ${{ github.workspace }}/.coverage.${{ matrix.os }}-python${{ matrix.python-version }}
+ steps:
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
+ with:
+ persist-credentials: false
+
+ - uses: taiki-e/install-action@4cef1412cce204788f482e778a0b9187f9626a29 # v2.87.21
+ with:
+ tool: just
+
+ # the GPU the tests draw with on Linux, on the CPU: Mesa's lavapipe (macOS has Metal,
+ # Windows WARP)
+ - name: Install a GPU driver
+ if: runner.os == 'Linux'
+ run: |
+ sudo apt-get update
+ sudo apt-get install --yes --no-install-recommends libvulkan1 mesa-vulkan-drivers
+
+ - uses: astral-sh/setup-uv@c18668ad3cf93ea998bef934396af7bb5c839dc7 # v10.2.0
+ with:
+ python-version: ${{ matrix.python-version }}
+
+ - uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2
+ with:
+ workspaces: rust
+ shared-key: engine
+ save-if: ${{ github.ref == 'refs/heads/main' }}
+
+ - name: Test
+ run: just test-coverage
+
+ - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
+ with:
+ name: coverage-${{ matrix.os }}-python${{ matrix.python-version }}
+ path: .coverage.*
+ include-hidden-files: true
+ if-no-files-found: error
+ retention-days: 7
+
+ coverage:
+ name: Combine the coverage
+ needs: test
+ # a job that failed leaves the others' coverage to report
+ if: ${{ !cancelled() }}
+ runs-on: ubuntu-24.04
+ timeout-minutes: 10
+ permissions:
+ contents: read
+ outputs:
+ total: ${{ steps.combine.outputs.total }}
+ steps:
+ # the report shows the source
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
+ with:
+ persist-credentials: false
+
+ - uses: taiki-e/install-action@4cef1412cce204788f482e778a0b9187f9626a29 # v2.87.21
+ with:
+ tool: just
+
+ - uses: astral-sh/setup-uv@c18668ad3cf93ea998bef934396af7bb5c839dc7 # v10.2.0
+
+ - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
+ with:
+ pattern: coverage-*
+ path: coverage
+ merge-multiple: true
+
+ - name: Combine the coverage
+ id: combine
+ run: |
+ just combine-coverage coverage >> "$GITHUB_STEP_SUMMARY"
+ total="$(uvx coverage report --format=total --precision=1)"
+ # the README's badge: https://shields.io/badges/endpoint-badge
+ jq --null-input --arg total "$total" '{
+ schemaVersion: 1, label: "coverage", message: "\($total)%",
+ color: (($total | tonumber) as $t | if $t >= 90 then "brightgreen"
+ elif $t >= 75 then "yellow" else "red" end)
+ }' > htmlcov/badge.json
+ echo "total=${total}" >> "$GITHUB_OUTPUT"
+
+ - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
+ with:
+ name: coverage-report
+ path: |
+ htmlcov/
+ .github/deploy/coverage.jsonc
+ # the deployment config lives in .github/, a hidden directory
+ include-hidden-files: true
+ if-no-files-found: error
+ retention-days: 7
+
+ publish-coverage:
+ name: Publish the coverage
+ needs: coverage
+ # main's pushes, and pull requests from this repository: pull requests from forks and from
+ # Dependabot get no secrets
+ if: >-
+ (github.event_name == 'push' && github.ref == 'refs/heads/main')
+ || (github.event_name == 'pull_request'
+ && github.event.pull_request.head.repo.full_name == github.repository
+ && github.actor != 'dependabot[bot]')
+ runs-on: ubuntu-24.04
+ timeout-minutes: 10
+ permissions:
+ statuses: write
+ environment:
+ name: ${{ github.event_name == 'push' && 'coverage' || 'coverage-preview' }}
+ url: ${{ steps.publish.outputs.url }}
+ steps:
+ - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
+ with:
+ name: coverage-report
+
+ - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
+
+ # main's report goes to its domain; every commit's report is also a deployment of its own
+ # (in the Worker's preview "main", or "pr-<number>"), which its status links to
+ - name: Publish the report
+ id: publish
+ run: |
+ if [[ "${GITHUB_EVENT_NAME}" == push ]]; then
+ bunx "wrangler@${WRANGLER_VERSION}" deploy --config .github/deploy/coverage.jsonc \
+ --message "${SHA}"
+ url="https://coverage.manimgx.academa.ai"
+ preview="main"
+ else
+ preview="pr-${PR_NUMBER}"
+ fi
+ bunx "wrangler@${WRANGLER_VERSION}" preview --config .github/deploy/coverage.jsonc \
+ --name "${preview}" --message "${SHA}"
+ deployment="$(jq -er 'select(.type == "preview") | .deployment_urls[0]' "${WRANGLER_OUTPUT_FILE_PATH}")"
+ url="${url:-$(jq -er 'select(.type == "preview") | .preview_urls[0]' "${WRANGLER_OUTPUT_FILE_PATH}")}"
+ echo "url=${url}" >> "${GITHUB_OUTPUT}"
+ gh api "repos/${GITHUB_REPOSITORY}/statuses/${SHA}" --field state=success \
+ --field context=coverage --field description="${TOTAL}% of lines run" \
+ --field target_url="${deployment}"
+ env:
+ CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
+ CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
+ WRANGLER_OUTPUT_FILE_PATH: ${{ runner.temp }}/wrangler.ndjson
+ GH_TOKEN: ${{ github.token }}
+ SHA: ${{ github.event.pull_request.head.sha || github.sha }}
+ PR_NUMBER: ${{ github.event.pull_request.number }}
+ TOTAL: ${{ needs.coverage.outputs.total }}
diff --git a/.gitignore b/.gitignore
index 7d70f493..242b4da3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -35,6 +35,7 @@ htmlcov/
# Render output (media/: Manim CE's, from the corpus's CE runs)
media/
*.mp4
+*.mkv
*.wav
!tests/integration/cases/*/*.wav
tests/**/_testoutput/
diff --git a/AGENTS.md b/AGENTS.md
index 5c3d9d46..28657962 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -80,9 +80,7 @@ is published apart from it has a folder of its own, with its own tests.
- `docker/`: the Docker image, manimgx from PyPI.
- `tests/unit/`: properties of each module, mirroring `src/manimgx/`, drawn
with Hypothesis (the shared kit: `tests/strategies.py`, `tests/oracles.py`, `tests/scenes.py`).
-- `tests/integration/`: stories per subject (`test_*.py`) and the corpus, `cases/` (per case:
- `scene.py`, its reference `manimgx.mkv`, Manim CE's `ce.mkv`, `case.json`, and once reviewed
- `review.json`), with its tools in `corpus/` and the review panel in `review/`.
+- `tests/integration/`: stories per subject (`test_*.py`) and the corpus, `cases/` (per case: `scene.py`, hashes of the local `manimgx.mkv` and `ce.mkv` references, `case.json`, and once reviewed `review.json`), with its tools in `corpus/` and the review panel in `review/`.
`tests/docs/`: `llms.txt`'s hand-written primer for agents, checked against the API, and
the narrated examples, which say what `docs/voice/` keeps (the site is built with no key).
- `tests/benchmarks/`: laws of what work costs (with the suite) and timed benchmarks against
diff --git a/docs/content/developer-guide/index.md b/docs/content/developer-guide/index.md
index 656db8a9..f4cd5d5f 100644
--- a/docs/content/developer-guide/index.md
+++ b/docs/content/developer-guide/index.md
@@ -51,27 +51,17 @@ sudo apt-get install libvulkan1 mesa-vulkan-drivers
### Manim Community Edition
-The integration corpus compares every case with Manim Community Edition's rendering of it.
-CE's references are in the repository; rendering them again (a new case, or a changed
-scene) needs CE, which is in its own dependency group: `uv sync --group ce` (`just sync`
-leaves it out again). Its bindings to Cairo and Pango build from source where they have no
-wheels (pycairo on macOS and Linux, ManimPango on Linux), so that needs those libraries:
-`brew install cairo pkg-config` on macOS, `apt-get install libcairo2-dev libpango1.0-dev
-pkg-config` on Debian or Ubuntu.
+The integration corpus compares every case with Manim Community Edition's rendering of it. CE's reference hashes and frame data are in the repository; the videos are generated locally when needed. Rendering them (a new case, or a changed scene) needs CE, which is in its own dependency group: `uv sync --group ce` (`just sync` leaves it out again). Its bindings to Cairo and Pango build from source where they have no wheels (pycairo on macOS and Linux, ManimPango on Linux), so that needs those libraries: `brew install cairo pkg-config` on macOS, `apt-get install libcairo2-dev libpango1.0-dev pkg-config` on Debian or Ubuntu.
## Setting up the development environment
1. Clone the repository and enter it:
```sh
- git clone --filter=blob:none https://github.com/academa-labs/manimgx.git
+ git clone https://github.com/academa-labs/manimgx.git
cd manimgx
```
- The integration corpus's reference videos make the full history large.
- `--filter=blob:none` makes a partial clone: it downloads every commit, but an old
- version of a file only when a command needs it (checking out an old commit, say).
-
2. Make the environment:
```sh
diff --git a/docs/content/developer-guide/project-management.md b/docs/content/developer-guide/project-management.md
index a81b1a6d..5bcfa751 100644
--- a/docs/content/developer-guide/project-management.md
+++ b/docs/content/developer-guide/project-management.md
@@ -313,10 +313,7 @@ the project works. When a command or a rule changes, `AGENTS.md` changes with th
### [`.gitignore`](https://github.com/academa-labs/manimgx/blob/main/.gitignore)
-What is made, not written, stays out of git: the environment, the compiled engine,
-`rust/target/`, `dist/`, the built site, the docs' rendered films and generated reference,
-the coverage data and report, and render output (`media/`, `*.mp4`). The corpus's reference
-videos are `.mkv` files, and are committed.
+What is made, not written, stays out of git: the environment, the compiled engine, `rust/target/`, `dist/`, the built site, the docs' rendered films and generated reference, the coverage data and report, and render output (`media/`, `*.mp4`). The corpus's reference videos are `.mkv` files and are ignored by Git; their SHA-256 sidecars are committed.
## The package
diff --git a/docs/content/developer-guide/testing.md b/docs/content/developer-guide/testing.md
index 63c0fa07..89b9768b 100644
--- a/docs/content/developer-guide/testing.md
+++ b/docs/content/developer-guide/testing.md
@@ -190,7 +190,7 @@ A case is a folder in
- `scene.py`: the only source. It is Manim code, and it reaches the engine only through
`import manimgx`. A file the scene reads (an SVG, a sound) sits beside it.
-- `manimgx.mkv` and `ce.mkv`: each engine's frames, lossless.
+- `manimgx.mkv` and `ce.mkv`: each engine's lossless frames, generated locally and ignored by Git. Their `.sha256` sidecars record the exact reviewed video files.
- `case.json`: the facts, written by the tools. The hash of the source both renders came
from, the hash of every frame, and how the two engines' frames compare.
- `review.json`, once a person has reviewed the case: their verdict and note, pinned to the
@@ -208,11 +208,7 @@ Both engines run the same bytes. manimgx runs `scene.py` as it is. Manim runs it
([`run_ce.py`](https://github.com/academa-labs/manimgx/blob/main/tests/integration/corpus/run_ce.py)).
Each render runs in a process of its own, with a fixed hash seed.
-A frame is identified by the hash of its pixels, and stored in lossless video (x264 in
-RGB, written and read with [PyAV](https://pyav.basswood-io.com), FFmpeg's libraries in a
-wheel). A video is rewritten only when its pixels change, so
-rendering an unchanged scene again changes no file. The corpus renders at 960 × 540, 10
-frames per second.
+A frame is identified by the hash of its pixels, and locally stored in lossless video (x264 in RGB, written and read with [PyAV](https://pyav.basswood-io.com), FFmpeg's libraries in a wheel). A video is rewritten only when its pixels change, so rendering an unchanged scene again changes no file. The committed `.sha256` sidecars identify each reviewed video without putting the video in clone history. The corpus renders at 960 × 540, 10 frames per second.
### Comparing at the same scene time
@@ -263,20 +259,16 @@ checks every case three ways:
duration and timeline. This check covers every case, including those that differ from
Manim or await review.
-When `test_regression` fails, it reports changes to the duration, timeline or frames. For
-changed frames it measures the difference and writes the worst pair, the reference's frame
-beside today's, into `tests/integration/_diffs/<case>/`.
+When `test_regression` fails, it reports changes to the duration, timeline or frames. If the local reference video is present, it measures the difference and writes the worst pair, the reference's frame beside today's, into `tests/integration/_diffs/<case>/`. A fresh clone can still check every stored frame hash without those videos.
### Working with the corpus
`test_corpus.py` only checks; `just corpus` renders and reviews. A reference changes only
when a change means it to, and after someone has looked at the new frames.
-- **A new case** is a folder in `cases/` holding its `scene.py`. Render it with
- `just corpus render CASE`, which renders it in both engines and compares them; look at
- it (`just review`); and record your verdict with `just corpus review CASE working` (or
- `not_matching`, or `not_working`; `--note` says why). Commit the folder as the tools left
- it.
+On a fresh clone, run `just corpus render CASE` before opening a case in the review panel or running `just corpus diff CASE`; those views need the locally generated videos. The regression test uses the committed frame hashes without them.
+
+- **A new case** is a folder in `cases/` holding its `scene.py`. Render it with `just corpus render CASE`, which renders it in both engines and compares them; look at it (`just review`); and record your verdict with `just corpus review CASE working` (or `not_matching`, or `not_working`; `--note` says why). Commit the scene, facts, review and video hash sidecars; Git ignores the videos.
- **A change that is meant to change how cases look** renders their references again with
`just corpus render CASE…`. A case's review is pinned to the renders it was given for,
so it no longer speaks for the new ones: look at the new frames before you commit them,
@@ -300,10 +292,7 @@ when a change means it to, and after someone has looked at the new frames.
| `types` | The type report for every scene |
| `leaks` | Scenes that render differently after others, in one process |
-`render` rewrites a video only when its pixels change, and a `case.json` only when its
-facts do. Rendering Manim's references (the `ce` engine, and both engines when a scene
-changed) needs Manim Community Edition: `uv sync --group ce` (see
-[Setup](index.md#manim-community-edition)).
+`render` rewrites a local video only when its pixels change, updating that video's SHA-256 sidecar, and a `case.json` only when its facts do. Rendering Manim's references (the `ce` engine, and both engines when a scene changed) needs Manim Community Edition: `uv sync --group ce` (see [Setup](index.md#manim-community-edition)).
### The review panel
diff --git a/tests/integration/corpus/case.py b/tests/integration/corpus/case.py
index 8d571c66..70a74be5 100644
--- a/tests/integration/corpus/case.py
+++ b/tests/integration/corpus/case.py
@@ -5,7 +5,8 @@ A case is a directory under `cases/`:
- `scene.py`: the only source. It is Manim CE's code, and it reaches the engine only through
`manimgx`'s top level (and its types, `manimgx.typing`): manimgx runs it as written, and CE
runs the same bytes with `manimgx` resolving to `manim` (`run_ce.py`).
-- `manimgx.mkv`, `ce.mkv`: each engine's frames, lossless.
+- `manimgx.mkv`, `ce.mkv`: each engine's lossless frames, generated locally and ignored by Git.
+- `manimgx.mkv.sha256`, `ce.mkv.sha256`: hashes of the reviewed reference videos.
- `case.json`: facts, written by the tool — the source both renders came from, every frame's
hash (so a change is found without decoding video), and how the two compare, frame by frame,
in every metric.
@@ -225,6 +226,9 @@ class Case:
def video(self, engine: Engine) -> Path:
return self.dir / f"{engine}.mkv"
+ def video_hash(self, engine: Engine) -> Path:
+ return self.dir / f"{engine}.mkv.sha256"
+
@property
def facts_path(self) -> Path:
return self.dir / "case.json"
diff --git a/tests/integration/corpus/references.py b/tests/integration/corpus/references.py
index e0755850..4fd1e080 100644
--- a/tests/integration/corpus/references.py
+++ b/tests/integration/corpus/references.py
@@ -1,6 +1,7 @@
"""Making a case's references: render each engine, keep a video only when its pixels change,
compare the two, and record the facts."""
+import hashlib
import importlib.metadata
import importlib.util
import shutil
@@ -55,6 +56,7 @@ def render(case: Case, wanted: set[Engine]) -> tuple[Facts, str]:
video = case.video(engine)
if isinstance(result.frames, Failure):
video.unlink(missing_ok=True)
+ case.video_hash(engine).unlink(missing_ok=True)
notes.append(f"{engine} failed: {result.frames.error}")
elif (
isinstance(previous, Frames)
@@ -64,6 +66,12 @@ def render(case: Case, wanted: set[Engine]) -> tuple[Facts, str]:
notes.append(f"{engine} unchanged")
else:
shutil.move(fresh, video)
+ if previous != result.frames or not case.video_hash(engine).exists():
+ digest = hashlib.sha256(video.read_bytes()).hexdigest()
+ case.video_hash(engine).write_text(
+ f"{digest} {video.name}\n",
+ encoding="ascii",
+ )
notes.append(f"{engine} {'new' if previous is None else 'changed'}")
kept = None if old is None or changed else old.comparison
facts = _facts(case, source, renders["manimgx"], renders["ce"], ce_version, kept)
@@ -93,6 +101,14 @@ def _facts(
) -> Facts:
comparison = None
if isinstance(manimgx, Frames) and isinstance(ce, Frames):
+ if kept is None:
+ missing = [engine for engine in ENGINES if not case.video(engine).exists()]
+ if missing:
+ msg = (
+ f"{case.name}: reference video(s) missing ({', '.join(missing)}); "
+ f"run `just corpus render {case.name}` to regenerate them"
+ )
+ raise FileNotFoundError(msg)
comparison = kept or comparing.compare(
ce, manimgx, case.video("ce"), case.video("manimgx"), SIZE, FPS
)
diff --git a/tests/integration/test_corpus.py b/tests/integration/test_corpus.py
index 8ff112fd..432e7564 100644
--- a/tests/integration/test_corpus.py
+++ b/tests/integration/test_corpus.py
@@ -13,6 +13,7 @@ This module only checks. `python -m tests.integration.corpus` renders and review
"""
import ast
+import re
import tempfile
from pathlib import Path
@@ -61,7 +62,17 @@ def test_same_source(case: Case) -> None:
assert (facts.size, facts.fps) == (SIZE, FPS), "rendered at another size or rate"
for engine in ("manimgx", "ce"):
if isinstance(facts.render(engine), Frames):
- assert case.video(engine).exists(), f"{engine}.mkv is missing"
+ video = case.video(engine)
+ sidecar = case.video_hash(engine)
+ assert sidecar.exists(), f"{sidecar.name} is missing"
+ digest, separator, filename = (
+ sidecar.read_text(encoding="ascii").strip().partition(" ")
+ )
+ assert separator == " ", f"{sidecar.name} is malformed"
+ assert filename == video.name, f"{sidecar.name} is malformed"
+ assert re.fullmatch(r"[0-9a-f]{64}", digest) is not None, (
+ f"{sidecar.name} is malformed"
+ )
def _imported(tree: ast.Module) -> list[tuple[int, str]]:
@@ -119,6 +130,7 @@ def _explain(case: Case, expected: Frames, fresh: Frames) -> str:
lines.append(
f" {len(changed)} frames differ, first {changed[0]}, last {changed[-1]}"
)
+ if changed and case.video("manimgx").exists():
with tempfile.TemporaryDirectory() as tmp:
video = Path(tmp) / "fresh.mkv"
engines.run(case, "manimgx", video=video)
@@ -144,6 +156,10 @@ def _explain(case: Case, expected: Frames, fresh: Frames) -> str:
lines.append(
f" reference | today: {out / f'reference_vs_today_{worst:04d}.png'}"
)
+ elif changed:
+ lines.append(
+ " reference video unavailable; regenerate it for a frame comparison"
+ )
lines.append(
f" intended? just corpus render {case.name} (its review then needs renewing)"
)