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

Implement performance benchmarks #446

Closed
wants to merge 14 commits into from
Closed
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
1 change: 1 addition & 0 deletions .github/actions/bootstrap/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ runs:
~/Library/Caches/Homebrew/vale*
~/Library/Caches/Homebrew/xcparse*
~/Library/Caches/Homebrew/sonar-scanner*
~/Library/Caches/Homebrew/google-cloud-sdk*
key: ${{ env.IMAGE }}-brew-${{ hashFiles('**/Brewfile.lock.json') }}
restore-keys: ${{ env.IMAGE }}-brew-
- uses: ./.github/actions/ruby-cache
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/cron-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ALLURE_TOKEN: ${{ secrets.ALLURE_TOKEN }}
XCODE_VERSION: ${{ matrix.xcode }}
IOS_SIMULATOR_DEVICE: "${{ matrix.device }} (${{ matrix.ios }})" # For the Allure report
steps:
- uses: actions/[email protected]
- uses: actions/download-artifact@v3
Expand Down
61 changes: 61 additions & 0 deletions .github/workflows/xcmetrics.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Performance Benchmarks

on:
schedule:
# Runs "At 03:00 every night"
- cron: '0 3 * * *'

pull_request:
branches: # FIXME: delete this
- '**'

# types:
# - opened
# - ready_for_review

workflow_dispatch:

env:
HOMEBREW_NO_INSTALL_CLEANUP: 1 # Disable cleanup for homebrew, we don't need it on CI

jobs:
xcmetrics:
name: XCMetrics
runs-on: macos-14
env:
GITHUB_TOKEN: '${{ secrets.CI_BOT_GITHUB_TOKEN }}'
steps:
- name: Install Bot SSH Key
# if: ${{ github.event_name != 'pull_request' || github.event.pull_request.draft == false }} # FIXME: delete the comment
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.BOT_SSH_PRIVATE_KEY }}

- uses: actions/[email protected]
# if: ${{ github.event_name != 'pull_request' || github.event.pull_request.draft == false }} # FIXME: delete the comment
with:
fetch-depth: 0 # to fetch git tags

- uses: ./.github/actions/bootstrap
# if: ${{ github.event_name != 'pull_request' || github.event.pull_request.draft == false }} # FIXME: delete the comment
env:
GOOGLE_APPLICATION_CREDENTIALS: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}
INSTALL_GCLOUD: true

- name: Run Performance Metrics
# if: ${{ github.event_name != 'pull_request' || github.event.pull_request.draft == false }} # FIXME: delete the comment
run: bundle exec fastlane xcmetrics
timeout-minutes: 120
env:
GITHUB_PR_NUM: ${{ github.event.pull_request.number }}
BRANCH_NAME: ${{ github.event.pull_request.head.ref }}
MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }}
APPSTORE_API_KEY: ${{ secrets.APPSTORE_API_KEY }}

- uses: actions/upload-artifact@v3
if: failure()
with:
name: Test Data
path: |
derived_data/Build/Products/xcodebuild_output.log
fastlane/performance/stream-chat-swiftui.json
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ Pods/
Carthage/
!Sample/Carthage/

# gcloud
google-cloud-sdk
gcloud.tar.gz
gcloud-service-account-key.json

# Ignore Products folder
Products/

Expand All @@ -74,6 +79,7 @@ fastlane/test_output
fastlane/allurectl
fastlane/xcresults
fastlane/recordings
fastlane/performance
StreamChatCore.framework.coverage.txt
StreamChatCoreTests.xctest.coverage.txt
vendor/bundle/
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

### βœ… Added
- Link detection in the text views
- Indicator when a message was edited

# [4.49.0](https://github.com/GetStream/stream-chat-swiftui/releases/tag/4.49.0)
_February 28, 2024_
Expand Down
1 change: 1 addition & 0 deletions Githubfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
export ALLURECTL_VERSION='2.15.1'
export XCRESULTS_VERSION='1.16.3'
export YEETD_VERSION='1.0'
export GCLOUD_VERSION='464.0.0'
11 changes: 11 additions & 0 deletions Scripts/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,14 @@ if [[ ${INSTALL_YEETD-default} == true ]]; then
puts "Running yeetd daemon"
yeetd &
fi

if [[ ${INSTALL_GCLOUD-default} == true ]]; then
puts "Install gcloud"
brew install --cask google-cloud-sdk

# Editor access required: https://console.cloud.google.com/iam-admin/iam
printf "%s" "$GOOGLE_APPLICATION_CREDENTIALS" > ./fastlane/gcloud-service-account-key.json
gcloud auth activate-service-account --key-file="./fastlane/gcloud-service-account-key.json"
gcloud config set project stream-chat-swiftui
gcloud services enable toolresults.googleapis.com
fi
2 changes: 2 additions & 0 deletions Sources/StreamChatSwiftUI/Appearance.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,5 @@ extension EnvironmentValues {
}
}
}

// I'M TESTING PERFORMACE BENCHMARKS
Original file line number Diff line number Diff line change
Expand Up @@ -350,8 +350,11 @@ open class ChatChannelViewModel: ObservableObject, MessagesDataSource {
}

let delay = previousMessage.createdAt.timeIntervalSince(date)
let showMessageEditedLabel = utils.messageListConfig.isMessageEditedLabelEnabled
&& message.textUpdatedAt != nil

if delay > utils.messageListConfig.maxTimeIntervalBetweenMessagesInGroup {
if delay > utils.messageListConfig.maxTimeIntervalBetweenMessagesInGroup
|| showMessageEditedLabel {
temp[message.id]?.append(firstMessageKey)
var prevInfo = temp[previousMessage.id] ?? []
prevInfo.append(lastMessageKey)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ public class DefaultMessageIdBuilder: MessageIdBuilder {
if message.localState != nil {
statesId = message.uploadingStatesId
}
if message.textUpdatedAt != nil {
statesId = "edited"
}
return message.baseId + statesId + message.reactionScoresId
+ message.repliesCountId + "\(message.updatedAt)" + message.pinStateId
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ public struct MessageListConfig {
handleTabBarVisibility: Bool = true,
messageListAlignment: MessageListAlignment = .standard,
uniqueReactionsEnabled: Bool = false,
localLinkDetectionEnabled: Bool = true
localLinkDetectionEnabled: Bool = true,
isMessageEditedLabelEnabled: Bool = true
) {
self.messageListType = messageListType
self.typingIndicatorPlacement = typingIndicatorPlacement
Expand All @@ -50,6 +51,7 @@ public struct MessageListConfig {
self.messageListAlignment = messageListAlignment
self.uniqueReactionsEnabled = uniqueReactionsEnabled
self.localLinkDetectionEnabled = localLinkDetectionEnabled
self.isMessageEditedLabelEnabled = isMessageEditedLabelEnabled
}

public let messageListType: MessageListType
Expand All @@ -72,6 +74,7 @@ public struct MessageListConfig {
public let messageListAlignment: MessageListAlignment
public let uniqueReactionsEnabled: Bool
public let localLinkDetectionEnabled: Bool
public let isMessageEditedLabelEnabled: Bool
}

/// Contains information about the message paddings.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,19 @@ struct MessageDateView: View {

var message: ChatMessage

var text: String {
var text = dateFormatter.string(from: message.createdAt)
let showMessageEditedLabel = utils.messageListConfig.isMessageEditedLabelEnabled
&& message.textUpdatedAt != nil
&& !message.isDeleted
if showMessageEditedLabel {
text = text + " β€’ " + L10n.Message.Cell.edited
}
return text
}

var body: some View {
Text(dateFormatter.string(from: message.createdAt))
Text(text)
.font(fonts.footnote)
.foregroundColor(Color(colors.textLowEmphasis))
.animation(nil)
Expand Down
2 changes: 2 additions & 0 deletions Sources/StreamChatSwiftUI/Generated/L10n.swift
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,8 @@ internal enum L10n {
internal static var title: String { L10n.tr("Localizable", "message.bounce.title") }
}
internal enum Cell {
/// Edited
internal static var edited: String { L10n.tr("Localizable", "message.cell.edited") }
/// Pinned by
internal static var pinnedBy: String { L10n.tr("Localizable", "message.cell.pinnedBy") }
/// unknown
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"message.gallery.photos" = "Photos";
"message.cell.pinnedBy" = "Pinned by";
"message.cell.unknownPin" = "unknown";
"message.cell.edited" = "Edited";
"message.reactions.currentUser" = "You";

"alert.actions.cancel" = "Cancel";
Expand Down
Loading
Loading