-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci(actions): add ci action to check fortran source formatting (#982)
- Loading branch information
Showing
3 changed files
with
90 additions
and
1 deletion.
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,48 @@ | ||
#! /bin/bash | ||
|
||
#SEARCHPATHS=(src srcbmi utils) | ||
SEARCHPATHS=(src) | ||
EXCLUDEDIRS=(src/Utilities/Libraries/blas # external library blas | ||
src/Utilities/Libraries/daglib # external library dag | ||
src/Utilities/Libraries/rcm # external library rcm | ||
src/Utilities/Libraries/sparsekit # external library sparsekit | ||
src/Utilities/Libraries/sparskit2) # external library sparsekit2 | ||
EXCLUDEFILES=(src/Utilities/InputOutput.f90) # excluded until refactored | ||
|
||
fformatfails=() | ||
checkcount=0 | ||
|
||
for path in "${SEARCHPATHS[@]}"; do | ||
readarray -d '' files < <(find "${path}" -type f -print0 | grep -z '\.[fF]9[0,5]$') | ||
for file in "${files[@]}"; do | ||
exclude=0 | ||
|
||
for d in "${EXCLUDEDIRS[@]}"; do | ||
[[ "${d}" == $(dirname "${file}") ]] && exclude=1 && break; done | ||
if [[ ${exclude} == 1 ]]; then continue; fi | ||
|
||
for f in "${EXCLUDEFILES[@]}"; do | ||
[[ "${f}" == "${file}" ]] && exclude=1 && break; done | ||
if [[ ${exclude} == 1 ]]; then continue; fi | ||
|
||
((checkcount++)) | ||
|
||
if [[ ! -z $(fprettify -d -c ./distribution/.fprettify.yaml "${file}" 2>&1) ]]; then | ||
fformatfails+=("${file}") | ||
fi | ||
done | ||
done | ||
|
||
echo -e "\nFortran source files checked: ${checkcount}" | ||
echo -e "Fortran source files failed: ${#fformatfails[@]}\n" | ||
|
||
if [[ ${#fformatfails[@]} > 0 ]]; then | ||
for f in "${fformatfails[@]}"; do echo "${f}"; done | ||
|
||
echo -e "\nTo verify file format diff and/or warn in local environment run:" | ||
echo -e " 'fprettify -d -c <path to modflow6>/distribution/.fprettify.yaml <filepath>'\n\n" | ||
|
||
exit 1 | ||
fi | ||
|
||
exit 0 |
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
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,41 @@ | ||
name: docs | ||
|
||
on: | ||
push: | ||
branches: [ master, develop ] | ||
pull_request: | ||
branches: [ develop ] | ||
|
||
jobs: | ||
fortan-format-check: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2.3.4 | ||
|
||
- name: Setup Python | ||
uses: actions/setup-python@v4.0.0 | ||
with: | ||
python-version: 3.9 | ||
|
||
- name: Install python packages | ||
run: | | ||
.github/common/install-python-std.sh | ||
- name: Setup symbolic links on Linux | ||
run: | | ||
sudo ln -fs /usr/bin/gfortran-10 /usr/local/bin/gfortran | ||
sudo ln -fs /usr/bin/gcc-10 /usr/local/bin/gcc | ||
sudo ln -fs /usr/bin/g++-10 /usr/local/bin/g++ | ||
- name: Print python package versions | ||
run: | | ||
pip list | ||
- name: Set and print branch name | ||
run: | | ||
.github/common/git-branch-export.sh | ||
- name: Fortran source format check | ||
run: | | ||
.github/common/fortran-format-check.sh |