Skip to content

Commit

Permalink
Add CI workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
dmigach committed Jun 1, 2021
1 parent c6b54d1 commit 19a2afe
Show file tree
Hide file tree
Showing 11 changed files with 152 additions and 46 deletions.
77 changes: 77 additions & 0 deletions .github/workflows/macos-checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: MacOS checks

on:
push:
branches:
- main
pull_request:
branches:
- main
release:
types:
- created

env:
HOMEBREW_NO_INSTALL_CLEANUP=1: 1 # Disable cleanup for homebrew, we don't need it on CI
DEVELOPER_DIR: /Applications/Xcode_12.4.app/Contents/Developer # Use Xcode 12.4

jobs:
build-and-test-release-macos:
name: Run Tests macOS (Release)
runs-on: macos-latest
steps:
- name: Install Bot SSH Key
uses: webfactory/ssh-agent@v0.4.1
with:
ssh-private-key: ${{ secrets.BOT_SSH_PRIVATE_KEY }}
- uses: actions/checkout@v1
- name: Cache RubyGems
uses: actions/cache@v2
id: rubygem-cache
with:
path: vendor/bundle
key: ${{ runner.os }}-gem-${{ hashFiles('**/Gemfile.lock') }}
restore-keys: ${{ runner.os }}-gem-
- name: Cache Mint
uses: actions/cache@v2
id: mint-cache
with:
path: /usr/local/lib/mint
key: ${{ runner.os }}-mint-${{ hashFiles('./Mintfile') }}
restore-keys: ${{ runner.os }}-mint-
- name: Run bootstrap.sh
run: ./bootstrap.sh
- name: Run Tests (Release)
env:
MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }}
run: bundle exec fastlane test_release_macos

build-and-test-debug-macos:
name: Run Tests macOS (Debug)
runs-on: macos-latest
steps:
- name: Install Bot SSH Key
uses: webfactory/ssh-agent@v0.4.1
with:
ssh-private-key: ${{ secrets.BOT_SSH_PRIVATE_KEY }}
- uses: actions/checkout@v1
- name: Cache RubyGems
uses: actions/cache@v2
id: rubygem-cache
with:
path: vendor/bundle
key: ${{ runner.os }}-gem-${{ hashFiles('**/Gemfile.lock') }}
restore-keys: ${{ runner.os }}-gem-
- name: Cache Mint
uses: actions/cache@v2
id: mint-cache
with:
path: /usr/local/lib/mint
key: ${{ runner.os }}-mint-${{ hashFiles('./Mintfile') }}
restore-keys: ${{ runner.os }}-mint-
- name: Run bootstrap.sh
run: ./bootstrap.sh
- name: Run Tests (Release)
env:
MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }}
run: bundle exec fastlane test_debug_macos
14 changes: 9 additions & 5 deletions Sources/StreamChat/APIClient/APIClient_Tests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ extension URLSessionConfiguration {
// simply compares the pointers.
@available(iOS, deprecated: 12.0, message: "Remove this workaround when dropping iOS 12 support.")
func isTestEqual(to otherConfiguration: URLSessionConfiguration) -> Bool {
identifier == otherConfiguration.identifier
let commonEquatability = identifier == otherConfiguration.identifier
&& requestCachePolicy == otherConfiguration.requestCachePolicy
&& timeoutIntervalForRequest == otherConfiguration.timeoutIntervalForRequest
&& timeoutIntervalForResource == otherConfiguration.timeoutIntervalForResource
Expand All @@ -333,15 +333,19 @@ extension URLSessionConfiguration {
&& urlCredentialStorage == otherConfiguration.urlCredentialStorage
&& urlCache == otherConfiguration.urlCache
&& shouldUseExtendedBackgroundIdleMode == otherConfiguration.shouldUseExtendedBackgroundIdleMode
// && protocolClasses == otherConfiguration.protocolClasses
// && multipathServiceType == otherConfiguration.multipathServiceType
&& waitsForConnectivity == otherConfiguration.waitsForConnectivity
&& isDiscretionary == otherConfiguration.isDiscretionary
&& sharedContainerIdentifier == otherConfiguration.sharedContainerIdentifier
// && sessionSendsLaunchEvents == otherConfiguration.sessionSendsLaunchEvents
// && connectionProxyDictionary == otherConfiguration.connectionProxyDictionary
&& waitsForConnectivity == otherConfiguration.waitsForConnectivity
&& isDiscretionary == otherConfiguration.isDiscretionary
&& sharedContainerIdentifier == otherConfiguration.sharedContainerIdentifier

#if os(iOS)
return commonEquatability
&& multipathServiceType == otherConfiguration.multipathServiceType
&& sessionSendsLaunchEvents == otherConfiguration.sessionSendsLaunchEvents
#endif

return commonEquatability
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,15 @@ class ChannelController_Combine_Tests: iOS13TestCase {
var cancellables: Set<AnyCancellable>!

override func setUp() {
print(-1)
super.setUp()
print("-1a")
channelController = ChannelControllerMock()
print("-1b")
cancellables = []
print(0)
}

override func tearDown() {
print(7)
// Release existing subscriptions and make sure the controller gets released, too
cancellables = nil
AssertAsync.canBeReleased(&channelController)
print(8)
super.tearDown()
}

Expand All @@ -51,32 +45,26 @@ class ChannelController_Combine_Tests: iOS13TestCase {
}

func test_channelChangePublisher() {
print(1)
// Setup Recording publishers
var recording = Record<EntityChange<ChatChannel>, Never>.Recording()

print(2)
// Setup the chain
channelController
.channelChangePublisher
.sink(receiveValue: { recording.receive($0) })
.store(in: &cancellables)

print(3)
// Keep only the weak reference to the controller. The existing publisher should keep it alive.
weak var controller: ChannelControllerMock? = channelController
channelController = nil

print(4)
let newChannel: ChatChannel = .mock(cid: .unique, name: .unique, imageURL: .unique(), extraData: .defaultValue)
controller?.channel_simulated = newChannel
controller?.delegateCallback {
$0.channelController(controller!, didUpdateChannel: .create(newChannel))
}

print(5)
XCTAssertEqual(recording.output, [.create(newChannel)])
print(6)
}

func test_messagesChangesPublisher() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ class ChannelControllerMock: ChatChannelController {
}

init() {
print("-1c")
super.init(channelQuery: .init(channelPayload: .unique), client: .mock)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,16 +272,13 @@ public class _ChatChannelController<ExtraData: ExtraDataTypes>: DataController,
environment: Environment = .init(),
isChannelAlreadyCreated: Bool = true
) {
print("-1d")
self.channelQuery = channelQuery
self.client = client
self.environment = environment
self.isChannelAlreadyCreated = isChannelAlreadyCreated
super.init()

print("-1e")
setChannelObserver()
print("-1f")
setMessagesObserver()
}

Expand Down
6 changes: 3 additions & 3 deletions Sources/StreamChat/WebSocketClient/WebSocketClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ class WebSocketClient {

private func handleAppDidEnterBackground() {
guard options.contains(.staysConnectedInBackground),
connectionState.isActive,
let scheduler = backgroundTaskScheduler
connectionState.isActive,
let scheduler = backgroundTaskScheduler
else { return }

let succeed = scheduler.beginTask { [weak self] in
Expand Down Expand Up @@ -227,7 +227,7 @@ extension WebSocketClient {
#if os(iOS)
return IOSBackgroundTaskScheduler()
#else
// No need for background schedulers on macOS, app continue running when inactive.
// No need for background schedulers on macOS, app continues running when inactive.
return nil
#endif
}
Expand Down
1 change: 1 addition & 0 deletions StreamChat.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -6764,6 +6764,7 @@
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
ENABLE_TESTABILITY = YES;
ENABLE_TESTING_SEARCH_PATHS = YES;
INFOPLIST_FILE = "$(SRCROOT)/Sources/StreamChatTestTools/Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,20 @@
ReferencedContainer = "container:StreamChat.xcodeproj">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "NO"
buildForArchiving = "NO"
buildForAnalyzing = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "793060ED25778897005CF846"
BuildableName = "StreamChatTestToolsTests.xctest"
BlueprintName = "StreamChatTestToolsTests"
ReferencedContainer = "container:StreamChat.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
Expand Down
61 changes: 41 additions & 20 deletions Tests/StreamChatTests/StreamChatTestPlan.xctestplan
Original file line number Diff line number Diff line change
@@ -1,37 +1,58 @@
{
"configurations" : [
"configurations": [
{
"id" : "5358EB81-7D4D-42F7-B281-016C02706988",
"name" : "Configuration 1",
"options" : {

"id": "5358EB81-7D4D-42F7-B281-016C02706988",
"name": "Configuration 1",
"options": {
}
}
],
"defaultOptions" : {
"codeCoverage" : {
"targets" : [
"defaultOptions": {
"codeCoverage": {
"targets": [
{
"containerPath" : "container:StreamChat.xcodeproj",
"identifier" : "799C941A247D2F80001F1104",
"name" : "StreamChat"
"containerPath": "container:StreamChat.xcodeproj",
"identifier": "799C941A247D2F80001F1104",
"name": "StreamChat"
}
]
},
"commandLineArgumentEntries" : [
"commandLineArgumentEntries": [
{
"argument" : "-com.apple.CoreData.ConcurrencyDebug 1"
"argument": "-com.apple.CoreData.ConcurrencyDebug 1"
}
],
"environmentVariableEntries": [
{
"key": "CI",
"value": "TRUE"
},
{
"key": "CI",
"value": "TRUE"
},
{
"key": "CI",
"value": "TRUE"
},
{
"key": "CI",
"value": "TRUE"
},
{
"key": "CI",
"value": "TRUE"
}
]
},
"testTargets" : [
"testTargets": [
{
"target" : {
"containerPath" : "container:StreamChat.xcodeproj",
"identifier" : "799C9450247D59B1001F1104",
"name" : "StreamChatTests"
"target": {
"containerPath": "container:StreamChat.xcodeproj",
"identifier": "799C9450247D59B1001F1104",
"name": "StreamChatTests"
}
}
],
"version" : 1
}
"version": 1
}
2 changes: 1 addition & 1 deletion fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ lane :test_debug_macos do
)
end

desc "Runs stress tests for"
desc "Runs stress tests for Debug config"
lane :stress_test do
scan(
project: "StreamChat.xcodeproj",
Expand Down
7 changes: 6 additions & 1 deletion fastlane/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,16 @@ Runs tests in Release config
fastlane test_release_macos
```
Runs tests in Release config on macOS
### test_debug_macos
```
fastlane test_debug_macos
```
Runs tests in Debug config on macOS
### stress_test
```
fastlane stress_test
```
Runs stress tests for in Debug config
Runs stress tests for Debug config
### stress_test_release
```
fastlane stress_test_release
Expand Down

0 comments on commit 19a2afe

Please sign in to comment.