[CLIENT-3033] Add CI/CD workflow that tests proxy client against a proxy server build from JFrog #77
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and upload proxy client to JFrog | |
on: | |
pull_request: | |
push: | |
branches: | |
- stage | |
# TODO: snapshots_private has been removed from base parent pom.xml. Need to add workflow code to write snapshots_private to local pipeline pom.xml (this workflow will not work until that is done) | |
jobs: | |
build: | |
env: | |
JFROG_URL: https://aerospike.jfrog.io | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout Java client | |
uses: actions/checkout@v4 | |
- name: Set up settings.xml for Maven | |
uses: s4u/maven-settings-action@v2.8.0 | |
with: | |
servers: '[{"id": "snapshots", "username": "${{ secrets.JFROG_USERNAME }}", "password": "${{ secrets.JFROG_MAVEN_TOKEN }}"}]' | |
- name: Run Aerospike server | |
run: docker run -d --name aerospike -p 3000:3000 aerospike/aerospike-server | |
- run: docker login aerospike.jfrog.io --username ${{ secrets.JFROG_USERNAME }} --password ${{ secrets.JFROG_DOCKER_TOKEN }} | |
# TODO: change to use "latest" tag | |
- name: Get all tags for proxy server Docker image | |
run: docker pull --all-tags ${{ vars.JFROG_PROXY_SERVER_DOCKER_REPO }} | |
# If we try to emulate aarch64 and run a proxy server Docker image designed for aarch64, the log file won't exist in the container | |
# i.e there won't be any output in `docker logs` for the proxy server. | |
# so we can't tell if the proxy server is running or not | |
- name: Get the latest tag for proxy server for this CPU platform | |
run: echo LATEST_TAG=$(docker images --filter label="architecture=$(uname -m)" ${{ vars.JFROG_PROXY_SERVER_DOCKER_REPO }} --format json | jq -r '.Tag' | head -n 1) >> $GITHUB_ENV | |
# Enables pipefail | |
shell: bash | |
- name: Run Aerospike Proxy on latest tag | |
# TODO: not sure why aerospike-proxy.yml couldn't be included in Docker image... | |
run: docker run -d --name aerospike-proxy -p 4000:4000 --network=host -v ./aerospike-proxy.yml:/etc/aerospike-proxy/aerospike-proxy.yml ${{ vars.JFROG_PROXY_SERVER_DOCKER_REPO }}:${{ env.LATEST_TAG }} | |
working-directory: .github/workflows/test-configs | |
- name: Wait for native and proxy server to start | |
run: sleep 3 | |
- uses: jfrog/setup-jfrog-cli@v4 | |
env: | |
JF_URL: ${{ env.JFROG_URL }} | |
JF_USER: ${{ secrets.JFROG_USERNAME }} | |
JF_PASSWORD: ${{ secrets.JFROG_MAVEN_TOKEN }} | |
JF_PROJECT: "clients" | |
- run: jf mvn-config --repo-deploy-releases clients-maven-dev-local --repo-deploy-snapshots clients-maven-dev-local | |
- run: sudo apt install -y libxml-xpath-perl | |
- name: Get Java proxy client version | |
id: get-proxy-client-version | |
# TODO: find a way to do this via java ecosystem instead of using generic cli tools | |
run: echo version=$(xpath -q -e "//project/version/text()" pom.xml) >> $GITHUB_OUTPUT | |
- name: Run Maven workflow | |
run: jf mvn deploy -Dtest=com.aerospike.test.SuiteAll -DfailIfNoTests=false -DskipTests=false --build-name=${{ steps.get-proxy-client-version.outputs.version }} --build-number=${{ github.run_number }} | |
- run: cat target/build-info.json | |
# TODO: For debugging. Remove later | |
- if: ${{ always() }} | |
run: docker container ps -a | |
- if: ${{ always() }} | |
run: docker logs aerospike | |
# TODO: docker logs prints nothing. Not sure why this happens | |
- if: ${{ always() }} | |
run: docker exec aerospike-proxy cat /var/log/aerospike-proxy/aerospike-proxy.log | |
# TODO: create release bundle | |
# Based on https://github.com/citrusleaf/devops/blob/master/jfrog/vector/deploy-to-jfrog.sh | |
# mvn deploy only uploads to JFrog but doesn't create a JFrog build | |
- name: Create JFrog build from uploaded artifacts | |
run: jf rt build-publish ${{ steps.get-proxy-client-version.outputs.version }} ${{ github.run_number }} | |
- run: sudo apt install -y moreutils | |
- name: Create file spec for release bundle | |
run: cat releasebundle-filespec.json | jq '.files[0].build = "${{ steps.get-proxy-client-version.outputs.version }}/${{ github.run_number }}"' | sponge releasebundle-filespec.json | |
working-directory: .github/workflows | |
shell: bash | |
- name: Create release bundle from JFrog build | |
# Platform URL required for lifecycle commands (e.g release bundle management) | |
run: jf release-bundle-create --signing-key=aerospike --project clients --sync --spec=./releasebundle-filespec.json aerospike-java-proxy-client ${{ steps.get-proxy-client-version.outputs.version }} | |
working-directory: .github/workflows | |
- name: Promote release bundle to DEV stage | |
run: jf release-bundle-promote --signing-key=aerospike --sync aerospike-java-proxy-client ${{ steps.get-proxy-client-version.outputs.version }} DEV | |
working-directory: .github/workflows |