-
Notifications
You must be signed in to change notification settings - Fork 72
Adding fortitude #150
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
Open
mo-lucy-gordon
wants to merge
16
commits into
MetOffice:main
Choose a base branch
from
mo-lucy-gordon:adding_fortitude
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Adding fortitude #150
Changes from 13 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
0fbd0d7
added fortitude to test suite and a rule
mo-lucy-gordon 2520a91
updated copyrights
mo-lucy-gordon 025a473
updated to fix PEP8 violations
mo-lucy-gordon 25ecd7e
signed contributors page
mo-lucy-gordon ecaf676
corrected message formatting
mo-lucy-gordon c72afdf
Merge branch 'main' into adding_fortitude
mo-lucy-gordon b943adf
removed test from other sites
mo-lucy-gordon 6d3ec8e
changed source argument type
mo-lucy-gordon 3991976
added pathlib, typehinting and made script generic
mo-lucy-gordon 9757ab2
added rules and config files to remove all errors but still test inte…
mo-lucy-gordon 93bb772
added other toml files
mo-lucy-gordon 1175de8
Merge branch 'main' into adding_fortitude
mo-lucy-gordon 4b6bcc4
removed a space so rule could be used on file
mo-lucy-gordon cf854d7
adding fix for pep8 violations
mo-lucy-gordon 5a3f1a9
get launcher script from SimSys scripts instead
mo-lucy-gordon b9f2b95
corrected source for simsys scripts
mo-lucy-gordon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,11 @@ | ||
| ############################################################################## | ||
| # (c) Crown copyright Met Office. All rights reserved. | ||
| # The file LICENCE, distributed with this code, contains details of the terms | ||
| # under which the code may be used. | ||
| ############################################################################## | ||
|
|
||
| [check] | ||
| file-extensions= ["f90", "F90", "X90", "x90", "pf"] #check these file types | ||
| select = ["S101", "PORT011"] | ||
| output-format = "grouped" #group results by file | ||
|
|
This file contains hidden or 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,18 @@ | ||
| ############################################################################## | ||
| # (c) Crown copyright Met Office. All rights reserved. | ||
| # The file LICENCE, distributed with this code, contains details of the terms | ||
| # under which the code may be used. | ||
| ############################################################################## | ||
|
|
||
| [check] | ||
|
|
||
| file-extensions= ["f90", "F90", "X90", "x90", "pf"] #check these file types | ||
|
|
||
| select = ["S101", "PORT011"] | ||
|
|
||
| output-format = "grouped" #group results by file | ||
|
|
||
| [check.per-file-ignores] | ||
|
|
||
| "process_send_fields_2d_mod.X90" = ["S101"] | ||
| "set_r_ocean_fraction_mod.F90" = ["S101"] |
This file contains hidden or 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,18 @@ | ||
| ############################################################################## | ||
| # (c) Crown copyright Met Office. All rights reserved. | ||
| # The file LICENCE, distributed with this code, contains details of the terms | ||
| # under which the code may be used. | ||
| ############################################################################## | ||
|
|
||
| [check] | ||
|
|
||
| file-extensions= ["f90", "F90", "X90", "x90", "pf"] #check these file types | ||
|
|
||
| select = ["S101", "PORT011"] | ||
|
|
||
| output-format = "grouped" #group results by file | ||
|
|
||
| [check.per-file-ignores] | ||
|
|
||
| "jedi_lfric_linear_modeldb_driver_mod.f90" = ["S101"] | ||
| "atlas_field_interface_mod.F90" = ["S101"] |
This file contains hidden or 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,20 @@ | ||
| ############################################################################## | ||
| # (c) Crown copyright Met Office. All rights reserved. | ||
| # The file LICENCE, distributed with this code, contains details of the terms | ||
| # under which the code may be used. | ||
| ############################################################################## | ||
|
|
||
| [check] | ||
|
|
||
| file-extensions= ["f90", "F90", "X90", "x90", "pf"] #check these file types | ||
|
|
||
| select = ["S101", "PORT011"] | ||
|
|
||
| output-format = "grouped" #group results by file | ||
|
|
||
| [check.per-file-ignores] | ||
|
|
||
| "update_ancils_alg_mod.x90" = ["S101"] | ||
| "jules_exp_kernel_mod.F90" = ["S101"] | ||
| "jules_extra_kernel_mod.F90" = ["S101"] | ||
| "jules_imp_kernel_mod.F90" = ["S101"] |
This file contains hidden or 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 hidden or 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,13 @@ | ||
| ############################################################################## | ||
| # (c) Crown copyright Met Office. All rights reserved. | ||
| # The file LICENCE, distributed with this code, contains details of the terms | ||
| # under which the code may be used. | ||
| ############################################################################## | ||
|
|
||
| [check] | ||
|
|
||
| file-extensions= ["f90", "F90", "X90", "x90", "pf"] #check these file types | ||
|
|
||
| select = ["PORT011"] | ||
|
|
||
| output-format = "grouped" #group results by file |
This file contains hidden or 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,19 @@ | ||
| ############################################################################## | ||
| # (c) Crown copyright Met Office. All rights reserved. | ||
| # The file LICENCE, distributed with this code, contains details of the terms | ||
| # under which the code may be used. | ||
| ############################################################################## | ||
|
|
||
| [check] | ||
|
|
||
| file-extensions= ["f90", "F90", "X90", "x90", "pf"] #check these file types | ||
|
|
||
| select = ["S101", "PORT011"] | ||
|
|
||
| output-format = "grouped" #group results by file | ||
|
|
||
| [check.per-file-ignores] | ||
|
|
||
| "init_radiation_fields_alg_mod.x90" = ["S101"] | ||
| "rad_cloud_alg_mod.x90" = ["S101"] | ||
| "lw_kernel_mod.F90" = ["S101"] |
This file contains hidden or 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,29 @@ | ||
| ############################################################################## | ||
| # (c) Crown copyright Met Office. All rights reserved. | ||
| # The file LICENCE, distributed with this code, contains details of the terms | ||
| # under which the code may be used. | ||
| ############################################################################## | ||
|
|
||
| [check] | ||
|
|
||
| file-extensions= ["f90", "F90", "X90", "x90", "pf"] #check these file types | ||
|
|
||
| select = ["S101", "PORT011"] | ||
|
|
||
| output-format = "grouped" #group results by file | ||
|
|
||
|
|
||
| # "./interfaces/coupled_interface/source/algorithm/process_send_fields_2d_mod.X90" = ["S101"] | ||
|
|
||
| # "./interfaces/socrates_interface*" = ["S101"] | ||
| # "../coupled_interface/*" = ["S101"] | ||
|
|
||
|
|
||
| # "./interfaces/coupled_interface/* = ["S101"] | ||
|
|
||
|
|
||
| # "../socrates_interface/*" = ["S101"] | ||
| # "physics_schemes_interface/*" = ["S101"] | ||
| # "jules_interface/*" = ["S101"] | ||
| # "jedi_lfric_interface/*" = ["S101"] | ||
|
|
This file contains hidden or 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,2 @@ | ||
| [command] | ||
| default=$CYLC_WORKFLOW_RUN_DIR/bin/fortitude_launcher.py $SOURCE_ROOT/lfric_apps |
This file contains hidden or 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,84 @@ | ||
| #!/usr/bin/env python3 | ||
| ############################################################################## | ||
| # (c) Crown copyright Met Office. All rights reserved. | ||
| # The file LICENCE, distributed with this code, contains details of the terms | ||
| # under which the code may be used. | ||
| ############################################################################## | ||
|
|
||
| """ | ||
| Launch fortitude on list of directories. Run on all and print outputs. | ||
| Fail if any style changes required. | ||
| """ | ||
|
|
||
| import sys | ||
| import subprocess | ||
| import argparse | ||
| from pathlib import Path | ||
|
|
||
|
|
||
| def launch_fortitude(config_path: Path, app_path: Path) -> subprocess.CompletedProcess[str]: | ||
| """ | ||
| Launch fortitude as a subprocess command and check the output | ||
| """ | ||
|
|
||
| command: list[str] = ["fortitude", "--config-file", str(config_path), "check", str(app_path)] | ||
| result = subprocess.run(command, capture_output=True, text=True) | ||
|
|
||
| print(result.stdout) | ||
| return result | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| parser = argparse.ArgumentParser( | ||
| description="Run fortitude on all applications. If " | ||
| "application/fortitude.toml exists use that file, otherwise " | ||
| "use one in rose-stem/app/check_fortitude_linter/file. " | ||
| "Print output, raise error if any changes required." | ||
| ) | ||
| parser.add_argument( | ||
| "source", | ||
| help="The top level of lfric_apps directory." | ||
| ) | ||
| args = parser.parse_args() | ||
|
|
||
| source_path: Path = Path(args.source) | ||
|
|
||
| failed_apps: dict[str, str] = {} | ||
|
|
||
| for top_dir_path in source_path.iterdir(): #e.g. applications,science,interfaces | ||
| if not top_dir_path.is_dir(): # don't try to loop over files | ||
| continue | ||
| for app_path in top_dir_path.iterdir(): #e.g. adjoint_tests, adjoint, coupled_interface | ||
| if not app_path.is_dir(): | ||
| continue | ||
| app_name: str = app_path.name | ||
| print(f"Running on {app_name}\n") | ||
| config_path: Path = app_path/"fortitude.toml" | ||
| if not config_path.exists(): | ||
| print("Using universal config (toml) file." | ||
| " (Some apps use their own config file.)") | ||
| config_path: Path = (source_path / "rose-stem" / "app" / "check_fortitude_linter" / "file" / "fortitude.toml") | ||
| result: subprocess.CompletedProcess[str] = launch_fortitude(config_path, app_path) | ||
| if result.returncode: | ||
| # prints the app run on if there are errors of any kind | ||
| print(f"Checking: {app_name} \n", file=sys.stderr) | ||
| if not result.stderr: | ||
| # prints if no other/config errors are found | ||
| print("Found lint errors:", file=sys.stderr) | ||
| # prints the lint errors | ||
| print(result.stdout, file=sys.stderr) | ||
| if result.stderr: | ||
| # prints if there are other/config errors | ||
| print("Found non-lint errors: \n", file=sys.stderr) | ||
| # prints the other/config errors | ||
| print(result.stderr, "\n\n\n", file=sys.stderr) | ||
| failed_apps[app_name] = result.stderr | ||
|
|
||
|
|
||
| if failed_apps: | ||
| error_message: str = "" | ||
| print("\n\n\nSummary: Fortitude found errors in" | ||
| " the following repositories:\n", file=sys.stderr) | ||
| for failed in failed_apps: | ||
| error_message += f"{failed}\n" | ||
| sys.exit(error_message) | ||
This file contains hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably be a positional argument as it's required. You can force that by removing the
-sargument and changing--sourceto justsource. Then you'll need to remove the-sfrom the call in the rose-app.confThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done