Skip to content

Commit

Permalink
feat: enhancements
Browse files Browse the repository at this point in the history
Signed-off-by: Allain Magyar <allain.magyar@iohk.io>
  • Loading branch information
amagyar-iohk committed Jun 24, 2024
1 parent c4484a7 commit 0b39188
Show file tree
Hide file tree
Showing 25 changed files with 1,107 additions and 93 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,23 @@ jobs:
run: |
npm install
npx semantic-release
- name: Dokka
run: ./gradlew dokkaHtml

- name: Upload GitHub Pages artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./docs

release-page:
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
needs: release-atala-automation

steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
29 changes: 19 additions & 10 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ plugins {
`maven-publish`
id("io.gitlab.arturbosch.detekt") version "1.23.0"
id("io.github.gradle-nexus.publish-plugin") version "2.0.0-rc-1"
id("org.jetbrains.dokka") version "1.9.20"
signing
}

Expand All @@ -16,26 +17,28 @@ repositories {
}

dependencies {
val serenityVersion = "4.1.20"

api("javax.inject:javax.inject:1")
api("junit:junit:4.13.2")

api("net.serenity-bdd:serenity-core:4.0.0")
api("net.serenity-bdd:serenity-ensure:4.0.0")
api("net.serenity-bdd:serenity-cucumber:4.0.0")
api("net.serenity-bdd:serenity-screenplay:4.0.0")
api("net.serenity-bdd:serenity-screenplay-rest:4.0.0")
api("net.serenity-bdd:serenity-core:$serenityVersion")
api("net.serenity-bdd:serenity-ensure:$serenityVersion")
api("net.serenity-bdd:serenity-cucumber:$serenityVersion")
api("net.serenity-bdd:serenity-screenplay:$serenityVersion")
api("net.serenity-bdd:serenity-screenplay-rest:$serenityVersion")

api("ch.qos.logback:logback-classic:1.4.8")
api("ch.qos.logback:logback-classic:1.5.6")
api("org.slf4j:slf4j-api:2.0.7")

api("io.ktor:ktor-client-core-jvm:2.3.1")
api("com.jayway.jsonpath:json-path:2.8.0")
api("com.jayway.jsonpath:json-path:2.9.0")
api("org.awaitility:awaitility:4.2.0")

api("org.jetbrains.kotlin:kotlin-reflect:1.8.22")
api("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.1")

testImplementation("com.github.tomakehurst:wiremock-jre8-standalone:2.35.0")
testImplementation("org.wiremock:wiremock-standalone:3.7.0")
}

kotlin {
Expand Down Expand Up @@ -108,6 +111,12 @@ nexusPublishing {
signing {
val base64EncodedAsciiArmoredSigningKey: String = System.getenv("BASE64_ARMORED_GPG_SIGNING_KEY_MAVEN") ?: ""
val signingKeyPassword: String = System.getenv("SIGNING_KEY_PASSWORD") ?: ""
useInMemoryPgpKeys(String(Base64.getDecoder().decode(base64EncodedAsciiArmoredSigningKey.toByteArray())), signingKeyPassword)
sign(publishing.publications)
if (base64EncodedAsciiArmoredSigningKey.isNotEmpty() && signingKeyPassword.isNotEmpty()) {
useInMemoryPgpKeys(String(Base64.getDecoder().decode(base64EncodedAsciiArmoredSigningKey.toByteArray())), signingKeyPassword)
sign(publishing.publications)
}
}

tasks.dokkaHtml.configure {
outputDirectory.set(projectDir.resolve("docs"))
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package io.iohk.atala.automation.cucumber.common

class AnsiEscapes private constructor(private val value: String) {
override fun toString(): String {
val sb = java.lang.StringBuilder()
appendTo(sb)
return sb.toString()
}

fun appendTo(a: java.lang.StringBuilder) {
a.append(ESC).append(BRACKET).append(
value
)
}

companion object {
val RESET = color(0)
val BLACK = color(30)
val BRIGHT_BLACK = color(90)

val RED = color(31)
val BRIGHT_RED = color(91)

val GREEN = color(32)
val BRIGHT_GREEN = color(92)

val YELLOW = color(33)
val BLUE = color(34)
val MAGENTA = color(35)
val CYAN = color(36)
val WHITE = color(37)
val DEFAULT = color(9)
val GREY = color(90)

val INTENSITY_BOLD = color(1)
val UNDERLINE = color(4)
private const val ESC = 27.toChar()
private const val BRACKET = '['
private fun color(code: Int): AnsiEscapes {
return AnsiEscapes(code.toString() + "m")
}

fun up(count: Int): AnsiEscapes {
return AnsiEscapes(count.toString() + "A")
}
}
}
36 changes: 36 additions & 0 deletions src/main/kotlin/io/iohk/atala/automation/cucumber/common/Format.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package io.iohk.atala.automation.cucumber.common

interface Format {
fun text(text: String): String

class Color internal constructor(private vararg val escapes: AnsiEscapes) : Format {

override fun text(text: String): String {
val sb = java.lang.StringBuilder()
for (escape in escapes) {
escape.appendTo(sb)
}
sb.append(text)
if (escapes.isNotEmpty()) {
AnsiEscapes.RESET.appendTo(sb)
}
return sb.toString()
}
}

class Monochrome internal constructor() : Format {
override fun text(text: String): String {
return text
}
}

companion object {
fun color(vararg escapes: AnsiEscapes): Format {
return Color(*escapes)
}

fun monochrome(): Format {
return Monochrome()
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package io.iohk.atala.automation.cucumber.common


interface Formats {
operator fun get(key: String): Format
fun up(n: Int): String

companion object {
@JvmStatic
fun monochrome(): Formats {
return Monochrome()
}

@JvmStatic
fun ansi(): Formats {
return Ansi()
}
}

class Monochrome internal constructor() : Formats {
override fun get(key: String): Format {
return Format.monochrome()
}

override fun up(n: Int): String {
return ""
}
}

class Ansi internal constructor() : Formats {
override fun get(key: String): Format {
val format: Format = formats[key] ?: throw NullPointerException("No format for key $key")
return format
}

override fun up(n: Int): String {
return AnsiEscapes.up(n).toString()
}

companion object {
private val formats: Map<String, Format> = object : java.util.HashMap<String, Format>() {
init {
// Never used, but avoids NPE in formatters.
put("undefined", Format.color(AnsiEscapes.YELLOW))
put("undefined_arg", Format.color(AnsiEscapes.YELLOW, AnsiEscapes.INTENSITY_BOLD))
put("unused", Format.color(AnsiEscapes.YELLOW))
put("unused_arg", Format.color(AnsiEscapes.YELLOW, AnsiEscapes.INTENSITY_BOLD))
put("pending", Format.color(AnsiEscapes.YELLOW))
put("pending_arg", Format.color(AnsiEscapes.YELLOW, AnsiEscapes.INTENSITY_BOLD))
put("executing", Format.color(AnsiEscapes.GREY))
put("executing_arg", Format.color(AnsiEscapes.GREY, AnsiEscapes.INTENSITY_BOLD))
put("failed", Format.color(AnsiEscapes.RED))
put("failed_arg", Format.color(AnsiEscapes.RED, AnsiEscapes.INTENSITY_BOLD))
put("ambiguous", Format.color(AnsiEscapes.RED))
put("ambiguous_arg", Format.color(AnsiEscapes.RED, AnsiEscapes.INTENSITY_BOLD))
put("passed", Format.color(AnsiEscapes.GREEN))
put("passed_arg", Format.color(AnsiEscapes.BRIGHT_GREEN, AnsiEscapes.INTENSITY_BOLD))
put("outline", Format.color(AnsiEscapes.CYAN))
put("outline_arg", Format.color(AnsiEscapes.CYAN, AnsiEscapes.INTENSITY_BOLD))
put("skipped", Format.color(AnsiEscapes.CYAN))
put("skipped_arg", Format.color(AnsiEscapes.CYAN, AnsiEscapes.INTENSITY_BOLD))
put("comment", Format.color(AnsiEscapes.GREY))
put("tag", Format.color(AnsiEscapes.CYAN))
put("output", Format.color(AnsiEscapes.BLUE))
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package io.iohk.atala.automation.cucumber.common

import java.io.OutputStream
import java.io.OutputStreamWriter
import java.nio.charset.StandardCharsets

class UTF8OutputStreamWriter(out: OutputStream) : OutputStreamWriter(out, StandardCharsets.UTF_8)
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package io.iohk.atala.automation.cucumber.common

import java.io.Closeable
import java.io.Flushable
import java.io.IOException
import java.io.OutputStream
import java.io.OutputStreamWriter

/**
* A "good enough" PrintWriter implementation that writes UTF-8 and rethrows all
* exceptions as runtime exceptions.
*/
class UTF8PrintWriter(out: OutputStream) : Appendable, Closeable, Flushable {
private val out: OutputStreamWriter = UTF8OutputStreamWriter(out)

fun println() {
try {
out.write(System.lineSeparator())
} catch (e: IOException) {
throw RuntimeException(e)
}
}

fun println(s: String) {
try {
out.write(s)
out.write(System.lineSeparator())
} catch (e: IOException) {
throw RuntimeException(e)
}
}

override fun flush() {
try {
out.flush()
} catch (e: IOException) {
throw RuntimeException(e)
}
}

override fun close() {
try {
out.close()
} catch (e: IOException) {
throw RuntimeException(e)
}
}

override fun append(csq: CharSequence): Appendable {
try {
return out.append(csq)
} catch (e: IOException) {
throw RuntimeException(e)
}
}

override fun append(csq: CharSequence, start: Int, end: Int): Appendable {
try {
return out.append(csq, start, end)
} catch (e: IOException) {
throw RuntimeException(e)
}
}

override fun append(c: Char): Appendable {
try {
return out.append(c)
} catch (e: IOException) {
throw RuntimeException(e)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package io.iohk.atala.automation.cucumber.plugins

import net.thucydides.model.domain.Story
import net.thucydides.model.domain.TestOutcome
import net.thucydides.model.domain.TestResult
import net.thucydides.model.screenshots.ScreenshotAndHtmlSource
import net.thucydides.model.steps.ExecutedStepDescription
import net.thucydides.model.steps.StepFailure
import net.thucydides.model.steps.StepListener
import java.time.ZonedDateTime

class SerenityStepListener: StepListener {
data class Entry(
val keyword: String,
val stepText: String,
val arguments: List<String>,
val isSubStep: Boolean
)
companion object {
val stepList = mutableListOf<Entry>()
}

override fun stepStarted(description: ExecutedStepDescription, startTime: ZonedDateTime) {
val split = description.title.split(" ")
val keyword = split[0] + " "
val stepText = split.subList(1, split.size).joinToString(" ")
val isSubStep = description.stepClass != null
val arguments = description.arguments
stepList.add(Entry(keyword, stepText, arguments, isSubStep))
}

override fun testSuiteStarted(storyClass: Class<*>?) {}
override fun testSuiteStarted(story: Story) {}
override fun testSuiteFinished() {}
override fun testStarted(description: String) {}
override fun testStarted(description: String, id: String) {}
override fun testStarted(description: String, id: String, startTime: ZonedDateTime) {}
override fun testFinished(result: TestOutcome) {}
override fun testFinished(result: TestOutcome, isInDataDrivenTest: Boolean, finishTime: ZonedDateTime) {}
override fun testRetried() {}
override fun stepStarted(description: ExecutedStepDescription) {}
override fun skippedStepStarted(description: ExecutedStepDescription) {}
override fun stepFailed(failure: StepFailure) {}
override fun stepFailed(failure: StepFailure?, screenshotList: MutableList<ScreenshotAndHtmlSource>?, isInDataDrivenTest: Boolean) {}
override fun stepFailed(failure: StepFailure?, screenshotList: MutableList<ScreenshotAndHtmlSource>?, isInDataDrivenTest: Boolean, zonedDateTime: ZonedDateTime?) {}

override fun lastStepFailed(failure: StepFailure) {}
override fun stepIgnored() {}
override fun stepPending() {}
override fun stepPending(message: String) {}
override fun stepFinished() {}
override fun stepFinished(screenshotList: List<ScreenshotAndHtmlSource>, time: ZonedDateTime) {}
override fun testFailed(testOutcome: TestOutcome, cause: Throwable) {}
override fun testIgnored() {}
override fun testSkipped() {}
override fun testPending() {}
override fun testIsManual() {}
override fun notifyScreenChange() {}
override fun useExamplesFrom(table: net.thucydides.model.domain.DataTable?) {}
override fun addNewExamplesFrom(table: net.thucydides.model.domain.DataTable?) {}
override fun exampleStarted(data: Map<String, String>) {}
override fun exampleFinished() {}
override fun assumptionViolated(message: String) {}
override fun testRunFinished() {}
override fun takeScreenshots(screenshots: List<ScreenshotAndHtmlSource>) {}
override fun takeScreenshots(testResult: TestResult, screenshots: List<ScreenshotAndHtmlSource>) {}
}

Loading

0 comments on commit 0b39188

Please sign in to comment.