Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@
| stevemullerworth | Steve Mullerworth | Met Office | 2026-01-08 |
| harry-shepherd | Harry Shepherd | Met Office | 2026-01-08 |
| EdHone | Ed Hone | Met Office | 2026-01-09 |
| mo-lucy-gordon | Lucy Gordon | Met Office | 2026-01-14 |

14 changes: 14 additions & 0 deletions infrastructure/fortitude.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
##############################################################################
# (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"] #check these file types


select = ["C121"]

output-format = "grouped" #group results by file
15 changes: 15 additions & 0 deletions rose-stem/app/check_fortitude_linter/file/fortitude.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
##############################################################################
# (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"] #check these file types


select = ["C121"]


output-format = "grouped" #group results by file
2 changes: 2 additions & 0 deletions rose-stem/app/check_fortitude_linter/rose-app.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[command]
default=$CYLC_WORKFLOW_RUN_DIR/bin/fortitude_launcher.py -s $SOURCE_ROOT/lfric_core
98 changes: 98 additions & 0 deletions rose-stem/bin/fortitude_launcher.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
#!/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 argparse
import os
import subprocess
import sys


def launch_fortitude(config_path, app_path):
"""
Launch fortitude as a subprocess command and check the output
"""

command = f"fortitude --config-file {config_path} check {app_path}"
result = subprocess.run(command.split(), 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(
"-s",
"--source",
help="The top level of lfric_core directory.",
required=True,
)
args = parser.parse_args()

failed_apps = {}

candidates = [
"infrastructure",
"mesh_tools",
"components/coupling",
"components/driver",
"components/science",
"components/inventory",
"components/lfric-xios",
"applications/skeleton",
"applications/simple_diffusion",
"applications/io_demo",
]
for app in candidates:
print(f"Running on {app}\n")
app_path = os.path.join(args.source, app)
config_path = os.path.join(app_path, "fortitude.toml")
if not os.path.exists(os.path.join(config_path)):
print("Using universal config (toml) file."
" (Some apps use their own config file.)")
config_path = os.path.join(
args.source,
"rose-stem",
"app",
"check_fortitude_linter",
"file",
"fortitude.toml",
)

result = 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} \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 error
print(result.stderr, "\n\n\n", file=sys.stderr)
failed_apps[app] = result.stderr

if failed_apps:
error_message = ""
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)
1 change: 1 addition & 0 deletions rose-stem/site/meto/groups.cylc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"scripts": [
"config_dump_checker",
"style_checker",
"fortitude_linter",
"site_validator",
"validate_rose_meta",
"rose-stem_lint_checker",
Expand Down
1 change: 1 addition & 0 deletions rose-stem/templates/graph/populate_graph_scripts.cylc
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
{# * config_dump_checker #}
{# * style_checker #}
{# * site_validator #}
{# * fortitude_linter #}
{# * rose-stem_lint_checker #}
{# * validate_rose_meta #}
{# * global_variables_checker #}
Expand Down
5 changes: 5 additions & 0 deletions rose-stem/templates/runtime/generate_runtime_scripts.cylc
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@
inherit={{inherit.str|upper}}
script="rose task-run --app-key=check_style"

{% elif "fortitude_linter" in task %}

inherit={{inherit.str|upper}}
script="rose task-run --app-key=check_fortitude_linter"

{% elif "extract_checker" in task %}

inherit={{inherit.str|upper}}
Expand Down