Skip to content

Commit

Permalink
Merge branch 'development' into true_sdc_normalization
Browse files Browse the repository at this point in the history
  • Loading branch information
zingale authored Sep 19, 2023
2 parents d86d17f + 575c8c9 commit 9f51c7e
Show file tree
Hide file tree
Showing 1,327 changed files with 121,504 additions and 85,037 deletions.
41 changes: 41 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
Checks: >
-*,
bugprone-*,
-bugprone-easily-swappable-parameters,
-bugprone-implicit-widening-of-multiplication-result,
clang-analyzer-*,
clang-diagnostic-*,
cppcoreguidelines-*,
-cppcoreguidelines-avoid-c-arrays,
-cppcoreguidelines-avoid-goto,
-cppcoreguidelines-avoid-magic-numbers,
-cppcoreguidelines-avoid-non-const-global-variables,
-cppcoreguidelines-init-variables,
-cppcoreguidelines-interfaces-global-init,
-cppcoreguidelines-macro-usage,
-cppcoreguidelines-no-malloc,
-cppcoreguidelines-non-private-member-variables-in-classes,
-cppcoreguidelines-owning-memory,
-cppcoreguidelines-pro-*,
modernize-*,
-modernize-avoid-c-arrays,
-modernize-use-trailing-return-type,
-modernize-use-using,
performance-*,
readability-*,
-readability-avoid-const-params-in-decls,
-readability-braces-around-statements,
-readability-else-after-return,
-readability-function-cognitive-complexity,
-readability-function-size,
-readability-identifier-length,
-readability-implicit-bool-conversion,
-readability-isolate-declaration,
-readability-magic-numbers,
-readability-named-parameter,
-readability-simplify-boolean-expr,
-readability-static-accessed-through-instance,
mpi-*,
openmp-*
HeaderFilterRegex: '(/Source/*/|/Util/model_parser|^\./|^tmp_build_dir/castro_sources/*/).*\.H$'
14 changes: 14 additions & 0 deletions .codespell-ignore-words
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
blocs
bloc
inout
als
truns
pres
dum
fom
fromm
thi
nd
ue
bion
aas
5 changes: 5 additions & 0 deletions .codespellrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[codespell]
skip = .git,*.ipynb,*.bib,*.ps
ignore-words = .codespell-ignore-words


37 changes: 27 additions & 10 deletions .github/workflows/c-linter.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
name: cpp-linter

on: [pull_request]

jobs:
cpp-linter:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Get submodules
- name: Get submodules
run: |
git submodule update --init
cd external/Microphysics
git fetch; git checkout development
cd ../amrex
cd ../amrex
git fetch; git checkout development
cd ../..
Expand All @@ -23,11 +24,21 @@ jobs:
sudo apt-get update -y -qq
sudo apt-get -qq -y install curl clang-tidy cmake jq clang cppcheck clang-format bear g++>=9.3.0 gfortran>=9.3.0
- name: Get cpp linter repo
- name: Install hypre
run: |
wget -q https://github.com/hypre-space/hypre/archive/refs/tags/v2.28.0.tar.gz
tar xfz v2.28.0.tar.gz
cd hypre-2.28.0/src
./configure --with-cxxstandard=17 --without-MPI
make -j 2
make install
cd ../../
- name: Get cpp linter repo
run: |
cd external
cd external
git clone https://github.com/AMReX-Astro/cpp-linter-action.git
cd ..
cd ..
- name: Check header includes
run: |
Expand All @@ -36,10 +47,16 @@ jobs:
if [[ -n "${HEADER_INCLUDES}" ]]; then exit 1; fi
- name: Run cpp linter
run: python3 external/cpp-linter-action/run_on_changed_files.py ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} -header-filter=Castro -ignore-files="amrex|Microphysics" -run-linter

run: |
export AMREX_HYPRE_HOME=${PWD}/hypre-2.28.0/src/hypre
python3 external/cpp-linter-action/run_on_changed_files.py ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} \
-ignore-files="amrex|Microphysics" \
-config-file="${GITHUB_WORKSPACE}/.clang-tidy" \
-header-filter='/Source/|/Util/model_parser|^\./' \
-run-linter
- name: Archive clang tidy report
uses: actions/upload-artifact@v1
uses: actions/upload-artifact@v3
with:
name: clang-tidy-report
path: clang-tidy-report.txt
path: clang-tidy-report.txt
37 changes: 37 additions & 0 deletions .github/workflows/check-ifdefs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: check ifdefs

on:
push:
branches:
- development
- main
pull_request:
branches:
- development

jobs:
check-ifdefs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.10'

- name: Cache pip
uses: actions/cache@v3
with:
# this path is specific to Ubuntu
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Run check-ifdefs
run: |
python .github/workflows/check_ifdefs.py .github/workflows/good_defines.txt
109 changes: 109 additions & 0 deletions .github/workflows/check_ifdefs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
#!/bin/env python

import re
import sys

from pathlib import Path


def find_source_files():
p = Path("./")
files = list(p.glob(r"**/*.cpp"))
files += list(p.glob(r"**/*.H"))
return files

def check_file(filename):

# this is a general check to see if we should further examine a line
if_general_re = re.compile(r"^(?:#if|#elif)", re.IGNORECASE|re.DOTALL)

# this checks something of the form "#ifdef NAME"
ifdef_re = re.compile(r"^#if[n]*def\s+([a-z_0-9]+)", re.IGNORECASE|re.DOTALL)

# this checks something of the form
# #if (NAME == X)
if_re = re.compile(r"^(?:#if|#elif)\s+[\(]?([a-z_0-9]+)", re.IGNORECASE|re.DOTALL)

# together these check something of the form
# #if defined(NAME1) || !defined(NAME2)
if_defined_re1 = re.compile(r"^(?:#if|#elif)\s+[!]?(?:defined)", re.IGNORECASE|re.DOTALL)
if_defined_re2 = re.compile(r"[!]?(?:defined)\s*[\(]?([a-z_0-9]+)[\)]?", re.IGNORECASE|re.DOTALL)

ierr = 0
defines = []

with open(filename) as cf:
for line in cf:
if if_general_re.search(line):

# check each of the patterns
if if_defined_re1.search(line):
g = if_defined_re2.findall(line)
defines += g
continue

if g := ifdef_re.search(line):
defines.append(g.group(1))
continue

if g := if_re.search(line):
defines.append(g.group(1))
continue


# if we made it here, then we didn't handle things
ierr = 1
print(f"unhandled, file: {filename} | {line}")

return ierr, set(defines)

if __name__ == "__main__":

good_defines_file = sys.argv[1]

# read in the list of good defines

good_defines = []
with open(good_defines_file) as gd:
for line in gd:
good_defines.append(line.strip())

all_defines = []
total_errors = 0
for f in find_source_files():
if "tmp_build_dir" in f.parts:
# skip generated files
continue
ierr, defines = check_file(f)
all_defines += defines
total_errors += ierr

# remove any header guards

defines = []
for d in all_defines:
if d.endswith("_H") or d.endswith("_H_"):
continue
if len(d) == 1 and d.isdigit():
continue
defines.append(d)

defines = sorted(set(defines))

print("found defines:")
for d in defines:
print(d)

# now check to make sure that all the defines we found are okay

invalid = []
for d in defines:
if d not in good_defines:
invalid.append(d)

if invalid or total_errors > 0:
if invalid:
print("\ninvalid defines:")
for bad in invalid:
print(bad)
sys.exit(1)
41 changes: 41 additions & 0 deletions .github/workflows/codespell.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: codespell

on:
push:
branches:
- development
- main
pull_request:
branches:
- development

jobs:
codespell:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.10'

- name: Cache pip
uses: actions/cache@v3
with:
# this path is specific to Ubuntu
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install dependencies
run: pip install -r ./requirements.txt

- name: Run codespell
run: |
codespell
39 changes: 39 additions & 0 deletions .github/workflows/compiler-warnings.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: "compiler warnings"

on: [pull_request]
jobs:
compiler_warnings:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Get submodules
run: |
git submodule update --init
cd external/Microphysics
git fetch; git checkout development
cd ../amrex
git fetch; git checkout development
cd ../..
- name: Install dependencies
run: |
sudo apt-get update -y -qq
sudo apt-get -qq -y install curl g++>=9.3.0
- name: Compile Detonation
run: |
cd Exec/science/Detonation
make USE_MPI=FALSE USE_OMP=FALSE DEBUG=TRUE WARN_ALL=TRUE WARN_ERROR=TRUE -j 2
- name: Compile subchandra
run: |
cd Exec/science/subchandra
make USE_MPI=FALSE USE_OMP=FALSE DEBUG=TRUE WARN_ALL=TRUE WARN_ERROR=TRUE -j 2
- name: Compile wdmerger
run: |
cd Exec/science/wdmerger
make USE_MPI=FALSE USE_OMP=FALSE DEBUG=TRUE WARN_ALL=TRUE WARN_ERROR=TRUE -j 2
6 changes: 3 additions & 3 deletions .github/workflows/create_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ on:
push:
# Sequence of patterns matched against refs/tags
tags:
- '[0-9][0-9].[0-9][0-9]'
- '[0-9][0-9].[0-9][0-9]'

name: Create Release

jobs:
Expand All @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Get the version
id: get_version
Expand Down
Loading

0 comments on commit 9f51c7e

Please sign in to comment.