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
Initial implementation of job summary #16
Conversation
|
||
private fun writeSuccessfulUpdates(updates: List<BuildpackUpdate>) { | ||
file.appendText("\n## success\n\n") | ||
updates.forEach { file.appendText("* currentBuildpack ${it.currentBuildpack} ${if (it.hasUpdate()) "has an update to " + it.latestUpdate else "has no update"}\n") } |
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.
What is this monstrosity of a line? 🙈
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.
I'd be tempted to move the if
to a chained appendText
, e.g.
updates.forEach {
file.appendText("* currentBuildpack ${it.currentBuildpack} ")
file.appendText(if (it.hasUpdate())"has an update to " + it.latestUpdate else "has no update")
file.appendText("\n")
}
} | ||
|
||
private fun writeSuccessfulUpdates(updates: List<BuildpackUpdate>) { | ||
file.appendText("\n## success\n\n") |
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.
Might need to be conditionally written, only when updates.length > 0? Otherwise you have a heading without content
} | ||
|
||
private fun writeFailures(errors: Map<BuildpackUpdate, Exception>) { | ||
file.appendText("\n## failures\n" + |
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.
Might need to be conditionally written, only when updates.length > 0? Otherwise you have a heading without content?
Also: newline-ception
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.
Looks good, have some tweaks 😁
class SummaryWriter(val file: File) { | ||
|
||
constructor(filename: String?) : this( | ||
if (filename == null || filename.isBlank()) { |
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.
|
||
private fun writeSuccessfulUpdates(updates: List<BuildpackUpdate>) { | ||
file.appendText("\n## success\n\n") | ||
updates.forEach { file.appendText("* currentBuildpack ${it.currentBuildpack} ${if (it.hasUpdate()) "has an update to " + it.latestUpdate else "has no update"}\n") } |
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.
I'd be tempted to move the if
to a chained appendText
, e.g.
updates.forEach {
file.appendText("* currentBuildpack ${it.currentBuildpack} ")
file.appendText(if (it.hasUpdate())"has an update to " + it.latestUpdate else "has no update")
file.appendText("\n")
}
|
||
SummaryWriter(tempFile).write(successfulChecksResults) | ||
|
||
tempFile.readText() shouldBeEqualTo "# CF buildpack update action results\n" + "\n" + "## success\n" + "\n" + "* currentBuildpack VersionedBuildpack(name=test/buildpack1, url=https://a.host/path, version=1.3, tag=GitTag(value=v1.3)) has no update\n" + "\n" + "Thanks for watching!\n" |
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.
You can template the string
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.
You mean raw strings? 🤔
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.
That works better tbh, much more readable
Looks like this if enabled: https://github.com/springernature/buildpack-update-action-test/actions/runs/2422936842#summary-6693494492 |
Inspired by …
… initial implementation, just to see that it's working. The report itself is still very basic.
As always: please feel free to criticise everything: style, shape, colour, etc 😄
Thanks!