Skip to content

Commit

Permalink
Add cmake and clang format to pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
oyvindeide committed Nov 30, 2023
1 parent 8e823a9 commit 65df574
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 260 deletions.
7 changes: 0 additions & 7 deletions .github/workflows/style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,6 @@ jobs:
run: |
pip install ".[style]"
- name: Clang Format
run: ./script/clang-format --check

- name: CMake Format
if: ${{ always() }}
run: ./script/cmake-format --check

- name: Add matching rule
run: echo ::add-matcher::.github/flake8-matcher.json

Expand Down
15 changes: 15 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,18 @@ repos:
rev: 23.11.0
hooks:
- id: black

- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v17.0.5
hooks:
- id: clang-format
args: [ --style=file, --Werror]
exclude: .json

- repo: https://github.com/cheshirekow/cmake-format-precommit
rev: v0.6.10
hooks:
- id: cmake-format
- id: cmake-lint
exclude: FindFilesystem
args: [ "--disable:C0301,C0111,C0113" ]
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,17 @@ If you checked out submodules without having git lfs installed, you can force gi
git submodule foreach "git lfs pull"
```


### Style requirements

There are a set of style requirements, which are gathered in the `pre-commit`
configuration, to have it automatically run on each commit do:

``` sh
$ pip install pre-commit
$ pre-commit install
```

### Trouble with setup

If you encounter problems during install, try deleting the `_skbuild` folder before reinstalling.
Expand Down
145 changes: 0 additions & 145 deletions script/clang-format

This file was deleted.

102 changes: 0 additions & 102 deletions script/cmake-format

This file was deleted.

10 changes: 4 additions & 6 deletions src/clib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,14 @@ list(APPEND CMAKE_PREFIX_PATH "${_tmp_dir}")
execute_process(
COMMAND "${_python_executable}" -c
"import resdata; print(resdata.get_include())"
OUTPUT_VARIABLE ECL_INCLUDE_DIRS
OUTPUT_STRIP_TRAILING_WHITESPACE COMMAND_ECHO STDOUT COMMAND_ERROR_IS_FATAL
LAST)
OUTPUT_VARIABLE ECL_INCLUDE_DIRS OUTPUT_STRIP_TRAILING_WHITESPACE
COMMAND_ECHO STDOUT COMMAND_ERROR_IS_FATAL LAST)

execute_process(
COMMAND "${_python_executable}" -c
"import resdata; print(resdata.ResdataPrototype.lib._name)"
OUTPUT_VARIABLE ECL_LIBRARY
OUTPUT_STRIP_TRAILING_WHITESPACE COMMAND_ECHO STDOUT COMMAND_ERROR_IS_FATAL
LAST)
OUTPUT_VARIABLE ECL_LIBRARY OUTPUT_STRIP_TRAILING_WHITESPACE COMMAND_ECHO
STDOUT COMMAND_ERROR_IS_FATAL LAST)

add_library(resdata SHARED IMPORTED GLOBAL)
set_target_properties(resdata PROPERTIES IMPORTED_LOCATION "${ECL_LIBRARY}"
Expand Down

0 comments on commit 65df574

Please sign in to comment.