Skip to content
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

ci: Add sync workflow #701

Merged
merged 3 commits into from
Jun 1, 2023
Merged

ci: Add sync workflow #701

merged 3 commits into from
Jun 1, 2023

Conversation

phlax
Copy link
Member

@phlax phlax commented May 28, 2023

Currently Envoy CI uses an SSH key with all powers to sync this repo by pushing to it

This is not optimally secure, and furthermore this pattern regularly causes Envoy CI to flake racing to checkout/push downstream repos.

I have created an app with just wf trigger permissions and added it to this repo

This PR adds a workflow that can be triggered by the app to sync Envoy by pulling from it

@phlax phlax changed the title ci: Add sync workflow [WIP] ci: Add sync workflow May 28, 2023
@phlax phlax marked this pull request as draft May 28, 2023 09:19
@alecholmez
Copy link
Contributor

@phlax let me know when this gets out of wip, thanks for this change this is great

@phlax
Copy link
Member Author

phlax commented May 28, 2023

let me know when this gets out of wip

will do, shouldnt take much, mostly i want to test it, but i think its also not quite right yet

@jpeach
Copy link
Contributor

jpeach commented May 29, 2023

I have created an app with just wf trigger permissions and added it to this repo

This PR adds a workflow that can be triggered by the app to sync Envoy by pulling from it

When this is ready, could you please also add an explanation (to the README maybe?) of where all the moving parts are, and how someone could update them? If the app has any source code, then it might be good for it to also live in the envoyproxy GitHub org.

@phlax phlax force-pushed the ci-sync branch 5 times, most recently from 78c40aa to 185efe4 Compare May 29, 2023 10:00
README.md Show resolved Hide resolved
@phlax phlax changed the title [WIP] ci: Add sync workflow ci: Add sync workflow May 29, 2023
@phlax phlax marked this pull request as ready for review May 29, 2023 10:02
@phlax
Copy link
Member Author

phlax commented May 29, 2023

@alecholmez i have shifted the algo from the python script to here, i will update to use the envoy api.go target once it has been added (envoyproxy/envoy#27675)

ive tested this pretty well now, so reasonably confident this should hit the ground working, but will follow up if there any issues

currently it takes ~3 mins, at the cost of some complexity it could be a lot faster with caching

@jpeach

When this is ready, could you please also add an explanation (to the README maybe?)

note about sync added

... of where all the moving parts are, and how someone could update them?

they are here, pr to this repo

If the app has any source code

it doesnt

then it might be good for it to also live in the envoyproxy GitHub org.

it does

Signed-off-by: Ryan Northey <ryan@synca.io>
@phlax
Copy link
Member Author

phlax commented May 29, 2023

for ref, you can see a triggered wf run here https://github.com/phlax/go-control-plane/actions/runs/5111042721/jobs/9187570100

and a commit here phlax@ed38670

i have fixed the commit message

alecholmez
alecholmez previously approved these changes May 29, 2023
Copy link
Contributor

@alecholmez alecholmez left a comment

Choose a reason for hiding this comment

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

This looks great thanks for the addition

.github/workflows/envoy-sync.yaml Show resolved Hide resolved
@phlax
Copy link
Member Author

phlax commented May 29, 2023

can we land? i have the other repos that envoy syncs to updated, so we should be good to update envoy

jpeach
jpeach previously approved these changes May 29, 2023
Copy link
Contributor

@jpeach jpeach left a comment

Choose a reason for hiding this comment

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

Nice! Added a few review comments, but just for tiny things. Not a big deal.

ci/sync_envoy.sh Outdated
# shellcheck disable=SC1091
. ci/setup_cache.sh

read -a go_protos <<< "$(bazel query "kind('go_proto_library', ${GO_TARGETS[*]})" | tr '\n' ' ')"
Copy link
Contributor

Choose a reason for hiding this comment

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

nit:

$ shellcheck ci/sync_envoy.sh

In ci/sync_envoy.sh line 31:
    read -a go_protos <<< "$(bazel query "kind('go_proto_library', ${GO_TARGETS[*]})" | tr '\n' ' ')"
    ^--^ SC2162 (info): read without -r will mangle backslashes.

For more information:
  https://www.shellcheck.net/wiki/SC2162 -- read without -r will mangle backs...

Copy link
Member Author

Choose a reason for hiding this comment

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

would be good to add shellcheck to the ci here - i was running it locally before submitting but i think this slipped through

also, would be good to clear up the whitespace issues

$ pip install envoy.code.check
$ envoy.code.check . -c glint

will show you issues

@@ -0,0 +1,95 @@
#!/bin/bash -e

set -o pipefail
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: if you add set -o errexit here, it's the same as bash -e, except (IMHO) a bit clearer to the reader.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also consider set -o nounset, which is also a useful check, though not always what you want.

Copy link
Member Author

Choose a reason for hiding this comment

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

nouunset would not work here if it is checking for an unset var

Copy link
Member Author

Choose a reason for hiding this comment

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

nit: if you add set -o errexit here, it's the same as bash -e, except (IMHO) a bit clearer to the reader.

thinking on this im not sure - my guess is that you if you surveyed devs more would recognize -e as its just far more common

re nounset - i guess it can probably work if i re/set it from the env

ci/sync_envoy.sh Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
ci/sync_envoy.sh Show resolved Hide resolved
@alecholmez
Copy link
Contributor

@phlax do you have merge permissions? If not I can roll it in

@phlax phlax dismissed stale reviews from jpeach and alecholmez via 507a6bd May 30, 2023 07:02
Signed-off-by: Ryan Northey <ryan@synca.io>
@phlax
Copy link
Member Author

phlax commented May 30, 2023

do you have merge permissions?

i do, but would rather let you guys do it

ive updated the pr with feedback

we can test it manually straight away when it lands, but i will also move to get the envoy side set up asap so we can test it properly - im happy to follow up if necessary

@alecholmez
Copy link
Contributor

I'm good to merge this... @jpeach I'll defer to you clicking the green button since you had some comments

@jpeach
Copy link
Contributor

jpeach commented May 31, 2023

I'm good to merge this... @jpeach I'll defer to you clicking the green button since you had some comments

Yeh, I just had a few nitpicks. This looks good overall 👍

@phlax phlax merged commit 9ccc02a into envoyproxy:main Jun 1, 2023
@phlax
Copy link
Member Author

phlax commented Jun 1, 2023

after removing nounset (#706 ) manual run has worked (with no change)

Syncing go protos ...
Copying ../envoy/build_go/envoy -> envoy
Copying ../envoy/build_go/contrib -> contrib
Committing changes ...
Nothing changed, not committing

https://github.com/envoyproxy/go-control-plane/actions/runs/5141777442/jobs/9254666886#step:5:160

i will land the update in Envoy shortly envoyproxy/envoy#27294 and check from there

the real test will be when there is some change to commit, so will keep watching

@phlax
Copy link
Member Author

phlax commented Jun 1, 2023

looking good

image

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