-
Notifications
You must be signed in to change notification settings - Fork 7
chore: update kotlin [WPB-20393] #3846
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
Open
MohamadJaara
wants to merge
19
commits into
develop
Choose a base branch
from
mo/chore/update-kotliun
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
55f7513
chore: update Gradle and Kotlin configurations
MohamadJaara bd006b1
use kotlin 2.3.0
MohamadJaara fc918dd
update shadow to 9.3.1
MohamadJaara 2b9a2dd
chore: update package names and rename destination files
MohamadJaara a82c209
set the correct gradle distributionSha256Sum
MohamadJaara b291072
chore: configure shadowJar task for testservice
MohamadJaara 2cd9c7c
chore: update commonAndroidLibConfig to conditionally include consume…
MohamadJaara 952eed4
chore: update compile SDK version to 36 and refactor configurations
MohamadJaara 7828511
Merge branch 'develop' into mo/chore/update-kotliun
MohamadJaara 30f4900
detekt
MohamadJaara f6e6798
update mokkery
MohamadJaara d2eeb43
chore: implement DagCommandTask for affected module detection and upd…
MohamadJaara cee05c6
chore: optimize task retrieval logic in OnlyAffectedTestTask
MohamadJaara a283063
chore: update test compilation commands for Android device and host t…
MohamadJaara a55285b
chore: rename test files and update detekt configuration exclusions
MohamadJaara 7653f48
Merge branch 'develop' into mo/chore/update-kotliun
MohamadJaara c47a4cd
chore: update test logging configuration and add silent logger for da…
MohamadJaara 8fde412
chore: update test logging configuration and add silent logger for da…
MohamadJaara 28141ed
Merge remote-tracking branch 'origin/develop' into mo/chore/update-ko…
MohamadJaara File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,149 @@ | ||
| /* | ||
| * Wire | ||
| * Copyright (C) 2024 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/. | ||
| */ | ||
|
|
||
| import org.gradle.api.DefaultTask | ||
| import org.gradle.api.artifacts.ProjectDependency | ||
| import org.gradle.api.tasks.Input | ||
| import org.gradle.api.tasks.TaskAction | ||
|
|
||
| /** | ||
| * Gradle 9 compatible replacement for the external dag-command plugin. | ||
| * It writes the same affected-modules output used by [OnlyAffectedTestTask]. | ||
| */ | ||
| open class DagCommandTask : DefaultTask() { | ||
|
|
||
| @Input | ||
| var defaultBranch: String = "origin/develop" | ||
|
|
||
| init { | ||
| group = "verification" | ||
| description = "Computes affected modules and writes build/dag-command/affected-modules.json" | ||
| } | ||
|
|
||
| @TaskAction | ||
| fun computeAffectedModules() { | ||
| val outputFile = project.layout.buildDirectory.file(OUTPUT_FILE).get().asFile | ||
| val changedModules = changedModules() ?: run { | ||
| outputFile.delete() | ||
| return | ||
| } | ||
| val affectedModules = expandToDependents(changedModules) | ||
|
|
||
| outputFile.parentFile.mkdirs() | ||
| outputFile.writeText( | ||
| affectedModules | ||
| .sorted() | ||
| .joinToString(prefix = "[", postfix = "]") { "\"$it\"" } | ||
| ) | ||
|
|
||
| println("Default branch: $defaultBranch") | ||
| println("Output type: json") | ||
| println("Output path: ${project.layout.buildDirectory.get().asFile.absolutePath}") | ||
| println("Changed modules: ${changedModules.size}, affected modules: ${affectedModules.size}") | ||
| } | ||
|
|
||
| private fun changedModules(): Set<String>? { | ||
| val process = ProcessBuilder( | ||
| "git", | ||
| "-C", | ||
| project.rootDir.absolutePath, | ||
| "diff", | ||
| defaultBranch, | ||
| "--dirstat=files,0" | ||
| ) | ||
| .redirectErrorStream(true) | ||
| .start() | ||
|
|
||
| val output = process.inputStream.bufferedReader().readText() | ||
| if (process.waitFor() != 0) { | ||
| println("Unable to resolve changed files from git. Falling back to running all tests.") | ||
| return null | ||
| } | ||
|
|
||
| val allModules = project.subprojects.map { it.path }.toSet() | ||
| val parsedModules = output | ||
| .lineSequence() | ||
| .map { it.trim() } | ||
| .filter { it.isNotEmpty() } | ||
| .flatMap { parseModuleCandidates(it).asSequence() } | ||
| .toSet() | ||
|
|
||
| return if (parsedModules.contains(BUILD_SRC) || parsedModules.contains(GRADLE)) { | ||
| allModules | ||
| } else { | ||
| parsedModules.filter(allModules::contains).toSet() | ||
| } | ||
| } | ||
|
|
||
| private fun parseModuleCandidates(dirstatLine: String): Set<String> { | ||
| val fullPath = dirstatLine | ||
| .trimStart() | ||
| .split(" ", limit = 2) | ||
| .getOrNull(1) | ||
| ?.trim() | ||
| .orEmpty() | ||
|
|
||
| val words = fullPath.split("/") | ||
| .takeWhile { it != "src" } | ||
| .filter { it.isNotEmpty() } | ||
|
|
||
| return words.fold(emptySet()) { acc, word -> | ||
| if (acc.isEmpty()) { | ||
| setOf(":$word") | ||
| } else { | ||
| val lastWord = acc.last() | ||
| acc + "$lastWord:$word" | ||
| } | ||
| } | ||
| } | ||
|
|
||
| private fun expandToDependents(changedModules: Set<String>): Set<String> { | ||
| if (changedModules.isEmpty()) return emptySet() | ||
|
|
||
| val reverseGraph = mutableMapOf<String, MutableSet<String>>() | ||
| project.subprojects.forEach { module -> | ||
| val dependencies = module.configurations.flatMap { configuration -> | ||
| configuration.dependencies | ||
| .withType(ProjectDependency::class.java) | ||
| .map { dependency -> dependency.path } | ||
| }.toSet() | ||
|
|
||
| dependencies.forEach { dependencyPath -> | ||
| reverseGraph.getOrPut(dependencyPath) { mutableSetOf() }.add(module.path) | ||
| } | ||
| } | ||
|
|
||
| val visited = changedModules.toMutableSet() | ||
| val queue = ArrayDeque(changedModules) | ||
| while (queue.isNotEmpty()) { | ||
| val current = queue.removeFirst() | ||
| reverseGraph[current].orEmpty().forEach { dependent -> | ||
| if (visited.add(dependent)) { | ||
| queue.add(dependent) | ||
| } | ||
| } | ||
| } | ||
| return visited | ||
| } | ||
|
|
||
| private companion object { | ||
| const val OUTPUT_FILE = "dag-command/affected-modules.json" | ||
| const val BUILD_SRC = ":buildSrc" | ||
| const val GRADLE = ":gradle" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the dag-command is not supported by Gradle 9 so here is a task that does more or less the same