Commit 452133c901
Verified · cmc
Layout: unified · split
CONTRIBUTING.org +4
| @@ -178,6 +178,10 @@ Each release goes out on three channels, in this order, from the same commit: | ||
| 178 | 178 | 2. =scripts/release-ios.sh=, the iOS app. |
| 179 | 179 | 3. =scripts/release-macos.sh=, the Mac App Store app. |
| 180 | 180 | |
| 181 | Each of them runs the performance gates (=ORGSTAR_GATES=1 swift test -c release --filter GateTests=) | |
| 182 | before it builds anything for signing, and stops if one misses. Run releases on a Mac that is | |
| 183 | otherwise idle, since the gates measure time. | |
| 184 | ||
| 181 | 185 | The App Store builds take their version from =MARKETING_VERSION= in =ios/Orgstar.xcodeproj=, |
| 182 | 186 | which every target shares and appstore-kit requires to be the same across them. Set it to |
| 183 | 187 | =<version>= before the release. |
Tests/OrgEditorAppKitTests/GateTests.swift +27 −2
| @@ -10,9 +10,11 @@ import Testing | ||
| 10 | 10 | /// ORGSTAR_GATES=1 swift test -c release --filter GateTests |
| 11 | 11 | /// |
| 12 | 12 | /// `ORGSTAR_GATE_FILE` adds a real file to the synthetic ones. Memory limits follow the design: |
| 13 | /// 10x the file size for typical documents, 45x for the synthetic worst cases. | |
| 13 | /// 10x the file size for typical documents, 45x for the synthetic worst cases. The 10 MB and | |
| 14 | /// workspace budgets are what the code did when they were set, plus headroom. The tests run one | |
| 15 | /// at a time so their timings don't overlap. | |
| 14 | 16 | @MainActor |
| 15 | @Suite(.enabled(if: ProcessInfo.processInfo.environment["ORGSTAR_GATES"] != nil)) | |
| 17 | @Suite(.enabled(if: ProcessInfo.processInfo.environment["ORGSTAR_GATES"] != nil), .serialized) | |
| 16 | 18 | struct GateTests { |
| 17 | 19 | /// About 1 MB of body text under a single top-level heading. |
| 18 | 20 | /// Entries with property and LOGBOOK drawers, all folded when the file opens. |
| @@ -45,6 +47,23 @@ struct GateTests { | ||
| 45 | 47 | return text |
| 46 | 48 | }() |
| 47 | 49 | |
| 50 | /// About 10 MB of headings with planning lines and drawers, paragraphs with markup, lists, | |
| 51 | /// tables, source blocks and footnotes. | |
| 52 | static let tenMegabytes: String = { | |
| 53 | var text = "" | |
| 54 | var n = 0 | |
| 55 | while text.utf8.count < 10_000_000 { | |
| 56 | text += "* TODO Heading \(n) :tag:\nSCHEDULED: <2026-10-04 Sun>\n:PROPERTIES:\n:ID: \(n)-uuid\n:END:\n" | |
| 57 | text += "Paragraph \(n) with *bold*, /italic/, =code=, a [[https://example.com/\(n)][link]] and a footnote[fn:\(n)].\n\n" | |
| 58 | text += "- item \(n)\n - nested [ ] task\n\n" | |
| 59 | text += "| id | name |\n|----+------|\n| \(n) | row \(n) |\n\n" | |
| 60 | text += "#+begin_src swift\nlet n = \(n)\n#+end_src\n\n" | |
| 61 | text += "[fn:\(n)] Footnote \(n).\n\n" | |
| 62 | n += 1 | |
| 63 | } | |
| 64 | return text | |
| 65 | }() | |
| 66 | ||
| 48 | 67 | struct Result: CustomStringConvertible { |
| 49 | 68 | var name: String |
| 50 | 69 | var bytes: Int |
| @@ -112,5 +131,11 @@ struct GateTests { | ||
| 112 | 131 | #expect(result.newlineP95 < .milliseconds(16), "\(name): blank line") |
| 113 | 132 | #expect(result.memoryRatio < memoryLimit, "\(name): memory") |
| 114 | 133 | } |
| 134 | let large = measure("10 MB mixed document", Self.tenMegabytes) | |
| 135 | print("GATE \(large)") | |
| 136 | #expect(large.open < .milliseconds(1_500), "10 MB: open") | |
| 137 | #expect(large.typingP95 < .milliseconds(400), "10 MB: typing") | |
| 138 | #expect(large.newlineP95 < .milliseconds(400), "10 MB: blank line") | |
| 139 | #expect(large.memoryRatio < 40, "10 MB: memory") | |
| 115 | 140 | } |
| 116 | 141 | } |
Tests/OrgEditorAppKitTests/WorkspaceGateTests.swift added +100
| @@ -0,0 +1,100 @@ | ||
| 1 | import Foundation | |
| 2 | import OrgApp | |
| 3 | import OrgCore | |
| 4 | import Testing | |
| 5 | ||
| 6 | /// Gates for a large workspace: the first index build, the agenda refresh and the backlinks of | |
| 7 | /// a file and a heading. In `GateTests` so they run one at a time with the editor gates. | |
| 8 | extension GateTests { | |
| 9 | /// Writes `count` notes of eight headings each, about 2 kB a note. Every heading has an ID | |
| 10 | /// and a paragraph; the first `fiveLinks` notes have five links and the rest four. A third of | |
| 11 | /// the headings are TODOs, and every hundredth note has one scheduled in the week of | |
| 12 | /// 5 October 2026. | |
| 13 | static func writeNotes(_ count: Int, fiveLinks: Int, to folder: URL) throws { | |
| 14 | let week = ["2026-10-05 Mon", "2026-10-06 Tue", "2026-10-07 Wed", "2026-10-08 Thu", "2026-10-09 Fri", "2026-10-10 Sat", "2026-10-11 Sun"] | |
| 15 | try FileManager.default.createDirectory(at: folder, withIntermediateDirectories: true) | |
| 16 | for n in 0..<count { | |
| 17 | let links = [ | |
| 18 | "[[id:\((n + 1) % count)-0][note \((n + 1) % count)]]", | |
| 19 | "[[file:note-\((n + 2) % count).org::*Heading \((n + 2) % count).1][a heading]]", | |
| 20 | "[[*Heading \(n).2]]", | |
| 21 | "[[file:note-\((n + 3) % count).org]]", | |
| 22 | "[[https://example.com/\(n)][the web]]" | |
| 23 | ].prefix(n < fiveLinks ? 5 : 4) | |
| 24 | var text = "#+title: Note \(n)\n\n" | |
| 25 | for h in 0..<8 { | |
| 26 | text += "* \(h % 3 == 0 ? "TODO " : "")Heading \(n).\(h) :tag\(h):\n" | |
| 27 | if h == 0, n % 100 == 0 { text += "SCHEDULED: <\(week[n / 100 % 7])>\n" } | |
| 28 | text += ":PROPERTIES:\n:ID: \(n)-\(h)\n:END:\n" | |
| 29 | text += "Paragraph of heading \(h) in note \(n), with *bold*, /italic/ and =code=, about as long as a note someone wrote. It goes on for a second sentence about nothing in particular.\n" | |
| 30 | if h < links.count { text += "See \(links[h]).\n" } | |
| 31 | text += "\n" | |
| 32 | } | |
| 33 | try Data(text.utf8).write(to: folder.appendingPathComponent("note-\(n).org")) | |
| 34 | } | |
| 35 | } | |
| 36 | ||
| 37 | /// A folder of `count` notes, indexed on disk as the app does, and how long the first build took. | |
| 38 | static func workspace(_ count: Int, fiveLinks: Int, in scratch: URL) async throws -> (model: WorkspaceModel, build: Duration) { | |
| 39 | let notes = scratch.appendingPathComponent("notes") | |
| 40 | try writeNotes(count, fiveLinks: fiveLinks, to: notes) | |
| 41 | let model = try WorkspaceModel(directory: scratch.appendingPathComponent("data")) | |
| 42 | let start = ContinuousClock.now | |
| 43 | try await model.addRoot(notes) | |
| 44 | return (model, ContinuousClock.now - start) | |
| 45 | } | |
| 46 | ||
| 47 | static func scratch() throws -> URL { | |
| 48 | let url = FileManager.default.temporaryDirectory.appendingPathComponent("orgstar-gates-\(UUID().uuidString)") | |
| 49 | try FileManager.default.createDirectory(at: url, withIntermediateDirectories: true) | |
| 50 | return url | |
| 51 | } | |
| 52 | ||
| 53 | /// One pass of the backlinks pane: the file's backlinks and the heading's. | |
| 54 | static func backlinks(_ model: WorkspaceModel) -> (found: Int, time: Duration) { | |
| 55 | let path = model.files.first { $0.name == "note-0.org" }!.path | |
| 56 | var found = 0 | |
| 57 | let time = ContinuousClock().measure { | |
| 58 | found += model.backlinks(to: Backlinks.Target(path: path)).count | |
| 59 | found += model.backlinks(to: Backlinks.Target(path: path, title: "Heading 0.1", id: "0-1")).count | |
| 60 | } | |
| 61 | return (found, time) | |
| 62 | } | |
| 63 | ||
| 64 | /// 10,000 notes, 49,400 links. | |
| 65 | @Test func workspaceGates() async throws { | |
| 66 | let scratch = try Self.scratch() | |
| 67 | defer { try? FileManager.default.removeItem(at: scratch) } | |
| 68 | let (model, build) = try await Self.workspace(10_000, fiveLinks: 9_400, in: scratch) | |
| 69 | #expect(model.files.count == 10_000) | |
| 70 | ||
| 71 | let agenda = AgendaModel(workspace: model) | |
| 72 | agenda.agendaFiles = [] | |
| 73 | agenda.includeSubfolders = false | |
| 74 | let now = DateComponents(calendar: .current, year: 2026, month: 10, day: 5, hour: 12).date! | |
| 75 | let clock = ContinuousClock() | |
| 76 | let cold = await clock.measure { await agenda.refresh(open: [:], now: now) } | |
| 77 | let warm = await clock.measure { await agenda.refresh(open: [:], now: now) } | |
| 78 | let items = agenda.days.reduce(0) { $0 + $1.items.count } | |
| 79 | #expect(items > 0) | |
| 80 | ||
| 81 | let (found, backlinks) = Self.backlinks(model) | |
| 82 | #expect(found > 0) | |
| 83 | print("GATE 10,000 notes: index build \(build), agenda refresh cold \(cold) / warm \(warm) (\(items) items), backlinks over 49,400 links \(backlinks)") | |
| 84 | #expect(build < .seconds(15), "index build") | |
| 85 | #expect(cold < .seconds(10), "agenda refresh, cold") | |
| 86 | #expect(warm < .seconds(2), "agenda refresh, warm") | |
| 87 | #expect(backlinks < .milliseconds(1_500), "backlinks, 49,400 links") | |
| 88 | } | |
| 89 | ||
| 90 | /// 1,000 notes, 5,000 links. | |
| 91 | @Test func backlinksGate() async throws { | |
| 92 | let scratch = try Self.scratch() | |
| 93 | defer { try? FileManager.default.removeItem(at: scratch) } | |
| 94 | let (model, _) = try await Self.workspace(1_000, fiveLinks: 1_000, in: scratch) | |
| 95 | let (found, time) = Self.backlinks(model) | |
| 96 | #expect(found > 0) | |
| 97 | print("GATE 1,000 notes: backlinks over 5,000 links \(time)") | |
| 98 | #expect(time < .milliseconds(150), "backlinks, 5,000 links") | |
| 99 | } | |
| 100 | } | |
scripts/release-ios.sh +5
| @@ -10,4 +10,9 @@ PUBLISH="${ORGSTAR_PUBLISH:-1}" | ||
| 10 | 10 | name=orgstar |
| 11 | 11 | project=ios/Orgstar.xcodeproj |
| 12 | 12 | scheme="Orgstar iOS" |
| 13 | ||
| 14 | # Runs before the archive. | |
| 15 | preflight() { | |
| 16 | ORGSTAR_GATES=1 swift test -c release --filter GateTests || fail "a performance gate failed" | |
| 17 | } | |
| 13 | 18 | . "${APPSTORE_KIT:-$(dirname "$0")/../../appstore-kit}/release-ios.sh" |
scripts/release-mac.sh +2
| @@ -42,6 +42,8 @@ if [ "$publish" != 0 ]; then | ||
| 42 | 42 | [ "$(git branch --show-current)" = main ] || { echo "Release from main." >&2; exit 1; } |
| 43 | 43 | fi |
| 44 | 44 | |
| 45 | ORGSTAR_GATES=1 swift test -c release --filter GateTests || { echo "A performance gate failed." >&2; exit 1; } | |
| 46 | ||
| 45 | 47 | # The build number counts commits, so each release's is higher than the last's. |
| 46 | 48 | build="$(git rev-list --count HEAD)" |
| 47 | 49 | ORGSTAR_SIGN="$sign" ORGSTAR_ARCHS="arm64 x86_64" sh scripts/build-app.sh "$version" "$build" > /dev/null |
scripts/release-macos.sh +2 −1
| @@ -12,7 +12,7 @@ scheme="Orgstar macOS" | ||
| 12 | 12 | platform=macos |
| 13 | 13 | configuration=Release |
| 14 | 14 | |
| 15 | # Runs before the archive, so it can only check build settings. | |
| 15 | # Runs before the archive, so it can only check build settings; then the performance gates. | |
| 16 | 16 | preflight() { |
| 17 | 17 | settings="$(command xcodebuild -project "$project" -scheme "$scheme" -configuration "$configuration" \ |
| 18 | 18 | -destination 'generic/platform=macOS' -showBuildSettings 2>/dev/null)" || fail "can't read the build settings of $scheme" |
| @@ -28,6 +28,7 @@ preflight() { | ||
| 28 | 28 | ios/OrgstarQuickLook/*-macOS.entitlements ios/OrgstarSpotlight/*.entitlements; do |
| 29 | 29 | ! grep -q temporary-exception "$entitlements" || fail "$entitlements has a temporary exception" |
| 30 | 30 | done |
| 31 | ORGSTAR_GATES=1 swift test -c release --filter GateTests || fail "a performance gate failed" | |
| 31 | 32 | } |
| 32 | 33 | |
| 33 | 34 | # Checks the built app: no Sparkle, no updater keys, no process launching, no temporary exceptions, |