Skip to content

Commit b742fa7

Browse files
author
Diptorup Deb
committed
Update CONTRIBUTING.md
1 parent c0704e9 commit b742fa7

File tree

1 file changed

+47
-17
lines changed

1 file changed

+47
-17
lines changed

CONTRIBUTING.md

Lines changed: 47 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,30 @@ Run before each commit: `clang-format -style=file -i dpctl-capi/include/*.h dpct
1515

1616
### Python code style
1717

18-
We use [black](https://black.readthedocs.io/en/stable/) code formatter.
18+
We use the following Python code style tools:
19+
- [black](https://black.readthedocs.io/en/stable/) code formatter.
20+
- Revision: `20.8b1`.
21+
- [flake8](https://flake8.pycqa.org/en/latest/) linter.
22+
- Revision `3.9.1`.
23+
- [isort](https://pycqa.github.io/isort/) import sorter.
24+
- Revision `5.8.0`.
1925

20-
- Revision: `20.8b1`.
21-
- See configuration in `pyproject.toml`.
26+
- Refer `pyproject.toml` and `.flake8` config files for current configurations.
2227

23-
Run before each commit: `black .`
28+
Please run these three tools before each commit. Although, you may choose to
29+
do so manually, but it is much easier and preferable to automate these checks.
30+
Refer your IDE docs to set them up in your IDE, or you can set up `pre-commit`
31+
to add git hooks.
32+
33+
### Setting up pre-commit
34+
35+
A `.pre-commit-config.yaml` is included to run various check before you
36+
commit your code. Here are the steps to setup `pre-commit` in your workflow:
37+
38+
- Install `pre-commit`: `pip install pre-commit`
39+
- Install the git hook scripts: `pre-commit install`
40+
41+
That should be it!
2442

2543
### C/C++ File Headers
2644

@@ -61,8 +79,9 @@ Few things to note about this format:
6179
- The copyright year should be updated every calendar year.
6280
- Each comment line should be a max of 80 chars.
6381
- A Doxygen `\file` tag describing the contents of the file must be provided.
64-
Also note that the `\file` tag is inside a Doxygen comment block (defined by `///`
65-
comment marker instead of the `//` comment marker used in the rest of the header.
82+
Also note that the `\file` tag is inside a Doxygen comment block (
83+
defined by `///` comment marker instead of the `//` comment marker used in the
84+
rest of the header.
6685

6786
### Python File Headers
6887

@@ -91,7 +110,8 @@ The copyright year should be updated every calendar year.
91110

92111
### Bandit
93112

94-
We use [Bandit](https://github.com/PyCQA/bandit) to find common security issues in Python code.
113+
We use [Bandit](https://github.com/PyCQA/bandit) to find common security issues
114+
in Python code.
95115

96116
Install: `pip install bandit`
97117

@@ -101,18 +121,21 @@ Run before each commit: `bandit -r dpctl -lll`
101121

102122
## Code Coverage
103123

104-
Implement python, cython and c++ file coverage using `coverage` and `llvm-cov` packages on Linux.
124+
Implement python, cython and c++ file coverage using `coverage` and `llvm-cov`
125+
packages on Linux.
105126

106127
### Using Code Coverage
107128

108-
You need to install additional packages and add an environment variable to cover:
129+
You need to install additional packages and add an environment variable to
130+
cover:
109131
- conda install cmake
110132
- conda install coverage
111133
- conda install conda-forge::lcov
112134
- conda install conda-forge::gtest
113135
- export CODE_COVERAGE=ON
114136

115-
CODE_COVERAGE allows you to build a debug version of dpctl and enable string tracing, which allows you to analyze strings to create a coverage report.
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.
116139
It was added for the convenience of configuring the CI in the future.
117140

118141
Installing the dpctl package:
@@ -121,34 +144,41 @@ Installing the dpctl package:
121144
It is important that there are no files of the old build in the folder.
122145
Use `git clean -xdf` to clean up the working tree.
123146

124-
The coverage report will appear during the build in the console. This report contains information about c++ file coverage.
125-
The `dpctl-c-api-coverage` folder will appear in the root folder after installation.
126-
The folder contains a report on the coverage of c++ files in html format.
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.
127152

128153
You need to run tests to cover the cython and python files:
129154
- coverage run -m unittest dpctl.tests
130155

131-
The required flags for the command coverage run are contained in the file `.coveragerc`.
156+
The required flags for the command coverage run are contained in the file
157+
`.coveragerc`.
132158

133159
The simplest reporting is a textual summary produced with report:
134160
- coverage report
135161

136-
For each module executed, the report shows the count of executable statements, the number of those statements missed, and the resulting coverage, expressed as a percentage.
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.
137165

138166
The `-m` flag also shows the line numbers of missing statements:
139167
- coverage report -m
140168

141169
To create an annotated HTML listings with coverage results:
142170
- coverage html
143171

144-
The `htmlcov` folder will appear in the root folder of the project. It contains reports on the coverage of python and cython files in html format.
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.
145174

146175
Erase previously collected coverage data:
147176
- coverage erase
148177

149178
### Error in the build process
150179

151-
An error occurs during the dcptl build with the CODE_COVERAGE environment variable:
180+
An error occurs during the dcptl build with the CODE_COVERAGE environment
181+
variable:
152182
```
153183
error: '../compat/unistd.h' file not found, did you mean 'compat/unistd.h'?
154184
# include "../compat/unistd.h"

0 commit comments

Comments
 (0)