#!/bin/bash echo "===================== prepare for installation =====================" # show where I am echo " > whoami" whoami echo " > uname -a" uname -a echo " > pwd" pwd echo " > ls -a" ls -a # define environment variables export CSST_SIMS_C3="/nfsdata/share/csst_simulation_data/Cycle-3-SimuData/" export CSST_SIMS_C5_2="/nfsdata/share/csst_simulation_data/Cycle-5-SimuData/" export AUX_DIR="/nfsdata/users/csstpipeline/L1Pipeline/unittests/" # show Python environment echo " > which python" which python echo " > which pip" which pip echo " > python --version" python --version echo "===================== install requirements =====================" if [ -f "requirements.txt" ]; then pip install -r requirements.txt fi echo "===================== install package =====================" #if [ -f "install_local.sh" ]; then # sh install_local.sh #else # default install script #python setup.py install rm -rf dist python setup.py build_ext --inplace python setup.py sdist pip install dist/*.tar.gz --force-reinstall --no-deps #fi echo "===================== show package info =====================" echo " > pip show $JOB_NAME" pip show $JOB_NAME if [ "$JOB_NAME" != "csst_proto" ]; then echo "===================== download code style tests =====================" curl -O https://csst-tb.bao.ac.cn/code/csst-l1/csst_proto/-/raw/main/pipelines/test_codestyle.py fi coverage run -m pytest unittest_status=$? echo "===================== make coverage =====================" coverage report coverage html zip -q -r htmlcov.zip htmlcov echo "===================== importability =====================" if [ "$JOB_NAME" != "csst_common" ]; then echo " > try 'from $JOB_NAME.top_level_interface import *'" python -c "from $JOB_NAME.top_level_interface import *" import_status=$? if [ "$import_status" != 0 ]; then echo "Import failed!" else echo "Import done!" fi else import_status=0 fi # the exit value is determined from unit tests if [ "$unittest_status" != 0 ] || [ "$import_status" != 0 ]; then echo "===================== TEST SUMMARY =====================" echo "Test failed!" echo "Importability status: $import_status" echo "Unit test status: $unittest_status" echo "===================== POST BUILD BELOW =====================" exit 1 else echo "===================== TEST SUMMARY =====================" echo "Test passed!" echo "Importability status: $import_status" echo "Unit test status: $unittest_status" echo "===================== POST BUILD BELOW =====================" exit 0 fi # In Jenkins: #!/bin/bash #sh -c "$(curl -fsSL https://csst-tb.bao.ac.cn/code/csst-l1/csst_proto/-/raw/main/pipelines/build.sh)"