build.sh 2.33 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
24
25
26
27
28
29
30
python --version

echo "===================== isntall requirements ====================="
pip install -r requirements.txt

echo "===================== install package ====================="
sh install_local.sh

echo "===================== show package info ====================="
BO ZHANG's avatar
BO ZHANG committed
31
echo " > pip show $JOB_NAME"
BO ZHANG's avatar
BO ZHANG committed
32
pip show $JOB_NAME
BO ZHANG's avatar
BO ZHANG committed
33

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

echo "===================== make coverage ====================="
coverage report
coverage html
# zip -q -r htmlcov.zip htmlcov

echo "===================== importability ====================="
47
48
49
50
51
52
53
54
55
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
56
else
57
  import_status=0
BO ZHANG's avatar
BO ZHANG committed
58
fi
BO ZHANG's avatar
BO ZHANG committed
59

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

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