Skip to content

Commit

Permalink
ci(msvs): workflow to verify msvs project files are complete
Browse files Browse the repository at this point in the history
  • Loading branch information
langevin-usgs committed Sep 23, 2023
1 parent 48eb172 commit d9a1864
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 1 deletion.
52 changes: 52 additions & 0 deletions .github/common/msvs_file_check.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
from pathlib import Path
import xml.etree.ElementTree as ET


def get_source_files(src_folder):
p = Path(".")
src_files = []
print(f"Processing {src_folder} folder")
ftypes = ('*.[fF]9[05]', '*.inc')
src_files = []
for ft in ftypes:
src_files.extend(p.glob(f"{src_folder}/**/{ft}"))
return src_files


def get_msvs_files(vfproj_file):
print(f"Processing {vfproj_file}")
tree = ET.parse(vfproj_file)
root = tree.getroot()
msvs_files = []
for f in root.iter('File'):
s = f.attrib["RelativePath"]
s = s.replace("\\", "/")
s = s.replace("../", "")
fpath = Path(s)
msvs_files.append(fpath)
return msvs_files


if __name__ == "__main__":

# get list of source files and files in msvs project files
src_files = get_source_files("src")
msvs_files = []
for vfproj in ["./msvs/mf6core.vfproj", "./msvs/mf6.vfproj"]:
msvs_files.extend(get_msvs_files(vfproj))

print(f"Verifying src files are in msvs project files...")
number_failures = 0
for f in src_files:
if f not in msvs_files:
print(f"{f} not found in msvs project file")
number_failures += 1

print(f"Verifying msvs project files are in src folder...")
for f in msvs_files:
if f not in src_files:
print(f"{f} not found in src folder")
number_failures += 1

assert number_failures == 0, "msvs project files not up to date..."
print ("msvs project files appear up to date...")
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ jobs:
- name: Check Fortran source formatting
run: python .github/common/fortran_format_check.py

- name: Check msvs project files are valid
run: python .github/common/msvs_file_check.py

build:
name: Build
runs-on: ubuntu-22.04
Expand Down
2 changes: 1 addition & 1 deletion msvs/mf6core.vfproj
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@
<File RelativePath="..\src\Model\ModelUtilities\Xt3dAlgorithm.f90"/>
<File RelativePath="..\src\Model\ModelUtilities\Xt3dInterface.f90"/></Filter>
<Filter Name="TransportModel">
<File RelativePath="..\src\Model\tsp1.f90"/></Filter>
<File RelativePath="..\src\Model\TransportModel\tsp1.f90"/></Filter>
<File RelativePath="..\src\Model\BaseModel.f90"/>
<File RelativePath="..\src\Model\ExplicitModel.f90"/>
<File RelativePath="..\src\Model\NumericalModel.f90"/>
Expand Down

0 comments on commit d9a1864

Please sign in to comment.