Skip to content
Merged
Show file tree
Hide file tree
Changes from 46 commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
117b02a
Linter CI part 1
yaswant Jan 13, 2025
0804359
fix codeowners
yaswant Jan 13, 2025
9d358e3
fix indent
yaswant Jan 13, 2025
4745280
fix indent again
yaswant Jan 13, 2025
0d6cc66
block some unwanted checks
yaswant Jan 13, 2025
55a0e93
falsify fail-fast strategy
yaswant Jan 13, 2025
3187c07
fix Perl lexical warnings
yaswant Jan 13, 2025
c35d2fa
fix Perl warning
yaswant Jan 13, 2025
8a2b172
update README
yaswant Jan 13, 2025
eafaa31
add percriticrc
yaswant Jan 13, 2025
5c492a3
add codeql badge
yaswant Jan 13, 2025
f31ba59
add codeql badge
yaswant Jan 13, 2025
74ec869
cancel in progress runs with PR updates
yaswant Jan 13, 2025
99ff5f5
Update .github/linters/.ruff.toml
yaswant Jan 24, 2025
d5198c9
Update .github/linters/.ruff.toml
yaswant Jan 24, 2025
ad64634
Update .github/linters/.ruff.toml
yaswant Jan 24, 2025
1fd8cc3
Update .github/linters/.ruff.toml
yaswant Jan 24, 2025
9fc38b6
turn off python ruff
james-bruten-mo Jan 24, 2025
e0c4a3a
Merge remote-tracking branch 'origin/main' into feature/ci_linter
james-bruten-mo Jan 24, 2025
5373809
apply black/isort, populate black/isort conf files
james-bruten-mo Jan 24, 2025
14fd008
run isort
james-bruten-mo Jan 24, 2025
f79a711
missed file
james-bruten-mo Jan 24, 2025
a528fda
update black config
james-bruten-mo Jan 24, 2025
4cd0dcc
partial fix shellcheck issues
yaswant Jan 24, 2025
cdee2a9
tidy
yaswant Jan 25, 2025
1978237
black check config try
yaswant Jan 25, 2025
3772d24
opaque black
yaswant Jan 25, 2025
2648d8a
black default
yaswant Jan 25, 2025
3882fb3
refactor run kgo script with POSIX compliance
yaswant Jan 27, 2025
3ddd0d1
response to @james-bruten-mo comments
yaswant Jan 27, 2025
db24407
revert changes to meto_run_kgi_script
yaswant Jan 30, 2025
93d04f1
revert printf changes and add shellcheck ignore
james-bruten-mo Jan 31, 2025
3eced4a
merge in hot and run black/isort
james-bruten-mo Mar 19, 2025
560c7de
lint checker fixes
james-bruten-mo Mar 19, 2025
be09862
error in bash
james-bruten-mo Mar 19, 2025
21bd738
black and isort with black profile
james-bruten-mo Mar 19, 2025
e2e3b62
another isort attempt
james-bruten-mo Mar 19, 2025
c133d59
remove isort linting
james-bruten-mo Mar 19, 2025
837eece
remove isort
james-bruten-mo Mar 19, 2025
3260c79
Update suite_report.py
james-bruten-mo Mar 20, 2025
faa60b6
Update suite_report.py
james-bruten-mo Mar 20, 2025
0d4e54a
merge main again after latest commit
james-bruten-mo Mar 20, 2025
6be7b41
run black
james-bruten-mo Mar 20, 2025
08d622b
another merge to main after suite_report update
james-bruten-mo Mar 20, 2025
8775a2d
forgot to run black...
james-bruten-mo Mar 20, 2025
926bb30
remove .github dir to split up ticket
james-bruten-mo Mar 24, 2025
af21e11
Update lfric_macros/apply_macros.py
james-bruten-mo Mar 24, 2025
2708e36
Update lfric_macros/release_lfric.py
james-bruten-mo Mar 24, 2025
8dbc15d
Merge branch 'main' into feature/ci_linter
t00sa Mar 31, 2025
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
7 changes: 4 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
*.sublime-workspace
*.code-workspace
.vscode
__pycache__/
*.pyc
*.sublime-workspace
*~
*.swp
.conda
.idea
.vscode
__pycache__
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
# SimSys Scripts
# Simulation Systems Scripts

This repository contains support scripts that are common across the many simulation and modelling codes owned by the Met Office.
Particularily those owned and maintained by the SSD team.
[![Checks](https://github.com/MetOffice/SimSys_Scripts/actions/workflows/lint.yml/badge.svg)](https://github.com/MetOffice/SimSys_Scripts/actions/workflows/lint.yml)
[![CodeQL](https://github.com/MetOffice/SimSys_Scripts/actions/workflows/github-code-scanning/codeql/badge.svg)](https://github.com/MetOffice/SimSys_Scripts/actions/workflows/github-code-scanning/codeql)

Also contains a copy of script_updater.sh which is intended to live in the fcm repositories to pull from
this repo.
This repository contains support scripts that are common across the many
simulation and modelling codes owned by the Met Office. Particularly those
owned and maintained by the Simulation Systems and Deployment (SSD) team.

Also contains a copy of `script_updater.sh` which is intended to live in the
fcm repositories to pull from this repository.
55 changes: 32 additions & 23 deletions fcm_bdiff.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
run tests on based on the branch-difference (to allow checking of only files
which a developer has actually modified on their branch)
"""
import re

import os
import re
import subprocess
import time

Expand All @@ -20,10 +21,11 @@ class FCMError(Exception):
"""
Exception class for FCM commands
"""

def __str__(self):
return ("\nFCM command: \"{0:s}\""
"\nFailed with error: \"{1:s}\""
.format(" ".join(self.args[0]), self.args[1].strip()))
return '\nFCM command: "{0:s}"\nFailed with error: "{1:s}"'.format(
" ".join(self.args[0]), self.args[1].strip()
)


# ------------------------------------------------------------------------------
Expand All @@ -32,16 +34,20 @@ def is_trunk(url):
Given an FCM url, returns True if it appears to be pointing to the
UM main trunk
"""
search = re.search(r"""
search = re.search(
r"""
(svn://fcm\d+/\w+_svn/\w+/trunk|
.*/svn/[\w\.]+/\w+/trunk|
..*_svn/\w+/trunk)
""", url, flags=re.VERBOSE)
""",
url,
flags=re.VERBOSE,
)
return search is not None


# ------------------------------------------------------------------------------
def text_decoder(bytes_type_string, codecs=['utf8', 'cp1252']):
def text_decoder(bytes_type_string, codecs=["utf8", "cp1252"]):
"""
Given a bytes type string variable, attempt to decode it using the codecs
listed.
Expand Down Expand Up @@ -127,18 +133,20 @@ def get_branch_diff_filenames(branch=".", path_override=None):
# Strip whitespace, and remove blank lines while turning the output into
# a list of strings.
bdiff_files = [x.strip() for x in bdiff.split("\n") if x.strip()]
bdiff_files = [bfile.split()[1] for bfile in bdiff_files
if bfile.split()[0].strip() == "M" or
bfile.split()[0].strip() == "A"]
bdiff_files = [
bfile.split()[1]
for bfile in bdiff_files
if bfile.split()[0].strip() == "M" or bfile.split()[0].strip() == "A"
]

# Convert the file paths to be relative to the current URL; to do this
# construct the base path of the trunk URL and compare it to the results
# of the bdiff command above
repos_root = get_repository_root(info)
relative_paths = [os.path.relpath(bfile,
os.path.join(repos_root,
"main", "trunk"))
for bfile in bdiff_files]
relative_paths = [
os.path.relpath(bfile, os.path.join(repos_root, "main", "trunk"))
for bfile in bdiff_files
]

# These relative paths can be joined to an appropriate base to complete
# the filenames to return
Expand Down Expand Up @@ -169,9 +177,9 @@ def run_fcm_command(command, max_retries, snooze):
"""
retries = 0
while True:
output = subprocess.Popen(command,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
output = subprocess.Popen(
command, stdout=subprocess.PIPE, stderr=subprocess.PIPE
)
_ = output.wait()
if output.returncode == 0:
return text_decoder(output.stdout.read())
Expand All @@ -198,8 +206,7 @@ def use_mirror(branch):
if mirror_key in os.environ:
branch = os.environ[mirror_key]
retries = 2
print("[INFO] Switching branch used for fcm command to : {0:}".format(
branch))
print(f"[INFO] Switching branch used for fcm command to: {branch}")
else:
retries = 0
return branch, retries
Expand All @@ -211,8 +218,9 @@ def get_repository_root(branch_info):
Given the raw output from an fcm binfo command - which can be retrieved by
calling get_branch_info() - returns the Repository Root field
"""
repos_root = re.search(r"^Repository Root:\s*(?P<url>.*)\s*$",
branch_info, flags=re.MULTILINE)
repos_root = re.search(
r"^Repository Root:\s*(?P<url>.*)\s*$", branch_info, flags=re.MULTILINE
)
if repos_root:
repos_root = repos_root.group("url")
else:
Expand All @@ -226,8 +234,9 @@ def get_branch_parent(branch_info):
Given the raw output from an fcm binfo command - which can be retrieved by
calling get_branch_info() - returns the Branch Parent Field
"""
parent = re.search(r"^Branch Parent:\s*(?P<parent>.*)$", branch_info,
flags=re.MULTILINE)
parent = re.search(
r"^Branch Parent:\s*(?P<parent>.*)$", branch_info, flags=re.MULTILINE
)
if parent:
parent = parent.group("parent")
else:
Expand Down
Loading