Skip to content

Commit a39c693

Browse files
MaxDesiatovniilohlin
authored andcommitted
Add support for Windows, add Windows job to ci.yml (pointfreeco#532)
* Add Windows job to `ci.yml` * Add missing newline * Add name field to Windows job, format consistently * Add `os(Windows)` checks * Fix Windows tests * Fix Windows line endings * Use LF line endings for git checkout on Windows
1 parent effe58b commit a39c693

File tree

6 files changed

+52
-19
lines changed

6 files changed

+52
-19
lines changed

.github/workflows/ci.yml

+46-13
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,56 @@ on:
66
- main
77
pull_request:
88
branches:
9-
- '*'
9+
- "*"
1010

1111
jobs:
1212
build:
13-
name: MacOS
14-
runs-on: macOS-latest
13+
strategy:
14+
matrix:
15+
xcode:
16+
- "11.7" # Swift 5.2
17+
- "12.4" # Swift 5.3
18+
- "12.5.1" # Swift 5.4
19+
- "13.0" # Swift 5.5
20+
21+
name: macOS 11, Xcode ${{ matrix.xcode }}
22+
runs-on: macos-11
1523
steps:
16-
- uses: actions/checkout@v1
17-
- name: Select Xcode 12.4
18-
run: sudo xcode-select -s /Applications/Xcode_12.4.app
19-
- name: Run tests
20-
run: make test-swift
24+
- uses: actions/checkout@v1
25+
- name: Select Xcode ${{ matrix.xcode }}
26+
run: sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode }}.app
27+
- name: Run tests
28+
run: make test-swift
2129

2230
ubuntu:
23-
name: Ubuntu
24-
runs-on: ubuntu-latest
31+
strategy:
32+
matrix:
33+
os: ["18.04", "20.04"]
34+
35+
name: Ubuntu ${{ matrix.os }}
36+
runs-on: ubuntu-${{ matrix.os }}
37+
steps:
38+
- uses: actions/checkout@v1
39+
- name: Run tests
40+
run: make test-linux
41+
42+
windows:
43+
strategy:
44+
matrix:
45+
swift:
46+
- "5.4"
47+
- "5.5"
48+
49+
name: Windows 2019, Swift ${{ matrix.swift }}
50+
runs-on: windows-2019
51+
2552
steps:
26-
- uses: actions/checkout@v1
27-
- name: Run tests
28-
run: make test-linux
53+
- name: Set git to use LF
54+
run: |
55+
git config --global core.autocrlf false
56+
git config --global core.eol lf
57+
- uses: actions/checkout@v2
58+
- uses: MaxDesiatov/swift-windows-action@v1
59+
with:
60+
shell-action: swift test
61+
swift-version: ${{ matrix.swift }}

Sources/SnapshotTesting/AssertInlineSnapshot.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ public func _verifyInlineSnapshot<Value>(
147147

148148
/// Did not successfully record, so we will fail.
149149
if !attachments.isEmpty {
150-
#if !os(Linux)
150+
#if !os(Linux) && !os(Windows)
151151
if ProcessInfo.processInfo.environment.keys.contains("__XCODE_BUILT_PRODUCTS_DIR_PATHS") {
152152
XCTContext.runActivity(named: "Attached Failure Diff") { activity in
153153
attachments.forEach {

Sources/SnapshotTesting/AssertSnapshot.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ public func verifySnapshot<Value, Format>(
275275
try snapshotting.diffing.toData(diffable).write(to: failedSnapshotFileUrl)
276276

277277
if !attachments.isEmpty {
278-
#if !os(Linux)
278+
#if !os(Linux) && !os(Windows)
279279
if ProcessInfo.processInfo.environment.keys.contains("__XCODE_BUILT_PRODUCTS_DIR_PATHS") {
280280
XCTContext.runActivity(named: "Attached Failure Diff") { activity in
281281
attachments.forEach {

Sources/SnapshotTesting/Common/XCTAttachment.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#if os(Linux)
1+
#if os(Linux) || os(Windows)
22
import Foundation
33

44
public struct XCTAttachment {

Sources/SnapshotTesting/Snapshotting/URLRequest.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,10 @@ extension Snapshotting where Value == URLRequest, Format == String {
6565
if let httpBodyData = request.httpBody, let httpBody = String(data: httpBodyData, encoding: .utf8) {
6666
var escapedBody = httpBody.replacingOccurrences(of: "\\\"", with: "\\\\\"")
6767
escapedBody = escapedBody.replacingOccurrences(of: "\"", with: "\\\"")
68-
68+
6969
components.append("--data \"\(escapedBody)\"")
7070
}
71-
71+
7272
// Cookies
7373
if let cookie = request.allHTTPHeaderFields?["Cookie"] {
7474
let escapedValue = cookie.replacingOccurrences(of: "\"", with: "\\\"")

Tests/SnapshotTestingTests/SnapshotTestingTests.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1260,7 +1260,7 @@ private let allContentSizes =
12601260
]
12611261
#endif
12621262

1263-
#if os(Linux)
1263+
#if os(Linux) || os(Windows)
12641264
extension SnapshotTestingTests {
12651265
static var allTests : [(String, (SnapshotTestingTests) -> () throws -> Void)] {
12661266
return [

0 commit comments

Comments
 (0)