Skip to content

Commit 2d45845

Browse files
revert files
more docs on pre-commit
1 parent ddeb557 commit 2d45845

File tree

7 files changed

+129
-11
lines changed

7 files changed

+129
-11
lines changed

.clang-format

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
---
2+
BasedOnStyle: Google
3+
Language: Cpp
4+
AlignAfterOpenBracket: Align
5+
AlignConsecutiveAssignments: 'true'
6+
AlignConsecutiveDeclarations: 'true'
7+
AlignTrailingComments: 'true'
8+
AllowAllArgumentsOnNextLine: 'false'
9+
AllowAllParametersOfDeclarationOnNextLine: 'false'
10+
AlwaysBreakBeforeMultilineStrings: 'false'
11+
AlwaysBreakTemplateDeclarations: 'Yes'
12+
BinPackArguments: 'false'
13+
BinPackParameters: 'false'
14+
BreakBeforeBraces: Linux
15+
ColumnLimit: '100'
16+
ConstructorInitializerAllOnOneLineOrOnePerLine: 'true'
17+
FixNamespaceComments: 'true'
18+
IndentAccessModifiers: 'true'
19+
IndentCaseLabels: 'true'
20+
IndentWidth: '2'
21+
NamespaceIndentation: All
22+
PointerAlignment: Left
23+
SortIncludes: Never
24+
SpaceAfterCStyleCast: 'true'
25+
SpaceAfterLogicalNot: 'false'
26+
SpaceAfterTemplateKeyword: 'false'
27+
SpaceBeforeAssignmentOperators: 'true'
28+
SpaceBeforeCtorInitializerColon: 'true'
29+
SpaceBeforeInheritanceColon: 'true'
30+
SpaceBeforeParens: ControlStatements
31+
SpacesInParentheses: 'false'
32+
SpacesInSquareBrackets: 'false'
33+
Standard: Cpp11
34+
TabWidth: '2'
35+
UseTab: Never
36+
37+
---
38+
Language: Json
39+
# Use 100 columns for JS.
40+
ColumnLimit: 100
41+
---
42+
Language: ObjC
43+
# Use 100 columns for C#.
44+
ColumnLimit: 100
45+
...

.github/workflows/.cmake-format.py renamed to .cmake-format

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@
1616

1717
# If a statement is wrapped to more than one line, than dangle the closing
1818
# parenthesis on its own line.
19-
dangle_parens = True
19+
dangle_parens = True

.github/workflows/.clang-format

-9
This file was deleted.

.github/workflows/documentation.yml

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
name: documentation
22

33
on: workflow_dispatch
4+
# on: [pull_request]
5+
46

57
permissions:
68
contents: write

.github/workflows/pre_commit.yaml

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: pre-commit GitHub Action
2+
3+
# Won't run on develop/main directly
4+
on:
5+
workflow_dispatch:
6+
inputs:
7+
branch:
8+
description: 'The branch to build'
9+
required: true
10+
pull_request:
11+
12+
jobs:
13+
pre-commit:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v3
17+
with:
18+
ref: ${{ github.event.pull_request.head.ref }}
19+
- uses: actions/setup-python@v3
20+
- uses: pre-commit/[email protected]
21+
# - uses: EndBug/[email protected]
22+
# # Only need to try and commit if the action failed
23+
# if: failure()
24+
# with:
25+
# fetch: false
26+
# committer_name: GitHub Actions
27+
# committer_email: [email protected]
28+
# message: Apply pre-commmit fixes
29+

.pre-commit-config.yaml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
2+
repos:
3+
- repo: https://github.com/cheshirekow/cmake-format-precommit
4+
rev: v0.6.13
5+
hooks:
6+
- id: cmake-format
7+
- repo: https://github.com/pre-commit/mirrors-clang-format
8+
rev: v16.0.1
9+
hooks:
10+
- id: clang-format
11+
- repo: https://github.com/pre-commit/pre-commit-hooks
12+
rev: v4.4.0
13+
hooks:
14+
- id: forbid-new-submodules
15+
- id: end-of-file-fixer
16+
- id: check-yaml
17+
args: [--allow-multiple-documents]

README.md

+35-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,42 @@ target_link_libraries(my_app PRIVATE ReSolve::ReSolve)
5353

5454
For all contributions to ReSolve please follow the [developer guidelines](CONTRIBUTING.md)
5555

56+
### Pre-commit
57+
Precommit is a framework for mmangaing and maintain multi-lanagueg pre-commit hooks. https://pre-commit.com/
5658

59+
Precommit is auto applied through CI to every pull request and every commit to the said pull request. Precommit checks for valid yaml files, end of file spaces, Syntax of C codeand etc. To see specifically what formating precommit looks for please check out our .clang-format and .cmake-format filed as well as our .pre-commit-config.yaml which show the specific precommit hooks being applied.
60+
61+
### Running Pre-commit locally
62+
To run pre-commit locally you first must install pre-commit and there are a couple ways to do this.
63+
64+
#### Prerequiste to installing pre-commit
65+
It is recommended that you install pre-commit through python. Here we assume Python is aleadly installed if that is not the case please check out these [docs](https://wiki.python.org/moin/BeginnersGuide/Download) for how to install python.
66+
67+
Next create a virtual environment with the following:
68+
```shell
69+
python -m venv /path/to/new/virtual/environment
70+
```
71+
72+
Activate the new environment:
73+
```shell
74+
source /path/to/new/virtual/environment/bin/activate
75+
```
76+
77+
Now that we are within a virtual environment we can install pre-commit via;
78+
```shell
79+
pip install pre-commit
80+
```
81+
82+
To install the hooks and have pre-commit run automatically before every commit run
83+
```shell
84+
pre-commit install --install-hooks
85+
```
86+
87+
If you want to manually run all pre-commit hooks on a repository, run
88+
```shell
89+
pre-commit run --all-files
90+
```
91+
To learn more about pre-commit usuage check out https://pre-commit.com/#usage.
5792

5893
## Test and Deploy
5994

@@ -111,4 +146,3 @@ contributions to ReSolve must be made under the smae licensing terms.
111146
**Please Note** If you are using ReSolve with any third party libraries linked
112147
in (e.g., KLU), be sure to review the respective license of the package as that
113148
license may have more restrictive terms than the ReSolve license.
114-

0 commit comments

Comments
 (0)