Skip to content

Commit

Permalink
Native image script for quickstart testing
Browse files Browse the repository at this point in the history
Signed-off-by: tvallin <thibault.vallin@oracle.com>
  • Loading branch information
tvallin committed Apr 23, 2024
1 parent bd6a9b7 commit 33e27a9
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -162,3 +162,19 @@ jobs:
run: etc/scripts/test-packaging-jlink.sh
- name: Native-Image packaging
run: etc/scripts/test-packaging-native.sh
native-image-example:
timeout-minutes: 36
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- uses: graalvm//setup-graalvm@v1
with:
java-version: 21
distribution: graalvm-community
github-token: ${{ secrets.GITHUB_TOKEN }}
native-image-job-reports: true
cache: maven
- name: Build Helidon
run: etc/scripts/github-compile.sh
- name: Test native image executable
run: etc/scripts/test-quickstart-native-image.sh
57 changes: 57 additions & 0 deletions etc/scripts/test-quickstart-native-image.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/bin/bash -e
#
# Copyright (c) 2024 Oracle and/or its affiliates.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

# Path to this script
[ -h "${0}" ] && readonly SCRIPT_PATH="$(readlink "${0}")" || readonly SCRIPT_PATH="${0}"

# Load pipeline environment setup and define WS_DIR
. $(dirname -- "${SCRIPT_PATH}")/includes/pipeline-env.sh "${SCRIPT_PATH}" '../..'

# Setup error handling using default settings (defined in includes/error_handlers.sh)
error_trap_setup

if [ -z "${GRAALVM_HOME}" ]; then
echo "ERROR: GRAALVM_HOME is not set";
exit 1
fi

if [ ! -x "${GRAALVM_HOME}/bin/native-image" ]; then
echo "ERROR: ${GRAALVM_HOME}/bin/native-image does not exist or is not executable";
exit 1
fi

mvn ${MAVEN_ARGS} --version

echo "GRAALVM_HOME=${GRAALVM_HOME}";
${GRAALVM_HOME}/bin/native-image --version;

# Build native executable, run it in the background and check the greet endpoint
readonly quickstarts="helidon-quickstart-mp helidon-quickstart-se"
for quickstart in ${quickstarts}; do
cd ${WS_DIR}/examples/quickstarts/"${quickstart}"
mvn ${MAVEN_ARGS} -e clean install -Pnative-image -DskipTests
timeout 8 ./target/"${quickstart}" -k 7 &
sleep 5
RESULT=$(curl http://localhost:8080/greet)
if [[ "$RESULT" =~ "Hello World" ]];
then
echo "${quickstart} Native image test passed"
else
echo "${quickstart} Native image test failed"
exit 1
fi
done

0 comments on commit 33e27a9

Please sign in to comment.