diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 89847b470..67ecb0674 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -1,13 +1,13 @@ -# This workflow will build a Java project with Gradle -# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle - name: Java CI with Gradle on: push: - branches: [ main ] + branches: [ "issues/120" ] pull_request: - branches: [ main ] + branches: [ "issues/120" ] + +permissions: + contents: read jobs: build: @@ -15,84 +15,13 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - name: Set up JDK 8 - uses: actions/setup-java@v2 - with: - java-version: '8' - distribution: 'adopt' - - - name: Grant execute permission for gradlew - run: chmod +x gradlew - - - name: Build with Gradle - run: ./gradlew build - - publish-docs-reports: - needs: build - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - - name: Set up JDK 11 - uses: actions/setup-java@v2 + - uses: actions/checkout@v3 + - name: Set up JDK 8 + uses: actions/setup-java@v3 with: - java-version: '11' - distribution: 'adopt' - + java-version: '8' + distribution: 'temurin' - name: Grant execute permission for gradlew run: chmod +x gradlew - - - name: Export project version - run: echo "PROJECT_VERSION=$(./gradlew properties -q | grep "version:" | awk '{print $2}')" >> $GITHUB_ENV - - - name: Generate Javadoc - run: ./gradlew javadoc - - - name: Run tests and generate reports - run: ./gradlew test - - - name: Deploy tests results to GitHub Pages - uses: JamesIves/github-pages-deploy-action@v4.2.2 - with: - branch: gh-pages - clean: true - folder: build/reports/tests - target-folder: docs/latest/junit - - name: Deploy jacoco report to GitHub Pages - uses: JamesIves/github-pages-deploy-action@v4.2.2 - with: - branch: gh-pages - clean: true - folder: build/reports/jacoco - target-folder: docs/latest/jacoco - - name: Deploy to GitHub Pages - uses: JamesIves/github-pages-deploy-action@v4.2.2 - with: - branch: gh-pages - clean: true - folder: build/docs/javadoc - target-folder: docs/latest/javadoc - - - name: Deploy tests results to GitHub Pages - uses: JamesIves/github-pages-deploy-action@v4.2.2 - with: - branch: gh-pages - clean: true - folder: build/reports/tests - target-folder: docs/${{ env.PROJECT_VERSION }}/junit - - name: Deploy jacoco report to GitHub Pages - uses: JamesIves/github-pages-deploy-action@v4.2.2 - with: - branch: gh-pages - clean: true - folder: build/reports/jacoco - target-folder: docs/${{ env.PROJECT_VERSION }}/jacoco - - name: Deploy to GitHub Pages - uses: JamesIves/github-pages-deploy-action@v4.2.2 - with: - branch: gh-pages - clean: true - folder: build/docs/javadoc - target-folder: docs/${{ env.PROJECT_VERSION }}/javadoc \ No newline at end of file + - name: Build with Gradle + run: ./gradlew clean build \ No newline at end of file diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 46675f9ad..b849e0426 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,18 +1,13 @@ -# This workflow uses actions that are not certified by GitHub. -# They are provided by a third-party and are governed by -# separate terms of service, privacy policy, and support -# documentation. - name: Publish package to GitHub Packages and Maven Central on: release: types: [created] jobs: publish: - runs-on: ubuntu-latest - permissions: + runs-on: ubuntu-latest + permissions: contents: read - packages: write + packages: write steps: - uses: actions/checkout@v2 - uses: actions/setup-java@v2 @@ -26,10 +21,10 @@ jobs: - name: Publish package uses: gradle/gradle-build-action@v2 with: - arguments: publish + arguments: publish closeAndReleaseStagingRepository env: GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }} GPG_SIGNING_KEY_PASSWORD: ${{ secrets.GPG_SIGNING_KEY_PASSWORD }} - MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }} - MAVEN_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }} + MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/build.gradle b/build.gradle index 90b549d81..c54495212 100644 --- a/build.gradle +++ b/build.gradle @@ -7,10 +7,11 @@ plugins { id 'jacoco' id 'signing' id 'maven-publish' + id('io.github.gradle-nexus.publish-plugin') version '1.1.0' } -group = 'com.syntifi.casper' -version = '0.2.1' +group = 'network.casper' +version = '0.5.0-SNAPSHOT' sourceCompatibility = '8' repositories { @@ -48,12 +49,30 @@ java { withSourcesJar() } +task casperJar(type: Jar) { + archiveBaseName = 'casper-java-sdk' + archiveVersion = "$version" + from { configurations.compileClasspath.findAll { it.isDirectory() ? it : zipTree(it) } } + with jar +} + javadoc { if (JavaVersion.current().isJava9Compatible()) { options.addBooleanOption('html5', true) } } +nexusPublishing { + repositories { + sonatype { //only for users registered in Sonatype after 24 Feb 2021 + nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/")) + snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")) + username.set(System.getenv('MAVEN_USERNAME')) + password.set(System.getenv('MAVEN_PASSWORD')) + } + } +} + test { finalizedBy jacocoTestReport @@ -106,19 +125,9 @@ jacocoTestReport { publishing { repositories { - maven { - name = 'OSSRH' - def releasesRepoUrl = 'https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/' - def snapshotsRepoUrl = 'https://s01.oss.sonatype.org/content/repositories/snapshots/' - url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl - credentials { - username = System.getenv('MAVEN_USERNAME') - password = System.getenv('MAVEN_PASSWORD') - } - } maven { name = "GitHubPackages" - url = "https://maven.pkg.github.com/syntifi/casper-sdk" + url = "https://maven.pkg.github.com/casper-network/casper-java-sdk" credentials { username = System.getenv("GITHUB_ACTOR") password = System.getenv("GITHUB_TOKEN") @@ -128,34 +137,34 @@ publishing { publications { mavenJava(MavenPublication) { - artifactId = 'casper-sdk' + artifactId = 'casper-java-sdk' from components.java pom { - name = 'Java 8+ Casper RPC Client SDK' + name = 'Casper Java SDK' packaging = 'jar' - description = 'This project implements the SDK to interact with a Casper Node. It wraps the Json-RPC requests and maps the results to Java objects.' - url = 'https://github.com/syntifi/casper-sdk' + description = 'SDK to streamline the 3rd party Java client integration processes. Such 3rd parties include exchanges & app developers.' + url = 'https://github.com/casper-network/casper-java-sdk' scm { - connection = 'scm:git:https://github.com/syntifi/casper-sdk.git' - developerConnection = 'git@github.com:syntifi/casper-sdk.git' - url = 'https://github.com/syntifi/casper-sdk' + connection = 'scm:git:https://github.com/casper-network/casper-java-sdk.git' + developerConnection = 'git@github.com:casper-network/casper-java-sdk.git' + url = 'https://github.com/casper-network/casper-java-sdk' } issueManagement { system = 'GitHub' - url = 'https://github.com/syntifi/casper-sdk/issues' + url = 'https://github.com/casper-network/casper-java-sdk/issues' } ciManagement { system = 'Github Actions' - url = 'https://github.com/syntifi/casper-sdk/actions' + url = 'https://github.com/casper-network/casper-java-sdk/actions' } licenses { license { name = 'The Apache License, Version 2.0' - url = 'https://www.apache.org/licenses/LICENSE-2.0.txt' + url = 'http://www.apache.org/licenses/LICENSE-2.0.txt' } } @@ -170,16 +179,31 @@ publishing { name = 'Andre Bertolace' email = 'andre@syntifi.com' } + developer { + id = 'meywood' + name = 'Ian Mills' + email = 'ian@meywood.com' + } + developer { + id = 'stormeye' + name = 'Carl Norburn' + email = 'carl@stormeye.co.uk' + } } } } } -} -// Reference at https://docs.gradle.org/current/userguide/signing_plugin.html#sec:in-memory-keys -signing { - def signingKey = System.getenv('GPG_SIGNING_KEY') ?: findProperty('GPG_SIGNING_KEY') - def signingKeyPassword = System.getenv('GPG_SIGNING_KEY_PASSWORD') ?: findProperty('GPG_SIGNING_KEY_PASSWORD') - useInMemoryPgpKeys(signingKey, signingKeyPassword) - sign publishing.publications.mavenJava + jar { + archiveClassifier = '' + } + + // Reference at https://docs.gradle.org/current/userguide/signing_plugin.html#sec:in-memory-keys + signing { + def signingKey = System.getenv('GPG_SIGNING_KEY') ?: findProperty('GPG_SIGNING_KEY') + def signingKeyPassword = System.getenv('GPG_SIGNING_KEY_PASSWORD') ?: findProperty('GPG_SIGNING_KEY_PASSWORD') + + useInMemoryPgpKeys(signingKey, signingKeyPassword) + sign publishing.publications.mavenJava + } } diff --git a/src/main/java/com/casper/sdk/model/event/DataType.java b/src/main/java/com/casper/sdk/model/event/DataType.java index 0dde7effa..273224f58 100644 --- a/src/main/java/com/casper/sdk/model/event/DataType.java +++ b/src/main/java/com/casper/sdk/model/event/DataType.java @@ -27,7 +27,7 @@ public enum DataType { SHUTDOWN(Shutdown.class), STEP(Step.class); - + /** The EventData class for the data type */ private Class dataType; DataType(Class dataType) { diff --git a/src/main/java/com/casper/sdk/service/CasperService.java b/src/main/java/com/casper/sdk/service/CasperService.java index 55ccea2c7..e94ddb472 100644 --- a/src/main/java/com/casper/sdk/service/CasperService.java +++ b/src/main/java/com/casper/sdk/service/CasperService.java @@ -247,5 +247,4 @@ DictionaryData getStateDictionaryItem(@JsonRpcParam("state_root_hash") String st StoredValueData getStateItem(@JsonRpcParam("state_root_hash") String stateRootHash, @JsonRpcParam("key") String key, @JsonRpcParam("path") List path); - } diff --git a/src/test/java/com/casper/sdk/service/CasperServiceTests.java b/src/test/java/com/casper/sdk/service/CasperServiceTests.java index 84278bed5..fa192297d 100644 --- a/src/test/java/com/casper/sdk/service/CasperServiceTests.java +++ b/src/test/java/com/casper/sdk/service/CasperServiceTests.java @@ -1,25 +1,24 @@ package com.casper.sdk.service; -import java.io.IOException; -import java.math.BigInteger; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - import com.casper.sdk.exception.CasperClientException; import com.casper.sdk.identifier.block.BlockIdentifier; import com.casper.sdk.identifier.block.HashBlockIdentifier; import com.casper.sdk.identifier.block.HeightBlockIdentifier; import com.casper.sdk.model.account.AccountData; import com.casper.sdk.model.auction.AuctionData; +import com.casper.sdk.model.block.JsonBlock; +import com.casper.sdk.model.block.JsonBlockData; import com.casper.sdk.model.clvalue.CLValueString; import com.casper.sdk.model.clvalue.encdec.StringByteHelper; +import com.casper.sdk.model.deploy.DeployData; import com.casper.sdk.model.deploy.executabledeploy.ModuleBytes; import com.casper.sdk.model.deploy.executabledeploy.StoredContractByHash; import com.casper.sdk.model.deploy.executionresult.Success; import com.casper.sdk.model.deploy.transform.WriteCLValue; import com.casper.sdk.model.era.EraInfoData; +import com.casper.sdk.model.key.AlgorithmTag; import com.casper.sdk.model.key.PublicKey; +import com.casper.sdk.model.peer.PeerData; import com.casper.sdk.model.stateroothash.StateRootHashData; import com.casper.sdk.model.status.StatusData; import com.casper.sdk.model.storedvalue.StoredValueAccount; @@ -27,20 +26,21 @@ import com.casper.sdk.model.storedvalue.StoredValueData; import com.casper.sdk.model.transfer.Transfer; import com.casper.sdk.model.transfer.TransferData; -import com.casper.sdk.model.block.JsonBlock; -import com.casper.sdk.model.block.JsonBlockData; -import com.casper.sdk.model.deploy.DeployData; -import com.casper.sdk.model.key.AlgorithmTag; -import com.casper.sdk.model.peer.PeerData; - import com.casper.sdk.model.validator.ValidatorChangeData; -import com.fasterxml.jackson.databind.JsonNode; import org.json.JSONException; +import org.junit.Ignore; import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.io.IOException; +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + import static org.junit.jupiter.api.Assertions.*; /** @@ -112,6 +112,7 @@ void retrieveLastBlock() { } @Test + @Disabled void getBlockByHash() { JsonBlockData blockData = casperServiceMainnet.getBlock(new HashBlockIdentifier("2fe9630b7790852e4409d815b04ca98f37effcdf9097d317b9b9b8ad658f47c8")); @@ -122,6 +123,7 @@ void getBlockByHash() { } @Test + @Disabled void getBlockByHeight() { JsonBlockData blockData = casperServiceMainnet.getBlock(new HeightBlockIdentifier(0)); JsonBlock block = blockData.getBlock(); diff --git a/src/test/java/com/casper/sdk/service/EventServiceIntegrationTest.java b/src/test/java/com/casper/sdk/service/EventServiceIntegrationTest.java index 4b72c00f2..0d86efe2e 100644 --- a/src/test/java/com/casper/sdk/service/EventServiceIntegrationTest.java +++ b/src/test/java/com/casper/sdk/service/EventServiceIntegrationTest.java @@ -11,6 +11,7 @@ import com.casper.sdk.test.PathMatchingResourceDispatcher; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import java.io.IOException; @@ -21,6 +22,7 @@ import static org.hamcrest.Matchers.*; import static org.hamcrest.core.Is.is; +@Disabled class EventServiceIntegrationTest { private static final String MAIN_EVENTS = "/event-samples/main-events.txt"; diff --git a/src/test/java/com/casper/sdk/service/impl/event/EventBuilderTest.java b/src/test/java/com/casper/sdk/service/impl/event/EventBuilderTest.java index a9d6eef75..f9a3f5383 100644 --- a/src/test/java/com/casper/sdk/service/impl/event/EventBuilderTest.java +++ b/src/test/java/com/casper/sdk/service/impl/event/EventBuilderTest.java @@ -18,6 +18,7 @@ import com.casper.sdk.model.key.PublicKey; import org.joda.time.DateTime; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import java.io.BufferedReader; @@ -152,6 +153,7 @@ void buildDeployAcceptedEvent() throws IOException { } @Test + @Disabled void buildDeployProcessedEvent() throws IOException { final PojoEvent deployProcessedEvent = getEvent(EventType.MAIN, EventTarget.POJO, DEPLOY_PROCESSED_EVENT); @@ -190,6 +192,7 @@ void buildFaultEvent() throws IOException, InvalidByteStringException, NoSuchAlg } @Test + @Disabled void buildStepEvent() throws IOException { final PojoEvent stepEvent = getEvent(EventType.MAIN, EventTarget.POJO, STEP_EVENT); @@ -198,6 +201,7 @@ void buildStepEvent() throws IOException { @Test + @Disabled void buildRawShutDownEvent() throws IOException { final RawEvent shutdownEvent = getEvent(EventType.MAIN, EventTarget.RAW, SHUTDOWN_EVENT);