Skip to content

Commit 7644873

Browse files
[CI] Enable clang-format check (uxlfoundation#595)
1 parent e3402a9 commit 7644873

8 files changed

+35
-6
lines changed

.github/pull_request_template.md

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ Fixes # (GitHub issue)
1313
## All Submissions
1414

1515
- [ ] Do all unit tests pass locally? Attach a log.
16-
- [ ] Have you formatted the code using clang-format?
1716

1817
## New interfaces
1918

.github/workflows/pr.yml

+13
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,19 @@ env:
1414
PARALLEL: -j 2
1515

1616
jobs:
17+
format-checks:
18+
runs-on: ubuntu-latest
19+
name: clang-format check
20+
steps:
21+
- uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5
22+
- uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5.2.0
23+
with:
24+
python-version: '3.10'
25+
cache: 'pip'
26+
- name: Install pre-commit
27+
run: pip install pre-commit
28+
- name: Run clang-format check
29+
run: pre-commit run --all-files --show-diff-on-failure --color always
1730
unit-tests:
1831
runs-on: ubuntu-latest
1932
# One runner for each domain

.pre-commit-config.yaml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
repos:
2+
3+
- repo: https://github.com/pre-commit/mirrors-clang-format
4+
rev: v19.1.0
5+
hooks:
6+
- id: clang-format
7+
files: \.(c|cxx|cpp|h|hxx|hpp)$
8+
exclude: ^deps/

CONTRIBUTING.md

+10-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,16 @@ The general principle is to follow the style of existing/surrounding code. If yo
8181
```sh
8282
clang-format -style=file -i foo.cpp
8383
```
84-
This formats code using the `_clang_format` file found in the oneMKL top-level directory.
84+
This formats code using the `_clang_format` file found in the oneMKL top-level directory. The version of `clang-format` is specified in [`.pre-commit-config.yaml`](https://github.com/oneapi-src/oneMKL/blob/develop/.pre-commit-config.yaml). Alternatively, you can install and run `pre-commit`, which will install the specified `clang-format` version automatically:
85+
```sh
86+
python3 -m venv <venv-name>
87+
source <venv-name>/bin/activate
88+
pip install pre-commit
89+
cd <path-to-onemkl>
90+
pre-commit run --all-files
91+
deactivate
92+
```
93+
By default, `pre-commit` caches data in `~/.cache/pre-commit`. You can set `PRE_COMMIT_HOME` to use another location.
8594

8695

8796
### GN: General Naming

scripts/generate_backend_api.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def usage(err = None):
3333
print('error: %s' % err)
3434
print('''\
3535
Script to generate backend library header based on base_header.h
36-
Note: requires clang-format 9.0.0 tool to be installed
36+
Note: requires clang-format tool to be installed
3737
Usage:
3838
3939
{script} <path/to/base_header.hpp> <path/to/backend_include.hpp> <namespace>

scripts/generate_ct_instant.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def usage(err = None):
3333
print('error: %s' % err)
3434
print('''\
3535
Script to generate CT API instantiations for backend based on general_ct_templates.hpp
36-
Note: requires clang-format 9.0.0 tool to be installed
36+
Note: requires clang-format tool to be installed
3737
Usage:
3838
3939
{script} <path/to/general_ct_templates.hpp> <path/to/out_ct_header.hpp> <path/to/backend_include.hpp> <backend> <namespace>

scripts/generate_ct_templates.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def usage(err = None):
3333
print('error: %s' % err)
3434
print('''\
3535
Script to generate header file for templated compile-time API based on base_header.h
36-
Note: requires clang-format 9.0.0 tool to be installed
36+
Note: requires clang-format tool to be installed
3737
Usage:
3838
3939
{script} <path/to/base_header.hpp> <path/to/out_headername.hpp>

scripts/generate_wrappers.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def usage(err = None):
3333
print('error: %s' % err)
3434
print('''\
3535
Script to generate blank wrappers and pointers table based on header.hpp
36-
Note: requires clang-format 9.0.0 tool
36+
Note: requires clang-format tool
3737
Usage:
3838
3939
{script} <path/to/header.hpp> <path/to/table.hpp> <path/to/out_wrappers.cpp> <libname>

0 commit comments

Comments
 (0)