From ea4e12c31bb0104364b09bcc290dfc0585792ba2 Mon Sep 17 00:00:00 2001 From: Jun Luo <4catcode@gmail.com> Date: Mon, 21 Aug 2023 16:33:37 +0800 Subject: [PATCH] Migrate to GitHub Actions. (#512) --- .circleci/config.yml | 73 ------------- .github/workflows/test-deploy.yml | 100 ++++++++++++++++++ after_deploy.sh | 16 --- build.gradle | 12 +++ src/main/java/org/stellar/sdk/KeyPair.java | 4 +- .../java/org/stellar/sdk/LedgerBounds.java | 2 +- .../org/stellar/sdk/SignedPayloadSigner.java | 7 +- .../java/org/stellar/sdk/SorobanServer.java | 2 +- .../org/stellar/sdk/TransactionBuilder.java | 2 +- .../stellar/sdk/TransactionPreconditions.java | 2 +- .../sdk/requests/AccountsRequestBuilder.java | 4 +- .../sorobanrpc/SorobanRpcErrorResponse.java | 2 +- .../sorobanrpc/SorobanRpcRequest.java | 2 +- .../sdk/responses/TransactionResponse.java | 2 +- .../sorobanrpc/SorobanRpcResponse.java | 2 +- 15 files changed, 128 insertions(+), 104 deletions(-) delete mode 100644 .circleci/config.yml create mode 100644 .github/workflows/test-deploy.yml delete mode 100755 after_deploy.sh diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 5ae388ee2..000000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,73 +0,0 @@ -version: 2.1 - -jobs: - test: - docker: - - image: circleci/openjdk:11 - steps: - - checkout - - run: ./gradlew check - shadow_jar: - docker: - - image: circleci/openjdk:11 - steps: - - checkout - - run: ./gradlew shadowJar - - persist_to_workspace: - root: build - paths: - - libs/stellar-sdk.jar - deploy: - docker: - - image: cimg/go:1.17 - steps: - - attach_workspace: - at: ./build - - run: - name: "Install github.com/github-release/github-release v0.10.0" - command: | - go get github.com/github-release/github-release@v0.10.0 - - run: - name: "Upload JAR to GitHub Release" - command: | - github-release upload -s ${GITHUB_TOKEN} -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -t ${CIRCLE_TAG} -f ./build/libs/stellar-sdk.jar -n java-stellar-sdk.jar - - after_deploy: - docker: - - image: circleci/openjdk:11 - steps: - - checkout - - run: ./after_deploy.sh - -workflows: - version: 2 - test-and-deploy: - jobs: - - test: - filters: # required since `deploy` has tag filters AND requires `build` - tags: - only: /.*/ - - shadow_jar: - requires: - - test - filters: - tags: - only: /.*/ - branches: - ignore: /.*/ - - deploy: - requires: - - shadow_jar - filters: - tags: - only: /.*/ - branches: - ignore: /.*/ - - after_deploy: - requires: - - deploy - filters: - tags: - only: /.*/ - branches: - ignore: /.*/ diff --git a/.github/workflows/test-deploy.yml b/.github/workflows/test-deploy.yml new file mode 100644 index 000000000..094cca8e9 --- /dev/null +++ b/.github/workflows/test-deploy.yml @@ -0,0 +1,100 @@ +name: "Test and Deploy" + +on: + push: + branches: + - master + - soroban + pull_request: + release: + types: + - created + +env: + JAVA_VERSION: '11' + JAVA_DISTRIBUTION: 'microsoft' + +jobs: + test: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + - name: Set up JDK + uses: actions/setup-java@v2 + with: + java-version: ${{ env.JAVA_VERSION }} + distribution: ${{ env.JAVA_DISTRIBUTION }} + - name: Test + run: ./gradlew check + + shadow_jar: + needs: test + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + - name: Set up JDK + uses: actions/setup-java@v2 + with: + java-version: ${{ env.JAVA_VERSION }} + distribution: ${{ env.JAVA_DISTRIBUTION }} + - name: Build JAR + run: ./gradlew shadowJar + - name: Persist JAR Artifact + uses: actions/upload-artifact@v3 + with: + name: jar + path: build/libs/stellar-sdk.jar + + javadoc: + needs: test + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + - name: Set up JDK + uses: actions/setup-java@v2 + with: + java-version: ${{ env.JAVA_VERSION }} + distribution: ${{ env.JAVA_DISTRIBUTION }} + - name: Generate Documentation + run: ./gradlew javadoc + - name: Persist Documentation + uses: actions/upload-artifact@v3 + with: + name: javadoc + path: javadoc + + deploy: + needs: [ shadow_jar, javadoc ] + permissions: + contents: write + if: github.event_name == 'release' && github.event.action == 'created' + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + - name: Download JAR Artifact + uses: actions/download-artifact@v2 + with: + name: jar + path: jar + - name: Download Java Documentation + uses: actions/download-artifact@v2 + with: + name: javadoc + path: javadoc + - name: Archive Documentation + run: tar -czf stellar-sdk-javadoc.tar.gz javadoc + - name: Upload artifacts to GitHub Release + uses: softprops/action-gh-release@v1 + with: + files: | + jar/stellar-sdk.jar + stellar-sdk-javadoc.tar.gz + - name: Upload Documentation to GitHub Pages + uses: JamesIves/github-pages-deploy-action@v4 + with: + folder: javadoc + diff --git a/after_deploy.sh b/after_deploy.sh deleted file mode 100755 index 4df2347b8..000000000 --- a/after_deploy.sh +++ /dev/null @@ -1,16 +0,0 @@ -echo "machine github.com login stellar-jenkins password $GITHUB_TOKEN" >~/.netrc -git clone -b gh-pages "https://stellar-jenkins@github.com/stellar/java-stellar-sdk.git" javadoc - -if [ ! -d "javadoc" ]; then - echo "Error cloning" - exit 1 -fi - -rm -rf javadoc/* # Remove all files without hidden (.git) -javadoc -public -splitindex -windowtitle "java-stellar-sdk documentation" -d ./javadoc -sourcepath ./src/main/java/ -subpackages org.stellar.sdk -exclude org.stellar.sdk.xdr -cd javadoc -git config user.name "post-release-script" -git config user.email "post-release-script@stellar.org" -git add . -git commit -m $CIRCLE_TAG -git push origin gh-pages diff --git a/build.gradle b/build.gradle index 6c700d0f0..7a6ba7ef8 100644 --- a/build.gradle +++ b/build.gradle @@ -102,4 +102,16 @@ tasks.register('updateGitHook', Copy) { rename { fileName -> fileName.endsWith('.sh') ? fileName[0..-4] : fileName } +} + +tasks.javadoc { + destinationDir = file('javadoc') + failOnError = true + exclude("org/stellar/sdk/xdr/**") + // cast options to StandardJavadocDocletOptions + // https://docs.gradle.org/current/javadoc/org/gradle/external/javadoc/StandardJavadocDocletOptions.html + StandardJavadocDocletOptions options = options as StandardJavadocDocletOptions + options.setSplitIndex(true) + options.setMemberLevel(JavadocMemberLevel.PUBLIC) + options.setEncoding('UTF-8') } \ No newline at end of file diff --git a/src/main/java/org/stellar/sdk/KeyPair.java b/src/main/java/org/stellar/sdk/KeyPair.java index 9787b5fe0..55533db5a 100644 --- a/src/main/java/org/stellar/sdk/KeyPair.java +++ b/src/main/java/org/stellar/sdk/KeyPair.java @@ -266,8 +266,8 @@ public DecoratedSignature signDecorated(byte[] data) { /** * Sign the provided payload data for payload signer where the input is the data being signed. Per * the {@link DecoratedSignature}. + * href="https://github.com/stellar/stellar-protocol/blob/master/core/cap-0040.md#signature-hint">CAP-40 + * Signature spec {@link DecoratedSignature}. * * @param signerPayload the payload signers raw data to sign * @return DecoratedSignature diff --git a/src/main/java/org/stellar/sdk/LedgerBounds.java b/src/main/java/org/stellar/sdk/LedgerBounds.java index 37c75ac15..057cb78a2 100644 --- a/src/main/java/org/stellar/sdk/LedgerBounds.java +++ b/src/main/java/org/stellar/sdk/LedgerBounds.java @@ -8,7 +8,7 @@ @lombok.Builder /** * LedgerBounds are Preconditions of a transaction per CAP-21 + * href="https://github.com/stellar/stellar-protocol/blob/master/core/cap-0021.md#specification">CAP-21 */ public class LedgerBounds { long minLedger; diff --git a/src/main/java/org/stellar/sdk/SignedPayloadSigner.java b/src/main/java/org/stellar/sdk/SignedPayloadSigner.java index 3b1d381bb..0eb30b16b 100644 --- a/src/main/java/org/stellar/sdk/SignedPayloadSigner.java +++ b/src/main/java/org/stellar/sdk/SignedPayloadSigner.java @@ -9,8 +9,8 @@ /** * Data model for the signed - * payload signer + * href="https://github.com/stellar/stellar-protocol/blob/master/core/cap-0040.md#xdr-changes" + * target="_blank">signed payload signer */ public class SignedPayloadSigner { public static final int SIGNED_PAYLOAD_MAX_PAYLOAD_LENGTH = 64; @@ -72,7 +72,8 @@ public AccountID getSignerAccountId() { * get the payload that signatures are produced from. * * @see + * href="https://github.com/stellar/stellar-protocol/blob/master/core/cap-0040.md#semantics">CAP-0040 + * Semantics * @return */ public byte[] getPayload() { diff --git a/src/main/java/org/stellar/sdk/SorobanServer.java b/src/main/java/org/stellar/sdk/SorobanServer.java index ff7f29aac..b038ab437 100644 --- a/src/main/java/org/stellar/sdk/SorobanServer.java +++ b/src/main/java/org/stellar/sdk/SorobanServer.java @@ -340,7 +340,7 @@ public SimulateTransactionResponse simulateTransaction(Transaction transaction) * Submit a trial contract invocation, first run a simulation of the contract invocation as * defined on the incoming transaction, and apply the results to a new copy of the transaction * which is then returned. Setting the ledger footprint and authorization, so the resulting - * transaction is ready for signing & sending. + * transaction is ready for signing and sending. * *
The returned transaction will also have an updated fee that is the sum of fee set on
* incoming transaction with the contract resource fees estimated from simulation. It is advisable
diff --git a/src/main/java/org/stellar/sdk/TransactionBuilder.java b/src/main/java/org/stellar/sdk/TransactionBuilder.java
index c1b900697..44dcb4794 100644
--- a/src/main/java/org/stellar/sdk/TransactionBuilder.java
+++ b/src/main/java/org/stellar/sdk/TransactionBuilder.java
@@ -89,7 +89,7 @@ public TransactionBuilder addOperations(Collection