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

Print version and revision before each command #757

Merged
merged 6 commits into from
May 2, 2020
Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions release_notes.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
## next (unreleased)
- [#757](https://github.com/Flank/flank/pull/757) Print version and revision before each command. ([jan-gogo](https://github.com/jan-gogo))
- [#731](https://github.com/Flank/flank/pull/731) Refactor jUnit HTML report. ([Writhe](https://github.com/Writhe))
- [#754](https://github.com/Flank/flank/pull/754) Sync README.md flank.yml flank.ios.yml. ([jan-gogo](https://github.com/jan-gogo))
- [#746](https://github.com/Flank/flank/pull/746) Ignore apk with filtered out tests instead of failing. ([pawelpasterz](https://github.com/pawelpasterz))
Expand Down
14 changes: 14 additions & 0 deletions test_runner/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -258,3 +258,17 @@ tasks.assemble {
dependsOn(generateManpageAsciiDoc)
}
// end --- ASCII doc generation ---

val updateVersion by tasks.registering {
shouldRunAfter(tasks.processResources)
doLast {
File("${project.buildDir}/resources/main/version.txt").writeText("local_snapshot")
File("${project.buildDir}/resources/main/revision.txt").writeText(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The bitrise job does this:

echo "$BITRISE_GIT_TAG" > ./test_runner/src/main/resources/version.txt
echo "$GIT_CLONE_COMMIT_HASH" > ./test_runner/src/main/resources/revision.txt

and then the gradle commands are run. I think this may break the bitrise release job.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for info. So I will use BITRISE_IO env for turning off this task when running on bitrise.

String(Runtime.getRuntime().exec("git rev-parse HEAD").inputStream.readBytes())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we exec on a background thread? here's an example:
https://github.com/bootstraponline/gradle_enterprise_example/blob/master/app/enterprise.gradle.kts#L152

also probably better to use exec { ... } instead of Runtime directly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Running on background from your example requires GradleEnterprisePlugin, TBH I have no experience with build scan. Any way, adding GradleEnterprisePlugin looks like standalone tasks, not a part of another. Also Updating those two files is pretty fast so it don't much impact on build time.

Ok, I will use exec { ... }.

)
}
}

tasks.classes {
dependsOn(updateVersion)
}
15 changes: 8 additions & 7 deletions test_runner/src/main/kotlin/ftl/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,8 @@ import picocli.CommandLine
)
class Main : Runnable {
override fun run() {
if (printVersion) {
println(readVersion())
println(readRevision())
} else {
CommandLine.usage(Main::class.java, System.out)
}
if (printVersion) return
CommandLine.usage(Main::class.java, System.out)
}

@CommandLine.Option(names = ["-v", "--version"], description = ["Prints the version"])
Expand All @@ -50,7 +46,12 @@ class Main : Runnable {
// BugSnag opens a non-daemon thread which will keep the JVM process alive.
// Flank must invoke exitProcess to exit cleanly.
// https://github.com/bugsnag/bugsnag-java/issues/151
withGlobalExceptionHandling { CommandLine(Main()).execute(*args) }
withGlobalExceptionHandling {
println("version: " + readVersion())
println("revision: " + readRevision())
println()
CommandLine(Main()).execute(*args)
}
}
}
}