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: run dependency sync script periodically and open a PR for it #339

Merged
merged 2 commits into from
Sep 14, 2023

Conversation

roobre
Copy link
Collaborator

@roobre roobre commented Sep 12, 2023

Description

This PR introduces a CI job that runs hack/depsync every day, and creates (or updates if it exists) a PR with the changes it produces.

PR should only be created if the job produces any changes to the git repository.

An example of the PR that would be created can be found here: roobre#28

Unfortunately, this does not currently trigger the regular PR workflow that would unittest those changes. This is a deliberate limitation of GH actions, as they automatically-generated GITHUB_TOKENs they use do not trigger other workflows themselves.

As a workaround for this, we can simply close and then reopen the PR, which will trigger the usual CI jobs for it, which the PR description says as a reminder. As I don't foresee having to do this very often, I think this workaround is enough and less maintenance than the alternative of creating a GitHub applciation.

Checklist:

  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works.
  • I have run linter locally (make lint) and all checks pass.
  • I have run tests locally (make test) and all tests pass.
  • I have run relevant integration test locally (make integration-xxx for agent related changes)
  • I have run relevant e2e test locally (make e2e-xxx for disruptors, kubernetes or cluster related changes)
  • Any dependent changes have been merged and published in downstream modules

@roobre roobre marked this pull request as ready for review September 13, 2023 16:33
git commit -am "go.mod: sync dependencies with k6 core"
git push -f -u origin "$BRANCH_NAME"

cat <<EOF > pr-body.txt
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not a fan of embedding texts in this way. I would prefer to have a script that generates this output.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm not sure I follow. WDYM by a script that generates the output? Something like this same code but in a separate .sh file?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, exactly.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

What would be the advantage in this case? I agree the heredoc is not particularly pretty, but to me moving it to a separate script will make the yaml file harder to follow, as you would need to go somewhere else to check what the file is doing. Moreover such script wouldn't make sense outside of the context of this particular CI step.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Basically, I think it is a bad practice to put any logic that does not depend on the CI environment (e.g. retrieving information provided by the CI) in the CI. Using a separate script allows running and testing this logic locally, if needed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Makes sense. I've added a depsync.sh script that does pretty much everything that is not related to git. LMK if this looks better :)

Copy link
Collaborator

@pablochacin pablochacin left a comment

Choose a reason for hiding this comment

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

Even with the minor limitations mentioned in the PR, this is a great tool to prevent conflicts in the dependencies with k6. Great job.

@roobre roobre merged commit 7700107 into main Sep 14, 2023
6 checks passed
@roobre roobre deleted the ci-depsync branch September 14, 2023 13:26
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.

None yet

2 participants