From 685cbf63b6f05a2d190e17615f0cdc250e69922f Mon Sep 17 00:00:00 2001 From: Mirza Karacic Date: Thu, 21 Nov 2024 15:14:43 -0800 Subject: [PATCH] Adding dev flows --- .github/actions/release-to-jfrog/actions.yaml | 53 +++++++++ .github/actions/run-ee-server/action.yaml | 44 ++++++++ .github/actions/upload-to-jfrog/action.yaml | 62 +++++++++++ .../wait-for-as-server-to-start/action.yaml | 22 ++++ .github/workflows/build-dev.yaml | 87 +++++++++++++++ .github/workflows/build.yaml | 101 ++++++++++++++++++ .github/workflows/build.yml | 21 ---- .github/workflows/pull-request-open-dev.yaml | 36 +++++++ .github/workflows/push-to-dev.yaml | 16 +++ client/pom.xml | 35 ++++++ pom.xml | 1 + 11 files changed, 457 insertions(+), 21 deletions(-) create mode 100644 .github/actions/release-to-jfrog/actions.yaml create mode 100644 .github/actions/run-ee-server/action.yaml create mode 100644 .github/actions/upload-to-jfrog/action.yaml create mode 100644 .github/actions/wait-for-as-server-to-start/action.yaml create mode 100644 .github/workflows/build-dev.yaml create mode 100644 .github/workflows/build.yaml delete mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/pull-request-open-dev.yaml create mode 100644 .github/workflows/push-to-dev.yaml diff --git a/.github/actions/release-to-jfrog/actions.yaml b/.github/actions/release-to-jfrog/actions.yaml new file mode 100644 index 000000000..18042b361 --- /dev/null +++ b/.github/actions/release-to-jfrog/actions.yaml @@ -0,0 +1,53 @@ +name: Publish artifacts to JFrog +description: Publishes artifacts to Sonatype + +inputs: + version: + description: "Version of client to build" + required: true + crypto-type: + description: Crypto type. This should either be bouncycastle or gnu + required: true + maven-username: + description: Maven repo username + required: true + maven-token: + description: Maven repo password + required: true + gpg-signing-key: + description: GPG private signing key + required: true + gpg-signing-key-password: + description: GPG private signing key password + required: true + module: + description: Module to publish + required: true + +runs: + using: "composite" + steps: + - name: Set version + shell: bash + run: mvn versions:set -DnewVersion=${{ inputs.version }} + + - name: Build + shell: bash + run: | + echo "-${{ inputs.crypto-type }}-" + mvn clean install -Dcrypto.type=${{ inputs.crypto-type }} + + - name: Build source jar + run: mvn source:jar -Dcrypto.type=${{ inputs.crypto-type }} + shell: bash + working-directory: ${{ inputs.module }} + + - name: Build docs + run: mvn javadoc:jar -Dcrypto.type=${{ inputs.crypto-type }} + shell: bash + working-directory: ${{ inputs.module }} + + - name: Debug list content + shell: bash + run: | + ls -R | grep ".*.jar" diff --git a/.github/actions/run-ee-server/action.yaml b/.github/actions/run-ee-server/action.yaml new file mode 100644 index 000000000..3476c2f9d --- /dev/null +++ b/.github/actions/run-ee-server/action.yaml @@ -0,0 +1,44 @@ +name: "Run EE Server" +description: "Run EE server. Returns once server is ready. Only tested on Linux and macOS" + +inputs: + # All inputs in composite actions are strings + use-server-rc: + description: Flag for rc candidates + required: true + default: "false" + server-tag: + description: Server version to use + required: true + default: "latest" + # Github Composite Actions can't access secrets + # so we need to pass them in as inputs + docker-hub-username: + description: Dockerhub username + required: false + docker-hub-password: + description: Dockerhub password + required: false + container-repo-url: + required: false + description: Container repo url + default: aerospike.jfrog.io/docker/ + +runs: + using: "composite" + steps: + - name: Log into Docker Hub to get server RC + if: ${{ inputs.use-server-rc == 'true' }} + run: docker login ${{ inputs.container-repo-url }} --username ${{ inputs.docker-hub-username }} --password ${{ inputs.docker-hub-password }} + shell: bash + + - run: echo IMAGE_NAME=${{ inputs.use-server-rc == 'true' && inputs.container-repo-url || '' }}aerospike/aerospike-server-enterprise${{ inputs.use-server-rc == 'true' && '-rc' || '' }}:${{ inputs.server-tag }} >> $GITHUB_ENV + shell: bash + + - run: docker run -d --name aerospike -p 3000:3000 ${{ env.IMAGE_NAME }} + shell: bash + + - uses: ./.github/actions/wait-for-as-server-to-start + with: + container-name: aerospike + is-security-enabled: true diff --git a/.github/actions/upload-to-jfrog/action.yaml b/.github/actions/upload-to-jfrog/action.yaml new file mode 100644 index 000000000..8e63b6a82 --- /dev/null +++ b/.github/actions/upload-to-jfrog/action.yaml @@ -0,0 +1,62 @@ +name: Publish artifacts to JFrog +description: "Publishes artifacts to JFrog" + +inputs: + version: + description: "" + required: true + jdk-version: + description: "" + required: true + jfrog-releases-repo-name: + description: "" + required: false + default: aerospike-maven-dev-local + jfrog-snapshots-repo-name: + description: "" + required: false + default: aerospike-maven-preview-internal-local + jfrog-platform-url: + description: "" + required: false + default: https://aerospike.jfrog.io/ + oidc-provider: + description: "" + required: false + default: gh-aerospike-clients + oidc-audience: + description: "" + required: false + default: aerospike/clients + crypto-type: + description: "" + required: false + default: gnu + +runs: + using: "composite" + steps: + - name: Set up JFrog credentials + uses: jfrog/setup-jfrog-cli@v3 + env: + JF_URL: ${{ inputs.jfrog-platform-url }} + with: + oidc-provider-name: ${{ inputs.oidc-provider }} + oidc-audience: ${{ inputs.oidc-audience }} + + #- name: Upload from branches to JFrog + # shell: bash + # # Only interested in `aerospike-proxy-client-x.x.x....` and `aerospike-client-jdkx-x.x.x....` + # run: jf rt upload --regexp=true "aerospike-(client-(jdk\d+))-(bc-)?\d+\.\d+\.\d+(-jar-with-dependencies|-javadoc|-sources)?\.jar" "${{ inputs.jfrog-repo-name }}" + + #- name: Publish build info + # shell: bash + # run: jf rt build-publish ${{ inputs.jdk-version == 'jdk8' && 'aerospike-client-jdk8' || 'aerospike-client-jdk21' }} ${{ inputs.version }} ${{ inputs.build-number }} + + - name: Deploy release + shell: bash + working-directory: client + run: | + jf --dry-run mvn-config --repo-deploy-releases=${{ inputs.jfrog-releases-repo-name }} --repo-deploy-snapshots=${{ inputs.jfrog-snapshots-repo-name }} + jf --dry-run mvn deploy -Dcrypto.type=${{ inputs.crypto-type == 'bouncycastle' && '-bc' || '' }} + jf rt bp --dry-run diff --git a/.github/actions/wait-for-as-server-to-start/action.yaml b/.github/actions/wait-for-as-server-to-start/action.yaml new file mode 100644 index 000000000..591c89434 --- /dev/null +++ b/.github/actions/wait-for-as-server-to-start/action.yaml @@ -0,0 +1,22 @@ +name: "Wait for Aerospike server to start" +description: Only tested on Linux and macOS +inputs: + container-name: + description: Container name + required: true + is-security-enabled: + description: Flag to toggle docker hub creds use. With this flag enabled before attempting to pull image we will attempt to log in do docker hub. + required: false + default: "false" + +runs: + using: "composite" + steps: + # Composite actions doesn't support step-level timeout-minutes + # Use timeout command and store polling logic in file to make it easier to read + # Call bash shell explicitly since timeout uses "sh" shell by default, for some reason + # Also, we don't want to fail if we timeout in case the server *did* finish starting up but the script couldn't detect it due to a bug + # Effectively, this composite action is like calling "sleep" that is optimized to exit early when it detects an ok from the server + - name: Wait for EE server to start + run: timeout 30 bash ./.github/workflows/scripts/wait-for-as-server-to-start.sh ${{ inputs.container-name }} ${{ inputs.is-security-enabled }} || true + shell: bash diff --git a/.github/workflows/build-dev.yaml b/.github/workflows/build-dev.yaml new file mode 100644 index 000000000..2a47beab5 --- /dev/null +++ b/.github/workflows/build-dev.yaml @@ -0,0 +1,87 @@ +on: + workflow_call: + inputs: + branch: + type: string + required: true + source-branch: + type: string + required: false + use-server-rc: + type: boolean + required: false + default: false + description: "Test against server release candidate?" + server-tag: + type: string + required: false + default: "latest" + description: "Server docker image tag" + upload-artifacts: + type: boolean + required: false + default: false + description: "Upload built artifacts to github?" + bump-version: + type: boolean + required: false + default: false + description: "Bump artifact version" + run-tests: + type: boolean + required: false + default: false + description: Spin up aerospike enterprise server and run tests + +jobs: + debug-job: + runs-on: ubuntu-latest + steps: + - name: debug + run: | + echo "${{ inputs.branch }}" + echo "${{ github.base_ref }}" + + java-version: + needs: debug-job + runs-on: ubuntu-latest + outputs: + java-version: ${{ steps.get-java-version.outputs.java-version }} + steps: + - name: Checkout client + uses: actions/checkout@v4 + with: + ref: ${{ inputs.branch }} + + - name: Get java version + id: get-java-version + run: | + echo java-version="$(grep '' pom.xml | sed -e 's/<[^>]*>//g' | awk '{$1=$1};1')" >> $GITHUB_OUTPUT + + - name: debug - print java-version + run: | + echo ${{ steps.get-java-version.outputs.java-version }} + + debug-java-version-job: + runs-on: ubuntu-latest + needs: java-version + steps: + - name: debug + run: | + echo "${{ needs.java-version.outputs.java-version }}" + + build: + uses: ./.github/workflows/build.yaml + needs: java-version + strategy: + matrix: + crypto-type: ["bouncycastle", "gnu"] + with: + java-version: ${{ needs.java-version.outputs.java-version }} + branch: ${{ inputs.branch }} + use-server-rc: ${{ inputs.use-server-rc }} + run-tests: ${{ inputs.run-tests }} + server-tag: ${{ inputs.server-tag }} + upload-artifacts: ${{ inputs.upload-artifacts }} + crypto-type: ${{ matrix.crypto-type }} + secrets: inherit diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 000000000..e342fd8dc --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,101 @@ +name: Build artifacts + +permissions: + # This is required for requesting the OIDC token + id-token: write + +on: + workflow_call: + inputs: + branch: + type: string + required: true + java-version: + type: string + required: true + use-server-rc: + type: boolean + required: false + default: false + description: "Test against server release candidate?" + server-tag: + type: string + required: false + default: "latest" + description: "Server docker image tag" + upload-artifacts: + type: boolean + required: false + default: false + description: "Upload built artifacts to github?" + run-tests: + type: boolean + required: false + default: false + description: Spin up aerospike enterprise server and run tests + crypto-type: + type: string + required: true + + secrets: + JFROG_USERNAME: + required: true + JFROG_DOCKER_TOKEN: + required: true + GPG_SECRET_KEY: + required: true + GPG_PASS: + required: true + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout client + uses: actions/checkout@v4 + with: + ref: ${{ inputs.branch }} + + - name: Setup Java + uses: actions/setup-java@v4 + with: + distribution: "semeru" # See 'Supported distributions' for available options + java-version: ${{ inputs.java-version }} + gpg-private-key: ${{ secrets.GPG_SECRET_KEY }} + gpg-passphrase: ${{ secrets.GPG_PASS }} + + - name: Build + run: mvn install -Dcrypto.type=${{ inputs.crypto-type == 'bouncycastle' && '-bc' || '' }} + + - name: Run EE server + if: ${{ inputs.run-tests == true }} + uses: ./.github/actions/run-ee-server + with: + use-server-rc: ${{ inputs.use-server-rc }} + server-tag: ${{ inputs.server-tag }} + docker-hub-username: ${{ secrets.JFROG_USERNAME }} + docker-hub-password: ${{ secrets.JFROG_DOCKER_TOKEN }} + + - name: Test + if: ${{ inputs.run-tests == true }} + working-directory: test + run: mvn test -DskipTests=false + + - name: Generate docs jar + if: ${{ !cancelled() && inputs.upload-artifacts == true }} + working-directory: client + run: | + mvn javadoc:jar -Dcrypto.type=${{ inputs.crypto-type == 'bouncycastle' && '-bc' || '' }} + + - name: Generate sources jar + if: ${{ !cancelled() && inputs.upload-artifacts == true }} + working-directory: client + run: | + mvn source:jar -Dcrypto.type=${{ inputs.crypto-type == 'bouncycastle' && '-bc' || '' }} + + - name: Upload to JFrog + if: ${{ !cancelled() && inputs.upload-artifacts == true }} + uses: ./.github/actions/upload-to-jfrog + with: + version: ${{ steps.get-new-version.outputs.new_version }} + jdk-version: "jdk${{ inputs.java-version }}" diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index d9bacbec2..000000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,21 +0,0 @@ -name: Aerospike Java Client Tests - -on: - push: - branches: - - master - pull_request: - branches: - - '**' - -jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Checkout client - uses: actions/checkout@v2 - - name: Setup Aerospike Database - uses: reugn/github-action-aerospike@v1 - - run: mvn install - - run: cd test - - run: mvn test -DskipTests=false diff --git a/.github/workflows/pull-request-open-dev.yaml b/.github/workflows/pull-request-open-dev.yaml new file mode 100644 index 000000000..bc8b0ae0b --- /dev/null +++ b/.github/workflows/pull-request-open-dev.yaml @@ -0,0 +1,36 @@ +name: PR open + +on: + pull_request: + branches: + - "dev/*" + types: + - opened + - reopened + workflow_dispatch: + inputs: + source-branch: + type: string + description: Base branch to use if manually starting. By default base_ref will empty if triggering manually hence base_ref is only available on PRs. + +jobs: + test-with-server-release: + name: Build stage - Test with latest version of Aerospike Enterprise Server + uses: ./.github/workflows/build-dev.yaml + with: + branch: ${{ github.ref }} + source-branch: ${{ inputs.source-branch || github.base_ref }} + use-server-rc: false + upload-artifacts: false + secrets: inherit + + test-with-server-rc: + name: Build stage - Test with latest RC version of Aerospike Enterprise Server + uses: ./.github/workflows/build-dev.yaml + with: + branch: ${{ github.base_ref || inputs.branch }} + source-branch: ${{ inputs.source-branch || github.base_ref }} + use-server-rc: true + upload-artifacts: false + run-tests: true + secrets: inherit diff --git a/.github/workflows/push-to-dev.yaml b/.github/workflows/push-to-dev.yaml new file mode 100644 index 000000000..32527321d --- /dev/null +++ b/.github/workflows/push-to-dev.yaml @@ -0,0 +1,16 @@ +name: Push to dev + +on: + push: + branches: + - dev/* + workflow_dispatch: + +jobs: + build-stage: + name: Build stage + uses: ./.github/workflows/build-dev.yaml + with: + branch: ${{ github.ref }} + upload-artifacts: true + secrets: inherit diff --git a/client/pom.xml b/client/pom.xml index 914fcc4c0..e12294f46 100644 --- a/client/pom.xml +++ b/client/pom.xml @@ -69,7 +69,36 @@ + + + sign + + false + + + + + org.apache.maven.plugins + maven-gpg-plugin + 3.2.7 + + + sign-artifacts + verify + + sign + + + + + + + + + + aerospike-client-jdk${java.version}${crypto.type}-${version} + ${project.basedir}/src @@ -78,6 +107,12 @@ + + org.apache.maven.plugins + maven-gpg-plugin + 3.2.7 + + org.apache.maven.plugins maven-compiler-plugin diff --git a/pom.xml b/pom.xml index 5f17a6604..69de7341c 100644 --- a/pom.xml +++ b/pom.xml @@ -43,6 +43,7 @@ 0.4 1.9.0 4.13.1 +