diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 458a3b4c4..65a32f3b4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,23 +6,56 @@ on: - main pull_request: branches: - - '*' + - "*" jobs: build: - name: MacOS - runs-on: macOS-latest + strategy: + matrix: + xcode: + - "11.7" # Swift 5.2 + - "12.4" # Swift 5.3 + - "12.5.1" # Swift 5.4 + - "13.0" # Swift 5.5 + + name: macOS 11, Xcode ${{ matrix.xcode }} + runs-on: macos-11 steps: - - uses: actions/checkout@v1 - - name: Select Xcode 12.4 - run: sudo xcode-select -s /Applications/Xcode_12.4.app - - name: Run tests - run: make test-swift + - uses: actions/checkout@v1 + - name: Select Xcode ${{ matrix.xcode }} + run: sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode }}.app + - name: Run tests + run: make test-swift ubuntu: - name: Ubuntu - runs-on: ubuntu-latest + strategy: + matrix: + os: ["18.04", "20.04"] + + name: Ubuntu ${{ matrix.os }} + runs-on: ubuntu-${{ matrix.os }} + steps: + - uses: actions/checkout@v1 + - name: Run tests + run: make test-linux + + windows: + strategy: + matrix: + swift: + - "5.4" + - "5.5" + + name: Windows 2019, Swift ${{ matrix.swift }} + runs-on: windows-2019 + steps: - - uses: actions/checkout@v1 - - name: Run tests - run: make test-linux + - name: Set git to use LF + run: | + git config --global core.autocrlf false + git config --global core.eol lf + - uses: actions/checkout@v2 + - uses: MaxDesiatov/swift-windows-action@v1 + with: + shell-action: swift test + swift-version: ${{ matrix.swift }} diff --git a/Sources/SnapshotTesting/AssertInlineSnapshot.swift b/Sources/SnapshotTesting/AssertInlineSnapshot.swift index 434cbfd13..403196471 100644 --- a/Sources/SnapshotTesting/AssertInlineSnapshot.swift +++ b/Sources/SnapshotTesting/AssertInlineSnapshot.swift @@ -147,7 +147,7 @@ public func _verifyInlineSnapshot( /// Did not successfully record, so we will fail. if !attachments.isEmpty { - #if !os(Linux) + #if !os(Linux) && !os(Windows) if ProcessInfo.processInfo.environment.keys.contains("__XCODE_BUILT_PRODUCTS_DIR_PATHS") { XCTContext.runActivity(named: "Attached Failure Diff") { activity in attachments.forEach { diff --git a/Sources/SnapshotTesting/AssertSnapshot.swift b/Sources/SnapshotTesting/AssertSnapshot.swift index 7065ec7f1..90d80af80 100644 --- a/Sources/SnapshotTesting/AssertSnapshot.swift +++ b/Sources/SnapshotTesting/AssertSnapshot.swift @@ -275,7 +275,7 @@ public func verifySnapshot( try snapshotting.diffing.toData(diffable).write(to: failedSnapshotFileUrl) if !attachments.isEmpty { - #if !os(Linux) + #if !os(Linux) && !os(Windows) if ProcessInfo.processInfo.environment.keys.contains("__XCODE_BUILT_PRODUCTS_DIR_PATHS") { XCTContext.runActivity(named: "Attached Failure Diff") { activity in attachments.forEach { diff --git a/Sources/SnapshotTesting/Common/XCTAttachment.swift b/Sources/SnapshotTesting/Common/XCTAttachment.swift index 312d8bcb0..8d5f17f64 100644 --- a/Sources/SnapshotTesting/Common/XCTAttachment.swift +++ b/Sources/SnapshotTesting/Common/XCTAttachment.swift @@ -1,4 +1,4 @@ -#if os(Linux) +#if os(Linux) || os(Windows) import Foundation public struct XCTAttachment { diff --git a/Sources/SnapshotTesting/Snapshotting/URLRequest.swift b/Sources/SnapshotTesting/Snapshotting/URLRequest.swift index c72f7527a..1f97d4003 100644 --- a/Sources/SnapshotTesting/Snapshotting/URLRequest.swift +++ b/Sources/SnapshotTesting/Snapshotting/URLRequest.swift @@ -65,10 +65,10 @@ extension Snapshotting where Value == URLRequest, Format == String { if let httpBodyData = request.httpBody, let httpBody = String(data: httpBodyData, encoding: .utf8) { var escapedBody = httpBody.replacingOccurrences(of: "\\\"", with: "\\\\\"") escapedBody = escapedBody.replacingOccurrences(of: "\"", with: "\\\"") - + components.append("--data \"\(escapedBody)\"") } - + // Cookies if let cookie = request.allHTTPHeaderFields?["Cookie"] { let escapedValue = cookie.replacingOccurrences(of: "\"", with: "\\\"") diff --git a/Tests/SnapshotTestingTests/SnapshotTestingTests.swift b/Tests/SnapshotTestingTests/SnapshotTestingTests.swift index 7eb169751..a4134c0fe 100644 --- a/Tests/SnapshotTestingTests/SnapshotTestingTests.swift +++ b/Tests/SnapshotTestingTests/SnapshotTestingTests.swift @@ -1210,7 +1210,7 @@ private let allContentSizes = ] #endif -#if os(Linux) +#if os(Linux) || os(Windows) extension SnapshotTestingTests { static var allTests : [(String, (SnapshotTestingTests) -> () throws -> Void)] { return [