Skip to content

try android CI again#22

Closed
MiaKoring wants to merge 8 commits into
amethystsoft:mainfrom
MiaKoring:main
Closed

try android CI again#22
MiaKoring wants to merge 8 commits into
amethystsoft:mainfrom
MiaKoring:main

Conversation

@MiaKoring
Copy link
Copy Markdown
Member

@MiaKoring MiaKoring commented May 19, 2026

Overview

This PR adds Android CI/CD support and extends the persistence model layer with new methods for model retrieval and representation conversion.

Changes

GitHub Actions - Android Testing Workflow

Added a new GitHub Actions workflow (swift-test-android.yml) that runs Swift package tests on Android. The workflow triggers on:

  • Push to main
  • Pull requests targeting main
  • Manual dispatch

Executes using the skiptools/swift-android-action@v2 with optimized disk space settings.

PersistentModel Protocol Extensions

Added two new public APIs to the PersistentModel extension:

  • asPersistentRepresentation - Computed property that returns the model's id as a PersistentRepresentation
  • init?(fromPersistent:) - Failable initializer for constructing models from PersistentRepresentation (currently a stub returning nil)

Model Context Relationship Fetching

Added getModel(id:type:) method to ManagedObjectContext that retrieves models by ULID, checking an in-memory identity map first before performing a database fetch. This provides efficient model resolution with proper error handling.

Platform-Specific Improvements

Improved platform-specific key-storage selection in ManagedObjectContext.getKeyForDatabase(at:appID:) by:

  • Explicitly routing AppKit/UIKit platforms to KeychainAccess
  • Limiting KeyringAccess to Linux only (#elseif os(Linux))
  • Returning nil for unsupported platforms instead of falling back to generic handling

This tightened approach improves type safety and platform support clarity.

Highlights

The explicit platform-specific handling in the key-storage selection represents good defensive programming that makes platform requirements clearer and prevents unexpected fallback behavior.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 19, 2026

Warning

Rate limit exceeded

@MiaKoring has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 22 minutes and 52 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 84797b78-6574-49bd-bd37-54dbf78ee2b7

📥 Commits

Reviewing files that changed from the base of the PR and between b27c50e and e3317a9.

📒 Files selected for processing (4)
  • .github/workflows/swift-test-linux.yml
  • .github/workflows/swift-test-mac.yml
  • Sources/Vein/Model/Protocols/PersistentModel.swift
  • Sources/Vein/ModelContext/ManagedObjectContext/ManagedObjectContext+Relationship.swift
📝 Walkthrough

Walkthrough

This PR extends persistent model storage with serialization conversion methods, adds model lookup by ULID via ManagedObjectContext, tightens platform-specific key-storage branching for AppKit/UIKit, KeyringAccess, and unsupported platforms, and introduces Android test CI coverage.

Changes

Persistent Model Storage & Retrieval

Layer / File(s) Summary
PersistentModel serialization protocol
Sources/Vein/Model/Protocols/PersistentModel.swift
Adds public asPersistentRepresentation computed property to convert model id to PersistentRepresentation, and failable initializer init?(fromPersistent:) stub for reverse conversion.
ManagedObjectContext model retrieval by ID
Sources/Vein/ModelContext/ManagedObjectContext/ManagedObjectContext+Relationship.swift
Implements getModel(id:type:) method that performs identity map fast-path lookup and falls back to fetching by id field predicate, suppressing fetch errors.
Platform-specific key-storage branching
Sources/Vein/ModelContext/ManagedObjectContext/ManagedObjectContext.swift
Refines getKeyForDatabase compile-time branching to explicitly route to KeychainAccess for Apple platforms, KeyringAccess on Linux only, and nil for unsupported platforms.
Android test CI workflow
.github/workflows/swift-test-android.yml
Adds GitHub Actions workflow that runs Swift package tests for Android on main branch events via skiptools/swift-android-action with disk-space and test-product configuration.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • amethystsoft/vein#21: Directly adjacent Linux encryption/keyring changes in the same ManagedObjectContext.swift area related to key-storage platform selection.
  • amethystsoft/vein#19: Prior database-encryption keychain-based implementation that overlaps with this PR's platform-specific key-storage refinement.
🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'try android CI again' is vague and doesn't clearly describe the main changes. It uses a generic phrase that doesn't convey what was actually implemented or fixed. Consider a more descriptive title like 'Add Android CI workflow and persistence model improvements' that explains the primary changes being introduced.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@Sources/Vein/Model/Protocols/PersistentModel.swift`:
- Around line 174-176: The init?(fromPersistent:) initializer must be added to
the PersistentModel protocol itself (not only in its extension) because the
current default implementation in the extension (returning nil) is statically
dispatched and shadows real conforming-type implementations; modify the
PersistentModel protocol to declare init?(fromPersistent:
PersistentRepresentation) as a requirement, remove the nil-returning default
implementation from the protocol extension, and ensure conforming types
implement their own init?(fromPersistent:) (update any conformances that relied
on the extension) so generic code constrained to PersistentModel will call the
concrete initializers.

In
`@Sources/Vein/ModelContext/ManagedObjectContext/ManagedObjectContext`+Relationship.swift:
- Line 8: The getModel implementation currently swallows fetch failures by using
`try?` on `self.fetchAll(PredicateBuilder<T>().addCheck(.isEqualTo, "id",
id)).first`; change the API to propagate errors: update `getModel` to be
`throws` (or return a throwing result) and replace `try?` with `try` so any
fetch error from `fetchAll` surfaces to the caller; keep using
`PredicateBuilder<T>().addCheck(.isEqualTo, "id", id)` and return the `.first`
result after the `try` so not-found remains `nil` but real errors are not
hidden.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: bbca3f69-2b4d-4c33-929c-ea4e488d226d

📥 Commits

Reviewing files that changed from the base of the PR and between ab2e213 and b27c50e.

📒 Files selected for processing (4)
  • .github/workflows/swift-test-android.yml
  • Sources/Vein/Model/Protocols/PersistentModel.swift
  • Sources/Vein/ModelContext/ManagedObjectContext/ManagedObjectContext+Relationship.swift
  • Sources/Vein/ModelContext/ManagedObjectContext/ManagedObjectContext.swift

Comment thread Sources/Vein/Model/Protocols/PersistentModel.swift Outdated
@MiaKoring MiaKoring closed this May 19, 2026
@MiaKoring
Copy link
Copy Markdown
Member Author

Android CI still doesn’t work. sadly.

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