Skip to content

Switch project to Gradle version catalog #569

Switch project to Gradle version catalog

Switch project to Gradle version catalog #569

Workflow file for this run

name: Smoke Test
on:
pull_request:
branches:
- "**"
workflow_dispatch:
concurrency:
group: smoke-test-${{ github.ref }}
cancel-in-progress: true
env:
RELEASE_NAME: "smoke-test-release"
jobs:
smoke-test-platform:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ${{ github.workspace }}
permissions:
contents: read
packages: write
steps:
- name: Get binaries
run: |
curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl && chmod +x kubectl && sudo mv kubectl /usr/local/bin/
curl -Lo kind https://github.com/kubernetes-sigs/kind/releases/download/v0.18.0/kind-linux-amd64 && chmod +x kind && sudo mv kind /usr/local/bin/
- name: Set up Docker QEMU
uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3
- name: Login to Container Registry
uses: docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446 # v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Checkout HiveMQ Helm Charts
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
with:
path: helm-charts
- name: Checkout HiveMQ Platform Operator on the default branch
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
with:
repository: hivemq/hivemq-platform-operator
token: ${{ secrets.JENKINS_GITHUB_TOKEN }}
path: hivemq-platform-operator
- name: Checkout HiveMQ Platform Operator on the same or target branch
working-directory: ${{ github.workspace }}/hivemq-platform-operator
run: |
echo "Checking if branch \"${GITHUB_HEAD_REF}\" exists on hivemq-platform-operator"
BRANCH=$(git ls-remote origin ${GITHUB_HEAD_REF})
if [[ -n "${BRANCH}" ]]; then
echo "Checking out branch with the same name"
git fetch --all
git checkout origin/${GITHUB_HEAD_REF}
exit
fi
if [[ "${GITHUB_BASE_REF}" == "master" ]]; then
exit
fi
echo "Checking if branch \"${GITHUB_BASE_REF}\" exists on hivemq-platform-operator"
BRANCH=$(git ls-remote origin ${GITHUB_BASE_REF})
if [[ -n "${BRANCH}" ]]; then
echo "Checking out target branch"
git fetch --all
git checkout origin/${GITHUB_BASE_REF}
fi
- name: Set up JDK 21
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4
with:
java-version: '21'
distribution: 'temurin'
- name: Set up Gradle
uses: gradle/actions/setup-gradle@31ae3562f68c96d481c31bc1a8a55cc1be162f83 # v3
with:
gradle-home-cache-includes: |
caches
notifications
jdks
gradle-home-cache-cleanup: true
- name: Build HiveMQ Platform Operator and HiveMQ Platform Operator Init images
working-directory: helm-charts
run: ./gradlew :tests-hivemq-platform-operator:build :tests-hivemq-platform-operator:saveDockerImages
- name: Start up KinD cluster with local images
working-directory: ${{ github.workspace }}/helm-charts
run: |
kind create cluster
kind load image-archive ./tests-hivemq-platform-operator/build/hivemq-platform-operator-init.tar
kind load image-archive ./tests-hivemq-platform-operator/build/hivemq-platform-operator.tar
kind load image-archive ./tests-hivemq-platform-operator/build/hivemq-platform.tar
- name: Install HiveMQ Platform Operator
working-directory: ${{ github.workspace }}/helm-charts
run: helm install operator-test --set image.name=hivemq-platform-operator-test --set image.initImageName=hivemq-platform-operator-init-test --set image.tag=snapshot ./charts/hivemq-platform-operator --wait
- name: Install HiveMQ Platform
working-directory: ${{ github.workspace }}/helm-charts
run: helm install $RELEASE_NAME --set nodes.replicaCount=1,nodes.resources.cpu=512m ./charts/hivemq-platform --wait --create-namespace -n test
- name: Test HiveMQ Platform
run: |
kubectl get events -n test -w &
# Otherwise the pods are not created and the next step fails
echo Waiting for statefulSet to be created && sleep 15 && echo Done Waiting
kubectl wait --for=condition=ready pod -l app.kubernetes.io/instance=$RELEASE_NAME --timeout=5m -n test
helm test $RELEASE_NAME -n test
- name: Capture HiveMQ Platform Pods logs on failure
if: failure()
run: |
mkdir ${{ runner.temp }}/logs
kubectl logs -l app.kubernetes.io/instance=$RELEASE_NAME --tail -1 -n default > ${{ runner.temp }}/logs/operator-pod.log
kubectl logs -l app.kubernetes.io/instance=$RELEASE_NAME --tail -1 -n test > ${{ runner.temp }}/logs/platform-pod.log
- name: Upload HiveMQ Platform Pods logs on failure
if: failure()
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4
with:
name: Pod logs
path: ${{ runner.temp }}/logs/*.log
retention-days: 5
- name: Uninstall HiveMQ Platform charts
if: always()
run: |
helm uninstall $RELEASE_NAME --wait -n test
helm uninstall operator-test --wait
kubectl get pods -A
smoke-test-legacy:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ${{ github.workspace }}
permissions:
contents: read
packages: write
steps:
- name: Get binaries
run: |
curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl && chmod +x kubectl && sudo mv kubectl /usr/local/bin/
curl -Lo kind https://github.com/kubernetes-sigs/kind/releases/download/v0.18.0/kind-linux-amd64 && chmod +x kind && sudo mv kind /usr/local/bin/
- name: Set up Docker QEMU
uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3
- name: Login to Container Registry
uses: docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446 # v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Checkout HiveMQ Helm Charts
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
with:
path: helm-charts
- name: Checkout HiveMQ Operator (legacy) on the default branch
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
with:
repository: hivemq/hivemq-operator
token: ${{ secrets.JENKINS_GITHUB_TOKEN }}
path: hivemq-operator
- name: Checkout HiveMQ Operator (legacy) on the same or target branch
working-directory: ${{ github.workspace }}/hivemq-operator
run: |
echo "Checking if branch \"${GITHUB_HEAD_REF}\" exists on hivemq-operator"
BRANCH=$(git ls-remote origin ${GITHUB_HEAD_REF})
if [[ -n "${BRANCH}" ]]; then
echo "Checking out branch with the same name"
git fetch --all
git checkout origin/${GITHUB_HEAD_REF}
exit
fi
if [[ "${GITHUB_BASE_REF}" == "master" ]]; then
exit
fi
echo "Checking if branch \"${GITHUB_BASE_REF}\" exists on hivemq-operator"
BRANCH=$(git ls-remote origin ${GITHUB_BASE_REF})
if [[ -n "${BRANCH}" ]]; then
echo "Checking out target branch"
git fetch --all
git checkout origin/${GITHUB_BASE_REF}
fi
- name: Set up JDK 21
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4
with:
java-version: '21'
distribution: 'temurin'
- name: Set up Gradle
uses: gradle/actions/setup-gradle@31ae3562f68c96d481c31bc1a8a55cc1be162f83 # v3
with:
gradle-home-cache-includes: |
caches
notifications
jdks
gradle-home-cache-cleanup: true
- name: Build HiveMQ Operator (legacy) images
working-directory: helm-charts
run: ./gradlew :tests-hivemq-operator:build :tests-hivemq-operator:saveDockerImages
- name: Start up KinD cluster with local images
working-directory: ${{ github.workspace }}/helm-charts
run: |
kind create cluster
kind load image-archive ./tests-hivemq-operator/build/hivemq-dns-init-wait.tar
kind load image-archive ./tests-hivemq-operator/build/hivemq-k8s.tar
kind load image-archive ./tests-hivemq-operator/build/hivemq-operator.tar
- name: Install HiveMQ Operator (legacy)
working-directory: ${{ github.workspace }}/helm-charts
run: |
helm repo add prometheus https://prometheus-community.github.io/helm-charts
helm dependency build ./charts/hivemq-operator
helm install $RELEASE_NAME ./charts/hivemq-operator -f ./examples/hivemq-operator/localStatefulTest.yml --wait --create-namespace -n test
- name: Test HiveMQ Cluster
run: |
kubectl get events -n test -w &
# Otherwise the pods are not created and the next step fails
echo Waiting for statefulSet to be created && sleep 15 && echo Done Waiting
kubectl wait --for=condition=ready pod -l hivemq-cluster=$RELEASE_NAME --timeout=5m -n test
helm test $RELEASE_NAME -n test
- name: Capture HiveMQ Operator (legacy) Pods logs on failure
if: failure()
run: |
mkdir ${{ runner.temp }}/logs
kubectl logs -l app.kubernetes.io/instance=$RELEASE_NAME --tail -1 -n default > ${{ runner.temp }}/logs/operator-pod.log
kubectl logs -l app.kubernetes.io/instance=$RELEASE_NAME --tail -1 -n test > ${{ runner.temp }}/logs/platform-pod.log
- name: Upload HiveMQ Operator (legacy) Pods logs on failure
if: failure()
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4
with:
name: Pod logs
path: ${{ runner.temp }}/logs/*.log
retention-days: 5
- name: Uninstall HiveMQ Operator (legacy) charts
if: always()
run: |
helm uninstall $RELEASE_NAME --wait -n test
kubectl get pods -A