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: enhancements #15

Merged
merged 2 commits into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
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
31 changes: 20 additions & 11 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ plugins {
kotlin("jvm") version "1.8.21"
`java-library`
`maven-publish`
id("io.gitlab.arturbosch.detekt") version "1.23.0"
id("io.gitlab.arturbosch.detekt") version "1.23.6"
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"))
}
21 changes: 11 additions & 10 deletions detekt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ complexity:
threshold: 600
LongMethod:
active: true
threshold: 60
threshold: 120
LongParameterList:
active: true
functionThreshold: 6
Expand Down Expand Up @@ -167,11 +167,11 @@ complexity:
TooManyFunctions:
active: true
excludes: [ '**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**' ]
thresholdInFiles: 11
thresholdInClasses: 11
thresholdInInterfaces: 11
thresholdInObjects: 30
thresholdInEnums: 11
thresholdInFiles: 50
thresholdInClasses: 50
thresholdInInterfaces: 50
thresholdInObjects: 35
thresholdInEnums: 50
ignoreDeprecated: false
ignorePrivate: false
ignoreOverridden: false
Expand Down Expand Up @@ -215,8 +215,8 @@ empty-blocks:
EmptyForBlock:
active: true
EmptyFunctionBlock:
active: true
ignoreOverridden: false
active: false
ignoreOverridden: true
EmptyIfBlock:
active: true
EmptyInitBlock:
Expand Down Expand Up @@ -260,6 +260,7 @@ exceptions:
ignoredExceptionTypes:
- 'InterruptedException'
- 'MalformedURLException'
- 'JsonSyntaxException'
- 'NumberFormatException'
- 'ParseException'
- 'ConditionTimeoutException'
Expand Down Expand Up @@ -298,7 +299,7 @@ exceptions:
- 'Throwable'
allowedExceptionNameRegex: '_|(ignore|expected).*'
TooGenericExceptionThrown:
active: true
active: false
exceptionNames:
- 'Error'
- 'Exception'
Expand Down Expand Up @@ -633,7 +634,7 @@ style:
maxChainedCalls: 5
MaxLineLength:
active: true
maxLineLength: 120
maxLineLength: 140
excludePackageStatements: true
excludeImportStatements: true
excludeCommentStatements: false
Expand Down
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)
}
}
}
Loading
Loading