Files
margin-docs/.github/workflows/ci.yml
T
2026-08-28 21:47:48 +05:30

79 lines
3.2 KiB
YAML

name: CI
on:
push:
branches: [main]
pull_request:
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
jobs:
frontend:
# macOS, not Linux. The keymap layer resolves the primary modifier from the user agent, so on a
# Linux runner `fits.test.ts` enumerates Ctrl chords and compares them against the Command ones
# the app actually binds. The app is macOS only; CI runs where it ships.
runs-on: macos-latest
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v6
with:
node-version: 26
- uses: pnpm/action-setup@v6
with:
version: 10
- run: pnpm install --frozen-lockfile
# `pnpm build` is tsc then vite, so this is the typecheck and the bundle in one step.
- run: pnpm build
- run: pnpm test
rust:
# Same reason, more sharply: `trash_does_not_hard_delete` asserts the file lands in
# `$HOME/.Trash`, which is where macOS puts it and not where Linux does.
runs-on: macos-latest
steps:
- uses: actions/checkout@v7
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- uses: swatinem/rust-cache@v2
with:
workspaces: src-tauri -> target
# tauri_build::build() wants a frontendDist that exists. The example file is what a fresh
# clone compiles against, so that is what CI uses.
- name: Stub the build inputs
run: mkdir -p dist && touch dist/index.html
# Every target except `no_write_on_open`, which gets the step below to itself.
- name: Test
working-directory: src-tauri
run: cargo test --lib --bins --test fs --test fts5 --test watch --test watch_payload --test pdf --test grammar --test export_writes_only_the_pdf
# The suite that checks the promise the whole project rests on, that the editor writes
# nothing the user did not edit. It runs against a real git repository rather than against a
# TempDir, because the evidence it wants is a folder somebody could plausibly have opened
# coming back from `git status` with no lines in it, and a bag of files in a TempDir cannot
# say that. The repository used to be built by hand at a fixed path under /tmp, which meant
# the suite ran on one machine until macOS reaped the folder and then ran nowhere, and that
# is why it spent a while excluded from this file. It is now built from scratch by
# `tests/support/notes_repo.rs` on the first test that asks for it: the documents are copied
# out of the markdown corpus, the vendored node_modules is generated, and a git init and one
# commit turn the result into the oracle. Nothing has to exist on the runner beforehand
# except git itself, and the suite says so plainly if git is missing rather than passing on a
# folder nobody checked.
#
# It gets its own step because the tests share that one folder and several of them mutate it,
# so they have to run one at a time. Passing `--test-threads=1` to the command above would
# slow the other suites to the same pace for no reason.
- name: Test no_write_on_open
working-directory: src-tauri
run: cargo test --test no_write_on_open -- --test-threads=1