-
Notifications
You must be signed in to change notification settings - Fork 94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
protobuf: automate derived file generation #6136
base: master
Are you sure you want to change the base?
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any point using an environment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Conda/Mamba can only install packages into isolated environments, they cannot install into the system environment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need an environment on the temporary GH Actions runner?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You cannot install software using mamba/conda without using an environment. It is not possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that is done by an app rather than GH Actions: https://github.com/marketplace/pre-commit-ci
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't work
Drafting in response to #6136 (comment) |
(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.md
and added my name as a Code Contributor.setup.cfg
(andconda-environment.yml
if present).CHANGES.md
entry included if this is a change that can affect users?.?.x
branch.