Skip to content

Commit 58bf604

Browse files
committed
Merge remote-tracking branch 'upstream/iroha2-dev' into update/MVP
2 parents e170d5b + a3397a7 commit 58bf604

File tree

21 files changed

+143
-32
lines changed

21 files changed

+143
-32
lines changed

.github/workflows/iroha2-allure.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,11 @@ on:
1717
ALLURE_USERNAME:
1818
description: "ALLURE_USERNAME service parameter. Leave blank"
1919
required: false
20+
repository_dispatch:
21+
types: [allure-upload-trigger]
2022

2123
env:
24+
IROHA_IMAGE_TAG: "dev"
2225
ALLURE_RESULTS: "${{ github.workspace }}/modules/client/build/allure-results"
2326
ALLURE_JOB_RUN_ID: ${{ github.event.inputs.ALLURE_JOB_RUN_ID }}
2427

.github/workflows/iroha2-pr.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@ name: Iroha2-java pull requests workflow
33
on:
44
pull_request:
55
branches: [ iroha2-dev, iroha2-main ]
6+
67
jobs:
78
build:
8-
runs-on: self-hosted
9-
9+
runs-on: [self-hosted, Linux, iroha2]
10+
env:
11+
IROHA_IMAGE_TAG: "2.0.0-pre-rc.22.2" # Place "dev" to run on the last iroha
1012
steps:
11-
- uses: actions/checkout@v3
13+
- uses: actions/checkout@v4
1214
- name: Set up JDK 17
1315
uses: actions/setup-java@v3
1416
with:
@@ -27,7 +29,7 @@ jobs:
2729
run: ./gradlew build --info
2830
- name: Upload build reports
2931
if: failure()
30-
uses: actions/upload-artifact@v3
32+
uses: actions/upload-artifact@v4
3133
with:
3234
name: build-reports
3335
path: /home/runner/work/iroha-java/iroha-java/**/index.html

.github/workflows/iroha2.yml

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@ name: Iroha2-java main branch workflow
33
on:
44
push:
55
branches: [ iroha2-dev, iroha2-main ]
6+
workflow_dispatch:
7+
68
jobs:
79
build:
8-
runs-on: ubuntu-latest
9-
10+
runs-on: [self-hosted, Linux, iroha2]
1011
steps:
11-
- uses: actions/checkout@v3
12+
- uses: actions/checkout@v4
1213
- name: Set up JDK 17
1314
uses: actions/setup-java@v3
1415
with:
@@ -23,8 +24,26 @@ jobs:
2324
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
2425
restore-keys: |
2526
${{ runner.os }}-gradle-
26-
- name: Build with Gradle
27-
run: ./gradlew build
27+
- name: Build with Gradle & Sonarqube analysis
28+
run: |
29+
./gradlew build
30+
./gradlew jacocoTestReport
31+
./gradlew sonar -Dsonar.token=${{ secrets.SONAR_TOKEN }}
32+
- name: DefectDojo
33+
if: always()
34+
uses: C4tWithShell/[email protected]
35+
with:
36+
token: ${{ secrets.DEFECTOJO_TOKEN }}
37+
defectdojo_url: ${{ secrets.DEFECTOJO_URL }}
38+
product_type: iroha2
39+
engagement: ${{ github.ref_name }}
40+
tools: "SonarQube API Import,Github Vulnerability Scan"
41+
sonar_projectKey: iroha2-java
42+
github_token: ${{ secrets.GITHUB_TOKEN }}
43+
github_repository: ${{ github.repository }}
44+
product: ${{ github.repository }}
45+
environment: Test
46+
reports: '{"Github Vulnerability Scan": "github.json"}'
2847
- name: Cleanup Gradle Cache
2948
# Remove some files from the Gradle cache, so they aren't cached by GitHub Actions.
3049
# Restoring these files from a GitHub Actions cache might cause problems for future builds.

build.gradle

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ plugins {
1515
id 'org.jmailen.kotlinter' version "$kotlinLinterVer"
1616
id 'maven-publish'
1717
id 'com.github.johnrengelman.shadow' version '8.1.1'
18+
id 'org.sonarqube' version "5.1.0.4882"
19+
id 'jacoco'
1820
}
1921

2022
allprojects {
@@ -30,6 +32,7 @@ subprojects {
3032
apply plugin: 'org.jetbrains.kotlin.jvm'
3133
apply plugin: 'org.jmailen.kotlinter'
3234
apply plugin: 'com.github.johnrengelman.shadow'
35+
apply plugin: 'jacoco'
3336

3437
publishing {
3538
publications {
@@ -53,10 +56,6 @@ subprojects {
5356
group = 'jp.co.soramitsu.iroha2-java'
5457
version = 'git rev-parse --short HEAD'.execute().text.trim()
5558

56-
test {
57-
useJUnitPlatform()
58-
}
59-
6059
java {
6160
toolchain {
6261
languageVersion = JavaLanguageVersion.of(21)
@@ -96,6 +95,36 @@ subprojects {
9695
// uncomment to produce shadowJar build by default
9796
// it is disabled by default to publish original version by CI, not a fat jar
9897
tasks.shadowJar.enabled = false
98+
99+
test {
100+
useJUnitPlatform()
101+
}
102+
103+
jacocoTestReport {
104+
reports {
105+
xml.required = true
106+
}
107+
}
108+
109+
plugins.withType(JacocoPlugin) {
110+
tasks["test"].finalizedBy 'jacocoTestReport'
111+
}
112+
113+
sonar {
114+
properties {
115+
property "sonar.projectKey", "iroha-java"
116+
property "sonar.host.url", "https://sonar.katana.soramitsu.co.jp"
117+
property "sonar.java.coveragePlugin", "jacoco"
118+
property "sonar.projectName", "${project.group}:${rootProject.name}.${project.name}"
119+
property "sonar.sources", "${project.projectDir}/src/main/kotlin"
120+
// exclude projects with no tests
121+
if (project.name != "codegen" && project.name != "model" && project.name != "tutorial") {
122+
property "sonar.tests", "${project.projectDir}/src/test"
123+
}
124+
property "sonar.java.test.binaries", "${project.projectDir}/build/test-results/test/binary"
125+
property "sonar.junit.reportPaths", "${project.projectDir}/build/test-results/test/"
126+
}
127+
}
99128
}
100129

101130
task allShadowJars {

examples/tutorial/build.gradle.kts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,26 @@
1+
val ktorVer = project.properties["ktorVer"] as String
2+
13
dependencies {
24
implementation(project(":admin-client"))
35

46
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.9.0")
7+
implementation("io.ktor:ktor-client-logging:$ktorVer")
8+
}
9+
10+
tasks.jacocoTestReport {
11+
mustRunAfter(":admin-client:jacocoTestReport")
12+
mustRunAfter(":block:jacocoTestReport")
13+
mustRunAfter(":client:jacocoTestReport")
14+
mustRunAfter(":codegen:jacocoTestReport")
15+
mustRunAfter(":model:jacocoTestReport")
16+
mustRunAfter(":test-tools:jacocoTestReport")
17+
}
18+
19+
tasks.jacocoTestReport {
20+
mustRunAfter(":admin-client:jacocoTestReport")
21+
mustRunAfter(":block:jacocoTestReport")
22+
mustRunAfter(":client:jacocoTestReport")
23+
mustRunAfter(":codegen:jacocoTestReport")
24+
mustRunAfter(":model:jacocoTestReport")
25+
mustRunAfter(":test-tools:jacocoTestReport")
526
}

examples/tutorial/src/main/kotlin/jp/co/soramitsu/iroha2/Main.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ fun main(): Unit = runBlocking {
2020
"CE7FA46C9DCE7EA4B125E2E36BDB63EA33073E7590AC92816AE1E861B7048B03",
2121
"CCF31D85E3B32A4BEA59987CE0C78E3B8E2DB93881468AB2435FE45D5C9DCD53",
2222
)
23-
val client = AdminIroha2Client(listOf(URI(apiUrl).toURL()), chainId, admin, adminKeyPair, log = true)
23+
val client = AdminIroha2Client(listOf(URI(apiUrl).toURL()), chainId, admin, adminKeyPair)
2424
val query = Query(client, admin, adminKeyPair)
2525
query.findAllDomains()
2626
.also { println("ALL DOMAINS: ${it.map { d -> d.id.asString() }}") }

gradle.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,4 @@ testContainersVer=1.20.3
1717
# logging
1818
logbackVer=1.5.12
1919
org.gradle.jvmargs=-XX:MetaspaceSize=128M -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
20+
systemProp.sonar.host.url=https://sonar.katana.soramitsu.co.jp

modules/admin-client/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ dependencies {
44

55
implementation "io.ktor:ktor-client-core:$ktorVer"
66
implementation "io.ktor:ktor-client-cio:$ktorVer"
7+
implementation "io.ktor:ktor-client-logging:$ktorVer"
78

89
testApi project(":test-tools")
910
testImplementation "org.jetbrains.kotlin:kotlin-test-junit5:$kotlinVer"

modules/admin-client/src/main/kotlin/jp/co/soramitsu/iroha2/AdminIroha2AsyncClient.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package jp.co.soramitsu.iroha2
22

3+
import io.ktor.client.plugins.logging.LogLevel
34
import jp.co.soramitsu.iroha2.generated.AccountId
45
import kotlinx.coroutines.future.future
56
import java.net.URL
@@ -15,9 +16,9 @@ class AdminIroha2AsyncClient @JvmOverloads constructor(
1516
override val chain: UUID,
1617
override val authority: AccountId,
1718
override val keyPair: KeyPair,
19+
httpLogLevel: LogLevel = LogLevel.NONE,
1820
credentials: String? = null,
19-
log: Boolean = false,
20-
) : AdminIroha2Client(apiURL, chain, authority, keyPair, credentials, log) {
21+
) : AdminIroha2Client(apiURL, chain, authority, keyPair, credentials, httpLogLevel) {
2122

2223
/**
2324
* Send health check request

modules/admin-client/src/main/kotlin/jp/co/soramitsu/iroha2/AdminIroha2Client.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package jp.co.soramitsu.iroha2
22

33
import io.ktor.client.call.body
4+
import io.ktor.client.plugins.logging.LogLevel
45
import io.ktor.client.request.get
56
import io.ktor.client.request.setBody
67
import io.ktor.client.statement.HttpResponse
@@ -23,9 +24,9 @@ open class AdminIroha2Client(
2324
override val authority: AccountId,
2425
override val keyPair: KeyPair,
2526
credentials: String? = null,
26-
log: Boolean = false,
27+
httpLogLevel: LogLevel = LogLevel.NONE,
2728
private val balancingHealthCheck: Boolean = true,
28-
) : Iroha2Client(apiURL, chain, authority, keyPair, credentials, log) {
29+
) : Iroha2Client(apiURL, chain, authority, keyPair, credentials, httpLogLevel) {
2930

3031
/**
3132
* Send metrics request

0 commit comments

Comments
 (0)