Skip to content

Build with specific Quarkus version #52

Build with specific Quarkus version

Build with specific Quarkus version #52

name: Build with specific Quarkus version
on:
workflow_call:
inputs:
quarkus-version-jq-cmd:
description: 'jq command to extract which Quarkus version to use from https://registry.quarkus.io/client/platforms'
type: string
required: false
quarkus-version:
type: string
required: false
java-version:
type: string
required: true
default: '17'
branch:
type: string
required: true
default: 'main'
repository:
type: string
default: ''
native-modules:
type: string
required: false
default: 'integration-tests,samples'
profiles:
type: string
required: false
default: 'default'
workflow_dispatch:
inputs:
quarkus-version-jq-cmd:
description: 'jq command to extract which Quarkus version to use from https://registry.quarkus.io/client/platforms'
type: string
required: false
default: '.platforms[0]."current-stream-id" as $current | .platforms[0].streams[] | select(.id == $current) | .releases[0].version'
josdk-pr:
description: 'JOSDK PR number (or main) to use to build QOSDK with'
type: string
required: false
quarkus-pr:
description: 'Quarkus PR number to use to run a QOSDK build with'
type: string
required: false
fkc-pr:
description: 'Fabric8 client PR number to use to run a QOSDK build with'
type: string
required: false
fkc-version:
description: 'Fabric8 client version to run a QOSDK build with'
type: string
required: false
quarkus-version:
type: string
required: false
description: 'Quarkus version to use'
java-version:
description: 'Java version to build with'
type: string
required: true
default: '17'
branch:
description: 'QOSDK branch to build'
type: string
required: true
default: 'main'
native-modules:
description: 'Comma-separated list of modules that should be built natively'
type: string
required: false
default: 'integration-tests,samples'
profiles:
description: 'Maven profiles to apply to build'
type: string
required: false
default: 'use-snapshots'
concurrency:
group: "${{ inputs.quarkus-version }}-${{inputs.java-version}}-${{ github.ref }}-${{inputs.quarkus-pr}}"
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.branch }}
repository: ${{ inputs.repository }}
- name: Set up Java
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: ${{ inputs.java-version }}
cache: 'maven'
- name: Check-out JOSDK if building from PR is requested
uses: actions/checkout@v4
if: "${{ inputs.josdk-pr != '' }}"
with:
repository: operator-framework/java-operator-sdk
path: josdk
- name: Build JOSDK PR if requested
if: "${{ inputs.josdk-pr != '' }}"
id: build-josdk-pr
run: |
cd josdk
echo ${{ inputs.josdk-pr }}
if [ "${{ inputs.josdk-pr }}" = "main" ]; then
echo "Using JOSDK main branch"
else
echo "Checking out ${{ inputs.josdk-pr }} PR"
git fetch origin pull/${{ github.event.inputs.josdk-pr }}/head:pr-to-check
git switch pr-to-check
fi
./mvnw install -DskipTests
echo "josdk_version=$(./mvnw help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_OUTPUT
echo "josdk_f8_version=$(./mvnw help:evaluate -Dexpression=fabric8-client.version -q -DforceStdout)" >> $GITHUB_OUTPUT
cd -
- name: Set JOSDK version from build PR if requested
if: "${{ inputs.josdk-pr != '' }}"
run: ./mvnw versions:set-property -Dproperty='java-operator-sdk.version' -DnewVersion=${{ steps.build-josdk-pr.outputs.josdk_version }}
- name: Check-out Quarkus if building from PR is requested
uses: actions/checkout@v4
if: "${{ inputs.quarkus-pr != '' }}"
with:
repository: quarkusio/quarkus
path: quarkus
- name: Build Quarkus PR if requested
if: "${{ inputs.quarkus-pr != '' }}"
id: build-quarkus-pr
run: |
cd quarkus
git fetch origin pull/${{ github.event.inputs.quarkus-pr }}/head:pr-to-check
git switch pr-to-check
./update-version.sh 999.${{ github.event.inputs.quarkus-pr }}-SNAPSHOT
echo "quarkus_f8_version=$(./mvnw help:evaluate -Dexpression=kubernetes-client.version -q -DforceStdout)" >> $GITHUB_OUTPUT
./mvnw -Dquickly
cd -
- name: Check-out Fabric8 client PR if requested
uses: actions/checkout@v4
if: "${{ inputs.fkc-pr != '' }}"
with:
repository: fabric8io/kubernetes-client
path: fkc
- name: Build Fabric8 client PR if requested
if: "${{ inputs.fkc-pr != '' }}"
id: build-fkc-pr
run: |
cd fkc
git fetch origin pull/${{ github.event.inputs.fkc-pr }}/head:pr-to-check
git switch pr-to-check
./mvnw versions:set -DnewVersion=999.${{ github.event.inputs.fkc-pr }}-SNAPSHOT versions:commit
echo "f8_pr_version=$(./mvnw help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_OUTPUT
./mvnw clean install -DskipTests
cd -
- name: Retrieve Quarkus version from platform
if: "${{ inputs.quarkus-version == '' && inputs.quarkus-pr == ''}}"
id: get-quarkus-version
uses: sergeysova/jq-action@v2
with:
cmd: curl https://registry.quarkus.io/client/platforms | jq '${{inputs.quarkus-version-jq-cmd}}'
- name: Select Quarkus version
id: quarkus-version
run: |
echo ${{ inputs.quarkus-version }}
if [[ -n "${{ steps.get-quarkus-version.outputs.value }}" ]]; then
quarkus_version="${{ steps.get-quarkus-version.outputs.value }}"
fi
if [[ -n "${{ inputs.quarkus-version }}" ]]; then
quarkus_version="${{ inputs.quarkus-version }}"
fi
if [[ -n "${{ inputs.quarkus-pr }}" ]]; then
quarkus_version=999.${{ github.event.inputs.quarkus-pr }}-SNAPSHOT
fi
echo "quarkus_version=${quarkus_version}" >> $GITHUB_OUTPUT
- name: Use snapshots profile for non-main builds
id: set-mvn-profiles
run: |
maven_profiles="${{ inputs.profiles }}"
if [ "${{ inputs.branch }}" != "main" ]; then
maven_profiles="${maven_profiles},use-snapshots"
fi
echo "Computed Maven profiles: ${maven_profiles}"
echo "maven_profiles=${maven_profiles}" >> $GITHUB_OUTPUT
- name: Change Quarkus version
run: |
echo "Using Quarkus ${{ steps.quarkus-version.outputs.quarkus_version }}"
./mvnw versions:set-property -P'${{steps.set-mvn-profiles.outputs.maven_profiles}}' -Dproperty=quarkus.version -DnewVersion=${{ steps.quarkus-version.outputs.quarkus_version }}
- name: Change Fabric8 client version
id: fkc-version
if: "${{ inputs.fkc-pr != '' || inputs.fkc-version != '' }}"
run: |
if [[ -n "${{ inputs.fkc-version }}" ]]; then
fkc_version="${{ inputs.fkc-version }}"
fi
if [[ -n "${{ inputs.fkc-pr }}" ]]; then
fkc_version=${{ steps.build-fkc-pr.outputs.f8_pr_version }}
fi
echo "Using Fabric8 ${fkc_version}"
./mvnw versions:set-property -P'${{steps.set-mvn-profiles.outputs.maven_profiles}}' -Dproperty=fabric8-client.version -DnewVersion=${fkc_version}
echo "fkc_version=${fkc_version}" >> $GITHUB_OUTPUT
- name: Output versions being used
run: |
echo "QOSDK version: $(./mvnw help:evaluate -P'${{steps.set-mvn-profiles.outputs.maven_profiles}}' -Dexpression=project.version -q -DforceStdout)"
echo "JOSDK version: $(./mvnw help:evaluate -P'${{steps.set-mvn-profiles.outputs.maven_profiles}}' -Dexpression=java-operator-sdk.version -q -DforceStdout)"
echo "JOSDK Fabric8 version: ${{ steps.build-josdk-pr.outputs.josdk_f8_version }}"
echo "JOSDK overridden Fabric8 version ${{ steps.fkc-version.outputs.fkc_version }}"
echo "Quarkus version: $(./mvnw help:evaluate -P'${{steps.set-mvn-profiles.outputs.maven_profiles}}' -Dexpression=quarkus.version -q -DforceStdout)"
echo "Quarkus Fabric8 version: ${{ steps.build-quarkus-pr.outputs.quarkus_f8_version }}"
echo "Effective Fabric8 version: $(./mvnw dependency:tree -P'${{steps.set-mvn-profiles.outputs.maven_profiles}}' -Dincludes=io.fabric8:kubernetes-client-api -pl core/deployment | grep io.fabric8:kubernetes-client-api -m1 | cut -d ':' -f 4)"
- name: Build with Maven (JVM)
run: ./mvnw -B formatter:validate install -P'${{steps.set-mvn-profiles.outputs.maven_profiles}}' --file pom.xml
- name: Dependency tree on failure
if: failure()
run: ./mvnw -B dependency:tree -Dverbose
- name: Kubernetes KinD Cluster
uses: container-tools/kind-action@v2
with:
registry: true
- name: Install OPM and Operator SDK tool
uses: redhat-actions/openshift-tools-installer@v1
with:
source: "github"
opm: "latest"
operator-sdk: "latest"
- name: Install Operator Lifecycle Manager and Operator SDK into Kind
run: operator-sdk olm install --version v0.23.0
# Joke sample currently doesn't validate with OLM v1 because it bundles required Joke CRD, which v1 thinks should be owned
- name: Validate OLM bundles (excluding Joke sample)
run: |
cd samples/
find . -type d -name bundle | grep -v joke | xargs -I {} find {} -type d -maxdepth 1 -mindepth 1 | xargs -I {} operator-sdk bundle validate {} --select-optional suite=operatorframework
- name: Run Joke sample using Quarkus DEV mode
run: |
SCRIPTS=$(pwd)/.github/scripts
K8S_NAMESPACE=dev
CURRENT_PWD=$(pwd)
# Create and set namespace
kubectl create namespace $K8S_NAMESPACE
kubectl config set-context --current --namespace=$K8S_NAMESPACE
# Run operator in DEV mode
cd samples/joke
# Need to override application.properties setting to avoid using dev services instead of set up cluster
"$CURRENT_PWD"/mvnw quarkus:dev -Dquarkus.kubernetes-client.devservices.override-kubeconfig=false >app.log 2>&1 &
PID=$(echo $!)
cd $CURRENT_PWD
# test joke sample
ERROR=0
if ! $SCRIPTS/testJokeSample.sh $K8S_NAMESPACE; then
ERROR=1
fi
# Kill all running java processes
killall -9 java
# Delete namespace
kubectl delete namespace $K8S_NAMESPACE
if [ ERROR = 1 ]; then
echo "Tests failed"
exit 1
fi
- name: Archive Dev Mode application logs
uses: actions/upload-artifact@v4
if: failure()
with:
name: dev-mode-app.log
path: samples/joke/app.log
- name: Build with Maven (Native)
run: ./mvnw -B install -Dnative --file pom.xml -P'${{steps.set-mvn-profiles.outputs.maven_profiles}}' -pl '${{inputs.native-modules}}' -amd
- name: Run Joke sample in native mode
if: ${{ contains(inputs.native-modules, 'samples') }}
run: |
SCRIPTS=$(pwd)/.github/scripts
K8S_NAMESPACE=native
CURRENT_PWD=$(pwd)
# Create and set namespace
kubectl create namespace $K8S_NAMESPACE
kubectl config set-context --current --namespace=$K8S_NAMESPACE
# Run operator in native mode
cd samples/joke
find . -type f -name '*-runner' -exec {} \; >native.log 2>&1 &
PID=$(echo $!)
cd $CURRENT_PWD
ERROR=0
if ! $SCRIPTS/testJokeSample.sh $K8S_NAMESPACE; then
ERROR=1
fi
# Kill running process
kill -9 $PID
# Delete namespace
kubectl delete namespace $K8S_NAMESPACE
if [ ERROR = 1 ]; then
echo "Tests failed"
exit 1
fi
- name: Archive native application logs
uses: actions/upload-artifact@v4
if: failure()
with:
name: native.log
path: samples/joke/native.log
- name: Run Joke sample into Kubernetes using OLM
run: |
SCRIPTS=$(pwd)/.github/scripts
# Install Joke operator
if ! $SCRIPTS/installOperatorUsingOlm.sh joke $(pwd)/samples/joke $KIND_REGISTRY; then
echo "Failed to install operator"
exit 1;
fi
# test joke sample
if ! $SCRIPTS/testJokeSample.sh operators; then
echo "Failed to interact with operator"
exit 1;
fi;
- name: Run Ping Pong sample into Kubernetes using OLM
run: |
SCRIPTS=$(pwd)/.github/scripts
# Install Ping Pong operator
if ! $SCRIPTS/installOperatorUsingOlm.sh pingpong $(pwd)/samples/pingpong $KIND_REGISTRY; then
echo "Failed to install operator"
exit 1;
fi
# test joke sample
if ! $SCRIPTS/testPingPongSample.sh operators; then
echo "Failed to interact with operator"
exit 1;
fi
- name: (Only if it failed) Log K8s status to troubleshoot issues
if: failure()
run: |
echo "Pod statuses in olm namespace:"
kubectl get pod -n olm
echo ""
echo "------------------------------"
echo "Subscriptions:"
kubectl get subs -n operators -o yaml
echo ""
echo "------------------------------"
echo "Controllers:"
kubectl get pod -n operators
echo ""
echo "------------------------------"
echo "Events:"
kubectl get events
echo ""
echo "------------------------------"