Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CI] Make CI great again #521

Merged
merged 5 commits into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions .github/workflows/cron-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ jobs:
run: bundle exec fastlane build_test_app_and_frameworks
timeout-minutes: 60
env:
XCODE_VERSION: "14.3.1"
- uses: actions/upload-artifact@v3
XCODE_VERSION: "15.2" # Should match the minimum version in dependent jobs
- uses: actions/upload-artifact@v4
if: success()
with:
name: cache-derived-data
Expand All @@ -42,13 +42,13 @@ jobs:
strategy:
matrix:
include:
- ios: 17.4
- ios: 17.2
xcode: 15.2
os: macos-14
device: "iPhone 15 Pro"
setup_runtime: false
- ios: 16.4
xcode: 14.3.1
xcode: 15.2
os: macos-14
device: "iPhone 14 Pro Max"
setup_runtime: false
Expand All @@ -61,14 +61,15 @@ jobs:
XCODE_VERSION: ${{ matrix.xcode }}
steps:
- uses: actions/[email protected]
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
name: cache-derived-data
path: derived_data/Build/
- uses: ./.github/actions/bootstrap
env:
INSTALL_ALLURE: true
INSTALL_YEETD: true
SKIP_MINT_BOOTSTRAP: true
- name: Cache iOS Simulator Runtime
uses: actions/cache@v4
id: runtime-cache
Expand Down Expand Up @@ -105,13 +106,14 @@ jobs:
run: |
brew install chargepoint/xcparse/xcparse
xcparse logs fastlane/test_output/StreamChatSwiftUITestsApp.xcresult fastlane/test_output/logs/
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
if: failure()
with:
name: Test Data E2E (iOS ${{ matrix.ios }})
path: |
fastlane/recordings
fastlane/sinatra_log.txt
fastlane/test_output/report.junit
fastlane/test_output/logs/*/Diagnostics/**/*.txt
fastlane/test_output/logs/*/Diagnostics/simctl_diagnostics/DiagnosticReports/*

Expand All @@ -120,12 +122,10 @@ jobs:
strategy:
matrix:
include:
- xcode: 15.2
- xcode: 15.4
os: macos-14
- xcode: 14.3.1
- xcode: 15.0.1
os: macos-14
- xcode: 14.2
os: macos-12
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
Expand Down Expand Up @@ -175,9 +175,9 @@ jobs:

automated-code-review:
name: Automated Code Review
runs-on: macos-12
runs-on: macos-13
env:
XCODE_VERSION: "14.0.1"
XCODE_VERSION: "15.0.1"
steps:
- uses: actions/[email protected]
- uses: ./.github/actions/bootstrap
Expand Down
21 changes: 14 additions & 7 deletions .github/workflows/smoke-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ jobs:
- name: Build
run: bundle exec fastlane build_test_app_and_frameworks
timeout-minutes: 60
- uses: actions/upload-artifact@v3
env:
XCODE_VERSION: "15.2" # Should match the minimum version in dependent jobs
- uses: actions/upload-artifact@v4
if: success()
with:
name: cache-derived-data
Expand All @@ -48,7 +50,7 @@ jobs:
needs: build-test-app-and-frameworks
steps:
- uses: actions/[email protected]
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
name: cache-derived-data
path: derived_data/Build/
Expand Down Expand Up @@ -90,7 +92,7 @@ jobs:
brew install chargepoint/xcparse/xcparse
xcparse logs fastlane/test_output/StreamChatSwiftUI.xcresult fastlane/test_output/logs/
xcparse screenshots fastlane/test_output/StreamChatSwiftUI.xcresult fastlane/test_output/snapshots --test
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
if: failure()
with:
name: Test Data UI
Expand All @@ -116,17 +118,21 @@ jobs:
fail-fast: false
steps:
- uses: actions/[email protected]
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
name: cache-derived-data
path: derived_data/Build/
- uses: ./.github/actions/bootstrap
env:
INSTALL_ALLURE: true
INSTALL_YEETD: true
SKIP_MINT_BOOTSTRAP: true
- name: Run UI Tests (Debug)
run: bundle exec fastlane test_e2e_mock device:"${{ env.IOS_SIMULATOR_DEVICE }}" batch:'${{ matrix.batch }}' test_without_building:true
timeout-minutes: 100
env:
XCODE_VERSION: "15.2" # the most stable pair of Xcode
IOS_SIMULATOR_DEVICE: "iPhone 15 Pro (17.2)" # and iOS
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_PR_NUM: ${{ github.event.number }}
MATRIX_SIZE: ${{ strategy.job-total }}
Expand All @@ -146,13 +152,14 @@ jobs:
run: |
brew install chargepoint/xcparse/xcparse
xcparse logs fastlane/test_output/StreamChatSwiftUITestsApp.xcresult fastlane/test_output/logs/
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
if: failure()
with:
name: Test Data E2E
name: Test Data E2E ${{ matrix.batch }}
path: |
fastlane/recordings
fastlane/sinatra_log.txt
fastlane/test_output/report.junit
fastlane/test_output/logs/*/Diagnostics/**/*.txt
fastlane/test_output/logs/*/Diagnostics/simctl_diagnostics/DiagnosticReports/*

Expand Down Expand Up @@ -182,7 +189,7 @@ jobs:
if: ${{ github.event_name != 'push' && github.event.inputs.snapshots != 'true' }}
steps:
- uses: actions/[email protected]
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
name: cache-derived-data
path: derived_data/Build/
Expand Down
6 changes: 4 additions & 2 deletions Scripts/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ chmod +x ./hooks/git-format-staged
puts "Install brew dependencies"
brew bundle -d

puts "Bootstrap Mint dependencies"
mint bootstrap --link
if [ "${SKIP_MINT_BOOTSTRAP:-}" != true ]; then
puts "Bootstrap Mint dependencies"
mint bootstrap --link
fi

if [[ ${INSTALL_ALLURE-default} == true ]]; then
puts "Install allurectl"
Expand Down
4 changes: 4 additions & 0 deletions StreamChatSwiftUITestsAppTests/Pages/MessageListPage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,10 @@ class MessageListPage {
static func giphyLabel(in messageCell: XCUIElement) -> XCUIElement {
messageCell.staticTexts["GiphyAttachmentView"]
}

static func actionButtons() -> XCUIElementQuery {
app.buttons.matching(NSPredicate(format: "identifier LIKE 'GiphyAttachmentView'"))
}

private static func attachmentActionButton(in messageCell: XCUIElement, label: String) -> XCUIElement {
messageCell.buttons.matching(NSPredicate(
Expand Down
21 changes: 15 additions & 6 deletions StreamChatSwiftUITestsAppTests/Robots/UserRobot+Asserts.swift
Original file line number Diff line number Diff line change
Expand Up @@ -442,22 +442,32 @@ extension UserRobot {
XCTAssertTrue(errorButton.exists, "There is no error icon", file: file, line: line)
return self
}

@discardableResult
func assertMessageDeliveryStatus(
func waitForMessageDeliveryStatus(
_ deliveryStatus: MessageDeliveryStatus?,
at messageCellIndex: Int? = nil,
file: StaticString = #filePath,
line: UInt = #line
) -> Self {
) -> Bool {
let messageCell = messageCell(withIndex: messageCellIndex, file: file, line: line)
let checkmark = attributes.statusCheckmark(for: deliveryStatus, in: messageCell)
if deliveryStatus == .failed || deliveryStatus == nil {
XCTAssertFalse(checkmark.exists, "Checkmark is visible", file: file, line: line)
return !checkmark.exists
} else {
XCTAssertTrue(checkmark.wait(timeout: 10).exists, "Checkmark is not visible", file: file, line: line)
return checkmark.wait(timeout: 10).exists
}
}

@discardableResult
func assertMessageDeliveryStatus(
_ deliveryStatus: MessageDeliveryStatus?,
at messageCellIndex: Int? = nil,
file: StaticString = #filePath,
line: UInt = #line
) -> Self {
let success = waitForMessageDeliveryStatus(deliveryStatus, at: messageCellIndex, file: file, line: line)
XCTAssertTrue(success)
return self
}

Expand Down Expand Up @@ -705,7 +715,6 @@ extension UserRobot {
let quotedMessage = attributes.quotedText(quotedText, in: messageCell).wait()
XCTAssertTrue(quotedMessage.exists, "Quoted message was not showed", file: file, line: line)
XCTAssertFalse(quotedMessage.isEnabled, "Quoted message should be disabled", file: file, line: line)
XCTAssertTrue(quotedMessage.isHittable, "Quoted message is not visible", file: file, line: line)
return self
}
}
Expand Down
30 changes: 16 additions & 14 deletions StreamChatSwiftUITestsAppTests/Robots/UserRobot.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,33 +29,34 @@ final class UserRobot: Robot {
ChannelListPage.userAvatar.safeTap()
return self
}

@discardableResult
func openChannel(channelCellIndex: Int = 0) -> Self {
let minExpectedCount = channelCellIndex + 1
let cells = ChannelListPage.cells.waitCount(minExpectedCount)
func waitForChannelListToLoad() -> Self {
let timeout = 15.0
let cells = ChannelListPage.cells.waitCount(1, timeout: timeout)

// TODO: CIS-1737
if !cells.firstMatch.exists {
for _ in 0...10 {
server.stop()
app.terminate()
_ = server.start(port: in_port_t(MockServerConfiguration.port))
server.stop()
_ = server.start(port: UInt16(MockServerConfiguration.port))
sleep(1)
app.launch()
login()
cells.waitCount(minExpectedCount)
cells.waitCount(1, timeout: timeout)
if cells.firstMatch.exists { break }
}
}

XCTAssertGreaterThanOrEqual(
cells.count,
minExpectedCount,
"Channel cell is not found at index #\(channelCellIndex)"
)

cells.allElementsBoundByIndex[channelCellIndex].safeTap()
XCTAssertGreaterThanOrEqual(cells.count, 1, "Channel list has not been loaded")
return self
}

@discardableResult
func openChannel(channelCellIndex: Int = 0) -> Self {
waitForChannelListToLoad()
ChannelListPage.cells.allElementsBoundByIndex[channelCellIndex].waitForHitPoint().safeTap()
return self
}
}
Expand Down Expand Up @@ -362,6 +363,7 @@ extension UserRobot {
sendMessage(text, waitForAppearance: false)
}
if send { tapOnSendGiphyButton() }
MessageListPage.Attributes.actionButtons().firstMatch.wait()
return self
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ final class Attachments_Tests: StreamTestCase {
override func setUpWithError() throws {
try super.setUpWithError()
addTags([.coreFeatures])
assertMockServer()
}

func test_uploadImage() throws {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class StreamTestCase: XCTestCase {
var backendRobot: BackendRobot!
var participantRobot: ParticipantRobot!
var server: StreamMockServer!
var mockServerCrashed = false
var recordVideo = false

override func setUpWithError() throws {
Expand All @@ -35,7 +36,6 @@ class StreamTestCase: XCTestCase {
stopVideo()
app.terminate()
server.stop()
server = nil
backendRobot.delayServerResponse(byTimeInterval: 0.0)

try super.tearDownWithError()
Expand All @@ -45,6 +45,10 @@ class StreamTestCase: XCTestCase {
}

extension StreamTestCase {

func assertMockServer() {
XCTAssertFalse(mockServerCrashed, "Mock server failed on start")
}

private func useMockServer() {
// Leverage web socket server
Expand Down Expand Up @@ -79,10 +83,17 @@ extension StreamTestCase {
private func startMockServer() {
server = StreamMockServer()
server.configure()
let result = server.start(port: in_port_t(MockServerConfiguration.port))
if !result {
XCTFail("Mock server failed on start")

for _ in 0...3 {
let serverHasStarted = server.start(port: UInt16(MockServerConfiguration.port))
if serverHasStarted {
return
}
server.stop()
MockServerConfiguration.port = Int.random(in: 61000..<62000)
}

mockServerCrashed = true
}

private func startVideo() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ final class ChannelList_Tests: StreamTestCase {
override func setUpWithError() throws {
try super.setUpWithError()
addTags([.coreFeatures])
assertMockServer()
}

func test_newMessageShownInChannelPreview_whenComingBackFromChannel() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
import XCTest

final class Ephemeral_Messages_Tests: StreamTestCase {

override func setUpWithError() throws {
try super.setUpWithError()
assertMockServer()
}

func test_userObservesAnimatedGiphy_whenUserAddsGiphyMessage() throws {
linkToScenario(withId: 435)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ final class MessageDeliveryStatus_ChannelList_Tests: StreamTestCase {
override func setUpWithError() throws {
try super.setUpWithError()
addTags([.messageDeliveryStatus])
assertMockServer()
}

func test_deliveryStatusClocksShownInPreview_whenTheLastMessageIsInPendingState() throws {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ final class MessageDeliveryStatus_Tests: StreamTestCase {
override func setUpWithError() throws {
try super.setUpWithError()
addTags([.messageDeliveryStatus])
assertMockServer()
}

// MARK: Message List
Expand Down
Loading
Loading