Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 53 additions & 26 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ name: CI
# changes decides whether the pull request needs the browser suites
# (not while it is a draft, nor for docs-only changes), and
# fetches the shard timings from the latest green main run
# checks Biome, ESLint, typecheck, unit tests, production build
# e2e the Playwright chromium and library projects in 3 shards,
# checks Biome, ESLint, typecheck, unit tests (parallel), production
# build
# e2e the Playwright chromium and library projects in 4 shards,
# against `next dev` + Hocuspocus and the library's Bun harness
# perf the typing-budget project on its own runner, one worker
# perf the perf project in two jobs, each on its own runner with one
# worker: the typing budget, and the feature budgets
# desktop the desktop static export and the local (dev bridge) project;
# not a required check
# e2e-gate "Playwright (Chromium)": merges the shard reports and passes
Expand Down Expand Up @@ -121,7 +123,11 @@ jobs:
timings=$(jq -c . "$RUNNER_TEMP/timings/e2e-timings.json") || timings=""
fi
echo "timings=$timings" >> "$GITHUB_OUTPUT"
echo "Shard timings from run ${run:-none}: ${timings:+found}${timings:-none}"
if [ -n "$timings" ]; then
echo "Shard timings: $(jq length <<< "$timings") files, from run $run"
else
echo "Shard timings: none (latest green run: ${run:-none})"
fi

checks:
name: Lint, typecheck, unit tests, build
Expand Down Expand Up @@ -174,15 +180,14 @@ jobs:
- name: Typecheck
run: bun run typecheck

# `bun run test` skips the stress probe; it runs below as a non-gating
# benchmark.
# Every file with `bun test --parallel`, then the files that assert a
# wall-clock budget serially (scripts/unit-tests.ts). The repository
# variable UNIT_SERIAL=1 runs them all serially instead. The stress
# probe runs nightly.
- name: Unit tests
run: bun run test

# Shared runners vary in speed, so a miss here is reported, not fatal.
- name: Stress benchmark (informational)
continue-on-error: true
run: bun run test:stress
env:
UNIT_SERIAL: ${{ vars.UNIT_SERIAL }}
run: bun scripts/unit-tests.ts

- name: Production build
run: bun run build
Expand All @@ -193,7 +198,7 @@ jobs:
run: bun scripts/check-editor-chunk-size.ts

e2e:
name: Playwright shard ${{ matrix.shard }}/3
name: Playwright shard ${{ matrix.shard }}/4
needs: changes
if: needs.changes.outputs.e2e == 'true'
runs-on: ubuntu-latest
Expand All @@ -204,7 +209,7 @@ jobs:
# Every shard reports, so one failure does not hide another.
fail-fast: false
matrix:
shard: [1, 2, 3]
shard: [1, 2, 3, 4]
env: &e2e-env
# Same raised limits as playwright.config.ts: three workers open many
# sockets and documents from one IP.
Expand Down Expand Up @@ -266,7 +271,7 @@ jobs:
SHARD: ${{ matrix.shard }}
run: |
printf '%s' "$TIMINGS" > "$RUNNER_TEMP/e2e-timings.json"
args=$(bun scripts/e2e-shards.ts plan "$SHARD/3" \
args=$(bun scripts/e2e-shards.ts plan "$SHARD/4" \
"$RUNNER_TEMP/e2e-timings.json" "$RUNNER_TEMP/shard-tests.txt")
echo "args=$args" >> "$GITHUB_OUTPUT"

Expand Down Expand Up @@ -303,13 +308,25 @@ jobs:
retention-days: 7

perf:
name: Playwright perf (typing budget)
name: Playwright perf (${{ matrix.suite }})
needs: changes
if: needs.changes.outputs.e2e == 'true'
runs-on: ubuntu-latest
timeout-minutes: 20
permissions:
contents: read
strategy:
fail-fast: false
# The typing budget (performance, toolbar-perf) is one job; every other
# spec of the perf project is the other, so a new perf spec lands there.
matrix:
include:
- suite: typing budget
select: --test-list
key: perf-typing
- suite: features
select: --test-list-invert
key: perf-features
env: *e2e-env
steps:
- *checkout
Expand All @@ -319,21 +336,25 @@ jobs:
- *install-chromium
- *start-dev-servers

# The typing budget compares timings, so it gets a runner of its own
# and one worker (the project's setting). --no-deps: the project
# depends on chromium, which the shards run.
# Budgets compare timings, so each job gets a runner of its own and
# one worker (the project's setting). --no-deps: the project depends
# on chromium, which the shards run.
- name: Run Playwright
env:
PLAYWRIGHT_BLOB_OUTPUT_NAME: report-perf.zip
run: >-
CI="" bun playwright test --project=perf --no-deps --retries=1
--trace off --reporter=list,blob
PLAYWRIGHT_BLOB_OUTPUT_NAME: report-${{ matrix.key }}.zip
SELECT: ${{ matrix.select }}
run: |
printf '%s\n' performance.spec.ts toolbar-perf.spec.ts \
> "$RUNNER_TEMP/typing-budget.txt"
CI="" bun playwright test --project=perf --no-deps \
"$SELECT=$RUNNER_TEMP/typing-budget.txt" --retries=1 \
--trace off --reporter=list,blob

- name: Upload blob report
if: ${{ !cancelled() }}
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: blob-report-perf
name: blob-report-${{ matrix.key }}
path: blob-report/
if-no-files-found: ignore
retention-days: 1
Expand All @@ -342,7 +363,7 @@ jobs:
if: failure()
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: e2e-results-perf
name: e2e-results-${{ matrix.key }}
path: |
test-results/
${{ runner.temp }}/dev.log
Expand Down Expand Up @@ -485,13 +506,19 @@ jobs:
fi

# Green pushes to main only: the shard timings the next runs pack by.
# Averaged with the timings this run packed by (the changes job's
# output, from the previous green push), so one noisy run moves the
# plan only halfway.
- name: Write shard timings
if: success() && github.event_name == 'push' && github.ref == 'refs/heads/main'
env:
PLAYWRIGHT_JSON_OUTPUT_NAME: ${{ runner.temp }}/report.json
PREVIOUS: ${{ needs.changes.outputs.timings }}
run: |
bun playwright merge-reports --reporter=json all-blob-reports
bun scripts/e2e-shards.ts timings "$RUNNER_TEMP/report.json" e2e-timings.json
printf '%s' "$PREVIOUS" > "$RUNNER_TEMP/previous-timings.json"
bun scripts/e2e-shards.ts timings "$RUNNER_TEMP/report.json" \
e2e-timings.json "$RUNNER_TEMP/previous-timings.json"

- name: Publish shard timings
if: success() && github.event_name == 'push' && github.ref == 'refs/heads/main'
Expand Down
46 changes: 46 additions & 0 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ name: Nightly
# from 3 clients against Hocuspocus (spec §7 abuse soak)
# mixed-version N+1, release N and pre-N clients on one document with
# the gate env at its default (spec §3.1 N+1 ship gate)
# unit-runs the unit tests fully serial and as CI runs them (parallel,
# clock-budget files serial), compared file by file, then
# the stress probe (informational)
# library-property the web library's multi-writer compaction property
# test (web library §2.5, W-D3) at 50,000 runs, seeded
# from the run id; a failure prints the seed to replay
Expand Down Expand Up @@ -364,6 +367,49 @@ jobs:
if-no-files-found: ignore
retention-days: 7

# CI runs the unit tests with --parallel (scripts/unit-tests.ts). Here a
# fully serial run checks it: a file whose counts differ fails the night.
unit-runs:
name: Unit tests, serial vs parallel; stress probe
runs-on: ubuntu-latest
timeout-minutes: 20
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false

- name: Set up Bun
uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
with:
bun-version-file: .tool-versions

- name: Install
run: bun install --frozen-lockfile

- name: Unit tests (serial)
run: |
mkdir -p "$RUNNER_TEMP/unit"
bun run test --reporter=junit --reporter-outfile="$RUNNER_TEMP/unit/all-serial.xml"

- name: Unit tests (as CI runs them)
if: ${{ !cancelled() }}
run: bun scripts/unit-tests.ts --junit "$RUNNER_TEMP/unit"

- name: Compare serial and parallel
if: ${{ !cancelled() }}
run: >-
bun scripts/compare-unit-runs.ts "$RUNNER_TEMP/unit/all-serial.xml"
"$RUNNER_TEMP/unit/parallel.xml" "$RUNNER_TEMP/unit/serial.xml"

# Shared runners vary in speed, so a miss here is reported, not fatal.
- name: Stress benchmark (informational)
if: ${{ !cancelled() }}
continue-on-error: true
run: bun run test:stress

library-property:
name: Web library compaction property (50,000 runs)
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,5 @@
- Heading stack extensions (fold, filter, drag, scale) should stay cleanly bounded so other Tiptap apps can adopt them without pulling in the full `components/document-editor` shell
- Document schema enforces title-first (`heading block*`), heading levels 1-6, and title-scoped paste handling; empty docs are seeded when the Yjs fragment is empty after a server sync
- Editor uses the `@docs.plus/extension-*` packages (Hyperlink, InlineCode, Indent, Placeholder, Mermaid, HyperMultimediaKit) in place of StarterKit `link`/`code`, `@tiptap/extensions` Placeholder and `@tiptap/extension-image`; mark names are `hyperlink` and `inlineCode` (legacy `link`/`code` in stored Yjs docs are renamed server-side in Hocuspocus `afterLoadDocument`); the extensions render their own popovers/toolbars, so `tiptap-ui` only adds toolbar triggers; `.github/workflows/docs-plus-extensions.yml` refreshes them daily (04:17 UTC) via PR
- CI: `.github/workflows/ci.yml` runs on PRs, the merge queue (`merge_group`) and pushes to `main`; only PR runs are cancelled by a newer push (a started `main` run always finishes and can deploy). Required checks (ruleset names, keep stable): `Lint, typecheck, unit tests, build` (`bun audit --audit-level=high`, Biome, ESLint, typecheck, unit tests without `tests/unit/stress`, build, editor chunk size) and `Playwright (Chromium)`, an always-run gate job that merges blob reports and needs `Playwright shard 1/3`–`3/3` (`make dev`, warm-up, the library harness, `CI= bun playwright test --project=chromium --project=library --test-list=<files> --retries=1`, files packed by duration by `scripts/e2e-shards.ts` from the `e2e-timings` artifact that only green pushes to `main` publish, falling back to `--shard=N/3`) and `Playwright perf (typing budget)` (`--project=perf --no-deps`, own runner, one worker); the `desktop` job (`Desktop renderer (export and local)`, not required) runs the desktop export and `local` projects; draft PRs and PRs touching only `docs/**` or `*.md` (not `desktop/**`) skip the shards, perf and `desktop` via the `Changed files` job and still pass the gate, which fails closed on any skip in the merge queue, on `main` or on a ready PR (`ready_for_review` starts the full run); open PRs as drafts until ready; `tests/unit/ci/ci-workflow.test.ts` pins this shape; the stress probe is a non-blocking timing benchmark; `tests/unit/ci/workflow-permissions.test.ts` requires explicit read-only job permissions, `persist-credentials: false` and SHA-pinned actions in every workflow, and no checkout plus a success-and-push `if` in `workflow_run` workflows; `.github/workflows/nightly.yml` (03:41 and 08:00 UTC and on demand) runs the `pwa` project on a production build, yjs-soak, quick soaks and the load harness; deploys: `.github/workflows/deploy.yml` (`workflow_run` after CI succeeds on a push to `main` when the `AUTO_DEPLOY` repo variable is `on`, plus manual `gh workflow run deploy.yml`; it refuses commits not on `main` or without green CI, then SSHes to the host whose key can only run `scripts/deploy.sh`: build in a second checkout, restart Hocus, swap `.next`, auto-revert if Next.js does not answer, then `startOrRestart` `editor-purge`; PM2 restarts use `ecosystem.config.cjs --update-env`, so production env lives in that file; see `docs/operations/deploy-runbook.md`); `.github/workflows/desktop-shell.yml` (3-OS installers and `electron` specs) runs on every PR and the merge queue behind its own always-run `Desktop shell (gate)` check (builds only for ready PRs touching its paths; always in the merge queue, nightly and on demand; fails closed), pinned by `tests/unit/ci/desktop-shell-workflow.test.ts`; releases: push a `vX.Y.Z` tag on `main` and `.github/workflows/release.yml` publishes the GitHub release (generated PR list + CHANGELOG link); the docs.plus update workflow starts CI on its branch with `gh workflow run` (bot-made PRs start no workflows, and CI is a required check)
- CI: `.github/workflows/ci.yml` runs on PRs, the merge queue (`merge_group`) and pushes to `main`; only PR runs are cancelled by a newer push (a started `main` run always finishes and can deploy). Required checks (ruleset names, keep stable): `Lint, typecheck, unit tests, build` (`bun audit --audit-level=high`, Biome, ESLint, typecheck, unit tests via `bun scripts/unit-tests.ts`: `--parallel` except the clock-budget `SERIAL_FILES`, which run serially after; repo variable `UNIT_SERIAL=1` makes it all serial; no `tests/unit/stress`, which runs nightly with a serial-vs-parallel comparison; build, editor chunk size) and `Playwright (Chromium)`, an always-run gate job that merges blob reports and needs `Playwright shard 1/4`–`4/4` (`make dev`, warm-up, the library harness, `CI= bun playwright test --project=chromium --project=library --test-list=<files> --retries=1`, files packed by duration by `scripts/e2e-shards.ts` from the `e2e-timings` artifact that only green pushes to `main` publish, falling back to `--shard=N/4`) and `Playwright perf (typing budget)` / `Playwright perf (features)` (`--project=perf --no-deps`, each on its own runner with one worker; typing budget is `performance` and `toolbar-perf` via `--test-list`, features is the rest via `--test-list-invert`); the `desktop` job (`Desktop renderer (export and local)`, not required) runs the desktop export and `local` projects; draft PRs and PRs touching only `docs/**` or `*.md` (not `desktop/**`) skip the shards, perf and `desktop` via the `Changed files` job and still pass the gate, which fails closed on any skip in the merge queue, on `main` or on a ready PR (`ready_for_review` starts the full run); open PRs as drafts until ready; `tests/unit/ci/ci-workflow.test.ts` pins this shape; the stress probe is a non-blocking timing benchmark that runs nightly (`unit-runs`); `tests/unit/ci/workflow-permissions.test.ts` requires explicit read-only job permissions, `persist-credentials: false` and SHA-pinned actions in every workflow, and no checkout plus a success-and-push `if` in `workflow_run` workflows; `.github/workflows/nightly.yml` (03:41 and 08:00 UTC and on demand) runs the `pwa` project on a production build, yjs-soak, quick soaks and the load harness; deploys: `.github/workflows/deploy.yml` (`workflow_run` after CI succeeds on a push to `main` when the `AUTO_DEPLOY` repo variable is `on`, plus manual `gh workflow run deploy.yml`; it refuses commits not on `main` or without green CI, then SSHes to the host whose key can only run `scripts/deploy.sh`: build in a second checkout, restart Hocus, swap `.next`, auto-revert if Next.js does not answer, then `startOrRestart` `editor-purge`; PM2 restarts use `ecosystem.config.cjs --update-env`, so production env lives in that file; see `docs/operations/deploy-runbook.md`); `.github/workflows/desktop-shell.yml` (3-OS installers and `electron` specs) runs on every PR and the merge queue behind its own always-run `Desktop shell (gate)` check (builds only for ready PRs touching its paths; always in the merge queue, nightly and on demand; fails closed), pinned by `tests/unit/ci/desktop-shell-workflow.test.ts`; releases: push a `vX.Y.Z` tag on `main` and `.github/workflows/release.yml` publishes the GitHub release (generated PR list + CHANGELOG link); the docs.plus update workflow starts CI on its branch with `gh workflow run` (bot-made PRs start no workflows, and CI is a required check)
- Testing stack is `bun test` (happy-dom preload; all files share one process, so `mock.module` spreads the real module and is followed by `await import()`, and import-time env goes through `importFresh()` + `resetModules()` in `afterEach`) + Playwright (+ Yjs load/soak harness); `EditorPage.waitForSync()` waits for `data-server-synced` (editable earlier from the device copy), and tests type at full speed: misplaced text means an app bug, not a missing wait; use `bun run test` (it skips the stress probe; `bun run test:stress` runs it), run Playwright with `CI=` against existing dev servers, and use `window.__HOCUS_URL`/`window.__HOCUS_TOKEN`/`window.__GLOBAL_TABS_DOC` hooks for test isolation; subprocesses that spawn `bun run hocus` for reconnect-heavy flows should set `HOCUS_THROTTLE=0` so official throttle does not false-positive ban clients; e2e hocus also needs `HOCUS_ALLOW_ISOLATED_TABS_DOCS=1` and raised socket limits (see `playwright.config.ts`), and `next dev` and hocus must share one `DB_PATH` (the DELETE route and Hocuspocus read the same tombstones); e2e needs `next dev` because helpers use `window.__tiptap_editor`; the `pwa` Playwright project runs only against a production build (`PWA_BASE_URL`); all other projects block service workers
Loading
Loading