mirror of
https://github.com/wu736139669/hapi.git
synced 2026-10-06 18:39:47 +00:00
ios/scripts/linux-test.sh stages HapiKit + shared/fixtures at repo depth
into a persistent tmp dir and runs swift test in swift:6.1-noble; the
manifest drops HapiUI (SwiftUI/swift-markdown/Highlightr) under
#if os(Linux). 458 tests green, including all 48 chat and 11 pagination
golden fixtures.
Fixes that fell out of the first real compile of the blind-written port:
- ChatTypes.CodexReview.wireValue + SummaryPatching legacy id fallback:
split expressions that exceeded the Swift 6 type-checker budget
- FileEndpointsTests: raw string containing "# terminated the literal
early (never compiled anywhere) — now ##-delimited
- SSEClient.backoffSleep: Task { try? ... } inferred Task<()?, Never>
- Darwin gates: Security/Keychain behind canImport(Security) (tests use
InMemoryCredentialStore via CredentialStoring), CryptoKit digest with
FNV-1a filename fallback, FoundationNetworking imports for URLSession
types, corelibs URLCache diskPath: initializer, get-only
waitsForConnectivity, delegate-based SSE transport where
URLSession.bytes(for:) does not exist
49 lines
2.1 KiB
Bash
Executable File
49 lines
2.1 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Compile-verify and test HapiKit's Linux-buildable targets (HapiProtocol +
|
|
# HapiClient and their test targets) inside a Swift Linux container, without
|
|
# a Mac. HapiUI (SwiftUI + swift-markdown + Highlightr) is excluded: the
|
|
# Package.swift drops the UI product/targets under `#if os(Linux)`, and this
|
|
# script additionally leaves the HapiUI sources out of the staging copy.
|
|
#
|
|
# Usage:
|
|
# ios/scripts/linux-test.sh # full `swift test`
|
|
# ios/scripts/linux-test.sh --filter Chat # any extra args go to swift test
|
|
#
|
|
# Environment:
|
|
# HAPI_SWIFT_IMAGE docker image (default swift:6.1-noble)
|
|
# HAPI_LINUX_STAGE staging dir (default: stable per-checkout dir in /tmp,
|
|
# kept across runs so the container's .build cache and
|
|
# resolved deps survive and re-runs are incremental)
|
|
#
|
|
# How it works: the package is rsynced into $STAGE/ios/Packages/HapiKit and
|
|
# the golden fixtures into $STAGE/shared/fixtures — replicating repo depth so
|
|
# the tests' `#filePath`-relative `../../../shared/fixtures` resolution works
|
|
# inside the container ($STAGE is mounted at /work). Fixes must be applied to
|
|
# the REAL worktree files; every run re-stages, so the loop is:
|
|
# edit real files -> run this script -> repeat.
|
|
set -euo pipefail
|
|
|
|
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
|
PKG="$REPO_ROOT/ios/Packages/HapiKit"
|
|
FIXTURES="$REPO_ROOT/shared/fixtures"
|
|
|
|
IMAGE="${HAPI_SWIFT_IMAGE:-swift:6.1-noble}"
|
|
STAGE="${HAPI_LINUX_STAGE:-${TMPDIR:-/tmp}/hapikit-linux-test-$(printf %s "$REPO_ROOT" | cksum | cut -d' ' -f1)}"
|
|
|
|
mkdir -p "$STAGE/ios/Packages/HapiKit" "$STAGE/shared/fixtures"
|
|
|
|
# --delete keeps the stage exact but (without --delete-excluded) leaves the
|
|
# excluded .build in place, preserving incremental builds across runs.
|
|
rsync -a --delete \
|
|
--exclude '.build' \
|
|
--exclude 'Sources/HapiUI' \
|
|
--exclude 'Tests/HapiUITests' \
|
|
"$PKG/" "$STAGE/ios/Packages/HapiKit/"
|
|
rsync -a --delete "$FIXTURES/" "$STAGE/shared/fixtures/"
|
|
|
|
exec docker run --rm \
|
|
-v "$STAGE":/work \
|
|
-w /work/ios/Packages/HapiKit \
|
|
"$IMAGE" \
|
|
swift test "$@"
|