Skip to content

A generic workflow to build Sphinx documentation and deploy to gitHub Pages#76

Open
Yaswant Pradhan (yaswant) wants to merge 124 commits into
mainfrom
develop
Open

A generic workflow to build Sphinx documentation and deploy to gitHub Pages#76
Yaswant Pradhan (yaswant) wants to merge 124 commits into
mainfrom
develop

Conversation

@yaswant
Copy link
Copy Markdown
Collaborator

@yaswant Yaswant Pradhan (yaswant) commented Mar 18, 2026

PR Summary

Code Reviewer: James Bruten (@james-bruten-mo)

closes #34

A generic reusable workflow to build and deploy sphinx-based documentation with minimal effort.

Code Quality Checklist

AI Assistance and Attribution

  • Some sections of the sphinx-docs/README.md were enhanced with assistance from Met Office Github Copilot Enterprise and I have followed the Simulation Systems AI policy

Code Review

  • The changes are approriate and testing has been sufficient

Co-authored-by: Yaswant Pradhan <2984440+yaswant@users.noreply.github.com>
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks good on the whole, a couple of suggestions to help with debugging etc.

Comment thread .github/workflows/sphinx-docs.yaml
Comment thread .github/workflows/sphinx-docs.yaml
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This all looks good to me now.

@andrewcoughtrie
Copy link
Copy Markdown
Collaborator

James Bruten (@james-bruten-mo) do you want to have a look at this as well?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I've got one minor change request to rename one of the variables pushed to github_env.

I guess I'm not completely convinced by this as a change. In the repos we manage, we'll be replacing a handful of relatively simple workflows with a single huge and complicated ones - I'm not sure that in this case, we're increasing maintainability?
I also really don't like the use of python throughout. Effectively we've got inline python, within a bash script, within a yaml file, which is something that you can do, but I'm not convinced we should. I'm not suggesting that it be rewritten as bash, but maybe it'd be better storing in a separate python file and just calling that?

The workflow seems reasonably impressive in many ways - I just worry that it's a little too complicated to be increasing maintainability (not to mention if it does break, all repos will be affected rather than just one at the moment). If you want to keep pursuing, then sure, but just noting some concerns.

Comment thread .github/workflows/sphinx-docs.yaml Outdated
id: detect-makefile
run: |
if [ -f "${{ inputs.docs-dir }}/Makefile" ]; then
echo "found=true" >> "$GITHUB_OUTPUT"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I suggest found should be something more explicit here, found_makefile if nothing else

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

done.

@yaswant
Copy link
Copy Markdown
Collaborator Author

I've got one minor change request to rename one of the variables pushed to github_env.

I guess I'm not completely convinced by this as a change. In the repos we manage, we'll be replacing a handful of relatively simple workflows with a single huge and complicated ones - I'm not sure that in this case, we're increasing maintainability? I also really don't like the use of python throughout. Effectively we've got inline python, within a bash script, within a yaml file, which is something that you can do, but I'm not convinced we should. I'm not suggesting that it be rewritten as bash, but maybe it'd be better storing in a separate python file and just calling that?

The workflow seems reasonably impressive in many ways - I just worry that it's a little too complicated to be increasing maintainability (not to mention if it does break, all repos will be affected rather than just one at the moment). If you want to keep pursuing, then sure, but just noting some concerns.

I understand your views and myself thought about keeping the scripts part separate (e.g., .github/scripts). But that will make the use of reusable workflow more complex when called from a forked PR unless we explicitly handle the checkout process . Keeping the messy python bit inline is guaranteed to work without additional work.

If you could test a few edge cases where you think this might fail, that would be great

@yaswant
Copy link
Copy Markdown
Collaborator Author

James Bruten (@james-bruten-mo) thanks for the review and for some critical points James raised. It made me think again! So, I've made some changes to address some concerns:

  1. The dependency resolution using conf.py was too long, too nested, a maintenance overhead. I've simplified this - if you are a fan of list comprehension you will appreciate the changes. This will resolve all dependencies we have in any SimIT documentation repositories.
    However, separating this as a standalone script will be counter-productive and will require checking out the script explicitly (unnecessary overhead + dependency).
  2. Replaced the toml parsing from python to yq (for yaml, but can handle toml, one-way) - I thought it was not available on action runner. Turns out its now available on ubuntu-* and macos runners. So if you are happy with the changes, I'll update the README to indicate that this is not 100% compatible on Windows runners or add an extra step to install if runner is Windows (for the sake of completeness)..

Andrew Coughtrie (@andrewcoughtrie) thanks for the discussion around ubuntu-slim runner offline. This is a perfect choice for sphinx-build on our private repositories.

I've tested few configurations here: https://github.com/MetOffice/git_playground/pull/136

Copy link
Copy Markdown
Contributor

@james-bruten-mo James Bruten (james-bruten-mo) left a comment

Choose a reason for hiding this comment

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

Thanks Yash, that looks better with the reduced python. Do you want to update the readme - I don't think we need to worry about windows runner support

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Optimise build-docs workflow

4 participants