-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce separate logExtension task to log VCS options (#327)
* Introduce separate logExtension task to log VCS options
- Loading branch information
1 parent
397396f
commit 96002d8
Showing
7 changed files
with
173 additions
and
88 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
|
@@ -24,3 +24,5 @@ captures/ | |
|
||
# Metadata used for plugin testing | ||
**/emerge_config.json | ||
|
||
.tool-versions |
This file contains 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 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
67 changes: 61 additions & 6 deletions
67
...lugin/src/functionalTest/kotlin/com/emergetools/android/gradle/LoggingEmergePluginTest.kt
This file contains 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 |
---|---|---|
@@ -1,17 +1,72 @@ | ||
package com.emergetools.android.gradle | ||
|
||
import com.emergetools.android.gradle.base.EmergeGradleRunner | ||
import com.emergetools.android.gradle.utils.EnvUtils.withGitHubPREvent | ||
import org.junit.jupiter.api.Assertions | ||
import org.junit.jupiter.api.Test | ||
|
||
class LoggingEmergePluginTest : EmergePluginTest() { | ||
|
||
/** | ||
* If the info logging level is enabled we print out the plugin configuration. This tests that it doesn't cause any crashes. | ||
*/ | ||
// Write a test that verifies that executing the task 'logExtension' prints the extension to the console. | ||
@Test | ||
fun infoLogLevel() { | ||
EmergeGradleRunner.create("simple") | ||
.withArguments("tasks", "-i") | ||
fun logExtension() { | ||
val result = EmergeGradleRunner.create("simple") | ||
.withArguments("logExtension") | ||
.withGitHubPREvent() | ||
.build() | ||
.assertSuccessfulTask(":logExtension") | ||
|
||
Assertions.assertTrue( | ||
result.output.contains( | ||
"╔══════════════════════╗\n" + | ||
"║ Emerge configuration ║\n" + | ||
"╠══════════════════════╝\n" + | ||
"╠═ apiToken: *****\n" + | ||
"╠═ includeDependencyInformation: true\n" + | ||
"╠═ dryRun (optional): false\n" + | ||
"╠═ verbose (optional): false\n" + | ||
"╔══════╗\n" + | ||
"║ size ║\n" + | ||
"╠══════╝\n" + | ||
"╠═ tag (optional): \n" + | ||
"╚═ enabled: true\n" + | ||
"╔═══════════╗\n" + | ||
"║ snapshots ║\n" + | ||
"╠═══════════╝\n" + | ||
"╠═ snapshotsStorageDirectory: \n" + | ||
"╠═ apiVersion: \n" + | ||
"╠═ includePrivatePreviews: \n" + | ||
"╠═ includePreviewParamPreviews: \n" + | ||
"╠═ tag (optional): \n" + | ||
"╠═ enabled: true\n" + | ||
"╚═ profile: false\n" + | ||
"╔════════╗\n" + | ||
"║ reaper ║\n" + | ||
"╠════════╝\n" + | ||
"╠═ enabledVariants: []\n" + | ||
"╠═ publishableApiKey: MISSING\n" + | ||
"╚═ tag (optional): \n" + | ||
"╔═════════════╗\n" + | ||
"║ performance ║\n" + | ||
"╠═════════════╝\n" + | ||
"╠═ projectPath: \n" + | ||
"╠═ tag (optional): \n" + | ||
"╚═ enabled: true\n" + | ||
"╔═══════════════════════════════════════════════╗\n" + | ||
"║ vcsOptions (optional, defaults to Git values) ║\n" + | ||
"╠═══════════════════════════════════════════════╝\n" + | ||
"╠═ sha: testSha\n" + | ||
"╠═ baseSha: testBaseSha\n" + | ||
"╠═ previousSha: testPreviousSha\n" + | ||
"╠═ branchName: testBranchName\n" + | ||
"╠═ prNumber: 123\n" + | ||
"╠═ gitHubOptions\n" + | ||
"╠═ repoOwner: repoOwner\n" + | ||
"╠═ repoName: repoName\n" + | ||
"╠═ includeEventInformation: true\n" + | ||
"╠═ gitLabOptions\n" + | ||
"╚═ projectId: " | ||
) | ||
) | ||
} | ||
} |
This file contains 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
93 changes: 93 additions & 0 deletions
93
.../plugin/src/main/kotlin/com/emergetools/android/gradle/tasks/internal/LogExtensionTask.kt
This file contains 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,93 @@ | ||
package com.emergetools.android.gradle.tasks.internal | ||
|
||
import com.emergetools.android.gradle.EmergePluginExtension | ||
import com.emergetools.android.gradle.util.orEmpty | ||
import com.emergetools.android.gradle.util.treePrinter | ||
import org.gradle.api.DefaultTask | ||
import org.gradle.api.provider.Property | ||
import org.gradle.api.tasks.Input | ||
import org.gradle.api.tasks.TaskAction | ||
|
||
abstract class LogExtensionTask : DefaultTask() { | ||
|
||
@get:Input | ||
abstract val emergePluginExtension: Property<EmergePluginExtension> | ||
|
||
@TaskAction | ||
fun logExtension() { | ||
val extension = emergePluginExtension.get() | ||
|
||
val extensionTree = treePrinter("Emerge configuration") { | ||
|
||
addItem("apiToken: ${if (extension.apiToken.isPresent) "*****" else "MISSING"}") | ||
addItem("includeDependencyInformation: ${extension.includeDependencyInformation.getOrElse(true)}") | ||
addItem("dryRun (optional): ${extension.dryRun.orEmpty()}") | ||
addItem("verbose (optional): ${extension.verbose.orEmpty()}") | ||
|
||
val sizeHeading = addHeading("size") | ||
addItem("tag (optional): ${extension.sizeOptions.tag.orEmpty()}", sizeHeading) | ||
addItem("enabled: ${extension.sizeOptions.enabled.getOrElse(true)}", sizeHeading) | ||
|
||
val snapshotsHeading = addHeading("snapshots") | ||
addItem( | ||
"snapshotsStorageDirectory: ${extension.snapshotOptions.snapshotsStorageDirectory.orEmpty()}", | ||
snapshotsHeading | ||
) | ||
addItem("apiVersion: ${extension.snapshotOptions.apiVersion.orEmpty()}", snapshotsHeading) | ||
addItem( | ||
"includePrivatePreviews: ${extension.snapshotOptions.includePrivatePreviews.orEmpty()}", | ||
snapshotsHeading | ||
) | ||
addItem( | ||
"includePreviewParamPreviews: ${extension.snapshotOptions.includePreviewParamPreviews.orEmpty()}", | ||
snapshotsHeading | ||
) | ||
addItem("tag (optional): ${extension.snapshotOptions.tag.orEmpty()}", snapshotsHeading) | ||
addItem("enabled: ${extension.snapshotOptions.enabled.getOrElse(true)}", snapshotsHeading) | ||
addItem("profile: ${extension.snapshotOptions.profile.getOrElse(false)}", snapshotsHeading) | ||
|
||
val reaperHeading = addHeading("reaper") | ||
addItem( | ||
"enabledVariants: ${extension.reaperOptions.enabledVariants.getOrElse(emptyList())}", | ||
reaperHeading | ||
) | ||
addItem( | ||
"publishableApiKey: ${if (extension.reaperOptions.publishableApiKey.isPresent) "*****" else "MISSING"}", | ||
reaperHeading | ||
) | ||
addItem("tag (optional): ${extension.reaperOptions.tag.orEmpty()}", reaperHeading) | ||
|
||
val performanceHeading = addHeading("performance") | ||
addItem("projectPath: ${extension.perfOptions.projectPath.orEmpty()}", performanceHeading) | ||
addItem("tag (optional): ${extension.perfOptions.tag.orEmpty()}", performanceHeading) | ||
addItem("enabled: ${extension.perfOptions.enabled.getOrElse(true)}", performanceHeading) | ||
|
||
val vcsOptionsHeading = addHeading("vcsOptions (optional, defaults to Git values)") | ||
addItem("sha: ${extension.vcsOptions.sha.orEmpty()}", vcsOptionsHeading) | ||
addItem("baseSha: ${extension.vcsOptions.baseSha.orEmpty()}", vcsOptionsHeading) | ||
addItem("previousSha: ${extension.vcsOptions.previousSha.orEmpty()}", vcsOptionsHeading) | ||
addItem("branchName: ${extension.vcsOptions.branchName.orEmpty()}", vcsOptionsHeading) | ||
addItem("prNumber: ${extension.vcsOptions.prNumber.orEmpty()}", vcsOptionsHeading) | ||
addItem("gitHubOptions", vcsOptionsHeading) | ||
addItem( | ||
"repoOwner: ${extension.vcsOptions.gitHubOptions.repoOwner.orEmpty()}", | ||
vcsOptionsHeading | ||
) | ||
addItem( | ||
"repoName: ${extension.vcsOptions.gitHubOptions.repoName.orEmpty()}", | ||
vcsOptionsHeading | ||
) | ||
addItem( | ||
"includeEventInformation: ${extension.vcsOptions.gitHubOptions.includeEventInformation.orEmpty()}", | ||
vcsOptionsHeading | ||
) | ||
addItem("gitLabOptions", vcsOptionsHeading) | ||
addItem( | ||
"projectId: ${extension.vcsOptions.gitLabOptions.projectId.orEmpty()}", | ||
vcsOptionsHeading | ||
) | ||
} | ||
|
||
logger.lifecycle(extensionTree) | ||
} | ||
} |
This file contains 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,3 @@ | ||
org.gradle.parallel=true | ||
org.gradle.caching=true | ||
org.gradle.jvmargs=-Duser.language=en -Duser.country=US -Dfile.encoding=UTF-8 |