From 0405a146ad4a5e13b7b7ea4abab642d51bafe01d Mon Sep 17 00:00:00 2001
From: Viktor Vorobev <vorobev@in.tum.de>
Date: Mon, 21 Jun 2021 14:05:30 +0000
Subject: [PATCH] Merged in NRRPLT-8191-makefile-schema-generation (pull
 request #31)

[NRRPLT-8191] Generate schema parsers via Makefile.

* [NRRPLT-8241] Test new make shemas targets

Approved-by: Ugo Albanese
Approved-by: Krzysztof Lebioda
---
 .ci/bitbucket_api_get.bash |  7 -------
 .ci/build.bash             | 36 +++++-------------------------------
 .gitignore                 |  1 +
 Jenkinsfile                |  2 --
 4 files changed, 6 insertions(+), 40 deletions(-)
 delete mode 100644 .ci/bitbucket_api_get.bash

diff --git a/.ci/bitbucket_api_get.bash b/.ci/bitbucket_api_get.bash
deleted file mode 100644
index 3ca93ca..0000000
--- a/.ci/bitbucket_api_get.bash
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/bin/bash
-REPOSITORY=$1
-FILENAME_XSD=$2
-TOPIC_BRANCH=$3
-
-wget https://api.bitbucket.org/2.0/repositories/hbpneurorobotics/${REPOSITORY}/src/${TOPIC_BRANCH}/${FILENAME_XSD} -O ${FILENAME_XSD} \
-    && echo ${FILENAME_XSD}:${TOPIC_BRANCH}
diff --git a/.ci/build.bash b/.ci/build.bash
index 7d41274..a3601e5 100644
--- a/.ci/build.bash
+++ b/.ci/build.bash
@@ -40,42 +40,16 @@ export export PYTHONPATH=$VIRTUAL_ENV_PATH/lib/python${PYTHON_VERSION_MAJOR_MINO
 cp ${HBP}/${USER_SCRIPTS_DIR}/config_files/CLE/config.ini.sample ${HBP}/${CLE_DIR}/hbp_nrp_cle/hbp_nrp_cle/config.ini
 
 # Obtain schemas
-REPOSITORY=experiments
-[ -z "$(git ls-remote --heads  https://bitbucket.org/hbpneurorobotics/${REPOSITORY}.git ${TOPIC_BRANCH})" ] \
-        && CO_BRANCH="${DEFAULT_BRANCH}" \
-        || CO_BRANCH="${TOPIC_BRANCH}"
-bash ./.ci/bitbucket_api_get.bash "${REPOSITORY}" bibi_configuration.xsd "${CO_BRANCH}" 
-bash ./.ci/bitbucket_api_get.bash "${REPOSITORY}" ExDConfFile.xsd "${CO_BRANCH}"
-
-REPOSITORY=models
-[ -z "$(git ls-remote --heads  https://bitbucket.org/hbpneurorobotics/${REPOSITORY}.git ${TOPIC_BRANCH})" ] \
-        && CO_BRANCH="${DEFAULT_BRANCH}" \
-        || CO_BRANCH="${TOPIC_BRANCH}"
-bash ./.ci/bitbucket_api_get.bash "${REPOSITORY}" robot_model_configuration.xsd "${CO_BRANCH}"
-bash ./.ci/bitbucket_api_get.bash "${REPOSITORY}" environment_model_configuration.xsd "${CO_BRANCH}"
-
-# Generate schemas
-pushd $VIRTUAL_ENV_PATH/lib/python${PYTHON_VERSION_MAJOR_MINOR}/site-packages && rm -f hbp-nrp-distributed-nest.egg-link && popd
-make devinstall # Otherwise it can't find pyxbgen
-export pyxb_version=`grep "pyxb" ${HBP}/${EXDBACKEND_DIR}/hbp_nrp_commons/requirements.txt`
-. $VIRTUAL_ENV_PATH/bin/activate \
-        && pyxbgen -u bibi_configuration.xsd -m bibi_api_gen \
-        && pyxbgen -u ExDConfFile.xsd -m exp_conf_api_gen \
-        && pyxbgen -u robot_model_configuration.xsd -m robot_conf_api_gen \
-        && pyxbgen -u environment_model_configuration.xsd -m environment_conf_api_gen
-mv bibi_api_gen.py exp_conf_api_gen.py robot_conf_api_gen.py environment_conf_api_gen.py ${HBP}/${EXDBACKEND_DIR}/hbp_nrp_commons/hbp_nrp_commons/generated
-touch ${HBP}/${EXDBACKEND_DIR}/hbp_nrp_commons/hbp_nrp_commons/generated/__init__.py
-deactivate
-
+cd ${HBP}/${EXDBACKEND_DIR}
+make schemas-install
 
+cd ${HBP}/${BRAIN_SIMULATION_DIR}
 # Run tests
 export IGNORE_LINT='platform_venv|migrations|nest|ci_download_directory'
-# Egg-links have to be removed because make devinstall set them up wrongly
-pushd $VIRTUAL_ENV_PATH/lib/python${PYTHON_VERSION_MAJOR_MINOR}/site-packages \
-        && rm -f hbp-nrp-distributed-nest.egg-link && popd
+# verify_base-ci fails on dependencies mismach, but ignores linter errors, that are cought by Jenkins afterwards
 . $VIRTUAL_ENV_PATH/bin/activate \
         && source /opt/ros/noetic/setup.bash \
         && source $HBP/GazeboRosPackages/devel/setup.bash \
         && echo "PYTHONPATH $PYTHONPATH" \
-        && make verify_base -i
+        && make verify_base-ci
         
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
index 42b783f..0cd44f1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -12,6 +12,7 @@ build/
 ci_dep.txt
 pep8.txt
 pylint.txt
+pycodestyle.txt
 test-reports/
 coverage.xml
 .project
diff --git a/Jenkinsfile b/Jenkinsfile
index 37bb808..6de8fbc 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -70,8 +70,6 @@ pipeline {
                 //      3 - name of topic branch
                 //      4 - default branch if topic unavailable
                 //      5 - username for chown
-                
-                // TODO: fix default branch to master when admin-scripts CI is merged
                 cloneRepoTopic(env.ADMIN_SCRIPTS_DIR,   'git@bitbucket.org:hbpneurorobotics/admin-scripts.git',     env.TOPIC_BRANCH, 'master',           '${USER}')
                 cloneRepoTopic(env.USER_SCRIPTS_DIR,    'git@bitbucket.org:hbpneurorobotics/user-scripts.git',      env.TOPIC_BRANCH, env.DEFAULT_BRANCH, '${USER}') 
                 cloneRepoTopic(env.GAZEBO_ROS_DIR,      'git@bitbucket.org:hbpneurorobotics/gazeborospackages.git', env.TOPIC_BRANCH, env.DEFAULT_BRANCH, '${USER}') 
-- 
GitLab