ch09_build.rst 3.8 KB
Newer Older
BO ZHANG's avatar
BO ZHANG committed
1
Build and Test
BO ZHANG's avatar
BO ZHANG committed
2
==============
BO ZHANG's avatar
BO ZHANG committed
3

BO ZHANG's avatar
BO ZHANG committed
4
5
6
7
A push to git repository will trigger an automatic build and test on the Jenkins platform.
Then a notification email from ``csst_das@nao.cas.cn`` is composed,
attached with a ``build log`` and a ``coverage report``,
is sent to relavant developers and code reviewers.
BO ZHANG's avatar
BO ZHANG committed
8

BO ZHANG's avatar
BO ZHANG committed
9
10
11
12

``build status`` explained
--------------------------

BO ZHANG's avatar
BO ZHANG committed
13
The ``build status`` is in the subject of the notification email.
BO ZHANG's avatar
BO ZHANG committed
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
Here are the explanations of them.

Successful
   Congratulations! Your code passes all tests.
Fixed
   Although last build fails, this build is successful.
Failure
   Current build fails in at least one test.
Still Failing
   Current build fails in at least one test. And last build fails.


``build log`` explained
-----------------------

BO ZHANG's avatar
BO ZHANG committed
29
The build log includes 6 sections.
BO ZHANG's avatar
BO ZHANG committed
30

BO ZHANG's avatar
BO ZHANG committed
31
[1/6] Check on versions of requirements
BO ZHANG's avatar
BO ZHANG committed
32
   The status will be non-zero if any of your requirements is behind other developers.
BO ZHANG's avatar
BO ZHANG committed
33
[2/6] Check on installation of requirements
BO ZHANG's avatar
BO ZHANG committed
34
   The status will be non-zero if ``pip install -r requirements.txt`` exit with non-zero status.
BO ZHANG's avatar
BO ZHANG committed
35
[3/6] Check on installation of package
BO ZHANG's avatar
BO ZHANG committed
36
37
38
39
40
41
42
43
44
   The status will be non-zero if the following code are unsuccessfully executed

   .. code-block:: bash

      rm -rf dist                                           # remove dist directory if exists
      python setup.py build_ext --inplace                   # build extension
      python setup.py sdist                                 # build source code
      pip install dist/*.tar.gz --force-reinstall --no-deps # install package without dependencies

BO ZHANG's avatar
BO ZHANG committed
45
[4/6] Check on import of interfaces (``top_level_interface``)
BO ZHANG's avatar
BO ZHANG committed
46
47
48
49
50
51
   The status will be non-zero if the following code are unsuccessfully executed

   .. code-block:: python

      from <your_package>.top_level_interface import *

BO ZHANG's avatar
BO ZHANG committed
52
[5/6] Run unit tests and coverage
BO ZHANG's avatar
BO ZHANG committed
53
54
55
56
57
58
   The status will be non-zero if the following code are unsuccessfully executed

   .. code-block:: bash

      coverage run -m pytest --import-mode=importlib

BO ZHANG's avatar
BO ZHANG committed
59
[6/6] ``Numpydoc`` validation of interfaces
BO ZHANG's avatar
BO ZHANG committed
60
   The status will be non-zero if the following code are unsuccessfully executed
BO ZHANG's avatar
BO ZHANG committed
61

BO ZHANG's avatar
BO ZHANG committed
62
63
64
   .. code-block:: bash

      python -m numpydoc --validate {YOUR_PACKAGE}.top_level_interface.{YOUR_FUNCTION/CLASS}
BO ZHANG's avatar
BO ZHANG committed
65

BO ZHANG's avatar
BO ZHANG committed
66
67

An example of test summary is at the end of build log (the attached ``build.zip``).
BO ZHANG's avatar
BO ZHANG committed
68
69
If all checks/tests/validations passed, you will see a section as below.

BO ZHANG's avatar
BO ZHANG committed
70
.. code-block:: none
BO ZHANG's avatar
BO ZHANG committed
71
72
73
74
75
76
77
78
79
80
81

    ===================== TEST SUMMARY =====================
    Test passed!
    Check requirements: 0
    Install requirements: 0
    Install package: 0
    Importability status: 0
    Unit test status: 0
    Numpydoc status: 0


BO ZHANG's avatar
BO ZHANG committed
82
83
84
85
86
87
Unit test coverage report
-------------------------

The ``build log`` also contains a section of unit test coverage report.
An example is below.

BO ZHANG's avatar
BO ZHANG committed
88
.. code-block:: none
BO ZHANG's avatar
BO ZHANG committed
89

BO ZHANG's avatar
BO ZHANG committed
90
91
92
    ---------- coverage: platform darwin, python 3.9.7-final-0 -----------
    Name                                Stmts   Miss  Cover   Missing
    -----------------------------------------------------------------
BO ZHANG's avatar
BO ZHANG committed
93
    csst_proto/__init__.py                  3      0   100%
BO ZHANG's avatar
BO ZHANG committed
94
95
    csst_proto/demo.py                      8      3    62%   56-57, 60
    csst_proto/flip_image.py               21      0   100%
BO ZHANG's avatar
BO ZHANG committed
96
    csst_proto/top_level_interface.py       3      0   100%
BO ZHANG's avatar
BO ZHANG committed
97
98
    -----------------------------------------------------------------
    TOTAL                                  35      3    91%
BO ZHANG's avatar
BO ZHANG committed
99

BO ZHANG's avatar
BO ZHANG committed
100
101
102

This means the overall unit test coverage is 91%.
The missing terms are also shown in the last column.
BO ZHANG's avatar
BO ZHANG committed
103
104
105
106
107
108
109
110
111
112
113
114
115
116
You can also find a detailed coverage report in ``html`` format in the attached ``htmlcov.zip``.


Caveats
-------
The Numpy style docstring check is only for the packages listed below. 

- csst_proto
- csst_cicd
- csst_ms_mbi_instrument
- csst_ms_mbi_distortion
- csst_ms_mbi_position
- csst_ms_mbi_flux
- csst_ms_mbi_photometry
BO ZHANG's avatar
BO ZHANG committed
117

BO ZHANG's avatar
BO ZHANG committed
118
We welcome other packages participate in.