build.sh 2.64 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

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

echo "===================== install package ====================="
BO ZHANG's avatar
BO ZHANG committed
32
33
34
35
36
37
38
39
40
41
if [ -f "install_local.sh" ]; then
  sh install_local.sh
else
  # default install script
  rm -rf dist
  #python setup.py build_ext --inplace
  #python setup.py install
  python setup.py sdist
  pip install dist/*.tar.gz --force-reinstall --no-deps
fi
BO ZHANG's avatar
BO ZHANG committed
42
43

echo "===================== show package info ====================="
BO ZHANG's avatar
BO ZHANG committed
44
echo " > pip show $JOB_NAME"
BO ZHANG's avatar
BO ZHANG committed
45
pip show $JOB_NAME
BO ZHANG's avatar
BO ZHANG committed
46

BO ZHANG's avatar
BO ZHANG committed
47
if [ "$JOB_NAME" != "csst_proto" ]; then
BO ZHANG's avatar
tweaks    
BO ZHANG committed
48
  echo "===================== download code style tests ====================="
49
50
  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
51
coverage run -m pytest
BO ZHANG's avatar
BO ZHANG committed
52
unittest_status=$?
BO ZHANG's avatar
BO ZHANG committed
53
54
55
56

echo "===================== make coverage ====================="
coverage report
coverage html
BO ZHANG's avatar
BO ZHANG committed
57
zip -q -r htmlcov.zip htmlcov
BO ZHANG's avatar
BO ZHANG committed
58
59

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

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

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