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

Add AMReX style CI and EditorConfig file #1349

Merged
merged 4 commits into from
Oct 6, 2023
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
62 changes: 62 additions & 0 deletions .editorconfig
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
2 changes: 2 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Replaced tabs with spaces and trimmed trailing whitespace
5a2247f598f88f80ad8b186188fccfd5537b18d3
22 changes: 22 additions & 0 deletions .github/workflows/style.yml
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
36 changes: 36 additions & 0 deletions .github/workflows/style/check_tabs.sh
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
38 changes: 38 additions & 0 deletions .github/workflows/style/check_trailing_whitespaces.sh
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