Skip to content

Commit

Permalink
test: coveralls + megalinter (#133)
Browse files Browse the repository at this point in the history
  • Loading branch information
amagyar-iohk authored Mar 5, 2024
1 parent 6d34193 commit 044121a
Show file tree
Hide file tree
Showing 11 changed files with 98 additions and 94 deletions.
1 change: 1 addition & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
root = true

[*.{kt,kts}]
ktlint_code_style = intellij_idea
ktlint_standard_no_semi = disabled
ktlint_standard_trailing-comma-on-call-site = disabled
ktlint_standard_trailing-comma-on-declaration-site = disabled
19 changes: 19 additions & 0 deletions .gherkin-lintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"indentation" : [
"on", {
"Feature": 0,
"Background": 2,
"Scenario": 2,
"Step": 4,
"Examples": 4,
"example": 6,
"given": 4,
"when": 4,
"then": 4,
"and": 4,
"but": 4,
"feature tag": 0,
"scenario tag": 2
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,24 +42,13 @@ jobs:
run: echo ${{ runner.os }}

- name: Build for JS, Android, JVM
run: |
./gradlew build test koverXmlReport koverHtmlReport --stacktrace
run: ./gradlew build allTests koverXmlReportRelease koverHtmlReportRelease --stacktrace

- name: Coverage Report
uses: mi-kas/kover-report@v1
- name: Coveralls
uses: coverallsapp/github-action@v2
with:
path: ${{ github.workspace }}/atala-prism-sdk/build/reports/kover/report.xml
token: ${{ env.ATALA_GITHUB_TOKEN }}
title: Code Coverage
update-comment: true

# - name: Publish test results
# if: always()
# uses: EnricoMi/publish-unit-test-result-action@v2
# with:
# files: "${{ github.workspace }}/atala-prism-sdk/build/test-results/testReleaseUnitTest/TEST-*.xml"
# comment_title: "Unit Test Results"
# check_name: "Unit Test Results"
file: "${{ github.workspace }}/atala-prism-sdk/build/reports/android/result.xml"
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: Publish test results
if: always()
Expand All @@ -70,13 +59,11 @@ jobs:
check_name: "Unit Test Results"

- name: Upload Tests Reports
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
if: always()
with:
name: kover-html
name: coverage-results
path: |
atala-prism-sdk/build/kover/atala-prism-sdk/xml
atala-prism-sdk/build/reports/tests/**/*.html
atala-prism-sdk/build/reports/tests/jvmTest/index.html
atala-prism-sdk/build/reports/jvm
atala-prism-sdk/build/reports/android
if-no-files-found: error
5 changes: 3 additions & 2 deletions .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,11 @@ jobs:
- name: Add notes to summary
if: always()
working-directory: tests/end-to-end
run: cat notes >> $GITHUB_STEP_SUMMARY
run: cat notes >> "$GITHUB_STEP_SUMMARY"

- name: Publish Serenity report
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
if: always()
with:
name: atala-prism-sdk-kmm
path: tests/end-to-end/target/site/serenity
Expand Down
34 changes: 9 additions & 25 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,39 +1,23 @@
---
name: Linter

# Default shell is `sh`
# which is old, use bourne-again version instead
defaults:
run:
shell: bash
name: MegaLinter

on:
pull_request:

jobs:
lint:
name: Lint changes
name: Lint project
runs-on: ubuntu-latest
env:
APPLY_FIXES: none
DISABLE: COPYPASTE,SPELL
GITHUB_TOKEN: ${{ secrets.ATALA_GITHUB_TOKEN }}
DISABLE_LINTERS: REPOSITORY_GITLEAKS
DISABLE_ERRORS_LINTERS: PROTOBUF_PROTOLINT
steps:
- name: Checkout Code
uses: actions/checkout@v3
with:
token: ${{ secrets.ATALA_GITHUB_TOKEN }}
fetch-depth: 0
# - name: Mega-Linter
# id: ml
# uses: megalinter/megalinter@v6
uses: actions/checkout@v4

- name: Mega-Linter
uses: oxsecurity/megalinter@v7

- name: Archive production artifacts
if: success() || failure()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: Mega-Linter reports
path: |
megalinter-reports
mega-linter.log
path: megalinter-reports
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ Pods/
*yarn.lock
dependinces.log
node_modules
megalinter-reports
22 changes: 9 additions & 13 deletions .mega-linter.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
APPLY_FIXES: none
FILTER_REGEX_EXCLUDE: (karma.config.js|polyfill.js|timeout.js|CHANGELOG.md)
VALIDATE_ALL_CODEBASE: true
REPOSITORY_DEVSKIM_DISABLE_ERRORS: true
REPOSITORY_CHECKOV_DISABLE_ERRORS: true
FILTER_REGEX_INCLUDE: (.editorconfig|.github/|atala-prism-sdk/src/|sampleapp/src/|protosLib/src/)
FILTER_REGEX_EXCLUDE: (tests/)
VALIDATE_ALL_CODEBASE: false

DISABLE_LINTERS:
- MARKDOWN_MARKDOWN_LINK_CHECK
- C_CPPLINT
- CPP_CPPLINT
- BASH_SHELLCHECK
- BASH_EXEC
- REPOSITORY_CHECKOV
ENABLE_LINTERS:
- KOTLIN_KTLINT
- GHERKIN_GHERKIN_LINT
- ACTION_ACTIONLINT
- MARKDOWN_MARKDOWN_TABLE_FORMATTER
- MARKDOWN_MARKDOWNLINT

DISABLE_ERRORS_LINTERS:
- REPOSITORY_CHECKOV
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

![badge-platform-android]
![badge-platform-jvm]
[![Coverage Status](https://coveralls.io/repos/github/input-output-hk/atala-prism-wallet-sdk-kmm/badge.svg?branch=main)](https://coveralls.io/github/input-output-hk/atala-prism-wallet-sdk-kmm?branch=main)

![Atala Prism Logo](Logo.png)

Expand Down
46 changes: 32 additions & 14 deletions atala-prism-sdk/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,42 @@ plugins {
id("org.jetbrains.kotlinx.kover") version "0.7.3"
}

kover {
useJacoco("0.8.11")
excludeJavaCode()
excludeInstrumentation {
packages("androidx.test.espresso", "androidx.test.ext")
}
}

koverReport {
filters {
excludes {
packages(
"io.iohk.atala.prism.protos",
"io.iohk.atala.prism.walletsdk.domain",
"io.iohk.atala.prism.walletsdk.pluto.data"
)
}
}

defaults {
// adds the contents of the reports of `release` Android build variant to default reports
mergeWith("release")
xml {
setReportFile(layout.buildDirectory.file("reports/jvm/result.xml"))
}
html {
title = "$currentModuleName - Test Coverage"
setReportDir(layout.buildDirectory.dir("kover/atala-prism-sdk/xml"))
title = "Wallet SDK - JVM"
setReportDir(layout.buildDirectory.dir("reports/jvm/html"))
}
xml {}
filters {
excludes {
packages(
"io.iohk.atala.prism.protos",
"io.iohk.atala.prism.walletsdk.domain",
"ioiohkatalaprismwalletsdkpluto.data"
)
}
}

androidReports("release") {
xml {
setReportFile(layout.buildDirectory.file("reports/android/result.xml"))
}
html {
title = "Wallet SDK - Android"
setReportDir(layout.buildDirectory.dir("reports/android/html"))
}
}
}
Expand Down Expand Up @@ -134,7 +153,6 @@ kotlin {
}
}
val androidInstrumentedTest by getting {
dependsOn(commonTest)
dependencies {
implementation("androidx.test.espresso:espresso-core:3.5.1")
implementation("androidx.test.ext:junit:1.1.5")
Expand Down
9 changes: 7 additions & 2 deletions tests/end-to-end/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
kotlin("jvm") version "1.8.21"
kotlin("jvm") version "1.9.21"
idea
java
id("com.github.ben-manes.versions") version "0.47.0"
Expand Down Expand Up @@ -31,10 +31,15 @@ repositories {
dependencies {
testImplementation("io.iohk.atala.prism.walletsdk:atala-prism-sdk:2.6.0")
testImplementation("io.iohk.atala.prism:prism-kotlin-client:1.28.0")
testImplementation("io.iohk.atala:atala-automation:0.3.0")
testImplementation("io.iohk.atala:atala-automation:0.3.2")
}

tasks.register<Delete>("cleanTarget") {
delete("target")
}

tasks.test {
dependsOn("cleanTarget")
testLogging.showStandardStreams = true
systemProperty("cucumber.filter.tags", System.getProperty("cucumber.filter.tags"))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import net.serenitybdd.rest.SerenityRest.lastResponse
import net.serenitybdd.screenplay.Actor
import net.serenitybdd.screenplay.rest.interactions.Post
import org.apache.http.HttpStatus
import java.util.*
import java.util.UUID

class CloudAgentWorkflow {
fun createConnection(cloudAgent: Actor, label: String?, goalCode: String?, goal: String?) {
Expand All @@ -31,18 +31,6 @@ class CloudAgentWorkflow {
cloudAgent.remember("connectionId", lastResponse().get<String>("connectionId"))
}

fun createConnectionWithoutOptionalArguments(cloudAgent: Actor) {
val createConnection = CreateConnectionRequest()

cloudAgent.attemptsTo(
Post.to("/connections").body(createConnection),
Ensure.thatTheLastResponse().statusCode().isEqualTo(HttpStatus.SC_CREATED)
)

cloudAgent.remember("invitation", lastResponse().get<String>("invitation.invitationUrl"))
cloudAgent.remember("connectionId", lastResponse().get<String>("connectionId"))
}

fun shareInvitation(cloudAgent: Actor, edgeAgent: Actor) {
val invitation = cloudAgent.recall<String>("invitation")
edgeAgent.remember("invitation", invitation)
Expand All @@ -67,7 +55,8 @@ class CloudAgentWorkflow {
schemaId = "${Environment.agentUrl}/schema-registry/schemas/${Environment.jwtSchemaGuid}"
)
cloudAgent.attemptsTo(
Post.to("/issue-credentials/credential-offers").body(credential)
Post.to("/issue-credentials/credential-offers").body(credential),
Ensure.thatTheLastResponse().statusCode().isEqualTo(HttpStatus.SC_CREATED)
)
cloudAgent.remember("recordId", lastResponse().get<String>("recordId"))
}
Expand All @@ -83,7 +72,8 @@ class CloudAgentWorkflow {
credentialDefinitionId = UUID.fromString(Environment.anoncredDefinitionId)
)
cloudAgent.attemptsTo(
Post.to("/issue-credentials/credential-offers").body(credential)
Post.to("/issue-credentials/credential-offers").body(credential),
Ensure.thatTheLastResponse().statusCode().isEqualTo(HttpStatus.SC_CREATED)
)
cloudAgent.remember("recordId", lastResponse().get<String>("recordId"))
}
Expand All @@ -107,7 +97,8 @@ class CloudAgentWorkflow {
)

cloudAgent.attemptsTo(
Post.to("/present-proof/presentations").body(presentProofRequest)
Post.to("/present-proof/presentations").body(presentProofRequest),
Ensure.thatTheLastResponse().statusCode().isEqualTo(HttpStatus.SC_CREATED)
)
cloudAgent.remember("presentationId", lastResponse().get<String>("presentationId"))
}
Expand Down

0 comments on commit 044121a

Please sign in to comment.