Skip to content

Commit

Permalink
Feature/10868 extract seatadjuster app (#25)
Browse files Browse the repository at this point in the history
* [10802] Improve local runtime scripts

Signed-off-by: Dennis Meister <dennis.meister@bosch.com>

* [10802] Fix linting

Signed-off-by: Dennis Meister <dennis.meister@bosch.com>

* Create Skeleton app and extract seat-adjuster to sdk

Signed-off-by: Dennis Meister <dennis.meister@bosch.com>

* [11025/11031] fix GitHub workflow to support external contributors (#23)

* fix: fix GitHub workflow to support external contributors

* fix: update the name of the notice file

* fix: rename deployment script to deploy_image_from_artifact.sh

* fix: remove head_refs from all readonly jobs (#24)

* [10802] Improve local runtime scripts (#17)

* [10802] Improve local runtime scripts

Signed-off-by: Dennis Meister <dennis.meister@bosch.com>

* [10802] Fix linting

Signed-off-by: Dennis Meister <dennis.meister@bosch.com>

* [11025/11031] fix GitHub workflow to support external contributors (#23)

* fix: fix GitHub workflow to support external contributors

* fix: update the name of the notice file

* fix: rename deployment script to deploy_image_from_artifact.sh

* fix: remove head_refs from all readonly jobs (#24)

* Change UTILS_DIRECTORY for consistency

Signed-off-by: Dennis Meister <dennis.meister@bosch.com>

Signed-off-by: Dennis Meister <dennis.meister@bosch.com>
Co-authored-by: Ebrahim.A <ebrahim.ameen@bosch.com>

* [10802] Improve local runtime scripts

Signed-off-by: Dennis Meister <dennis.meister@bosch.com>

* [10802] Fix linting

Signed-off-by: Dennis Meister <dennis.meister@bosch.com>

* Create Skeleton app and extract seat-adjuster to sdk

Signed-off-by: Dennis Meister <dennis.meister@bosch.com>

* Fix rebase issue

Signed-off-by: Dennis Meister <dennis.meister@bosch.com>

* Change log level of data received

Signed-off-by: Dennis Meister <dennis.meister@bosch.com>

* Bump version for sdk requirement

Signed-off-by: Dennis Meister <dennis.meister@bosch.com>

* Fix merge conflict

Signed-off-by: Dennis Meister <dennis.meister@bosch.com>

* Adapt to SDK pr findings

Signed-off-by: Dennis Meister <dennis.meister@bosch.com>

* Remove other examples beside seat-adjuster

Signed-off-by: Dennis Meister <dennis.meister@bosch.com>

* Remove AppManifest.json from root directory

Signed-off-by: Dennis Meister <dennis.meister@bosch.com>

* Add missing path change

Signed-off-by: Dennis Meister <dennis.meister@bosch.com>

* Fix unit tests in workflow

Signed-off-by: Dennis Meister <dennis.meister@bosch.com>

* Adapt import example app task

Signed-off-by: Dennis Meister <dennis.meister@bosch.com>

Signed-off-by: Dennis Meister <dennis.meister@bosch.com>
Co-authored-by: Ebrahim.A <ebrahim.ameen@bosch.com>
  • Loading branch information
dennismeister93 and emsameen committed Sep 5, 2022
1 parent 6d91042 commit 5e1df64
Show file tree
Hide file tree
Showing 35 changed files with 429 additions and 521 deletions.
3 changes: 2 additions & 1 deletion .devcontainer/devcontainer.json
Expand Up @@ -46,7 +46,8 @@
"dotjoshjohnson.xml",
"ms-kubernetes-tools.vscode-kubernetes-tools",
"matangover.mypy",
"anweber.vscode-httpyac"
"anweber.vscode-httpyac",
"augustocdias.tasks-shell-input"
],

// Use 'forwardPorts' to make a list of ports inside the container available locally.
Expand Down
2 changes: 1 addition & 1 deletion .devcontainer/scripts/add-python.sh
Expand Up @@ -29,7 +29,7 @@ echo "#######################################################"
echo "### Installing python version 3 ###"
echo "#######################################################"
ROOT_DIRECTORY=$( realpath "$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )/../.." )
PYTHON_VERSION=$(cat $ROOT_DIRECTORY/AppManifest.json | jq .[].dependencies.python.version | tr -d '"')
PYTHON_VERSION=$(cat $ROOT_DIRECTORY/app/AppManifest.json | jq .[].dependencies.python.version | tr -d '"')

sudo apt-get install -y python3-distutils
sudo apt-get install -y python$PYTHON_VERSION
Expand Down
6 changes: 3 additions & 3 deletions .devcontainer/scripts/postCreateCommand.sh
Expand Up @@ -44,18 +44,18 @@ REQUIREMENTS="./requirements-dev.txt"
if [ -f $REQUIREMENTS ]; then
pip3 install -r $REQUIREMENTS
fi
REQUIREMENTS="./src/requirements-links.txt"
REQUIREMENTS="./app/requirements-links.txt"
if [ -f $REQUIREMENTS ]; then
pip3 install -r $REQUIREMENTS
fi
# Dependencies for the app
REQUIREMENTS="./src/requirements.txt"
REQUIREMENTS="./app/requirements.txt"
if [ -f $REQUIREMENTS ]; then
pip3 install -r $REQUIREMENTS
fi

# Dependencies for unit and integration tests
REQUIREMENTS="./test/requirements.txt"
REQUIREMENTS="./app/tests/requirements.txt"
if [ -f $REQUIREMENTS ]; then
pip3 install -r $REQUIREMENTS
fi
8 changes: 4 additions & 4 deletions .github/scripts/deploy_image_from_artifact.sh
Expand Up @@ -14,11 +14,11 @@
# SPDX-License-Identifier: Apache-2.0

ROOT_DIRECTORY=$( realpath "$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )/../.." )
APP_NAME=$(cat $ROOT_DIRECTORY/AppManifest.json | jq .[].Name | tr -d '"')
APP_PORT=$(cat $ROOT_DIRECTORY/AppManifest.json | jq .[].Port | tr -d '"')
APP_NAME=$(cat $ROOT_DIRECTORY/app/AppManifest.json | jq .[].Name | tr -d '"')
APP_PORT=$(cat $ROOT_DIRECTORY/app/AppManifest.json | jq .[].Port | tr -d '"')
APP_REGISTRY="k3d-registry.localhost:12345"

jq -c '.[]' $ROOT_DIRECTORY/AppManifest.json | while read i; do
jq -c '.[]' $ROOT_DIRECTORY/app/AppManifest.json | while read i; do
name=$(jq -r '.Name' <<< "$i")

local_tag="$APP_REGISTRY/$name:local"
Expand All @@ -39,7 +39,7 @@ helm install vapp-chart $ROOT_DIRECTORY/deploy/VehicleApp/helm \
kubectl get svc --all-namespaces
kubectl get pods

jq -c '.[]' $ROOT_DIRECTORY/AppManifest.json | while read i; do
jq -c '.[]' $ROOT_DIRECTORY/app/AppManifest.json | while read i; do
name=$(jq -r '.Name' <<< "$i")
podname=$(kubectl get pods -o name | grep $name)
kubectl describe $podname
Expand Down
24 changes: 12 additions & 12 deletions .github/workflows/ci.yml
Expand Up @@ -50,18 +50,18 @@ jobs:
shell: bash
run: |
pip install -r requirements-dev.txt
pip install -r src/requirements-links.txt
pip install -r src/requirements.txt
pip install -r test/requirements.txt
pip install -r app/requirements-links.txt
pip install -r app/requirements.txt
pip install -r app/tests/requirements.txt
- name: Run Linters
uses: pre-commit/action@v3.0.0

- name: unit test
shell: bash
run: |
pip install -r test/requirements.txt
pytest --rootdir . --override-ini junit_family=xunit1 --junit-xml=./results/UnitTest/junit.xml --cov ./src --cov-report=xml:results/CodeCoverage/cobertura-coverage.xml --cov-branch ./src --cov-config=setup.cfg
pip install -r app/tests/requirements.txt
pytest --rootdir=./app/tests/unit --override-ini junit_family=xunit1 --junit-xml=./results/UnitTest/junit.xml --cov ./app/tests/unit --cov-report=xml:results/CodeCoverage/cobertura-coverage.xml --cov-branch ./app/tests/unit --cov-config=setup.cfg
coverage2clover -i results/CodeCoverage/cobertura-coverage.xml -o results/CodeCoverage/clover.xml
coveragepy-lcov --data_file_path ./.coverage --output_file_path results/CodeCoverage/lcov.info
Expand Down Expand Up @@ -130,8 +130,8 @@ jobs:
id: export-deployment-matrix
run: |
SITE_PACKAGES=$(python -m site --user-site)
sed -i "s|SITE_PACKAGES|$SITE_PACKAGES|g" ./AppManifest.json
MATRIX=$(cat ./AppManifest.json | tr '\n' ' ')
sed -i "s|SITE_PACKAGES|$SITE_PACKAGES|g" ./app/AppManifest.json
MATRIX=$(cat ./app/AppManifest.json | tr '\n' ' ')
echo "::set-output name=deployment-matrix::$MATRIX"
Expand Down Expand Up @@ -187,9 +187,9 @@ jobs:
- name: Install required packages
shell: pwsh
run: |
pip install -r ./src/requirements.txt
pip install -r ./src/requirements-links.txt
pip install -r ./test/requirements.txt
pip install -r ./app/requirements.txt
pip install -r ./app/requirements-links.txt
pip install -r ./app/tests/requirements.txt
- name: Install K3D and prerequisites
working-directory: ./.vscode/scripts/runtime/k3d
Expand Down Expand Up @@ -227,8 +227,8 @@ jobs:
VDB_PORT: 30555
MQTT_PORT: 31883
run: |
pip install -r test/requirements.txt
pytest ./test --override-ini junit_family=xunit1 --junit-xml=./results/IntTest/junit.xml
pip install -r app/tests/requirements.txt
pytest ./app/tests/integration --override-ini junit_family=xunit1 --junit-xml=./results/IntTest/junit.xml
- name: Publish Unit Test Results
uses: EnricoMi/publish-unit-test-result-action@v1
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Expand Up @@ -33,8 +33,8 @@ jobs:
id: export-deployment-matrix
run: |
SITE_PACKAGES=$(python -m site --user-site)
sed -i "s|SITE_PACKAGES|$SITE_PACKAGES|g" ./AppManifest.json
MATRIX=$(cat ./AppManifest.json | tr '\n' ' ')
sed -i "s|SITE_PACKAGES|$SITE_PACKAGES|g" ./app/AppManifest.json
MATRIX=$(cat ./app/AppManifest.json | tr '\n' ' ')
echo "::set-output name=deployment-matrix::$MATRIX"
Expand Down
2 changes: 1 addition & 1 deletion .licensechecker.yml
Expand Up @@ -18,4 +18,4 @@ scan-dirs:
python-version: 3
python-pip-included-requirement-files:
- requirements-dev.txt
- src/requirements.txt
- app/requirements.txt
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Expand Up @@ -77,7 +77,7 @@ repos:
rev: "v0.920"
hooks:
- id: mypy
args: [src]
args: [app]
language: system
pass_filenames: false

Expand Down
30 changes: 26 additions & 4 deletions .vscode/launch.json
Expand Up @@ -10,16 +10,38 @@
"justMyCode": false,
"request": "launch",
"name": "VehicleApp",
"program": "${workspaceFolder}/src/VehicleApp/main.py",
"program": "${workspaceFolder}/app/src/main.py",
"console": "integratedTerminal",
"preLaunchTask": "dapr-VehicleApp-run",
"postDebugTask": "dapr-VehicleApp-stop",
"env": {
"DAPR_GRPC_PORT":"50001",
"DAPR_HTTP_PORT":"3500",
"SEATSERVICE_DAPR_APP_ID": "seatservice",
"DAPR_HTTP_PORT": "3500",
"DAPR_GRPC_PORT": "${input:DAPR_GRPC_PORT}",
"SERVICE_DAPR_APP_ID": "${input:SERVICE_NAME}",
"VEHICLEDATABROKER_DAPR_APP_ID": "vehicledatabroker"
}
}
],
"inputs": [
{
"id": "DAPR_GRPC_PORT",
"type": "command",
"command": "shellCommand.execute",
"args": {
"useSingleResult": true,
"command": "cat ./app/AppManifest.json | jq .[].DAPR_GRPC_PORT | tr -d '\"'",
"cwd": "${workspaceFolder}",
}
},
{
"id": "SERVICE_NAME",
"type": "command",
"command": "shellCommand.execute",
"args": {
"useSingleResult": true,
"command": "cat ./app/AppManifest.json | jq .[].Name | tr -d '\"'",
"cwd": "${workspaceFolder}",
}
}
]
}
4 changes: 2 additions & 2 deletions .vscode/scripts/runtime/k3d/build_vehicleapp.sh
Expand Up @@ -13,8 +13,8 @@
# SPDX-License-Identifier: Apache-2.0

ROOT_DIRECTORY=$( realpath "$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )/../../../.." )
APP_NAME=$(cat $ROOT_DIRECTORY/AppManifest.json | jq .[].Name | tr -d '"')
DOCKERFILE_FILE="$(cat $ROOT_DIRECTORY/AppManifest.json | jq .[].Dockerfile | tr -d '"')"
APP_NAME=$(cat $ROOT_DIRECTORY/app/AppManifest.json | jq .[].Name | tr -d '"')
DOCKERFILE_FILE="$(cat $ROOT_DIRECTORY/app/AppManifest.json | jq .[].Dockerfile | tr -d '"')"

if [ -n "$HTTP_PROXY" ]; then
echo "Building image with proxy configuration"
Expand Down
2 changes: 1 addition & 1 deletion .vscode/scripts/runtime/k3d/configure_controlplane.sh
Expand Up @@ -14,7 +14,7 @@
# SPDX-License-Identifier: Apache-2.0

ROOT_DIRECTORY=$( realpath "$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )/../../../.." )
DAPR_RUNTIME=$(cat $ROOT_DIRECTORY/AppManifest.json | jq .[].dependencies.dapr.runtime.version | tr -d '"')
DAPR_RUNTIME=$(cat $ROOT_DIRECTORY/app/AppManifest.json | jq .[].dependencies.dapr.runtime.version | tr -d '"')

if ! k3d registry get k3d-registry.localhost &> /dev/null
then
Expand Down
2 changes: 1 addition & 1 deletion .vscode/scripts/runtime/k3d/deploy_runtime.sh
Expand Up @@ -16,7 +16,7 @@
if ! helm status vehicleappruntime &> /dev/null
then
ROOT_DIRECTORY=$( realpath "$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )/../../../.." )
DEPENDENCIES=$(cat $ROOT_DIRECTORY/AppManifest.json | jq .[].dependencies)
DEPENDENCIES=$(cat $ROOT_DIRECTORY/app/AppManifest.json | jq .[].dependencies)
SERVICES=$(echo $DEPENDENCIES | jq '.services')

# Get Data from AppManifest.json and save to ENV
Expand Down
4 changes: 2 additions & 2 deletions .vscode/scripts/runtime/k3d/deploy_vehicleapp.sh
Expand Up @@ -13,8 +13,8 @@
# SPDX-License-Identifier: Apache-2.0

ROOT_DIRECTORY=$( realpath "$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )/../../../.." )
APP_NAME=$(cat $ROOT_DIRECTORY/AppManifest.json | jq .[].Name | tr -d '"')
APP_PORT=$(cat $ROOT_DIRECTORY/AppManifest.json | jq .[].Port | tr -d '"')
APP_NAME=$(cat $ROOT_DIRECTORY/app/AppManifest.json | jq .[].Name | tr -d '"')
APP_PORT=$(cat $ROOT_DIRECTORY/app/AppManifest.json | jq .[].Port | tr -d '"')
APP_REGISTRY="k3d-registry.localhost:12345"

helm uninstall vapp-chart --wait
Expand Down
4 changes: 2 additions & 2 deletions .vscode/scripts/runtime/local/ensure-dapr.sh
Expand Up @@ -29,8 +29,8 @@ init_dapr()
}

ROOT_DIRECTORY=$( realpath "$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )/../../../.." )
DEFAULT_DAPR_CLI_VERSION=$(cat $ROOT_DIRECTORY/AppManifest.json | jq .[].dependencies.dapr.cli.version | tr -d '"')
DEFAULT_DAPR_RUNTIME_VERSION=$(cat $ROOT_DIRECTORY/AppManifest.json | jq .[].dependencies.dapr.runtime.version | tr -d '"')
DEFAULT_DAPR_CLI_VERSION=$(cat $ROOT_DIRECTORY/app/AppManifest.json | jq .[].dependencies.dapr.cli.version | tr -d '"')
DEFAULT_DAPR_RUNTIME_VERSION=$(cat $ROOT_DIRECTORY/app/AppManifest.json | jq .[].dependencies.dapr.runtime.version | tr -d '"')

INSTALLED_DAPR_CLI_VERSION=$(dapr --version | grep "CLI version: " | sed 's/^.*: //' | sed 's/\s*//g')
INSTALLED_DAPR_RUNTIME_VERSION=$(dapr --version | grep "Runtime version: " | sed 's/^.*: //' | sed 's/\s*//g')
Expand Down
30 changes: 17 additions & 13 deletions .vscode/scripts/runtime/local/run-vehicleservices.sh
Expand Up @@ -68,21 +68,25 @@ run_service() {
--config $ROOT_DIRECTORY/.dapr/config.yaml &
}

DEPENDENCIES=$(cat $ROOT_DIRECTORY/AppManifest.json | jq .[].dependencies)
DEPENDENCIES=$(cat $ROOT_DIRECTORY/app/AppManifest.json | jq .[].dependencies)
SERVICES=$(echo $DEPENDENCIES | jq '.services')

readarray -t SERVICES_ARRAY < <(echo $SERVICES | jq -c '.[]')
if [ "$SERVICES" = "null" ];then
echo "No Services defined in AppManifest. Skip running vehicle services.";
else
readarray -t SERVICES_ARRAY < <(echo $SERVICES | jq -c '.[]')

for service in ${SERVICES_ARRAY[@]}; do
SERVICE_NAME=$(echo $service | jq '.name' | tr -d '"' )
SERVICE_IMAGE=$(echo $service | jq '.image' | tr -d '"')
SERVICE_TAG=$(echo $service | jq '.version' | tr -d '"')
if [ $SERVICE_IMAGE = "null" ] || [ $SERVICE_TAG = "null" ];then
echo "Missing configuration in AppManifest.json for Service: $SERVICE_NAME"
else
echo "Starting Service: $SERVICE_NAME"
run_service $SERVICE_NAME
fi
done
for service in ${SERVICES_ARRAY[@]}; do
SERVICE_NAME=$(echo $service | jq '.name' | tr -d '"' )
SERVICE_IMAGE=$(echo $service | jq '.image' | tr -d '"')
SERVICE_TAG=$(echo $service | jq '.version' | tr -d '"')
if [ $SERVICE_IMAGE = "null" ] || [ $SERVICE_TAG = "null" ];then
echo "Missing configuration in AppManifest.json for Service: $SERVICE_NAME"
else
echo "Starting Service: $SERVICE_NAME"
run_service $SERVICE_NAME
fi
done
fi

wait
54 changes: 31 additions & 23 deletions .vscode/scripts/runtime/utils/get-appmanifest-data.sh
Expand Up @@ -19,31 +19,39 @@ echo "#######################################################"

ROOT_DIRECTORY=$( realpath "$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )/../../../.." )

DEPENDENCIES=$(cat $ROOT_DIRECTORY/AppManifest.json | jq .[].dependencies)
DEPENDENCIES=$(cat $ROOT_DIRECTORY/app/AppManifest.json | jq .[].dependencies)
SERVICES=$(echo $DEPENDENCIES | jq '.services')
RUNTIME=$(echo $DEPENDENCIES | jq '.runtime')

readarray -t SERVICES_ARRAY < <(echo $SERVICES | jq -c '.[]')
readarray -t RUNTIME_ARRAY < <(echo $RUNTIME | jq -c '.[]')
if [ "$SERVICES" = "null" ];then
echo "No Services defined in AppManifest";
else
readarray -t SERVICES_ARRAY < <(echo $SERVICES | jq -c '.[]')
# Exports content from service dependency configuration to ENV
# $<SERVICENAME>_TAG=version
# $<SERVICENAME>_IMAGE=image
for service in ${SERVICES_ARRAY[@]}; do
name=$(jq '.name' <<< "${service}" | tr -d '"')
version=$(jq '.version' <<< "${service}" | tr -d '"')
image=$(jq '.image' <<< "${service}" | tr -d '"')
export ${name^^}_TAG=$version
export ${name^^}_IMAGE=$image
done
fi

# Exports content from service dependency configuration to ENV
# $<SERVICENAME>_TAG=version
# $<SERVICENAME>_IMAGE=image
for service in ${SERVICES_ARRAY[@]}; do
name=$(jq '.name' <<< "${service}" | tr -d '"')
version=$(jq '.version' <<< "${service}" | tr -d '"')
image=$(jq '.image' <<< "${service}" | tr -d '"')
export ${name^^}_TAG=$version
export ${name^^}_IMAGE=$image
done

# Exports content from runtime dependency configuration to ENV
# $<RUNTIMENAME>_TAG=version
# $<RUNTIMENAME>_IMAGE=image
for runtime in ${RUNTIME_ARRAY[@]}; do
name=$(jq '.name' <<< "${runtime}" | tr -d '"')
version=$(jq '.version' <<< "${runtime}" | tr -d '"')
image=$(jq '.image' <<< "${runtime}" | tr -d '"')
export ${name^^}_TAG=$version
export ${name^^}_IMAGE=$image
done
if [ "$RUNTIME" = "null" ];then
echo "No Runtime defined in AppManifest";
else
readarray -t RUNTIME_ARRAY < <(echo $RUNTIME | jq -c '.[]')
# Exports content from runtime dependency configuration to ENV
# $<RUNTIMENAME>_TAG=version
# $<RUNTIMENAME>_IMAGE=image
for runtime in ${RUNTIME_ARRAY[@]}; do
name=$(jq '.name' <<< "${runtime}" | tr -d '"')
version=$(jq '.version' <<< "${runtime}" | tr -d '"')
image=$(jq '.image' <<< "${runtime}" | tr -d '"')
export ${name^^}_TAG=$version
export ${name^^}_IMAGE=$image
done
fi
30 changes: 30 additions & 0 deletions .vscode/scripts/runtime/utils/import-example-app.sh
@@ -0,0 +1,30 @@
#!/bin/bash
# Copyright (c) 2022 Robert Bosch GmbH and Microsoft Corporation
#
# This program and the accompanying materials are made available under the
# terms of the Apache License, Version 2.0 which is available at
# https://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.
#
# SPDX-License-Identifier: Apache-2.0

SDV_EXAMPLES_PATH="$(python -c 'import os,inspect,sdv; print(os.path.dirname(inspect.getfile(sdv)))')_examples"

if [[ `git status --porcelain` ]]; then
echo "####################### WARNING #######################"
echo "#### Please commit or stash your changes before ####"
echo "#### importing the example app. ####"
echo "#### Otherwise all changes will be discarded! ####
"
echo "####################### WARNING #######################"
else
rm -rf app/ && cp -a $SDV_EXAMPLES_PATH/$@ app && pip install -r ./app/requirements.txt
echo "#######################################################"
echo "Successfully imported $@"
echo "#######################################################"
fi

0 comments on commit 5e1df64

Please sign in to comment.