Skip to content

Make "latest" refer to latest release branch (#76) #225

Make "latest" refer to latest release branch (#76)

Make "latest" refer to latest release branch (#76) #225

name: Building Image, Running Benchmarks and Deploying to Dockerhub
on:
# Launch on manual trigger
workflow_dispatch:
# Launch on any push
push:
pull_request:
# Launch on PRs *towards* these branches
branches:
- 'release-**'
- main
# Not running on "closed" - that is taken care of by "push" (if merged)
types: [opened, synchronize, reopened]
env:
BASE_DEPLOY_URL: https://repo.hops.works/master
ARM_IMAGE_NAME: rondb-standalone-arm64
X86_IMAGE_NAME: rondb-standalone-amd64
RONDB_VERSION_LTS: 21.04.16
LTS_X86_TARBALL_NAME: rondb-21.04.16-linux-glibc2.17-x86_64.tar.gz
LTS_ARM_TARBALL_NAME: rondb-21.04.16-linux-glibc2.35-arm64_v8.tar.gz
RONDB_VERSION_STABLE: 22.10.3
STABLE_X86_TARBALL_NAME: rondb-22.10.3-linux-glibc2.28-x86_64.tar.gz
STABLE_ARM_TARBALL_NAME: rondb-22.10.3-linux-glibc2.28-arm64_v8.tar.gz
jobs:
check-git:
runs-on: ubuntu-latest
outputs:
is_highest_release: ${{ steps.is_highest_release.outputs.is_highest }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check if current branch is the highest release branch
if: github.repository == 'logicalclocks/rondb-docker'
id: is_highest_release
run: |
ALL_RELEASES=$(git branch -r | grep 'origin/release-' | sed 's|origin/||')
HIGHEST_RELEASE=$(echo "$ALL_RELEASES" | sort -V | tail -n 1)
echo "Highest release branch is $HIGHEST_RELEASE"
if [ "${GITHUB_REF_NAME}" = "$HIGHEST_RELEASE" ]; then
echo "Current branch is the highest release branch."
echo "is_highest=true" >> $GITHUB_ENV
else
echo "is_highest=false" >> $GITHUB_ENV
fi
integration-test-and-package:
runs-on: ubuntu-latest
needs: [check-git]
steps:
- uses: actions/checkout@v4
- name: Build and run Docker Compose cluster with benchmarking for RONDB_VERSION_LTS
run: |
./run.sh -lv \
--rondb-tarball-url $BASE_DEPLOY_URL/$LTS_X86_TARBALL_NAME \
--rondb-version $RONDB_VERSION_LTS \
--size mini \
--run-benchmark sysbench_single \
--detached
- name: Wait for one container exit or timeout
run: |
start=`date +%s`
while true; do
end=`date +%s`
runtime=$((end-start))
if [ $( docker container ls --filter "status=exited" | grep rondb | wc -l ) -gt 0 ]; then
echo "One container is down. We can continue"
docker container ls --filter "status=exited"
exit 0
elif [ $runtime -gt 800 ]; then
echo "The benchmarking seems to be stuck. We're aborting now."
docker ps
exit 1
fi
sleep 2
done
- run: docker container ls
- run: docker logs mgmd_1
- run: docker logs ndbd_1
- run: docker logs mysqld_1
- run: docker logs rest_1
- run: docker logs bench_1
# At this point we only know that one container has exited. We want to
# check whether the bench container has exited with exit code 0. We need
# both status and exit code to do so, since Docker reports exit code 0
# for running containers.
- name: Check Benchmarking Exit Code
run: |
if [ "$(docker inspect bench_1 --format='{{.State.Status}}')" != "exited" ]
then
echo "Some container other than bench_1 exited unexpectedly."
docker ps -a
exit 1
elif [ "$(docker inspect bench_1 --format='{{.State.ExitCode}}')" != "0" ]
then
echo "Benchmarking failed."
cat autogenerated_files/*/volumes/sysbench_single/sysbench_results/oltp_rw_0_0.res
exit 1
fi
- name: Printing Sysbench results
run: cat autogenerated_files/*/volumes/sysbench_single/final_result.txt
- name: Login to Dockerhub
uses: docker/login-action@v2
if: github.repository == 'logicalclocks/rondb-docker' && (startsWith(github.ref_name, 'release-') || github.ref_name == 'main')
with:
username: hopsworks
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build X86 image for RONDB_VERSION_STABLE
if: github.repository == 'logicalclocks/rondb-docker' && (startsWith(github.ref_name, 'release-') || github.ref_name == 'main')
run: |
VERSION="$(< "./VERSION" sed -e 's/^[[:space:]]*//')"
docker buildx build . \
--tag rondb-standalone:$RONDB_VERSION_STABLE-$VERSION \
--build-arg RONDB_VERSION=$RONDB_VERSION_STABLE \
--build-arg RONDB_TARBALL_LOCAL_REMOTE=remote \
--build-arg RONDB_X86_TARBALL_URI=$BASE_DEPLOY_URL/$STABLE_X86_TARBALL_NAME
- name: Push X86 images to Dockerhub
if: github.repository == 'logicalclocks/rondb-docker' && (startsWith(github.ref_name, 'release-') || github.ref_name == 'main')
run: |
VERSION="$(< "./VERSION" sed -e 's/^[[:space:]]*//')"
docker tag rondb-standalone:$RONDB_VERSION_LTS-$VERSION hopsworks/$X86_IMAGE_NAME:$RONDB_VERSION_LTS-$VERSION
docker tag rondb-standalone:$RONDB_VERSION_STABLE-$VERSION hopsworks/$X86_IMAGE_NAME:$RONDB_VERSION_STABLE-$VERSION
docker push hopsworks/$X86_IMAGE_NAME:$RONDB_VERSION_LTS-$VERSION
docker push hopsworks/$X86_IMAGE_NAME:$RONDB_VERSION_STABLE-$VERSION
# Our "latest" branch points to the latest *release* branch.
- name: Push X86 *latest* images to Dockerhub
if: github.repository == 'logicalclocks/rondb-docker' && needs.check-git.outputs.is_highest_release == 'true'
run: |
VERSION="$(< "./VERSION" sed -e 's/^[[:space:]]*//')"
docker tag rondb-standalone:$RONDB_VERSION_LTS-$VERSION hopsworks/$X86_IMAGE_NAME:$RONDB_VERSION_LTS-latest
docker tag rondb-standalone:$RONDB_VERSION_STABLE-$VERSION hopsworks/$X86_IMAGE_NAME:$RONDB_VERSION_STABLE-latest
docker tag rondb-standalone:$RONDB_VERSION_STABLE-$VERSION hopsworks/$X86_IMAGE_NAME:latest
docker push hopsworks/$X86_IMAGE_NAME:$RONDB_VERSION_LTS-latest
docker push hopsworks/$X86_IMAGE_NAME:$RONDB_VERSION_STABLE-latest
docker push hopsworks/$X86_IMAGE_NAME:latest
build-and-push-ARM64:
runs-on: ubuntu-latest
if: github.repository == 'logicalclocks/rondb-docker' && (startsWith(github.ref_name, 'release-') || github.ref_name == 'main')
needs: [check-git]
env:
is_highest_release: ${{ needs.check-git.outputs.is_highest_release == 'true' }}
steps:
- uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Dockerhub
uses: docker/login-action@v2
with:
username: hopsworks
password: ${{ secrets.DOCKERHUB_TOKEN }}
# We're skipping the benchmarking on ARM64 as we assume this will be run on a regular basis
# during development. ARM64 images are only for development anyways. It is more important to add
# all types of benchmarking to the tests.
- name: Build and push ARM64 image for RONDB_VERSION_LTS
run: |
VERSION="$(< "./VERSION" sed -e 's/^[[:space:]]*//')"
TAGS="hopsworks/$ARM_IMAGE_NAME:$RONDB_VERSION_LTS-$VERSION"
if [[ "$is_highest_release" == "true" ]]; then
TAGS+=" --tag hopsworks/$ARM_IMAGE_NAME:$RONDB_VERSION_LTS-latest"
fi
docker buildx build . \
--tag $TAGS \
--platform=linux/arm64 \
--output type=registry \
--build-arg RONDB_VERSION=$RONDB_VERSION_LTS \
--build-arg RONDB_TARBALL_LOCAL_REMOTE=remote \
--build-arg RONDB_ARM_TARBALL_URI=$BASE_DEPLOY_URL/$LTS_ARM_TARBALL_NAME \
--cache-to type=registry,ref=hopsworks/rondb-standalone-cache,mode=max \
--cache-from type=registry,ref=hopsworks/rondb-standalone-cache,mode=max
- name: Build and push ARM64 image for RONDB_VERSION_STABLE
run: |
VERSION="$(< "./VERSION" sed -e 's/^[[:space:]]*//')"
TAGS="--tag hopsworks/$ARM_IMAGE_NAME:$RONDB_VERSION_STABLE-$VERSION"
if [[ "$is_highest_release" == "true" ]]; then
TAGS+=" --tag hopsworks/$ARM_IMAGE_NAME:$RONDB_VERSION_STABLE-latest"
TAGS+=" --tag hopsworks/$ARM_IMAGE_NAME:latest"
fi
docker buildx build . \
$TAGS \
--platform=linux/arm64 \
--output type=registry \
--build-arg RONDB_VERSION=$RONDB_VERSION_STABLE \
--build-arg RONDB_TARBALL_LOCAL_REMOTE=remote \
--build-arg RONDB_ARM_TARBALL_URI=$BASE_DEPLOY_URL/$STABLE_ARM_TARBALL_NAME \
--cache-to type=registry,ref=hopsworks/rondb-standalone-cache,mode=max \
--cache-from type=registry,ref=hopsworks/rondb-standalone-cache,mode=max
build-and-push-cross-platform-image:
runs-on: ubuntu-latest
if: github.repository == 'logicalclocks/rondb-docker' && (startsWith(github.ref_name, 'release-') || github.ref_name == 'main')
needs: [check-git, integration-test-and-package, build-and-push-ARM64]
env:
is_highest_release: ${{ needs.check-git.outputs.is_highest_release == 'true' }}
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Dockerhub
uses: docker/login-action@v2
with:
username: hopsworks
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Create and push multi-platform image
run: |
VERSION="$(< "./VERSION" sed -e 's/^[[:space:]]*//')"
docker buildx imagetools create -t hopsworks/rondb-standalone:$RONDB_VERSION_LTS-$VERSION \
hopsworks/$X86_IMAGE_NAME:$RONDB_VERSION_LTS-$VERSION \
hopsworks/$ARM_IMAGE_NAME:$RONDB_VERSION_LTS-$VERSION
docker buildx imagetools create -t hopsworks/rondb-standalone:$RONDB_VERSION_STABLE-$VERSION \
hopsworks/$X86_IMAGE_NAME:$RONDB_VERSION_STABLE-$VERSION \
hopsworks/$ARM_IMAGE_NAME:$RONDB_VERSION_STABLE-$VERSION
if [[ "$is_highest_release" == "true" ]]; then
docker buildx imagetools create -t hopsworks/rondb-standalone:$RONDB_VERSION_LTS-latest \
hopsworks/$X86_IMAGE_NAME:$RONDB_VERSION_LTS-latest \
hopsworks/$ARM_IMAGE_NAME:$RONDB_VERSION_LTS-latest
docker buildx imagetools create -t hopsworks/rondb-standalone:$RONDB_VERSION_STABLE-latest \
hopsworks/$X86_IMAGE_NAME:$RONDB_VERSION_STABLE-latest \
hopsworks/$ARM_IMAGE_NAME:$RONDB_VERSION_STABLE-latest
docker buildx imagetools create -t hopsworks/rondb-standalone:latest \
hopsworks/$X86_IMAGE_NAME:latest \
hopsworks/$ARM_IMAGE_NAME:latest
fi