Skip to content

Commit 7704b02

Browse files
authored
New procedure for updating .md and .yaml files (#122)
Because it is a bit of a hassle for PR authors to have to make changes to multiple files, #117 attempted to automate the process using the `tools/write_standard_name_table.py` tool. However, this new GitHub action could not run automatically due to branch protection rules on the `main` branch. Rather than remove those restrictions, this PR reverts to the old method of manual updates, but provides more extensive documentation and user prompts to do this updating properly.
1 parent 422cfb5 commit 7704b02

File tree

7 files changed

+55
-66
lines changed

7 files changed

+55
-66
lines changed

.github/PULL_REQUEST_TEMPLATE

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,22 @@
11
<!-- Please read all instructions, then fill out the following template.-->
22

3+
<!-- If this PR includes changes to standard names, you must update the Markdown and YAML files
4+
to be consistent with your changes to standard_names.xml.
5+
6+
This can be done by running the following commands:
7+
8+
tools/write_standard_name_table.py --output-format md standard_names.xml
9+
10+
This script requires the pyyaml Python package; to install with pip use command:
11+
python -m pip install PyYaml
12+
For conda users, environment file tools/environment.yml is provided.
13+
14+
Note that the above procedure assumes your changes were made to standard_names.xml If you instead
15+
made your changes to one of the human-readable files (Metadata-standard-names.md or
16+
Metadata-standard-names.yaml), YOU MUST UPDATE THE FILE standard_names.xml MANUALLY, otherwise your
17+
changes may be lost.
18+
-->
19+
320
<!-- Include a short, descriptive title in the field above. If this PR is for a branch other than
421
`main`, include the destination branch name in brackets at the beginning, e.g.:
522

@@ -15,6 +32,12 @@ Developers listed in the CODEOWNERS file will automatically be assigned to revie
1532
If your contribution should be reviewed by anyone else, assign those reviewers manually from the
1633
menu at right, or by tagging them with @USERNAME in the Description text.
1734

35+
Changes to standard names and/or descriptions should be made in the standard_names.xml file. The
36+
files Metadata-standard-names.md and Metadata-standard-names.yaml will need to be updated before
37+
a pull request is merged; this can be done manually by the PR author using the script
38+
tools/write_standard_name_table.py or will be done by the Code Manager prior to merging via Github
39+
Actions.
40+
1841
Be sure to check in on the PR regularly to respond to comments/questions/reviews!
1942
-->
2043

.github/workflows/commit_to_main.yml

Lines changed: 0 additions & 56 deletions
This file was deleted.

.github/workflows/pull_request_ci.yml

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,31 @@ jobs:
7272
7373
- name: Test rendering xml file to markdown
7474
run: |
75+
# Checks if the saved markdown matches freshly rendered markdown.
76+
# If this fails, prompt user to update
7577
tools/write_standard_name_table.py --output-format md standard_names.xml
76-
echo "The following changes will be committed when this pull request is merged (git diff Metadata-standard-names.md; "
77-
echo "assuming that 'Metadata-standard-names.md' wasn't updated and matches the version in the authoritative branch):"
78-
git diff Metadata-standard-names.md
78+
if ! git diff --exit-code --quiet; then
79+
echo "❌ Detected that Metadata-standard-names.md is not consistent with standard_names.xml"
80+
echo "✅ To fix: Run the following command locally and commit the result:"
81+
echo " tools/write_standard_name_table.py --output-format md standard_names.xml"
82+
echo "📘 This script requires the pyyaml Python package; to install with pip use command:"
83+
echo " python -m pip install PyYaml"
84+
echo "📘 For conda users, environment file tools/environment.yml is provided."
85+
echo
86+
exit 1
87+
fi
7988
8089
- name: Test rendering xml file to yaml
8190
run: |
8291
tools/write_standard_name_table.py --output-format yaml standard_names.xml
83-
echo "The following changes will be committed when this pull request is merged (git diff Metadata-standard-names.yaml; "
84-
echo "assuming that 'Metadata-standard-names.yaml' wasn't updated and matches the version in the authoritative branch):"
85-
git diff Metadata-standard-names.yaml
92+
if ! git diff --exit-code --quiet; then
93+
echo "❌ Detected that Metadata-standard-names.yaml is not consistent with standard_names.xml"
94+
echo "✅ To fix: Run the following command locally and commit the result:"
95+
echo " tools/write_standard_name_table.py --output-format yaml standard_names.xml"
96+
echo "📘 This script requires the pyyaml Python package; to install with pip use command:"
97+
echo " python -m pip install PyYaml"
98+
echo "📘 For conda users, environment file tools/environment.yml is provided."
99+
echo
100+
exit 1
101+
fi
102+

Metadata-standard-names.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Earth System Modeling Standard Name Library - add some chunk here to test auto update
1+
# Earth System Modeling Standard Name Library
22
#### Table of Contents
33
* [dimensions](#dimensions)
44
* [constants](#constants)

Metadata-standard-names.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
library_name: Earth System Modeling Standard Name Library - add some chunk here to test auto update
1+
library_name: Earth System Modeling Standard Name Library
22
sections:
33
- name: dimensions
44
comment: 'Dimension standard names may come in sets of six related standard names

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ The Earth System Modeling Standard Names Repository contains community-accepted
44

55
Rules governing the designation and format of standard names can be found in [StandardNamesRules.rst](https://github.com/ESCOMP/ESMStandardNames/blob/main/StandardNamesRules.rst)
66

7-
A [Markdown file describing the standard names is included](https://github.com/ESCOMP/ESMStandardNames/blob/main/Metadata-standard-names.md), as well as a [Yaml version of the XML file](https://github.com/ESCOMP/ESMStandardNames/blob/main/Metadata-standard-names.yaml).
7+
A [Markdown file describing the standard names is included](https://github.com/ESCOMP/ESMStandardNames/blob/main/Metadata-standard-names.md), as well as a [YAML version of the XML file](https://github.com/ESCOMP/ESMStandardNames/blob/main/Metadata-standard-names.yaml).
88

9-
Edits to standard names must be made in the xml file `standard_names.xml` only. When pull requests are merged into the authoritative branch, a tool is run in GitHub actions that automatically updates the human-readable standard name Markdown file and the Yaml version.
9+
Edits to standard names must be made in the xml file `standard_names.xml` only. When a pull request is opened into the main branch, the YAML and Markdown files should be updated using the `tools/write_standard_name_table.py` script. This can be done manually by the pull request author, or by activating the GitHub action available on an open pull request.

tools/environment.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
name: test
2+
channels:
3+
- conda-forge
4+
dependencies:
5+
- pyyaml

0 commit comments

Comments
 (0)