build.sh 2.73 KB
Newer Older
BO ZHANG's avatar
BO ZHANG committed
1
2
#!/bin/bash
echo "===================== prepare for installation ====================="
BO ZHANG's avatar
BO ZHANG committed
3
# show where I am
BO ZHANG's avatar
BO ZHANG committed
4
echo " > whoami"
BO ZHANG's avatar
BO ZHANG committed
5
whoami
BO ZHANG's avatar
BO ZHANG committed
6
echo " > uname -a"
BO ZHANG's avatar
BO ZHANG committed
7
uname -a
BO ZHANG's avatar
BO ZHANG committed
8
echo " > pwd"
BO ZHANG's avatar
BO ZHANG committed
9
pwd
BO ZHANG's avatar
BO ZHANG committed
10
echo " > ls -a"
BO ZHANG's avatar
BO ZHANG committed
11
12
ls -a

BO ZHANG's avatar
BO ZHANG committed
13
# define environment variables
BO ZHANG's avatar
BO ZHANG committed
14
15
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/"
BO ZHANG's avatar
BO ZHANG committed
16
export AUX_DIR="/nfsdata/users/csstpipeline/L1Pipeline/unittests/"
BO ZHANG's avatar
BO ZHANG committed
17

BO ZHANG's avatar
BO ZHANG committed
18
# show Python environment
BO ZHANG's avatar
BO ZHANG committed
19
echo " > which python"
BO ZHANG's avatar
BO ZHANG committed
20
which python
BO ZHANG's avatar
BO ZHANG committed
21
echo " > which pip"
BO ZHANG's avatar
BO ZHANG committed
22
which pip
BO ZHANG's avatar
BO ZHANG committed
23
echo " > python --version"
BO ZHANG's avatar
BO ZHANG committed
24
25
python --version

26
27
28
echo "===================== uninstall package ====================="
pip uninstall -y "$JOB_NAME"

BO ZHANG's avatar
BO ZHANG committed
29
echo "===================== install requirements ====================="
BO ZHANG's avatar
BO ZHANG committed
30
31
32
if [ -f "requirements.txt" ]; then
  pip install -r requirements.txt
fi
BO ZHANG's avatar
BO ZHANG committed
33
34

echo "===================== install package ====================="
BO ZHANG's avatar
BO ZHANG committed
35
36
37
#if [ -f "install_local.sh" ]; then
#  sh install_local.sh
#else
BO ZHANG's avatar
BO ZHANG committed
38
  # default install script
BO ZHANG's avatar
BO ZHANG committed
39
40
41
42
43
44
#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
BO ZHANG's avatar
BO ZHANG committed
45
46

echo "===================== show package info ====================="
BO ZHANG's avatar
BO ZHANG committed
47
echo " > pip show $JOB_NAME"
BO ZHANG's avatar
BO ZHANG committed
48
pip show $JOB_NAME
BO ZHANG's avatar
BO ZHANG committed
49

BO ZHANG's avatar
BO ZHANG committed
50
if [ "$JOB_NAME" != "csst_proto" ]; then
BO ZHANG's avatar
tweaks    
BO ZHANG committed
51
  echo "===================== download code style tests ====================="
52
53
  curl -O https://csst-tb.bao.ac.cn/code/csst-l1/csst_proto/-/raw/main/pipelines/test_codestyle.py
fi
BO ZHANG's avatar
BO ZHANG committed
54
coverage run -m pytest
BO ZHANG's avatar
BO ZHANG committed
55
unittest_status=$?
BO ZHANG's avatar
BO ZHANG committed
56
57
58
59

echo "===================== make coverage ====================="
coverage report
coverage html
BO ZHANG's avatar
BO ZHANG committed
60
zip -q -r htmlcov.zip htmlcov
BO ZHANG's avatar
BO ZHANG committed
61
62

echo "===================== importability ====================="
63
64
65
66
67
68
69
70
71
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
BO ZHANG's avatar
tweaks    
BO ZHANG committed
72
else
73
  import_status=0
BO ZHANG's avatar
BO ZHANG committed
74
fi
BO ZHANG's avatar
BO ZHANG committed
75

BO ZHANG's avatar
BO ZHANG committed
76
# the exit value is determined from unit tests
BO ZHANG's avatar
BO ZHANG committed
77
if [ "$unittest_status" != 0 ] || [ "$import_status" != 0 ]; then
BO ZHANG's avatar
tweaks    
BO ZHANG committed
78
  echo "===================== TEST SUMMARY ====================="
BO ZHANG's avatar
BO ZHANG committed
79
  echo "Test failed!"
BO ZHANG's avatar
tweaks    
BO ZHANG committed
80
  echo "Importability status: $import_status"
BO ZHANG's avatar
BO ZHANG committed
81
82
83
  echo "Unit test status: $unittest_status"
  echo "===================== POST BUILD BELOW ====================="
  exit 1
BO ZHANG's avatar
BO ZHANG committed
84
else
BO ZHANG's avatar
tweaks    
BO ZHANG committed
85
  echo "===================== TEST SUMMARY ====================="
BO ZHANG's avatar
tweaks    
BO ZHANG committed
86
  echo "Test passed!"
BO ZHANG's avatar
tweaks    
BO ZHANG committed
87
  echo "Importability status: $import_status"
BO ZHANG's avatar
BO ZHANG committed
88
  echo "Unit test status: $unittest_status"
BO ZHANG's avatar
BO ZHANG committed
89
  echo "===================== POST BUILD BELOW ====================="
BO ZHANG's avatar
BO ZHANG committed
90
91
92
  exit 0
fi

BO ZHANG's avatar
BO ZHANG committed
93
94
95
# In Jenkins:
#!/bin/bash
#sh -c "$(curl -fsSL https://csst-tb.bao.ac.cn/code/csst-l1/csst_proto/-/raw/main/pipelines/build.sh)"