-
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
exclude_paths: | ||
- 'etc/**' | ||
- 'tests/**' | ||
- 'cylc/flow/**_pb2.py' | ||
- 'cylc/flow/network/protobuf/**_pb2.py' |
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,83 @@ | ||||||||||
name: protobuf | ||||||||||
# CI tests to run against the protobuf schema on change: | ||||||||||
|
||||||||||
on: | ||||||||||
# run for any PRs raising changes to the protobuf files or setup | ||||||||||
pull_request: | ||||||||||
paths: | ||||||||||
- 'cylc/flow/network/protobuf/**' | ||||||||||
|
||||||||||
jobs: | ||||||||||
protobuf: | ||||||||||
runs-on: ubuntu-latest | ||||||||||
timeout-minutes: 10 | ||||||||||
|
||||||||||
steps: | ||||||||||
- name: Checkout | ||||||||||
uses: actions/checkout@v4 | ||||||||||
with: | ||||||||||
# we need all of the commits on the PR branch in order to be able to add new ones | ||||||||||
fetch-depth: 100 | ||||||||||
|
||||||||||
- name: Configure git | ||||||||||
uses: cylc/release-actions/configure-git@v1 | ||||||||||
|
||||||||||
- 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 | ||||||||||
|
||||||||||
- name: Install bufbuild/buf | ||||||||||
run: | | ||||||||||
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" # activate homebrew | ||||||||||
|
||||||||||
# NOTE: bufbuild does exist on conda-forge but hasn't been updated for a while | ||||||||||
brew install bufbuild/buf/buf | ||||||||||
|
||||||||||
- name: Lint | ||||||||||
run: | | ||||||||||
# 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 commentThe 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 commentThe 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? |
||||||||||
|
||||||||||
- name: Compatibility | ||||||||||
shell: bash -el {0} | ||||||||||
run: | | ||||||||||
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" # activate homebrew | ||||||||||
cd cylc/flow/network/protobuf | ||||||||||
# NOTE: there is currently no process for committing a breaking change. | ||||||||||
# If a breaking change is needed: | ||||||||||
# - Increment the Cylc API version number. | ||||||||||
# - Increment the protobuf schema version number to match. | ||||||||||
# - Increment the API number filter in cylc-uiserver. | ||||||||||
# - Bypass this step of the workflow. | ||||||||||
buf breaking \ | ||||||||||
--against 'https://github.com/cylc/cylc-flow.git#tag=${{ github.base_ref }},subdir=cylc/flow/network/protobuf' | ||||||||||
|
||||||||||
- name: Build | ||||||||||
shell: bash -el {0} | ||||||||||
run: | | ||||||||||
# generate .py and .pyi files from the .proto files | ||||||||||
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" # activate homebrew | ||||||||||
micromamba activate protobuf | ||||||||||
cd cylc/flow/network/protobuf | ||||||||||
buf generate | ||||||||||
|
||||||||||
- name: Commit & Push | ||||||||||
run: | | ||||||||||
if [[ -z $(git diff --stat) ]]; then | ||||||||||
echo '::error:: No functional changes made to the protobuf schema' | ||||||||||
Comment on lines
+73
to
+74
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
exit 0 | ||||||||||
else | ||||||||||
echo '::info:: pushing update commit' | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
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 commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. Didn't work |
||||||||||
exit 0 | ||||||||||
fi |
This file was deleted.
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.