Skip to content

Commit

Permalink
ci: Update workflow file (#1639)
Browse files Browse the repository at this point in the history
  • Loading branch information
pawelpasterz authored Mar 2, 2021
1 parent cd5ed96 commit bb1741d
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 32 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/full_suite_integration_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ jobs:
- name: Checkout code
uses: actions/checkout@v2
- name: Download flankScripts and add it to PATH
env:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
./gradlew :flank-scripts:download
Expand All @@ -156,8 +156,8 @@ jobs:
- name: Process IT results
run: |
flankScripts integration_tests process_results \
--result=${{ needs.run-it-full-suite.outputs.job_status }} \
--url=${{ needs.run-it-full-suite.outputs.build-scan-url }} \
--global-result=${{ needs.run-it-full-suite.outputs.job_status }} \
--run-result=${{ env }} \
--github-token=${{ secrets.GITHUB_TOKEN }} \
--run-id=${{ github.run_id }}
Expand Down
3 changes: 1 addition & 2 deletions flank-scripts/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ shadowJar.apply {
}
}
// <breaking change>.<feature added>.<fix/minor change>
version = "1.7.2"
version = "1.7.3"
group = "com.github.flank"

application {
Expand Down Expand Up @@ -161,7 +161,6 @@ val releaseFlankScripts by tasks.registering(Exec::class) {
)
}


fun isVersionChangedInBuildGradle(): Boolean {

val localResultsStream = execAndGetStdout("git", "diff", "origin/master", "HEAD", "--", "build.gradle.kts")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import flank.scripts.ops.integrationtests.common.closeIssue
import flank.scripts.ops.integrationtests.common.createNewIssue
import flank.scripts.ops.integrationtests.common.postComment
import flank.scripts.ops.integrationtests.common.toITRunState
import flank.scripts.utils.toJson
import kotlinx.coroutines.runBlocking

fun processIntegrationTestsResult(
Expand All @@ -21,8 +22,9 @@ fun processIntegrationTestsResult(
runState: String,
runID: String
) {
logArgs(result, runState, runID)
createContext(result, githubToken, runState.toITRunState(), runID).processIntegrationTestsResult()
val state = runState.toITRunState()
logArgs(result, state.toJson(), runID)
createContext(result, githubToken, state, runID).processIntegrationTestsResult()
}

private fun logArgs(
Expand All @@ -31,11 +33,11 @@ private fun logArgs(
runID: String
) = println(
"""
** Parameters:
global Run Result: $result
run State: $url
runID: $runID
""".trimIndent()
|** Parameters:
| global run result: $result
| run state: $url
| runID: $runID
""".trimMargin()
)

private fun createContext(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
package flank.scripts.ops.integrationtests.common

import kotlinx.serialization.KSerializer
import kotlinx.serialization.Serializable
import kotlinx.serialization.descriptors.PrimitiveKind
import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor
import kotlinx.serialization.descriptors.SerialDescriptor
import kotlinx.serialization.encoding.Decoder
import kotlinx.serialization.encoding.Encoder

@Serializable(with = ITResultSerializer::class)
enum class ITResult {
SUCCESS, FAILURE
}

object ITResultSerializer : KSerializer<ITResult> {
override val descriptor: SerialDescriptor = PrimitiveSerialDescriptor("ITResult", PrimitiveKind.STRING)
override fun deserialize(decoder: Decoder) = ITResult.valueOf(decoder.decodeString().toUpperCase())
override fun serialize(encoder: Encoder, value: ITResult) = encoder.encodeString(value.name.toLowerCase())
}
Original file line number Diff line number Diff line change
Expand Up @@ -118,23 +118,14 @@ data class ITRunState(
val windowsResult: ITResult = ITResult.FAILURE,
@SerialName("windows-latest-bs")
val windowsBSUrl: String = "",
@SerialName("macOs-latest")
@SerialName("macos-latest")
val macOsResult: ITResult = ITResult.FAILURE,
@SerialName("macOs-latest-bs")
@SerialName("macos-latest-bs")
val macOsBSUrl: String = "",
@SerialName("ubuntu-latest")
val linuxResult: ITResult = ITResult.FAILURE,
@SerialName("ubuntut-latest-bs")
@SerialName("ubuntu-latest-bs")
val linuxBSUrl: String = ""
)

internal val dummyITRunState = ITRunState(
windowsBSUrl = "",
windowsResult = ITResult.FAILURE,
macOsBSUrl = "",
macOsResult = ITResult.FAILURE,
linuxBSUrl = "",
linuxResult = ITResult.FAILURE,
)

internal fun String.toITRunState() = this.toObject<ITRunState>()
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ private val failureTemplate = { lastRun: String, runId: String, runState: ITRunS
}

private fun ITRunState.failureResult() = """
|**Windows status:** $windowsResult - url:${windowsBSUrl.withDefault()}
|**Linux status:** $linuxResult - url:${linuxBSUrl.withDefault()}
|**MacOs status:** $macOsResult - url:${macOsBSUrl.withDefault()}
|**Windows status:** $windowsResult - url: ${windowsBSUrl.withDefault()}
|**Linux status:** $linuxResult - url: ${linuxBSUrl.withDefault()}
|**MacOs status:** $macOsResult - url: ${macOsBSUrl.withDefault()}
""".trimIndent()

private fun String.withDefault() = if (this.isBlank()) "N/A" else this
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,14 @@ private val issueCreated = """
number: 123
** Comment posted
{
"body": "### Full suite IT run :x: FAILED :x:\n**Timestamp:** 2000-10-10 12:33:17\n**Job run:** [123abc](https://github.com/Flank/flank/actions/runs/123abc)\n**Windows status:** FAILURE - url:N/A\n**Linux status:** FAILURE - url:N/A\n**MacOs status:** FAILURE - url:N/A\n|commit SHA|PR|\n|---|:---:|\n|aaaaaaaaa|[feat: new Feature](www.pull.request)\n"
"body": "### Full suite IT run :x: FAILED :x:\n**Timestamp:** 2000-10-10 12:33:17\n**Job run:** [123abc](https://github.com/Flank/flank/actions/runs/123abc)\n**Windows status:** FAILURE - url: N/A\n**Linux status:** FAILURE - url: N/A\n**MacOs status:** FAILURE - url: N/A\n|commit SHA|PR|\n|---|:---:|\n|aaaaaaaaa|[feat: new Feature](www.pull.request)\n"
}
""".trimIndent()

private val commentPosted = """
** Comment posted
{
"body": "### Full suite IT run :x: FAILED :x:\n**Timestamp:** 2000-10-10 12:33:17\n**Job run:** [123abc](https://github.com/Flank/flank/actions/runs/123abc)\n**Windows status:** FAILURE - url:N/A\n**Linux status:** FAILURE - url:N/A\n**MacOs status:** FAILURE - url:N/A\n|commit SHA|PR|\n|---|:---:|\n|aaaaaaaaa|[feat: new Feature](www.pull.request)\n"
"body": "### Full suite IT run :x: FAILED :x:\n**Timestamp:** 2000-10-10 12:33:17\n**Job run:** [123abc](https://github.com/Flank/flank/actions/runs/123abc)\n**Windows status:** FAILURE - url: N/A\n**Linux status:** FAILURE - url: N/A\n**MacOs status:** FAILURE - url: N/A\n|commit SHA|PR|\n|---|:---:|\n|aaaaaaaaa|[feat: new Feature](www.pull.request)\n"
}
""".trimIndent()

Expand All @@ -108,8 +108,9 @@ private val issueClosed = """

private val missingUrl = """
** Parameters:
global Run Result: FAILURE
run State: {}
global run result: FAILURE
run state: {
}
runID: 123
** Last workflow run:
name: any-name
Expand All @@ -118,6 +119,6 @@ private val missingUrl = """
** Issue found: www.pull.request
** Comment posted
{
"body": "### Full suite IT run :x: FAILED :x:\n**Timestamp:** 2020-12-10 09:51:56\n**Job run:** [123](https://github.com/Flank/flank/actions/runs/123)\n**Windows status:** FAILURE - url:N/A\n**Linux status:** FAILURE - url:N/A\n**MacOs status:** FAILURE - url:N/A\n|commit SHA|PR|\n|---|:---:|\n|aaaaaaaaa|[feat: new Feature](www.pull.request)\n"
"body": "### Full suite IT run :x: FAILED :x:\n**Timestamp:** 2020-12-10 09:51:56\n**Job run:** [123](https://github.com/Flank/flank/actions/runs/123)\n**Windows status:** FAILURE - url: N/A\n**Linux status:** FAILURE - url: N/A\n**MacOs status:** FAILURE - url: N/A\n|commit SHA|PR|\n|---|:---:|\n|aaaaaaaaa|[feat: new Feature](www.pull.request)\n"
}
""".trimIndent()

0 comments on commit bb1741d

Please sign in to comment.