-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add AMReX style CI and EditorConfig file (#1349)
https://editorconfig.org/ has instructions on setting up your editor to follow the configured style.
- Loading branch information
Showing
5 changed files
with
160 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# http://EditorConfig.org | ||
# | ||
# precedence of rules is bottom to top | ||
|
||
# this is the top-most EditorConfig file | ||
root = true | ||
|
||
|
||
[*.{c,h,cpp,hpp,H,py}] | ||
# 4 space indentation | ||
indent_style = space | ||
indent_size = 4 | ||
|
||
# Clean up trailing whitespace | ||
trim_trailing_whitespace = true | ||
|
||
# unix-style newlines | ||
end_of_line = lf | ||
|
||
# newline ending in files | ||
insert_final_newline = true | ||
|
||
[networks/**/reaclib_rates.H] | ||
# some reaclib rate labels have trailing spaces | ||
trim_trailing_whitespace = false | ||
|
||
|
||
[*.md] | ||
# two end of line whitespaces are newlines without a paragraph | ||
trim_trailing_whitespace = false | ||
|
||
|
||
[*.rst] | ||
# Enforce UTF-8 encoding | ||
charset = utf-8 | ||
|
||
# Unix-style newlines | ||
end_of_line = lf | ||
|
||
# Newline ending in files | ||
insert_final_newline = true | ||
|
||
# 3 space indentation | ||
indent_style = space | ||
indent_size = 3 | ||
|
||
# Clean up trailing whitespace | ||
trim_trailing_whitespace = true | ||
|
||
[{Makefile,GNUmakefile,Make.*}] | ||
# TABs are part of its syntax | ||
indent_style = tab | ||
indent_size = unset | ||
|
||
|
||
[util/gcem/**] | ||
# don't mess with the gcem subtree | ||
indent_style = unset | ||
indent_size = unset | ||
trim_trailing_whitespace = unset | ||
end_of_line = unset | ||
insert_final_newline = unset |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Replaced tabs with spaces and trimmed trailing whitespace | ||
5a2247f598f88f80ad8b186188fccfd5537b18d3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
name: Style | ||
|
||
on: [push, pull_request] | ||
|
||
concurrency: | ||
group: ${{ github.ref }}-${{ github.head_ref }}-style | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
tabs: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Tabs | ||
run: .github/workflows/style/check_tabs.sh | ||
|
||
trailing_whitespaces: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Trailing Whitespaces | ||
run: .github/workflows/style/check_trailing_whitespaces.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -eu -o pipefail | ||
|
||
find . -type d \( -name .git \ | ||
-o -path ./paper \ | ||
-o -name build -o -name install \ | ||
-o -name tmp_build_dir -o -name tmp_install_dir \ | ||
\) -prune -o \ | ||
-type f \( \( -name "*.H" -o -name "*.h" -o -name "*.hh" -o -name "*.hpp" \ | ||
-o -name "*.c" -o -name "*.cc" -o -name "*.cpp" -o -name "*.cxx" \ | ||
-o -name "*.f" -o -name "*.F" -o -name "*.f90" -o -name "*.F90" \ | ||
-o -name "*.py" \ | ||
-o -name "*.md" -o -name "*.rst" \ | ||
-o -name "*.sh" \ | ||
-o -name "*.tex" \ | ||
-o -name "*.txt" \ | ||
-o -name "*.yml" \) \ | ||
-a \( ! -name "*.tab.h" -a ! -name "*.tab.nolint.H" \ | ||
-a ! -name "*.lex.h" -a ! -name "*.lex.nolint.H" \) \ | ||
\) \ | ||
-exec grep -Iq . {} \; \ | ||
-exec sed -i 's/\t/\ \ \ \ /g' {} + | ||
|
||
gitdiff=`git diff` | ||
|
||
if [ -z "$gitdiff" ] | ||
then | ||
exit 0 | ||
else | ||
echo -e "\nTabs are not allowed. Changes suggested by" | ||
echo -e " ${0}\n" | ||
git --no-pager diff | ||
echo "" | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -eu -o pipefail | ||
|
||
find . -type d \( -name .git \ | ||
-o -path ./paper \ | ||
-o -name build -o -name install \ | ||
-o -name tmp_build_dir -o -name tmp_install_dir \ | ||
-o -path ./util/gcem \ | ||
\) -prune -o \ | ||
-type f \( \( -name "*.H" -o -name "*.h" -o -name "*.hh" -o -name "*.hpp" \ | ||
-o -name "*.c" -o -name "*.cc" -o -name "*.cpp" -o -name "*.cxx" \ | ||
-o -name "*.f" -o -name "*.F" -o -name "*.f90" -o -name "*.F90" \ | ||
-o -name "*.py" \ | ||
-o -name "*.rst" \ | ||
-o -name "*.sh" \ | ||
-o -name "*.tex" \ | ||
-o -name "*.txt" \ | ||
-o -name "*.yml" \) \ | ||
-a \( ! -name "*.tab.h" -a ! -name "*.tab.nolint.H" \ | ||
-a ! -name "*.lex.h" -a ! -name "*.lex.nolint.H" \ | ||
-a ! -path "./networks/*/reaclib_rates.H" \) \ | ||
\) \ | ||
-exec grep -Iq . {} \; \ | ||
-exec sed -i 's/[[:blank:]]\+$//g' {} + | ||
|
||
gitdiff=`git diff` | ||
|
||
if [ -z "$gitdiff" ] | ||
then | ||
exit 0 | ||
else | ||
echo -e "\nTrailing whitespaces at the end of a line are not allowed. Changes suggested by" | ||
echo -e " ${0}\n" | ||
git --no-pager diff | ||
echo "" | ||
exit 1 | ||
fi |