Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FLPATH-1066: swf-builder: generate manifests using kn-workflow #1751

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions kogito-swf-builder-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@
- name: org.kie.kogito.project.versions
- name: org.kie.kogito.swf.common.scripts
- name: org.kie.kogito.swf.builder.runtime.community
- name: org.kie.kogito.workflow-manifests

run:
workdir: "/home/kogito/${PROJECT_ARTIFACT_ID}"
user: 1001

2 changes: 2 additions & 0 deletions modules/kogito-swf/common/scripts/added/build-app.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,5 @@ cd ${KOGITO_HOME}/serverless-workflow-project
-DskipTests \
-Dquarkus.container-image.build=false \
clean install

"${script_dir_path}"/generate-manifests.sh "${resources_path}"
29 changes: 29 additions & 0 deletions modules/kogito-workflow-manifests/added/generate-manifests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env bash
ricardozanini marked this conversation as resolved.
Show resolved Hide resolved
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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.
#
set -x
resource_dir="${1:-${KOGITO_HOME}/serverless-workflow-project/src/main/resources}"
target_dir="${KOGITO_HOME}/build/manifests"
if [ "${GEN_MANIFESTS}" = "true" ]; then
# kn-workflow doesn't support source dir yet, we have to get in
pushd "${resource_dir}" || exit
kn-workflow gen-manifest --custom-generated-manifests-dir "${target_dir}" --namespace ""
popd || exit
fi

30 changes: 30 additions & 0 deletions modules/kogito-workflow-manifests/configure
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env bash
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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.
#
#
set -x

cp /tmp/artifacts/kn-workflow-"$(uname --machine)" /usr/local/bin/kn-workflow
chmod +x-w /usr/local/bin/kn-workflow

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cp -v "${SCRIPT_DIR}"/added/* "${KOGITO_HOME}"/launch

chown -R 1001:0 "${KOGITO_HOME}"/launch
chmod -R ug+rwX "${KOGITO_HOME}"/launch
34 changes: 34 additions & 0 deletions modules/kogito-workflow-manifests/module.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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.
#
schema_version: 1
name: org.kie.kogito.workflow-manifests
version: "999-SNAPSHOT"
description: Module to install kn-workflow tool and scripts
execute:
- script: configure
envs:
- name: KN_CLI
value: /usr/local/bin/kn-workflow
- name: GEN_MANIFESTS
value: false
ricardozanini marked this conversation as resolved.
Show resolved Hide resolved

artifacts:
- name: kn-workflow-x86_64
url: https://github.com/rgolangh/kie-tools/releases/download/0.0.2/kn-workflow-linux-amd64

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The link does not seems to be correct as it points to the fork.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will review this once we move kn-workflow to the operator.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a release I can use already?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, there's not.

md5: defdb771fd65d47c0255fd4389127656
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#!/usr/bin/env bats
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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.
#


setup() {
export KOGITO_HOME=/tmp/kogito
export HOME="${KOGITO_HOME}"
mkdir -p "${KOGITO_HOME}"/launch
mock_bin kn-workflow
mkdir -p "${KOGITO_HOME}"/serverless-workflow-project/src/main/resources/schemas

touch "${KOGITO_HOME}"/launch/configure-jvm-mvn.sh
cp $BATS_TEST_DIRNAME/../../added/generate-manifests.sh "${KOGITO_HOME}"/launch/
cp $BATS_TEST_DIRNAME/../../../kogito-logging/added/logging.sh "${KOGITO_HOME}"/launch/
cp $BATS_TEST_DIRNAME/../../../kogito-swf/common/scripts/added/build-app.sh "${KOGITO_HOME}"/launch/
}

teardown() {
rm -rf "${KOGITO_HOME}"
rm -rf /tmp/resources
}

@test "verify generate manifest is working" {
TEMPD=$(mktemp -d)
cp -r $BATS_TEST_DIRNAME/../../../../tests/shell/kogito-swf-builder/resources/greet-with-inputschema/* ${TEMPD}

# opt-in to generate-manifests
export GEN_MANIFESTS=true
# 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 ${TEMPD} || true

# this tests the call to kn-workflow actually happend
[ -f "${KOGITO_HOME}"/bin/kn-workflow_invocation.txt ]
}

@test "verify generate manifest is an opt-in" {
TEMPD=$(mktemp -d)
cp -r $BATS_TEST_DIRNAME/../../../../tests/shell/kogito-swf-builder/resources/greet-with-inputschema/* ${TEMPD}

# opt-out to generate-manifests
export GEN_MANIFESTS=false
# 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 ${TEMPD} || true

# this tests that the call to kn-workflow didn't happend
[ ! -f "${KOGITO_HOME}"/bin/kn-workflow_invocation.txt ]
}

mock_bin() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pretty cool!

mkdir -p "${KOGITO_HOME}"/bin
PATH+=":${KOGITO_HOME}/bin/"
cat << EOF > "${KOGITO_HOME}"/bin/$1
echo $1 "$@" > $"${KOGITO_HOME}"/bin/$1_invocation.txt
EOF
chmod +x "${KOGITO_HOME}"/bin/$1
}

Loading