Skip to content

Commit

Permalink
Add watchOS Testing (Alamofire#3449)
Browse files Browse the repository at this point in the history
* Add watchOS tests, fix them, add action.

* Return to timeout.

* Fix YML.

* Actually test on watchOS 7.4.

* Turn off Metal validation for test scheme.

* Enable retry tests by using different basic auth users.

* Move logos, add MacStadium logo.
  • Loading branch information
jshier authored May 2, 2021
1 parent ca9d8f3 commit 03e6e9c
Show file tree
Hide file tree
Showing 15 changed files with 410 additions and 97 deletions.
20 changes: 17 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ jobs:
DEVELOPER_DIR: /Applications/Xcode_12.4.app/Contents/Developer
strategy:
matrix:
destination: ["OS=14.4,name=iPhone 12 Pro"] #, "OS=12.4,name=iPhone XS", "OS=11.4,name=iPhone X", "OS=10.3.1,name=iPhone SE"]
destination: ["OS=14.4,name=iPhone 12 Pro"]
steps:
- uses: actions/checkout@v2
- name: Install Firewalk
Expand All @@ -84,7 +84,7 @@ jobs:
DEVELOPER_DIR: /Applications/Xcode_12.4.app/Contents/Developer
strategy:
matrix:
destination: ["OS=14.3,name=Apple TV 4K"] #, "OS=11.4,name=Apple TV 4K", "OS=10.2,name=Apple TV 1080p"]
destination: ["OS=14.3,name=Apple TV 4K"]
steps:
- uses: actions/checkout@v2
- name: Install Firewalk
Expand All @@ -98,11 +98,25 @@ jobs:
DEVELOPER_DIR: /Applications/Xcode_12.4.app/Contents/Developer
strategy:
matrix:
destination: ["OS=7.2,name=Apple Watch Series 6 - 44mm"] #, "OS=4.2,name=Apple Watch Series 3 - 42mm", "OS=3.2,name=Apple Watch Series 2 - 42mm"]
destination: ["OS=7.2,name=Apple Watch Series 6 - 44mm"]
steps:
- uses: actions/checkout@v2
- name: watchOS - ${{ matrix.destination }}
run: set -o pipefail && env NSUnbufferedIO=YES xcodebuild -project "Alamofire.xcodeproj" -scheme "Alamofire watchOS" -destination "${{ matrix.destination }}" clean build | xcpretty
watchOS_Test:
name: Test watchOS
runs-on: firebreak
env:
DEVELOPER_DIR: /Applications/Xcode_12.5.app/Contents/Developer
strategy:
matrix:
destination: ["OS=7.4,name=Apple Watch Series 6 - 44mm"]
steps:
- uses: actions/checkout@v2
- name: Install Firewalk
run: arch -arch arm64e brew install alamofire/alamofire/firewalk && arch -arch x86_64 firewalk &
- name: watchOS - ${{ matrix.destination }}
run: set -o pipefail && arch -arch arm64e env NSUnbufferedIO=YES xcodebuild -project "Alamofire.xcodeproj" -scheme "Alamofire watchOS" -destination "${{ matrix.destination }}" clean test | xcpretty
spm:
name: Test with SPM
runs-on: macOS-10.15
Expand Down
276 changes: 271 additions & 5 deletions Alamofire.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,36 @@
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
enableThreadSanitizer = "YES">
enableThreadSanitizer = "YES"
codeCoverageEnabled = "YES"
onlyGenerateCoverageForSpecifiedTargets = "YES">
<AdditionalOptions>
<AdditionalOption
key = "NSZombieEnabled"
value = "YES"
isEnabled = "YES">
</AdditionalOption>
</AdditionalOptions>
<CodeCoverageTargets>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "E4202FCD1B667AA100C997FB"
BuildableName = "Alamofire.framework"
BlueprintName = "Alamofire watchOS"
ReferencedContainer = "container:Alamofire.xcodeproj">
</BuildableReference>
</CodeCoverageTargets>
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "31293064263E17D600473CEA"
BuildableName = "Alamofire watchOS Tests.xctest"
BlueprintName = "Alamofire watchOS Tests"
ReferencedContainer = "container:Alamofire.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
Expand All @@ -48,6 +69,7 @@
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
enableGPUValidationMode = "1"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
Expand Down
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
![Alamofire: Elegant Networking in Swift](https://raw.githubusercontent.com/Alamofire/Alamofire/master/alamofire.png)
![Alamofire: Elegant Networking in Swift](https://raw.githubusercontent.com/Alamofire/Alamofire/master/Resources/Alamofire.png)

[![Build Status](https://github.com/Alamofire/Alamofire/workflows/Alamofire%20CI/badge.svg?branch=master)](https://github.com/Alamofire/Alamofire/actions)
[![CocoaPods Compatible](https://img.shields.io/cocoapods/v/Alamofire.svg)](https://img.shields.io/cocoapods/v/Alamofire.svg)
Expand Down Expand Up @@ -201,6 +201,12 @@ Any amount you can donate today to help us reach our goal would be greatly appre

[![paypal](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=W34WPEE74APJQ)

## Supporters

[MacStadium](https://macstadium.com) provides Alamofire with a free, hosted Mac mini.

![Powered by MacStadium](https://raw.githubusercontent.com/Alamofire/Alamofire/master/Resources/MacStadiumLogo.png)

## License

Alamofire is released under the MIT license. [See LICENSE](https://github.com/Alamofire/Alamofire/blob/master/LICENSE) for details.
Binary file added Resources/AlamofireLogo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Resources/MacStadiumLogo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions Source/URLSessionConfiguration+Alamofire.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,13 @@ extension AlamofireExtension where ExtendedType: URLSessionConfiguration {

return configuration
}

/// `.ephemeral` configuration with Alamofire's default `Accept-Language`, `Accept-Encoding`, and `User-Agent`
/// headers.
public static var ephemeral: URLSessionConfiguration {
let configuration = URLSessionConfiguration.ephemeral
configuration.headers = .default

return configuration
}
}
16 changes: 8 additions & 8 deletions Tests/AuthenticationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import XCTest
final class BasicAuthenticationTestCase: BaseTestCase {
func testHTTPBasicAuthenticationFailsWithInvalidCredentials() {
// Given
let session = Session(configuration: URLSessionConfiguration.af.default)
let session = Session()
let endpoint = Endpoint.basicAuth()
let expectation = self.expectation(description: "\(endpoint.url) 401")

Expand All @@ -55,8 +55,8 @@ final class BasicAuthenticationTestCase: BaseTestCase {

func testHTTPBasicAuthenticationWithValidCredentials() {
// Given
let session = Session(configuration: URLSessionConfiguration.af.default)
let user = "user", password = "password"
let session = Session()
let user = "user1", password = "password"
let endpoint = Endpoint.basicAuth(forUser: user, password: password)
let expectation = self.expectation(description: "\(endpoint.url) 200")

Expand All @@ -82,8 +82,8 @@ final class BasicAuthenticationTestCase: BaseTestCase {

func testHTTPBasicAuthenticationWithStoredCredentials() {
// Given
let session = Session(configuration: URLSessionConfiguration.af.default)
let user = "user", password = "password"
let session = Session()
let user = "user2", password = "password"
let endpoint = Endpoint.basicAuth(forUser: user, password: password)
let expectation = self.expectation(description: "\(endpoint.url) 200")

Expand Down Expand Up @@ -115,7 +115,7 @@ final class BasicAuthenticationTestCase: BaseTestCase {

func testHiddenHTTPBasicAuthentication() {
// Given
let session = Session(configuration: URLSessionConfiguration.af.default)
let session = Session()
let endpoint = Endpoint.hiddenBasicAuth()
let expectation = self.expectation(description: "\(endpoint.url) 200")

Expand Down Expand Up @@ -144,7 +144,7 @@ final class BasicAuthenticationTestCase: BaseTestCase {
final class HTTPDigestAuthenticationTestCase: BaseTestCase {
func testHTTPDigestAuthenticationWithInvalidCredentials() {
// Given
let session = Session(configuration: URLSessionConfiguration.af.default)
let session = Session()
let endpoint = Endpoint.digestAuth()
let expectation = self.expectation(description: "\(endpoint.url) 401")

Expand All @@ -170,7 +170,7 @@ final class HTTPDigestAuthenticationTestCase: BaseTestCase {

func testHTTPDigestAuthenticationWithValidCredentials() {
// Given
let session = Session(configuration: URLSessionConfiguration.af.default)
let session = Session()
let user = "user", password = "password"
let endpoint = Endpoint.digestAuth(forUser: user, password: password)
let expectation = self.expectation(description: "\(endpoint.url) 200")
Expand Down
2 changes: 1 addition & 1 deletion Tests/DataStreamTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -935,7 +935,7 @@ final class DataStreamIntegrationTests: BaseTestCase {

func testThatDataStreamCanAuthenticate() {
// Given
let user = "user", password = "password"
let user = "userstream", password = "password"
var response: HTTPURLResponse?
var streamOnMain = false
var completeOnMain = false
Expand Down
4 changes: 4 additions & 0 deletions Tests/NetworkReachabilityManagerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
// THE SOFTWARE.
//

#if canImport(SytemConfiguration)

@testable import Alamofire
import Foundation
import SystemConfiguration
Expand Down Expand Up @@ -297,3 +299,5 @@ final class NetworkReachabilityManagerTestCase: BaseTestCase {
}
#endif
}

#endif
7 changes: 6 additions & 1 deletion Tests/ResponseSerializationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1318,6 +1318,11 @@ final class DataPreprocessorTests: BaseTestCase {
extension HTTPURLResponse {
convenience init(statusCode: Int, headers: HTTPHeaders? = nil) {
let url = Endpoint().url
self.init(url: url, statusCode: statusCode, httpVersion: String(kCFHTTPVersion1_1), headerFields: headers?.dictionary)!
#if os(watchOS) || os(Linux) || os(Windows)
let httpVersion = "HTTP/1.1"
#else
let httpVersion = String(kCFHTTPVersion1_1)
#endif
self.init(url: url, statusCode: statusCode, httpVersion: httpVersion, headerFields: headers?.dictionary)!
}
}
Loading

0 comments on commit 03e6e9c

Please sign in to comment.