diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..e96ba68 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,50 @@ +name: CI + +on: + push: + branches: [main] + pull_request: + +permissions: + contents: read + +concurrency: + group: ci-${{ github.ref }} + cancel-in-progress: true + +jobs: + test: + name: Package tests on macOS + runs-on: macos-latest + timeout-minutes: 30 + steps: + - uses: actions/checkout@v4 + - name: Show the Xcode version + run: xcodebuild -version + - name: Run the tests + run: swift test + + build-ios: + name: iOS builds + runs-on: macos-latest + timeout-minutes: 45 + steps: + - uses: actions/checkout@v4 + - name: Show the Xcode version + run: xcodebuild -version + - name: Build the package + run: > + xcodebuild build -scheme TranscriptKit -destination 'generic/platform=iOS' + CODE_SIGNING_ALLOWED=NO + - name: Build the demo app + run: > + xcodebuild build -project Demo/TranscriptDemo.xcodeproj -scheme TranscriptDemo + -destination 'generic/platform=iOS' -skipMacroValidation CODE_SIGNING_ALLOWED=NO + - name: Build the chat sample + run: > + xcodebuild build -project Examples/ChatSample/ChatSample.xcodeproj -scheme ChatSample + -destination 'generic/platform=iOS' -skipMacroValidation CODE_SIGNING_ALLOWED=NO + - name: Build the benchmark app + run: > + xcodebuild build -project Benchmark/TranscriptBench.xcodeproj -scheme TranscriptBench + -destination 'generic/platform=iOS' -skipMacroValidation CODE_SIGNING_ALLOWED=NO diff --git a/Sources/TranscriptKit/Markdown/InlineParser.swift b/Sources/TranscriptKit/Markdown/InlineParser.swift index 739366c..f87cb7c 100644 --- a/Sources/TranscriptKit/Markdown/InlineParser.swift +++ b/Sources/TranscriptKit/Markdown/InlineParser.swift @@ -128,9 +128,14 @@ enum InlineParser { } /// Whether every parse also rebuilds its whole result and checks that the - /// settled part matches. On only when the test framework is loaded: in an - /// app's debug build it would double the cost of every parse. - static let checksSettledResult = NSClassFromString("XCTestCase") != nil + /// settled part matches. On only under a test runner: in an app's debug + /// build it would double the cost of every parse. Swift Testing can run + /// without loading XCTest, so a loaded `.xctest` bundle also counts. + static let checksSettledResult: Bool = { + if NSClassFromString("XCTestCase") != nil { return true } + if Bundle.allBundles.contains(where: { $0.bundlePath.hasSuffix(".xctest") }) { return true } + return ProcessInfo.processInfo.arguments.contains { $0.hasSuffix(".xctest") || $0.contains(".xctest/") } + }() /// Parses a whole string. static func parse(_ source: String, open: Bool, tags: [String: TranscriptTag] = [:]) -> Result {