Skip to content

Commit a98d4f9

Browse files
author
Diptorup Deb
committed
Update docs and add coverage badge.
1 parent 767ab68 commit a98d4f9

File tree

2 files changed

+49
-45
lines changed

2 files changed

+49
-45
lines changed

CONTRIBUTING.md

Lines changed: 48 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,20 @@ Install: `conda install clang-tools`
1111
- Revision: `10.0.1`
1212
- See the default configuration used by dpctl in `.clang-format`.
1313

14-
Run before each commit: `clang-format -style=file -i dpctl-capi/include/*.h dpctl-capi/include/Support/*.h dpctl-capi/source/*.cpp dpctl-capi/tests/*.cpp dpctl-capi/helper/include/*.h dpctl-capi/helper/source/*.cpp`
14+
Run before each commit:
15+
16+
```bash
17+
clang-format -style=file -i \
18+
dpctl-capi/include/*.h \
19+
dpctl-capi/include/Support/*.h \
20+
dpctl-capi/source/*.cpp \
21+
dpctl-capi/tests/*.cpp \
22+
dpctl-capi/helper/include/*.h \
23+
dpctl-capi/helper/source/*.cpp
24+
```
25+
26+
> **_NOTE:_** A much simpler option is to use `pre-commit` and the
27+
> `clang-format` hook that we provide.
1528
1629
### Python code style
1730

@@ -121,61 +134,51 @@ Run before each commit: `bandit -r dpctl -lll`
121134

122135
## Code Coverage
123136

124-
Implement python, cython and c++ file coverage using `coverage` and `llvm-cov`
125-
packages on Linux.
126-
127-
### Using Code Coverage
128-
129-
You need to install additional packages and add an environment variable to
130-
cover:
131-
- conda install cmake
132-
- conda install coverage
133-
- conda install conda-forge::lcov
134-
- conda install conda-forge::gtest
135-
- export CODE_COVERAGE=ON
136-
137-
CODE_COVERAGE allows you to build a debug version of dpctl and enable string
138-
tracing, which allows you to analyze strings to create a coverage report.
139-
It was added for the convenience of configuring the CI in the future.
140-
141-
Installing the dpctl package:
142-
- python setup.py develop
137+
Code coverage for both C and Python sources in dpctl is generated for each
138+
pull request (PR). A PR cannot be merged if it leads to a drop in the code
139+
coverage by more than five percentage points. *Ergo, do not forget to write
140+
unit tests for your changes.* To check the code coverage for your code, follow
141+
these steps:
143142

144-
It is important that there are no files of the old build in the folder.
145-
Use `git clean -xdf` to clean up the working tree.
143+
1. Install dependencies for C/C++ source.
146144

147-
The coverage report will appear during the build in the console. This report
148-
contains information about c++ file coverage.
149-
The `dpctl-c-api-coverage` folder will appear in the root folder after
150-
installation. The folder contains a report on the coverage of c++ files in html
151-
format.
145+
For C/C++ source we require `lcov`, `llvm-cov`, and `llvm-profdata`. Note
146+
that `llvm-cov` and `llvm-profdata` should be version 11.0 or higher. If you
147+
have multiple `llvm-cov` tools installed, most likely because you have
148+
multiple llvm installations, you should set the `LLVM_TOOLS_HOME`
149+
environment variable to make sure the correct one is used to generate
150+
coverage.
152151

153-
You need to run tests to cover the cython and python files:
154-
- coverage run -m unittest dpctl.tests
152+
2. Install dependencies for Python sources.
155153

156-
The required flags for the command coverage run are contained in the file
157-
`.coveragerc`.
154+
To generate the coverage data for dpctl's Python sources, you only need to
155+
install `coverage`.
158156

159-
The simplest reporting is a textual summary produced with report:
160-
- coverage report
157+
3. Build dpctl with code coverage support.
161158

162-
For each module executed, the report shows the count of executable statements,
163-
the number of those statements missed, and the resulting coverage, expressed as
164-
a percentage.
159+
```bash
160+
python setup.py develop --coverage=True
161+
pytest -q -ra --disable-warnings --cov dpctl --cov-report term-missing --pyargs dpctl -vv
162+
coverage html
163+
```
165164

166-
The `-m` flag also shows the line numbers of missing statements:
167-
- coverage report -m
165+
Note that code coverage builds the C sources with debug symbols. For this
166+
reason, the coverage flag is only available with the `develop` mode of
167+
`setup.py`.
168168

169-
To create an annotated HTML listings with coverage results:
170-
- coverage html
169+
The coverage results for the C and Python sources will be printed to the
170+
terminal during the build (C API) and during the pytest execution (Python).
171+
The detailed coverage reports for the C API is saved to the
172+
`dpctl-c-api-coverage` directory. The Python coverage reports are saved to
173+
the `htmlcov` directory.
171174

172-
The `htmlcov` folder will appear in the root folder of the project. It contains
173-
reports on the coverage of python and cython files in html format.
175+
The coverage data for every PR is also available online at
176+
[coveralls.io](https://coveralls.io/github/IntelPython/dpctl).
174177

175-
Erase previously collected coverage data:
176-
- coverage erase
178+
> **_NOTE:_** Run `git clean -xdf` to clean up the working tree before running
179+
> a fresh build with code coverage data generation.
177180

178-
### Error in the build process
181+
## Error in the build process
179182

180183
An error occurs during the dcptl build with the CODE_COVERAGE environment
181184
variable:

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
22
[![Imports: isort](https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336)](https://pycqa.github.io/isort/)
3+
[![Coverage Status](https://coveralls.io/repos/github/IntelPython/dpctl/badge.svg?branch=master)](https://coveralls.io/github/IntelPython/dpctl?branch=master)
34

45
What?
56
====

0 commit comments

Comments
 (0)