Skip to content

Add unit tests + CI workflow (GitHub Actions)#8

Open
Ti-03 wants to merge 5 commits into
mainfrom
ci/tests-and-actions
Open

Add unit tests + CI workflow (GitHub Actions)#8
Ti-03 wants to merge 5 commits into
mainfrom
ci/tests-and-actions

Conversation

@Ti-03

@Ti-03 Ti-03 commented Jun 29, 2026

Copy link
Copy Markdown
Owner

What

  • Tests: rewrote the TreemapLayout + ByteFormatter unit tests (12 of them, Arrange/Act/Assert) so the suite compiles and passes again. The treemap was redesigned from a rectangular layout to a radial sunburst, and the old tests still asserted on the removed TreemapCell.rect API. Suite is now 20 passing tests via swift test.
  • CI: .github/workflows/ci.yml — a matrixed build-test job across macos-14 and macos-15, on every push to main and every PR, with SwiftPM caching, swift build -v (static-analysis gate via StrictConcurrency), and swift test.
  • Docs: CI status badge in the README; docs/ci-journal.md documenting the workflow, three real bugs found while making the suite compile, and the act limitation.

Bugs found while wiring up CI

  1. Sparkle was imported in the source but only declared in the Xcode project, not Package.swift — so swift build/swift test failed from the CLI. Added it to the SPM manifest.
  2. Six TreemapLayoutTests asserted on the old rectangular rect API after the radial redesign.
  3. A ByteFormatter test expected binary (1024^3) units; the formatter defaults to decimal SI.

Why

Week 5 of the JOSA OpenLab apprenticeship: testing, CI/CD, and GitHub Actions.

Note on act

act runs workflows in Linux Docker containers, so it cannot reproduce a macos-14 job (no macOS container image exists). For a macOS app the local-act loop isn't available; verification is swift build/swift test on a Mac (done — 20/20 pass) plus watching Actions on push. Details in docs/ci-journal.md.

Ti-03 added 5 commits June 29, 2026 19:34
The treemap was redesigned from a rectangular layout to a radial sunburst,
but the tests still asserted on the old TreemapCell.rect API and no longer
compiled. Rewrite the 12 tests against the radial model (startAngle/endAngle/
innerRadius/outerRadius), preserving each test's original intent. Also fix a
ByteFormatter expectation that assumed binary (1024^3) units when the formatter
defaults to decimal SI units.

All 20 tests in the suite now pass via 'swift test'.
…cache)

Adds .github/workflows/ci.yml: a matrixed build-test job across macos-14 and
macos-15, run on every push to main and every PR. Steps: SwiftPM cache (.build +
~/Library/Caches/org.swift.swiftpm keyed on Package.resolved), 'swift build -v'
(serves as the static-analysis gate via StrictConcurrency), then 'swift test'.

Also declares Sparkle 2.9.1 in Package.swift (and pins Package.resolved). The
source does 'import Sparkle' but the dependency had only been declared in the
Xcode project, so 'swift build'/'swift test' failed from the command line and
would fail in any SPM-based CI. No Linux/lint matrix: this is a macOS-only
SwiftUI app, so it cannot build on Linux runners.
Adds the GitHub Actions CI badge to the README header and docs/ci-journal.md,
which documents the workflow, three real bugs found while making the suite
compile, and why 'act' cannot reproduce a macOS job locally (act uses Linux
Docker containers; there is no macOS container image).
The first CI run was red on macos-14 and macos-15: GlassCompat used glassEffect /
.buttonStyle(.glass), which exist only in the macOS 26 SDK (Xcode 26 / Swift 6.2).
'if #available(macOS 26, *)' is a runtime check and does not stop the compiler from
needing the symbol, so the build failed on older SDKs (and cascaded into ContentView,
which calls the helpers). It compiled locally only because this machine has the
macOS 26 SDK, a textbook 'works on my machine' bug, which is exactly what the OS
matrix is for.

Wrap each macOS-26-only call in '#if compiler(>=6.2)' so older toolchains compile
only the NSVisualEffectView fallback; the runtime #available stays inside the new-SDK
branch so an Xcode-26 build still back-deploys to macOS 14/15. Documented in
docs/ci-journal.md.
macos-14 cannot build the app: it uses MeshGradient (macOS 15 SDK) and glassEffect
(macOS 26 SDK), so the macOS 14 SDK lacks both symbols. The app requires the macOS 15+
SDK to compile (runtime back-deploy to macOS 14 is handled separately via #available).
Settle on macos-15 (Xcode 16 / Swift 6.1, fallback compile path) + macos-26 (Xcode 26 /
Swift 6.2, real Liquid Glass path). Journal updated with the finding.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant