diff --git a/.editorconfig b/.editorconfig index 0f64ec15d..3e22a6088 100644 --- a/.editorconfig +++ b/.editorconfig @@ -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 diff --git a/.gherkin-lintrc b/.gherkin-lintrc new file mode 100644 index 000000000..373f8d209 --- /dev/null +++ b/.gherkin-lintrc @@ -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 + } + ] +} diff --git a/.github/workflows/pull-request.yml b/.github/workflows/build-and-test.yml similarity index 58% rename from .github/workflows/pull-request.yml rename to .github/workflows/build-and-test.yml index 59f20b532..7d2097eb1 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/build-and-test.yml @@ -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() @@ -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 diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index bc37bfeea..c697cfa37 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -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 diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 651c37d65..99b551dd8 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -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 diff --git a/.gitignore b/.gitignore index 55f56ab9d..195cb999e 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,4 @@ Pods/ *yarn.lock dependinces.log node_modules +megalinter-reports diff --git a/.mega-linter.yml b/.mega-linter.yml index 32527b968..3f1b295c9 100644 --- a/.mega-linter.yml +++ b/.mega-linter.yml @@ -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 diff --git a/README.md b/README.md index b6a7a6cb8..d45bd3aad 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/atala-prism-sdk/build.gradle.kts b/atala-prism-sdk/build.gradle.kts index 98eea996e..c032a2ccd 100644 --- a/atala-prism-sdk/build.gradle.kts +++ b/atala-prism-sdk/build.gradle.kts @@ -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")) } } } @@ -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") diff --git a/tests/end-to-end/build.gradle.kts b/tests/end-to-end/build.gradle.kts index ce7a7f516..3ad69f5cf 100644 --- a/tests/end-to-end/build.gradle.kts +++ b/tests/end-to-end/build.gradle.kts @@ -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" @@ -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("cleanTarget") { + delete("target") } tasks.test { + dependsOn("cleanTarget") testLogging.showStandardStreams = true systemProperty("cucumber.filter.tags", System.getProperty("cucumber.filter.tags")) } diff --git a/tests/end-to-end/src/test/kotlin/io/iohk/atala/prism/workflow/CloudAgentWorkflow.kt b/tests/end-to-end/src/test/kotlin/io/iohk/atala/prism/workflow/CloudAgentWorkflow.kt index aead98490..71a2ddae3 100644 --- a/tests/end-to-end/src/test/kotlin/io/iohk/atala/prism/workflow/CloudAgentWorkflow.kt +++ b/tests/end-to-end/src/test/kotlin/io/iohk/atala/prism/workflow/CloudAgentWorkflow.kt @@ -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?) { @@ -31,18 +31,6 @@ class CloudAgentWorkflow { cloudAgent.remember("connectionId", lastResponse().get("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("invitation.invitationUrl")) - cloudAgent.remember("connectionId", lastResponse().get("connectionId")) - } - fun shareInvitation(cloudAgent: Actor, edgeAgent: Actor) { val invitation = cloudAgent.recall("invitation") edgeAgent.remember("invitation", invitation) @@ -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("recordId")) } @@ -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("recordId")) } @@ -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("presentationId")) }