Skip to content

Commit

Permalink
Fix GitHub CI (#199)
Browse files Browse the repository at this point in the history
* Fix GitHub CI

GitHub now has 17.2 simulators installed, so we should target them
directly.

* wip

* wip
  • Loading branch information
stephencelis committed Jan 25, 2024
1 parent f7d86cd commit ab1daa7
Show file tree
Hide file tree
Showing 14 changed files with 188 additions and 128 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Expand Up @@ -18,7 +18,7 @@ jobs:
name: macOS
runs-on: macOS-13
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
# - name: Setup tmate session
# uses: mxschmitt/action-tmate@v2
- name: LFS pull
Expand All @@ -29,8 +29,8 @@ jobs:
run: brew link postgresql@15
- name: Start Postgres
run: brew services start postgresql@15
- name: Select Xcode 15.1
run: sudo xcode-select -s /Applications/Xcode_15.1.app
- name: Select Xcode 15.2
run: sudo xcode-select -s /Applications/Xcode_15.2.app
- name: Bootstrap
run: make bootstrap
- name: Run tests
Expand All @@ -40,7 +40,7 @@ jobs:
name: Ubuntu
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Install dependencies
run: 'sudo apt-get --fix-missing update && sudo apt-get install -y wamerican'
- name: Bootstrap
Expand Down
Expand Up @@ -113,8 +113,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/swift-composable-architecture",
"state" : {
"revision" : "3568f01377c6c668aad40d066acf97ce670a1dad",
"version" : "1.5.6"
"revision" : "ae491c9e3f66631e72d58db8bb4c27dfc3d3afd4",
"version" : "1.6.0"
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -26,7 +26,7 @@ else
@git lfs pull
endif

PLATFORM_IOS = iOS Simulator,id=$(call udid_for,iOS 17,iPhone \d\+ Pro [^M])
PLATFORM_IOS = iOS Simulator,id=$(call udid_for,iOS 17.2,iPhone \d\+ Pro [^M])
test-client:
@xcodebuild test \
-project App/isowords.xcodeproj \
Expand Down
27 changes: 20 additions & 7 deletions Package.swift
Expand Up @@ -93,6 +93,7 @@ var package = Package(
"SiteMiddleware",
.product(name: "HttpPipeline", package: "swift-web"),
.product(name: "HttpPipelineTestSupport", package: "swift-web"),
.product(name: "InlineSnapshotTesting", package: "swift-snapshot-testing"),
.product(name: "Prelude", package: "swift-prelude"),
.product(name: "SnapshotTesting", package: "swift-snapshot-testing"),
],
Expand Down Expand Up @@ -158,6 +159,7 @@ var package = Package(
"FirstPartyMocks",
"SharedModels",
"TestHelpers",
.product(name: "InlineSnapshotTesting", package: "swift-snapshot-testing"),
.product(name: "Overture", package: "swift-overture"),
.product(name: "SnapshotTesting", package: "swift-snapshot-testing"),
],
Expand Down Expand Up @@ -396,6 +398,7 @@ if ProcessInfo.processInfo.environment["TEST_SERVER"] == nil {
"FirstPartyMocks",
"TestHelpers",
.product(name: "CustomDump", package: "swift-custom-dump"),
.product(name: "InlineSnapshotTesting", package: "swift-snapshot-testing"),
.product(name: "Overture", package: "swift-overture"),
.product(name: "SnapshotTesting", package: "swift-snapshot-testing"),
],
Expand Down Expand Up @@ -1027,6 +1030,7 @@ package.targets.append(contentsOf: [
"AppSiteAssociationMiddleware",
"SiteMiddleware",
.product(name: "HttpPipelineTestSupport", package: "swift-web"),
.product(name: "InlineSnapshotTesting", package: "swift-snapshot-testing"),
.product(name: "SnapshotTesting", package: "swift-snapshot-testing"),
]
),
Expand Down Expand Up @@ -1055,6 +1059,7 @@ package.targets.append(contentsOf: [
.product(name: "CustomDump", package: "swift-custom-dump"),
.product(name: "HttpPipeline", package: "swift-web"),
.product(name: "HttpPipelineTestSupport", package: "swift-web"),
.product(name: "InlineSnapshotTesting", package: "swift-snapshot-testing"),
.product(name: "SnapshotTesting", package: "swift-snapshot-testing"),
],
exclude: ["__Snapshots__"]
Expand Down Expand Up @@ -1118,6 +1123,7 @@ package.targets.append(contentsOf: [
"DemoMiddleware",
"SiteMiddleware",
.product(name: "HttpPipelineTestSupport", package: "swift-web"),
.product(name: "InlineSnapshotTesting", package: "swift-snapshot-testing"),
.product(name: "SnapshotTesting", package: "swift-snapshot-testing"),
]
),
Expand Down Expand Up @@ -1146,6 +1152,7 @@ package.targets.append(contentsOf: [
"SiteMiddleware",
.product(name: "CustomDump", package: "swift-custom-dump"),
.product(name: "HttpPipelineTestSupport", package: "swift-web"),
.product(name: "InlineSnapshotTesting", package: "swift-snapshot-testing"),
.product(name: "SnapshotTesting", package: "swift-snapshot-testing"),
],
exclude: ["__Snapshots__"]
Expand Down Expand Up @@ -1190,6 +1197,7 @@ package.targets.append(contentsOf: [
.product(name: "Either", package: "swift-prelude"),
.product(name: "HttpPipeline", package: "swift-web"),
.product(name: "HttpPipelineTestSupport", package: "swift-web"),
.product(name: "InlineSnapshotTesting", package: "swift-snapshot-testing"),
.product(name: "Overture", package: "swift-overture"),
.product(name: "Prelude", package: "swift-prelude"),
.product(name: "SnapshotTesting", package: "swift-snapshot-testing"),
Expand Down Expand Up @@ -1244,13 +1252,6 @@ package.targets.append(contentsOf: [
.product(name: "HttpPipeline", package: "swift-web"),
]
),
.target(
name: "ServerTestHelpers",
dependencies: [
.product(name: "Either", package: "swift-prelude"),
.product(name: "XCTestDynamicOverlay", package: "xctest-dynamic-overlay"),
]
),
.testTarget(
name: "ServerConfigMiddlewareTests",
dependencies: [
Expand All @@ -1259,9 +1260,17 @@ package.targets.append(contentsOf: [
.product(name: "Either", package: "swift-prelude"),
.product(name: "HttpPipeline", package: "swift-web"),
.product(name: "HttpPipelineTestSupport", package: "swift-web"),
.product(name: "InlineSnapshotTesting", package: "swift-snapshot-testing"),
.product(name: "Prelude", package: "swift-prelude"),
]
),
.target(
name: "ServerTestHelpers",
dependencies: [
.product(name: "Either", package: "swift-prelude"),
.product(name: "XCTestDynamicOverlay", package: "xctest-dynamic-overlay"),
]
),
.target(
name: "ShareGameMiddleware",
dependencies: [
Expand All @@ -1280,6 +1289,7 @@ package.targets.append(contentsOf: [
"SiteMiddleware",
"TestHelpers",
.product(name: "HttpPipelineTestSupport", package: "swift-web"),
.product(name: "InlineSnapshotTesting", package: "swift-snapshot-testing"),
.product(name: "SnapshotTesting", package: "swift-snapshot-testing"),
],
exclude: ["__Snapshots__"]
Expand Down Expand Up @@ -1315,6 +1325,7 @@ package.targets.append(contentsOf: [
"SiteMiddleware",
"TestHelpers",
.product(name: "HttpPipelineTestSupport", package: "swift-web"),
.product(name: "InlineSnapshotTesting", package: "swift-snapshot-testing"),
.product(name: "SnapshotTesting", package: "swift-snapshot-testing"),
],
exclude: ["__Snapshots__"]
Expand All @@ -1332,6 +1343,7 @@ package.targets.append(contentsOf: [
name: "SnsClientTests",
dependencies: [
"SnsClient",
.product(name: "InlineSnapshotTesting", package: "swift-snapshot-testing"),
.product(name: "SnapshotTesting", package: "swift-snapshot-testing"),
]
),
Expand Down Expand Up @@ -1361,6 +1373,7 @@ package.targets.append(contentsOf: [
"SiteMiddleware",
.product(name: "CustomDump", package: "swift-custom-dump"),
.product(name: "HttpPipelineTestSupport", package: "swift-web"),
.product(name: "InlineSnapshotTesting", package: "swift-snapshot-testing"),
.product(name: "SnapshotTesting", package: "swift-snapshot-testing"),
]
),
Expand Down
@@ -1,24 +1,26 @@
import AppSiteAssociationMiddleware
import Foundation
#if canImport(FoundationNetworking)
import FoundationNetworking
#endif
import HttpPipeline
import HttpPipelineTestSupport
import InlineSnapshotTesting
import Prelude
import ServerRouter
import SharedModels
import SiteMiddleware
import SnapshotTesting
import XCTest

#if canImport(FoundationNetworking)
import FoundationNetworking
#endif

class AppSiteAssociationMiddlewareTests: XCTestCase {
func testBasics() throws {
let request = URLRequest(url: URL(string: "/.well-known/apple-app-site-association")!)
let middleware = siteMiddleware(environment: .testValue)
let result = middleware(connection(from: request)).perform()

_assertInlineSnapshot(matching: result, as: .conn, with: #"""
assertInlineSnapshot(of: result, as: .conn) {
#"""
GET /.well-known/apple-app-site-association
200 OK
Expand Down Expand Up @@ -54,6 +56,8 @@ class AppSiteAssociationMiddlewareTests: XCTestCase {
]
}
}
"""#)
"""#
}
}
}
@@ -1,21 +1,22 @@
import CustomDump
import DatabaseClient
import Either
import Foundation
#if canImport(FoundationNetworking)
import FoundationNetworking
#endif
import FirstPartyMocks
import Foundation
import HttpPipeline
import HttpPipelineTestSupport
import InlineSnapshotTesting
import MailgunClient
import Overture
import SharedModels
import SnapshotTesting
import XCTest

@testable import SiteMiddleware

#if canImport(FoundationNetworking)
import FoundationNetworking
#endif

class DailyChallengeMiddlewareTests: XCTestCase {
let encoder = update(JSONEncoder()) {
$0.dateEncodingStrategy = .secondsSince1970
Expand All @@ -24,7 +25,7 @@ class DailyChallengeMiddlewareTests: XCTestCase {

override func setUp() {
super.setUp()
// SnapshotTesting.isRecording=true
// SnapshotTesting.isRecording=true
}

func testToday_NotYetPlayed() {
Expand Down Expand Up @@ -178,10 +179,8 @@ class DailyChallengeMiddlewareTests: XCTestCase {
)
)
request.allHTTPHeaderFields = [
"X-Signature": (
request.httpBody! + Data("----SECRET_DEADBEEF----1234567890".utf8)
)
.base64EncodedString()
"X-Signature": (request.httpBody! + Data("----SECRET_DEADBEEF----1234567890".utf8))
.base64EncodedString()
]

var environment = ServerEnvironment.testValue
Expand Down Expand Up @@ -237,7 +236,8 @@ class DailyChallengeMiddlewareTests: XCTestCase {
let middleware = siteMiddleware(environment: environment)
let result = middleware(connection(from: request)).perform()

_assertInlineSnapshot(matching: result, as: .conn, with: """
assertInlineSnapshot(of: result, as: .conn) {
"""
POST /api/games?accessToken=deadbeef-dead-beef-dead-beefdeadbeef&timestamp=1234567890
X-Signature: ewogICJnYW1lQ29udGV4dCIgOiB7CiAgICAiZGFpbHlDaGFsbGVuZ2VJZCIgOiAiREVBREJFRUYtREVBRC1CRUVGLURFQUQtREExMTdDNEExMTMyIgogIH0sCiAgIm1vdmVzIiA6IFsKICAgIHsKICAgICAgInBsYXllZEF0IiA6IDEyMzQ1Njc4OTAuNSwKICAgICAgInNjb3JlIiA6IDI3LAogICAgICAidHlwZSIgOiB7CiAgICAgICAgInBsYXllZFdvcmQiIDogWwogICAgICAgICAgewogICAgICAgICAgICAiaW5kZXgiIDogewogICAgICAgICAgICAgICJ4IiA6IDIsCiAgICAgICAgICAgICAgInkiIDogMiwKICAgICAgICAgICAgICAieiIgOiAyCiAgICAgICAgICAgIH0sCiAgICAgICAgICAgICJzaWRlIiA6IDAKICAgICAgICAgIH0sCiAgICAgICAgICB7CiAgICAgICAgICAgICJpbmRleCIgOiB7CiAgICAgICAgICAgICAgIngiIDogMiwKICAgICAgICAgICAgICAieSIgOiAyLAogICAgICAgICAgICAgICJ6IiA6IDIKICAgICAgICAgICAgfSwKICAgICAgICAgICAgInNpZGUiIDogMQogICAgICAgICAgfSwKICAgICAgICAgIHsKICAgICAgICAgICAgImluZGV4IiA6IHsKICAgICAgICAgICAgICAieCIgOiAyLAogICAgICAgICAgICAgICJ5IiA6IDIsCiAgICAgICAgICAgICAgInoiIDogMgogICAgICAgICAgICB9LAogICAgICAgICAgICAic2lkZSIgOiAyCiAgICAgICAgICB9CiAgICAgICAgXQogICAgICB9CiAgICB9CiAgXQp9LS0tLVNFQ1JFVF9ERUFEQkVFRi0tLS0xMjM0NTY3ODkw
Expand Down Expand Up @@ -280,7 +280,7 @@ class DailyChallengeMiddlewareTests: XCTestCase {
}
]
}
200 OK
Content-Length: 107
Content-Type: application/json
Expand All @@ -290,7 +290,7 @@ class DailyChallengeMiddlewareTests: XCTestCase {
X-Frame-Options: SAMEORIGIN
X-Permitted-Cross-Domain-Policies: none
X-XSS-Protection: 1; mode=block
{
"dailyChallenge" : {
"outOf" : 100,
Expand All @@ -299,8 +299,9 @@ class DailyChallengeMiddlewareTests: XCTestCase {
"started" : false
}
}
"""
)
}

XCTAssertNoDifference(
submittedScore,
Expand Down Expand Up @@ -352,10 +353,8 @@ class DailyChallengeMiddlewareTests: XCTestCase {
)
)
request.allHTTPHeaderFields = [
"X-Signature": (
request.httpBody! + Data("----SECRET_DEADBEEF----1234567890".utf8)
)
.base64EncodedString()
"X-Signature": (request.httpBody! + Data("----SECRET_DEADBEEF----1234567890".utf8))
.base64EncodedString()
]

var environment = ServerEnvironment.testValue
Expand All @@ -382,10 +381,11 @@ class DailyChallengeMiddlewareTests: XCTestCase {

// NB: Linux's localized message is different
#if !os(Linux)
_assertInlineSnapshot(matching: result, as: .conn, with: #"""
assertInlineSnapshot(of: result, as: .conn) {
#"""
POST /api/games?accessToken=deadbeef-dead-beef-dead-beefdeadbeef&timestamp=1234567890
X-Signature: ewogICJnYW1lQ29udGV4dCIgOiB7CiAgICAiZGFpbHlDaGFsbGVuZ2VJZCIgOiAiREVBREJFRUYtREVBRC1CRUVGLURFQUQtREExMTdDNEExMTMyIgogIH0sCiAgIm1vdmVzIiA6IFsKICAgIHsKICAgICAgInBsYXllZEF0IiA6IDEyMzQ1Njc4OTAsCiAgICAgICJzY29yZSIgOiAxMDAwLAogICAgICAidHlwZSIgOiB7CiAgICAgICAgInBsYXllZFdvcmQiIDogWwogICAgICAgICAgewogICAgICAgICAgICAiaW5kZXgiIDogewogICAgICAgICAgICAgICJ4IiA6IDAsCiAgICAgICAgICAgICAgInkiIDogMCwKICAgICAgICAgICAgICAieiIgOiAwCiAgICAgICAgICAgIH0sCiAgICAgICAgICAgICJzaWRlIiA6IDEKICAgICAgICAgIH0sCiAgICAgICAgICB7CiAgICAgICAgICAgICJpbmRleCIgOiB7CiAgICAgICAgICAgICAgIngiIDogMCwKICAgICAgICAgICAgICAieSIgOiAwLAogICAgICAgICAgICAgICJ6IiA6IDAKICAgICAgICAgICAgfSwKICAgICAgICAgICAgInNpZGUiIDogMgogICAgICAgICAgfSwKICAgICAgICAgIHsKICAgICAgICAgICAgImluZGV4IiA6IHsKICAgICAgICAgICAgICAieCIgOiAxLAogICAgICAgICAgICAgICJ5IiA6IDAsCiAgICAgICAgICAgICAgInoiIDogMAogICAgICAgICAgICB9LAogICAgICAgICAgICAic2lkZSIgOiAyCiAgICAgICAgICB9CiAgICAgICAgXQogICAgICB9CiAgICB9CiAgXQp9LS0tLVNFQ1JFVF9ERUFEQkVFRi0tLS0xMjM0NTY3ODkw
{
"gameContext" : {
"dailyChallengeId" : "DEADBEEF-DEAD-BEEF-DEAD-DA117C4A1132"
Expand Down Expand Up @@ -425,7 +425,7 @@ class DailyChallengeMiddlewareTests: XCTestCase {
}
]
}
400 Bad Request
Content-Length: 492
Content-Type: application/json
Expand All @@ -435,15 +435,16 @@ class DailyChallengeMiddlewareTests: XCTestCase {
X-Frame-Options: SAMEORIGIN
X-Permitted-Cross-Domain-Policies: none
X-XSS-Protection: 1; mode=block
{
"errorDump" : "▿ SharedModels.ApiError\n - errorDump: \"- LeaderboardMiddleware.VerificationFailed\\n\"\n - file: \"LeaderboardMiddleware\/SubmitGameMiddleware.swift\"\n - line: 109\n - message: \"The operation couldn’t be completed. (LeaderboardMiddleware.VerificationFailed error 1.)\"\n",
"file" : "LeaderboardMiddleware\/SubmitGameMiddleware.swift",
"line" : 202,
"message" : "The operation couldn’t be completed. (LeaderboardMiddleware.VerificationFailed error 1.)"
}
"""#
)
}
#endif
}

Expand Down Expand Up @@ -488,9 +489,10 @@ class DailyChallengeMiddlewareTests: XCTestCase {
let middleware = siteMiddleware(environment: environment)
let result = middleware(connection(from: request)).perform()

_assertInlineSnapshot(matching: result, as: .conn, with: """
assertInlineSnapshot(of: result, as: .conn) {
"""
GET /api/daily-challenges/results?accessToken=deadbeef-dead-beef-dead-beefdeadbeef&gameMode=unlimited&language=en
200 OK
Content-Length: 471
Content-Type: application/json
Expand All @@ -500,7 +502,7 @@ class DailyChallengeMiddlewareTests: XCTestCase {
X-Frame-Options: SAMEORIGIN
X-Permitted-Cross-Domain-Policies: none
X-XSS-Protection: 1; mode=block
{
"results" : [
{
Expand All @@ -523,7 +525,8 @@ class DailyChallengeMiddlewareTests: XCTestCase {
}
]
}
"""
)
}
}
}

0 comments on commit ab1daa7

Please sign in to comment.