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

feat: Android integration tests run on non wsl windows #1175

Merged
merged 17 commits into from
Oct 5, 2020
Merged
Show file tree
Hide file tree
Changes from 12 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
51 changes: 51 additions & 0 deletions .github/workflows/windows-non-wsl-workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Flank Windows

on:
pull_request_review:
types: submitted

jobs:
build:
# The type of runner that the job will run on
runs-on: windows-2019
steps:

- uses: actions/checkout@v2
with:
submodules: true

- uses: actions/cache@v2
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-2-gradle-${{ hashFiles('**/*.gradle*') }}
restore-keys: |
${{ runner.os }}-2-gradle-

- name: Set GCLOUD_KEY for WINDOWS
shell: cmd
run: |
echo ${{ secrets.GCLOUD_KEY }} > gcloud_key.txt

- name: Gradle clean build
shell: cmd
run: |
gradlew.bat clean build

- name: Prepare Google Service Account
shell: cmd
run: |
set GCLOUD_DIR="%HOMEPATH%/.config/gcloud/"
mkdir %GCLOUD_DIR%
echo certutil -decode gcloud_key.txt %GCLOUD_DIR%application_default_credentials.json

- name: Check pull request is approved
uses: jrylan/github-action-reviews-counter@main
with:
repo-token: '${{ secrets.GITHUB_TOKEN }}'
- name: Gradle Integration Tests Android
if: 'steps.reviews.outputs.approved >= 2 && steps.reviews.outputs.changes_requested == 0 && github.event.pull_request.draft == false'
uses: eskatos/gradle-command-action@v1
env:
GOOGLE_APPLICATION_CREDENTIALS: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}
with:
arguments: "--info :integration_tests:test --tests IntegrationTests.shouldMatchAndroidSuccessExitCodeAndPattern -Dflank-path=../test_runner/build/libs/flank.jar -Dyml-path=./src/test/resources/flank_android.yml"
33 changes: 27 additions & 6 deletions integration_tests/src/test/kotlin/utils/CommandHelper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,32 @@ package utils
import java.io.File
import java.util.concurrent.TimeUnit


fun String.runCommand(workingDir: File): ProcessResult = ProcessBuilder(*split("\\s".toRegex()).toTypedArray())
.directory(workingDir)
.redirectOutput(ProcessBuilder.Redirect.PIPE)
.redirectError(ProcessBuilder.Redirect.PIPE)
.start().run {
waitFor(60, TimeUnit.MINUTES)
ProcessResult(exitValue(), inputStream.bufferedReader().readText() + this.errorStream.bufferedReader().readText())
.directory(workingDir).redirectOutputForCompatibleOS().startProcess()


private fun ProcessBuilder.startProcess() = start().run {
waitFor(processTimeout, TimeUnit.MINUTES)
ProcessResult(exitValue(), getOsSpecificOutput())
}

private fun Process.getOsSpecificOutput(): String {
return if (isWindows) {
File(outputFileName).readText() + File(errorFileName).readText()
} else {
inputStream.bufferedReader().readText() + this.errorStream.bufferedReader().readText()
}
}

private fun ProcessBuilder.redirectOutputForCompatibleOS() = if (isWindows) {
redirectOutput(File(outputFileName)).redirectError(File(errorFileName))
} else {
redirectOutput(ProcessBuilder.Redirect.PIPE).redirectError(ProcessBuilder.Redirect.PIPE)
}
Sloox marked this conversation as resolved.
Show resolved Hide resolved

private val isWindows = System.getProperty("os.name").startsWith("Windows")

private const val outputFileName = "out.log"
private const val errorFileName = "error.log"
private const val processTimeout = 60L
7 changes: 7 additions & 0 deletions test_runner/bash/update_flank.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

for %%F in (%filename%) do set dirname=%%~dpF
echo "%dirname%"
cd ..
cd ..
call gradlew.bat clean assemble shadowjar
cd test_runner\bash
34 changes: 22 additions & 12 deletions test_runner/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,10 @@ jacoco {
}

tasks.jacocoTestReport {
classDirectories.setFrom(
fileTree("build/classes/kotlin/main").apply {
exclude("**/*\$run$1.class")
exclude("**/ftl/mock/*")
})
classDirectories.setFrom(fileTree("build/classes/kotlin/main").apply {
exclude("**/*\$run$1.class")
exclude("**/ftl/mock/*")
})

reports {
xml.isEnabled = true
Expand Down Expand Up @@ -274,7 +273,18 @@ tasks["check"].dependsOn(tasks["jacocoTestReport"], tasks["detekt"])
val updateFlank by tasks.registering(Exec::class) {
group = "Build"
description = "Update flank jar"
commandLine = listOf("./bash/update_flank.sh")
commandLine = if (System.getProperty("os.name").toLowerCase().contains("windows")) {
doLast {
copy {//due to security permissions copying files is restricted via bat files
from("./test_runner/build/libs/flank.jar")
into("./test_runner/bash/")
}
}
listOf("./bash/update_flank.bat")
} else {
listOf("./bash/update_flank.sh")
}

}

val flankFullRun by tasks.registering(Exec::class) {
Expand Down Expand Up @@ -307,17 +317,17 @@ tasks.create("applyProguard", proguard.gradle.ProGuardTask::class.java) {
val generateCliAsciiDoc by tasks.registering(JavaExec::class) {
dependsOn(tasks.classes)
classpath(
configurations.compile,
configurations.annotationProcessor,
sourceSets["main"].runtimeClasspath
configurations.compile,
configurations.annotationProcessor,
sourceSets["main"].runtimeClasspath
)
group = "Documentation"
description = "Generate AsciiDoc manpage"
main = "picocli.codegen.docgen.manpage.ManPageGenerator"
args = listOf(
application.mainClass.get(),
"--outdir=${project.rootDir}/docs/ascii/",
"-v"
application.mainClass.get(),
"--outdir=${project.rootDir}/docs/ascii/",
"-v"
)
}

Expand Down