protobuf: automate derived file generation - #6136
oliver-sanders wants to merge 2 commits into
Conversation
|
(note the protobuf compatibility test will correctly fail on this branch because the schema file it is comparing against does not exist on the branch it is being merged into) |
|
Moving the protobuf files in with the network code introduced circular import issues due to the definition of code in |
54b4af6 to
d72859b
Compare
* Use the bufbuild/buf tool to: * Lint the protobuf schema. * Check for breaking changes. * Configure the generation of derived Python files. * Adds a GitHub action which automates the checking and generation of derived files and commits the results back on pull request branches.
* Some code in the __init__ file was creating a circular dependency issue. * Move this code into its own modules, this may have efficiecncy benefits for other network modules when the code in __init__ is not required.
MetRonnie
left a comment
There was a problem hiding this comment.
Had a quick look at this so far
| - name: Install Protobuf | ||
| uses: mamba-org/setup-micromamba@v1 | ||
| with: | ||
| # install protobuf into a mamba env (note use shell = "bash -el {0}" | ||
| # to access this envionment) | ||
| environment-name: protobuf | ||
| create-args: protobuf | ||
| init-shell: bash |
There was a problem hiding this comment.
Is there any point using an environment?
There was a problem hiding this comment.
Conda/Mamba can only install packages into isolated environments, they cannot install into the system environment.
There was a problem hiding this comment.
Why do we need an environment on the temporary GH Actions runner?
There was a problem hiding this comment.
You cannot install software using mamba/conda without using an environment. It is not possible.
There was a problem hiding this comment.
I am asking why are you using mamba/conda instead of pip (which is simpler - no bash -el {0} needed)?
There was a problem hiding this comment.
Mamba installs low-level dependencies properly, pip doesn't.
I think I had issues installing from pip/npm but it was a while back so I can't quite remember the deal.
| # lint .proto files | ||
| eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" # activate homebrew | ||
| cd cylc/flow/network/protobuf | ||
| buf lint |
There was a problem hiding this comment.
I wouldn't have used a system package manager if I could have avoided it (I don't like system package managers), but I can't remember. Possibly to ensure that dependencies (incl Node) are installed correctly?
| if [[ -z $(git diff --stat) ]]; then | ||
| echo '::error:: No functional changes made to the protobuf schema' |
There was a problem hiding this comment.
| if [[ -z $(git diff --stat) ]]; then | |
| echo '::error:: No functional changes made to the protobuf schema' | |
| if git diff --exit-code --stat; then | |
| echo '::warning::No functional changes made to the protobuf schema' |
| echo '::error:: No functional changes made to the protobuf schema' | ||
| exit 0 | ||
| else | ||
| echo '::info:: pushing update commit' |
There was a problem hiding this comment.
| echo '::info:: pushing update commit' | |
| echo '::notice::pushing update commit' |
| git add -u | ||
| git commit -m 'protobuf: updating generated files' | ||
| git remote add pr https://github.com/${{ github.event.pull_request.head.repo.owner.login }}/cylc-flow | ||
| git push pr HEAD:${{ github.head_ref }} |
There was a problem hiding this comment.
Ah, I'm not sure this will work for a PR from a fork
I think GITHUB_TOKEN only has read permissions in PRs from forks.
There was a problem hiding this comment.
Dammit (although the workflow would work on their fork).
Only one way to find out. My master branch is still @ f3342c2, maybe try raising a PR there (along the lines of the one in the OP) and see what happens?
I know there are other repos that manage to do this. E.G. checkout jupyter-server#1448 (deliberately not linking their issue), those pre-commit commits are pushed onto the branch automatically.
There was a problem hiding this comment.
There was a problem hiding this comment.
I think that is done by an app rather than GH Actions: https://github.com/marketplace/pre-commit-ci
|
Drafting in response to #6136 (comment) |
|
Don't have time to push this forward. |

(Training day washup)
Sibling: cylc/cylc-uiserver#606
Take the guesswork out of protobuf schema changes by automating the updating of the derived Python files:
Example CI runs (my fork):
Note:
Check List
CONTRIBUTING.mdand added my name as a Code Contributor.setup.cfg(andconda-environment.ymlif present).CHANGES.mdentry included if this is a change that can affect users?.?.xbranch.