Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CI] Enable clang-format check #595

Merged
merged 2 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ Fixes # (GitHub issue)
## All Submissions

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

## New interfaces

Expand Down
13 changes: 13 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,19 @@ env:
PARALLEL: -j 2

jobs:
format-checks:
runs-on: ubuntu-latest
name: clang-format check
steps:
- uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5
- uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5.2.0
with:
python-version: '3.10'
cache: 'pip'
- name: Install pre-commit
run: pip install pre-commit
- name: Run clang-format check
run: pre-commit run --all-files --show-diff-on-failure --color always
Rbiessy marked this conversation as resolved.
Show resolved Hide resolved
unit-tests:
runs-on: ubuntu-latest
# One runner for each domain
Expand Down
8 changes: 8 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
repos:

- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v19.1.0
hooks:
- id: clang-format
files: \.(c|cxx|cpp|h|hxx|hpp)$
exclude: ^deps/
11 changes: 10 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,16 @@ The general principle is to follow the style of existing/surrounding code. If yo
```sh
clang-format -style=file -i foo.cpp
```
This formats code using the `_clang_format` file found in the oneMKL top-level directory.
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:
```sh
python3 -m venv <venv-name>
source <venv-name>/bin/activate
pip install pre-commit
cd <path-to-onemkl>
pre-commit run --all-files
deactivate
```
By default, `pre-commit` caches data in `~/.cache/pre-commit`. You can set `PRE_COMMIT_HOME` to use another location.


### GN: General Naming
Expand Down
2 changes: 1 addition & 1 deletion scripts/generate_backend_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def usage(err = None):
print('error: %s' % err)
print('''\
Script to generate backend library header based on base_header.h
Note: requires clang-format 9.0.0 tool to be installed
Note: requires clang-format tool to be installed
Usage:

{script} <path/to/base_header.hpp> <path/to/backend_include.hpp> <namespace>
Expand Down
2 changes: 1 addition & 1 deletion scripts/generate_ct_instant.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def usage(err = None):
print('error: %s' % err)
print('''\
Script to generate CT API instantiations for backend based on general_ct_templates.hpp
Note: requires clang-format 9.0.0 tool to be installed
Note: requires clang-format tool to be installed
Usage:

{script} <path/to/general_ct_templates.hpp> <path/to/out_ct_header.hpp> <path/to/backend_include.hpp> <backend> <namespace>
Expand Down
2 changes: 1 addition & 1 deletion scripts/generate_ct_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def usage(err = None):
print('error: %s' % err)
print('''\
Script to generate header file for templated compile-time API based on base_header.h
Note: requires clang-format 9.0.0 tool to be installed
Note: requires clang-format tool to be installed
Usage:

{script} <path/to/base_header.hpp> <path/to/out_headername.hpp>
Expand Down
2 changes: 1 addition & 1 deletion scripts/generate_wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def usage(err = None):
print('error: %s' % err)
print('''\
Script to generate blank wrappers and pointers table based on header.hpp
Note: requires clang-format 9.0.0 tool
Note: requires clang-format tool
Usage:

{script} <path/to/header.hpp> <path/to/table.hpp> <path/to/out_wrappers.cpp> <libname>
Expand Down
Loading