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 @@ -10,4 +10,5 @@
| oakleybrunt | Oakley Brunt | Met Office | 2025-12-19 |
| harry-shepherd | Harry Shepherd | Met Office | 2026-01-08 |
| DrTVockerodtMO | Terence Vockerodt | Met Office | 2026-01-08 |
| mo-lucy-gordon | Lucy Gordon | Met Office | 2026-01-14 |
| MetBenjaminWent | Benjamin Went | Met Office | 2026-01-15 |
13 changes: 13 additions & 0 deletions applications/lfricinputs/fortitude.toml
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 = ["S101"]

output-format = "grouped" #group results by file
13 changes: 13 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,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 = ["S101"]

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_apps
87 changes: 87 additions & 0 deletions rose-stem/bin/fortitude_launcher.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
#!/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 os
import subprocess
import argparse


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_apps directory.",
required=True,
)
args = parser.parse_args()

failed_apps = {}

for top_dir in ["applications", "science"]:
applications = os.listdir(os.path.join(args.source, top_dir))
for app in applications:
print(f"Running on {app}\n")
app_path = os.path.join(args.source, top_dir, 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 errors
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/azngarch/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",
"extract_checker",
"site_validator",
"validate_rose_meta",
Expand Down
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",
"extract_checker",
"site_validator",
"validate_rose_meta",
Expand Down
1 change: 1 addition & 0 deletions rose-stem/site/nci/groups.cylc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"scripts": [
"config_dump_checker",
"style_checker",
"fortitude_linter",
"extract_checker",
"site_validator",
"validate_rose_meta",
Expand Down
1 change: 1 addition & 0 deletions rose-stem/site/uoe/groups.cylc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"scripts": [
"config_dump_checker",
"style_checker",
"fortitude_linter",
"extract_checker",
"site_validator",
],
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 @@
{# All other scripts have the same simple graph. These are: #}
{# * config_dump_checker #}
{# * style_checker #}
{# * fortitude_linter #}
{# * site_validator #}
{# * rose-stem_lint_checker #}
{# * validate_rose_meta #}
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 @@ -43,6 +43,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