Skip to content

Commit

Permalink
chore: enable coverage, sbt fixes (#433)
Browse files Browse the repository at this point in the history
  • Loading branch information
abalias committed Mar 14, 2023
1 parent 30d11ff commit 735922b
Show file tree
Hide file tree
Showing 42 changed files with 259 additions and 245 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/connect.yml
Expand Up @@ -21,7 +21,7 @@ on:
- "connect/lib/**"

jobs:
build-and-test-mercury:
build-and-test-connect:
uses: ./.github/workflows/scala-unit-tests.yml
with:
component-name: "Connect Lib"
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/e2e-tests.yml
Expand Up @@ -65,7 +65,6 @@ jobs:
PRISM_AGENT_PATH: "../../prism-agent/service/"
GITHUB_ACTOR: ${{ secrets.ATALA_GITHUB_ACTOR }}
GITHUB_TOKEN: ${{ secrets.ATALA_GITHUB_TOKEN }}
ATALA_GITHUB_TOKEN: ${{ secrets.ATALA_GITHUB_TOKEN }}
run: |
cd "${PRISM_AGENT_PATH}" || exit 129
sbt docker:publishLocal
Expand Down Expand Up @@ -106,8 +105,6 @@ jobs:

- name: Run e2e tests
continue-on-error: true
env:
ATALA_GITHUB_TOKEN: ${{ secrets.ATALA_GITHUB_TOKEN }}
run: |
./gradlew test --tests "E2eTestsRunner" || true
./gradlew reports
Expand All @@ -132,6 +129,7 @@ jobs:
run: |
JSON_RESULTS="target/site/serenity/serenity-summary.json"
CONCLUSION=failure
SLACK_REPORT_FAILURE=true
TOTAL_TESTS=0
FAILED_TESTS=0
SKIPPED_TESTS=0
Expand All @@ -145,9 +143,11 @@ jobs:
TESTS_WITH_ERRORS="$(cat ${JSON_RESULTS} | jq '.results.counts.error')"
if [[ ${FAILED_TESTS} == 0 && ${TESTS_WITH_ERRORS} == 0 ]] ; then
CONCLUSION=success
SLACK_REPORT_FAILURE=false
fi
fi
{
echo "slack_report_failure=${SLACK_REPORT_FAILURE}";
echo "conclusion=${CONCLUSION}";
echo "tests=${TOTAL_TESTS}";
echo "failures=${FAILED_TESTS}";
Expand All @@ -158,7 +158,7 @@ jobs:
} >> "$GITHUB_OUTPUT"
- name: Slack Notification
if: github.ref_name == 'main'
if: github.ref_name == 'main' && steps.analyze_test_results.outputs.slack_report_failure
uses: rtCamp/action-slack-notify@v2
env:
SLACK_COLOR: ${{ steps.analyze_test_results.outputs.conclusion }}
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/release.yml
Expand Up @@ -29,9 +29,8 @@ jobs:
env:
GITHUB_ACTOR: ${{ secrets.ATALA_GITHUB_ACTOR }}
GITHUB_TOKEN: ${{ secrets.ATALA_GITHUB_TOKEN }}
ATALA_GITHUB_TOKEN: ${{ secrets.ATALA_GITHUB_TOKEN }}
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SBT_PACKAGER: "enable" # To enable the packager plugin on Mercury
PUBLISH_PACKAGES: "enable" # To enable the packager plugin on Mercury
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/scala-steward.yml
Expand Up @@ -25,7 +25,6 @@ jobs:
uses: scala-steward-org/scala-steward-action@v2
env:
GITHUB_TOKEN: ${{ secrets.ATALA_GITHUB_TOKEN }}
ATALA_GITHUB_TOKEN: ${{ secrets.ATALA_GITHUB_TOKEN }}
with:
github-token: ${{ secrets.ATALA_GITHUB_TOKEN }}
sign-commits: true
Expand Down
15 changes: 3 additions & 12 deletions .github/workflows/scala-unit-tests.yml
Expand Up @@ -16,9 +16,6 @@ jobs:
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.ATALA_GITHUB_TOKEN }}
ATALA_GITHUB_TOKEN: ${{ secrets.ATALA_GITHUB_TOKEN }}
SBT_PACKAGER: "enable"
SBT_SCOVERAGE: "enable"
defaults:
run:
working-directory: ${{ inputs.component-dir }}
Expand All @@ -38,12 +35,7 @@ jobs:
run: sbt scalafmtCheckAll

- name: Run Unit Tests
run: |
if [[ ${{ inputs.component-dir }} == mercury/mercury-library ]]; then
SBT_SCOVERAGE=enable sbt clean coverage test coverageAggregate
else
sbt test
fi
run: sbt coverage test coverageAggregate

- name: Aggregate test reports
if: always()
Expand All @@ -61,17 +53,16 @@ jobs:
check_name: "${{ inputs.component-name }} Test Results"

- name: Code coverage report
if: inputs.component-dir == 'mercury/mercury-library'
uses: 5monkeys/cobertura-action@master
with:
path: "${{ inputs.component-dir }}/target/coverage/coverage-report/cobertura.xml"
report_name: "${{ inputs.component-name }} Code Coverage"
minimum_coverage: 10
fail_below_threshold: false
only_changed_files: true

- name: Artifact coverage HTML
uses: actions/upload-artifact@v2
if: inputs.component-dir == 'mercury/mercury-library'
with:
name: code-coverage-report-mercury
name: "code-coverage-report-${{ inputs.component-name }}"
path: "${{ inputs.component-dir }}/target/coverage/scoverage-report"
2 changes: 2 additions & 0 deletions .mega-linter.yml
Expand Up @@ -32,6 +32,8 @@ BASH_SHELLCHECK_DISABLE_ERRORS: true
PRE_COMMANDS:
- command: git config --global core.autocrlf input
cwd: "workspace"
- command: pip install Click==8.1.3
cwd: "workspace"

# Linter customisation
MARKDOWN_MARKDOWN_LINK_CHECK_FILTER_REGEX_EXCLUDE: "CHANGELOG.md"
Expand Down
61 changes: 35 additions & 26 deletions castor/lib/build.sbt
@@ -1,31 +1,51 @@
import Dependencies._
import sbtrelease.ReleasePlugin.autoImport.ReleaseTransformations._

inThisBuild(
Seq(
organization := "io.iohk.atala",
scalaVersion := "3.2.1",
scalaVersion := "3.2.2",
fork := true,
run / connectInput := true,
versionScheme := Some("semver-spec"),
githubOwner := "input-output-hk",
githubRepository := "atala-prism-building-blocks",
githubTokenSource := TokenSource.Environment("ATALA_GITHUB_TOKEN")
testFrameworks := Seq(new TestFramework("zio.test.sbt.ZTestFramework")),
resolvers += Resolver.githubPackages("input-output-hk"),
resolvers += "JetBrains Space Maven Repository" at "https://maven.pkg.jetbrains.space/public/p/kotlinx-coroutines/maven"
)
)

val commonSettings = Seq(
testFrameworks := Seq(new TestFramework("zio.test.sbt.ZTestFramework")),
githubTokenSource := TokenSource.Environment("ATALA_GITHUB_TOKEN"),
resolvers += Resolver.githubPackages("input-output-hk"),
// Needed for Kotlin coroutines that support new memory management mode
resolvers += "JetBrains Space Maven Repository" at "https://maven.pkg.jetbrains.space/public/p/kotlinx-coroutines/maven"
)
coverageDataDir := target.value / "coverage"

SbtUtils.disablePlugins(publishConfigure) // SEE also SbtUtils.scala
lazy val publishConfigure: Project => Project = sys.env
.get("PUBLISH_PACKAGES") match {
case None => _.disablePlugins(GitHubPackagesPlugin)
case Some(_) => (p: Project) => p
}

sys.env
.get("PUBLISH_PACKAGES") // SEE also plugin.sbt
.map { _ =>
println("### Configure release process ###")
import sbtrelease.ReleasePlugin.autoImport.ReleaseTransformations._
ThisBuild / releaseUseGlobalVersion := false
ThisBuild / githubOwner := "input-output-hk"
ThisBuild / githubRepository := "atala-prism-building-blocks"
releaseProcess := Seq[ReleaseStep](
checkSnapshotDependencies,
inquireVersions,
runClean,
runTest,
setReleaseVersion,
publishArtifacts,
setNextVersion
)
}
.toSeq

// Project definitions
lazy val root = project
.in(file("."))
.settings(commonSettings)
.configure(publishConfigure)
.settings(
name := "castor-root",
)
Expand All @@ -34,28 +54,17 @@ lazy val root = project

lazy val core = project
.in(file("core"))
.settings(commonSettings)
.configure(publishConfigure)
.settings(
name := "castor-core",
libraryDependencies ++= coreDependencies
)

lazy val `sql-doobie` = project
.in(file("sql-doobie"))
.settings(commonSettings)
.configure(publishConfigure)
.settings(
name := "castor-sql-doobie",
libraryDependencies ++= sqlDoobieDependencies
)
.dependsOn(core)

// ### ReleaseStep ###
releaseProcess := Seq[ReleaseStep](
checkSnapshotDependencies,
inquireVersions,
runClean,
runTest,
setReleaseVersion,
publishArtifacts,
setNextVersion
)
10 changes: 10 additions & 0 deletions castor/lib/project/SbtUtils.scala
@@ -0,0 +1,10 @@
object SbtUtils {

import sbt._
import sbt.internal.DslEntry.DslDisablePlugins

def disablePlugins(f: Project => Project) = new DslDisablePlugins(Seq()) {
override val toFunction: Project => Project = f
}

}
1 change: 1 addition & 0 deletions castor/lib/project/build.sbt
@@ -1,3 +1,4 @@
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.0")
addSbtPlugin("com.github.sbt" % "sbt-release" % "1.1.0")
addSbtPlugin("com.codecommit" % "sbt-github-packages" % "0.5.3")
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "2.0.7")
Empty file removed connect/.gitkeep
Empty file.
21 changes: 7 additions & 14 deletions connect/lib/build.sbt
@@ -1,5 +1,4 @@
import Dependencies._
import sbtrelease.ReleasePlugin.autoImport.ReleaseTransformations._

inThisBuild(
Seq(
Expand All @@ -10,29 +9,23 @@ inThisBuild(
versionScheme := Some("semver-spec"),
githubOwner := "input-output-hk",
githubRepository := "atala-prism-building-blocks",
githubTokenSource := TokenSource.Environment("ATALA_GITHUB_TOKEN")
resolvers += Resolver.githubPackages("input-output-hk"),
resolvers += "JetBrains Space Maven Repository" at "https://maven.pkg.jetbrains.space/public/p/kotlinx-coroutines/maven",
testFrameworks := Seq(new TestFramework("zio.test.sbt.ZTestFramework"))
)
)

val commonSettings = Seq(
githubTokenSource := TokenSource.Environment("ATALA_GITHUB_TOKEN"),
resolvers += Resolver.githubPackages("input-output-hk"),
// Needed for Kotlin coroutines that support new memory management mode
resolvers += "JetBrains Space Maven Repository" at "https://maven.pkg.jetbrains.space/public/p/kotlinx-coroutines/maven",
testFrameworks := Seq(new TestFramework("zio.test.sbt.ZTestFramework"))
)
coverageDataDir := target.value / "coverage"

// Project definitions
lazy val root = project
.in(file("."))
.settings(commonSettings)
.settings(name := "connect")
.aggregate(core, `sql-doobie`)
publish / skip := true //Do not publish the root
publish / skip := true // Do not publish the root

lazy val core = project
.in(file("core"))
.settings(commonSettings)
.settings(
name := "connect-core",
libraryDependencies ++= coreDependencies,
Expand All @@ -41,14 +34,14 @@ lazy val core = project

lazy val `sql-doobie` = project
.in(file("sql-doobie"))
.settings(commonSettings)
.settings(
name := "connect-sql-doobie",
libraryDependencies ++= sqlDoobieDependencies
)
.dependsOn(core % "compile->compile;test->test")

// ### ReleaseStep ###
// Configure release process
import sbtrelease.ReleasePlugin.autoImport.ReleaseTransformations._
releaseProcess := Seq[ReleaseStep](
checkSnapshotDependencies,
inquireVersions,
Expand Down
1 change: 1 addition & 0 deletions connect/lib/project/build.sbt
@@ -1,3 +1,4 @@
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.0")
addSbtPlugin("com.codecommit" % "sbt-github-packages" % "0.5.3")
addSbtPlugin("com.github.sbt" % "sbt-release" % "1.1.0")
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "2.0.7")
1 change: 0 additions & 1 deletion connect/lib/project/plugins.sbt

This file was deleted.

1 change: 0 additions & 1 deletion connect/project/build.properties

This file was deleted.

3 changes: 1 addition & 2 deletions infrastructure/dev/README.md
Expand Up @@ -8,15 +8,14 @@ All components are built at the current repository version and published locally
**Running using the scripts in this directory does not create a production-ready or secure environment. It is designed to allow easy development and should not be used to run a production instance**

Please ensure you have set the `ATALA_GITHUB_TOKEN` and `GITHUB_TOKEN` environment variable. These both need to be set to the same value.
Please ensure you have set the `GITHUB_TOKEN` environment variable.

The value of this variable must be a Github token generated with the `read:packages` permission set on the `building-block` repository.

> Replace `YOUR_TOKEN_HERE` with your Github token
```
export GITHUB_TOKEN=YOUR_TOKEN_HERE
export ATALA_GITHUB_TOKEN=$GITHUB_TOKEN
```

Please ensure you have logged into the ATALA IOHK Docker Registry using the following command [once the `GITHUB_TOKEN` is set]
Expand Down
3 changes: 1 addition & 2 deletions infrastructure/local/README.md
Expand Up @@ -8,15 +8,14 @@ All images will be pulled from a remote repository and the `.env` file controls
**Running using the scripts in this directory does not create a production-ready or secure environment. It is designed to allow easy development and should not be used to run a production instance**

Please ensure you have set the `ATALA_GITHUB_TOKEN` and `GITHUB_TOKEN` environment variable. These both need to be set to the same value.
Please ensure you have set the `GITHUB_TOKEN` environment variable.

The value of this variable must be a Github token generated with the `read:packages` permission set on the `building-block` repository.

> Replace `YOUR_TOKEN_HERE` with your Github token
```
export GITHUB_TOKEN=YOUR_TOKEN_HERE
export ATALA_GITHUB_TOKEN=$GITHUB_TOKEN
```

Please ensure you have logged into the ATALA IOHK Docker Registry using the following command [once the `GITHUB_TOKEN` is set]
Expand Down
3 changes: 1 addition & 2 deletions infrastructure/multi/README.md
Expand Up @@ -19,15 +19,14 @@ All images will be pulled from a remote repository and the `.env` file controls
**Running using the scripts in this directory does not create a production-ready or secure environment. It is designed to allow easy development and should not be used to run a production instance**

Please ensure you have set the `ATALA_GITHUB_TOKEN` and `GITHUB_TOKEN` environment variable. These both need to be set to the same value.
Please ensure you have set the `GITHUB_TOKEN` environment variable.

The value of this variable must be a Github token generated with the `read:packages` permission set on the `building-block` repository.

> Replace `YOUR_TOKEN_HERE` with your Github token
```
export GITHUB_TOKEN=YOUR_TOKEN_HERE
export ATALA_GITHUB_TOKEN=$GITHUB_TOKEN
```

Please ensure you have logged into the ATALA IOHK Docker Registry using the following command [once the `GITHUB_TOKEN` is set]
Expand Down
Expand Up @@ -10,6 +10,7 @@
import logging
import sys

# pylint: disable=import-error
import click

# pylint: disable=E0402
Expand Down Expand Up @@ -66,7 +67,7 @@ def __init__(self, token, owner, repo):
@click.group()
@click.option(
"--token",
envvar="ATALA_GITHUB_TOKEN",
envvar="GITHUB_TOKEN",
metavar="TOKEN",
required=True,
help="GitHub authentication token.",
Expand Down Expand Up @@ -137,7 +138,7 @@ def get_latest_package_version(ctx, package, package_type):
print(versions[0].get("metadata").get("container").get("tags")[0])
else:
print(versions[0].get("name", "NOT EXIST"))
except:
except IndexError:
print("NOT EXIST")


Expand Down
2 changes: 1 addition & 1 deletion infrastructure/utils/python/github-helpers/setup.py
Expand Up @@ -13,7 +13,7 @@
"console_scripts": ["github=github_helpers.cli:cli"],
},
install_requires=[
"Click==8.0.1",
"Click==8.1.3",
"requests==2.26.0",
"pylint==2.10.2",
"pytest==6.2.4",
Expand Down

0 comments on commit 735922b

Please sign in to comment.