-
Notifications
You must be signed in to change notification settings - Fork 369
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Include the Scripts into the Gradle Build (#2076)
* Use gradle for the scripts. * Build the scripts as part of the tests
- Loading branch information
1 parent
384b1da
commit 63901b4
Showing
15 changed files
with
103 additions
and
78 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
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
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,2 @@ | ||
#!/bin/bash | ||
./scripts/run.sh new-feature-module "$@" |
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,2 @@ | ||
#!/bin/bash | ||
./scripts/run.sh populate-test-files "$@" |
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,12 @@ | ||
plugins { | ||
alias(libs.plugins.kotlin.jvm) | ||
application | ||
} | ||
|
||
application { | ||
mainClass.set("voice.scripts.ScriptKt") | ||
} | ||
|
||
dependencies { | ||
implementation(libs.clikt) | ||
} |
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,4 @@ | ||
#!/bin/bash | ||
set -e | ||
./gradlew :scripts:installDist --quiet --console=plain | ||
./scripts/build/install/scripts/bin/scripts "$@" |
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
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,12 @@ | ||
package voice.scripts | ||
|
||
fun runCommand(vararg command: String) { | ||
val process = ProcessBuilder(command.toList()) | ||
.redirectOutput(ProcessBuilder.Redirect.INHERIT) | ||
.start() | ||
process.waitFor().also { | ||
check(it == 0) { | ||
"output=${process.errorStream.bufferedReader().readText()}" | ||
} | ||
} | ||
} |
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,18 @@ | ||
package voice.scripts | ||
|
||
import com.github.ajalt.clikt.core.CliktCommand | ||
import com.github.ajalt.clikt.core.subcommands | ||
|
||
class Script : CliktCommand() { | ||
override fun run() {} | ||
} | ||
|
||
fun main(args: Array<String>) { | ||
Script() | ||
.subcommands( | ||
UpdateScreenshots(), | ||
NewFeatureModule(), | ||
PopulateTestFiles(), | ||
) | ||
.main(args) | ||
} |
43 changes: 43 additions & 0 deletions
43
scripts/src/main/kotlin/voice/scripts/UpdateScreenshots.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,43 @@ | ||
package voice.scripts | ||
|
||
import com.github.ajalt.clikt.core.CliktCommand | ||
import java.io.File | ||
|
||
class UpdateScreenshots : CliktCommand() { | ||
|
||
override fun run() { | ||
// https://issuetracker.google.com/issues/193118030 | ||
runCommand("./gradlew", ":app:packageDebugAndroidTest") | ||
runCommand( | ||
"./gradlew", | ||
":app:screenshotDevicesGroupDebugAndroidTest", | ||
"-Pandroid.testInstrumentationRunnerArguments.class=voice.app.misc.ScreenshotCapture", | ||
"-Dorg.gradle.workers.max=1", | ||
) | ||
|
||
mapOf( | ||
"pixel5" to "phone", | ||
"nexus7" to "tablet", | ||
"nexus10" to "large-tablet", | ||
) | ||
.flatMap { (device, qualifier) -> | ||
val deviceOutput = File("app/build/outputs/managed_device_android_test_additional_output", device) | ||
listOf( | ||
"book_overview_grid", | ||
"book_overview_list", | ||
"settings", | ||
"folder_picker", | ||
) | ||
.mapIndexed { index, screenshotName -> | ||
val sourceFile = File(deviceOutput, "$screenshotName.png") | ||
val qualifierFolder = File("app/src/main/play/listings/en-US/graphics", "$qualifier-screenshots") | ||
val targetFile = File(qualifierFolder, "${index + 1}.png") | ||
sourceFile to targetFile | ||
} | ||
} | ||
.forEach { (sourceFile, targetFile) -> | ||
println("copy $sourceFile to $targetFile") | ||
sourceFile.copyTo(targetFile, overwrite = true) | ||
} | ||
} | ||
} |
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 was deleted.
Oops, something went wrong.
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,2 @@ | ||
#!/bin/bash | ||
./scripts/run.sh update-screenshots "$@" |