Skip to content

armgit / klad

Public Imported from GitHub
0

A drawing app built for agent/human collaboration

Rust

The test of each release's drawings compares pixels only where its hashes were made

Indicode BV8da48c944976
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 4e718a8..48a0a95 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -65,7 +65,7 @@ jobs:
continue-on-error: true
run: |
set -o pipefail
- cargo test --workspace 2>&1 | tee tests.log
+ cargo test --workspace --no-fail-fast 2>&1 | tee tests.log
- name: Say what happened
if: always()
run: |
@@ -94,7 +94,7 @@ jobs:
if [ -f tests.log ]; then
failed="$({ grep -E "^test .* FAILED$" tests.log || true; } | sed -E 's/^test (.*) \.\.\. FAILED$/\1/' | sort -u | tr '\n' ' ')"
[ -z "$failed" ] || echo "::warning title=${{ matrix.name }} tests that failed::$failed"
- { grep -A 1 "panicked at" tests.log || true; } | { grep -v "^--$" || true; } | paste -d ' ' - - | cut -c1-400 | head -n 8 | while read -r line; do
+ { grep -A 3 "panicked at" tests.log || true; } | { grep -v "^--$" || true; } | paste -d ' ' - - - - | cut -c1-600 | head -n 8 | while read -r line; do
echo "::warning title=${{ matrix.name }} test failure::$line"
done
{ grep -E "^test result|^error" tests.log || true; } | { grep -v " 0 failed" || true; } | head -n 4 | while read -r line; do
diff --git a/crates/cli/tests/formats.rs b/crates/cli/tests/formats.rs
index c2ff263..71d0972 100644
--- a/crates/cli/tests/formats.rs
+++ b/crates/cli/tests/formats.rs
@@ -3,6 +3,8 @@ use std::fs;
use std::path::{Path, PathBuf};
use std::process::Command;
+const SAME_PIXELS: bool = cfg!(target_arch = "aarch64");
+
fn copy(from: &Path, to: &Path) {
fs::create_dir_all(to).unwrap();
fs::read_dir(from).unwrap().map(Result::unwrap).for_each(|entry| {
@@ -92,7 +94,11 @@ fn drawings_saved_by_every_release_open_and_render_as_they_did() {
frames.iter().for_each(|(frame, digest)| {
let key = (format!("{name}/{bundle}"), frame.clone());
let expected = accepted.get(&key).unwrap_or(digest);
- if now.get(frame) != Some(expected) {
+ let differs = match now.get(frame) {
+ None => true,
+ Some(found) => SAME_PIXELS && found != expected,
+ };
+ if differs {
wrong.push(format!(
"{name}/{bundle} frame {frame}: was {expected}, now {}",
now.get(frame).map_or("missing", String::as_str)
@@ -104,7 +110,8 @@ fn drawings_saved_by_every_release_open_and_render_as_they_did() {
let _ = fs::remove_dir_all(&scratch);
assert!(
wrong.is_empty(),
- "drawings from a release render differently (fix it, or list the change in tests/formats/accepted.txt and the release notes):\n{}",
+ "drawings from a release no longer open or render as they did (fix it, or list the change in tests/formats/accepted.txt and the release notes; pixels are compared on {}, where the hashes were made, and elsewhere each frame only has to render):\n{}",
+ "aarch64",
wrong.join("\n")
);
assert!(
diff --git a/docs/DESIGN.md b/docs/DESIGN.md
index bdcfc7c..b546f3f 100644
--- a/docs/DESIGN.md
+++ b/docs/DESIGN.md
@@ -29,7 +29,7 @@ crates/
Two binaries from one crate: `klad`, the command line, and `klad-editor`, the editor alone (a windowed program on Windows, the executable of `klad.app` on a Mac, started by the Linux AppImage). `klad open [bundle]` launches the same editor from the command line, on the bundle or, without one, on the start window (new, open, recent). `--no-default-features` builds `klad` without the editor. `klad --version` and the editor's About show the version and `git describe` of the commit it was built from (`crates/version.rs`, shared by both crates' build scripts; `KLAD_BUILD` overrides it).
-**Platforms and packaging (M7).** Folders follow each platform: settings in `~/Library/Application Support/klad`, `%APPDATA%\klad` or `$XDG_CONFIG_HOME/klad`; downloaded fonts in the same places' data folder; drawings in `~/Drawings` by default. The open panel is `NSOpenPanel` on macOS and `rfd` elsewhere (the XDG portal on Linux, the common dialog on Windows). The pen: macOS reads `NSEvent`; elsewhere a pen that the system reports as a touch with force (Windows pens through `WM_POINTER`) draws with that pressure (`pen::from_egui`), and anything else draws as a mouse at full pressure; Linux tablets report no pressure through `winit` yet. `packaging/` makes the downloads: `macos/app.sh` builds `klad.app` (both binaries, lipo'd when several targets are given, the fonts, licences and skill in `Resources`, `.klad` declared as a document package of type `com.indicode.klad.drawing` so Finder shows a drawing as one item and opens it in klad) and a disk image; `archive.sh <target>` builds a `tar.gz` or `zip` with both binaries, `fonts/`, the licences and `SKILL.md`, and an AppImage on Linux when `APPIMAGETOOL` is set; `icon/` draws the icon in klad and packs `klad.icns` and `klad.ico` (the icon is a K in two brush strokes with paint body and a dry edge, an ink stem and one ember stroke for the arm and the leg; `build.sh <folder>` keeps the drawing to open in the editor). Builds use the `dist` profile (no debug info, stripped, thin LTO); the samples hash the same from it. The fonts are found next to the binary (`fonts/`), in `../Resources/fonts` or `../share/klad/fonts`. On macOS a drawing opened from Finder arrives as an `application:openURLs:` message, which klad adds to `NSObject` before the event loop starts so it reaches whatever delegate `winit` installs; the paths queue up (`opened.rs`) and the start window or editor opens the last. `klad install` puts `klad` on the terminal's path (a link in `/usr/local/bin` through an administrator prompt on macOS, `~/.local/bin` on Linux, the user's `PATH` on Windows); the editor's document menu runs it as a job. `klad skill` prints the agent skill compiled into the binary; `klad samples` lists and copies the sample drawings a build carries (First start, below). Builds are sold on itch.io (later Steam) for macOS and Windows, and Linux is built from source: on a version tag the `release` workflow builds the Windows version and pushes it to itch.io with butler (never as a workflow artifact, which anyone could download from a public repository) and publishes the changelog section as the release notes, and `just itch-mac` builds and pushes the Mac app from a Mac; `check` runs the format check and the licence and advisory audit on every pull request and every push to `main`; `build` runs on every push to `main` and when started by hand from the Actions tab (on any branch), not on pull requests, since three builds per pull request is a lot; it does what the README tells someone who clones klad, on macOS, Linux and Windows: the Linux packages it lists, `just compile`, then a stroke painted and rendered with that build, then the tests. Each job writes what it saw (the errors and the last lines of each step) into its summary on the run's page. The tests have to pass on macOS and Linux; on Windows, where klad is not tested yet, they are reported only. The editor asks the GitHub releases API at most once a day (`updates.rs`, curl on a thread, off in the settings window) and, when a newer version is out, says so in the start window, the message line and About, with a link to what changed; it installs nothing. About's "check now" and `klad updates` check on demand (`updates::spawn`, a channel per check) and say why a check failed: no release published yet, no network, or a feed that does not parse.
+**Platforms and packaging (M7).** Folders follow each platform: settings in `~/Library/Application Support/klad`, `%APPDATA%\klad` or `$XDG_CONFIG_HOME/klad`; downloaded fonts in the same places' data folder; drawings in `~/Drawings` by default. The open panel is `NSOpenPanel` on macOS and `rfd` elsewhere (the XDG portal on Linux, the common dialog on Windows). The pen: macOS reads `NSEvent`; elsewhere a pen that the system reports as a touch with force (Windows pens through `WM_POINTER`) draws with that pressure (`pen::from_egui`), and anything else draws as a mouse at full pressure; Linux tablets report no pressure through `winit` yet. `packaging/` makes the downloads: `macos/app.sh` builds `klad.app` (both binaries, lipo'd when several targets are given, the fonts, licences and skill in `Resources`, `.klad` declared as a document package of type `com.indicode.klad.drawing` so Finder shows a drawing as one item and opens it in klad) and a disk image; `archive.sh <target>` builds a `tar.gz` or `zip` with both binaries, `fonts/`, the licences and `SKILL.md`, and an AppImage on Linux when `APPIMAGETOOL` is set; `icon/` draws the icon in klad and packs `klad.icns` and `klad.ico` (the icon is a K in two brush strokes with paint body and a dry edge, an ink stem and one ember stroke for the arm and the leg; `build.sh <folder>` keeps the drawing to open in the editor). Builds use the `dist` profile (no debug info, stripped, thin LTO); the samples hash the same from it. The fonts are found next to the binary (`fonts/`), in `../Resources/fonts` or `../share/klad/fonts`. On macOS a drawing opened from Finder arrives as an `application:openURLs:` message, which klad adds to `NSObject` before the event loop starts so it reaches whatever delegate `winit` installs; the paths queue up (`opened.rs`) and the start window or editor opens the last. `klad install` puts `klad` on the terminal's path (a link in `/usr/local/bin` through an administrator prompt on macOS, `~/.local/bin` on Linux, the user's `PATH` on Windows); the editor's document menu runs it as a job. `klad skill` prints the agent skill compiled into the binary; `klad samples` lists and copies the sample drawings a build carries (First start, below). Builds are sold on itch.io (later Steam) for macOS and Windows, and Linux is built from source: on a version tag the `release` workflow builds the Windows version and pushes it to itch.io with butler (never as a workflow artifact, which anyone could download from a public repository) and publishes the changelog section as the release notes, and `just itch-mac` builds and pushes the Mac app from a Mac; `check` runs the format check and the licence and advisory audit on every pull request and every push to `main`; `build` runs on every push to `main` and when started by hand from the Actions tab (on any branch), not on pull requests, since three builds per pull request is a lot; it does what the README tells someone who clones klad, on macOS, Linux and Windows: the Linux packages it lists, `just compile`, then a stroke painted and rendered with that build, then the tests. Each job writes what it saw (the errors and the last lines of each step) into its summary on the run's page. The tests have to pass on macOS and Linux; on Windows, where klad is not tested yet, they are reported only. Pixel hashes are the same on machines of one processor family only: the vector parts are drawn by Skia, whose fast paths differ between ARM and Intel. So the test that opens the drawings of each release (`crates/cli/tests/formats.rs`) compares pixels on ARM, where its hashes were made (the Macs and the macOS runner), and on Intel checks that every frame still opens and renders. The editor asks the GitHub releases API at most once a day (`updates.rs`, curl on a thread, off in the settings window) and, when a newer version is out, says so in the start window, the message line and About, with a link to what changed; it installs nothing. About's "check now" and `klad updates` check on demand (`updates::spawn`, a channel per check) and say why a check failed: no release published yet, no network, or a feed that does not parse.
### Stack