build.sh 2.44 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
echo " > whoami"
BO ZHANG's avatar
BO ZHANG committed
4
whoami
BO ZHANG's avatar
BO ZHANG committed
5
echo " > uname -a"
BO ZHANG's avatar
BO ZHANG committed
6
uname -a
BO ZHANG's avatar
BO ZHANG committed
7
echo " > pwd"
BO ZHANG's avatar
BO ZHANG committed
8
pwd
BO ZHANG's avatar
BO ZHANG committed
9
echo " > ls -a"
BO ZHANG's avatar
BO ZHANG committed
10
11
ls -a

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

BO ZHANG's avatar
BO ZHANG committed
17
echo " > which python"
BO ZHANG's avatar
BO ZHANG committed
18
which python
BO ZHANG's avatar
BO ZHANG committed
19
echo " > which pip"
BO ZHANG's avatar
BO ZHANG committed
20
which pip
BO ZHANG's avatar
BO ZHANG committed
21
echo " > python --version"
BO ZHANG's avatar
BO ZHANG committed
22
23
python --version

BO ZHANG's avatar
BO ZHANG committed
24
echo "===================== install requirements ====================="
BO ZHANG's avatar
BO ZHANG committed
25
26
27
pip install -r requirements.txt

echo "===================== install package ====================="
BO ZHANG's avatar
BO ZHANG committed
28
29
30
31
32
rm -rf dist
#python setup.py build_ext --inplace
#python setup.py install
python setup.py sdist
pip install dist/*.tar.gz --force-reinstall
BO ZHANG's avatar
BO ZHANG committed
33
34

echo "===================== show package info ====================="
BO ZHANG's avatar
BO ZHANG committed
35
echo " > pip show $JOB_NAME"
BO ZHANG's avatar
BO ZHANG committed
36
pip show $JOB_NAME
BO ZHANG's avatar
BO ZHANG committed
37

BO ZHANG's avatar
BO ZHANG committed
38
if [ "$JOB_NAME" != "csst_proto" ]; then
BO ZHANG's avatar
tweaks    
BO ZHANG committed
39
  echo "===================== download code style tests ====================="
40
41
  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
42
coverage run -m pytest
BO ZHANG's avatar
BO ZHANG committed
43
unittest_status=$?
BO ZHANG's avatar
BO ZHANG committed
44
45
46
47

echo "===================== make coverage ====================="
coverage report
coverage html
BO ZHANG's avatar
BO ZHANG committed
48
zip -q -r htmlcov.zip htmlcov
BO ZHANG's avatar
BO ZHANG committed
49
50

echo "===================== importability ====================="
51
52
53
54
55
56
57
58
59
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
60
else
61
  import_status=0
BO ZHANG's avatar
BO ZHANG committed
62
fi
BO ZHANG's avatar
BO ZHANG committed
63

BO ZHANG's avatar
BO ZHANG committed
64
# the exit value is determined from unit tests
BO ZHANG's avatar
BO ZHANG committed
65
if [ "$unittest_status" != 0 ] || [ "$import_status" != 0 ]; then
BO ZHANG's avatar
tweaks    
BO ZHANG committed
66
  echo "===================== TEST SUMMARY ====================="
BO ZHANG's avatar
BO ZHANG committed
67
  echo "Test failed!"
BO ZHANG's avatar
tweaks    
BO ZHANG committed
68
  echo "Importability status: $import_status"
BO ZHANG's avatar
BO ZHANG committed
69
70
71
  echo "Unit test status: $unittest_status"
  echo "===================== POST BUILD BELOW ====================="
  exit 1
BO ZHANG's avatar
BO ZHANG committed
72
else
BO ZHANG's avatar
tweaks    
BO ZHANG committed
73
  echo "===================== TEST SUMMARY ====================="
BO ZHANG's avatar
tweaks    
BO ZHANG committed
74
  echo "Test passed!"
BO ZHANG's avatar
tweaks    
BO ZHANG committed
75
  echo "Importability status: $import_status"
BO ZHANG's avatar
BO ZHANG committed
76
  echo "Unit test status: $unittest_status"
BO ZHANG's avatar
BO ZHANG committed
77
  echo "===================== POST BUILD BELOW ====================="
BO ZHANG's avatar
BO ZHANG committed
78
79
80
  exit 0
fi

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