Skip to content

Commit f46c518

Browse files
trexfeatherspp-mo
andauthored
Explainability improvements (#54)
* Cleaner text for notify-updates. * Add a templating README. * Update main README. * Note on placeholders. * Be more specific about template updates AND creation. Co-authored-by: Patrick Peglar <patrick.peglar@metoffice.gov.uk> * Remember to include README in the template index. --------- Co-authored-by: Patrick Peglar <patrick.peglar@metoffice.gov.uk>
1 parent a090dc6 commit f46c518

File tree

4 files changed

+70
-8
lines changed

4 files changed

+70
-8
lines changed

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ Organisational level things such as the SciTools README and organisation workflo
1010
[SciTools Peloton project](https://github.com/orgs/SciTools/projects/13?pane=info).
1111
See also [`.github/workflows/peloton.yml`](.github/workflows/peloton.yml).
1212
- [`./templates`](./templates) - tooling for standardising files across
13-
SciTools repos. See also
14-
[`.github/workflows/template-sync.yml`](.github/workflows/template-sync.yml).
13+
SciTools repos.
1514

1615
## Possible future uses
1716

templates/README.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Templating
2+
3+
SciTools developers manage several similar repositories. Where the same files
4+
are used across multiple repositories, it helps to keep them as similar as
5+
possible. We achieve this by storing templates for common files in this
6+
directory.
7+
8+
## Benefits
9+
10+
- Smoother transition for developers when switching between repositories.
11+
- Encodes agreed SciTools best practices.
12+
- Avoids useful ideas being isolated to the repository where they were first
13+
tried.
14+
- A way to share simple scripting across repositories without needing an
15+
installable package or similar - less overhead and easier to follow.
16+
17+
## How it works
18+
19+
[`_templating_config.json`](_templating_config.json) is the 'index' of all the
20+
templates and how they map to files in the SciTools repositories.
21+
22+
[`_templating_scripting.py`](_templating_scripting.py) contains the logic for
23+
communicating template updates around SciTools - using GitHub issues and
24+
comments. It is called by two GitHub Actions workflows:
25+
26+
- [`template-update-notification.yml`](../.github/workflows/template-update-notification.yml)
27+
uses the `notify_updates()` function to raise issues on all relevant
28+
repositories when a template is updated, or a new one created.
29+
- [SciTools/workflows `ci-template-check.yml`](https://github.com/SciTools/workflows/blob/main/.github/workflows/ci-template-check.yml)
30+
uses the `prompt_share()` function to remind repository developers if they are
31+
modifying a templated file and should consider sharing the change.
32+
33+
All other files in this directory are the templates themselves.
34+
35+
## Things we template
36+
37+
- Files that all repositories should have, e.g. `CODE_OF_CONDUCT.md`.
38+
- Tools that will be valuable to multiple repositories, e.g. benchmarking
39+
scripts.
40+
- Files that are useful to have in a consistent format, e.g.
41+
`.pre-commit-config.yaml`.
42+
43+
Files DO NOT need to be identical - they are human-readable not
44+
machine-readable, so can include whatever placeholders / optional content is
45+
considered appropriate.
46+
47+
## Please contribute!
48+
49+
This directory needs to grow. Any files you can think to template will be a
50+
valuable addition.
51+
**Remember to update [`_templating_config.json`](_templating_config.json).**

templates/_templating_config.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"_templating_config.json": {},
33
"_templating_scripting.py": {},
4+
"README.md": {},
45
".pre-commit-config.yaml": {
56
"cf-units": ".pre-commit-config.yaml",
67
"iris": ".pre-commit-config.yaml",

templates/_templating_scripting.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,23 @@ def git_diff(*args: str) -> str:
9898
file_url = f"{SCITOOLS_URL}/{repo}/blob/main/{path_in_repo}"
9999
file_link = f"[`{path_in_repo}`]({file_url})"
100100
issue_body = (
101-
f"The template for {file_link} has been updated.\n\n"
102-
"Consider adopting these changes into the repo; "
103-
"the changes can be found below.\n\n"
104-
"The template file can be found in the **.github** repo: "
105-
f"{template_link}\n\n"
106-
"The diff between the specified file is as follows:\n\n"
101+
f"The template for `{path_in_repo}` has been updated; see the "
102+
"diff below. Please either:\n\n"
103+
104+
"- Action this issue with a pull request applying some/all of "
105+
f"these changes to `{path_in_repo}`.\n"
106+
"- Close this issue if _none_ of these changes are appropriate "
107+
"for this repo.\n\n"
108+
"Also consider reviewing a full diff between the template and "
109+
f"`{path_in_repo}`, in case other valuable shared conventions "
110+
f"have previously been missed.\n\n"
111+
112+
"## File Links\n\n"
113+
f"- The file in this repo: {file_link}\n"
114+
f"- The template file in the **.github** repo: {template_link}\n\n"
115+
# TODO: a link to the whole diff compared to the template?
116+
117+
"## Diff\n\n"
107118
f"```diff\n{diff}\n```"
108119
)
109120
with NamedTemporaryFile("w") as file_write:

0 commit comments

Comments
 (0)