Skip to content

Commit 8f73298

Browse files
authored
Use pre-commit for linting in github actions (#748)
Keep things consistent by using pre-commit for linting in CI, this ensures that the same version of the tools are used in the pre-commit hooks on developer machines and in CI.
1 parent d26cef3 commit 8f73298

3 files changed

Lines changed: 14 additions & 41 deletions

File tree

.github/workflows/build.yml

Lines changed: 3 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -17,40 +17,10 @@ jobs:
1717
runs-on: ubuntu-latest
1818
steps:
1919
- uses: actions/checkout@v6
20-
21-
- name: Set up Python
22-
uses: actions/setup-python@v6
20+
- uses: actions/setup-python@v6
2321
with:
24-
python-version: 3.9
25-
26-
- name: Install dependencies
27-
run: |
28-
python -m pip install --upgrade pip
29-
pip install -r requirements-dev.txt
30-
- name: Lint with flake8
31-
run: |
32-
# stop the build if there are Python syntax errors or undefined names
33-
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
34-
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
35-
flake8 . --count --exit-zero --max-complexity=11 --max-line-length=127 --statistics
36-
flake8 --filename='*.pyx,*.px*' --ignore E901,E225,E226,E227,E402,E999
37-
- name: Lint with black
38-
run: |
39-
black --check .
40-
- name: Lint with clang-format
41-
run: |
42-
sudo apt install clang-format
43-
find implicit | grep -E '\.(cu|cuh|h|cpp)$' | xargs clang-format --dry-run --Werror
44-
if: runner.os == 'Linux'
45-
- name: Lint with isort
46-
run: |
47-
isort -c .
48-
- name: Lint with codespell
49-
run: |
50-
codespell
51-
- name: Lint with pylint
52-
run: |
53-
pylint implicit tests benchmarks examples
22+
python-version: 3.12
23+
- uses: pre-commit/action@v3.0.1
5424

5525
build-wheels:
5626
needs: [lint]

.pre-commit-config.yaml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,9 @@ repos:
2020
rev: v2.2.4
2121
hooks:
2222
- id: codespell
23-
- repo: local
23+
- repo: https://github.com/pre-commit/mirrors-clang-format
24+
rev: v22.1.4
2425
hooks:
2526
- id: clang-format
26-
name: clang-format
27-
description: Format files with ClangFormat.
28-
entry: clang-format --dry-run --Werror
29-
language: system
3027
files: \.(cu|cuh|h|cpp)$
3128

implicit/gpu/utils.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ using std::invalid_argument;
1313
// and throws exceptions on failure (which cython can proxy back to python)
1414

1515
#define CHECK_CUDA(code) \
16-
{ checkCuda((code), __FILE__, __LINE__); }
16+
{ \
17+
checkCuda((code), __FILE__, __LINE__); \
18+
}
1719
inline void checkCuda(cudaError_t code, const char *file, int line) {
1820
if (code != cudaSuccess) {
1921
std::stringstream err;
@@ -46,7 +48,9 @@ inline const char *cublasGetErrorString(cublasStatus_t status) {
4648
}
4749

4850
#define CHECK_CUBLAS(code) \
49-
{ checkCublas((code), __FILE__, __LINE__); }
51+
{ \
52+
checkCublas((code), __FILE__, __LINE__); \
53+
}
5054
inline void checkCublas(cublasStatus_t code, const char *file, int line) {
5155
if (code != CUBLAS_STATUS_SUCCESS) {
5256
std::stringstream err;
@@ -57,7 +61,9 @@ inline void checkCublas(cublasStatus_t code, const char *file, int line) {
5761
}
5862

5963
#define CHECK_CURAND(code) \
60-
{ checkCurand((code), __FILE__, __LINE__); }
64+
{ \
65+
checkCurand((code), __FILE__, __LINE__); \
66+
}
6167
inline void checkCurand(curandStatus_t code, const char *file, int line) {
6268
if (code != CURAND_STATUS_SUCCESS) {
6369
std::stringstream err;

0 commit comments

Comments
 (0)