Skip to content

Commit 60765af

Browse files
committed
Merge branch 'release/7.1.0' into main
2 parents 6153be8 + 9f07dce commit 60765af

File tree

32 files changed

+433
-316
lines changed

32 files changed

+433
-316
lines changed

Jenkinsfile

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
@Library('jenkins-library@1.1.0') _
1+
@Library('global-jenkins-library@2.0.1') _
22
buildJavaProject(
3-
shouldRunIntegrationTests: true,
4-
integrationTestsEnvVars: ["BROKER_PRIVATE_KEY"],
5-
shouldPublishJars: false,
3+
buildInfo: getBuildInfo(),
4+
integrationTestsEnvVars: ['BROKER_PRIVATE_KEY'],
5+
shouldPublishJars: true,
66
shouldPublishDockerImages: true,
7-
dockerfileDir: './docker',
8-
//dockerfileFilename: "Dockerfile-local",
7+
dockerfileDir: 'docker',
98
buildContext: '.',
10-
//dockerImageRepositoryName: '',
9+
preDevelopVisibility: 'iex.ec',
10+
developVisibility: 'iex.ec',
1111
preProductionVisibility: 'docker.io',
12-
productionVisibility: 'docker.io')
12+
productionVisibility: 'docker.io')

build.gradle

Lines changed: 64 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,34 @@
11
plugins {
2-
id 'org.springframework.boot' version '2.4.3'
3-
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
42
id 'java'
5-
id 'com.palantir.docker' version '0.26.0'
6-
id "org.sonarqube" version "2.7"
3+
id 'org.springframework.boot' version '2.6.2'
4+
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
5+
id 'jacoco'
6+
id 'org.sonarqube' version '3.3'
77
id 'maven-publish'
88
}
99

1010
ext {
1111
openFeignVersion = '11.6'
12+
gitBranch = 'git rev-parse --abbrev-ref HEAD'.execute().text.trim()
1213
}
1314

14-
group = 'com.iexec.blockchain'
15-
sourceCompatibility = '11'
16-
targetCompatibility = '11'
17-
18-
configurations {
19-
compileOnly {
20-
extendsFrom annotationProcessor
21-
}
22-
}
23-
24-
repositories {
25-
mavenLocal()
26-
mavenCentral()
27-
// iExec
28-
maven {
29-
url "https://nexus.iex.ec/repository/maven-public/"
15+
allprojects {
16+
group = 'com.iexec.blockchain'
17+
sourceCompatibility = 11
18+
targetCompatibility = 11
19+
if (gitBranch != 'main' && gitBranch != 'master' && !(gitBranch ==~ '(release|hotfix|support)/.*')) {
20+
version += '-NEXT-SNAPSHOT'
3021
}
31-
maven {
32-
url "https://jitpack.io"
22+
repositories {
23+
mavenLocal()
24+
mavenCentral()
25+
// iExec
26+
maven {
27+
url "https://nexus.intra.iex.ec/repository/maven-public/"
28+
}
29+
maven {
30+
url "https://jitpack.io"
31+
}
3332
}
3433
}
3534

@@ -46,8 +45,9 @@ dependencies {
4645
testImplementation 'org.springframework.boot:spring-boot-starter-test'
4746
testImplementation 'org.awaitility:awaitility:4.0.1'
4847

49-
implementation "io.springfox:springfox-boot-starter:3.0.0"
50-
implementation "io.springfox:springfox-swagger-ui:3.0.0"
48+
// Spring Doc
49+
implementation 'org.springdoc:springdoc-openapi-ui:1.6.3'
50+
5151
implementation 'org.springframework.boot:spring-boot-starter-security'
5252
implementation 'org.springframework.boot:spring-boot-starter-data-mongodb'
5353
implementation 'org.springframework.boot:spring-boot-starter-validation'
@@ -65,6 +65,13 @@ dependencies {
6565
implementation "io.github.openfeign:feign-core:$openFeignVersion"
6666
implementation "io.github.openfeign:feign-jackson:$openFeignVersion"
6767
implementation "io.github.openfeign:feign-slf4j:$openFeignVersion"
68+
69+
// integration tests
70+
implementation project(':iexec-blockchain-adapter-api-library')
71+
}
72+
73+
springBoot {
74+
buildInfo()
6875
}
6976

7077
sourceSets {
@@ -78,7 +85,19 @@ sourceSets {
7885
}
7986
}
8087

88+
task itestSetup(type: Exec) {
89+
commandLine 'docker-compose', 'up', '-d'
90+
}
91+
92+
task itestTeardown(type: Exec) {
93+
commandLine 'docker-compose', 'down'
94+
}
95+
8196
task itest(type: Test) {
97+
group 'Verification'
98+
description 'Runs the integration tests.'
99+
dependsOn itestSetup
100+
finalizedBy itestTeardown
82101
setTestClassesDirs(sourceSets.integrationTest.output)
83102
classpath = sourceSets.integrationTest.runtimeClasspath
84103
useJUnitPlatform()
@@ -113,12 +132,25 @@ test {
113132
useJUnitPlatform()
114133
}
115134

116-
def jar = rootProject.name + '-' + version + ".jar"
117-
118-
docker {
119-
name 'docker.io/iexechub/' + rootProject.name + ':dev'
120-
dockerfile file('docker/Dockerfile-local')
121-
files('build/libs/' + jar)
122-
buildArgs([JAR_PATH: jar ])
135+
jacoco {
136+
toolVersion = "0.8.7"
137+
}
138+
// sonarqube code coverage requires jacoco XML report
139+
jacocoTestReport {
140+
reports {
141+
xml.enabled true
142+
}
143+
}
144+
tasks.test.finalizedBy tasks.jacocoTestReport
145+
tasks.sonarqube.dependsOn tasks.jacocoTestReport
146+
147+
ext.jarPathForOCI = relativePath(tasks.bootJar.outputs.files.singleFile)
148+
ext.gitShortCommit = 'git rev-parse --short=8 HEAD'.execute().text.trim()
149+
ext.ociImageName = 'local/' + ['bash', '-c', 'basename $(git config --get remote.origin.url) .git'].execute().text.trim()
150+
151+
task buildImage(type: Exec) {
152+
group 'Build'
153+
description 'Builds an OCI image from a Dockerfile.'
154+
commandLine("sh", "-c", "docker build -f docker/Dockerfile --build-arg jar=$jarPathForOCI -t $ociImageName:$gitShortCommit ."
155+
+ " && docker tag $ociImageName:$gitShortCommit $ociImageName:dev")
123156
}
124-
tasks.docker.dependsOn tasks.build

docker-compose.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
version: "3.4"
1+
version: "3.5"
22

33
networks:
44
iexec-blockchain-adapter-api-net:
5-
external: true
5+
name: iexec-blockchain-adapter-api-net
66

77
services:
88

@@ -37,4 +37,4 @@ services:
3737
ports:
3838
- 23012:13012
3939
networks:
40-
- iexec-blockchain-adapter-api-net
40+
- iexec-blockchain-adapter-api-net

docker/Dockerfile

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,10 @@
1-
ARG HOME=/home
2-
ARG JAR_PATH=$HOME/build/libs/*.jar
1+
# Build app container
2+
FROM openjdk:11.0.15-jre-slim
33

4-
# Build jar
5-
FROM gradle:6.8.3-jdk11 as gradle-builder
6-
ARG HOME
7-
WORKDIR $HOME
8-
COPY build.gradle gradle.properties settings.gradle ./
9-
COPY src/ src/
10-
RUN gradle build -i --no-daemon
4+
ARG jar
115

12-
# Build app container
13-
FROM openjdk:11.0.3-jre-slim
14-
ARG JAR_PATH
15-
COPY --from=gradle-builder $JAR_PATH app.jar
16-
ENTRYPOINT [ "/bin/sh", "-c", "exec java -Djava.security.egd=file:/dev/./urandom -jar app.jar" ]
6+
RUN test -n "$jar"
177

18-
# CI/CD version
19-
## git clone, then cd into
20-
## docker image build -f docker/Dockerfile .
8+
COPY $jar app.jar
9+
10+
ENTRYPOINT [ "/bin/sh", "-c", "exec java -Djava.security.egd=file:/dev/./urandom -jar app.jar" ]

docker/Dockerfile-local

Lines changed: 0 additions & 5 deletions
This file was deleted.

gradle.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
version=7.0.0
2-
iexecCommonVersion=5.8.0
1+
version=7.1.0
2+
iexecCommonVersion=6.0.0
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
plugins {
2+
id 'java-library'
3+
id 'jacoco'
4+
id 'maven-publish'
5+
}
6+
7+
dependencies {
8+
implementation "com.iexec.common:iexec-common:$iexecCommonVersion"
9+
testImplementation 'org.junit.jupiter:junit-jupiter:5.8.2'
10+
}
11+
12+
java {
13+
withJavadocJar()
14+
withSourcesJar()
15+
}
16+
17+
test {
18+
useJUnitPlatform()
19+
}
20+
21+
jacoco {
22+
toolVersion = "0.8.7"
23+
}
24+
// sonarqube code coverage requires jacoco XML report
25+
jacocoTestReport {
26+
reports {
27+
xml.enabled true
28+
}
29+
}
30+
tasks.test.finalizedBy tasks.jacocoTestReport
31+
32+
publishing {
33+
publications {
34+
maven(MavenPublication) {
35+
from components.java
36+
}
37+
}
38+
repositories {
39+
maven {
40+
credentials {
41+
username project.hasProperty("nexusUser")? project.nexusUser: ''
42+
password project.hasProperty("nexusPassword")? project.nexusPassword: ''
43+
}
44+
url = project.hasProperty("nexusUrl")? project.nexusUrl: ''
45+
}
46+
}
47+
}
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
/*
2+
* Copyright 2022 IEXEC BLOCKCHAIN TECH
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.iexec.blockchain.api;
18+
19+
import com.iexec.blockchain.tool.Status;
20+
import com.iexec.common.chain.ChainDataset;
21+
import com.iexec.common.chain.ChainTask;
22+
import com.iexec.common.chain.adapter.CommandStatus;
23+
import com.iexec.common.chain.adapter.args.TaskContributeArgs;
24+
import com.iexec.common.chain.adapter.args.TaskFinalizeArgs;
25+
import com.iexec.common.chain.adapter.args.TaskRevealArgs;
26+
import com.iexec.common.config.PublicChainConfig;
27+
import com.iexec.common.sdk.broker.BrokerOrder;
28+
import feign.Param;
29+
import feign.RequestLine;
30+
31+
/**
32+
* Interface allowing to instantiate a Feign client targeting Blockchain adapter API REST endpoints.
33+
* <p>
34+
* To create the client, call:
35+
* <pre>FeignBuilder.createBuilder(feignLogLevel)
36+
* .target(BlockchainAdapterApiClient.class, blockchainAdapterUrl)</pre>
37+
* @see com.iexec.common.utils.FeignBuilder
38+
*/
39+
public interface BlockchainAdapterApiClient {
40+
41+
// region authenticated APIs
42+
43+
//TODO update endpoint
44+
@RequestLine("POST /broker/broker/orders/match")
45+
String matchOrders(BrokerOrder brokerOrder);
46+
47+
@RequestLine("POST /datasets/requests?name={name}&multiAddress={multiAddress}&checksum={checksum}")
48+
String createDataset(@Param("name") String name,
49+
@Param("multiAddress") String multiAddress,
50+
@Param("checksum") String checksum);
51+
52+
@RequestLine("GET /datasets/requests/{requestId}")
53+
String getAddressForCreateDatasetRequest(@Param("requestId") String requestId);
54+
55+
@RequestLine("GET /datasets/requests/{requestId}/status")
56+
Status getStatusForCreateDatasetRequest(@Param("requestId") String requestId);
57+
58+
@RequestLine("GET /datasets?address={address}")
59+
ChainDataset getDatasetByAddress(@Param("address") String address);
60+
61+
@RequestLine("GET /metrics")
62+
String getMetrics();
63+
64+
@RequestLine("GET /tasks/{chainTaskId}")
65+
ChainTask getTask(@Param("chainTaskId") String chainTaskId);
66+
67+
@RequestLine("POST /tasks/initialize?chainDealId={chainDealId}&taskIndex={taskIndex}")
68+
String requestInitializeTask(@Param("chainDealId") String chainDealId,
69+
@Param("taskIndex") int taskIndex);
70+
71+
@RequestLine("GET /tasks/initialize/{chainTaskId}/status")
72+
CommandStatus getStatusForInitializeTaskRequest(@Param("chainTaskId") String chainTaskId);
73+
74+
@RequestLine("POST /tasks/contribute/{chainTaskId}")
75+
String requestContributeTask(@Param("chainTaskId") String chainTaskId, TaskContributeArgs taskContributeArgs);
76+
77+
@RequestLine("GET /tasks/contribute/{chainTaskId}/status")
78+
CommandStatus getStatusForContributeTaskRequest(@Param("chainTaskId") String chainTaskId);
79+
80+
@RequestLine("POST /tasks/reveal/{chainTaskId}")
81+
String requestRevealTask(@Param("chainTaskId") String chainTaskId, TaskRevealArgs taskRevealArgs);
82+
83+
@RequestLine("GET /tasks/reveal/{chainTaskId}/status")
84+
CommandStatus getStatusForRevealTaskRequest(@Param("chainTaskId") String chainTaskId);
85+
86+
@RequestLine("POST /tasks/finalize/{chainTaskId}")
87+
String requestFinalizeTask(@Param("chainTaskId") String chainTaskId, TaskFinalizeArgs taskFinalizeArgs);
88+
89+
@RequestLine("GET /tasks/finalize/{chainTaskId}/status")
90+
CommandStatus getStatusForFinalizeTaskRequest(@Param("chainTaskId") String chainTaskId);
91+
92+
// endregion
93+
94+
// region unauthenticated APIs
95+
96+
@RequestLine("GET /config/chain")
97+
PublicChainConfig getPublicChainConfig();
98+
99+
//endregion
100+
101+
}

0 commit comments

Comments
 (0)