Skip to content
Merged
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
56 changes: 56 additions & 0 deletions .github/workflows/commit_to_main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Render xml standard name dictionary to markdown and yaml and commit to repository

on:
push:
branches:
- main

jobs:
update-md-and-yaml:
name: Render xml to markdown and yaml and commit
runs-on: ubuntu-latest

permissions:
contents: write

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: "3.x"

- name: Configure git
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get -y install libxml2-utils
python -m pip install --upgrade pip
python -m pip install PyYaml

- name: Render xml to markdown
run: |
tools/write_standard_name_table.py --output-format md standard_names.xml
echo "The following changes will be committed (git diff Metadata-standard-names.md):"
git diff Metadata-standard-names.md
git add Metadata-standard-names.md

- name: Rendering xml to yaml
run: |
tools/write_standard_name_table.py --output-format yaml standard_names.xml
echo "The following changes will be committed (git diff Metadata-standard-names.yaml):"
git diff Metadata-standard-names.yaml
git add Metadata-standard-names.yaml

- name: Commit and push changes
run: |
git commit -m "Update Metadata-standard-names.{md,yaml} from standard_names.xml" || echo "No changes to commit"
git push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
62 changes: 38 additions & 24 deletions .github/workflows/pull_request_ci.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,33 @@
name: Pull request checks

on:
pull_request:
workflow_dispatch:
pull_request:
branches:
- main
- release/*

jobs:
check-unique-standard-names:
name: Check for duplicates in standard names
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Checkout repository
uses: actions/checkout@v4

- uses: actions/setup-python@v4
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: "3.x"

- name: Install xmllint
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get -y install libxml2-utils
sudo apt-get update
sudo apt-get -y install libxml2-utils

- name: Check for duplicate standard names
run: tools/check_xml_unique.py standard_names.xml
run: |
tools/check_xml_unique.py standard_names.xml

check-name-rules:
name: Check standard names against rules
Expand All @@ -30,42 +37,49 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4

- uses: actions/setup-python@v4
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: "3.x"

# Install dependencies
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get -y install libxml2-utils


- name: Checks standard names against character rules
run: |
python3 tools/check_name_rules.py -s standard_names.xml

check-rerendered-markdown:
test-rendering:
name: Test rendering xml file to markdown and yaml
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Checkout repository
uses: actions/checkout@v4

- uses: actions/setup-python@v4
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: "3.x"

- name: Install xmllint
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get -y install libxml2-utils
sudo apt-get update
sudo apt-get -y install libxml2-utils
python -m pip install --upgrade pip
python -m pip install PyYaml

- name: Check markdown has been rerendered
- name: Test rendering xml file to markdown
run: |
# Checks if the saved markdown matches freshly rendered markdown.
# If this fails you have likely forgotten to rerun the write script
# after adding a new name, or updating its description.
checksum=$(sha256sum Metadata-standard-names.md)
tools/write_standard_name_table.py standard_names.xml
test "$checksum" = "$(sha256sum Metadata-standard-names.md)"

tools/write_standard_name_table.py --output-format md standard_names.xml
echo "The following changes will be committed when this pull request is merged (git diff Metadata-standard-names.md; "
echo "assuming that 'Metadata-standard-names.md' wasn't updated and matches the version in the authoritative branch):"
git diff Metadata-standard-names.md

- name: Test rendering xml file to yaml
run: |
tools/write_standard_name_table.py --output-format yaml standard_names.xml
echo "The following changes will be committed when this pull request is merged (git diff Metadata-standard-names.yaml; "
echo "assuming that 'Metadata-standard-names.yaml' wasn't updated and matches the version in the authoritative branch):"
git diff Metadata-standard-names.yaml
2 changes: 1 addition & 1 deletion Metadata-standard-names.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Earth System Modeling Standard Name Library
# Earth System Modeling Standard Name Library - add some chunk here to test auto update
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ignore this - to prove that the auto update works. The file will be re-rendered from the XML and submitted to the repository when this PR is merged.

#### Table of Contents
* [dimensions](#dimensions)
* [constants](#constants)
Expand Down
Loading