Skip to content

Commit

Permalink
Merge develop into feat/update_conversation_proteus_verification_status
Browse files Browse the repository at this point in the history
  • Loading branch information
borichellow committed Oct 19, 2023
2 parents 551cbd8 + 3b1d9b2 commit 1feeac9
Show file tree
Hide file tree
Showing 427 changed files with 12,725 additions and 3,935 deletions.
22 changes: 22 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "gradle"
open-pull-requests-limit: 1
directory: "/"
schedule:
interval: "daily"
reviewers:
- "wireapp/android"

- package-ecosystem: "github-actions"
open-pull-requests-limit: 1
directory: "/"
schedule:
interval: "weekly"
reviewers:
- "wireapp/android"
113 changes: 100 additions & 13 deletions .github/workflows/cherry-pick-rc-to-develop.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
# GitHub Action: Cherry-pick from `release/candidate` to `TARGET_BRANCH`
#
# This action automates the process of cherry-picking merged PRs from `release/candidate` branch to `TARGET_BRANCH`.
# It is triggered whenever a pull request is merged into `release/candidate`.
#
# The action performs the following steps:
# 1. Checkout the merged PR.
# 2. If changes are made outside the specified submodule or no submodule is specified, the action proceeds.
# 3. If a submodule name is provided in the `SUBMODULE_NAME` environment variable:
# a. The action creates a temporary branch.
# b. Updates the submodule to its latest version from `develop`.
# c. Commits the submodule updates.
# 4. Squashes the commit with the commit message of the merged PR (if a submodule was updated).
# 5. Cherry-picks the squashed (or original if no squashing occurred) commit to a new branch based on `develop`.
# 6. If any conflicts arise during the cherry-pick, they are committed.
# 7. The branch with the cherry-picked changes is pushed.
# 8. A new pull request is created against `develop` with the cherry-picked changes.
#
# Note: Ensure you add a "cherry-pick" label to your project. This label is required for the creation of cherry-picked PRs.
# If needed, you can also set the `TARGET_BRANCH` environment variable to specify a different target branch for the cherry-pick.
# By default, it's set to `develop`.

name: "Cherry-pick from rc to develop"

on:
Expand All @@ -7,6 +29,11 @@ on:
types:
- closed

env:

TARGET_BRANCH: develop
# SUBMODULE_NAME:

jobs:
cherry-pick:
runs-on: ubuntu-latest
Expand All @@ -17,9 +44,10 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive

- name: Append -cherry-pick to branch name
id: extract
Expand All @@ -29,27 +57,86 @@ jobs:
echo "New branch name: $NEW_BRANCH_NAME"
echo "newBranchName=$NEW_BRANCH_NAME" >> $GITHUB_ENV
- name: Check for changes excluding submodule
id: check_changes
run: |
if [[ -n "${{ env.SUBMODULE_NAME }}" ]]; then
# If SUBMODULE_NAME is set
NUM_CHANGES=$(git diff origin/${{ env.TARGET_BRANCH }} --name-only | grep -v "^${{ env.SUBMODULE_NAME }}/" | wc -l)
else
# If SUBMODULE_NAME is not set
NUM_CHANGES=$(git diff origin/${{ env.TARGET_BRANCH }} --name-only | wc -l)
fi
if [ "$NUM_CHANGES" -gt 0 ]; then
echo "shouldCherryPick=true" >> $GITHUB_ENV
else
if [[ -n "${{ env.SUBMODULE_NAME }}" ]]; then
echo "No changes outside of ${{ env.SUBMODULE_NAME }} submodule, skipping cherry-pick"
else
echo "No changes detected, skipping cherry-pick"
fi
echo "shouldCherryPick=false" >> $GITHUB_ENV
fi
- uses: fregante/setup-git-user@v2

- name: Update submodule
if: env.SUBMODULE_NAME && env.shouldCherryPick == 'true'
run: |
set -x
# Create a temporary branch and get the last commit message
git checkout -b temp-branch-for-cherry-pick
LAST_COMMIT_MESSAGE=$(git log --format=%B -n 1 ${{ github.event.pull_request.merge_commit_sha }})
cd ${{ env.SUBMODULE_NAME }}
git checkout ${{ env.TARGET_BRANCH }}
git pull origin ${{ env.TARGET_BRANCH }}
cd ..
git add ${{ env.SUBMODULE_NAME }}
git commit -m "Update submodule ${{ env.SUBMODULE_NAME }} to latest from ${{ env.TARGET_BRANCH }}"
echo "lastCommitMessage=LAST_COMMIT_MESSAGE" >> $GITHUB_ENV
- name: Get Cherry-pick commit
id: get-cherry
if: env.shouldCherryPick == 'true'
run: |
if [[ -n "${{ env.SUBMODULE_NAME }}" ]]; then
# If SUBMODULE_NAME is set
git reset --soft HEAD~2
git commit -m "${{ env.lastCommitMessage }}"
fi
# Get the SHA of the current commit (either squashed or not based on the condition above)
CHERRY_PICK_COMMIT=$(git rev-parse HEAD)
echo "cherryPickCommit=$CHERRY_PICK_COMMIT" >> $GITHUB_ENV
- name: Cherry-pick commits
id: cherry
id: commit-cherry-pick
if: env.shouldCherryPick == 'true'
run: |
git fetch origin develop:develop
git checkout -b ${{ env.newBranchName }} develop
# Cherry-picking the last commit on the base branch
OUTPUT=$(git cherry-pick ${{ github.event.pull_request.merge_commit_sha }} --strategy-option theirs || true)
CONFLICTS=$(echo "$OUTPUT" | grep 'CONFLICT' || echo "")
if [ -n "$CONFLICTS" ]; then
git add .
git cherry-pick --continue || true
# Checkout the desired branch and cherry-pick the commit
git checkout ${{ env.TARGET_BRANCH }}
git checkout -b ${{ env.newBranchName }}
OUTPUT=$(git cherry-pick ${{ env.cherryPickCommit }} || true)
# Handle conflicts
CONFLICTED_FILES=$(git diff --name-only --diff-filter=U)
if [[ "$OUTPUT" == *"CONFLICT"* ]]; then
# Commit the remaining conflicts
git commit -am "Commit with unresolved merge conflicts outside of ${{ env.SUBMODULE_NAME }}"
fi
# Push branch and remove temp
git push origin ${{ env.newBranchName }} || (echo "Failed to push to origin" && exit 1)
echo "conflicts=$CONFLICTS" >> $GITHUB_ENV
echo "conflictedFiles=$CONFLICTED_FILES" >> $GITHUB_ENV
if [[ -n "${{ env.SUBMODULE_NAME }}" ]]; then
git branch -D temp-branch-for-cherry-pick
fi
- name: Create PR
if: env.shouldCherryPick == 'true'
env:
PR_TITLE: ${{ github.event.pull_request.title }}
PR_BRANCH: ${{ env.newBranchName }}
PR_ASSIGNEE: ${{ github.event.pull_request.user.login }}
PR_BODY: "${{ format('Cherry pick from the original PR: \n- #{0}\n\n---- \n\n ⚠️ Conflicts during cherry-pick:\n{1}\n\n{2}', github.event.pull_request.number, env.conflicts, github.event.pull_request.body) }}"
run: gh pr create --title "$PR_TITLE" --body "$PR_BODY" --base develop --head "$PR_BRANCH" --label "cherry-pick" --assignee "$PR_ASSIGNEE"
PR_BODY: "${{ format('Cherry pick from the original PR: \n- #{0}\n\n---- \n\n ⚠️ Conflicts during cherry-pick:\n{1}\n\n{2}', github.event.pull_request.number, env.conflictedFiles, github.event.pull_request.body) }}"
run: gh pr create --title "$PR_TITLE" --body "$PR_BODY" --base ${{ env.TARGET_BRANCH }} --head "$PR_BRANCH" --label "cherry-pick" --assignee "$PR_ASSIGNEE"
2 changes: 1 addition & 1 deletion .github/workflows/label-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ jobs:
name: Label PR based on title
runs-on: ubuntu-latest
steps:
- uses: srvaroa/labeler@v0.9
- uses: srvaroa/labeler@v1.6.3
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
16 changes: 0 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,6 @@

## How to build

### GitHub Packages authentication

In order to download some open source libraries published on GitHub Pacakges, a GitHub Personal Access Token is needed with `packages:read` scope.

1. You can generate one quickly [on this page](https://github.com/settings/tokens/new?description=ReadPackages&scopes=read:packages). Or, for more details, see [Creating a personal access token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token).

2. In `local.properties` add:
```
github.package_registry.user=<github_username>
github.package_registry.token=<github_token>
```

Alternatively the credentials are also read from your environment if `GITHUB_USER` and `GITHUB_TOKEN` exists.

> *Note*: See [GitHub packages docs](https://docs.github.com/en/packages/learn-github-packages/introduction-to-github-packages#authenticating-to-github-packages) for more details and.
### Dependencies

- JDK 17 (ex: openjdk-17-jdk on Ubuntu)
Expand Down
7 changes: 0 additions & 7 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,6 @@ allprojects {
mavenLocal()
google()
mavenCentral()
maven {
url = uri("https://maven.pkg.github.com/wireapp/core-crypto")
credentials {
username = getLocalProperty("github.package_registry.user", System.getenv("GITHUB_USER"))
password = getLocalProperty("github.package_registry.token", System.getenv("GITHUB_TOKEN"))
}
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@ sealed class InputAction {
val command: Command
) : InputAction()

object Quit : InputAction()
data object Quit : InputAction()
}
20 changes: 10 additions & 10 deletions cli/src/appleMain/kotlin/com/wire/kalium/cli/commands/InputFlow.kt
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,14 @@ fun readChar(): Input =

sealed class Input {
data class Character(val char: Char) : Input()
object ArrowUp : Input()
object ArrowDown : Input()
object ArrowLeft : Input()
object ArrowRight : Input()
object HomeKey : Input()
object EndKey : Input()
object DeleteKey : Input()
object PageUp : Input()
object PageDown : Input()
object Backspace : Input()
data object ArrowUp : Input()
data object ArrowDown : Input()
data object ArrowLeft : Input()
data object ArrowRight : Input()
data object HomeKey : Input()
data object EndKey : Input()
data object DeleteKey : Input()
data object PageUp : Input()
data object PageDown : Input()
data object Backspace : Input()
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ import platform.posix.tcsetattr
import platform.posix.termios

sealed class PosixSignal {
object WindowChanged : PosixSignal()
data object WindowChanged : PosixSignal()
}

private val signalFlow = MutableSharedFlow<PosixSignal>()
Expand Down
4 changes: 3 additions & 1 deletion cli/src/appleMain/kotlin/main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import com.wire.kalium.cli.commands.MarkAsReadCommand
import com.wire.kalium.cli.commands.RefillKeyPackagesCommand
import com.wire.kalium.cli.commands.RemoveMemberFromGroupCommand
import com.wire.kalium.cli.commands.InteractiveCommand
import com.wire.kalium.cli.commands.UpdateSupportedProtocolsCommand

fun main(args: Array<String>) = CLIApplication().subcommands(
LoginCommand().subcommands(
Expand All @@ -37,6 +38,7 @@ fun main(args: Array<String>) = CLIApplication().subcommands(
RemoveMemberFromGroupCommand(),
RefillKeyPackagesCommand(),
MarkAsReadCommand(),
InteractiveCommand()
InteractiveCommand(),
UpdateSupportedProtocolsCommand()
)
).main(args)
36 changes: 25 additions & 11 deletions cli/src/commonMain/kotlin/com/wire/kalium/cli/CLIApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,30 @@ import com.github.ajalt.clikt.parameters.options.flag
import com.github.ajalt.clikt.parameters.options.option
import com.github.ajalt.clikt.parameters.types.enum
import com.wire.kalium.logger.KaliumLogLevel
import com.wire.kalium.logger.KaliumLogger
import com.wire.kalium.logic.CoreLogger
import com.wire.kalium.logic.CoreLogic
import com.wire.kalium.logic.featureFlags.KaliumConfigs
import kotlinx.coroutines.runBlocking
import kotlin.time.Duration

class CLIApplication : CliktCommand(allowMultipleSubcommands = true) {

private val logLevel by option(help = "log level").enum<KaliumLogLevel>().default(KaliumLogLevel.WARN)
private val logOutputFile by option(help = "output file for logs")
private val developmentApiEnabled by option(help = "use development API if supported by backend").flag(default = false)
private val encryptProteusStorage by option(help = "use encrypted storage for proteus sessions and identity").flag(default = false)
private val logLevel by option(
help = "log level"
).enum<KaliumLogLevel>().default(KaliumLogLevel.WARN)
private val logOutputFile by option(
help = "output file for logs"
)
private val developmentApiEnabled by option(
help = "use development API if supported by backend"
).flag(default = false)
private val encryptProteusStorage by option(
help = "use encrypted storage for proteus sessions and identity"
).flag(default = false)
private val mlsMigrationInterval by option(
help = "interval at which mls migration is updated"
).default("24h")
private val fileLogger: LogWriter by lazy { fileLogger(logOutputFile ?: "kalium.log") }

override fun run() = runBlocking {
Expand All @@ -45,16 +58,18 @@ class CLIApplication : CliktCommand(allowMultipleSubcommands = true) {
rootPath = "$HOME_DIRECTORY/.kalium/accounts",
kaliumConfigs = KaliumConfigs(
developmentApiEnabled = developmentApiEnabled,
encryptProteusStorage = encryptProteusStorage
encryptProteusStorage = encryptProteusStorage,
mlsMigrationInterval = Duration.parse(mlsMigrationInterval)
)
)
}

if (logOutputFile != null) {
CoreLogger.setLoggingLevel(logLevel, fileLogger)
} else {
CoreLogger.setLoggingLevel(logLevel)
}
CoreLogger.init(
KaliumLogger.Config(
logLevel,
if (logOutputFile != null) listOf(fileLogger) else emptyList(),
)
)

currentContext.findObject<CoreLogic>()?.updateApiVersionsScheduler?.scheduleImmediateApiVersionUpdate()
Unit
Expand All @@ -63,7 +78,6 @@ class CLIApplication : CliktCommand(allowMultipleSubcommands = true) {
companion object {
val HOME_DIRECTORY: String = homeDirectory()
}

}

expect fun fileLogger(filePath: String): LogWriter
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Wire
* Copyright (C) 2023 Wire Swiss GmbH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://www.gnu.org/licenses/.
*/

package com.wire.kalium.cli.commands

import com.github.ajalt.clikt.core.CliktCommand
import com.github.ajalt.clikt.core.PrintMessage
import com.github.ajalt.clikt.core.requireObject
import com.wire.kalium.logic.feature.UserSessionScope
import com.wire.kalium.logic.functional.fold
import kotlinx.coroutines.runBlocking

class UpdateSupportedProtocolsCommand : CliktCommand(name = "update-supported-protocols") {

private val userSession by requireObject<UserSessionScope>()

override fun run() = runBlocking {
userSession.syncManager.waitUntilLive()
userSession.users.updateSupportedProtocols().fold({ failure ->
throw PrintMessage("updating supported protocols failed: $failure")
}, {
echo("supported protocols were updated")
})
}
}
Loading

0 comments on commit 1feeac9

Please sign in to comment.