From 90bd99898ce2108d10f9d7f2ca57473d2da6d7b6 Mon Sep 17 00:00:00 2001 From: Michael Zingale Date: Thu, 19 Oct 2023 09:37:15 -0400 Subject: [PATCH 1/5] add an action to enforce consistency in GNUmakefiles --- .github/workflows/check-makefiles.yml | 38 ++++++++++++++++++++++ .github/workflows/check_makefiles.py | 47 +++++++++++++++++++++++++++ Exec/mhd_tests/Alfven/GNUmakefile | 2 +- Exec/mhd_tests/BrioWu/GNUmakefile | 2 +- Exec/mhd_tests/species/GNUmakefile | 2 +- Exec/science/nova/GNUmakefile | 2 +- 6 files changed, 89 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/check-makefiles.yml create mode 100644 .github/workflows/check_makefiles.py diff --git a/.github/workflows/check-makefiles.yml b/.github/workflows/check-makefiles.yml new file mode 100644 index 0000000000..396393f383 --- /dev/null +++ b/.github/workflows/check-makefiles.yml @@ -0,0 +1,38 @@ +name: check makefiles + +on: + push: + branches: + - development + - main + pull_request: + branches: + - development + +jobs: + check-ifdefs: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + 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_makefiles.py + diff --git a/.github/workflows/check_makefiles.py b/.github/workflows/check_makefiles.py new file mode 100644 index 0000000000..a103f95a33 --- /dev/null +++ b/.github/workflows/check_makefiles.py @@ -0,0 +1,47 @@ +import sys +from pathlib import Path + +correct_params = { + "DEBUG": "FALSE", + "USE_MPI": "TRUE", + "COMP": "gnu", + "USE_CUDA": "FALSE", + "USE_HIP": "FALSE", + "PRECISION": "DOUBLE", + "PROFILE": "FALSE"} + + +def find_source_files(): + p = Path("./Exec") + files = list(p.glob(r"**/GNUmakefile")) + return files + +def check_makefile(makefile): + + with open(makefile) as mf: + for _line in mf: + if idx := _line.find("#") >= 0: + line = _line[:idx] + else: + line = _line + + for key in correct_params: + if key in line: + try: + _, v = line.split(":=") + except ValueError: + try: + _, v = line.split("=") + except ValueError: + sys.exit(f"invalid line: {line}") + + if not v.strip() == correct_params[key]: + sys.exit(f"invalid param {key} in {makefile}") + +if __name__ == "__main__": + + for f in find_source_files(): + check_makefile(f) + + + diff --git a/Exec/mhd_tests/Alfven/GNUmakefile b/Exec/mhd_tests/Alfven/GNUmakefile index d0420ce36b..18a723c41d 100644 --- a/Exec/mhd_tests/Alfven/GNUmakefile +++ b/Exec/mhd_tests/Alfven/GNUmakefile @@ -1,7 +1,7 @@ PRECISION = DOUBLE PROFILE = FALSE -DEBUG = TRUE +DEBUG = FALSE DIM = 3 diff --git a/Exec/mhd_tests/BrioWu/GNUmakefile b/Exec/mhd_tests/BrioWu/GNUmakefile index d0420ce36b..18a723c41d 100644 --- a/Exec/mhd_tests/BrioWu/GNUmakefile +++ b/Exec/mhd_tests/BrioWu/GNUmakefile @@ -1,7 +1,7 @@ PRECISION = DOUBLE PROFILE = FALSE -DEBUG = TRUE +DEBUG = FALSE DIM = 3 diff --git a/Exec/mhd_tests/species/GNUmakefile b/Exec/mhd_tests/species/GNUmakefile index d601c6bae0..69314fc30b 100644 --- a/Exec/mhd_tests/species/GNUmakefile +++ b/Exec/mhd_tests/species/GNUmakefile @@ -1,7 +1,7 @@ PRECISION = DOUBLE PROFILE = FALSE -DEBUG = TRUE +DEBUG = FALSE DIM = 3 diff --git a/Exec/science/nova/GNUmakefile b/Exec/science/nova/GNUmakefile index 6772310dd6..e2a49d9aca 100644 --- a/Exec/science/nova/GNUmakefile +++ b/Exec/science/nova/GNUmakefile @@ -7,7 +7,7 @@ COMP = gnu USE_MPI = TRUE USE_OMP = FALSE -USE_CUDA = TRUE +USE_CUDA = FALSE USE_REACT = TRUE USE_DIFFUSION = TRUE From d416b831024fba10a4d59ac5d27b0000279ed629 Mon Sep 17 00:00:00 2001 From: Michael Zingale Date: Thu, 19 Oct 2023 09:44:51 -0400 Subject: [PATCH 2/5] another attempt --- .github/workflows/check_makefiles.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/check_makefiles.py b/.github/workflows/check_makefiles.py index a103f95a33..60729f5575 100644 --- a/.github/workflows/check_makefiles.py +++ b/.github/workflows/check_makefiles.py @@ -1,3 +1,4 @@ +import re import sys from pathlib import Path @@ -28,12 +29,9 @@ def check_makefile(makefile): for key in correct_params: if key in line: try: - _, v = line.split(":=") + k, v = re.split(":=|\?=|=", line) except ValueError: - try: - _, v = line.split("=") - except ValueError: - sys.exit(f"invalid line: {line}") + sys.exit(f"invalid line: {line}") if not v.strip() == correct_params[key]: sys.exit(f"invalid param {key} in {makefile}") From 0f58aa9eec2c8ef16e7acdc15c3c242c0245249f Mon Sep 17 00:00:00 2001 From: Michael Zingale Date: Thu, 19 Oct 2023 09:48:22 -0400 Subject: [PATCH 3/5] fix another --- Exec/scf_tests/single_star/GNUmakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Exec/scf_tests/single_star/GNUmakefile b/Exec/scf_tests/single_star/GNUmakefile index 1fb3b047d5..b8bad88989 100644 --- a/Exec/scf_tests/single_star/GNUmakefile +++ b/Exec/scf_tests/single_star/GNUmakefile @@ -15,7 +15,7 @@ DEBUG ?= FALSE DIM := 3 -COMP ?= gcc +COMP ?= gnu USE_MPI ?= TRUE USE_OMP ?= FALSE From f3fe099d77f06c8079e37d93d8bda8a0b63ef46f Mon Sep 17 00:00:00 2001 From: Michael Zingale Date: Thu, 19 Oct 2023 09:53:02 -0400 Subject: [PATCH 4/5] finish fixes --- Exec/gravity_tests/uniform_cube/GNUmakefile | 2 +- Exec/gravity_tests/uniform_sphere/GNUmakefile | 2 +- Exec/mhd_tests/MagnetosonicWaves/GNUmakefile | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Exec/gravity_tests/uniform_cube/GNUmakefile b/Exec/gravity_tests/uniform_cube/GNUmakefile index 4023488bac..dd54908a9d 100644 --- a/Exec/gravity_tests/uniform_cube/GNUmakefile +++ b/Exec/gravity_tests/uniform_cube/GNUmakefile @@ -15,7 +15,7 @@ DEBUG ?= FALSE DIM ?= 3 -COMP ?= gcc +COMP ?= gnu USE_MPI ?= TRUE USE_OMP ?= FALSE diff --git a/Exec/gravity_tests/uniform_sphere/GNUmakefile b/Exec/gravity_tests/uniform_sphere/GNUmakefile index 50dc156659..ae6e618624 100644 --- a/Exec/gravity_tests/uniform_sphere/GNUmakefile +++ b/Exec/gravity_tests/uniform_sphere/GNUmakefile @@ -15,7 +15,7 @@ DEBUG ?= FALSE DIM ?= 3 -COMP ?= gcc +COMP ?= gnu USE_MPI ?= TRUE USE_OMP ?= FALSE diff --git a/Exec/mhd_tests/MagnetosonicWaves/GNUmakefile b/Exec/mhd_tests/MagnetosonicWaves/GNUmakefile index d0420ce36b..18a723c41d 100644 --- a/Exec/mhd_tests/MagnetosonicWaves/GNUmakefile +++ b/Exec/mhd_tests/MagnetosonicWaves/GNUmakefile @@ -1,7 +1,7 @@ PRECISION = DOUBLE PROFILE = FALSE -DEBUG = TRUE +DEBUG = FALSE DIM = 3 From ac0d86aa91f857d06a101fc38519d98afb9ffca9 Mon Sep 17 00:00:00 2001 From: Michael Zingale Date: Thu, 19 Oct 2023 10:51:27 -0400 Subject: [PATCH 5/5] disable USE_OMP --- .github/workflows/check_makefiles.py | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/check_makefiles.py b/.github/workflows/check_makefiles.py index 60729f5575..d9e17baa47 100644 --- a/.github/workflows/check_makefiles.py +++ b/.github/workflows/check_makefiles.py @@ -5,6 +5,7 @@ correct_params = { "DEBUG": "FALSE", "USE_MPI": "TRUE", + "USE_OMP": "FALSE", "COMP": "gnu", "USE_CUDA": "FALSE", "USE_HIP": "FALSE",