Commit Graph
2 Commits
Author SHA1 Message Date
Andrew Heard bc9f9ea1da feat(ai): add FoundationModelsFake for GLM tests (#16995)
Add FoundationModelsFake, a nested Swift package that fakes Apple's
Foundation Models framework, so that GeminiLanguageModel (GLM) can build
and run its unit tests on Linux and on OS versions without the real
framework. It's used only for development and testing.

- GLM depends on the fake through a `FoundationModelsFake` package
  trait, which is on by default where Darwin isn't available (e.g.,
  Linux). With the trait off, the fake isn't built. The root
  `Package.swift` and podspecs can't reach it.
- The fake mirrors Apple's public API and availability in the 27.2
  SDKs, including `@Generable` macro expansions. It omits
  PrivateCloudComputeLanguageModel, OCRTool, BarcodeReaderTool, the
  adapter and feedback APIs, and deprecated APIs.
  SystemLanguageModel is always unavailable. Below Swift 6.4 it
  compiles to an empty module.
- Decoding rejects transcript images with `file:` URLs and schemas
  whose references never resolve, instead of reading local files or
  overflowing the stack.
- Without ImageIO, GLM passes PNG, JPEG, WebP, HEIC, and HEIF images
  through to Gemini after checking their signatures, and rejects
  images that would need re-encoding.
- Add CI jobs that run both packages' tests against the fake: one on
  Linux in a digest-pinned `swift:6.4.2` container, and one on macOS
  with Xcode 27.2. Skip `sdk.ai` for changes that only touch the fake.
2026-11-05 14:13:50 -05:00
Andrew Heard bfb2eaac29 test(ai): GeminiLanguageModel integration testing foundation (#16617)
Establishes the integration testing foundation and parameterized test
suites for `GeminiLanguageModel`, enabling fast local execution via
`swift test` and automated CI verification on iOS Simulator.

Key Changes:
- `IntegrationTestingBackend`: Defines canonical backend configurations
  (`.developerAPI`, `.firebaseAILogicDeveloperAPI`, and
  `.firebaseAILogicAgentPlatform`), dynamically resolving endpoints,
  model resource paths, and auth headers from available credentials.
- `IntegrationTestEnvironment`: Centralizes credential discovery
  (`GEMINI_API_KEY`, `GOOGLE_API_KEY`, and `FIREBASE_PLIST_PATH`) into
  an immutable, thread-safe configuration struct with cached process
  access to avoid redundant disk I/O.
- `AppCheckDebugClient`: Implements a lightweight client to exchange
  debug tokens for App Check tokens without Keychain dependencies,
  deduplicating token requests across test runs with an in-memory cache.
- Parameterized Tests: Adds `BasicContentGenerationIntegrationTests`
  running against all available backends, tagged with `@Tag.integration`
  and gated by condition traits to cleanly skip when credentials are
  missing.
- CI Workflow: Adds `.github/workflows/sdk.geminilanguagemodel.yml` to
  run integration tests against Firebase AI Logic on iOS Simulator
  using decrypted repo secrets.
2026-09-07 18:28:37 -04:00