This is an automated email from the ASF dual-hosted git repository. ricardozanini pushed a commit to branch radtriste-fix-pipelines in repository https://gitbox.apache.org/repos/asf/incubator-kie-kogito-images.git
commit 1bad3b8f7e4f4abdbb2537ec30c73fadad38ce20 Author: Ricardo Zanini <[email protected]> AuthorDate: Tue Nov 21 15:24:47 2023 -0300 Fix problem with builder script copying files for swf-builder-image Signed-off-by: Ricardo Zanini <[email protected]> --- kogito-swf-builder-image.yaml | 2 ++ .../kogito-swf/common/scripts/added/build-app.sh | 13 +++++++---- .../tests/bats/kogito-swf-builder-build-app.bats | 27 ++++++++++++++++++++++ .../resources/greet-with-inputschema/Dockerfile | 2 +- 4 files changed, 39 insertions(+), 5 deletions(-) diff --git a/kogito-swf-builder-image.yaml b/kogito-swf-builder-image.yaml index 421d0448..4b9ed0be 100644 --- a/kogito-swf-builder-image.yaml +++ b/kogito-swf-builder-image.yaml @@ -21,6 +21,8 @@ packages: manager: microdnf + install: + - rsync - name: "quay.io/kiegroup/kogito-swf-builder" from: "registry.access.redhat.com/ubi8/ubi-minimal:latest" diff --git a/modules/kogito-swf/common/scripts/added/build-app.sh b/modules/kogito-swf/common/scripts/added/build-app.sh index 762c791e..d570ffea 100755 --- a/modules/kogito-swf/common/scripts/added/build-app.sh +++ b/modules/kogito-swf/common/scripts/added/build-app.sh @@ -3,7 +3,7 @@ set -e script_dir_path="$(cd $(dirname "${BASH_SOURCE[0]}") && pwd)" resources_path="$1" -if [ ! -z "${resources_path}" ]; then +if [ -n "${resources_path}" ]; then resources_path="$(realpath "${resources_path}")" fi @@ -13,14 +13,17 @@ if [ "${SCRIPT_DEBUG}" = "true" ] ; then set -x export MAVEN_ARGS_APPEND="${MAVEN_ARGS_APPEND} -X --batch-mode" log_info "Script debugging is enabled, allowing bash commands and their arguments to be printed as they are executed" + log_info "Resources path is ${resources_path}" printenv fi # Copy resources if exists -SUPPORTED_FILES=(".yaml" ".yml" ".json" ".properties" ".mvn/jvm.config") log_info "-> Copying files from ${resources_path}, if any..." -if [ ! -z "${resources_path}" ]; then - cd "${resources_path}" && find . -regex '.*\.\(yaml\|yml\|json\|properties\)$' | sed 's|^./||' | xargs cp -v --parents -t "${swf_home_dir}"/src/main/resources/ && cd - +if [ -n "${resources_path}" ]; then + destination="${KOGITO_HOME}/serverless-workflow-project/src/main/resources/" + cd "${resources_path}" && + rsync -av --remove-source-files --prune-empty-dirs --progress --files-from <(find . -regex '.*\.(yaml|yml|json|properties)$' -type f) . "$destination" && + cd - find "${resources_path}" -name 'jvm.config' -exec echo "--> found {}" \; -exec mkdir -p .mvn \; -exec cp -v {} .mvn/ \; else log_warning "-> Nothing to copy from ${resources_path}" @@ -33,6 +36,8 @@ if [ ! -z "${QUARKUS_EXTENSIONS}" ]; then ${script_dir_path}/add-extension.sh "${QUARKUS_EXTENSIONS}" "true" fi +cd ${KOGITO_HOME}/serverless-workflow-project + "${MAVEN_HOME}"/bin/mvn -B ${MAVEN_ARGS_APPEND} \ -nsu \ -s "${MAVEN_SETTINGS_PATH}" \ diff --git a/modules/kogito-swf/common/scripts/tests/bats/kogito-swf-builder-build-app.bats b/modules/kogito-swf/common/scripts/tests/bats/kogito-swf-builder-build-app.bats new file mode 100644 index 00000000..4fa64eff --- /dev/null +++ b/modules/kogito-swf/common/scripts/tests/bats/kogito-swf-builder-build-app.bats @@ -0,0 +1,27 @@ +#!/usr/bin/env bats + +setup() { + export KOGITO_HOME=/tmp/kogito + export HOME="${KOGITO_HOME}" + mkdir -p "${KOGITO_HOME}"/launch + mkdir -p "${KOGITO_HOME}"/serverless-workflow-project/src/main/resources/ + cp $BATS_TEST_DIRNAME/../../../../../kogito-logging/added/logging.sh "${KOGITO_HOME}"/launch/ + cp $BATS_TEST_DIRNAME/../../added/jvm-settings.sh "${KOGITO_HOME}"/launch/ + cp $BATS_TEST_DIRNAME/../../added/build-app.sh "${KOGITO_HOME}"/launch/ +} + +teardown() { + rm -rf "${KOGITO_HOME}" + rm -rf /tmp/resources +} + +@test "verify copy resources is working" { + mkdir -p /tmp/resources + cp -r $BATS_TEST_DIRNAME/../../../../../../tests/shell/kogito-swf-builder/resources/greet-with-inputschema/* /tmp/resources/ + + # We don't care about the errors to try to execute and build the program, just the copy matters + source ${KOGITO_HOME}/launch/build-app.sh /tmp/resources/ || true + + [[ -f "${KOGITO_HOME}"/serverless-workflow-project/src/main/resources/greet.sw.json ]] + [[ -f "${KOGITO_HOME}"/serverless-workflow-project/src/main/resources/schemas/input.json ]] +} diff --git a/tests/shell/kogito-swf-builder/resources/greet-with-inputschema/Dockerfile b/tests/shell/kogito-swf-builder/resources/greet-with-inputschema/Dockerfile index 88e1fc8a..a8e4bdd1 100644 --- a/tests/shell/kogito-swf-builder/resources/greet-with-inputschema/Dockerfile +++ b/tests/shell/kogito-swf-builder/resources/greet-with-inputschema/Dockerfile @@ -11,7 +11,7 @@ ARG MAVEN_DOWNLOAD_OUTPUT="true" ARG MAVEN_OFFLINE_MODE="true" # Copy from build context to resources directory -COPY ./ ./resources/ +COPY * ./resources/ # Build app with given resources RUN "${KOGITO_HOME}"/launch/build-app.sh './resources' --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
