Skip to content

Conversation

@mkavulich
Copy link
Collaborator

@mkavulich mkavulich commented Jul 17, 2025

Description

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 proposes a compromise with a GitHub action that can optionally be run by the user or code manager to update these files, while also allowing the user to do this process manually if desired. This way, the changes will be made prior to merge, and so the test that prevents merge if the .md and/or .yaml files have not been updated has been re-implemented.

Issues

Addresses #121

@mkavulich mkavulich changed the title New procedure for updating .md and .yaml files [DRAFTNew procedure for updating .md and .yaml files Jul 17, 2025
@mkavulich mkavulich changed the title [DRAFTNew procedure for updating .md and .yaml files [DRAFT] New procedure for updating .md and .yaml files Jul 17, 2025
@mkavulich mkavulich marked this pull request as draft July 17, 2025 16:25
@mkavulich mkavulich marked this pull request as ready for review July 17, 2025 16:39
@mkavulich mkavulich changed the title [DRAFT] New procedure for updating .md and .yaml files New procedure for updating .md and .yaml files Jul 17, 2025
@climbfuji
Copy link
Collaborator

I prefer a slightly different solution, but it goes in the same direction. Let's chat in an hour

Copy link
Collaborator

@gold2718 gold2718 left a comment

Choose a reason for hiding this comment

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

👍

@climbfuji
Copy link
Collaborator

The solution I had in mind yesterday is in #123, but there is one problem with it - the pull request branch can't come from a fork because of permissions, it must be in the base repository. This is not what we want. There are insecure workarounds for it that I don't think we should use (pull_request_target). Bearing any better ideas, let's try your approach. I will submit a code review in a minute with a suggested change.

Comment on lines 75 to 79
# Checks if the saved markdown matches freshly rendered markdown.
# If this fails, prompt user to update
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
test "$checksum" = "$(sha256sum Metadata-standard-names.md)" || exit "Markdown file Metadata-standard-names.md must be updated; see documentation for details"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why not just run git diff after line 78 and check the return code?

Generally, why do we need this. I would revert the changes to pull_request_ci.yml entirely. Can't we just add a checkbox to the pull request template that instructs the code managers to check if the rendered files need to be updated, run the workflow_dispatch action and then tick the box? See #123

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm happy removing these actions all together and returning to the manual updates of old. It would be nice to have an automatic (or at least push-button) solution to update these tables within GitHub but it could be getting that working seems to be more trouble than it's worth.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I wonder, yes. Maybe the best approach is a pragmatic one. Your PR has it so that the checks fail because the files must be updated. If we add a big bold message there (and in the documentation) that tells the user to update and commit the files, and how to do it, then that is perfectly fine for me.

push:
branches:
- main
workflow_dispatch:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do you know if this works? How does this change circumvent the branch protection that the original logic doesn't?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If the commit is done on the PR branch prior to merge rather than in main then there are no branch protection issues (I think). But this would require that the user's fork has been updated to include this workflow file already, since workflow_dispatch tasks must be in that specific repository's main branch.

@climbfuji climbfuji mentioned this pull request Aug 6, 2025
1 task
@mkavulich
Copy link
Collaborator Author

@climbfuji I have removed the automated task and updated the instructions for users to update the MD/YAML files when the test fails. Let me know if you think we need more.

@climbfuji
Copy link
Collaborator

Excellent, thanks! I see you tested this in https://github.com/ESCOMP/ESMStandardNames/actions/runs/17280713958/job/49048314628.

@mkavulich mkavulich merged commit 7704b02 into main Sep 24, 2025
3 checks passed
@mkavulich mkavulich deleted the feature/md_and_yaml_updates branch September 24, 2025 20:10
mkavulich added a commit to mkavulich/ESMStandardNames that referenced this pull request Oct 7, 2025
New procedure for updating .md and .yaml files (ESCOMP#122)

Because it is a bit of a hassle for PR authors to have to make changes to multiple files, ESCOMP#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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants