Skip to content

Commit de01878

Browse files
authored
Merge pull request #1 from climbfuji/feature/xml2yaml
Feature/xml2yaml
2 parents 7216533 + fcb7a39 commit de01878

File tree

5 files changed

+5920
-96
lines changed

5 files changed

+5920
-96
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Render xml standard name dictionary to markdown and yaml and commit to repository
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
commit-file:
10+
runs-on: ubuntu-latest
11+
12+
permissions:
13+
contents: write
14+
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v4
18+
19+
- name: Setup Python
20+
uses: actions/setup-python@v4
21+
with:
22+
python-version: "3.x"
23+
24+
- name: Configure git
25+
run: |
26+
git config --global user.name "github-actions[bot]"
27+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
28+
29+
- name: Install dependencies
30+
run: |
31+
sudo apt-get update
32+
sudo apt-get -y install libxml2-utils
33+
python -m pip install --upgrade pip
34+
python -m pip install PyYaml
35+
36+
- name: Render xml to markdown
37+
run: |
38+
tools/write_standard_name_table.py --output-format md standard_names.xml
39+
echo "The following changes will be committed (git diff Metadata-standard-names.md):"
40+
git diff Metadata-standard-names.md
41+
git add Metadata-standard-names.md
42+
git commit -m "Update Metadata-standard-names.md from standard_names.xml" || echo "No changes to commit"
43+
44+
- name: Rendering xml to yaml
45+
run: |
46+
tools/write_standard_name_table.py --output-format yaml standard_names.xml
47+
echo "The following changes will be committed (git diff Metadata-standard-names.yaml):"
48+
git diff Metadata-standard-names.yaml
49+
git add Metadata-standard-names.yaml
50+
git commit -m "Update Metadata-standard-names.yaml from standard_names.xml" || echo "No changes to commit"
51+
52+
- name: Push changes
53+
run: |
54+
git push
55+
env:
56+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/pull_request_ci.yml

Lines changed: 36 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,30 @@ name: Pull request checks
22

33
on:
44
pull_request:
5-
workflow_dispatch:
5+
branches:
6+
- main
67

78
jobs:
89
check-unique-standard-names:
10+
name: Check for duplicates in standard names
911
runs-on: ubuntu-latest
1012
steps:
11-
- uses: actions/checkout@v4
13+
- name: Checkout repository
14+
uses: actions/checkout@v4
1215

13-
- uses: actions/setup-python@v4
16+
- name: Setup Python
17+
uses: actions/setup-python@v4
1418
with:
1519
python-version: "3.x"
1620

17-
- name: Install xmllint
21+
- name: Install dependencies
1822
run: |
19-
sudo apt-get update
20-
sudo apt-get -y install libxml2-utils
23+
sudo apt-get update
24+
sudo apt-get -y install libxml2-utils
2125
2226
- name: Check for duplicate standard names
23-
run: tools/check_xml_unique.py standard_names.xml
27+
run: |
28+
tools/check_xml_unique.py standard_names.xml
2429
2530
check-name-rules:
2631
name: Check standard names against rules
@@ -30,42 +35,49 @@ jobs:
3035
- name: Checkout repository
3136
uses: actions/checkout@v4
3237

33-
- uses: actions/setup-python@v4
38+
- name: Setup Python
39+
uses: actions/setup-python@v4
3440
with:
3541
python-version: "3.x"
3642

37-
# Install dependencies
3843
- name: Install dependencies
3944
run: |
4045
sudo apt-get update
4146
sudo apt-get -y install libxml2-utils
4247
43-
4448
- name: Checks standard names against character rules
4549
run: |
4650
python3 tools/check_name_rules.py -s standard_names.xml
4751
48-
check-rerendered-markdown:
52+
test-rendering:
53+
name: Test rendering xml file to markdown and yaml
4954
runs-on: ubuntu-latest
5055
steps:
51-
- uses: actions/checkout@v4
56+
- name: Checkout repository
57+
uses: actions/checkout@v4
5258

53-
- uses: actions/setup-python@v4
59+
- name: Setup Python
60+
uses: actions/setup-python@v4
5461
with:
5562
python-version: "3.x"
5663

57-
- name: Install xmllint
64+
- name: Install dependencies
5865
run: |
59-
sudo apt-get update
60-
sudo apt-get -y install libxml2-utils
66+
sudo apt-get update
67+
sudo apt-get -y install libxml2-utils
68+
python -m pip install --upgrade pip
69+
python -m pip install PyYaml
6170
62-
- name: Check markdown has been rerendered
71+
- name: Test rendering xml file to markdown
6372
run: |
64-
# Checks if the saved markdown matches freshly rendered markdown.
65-
# If this fails you have likely forgotten to rerun the write script
66-
# after adding a new name, or updating its description.
67-
checksum=$(sha256sum Metadata-standard-names.md)
68-
tools/write_standard_name_table.py standard_names.xml
69-
test "$checksum" = "$(sha256sum Metadata-standard-names.md)"
70-
73+
tools/write_standard_name_table.py --output-format md standard_names.xml
74+
echo "The following changes will be committed when this pull request is merged (git diff Metadata-standard-names.md; "
75+
echo "assuming that 'Metadata-standard-names.md' wasn't updated and matches the version in the authoritative branch):"
76+
git diff Metadata-standard-names.md
7177
78+
- name: Test rendering xml file to yaml
79+
run: |
80+
tools/write_standard_name_table.py --output-format yaml standard_names.xml
81+
echo "The following changes will be committed when this pull request is merged (git diff Metadata-standard-names.yaml; "
82+
echo "assuming that 'Metadata-standard-names.yaml' wasn't updated and matches the version in the authoritative branch):"
83+
git diff Metadata-standard-names.yaml

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 - abcdefg
1+
# Earth System Modeling Standard Name Library - add some chunk here to test auto update
22
#### Table of Contents
33
* [dimensions](#dimensions)
44
* [constants](#constants)

0 commit comments

Comments
 (0)