Add unit tests + CI workflow (GitHub Actions)#8
Open
Ti-03 wants to merge 5 commits into
Open
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
TreemapLayout+ByteFormatterunit 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 removedTreemapCell.rectAPI. Suite is now 20 passing tests viaswift test..github/workflows/ci.yml— a matrixedbuild-testjob acrossmacos-14andmacos-15, on every push tomainand every PR, with SwiftPM caching,swift build -v(static-analysis gate via StrictConcurrency), andswift test.docs/ci-journal.mddocumenting the workflow, three real bugs found while making the suite compile, and theactlimitation.Bugs found while wiring up CI
Sparklewasimported in the source but only declared in the Xcode project, notPackage.swift— soswift build/swift testfailed from the CLI. Added it to the SPM manifest.TreemapLayoutTestsasserted on the old rectangularrectAPI after the radial redesign.ByteFormattertest 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
actactruns workflows in Linux Docker containers, so it cannot reproduce amacos-14job (no macOS container image exists). For a macOS app the local-actloop isn't available; verification isswift build/swift teston a Mac (done — 20/20 pass) plus watching Actions on push. Details indocs/ci-journal.md.