-
Notifications
You must be signed in to change notification settings - Fork 14k
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
KAFKA-17540: Create script for updating a reference of latest cached trunk commit #17204
KAFKA-17540: Create script for updating a reference of latest cached trunk commit #17204
Conversation
Hi, @mumrah! I have made a test to check if it works as expected. You can check it: https://github.com/fonsdant/github-actions. To test, I have created two jobs: one for a successful build (and then tag update) and another for a failed build (no tag update). I have needed to give read and write permission to GitHub Action to perform the tag creation. |
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.
Thanks @fonsdant! Left a few comments.
I also wonder if we should put this in the CI Complete workflow. Though unlikely, it is possible that the build succeeds, but writing to the cache fails in the Post Gradle Setup step. If this happened, we would have updated the tag prematurely.
If we add a "update-cached-tag" job in CI Complete, we can trigger it to only run when a CI workflow on trunk is successful (which would mean the cache was updated).
Moved! |
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.
One small thing remaining.
Also, can you see if signed tags are possible here? That might be a nice thing to include.
.github/workflows/ci-complete.yml
Outdated
|
||
update-cached-tag: | ||
# Skip this workflow if the CI run was skipped or cancelled | ||
if: (github.event.workflow_run.conclusion == 'success' || github.event.workflow_run.conclusion == 'failure') |
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.
In this case, we only want to run if the workflow was successful.
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.
Oh, thanks! I will fix it!
Yes, they are possible but require a GPG key. Is the purpose of the sign to be the same as the commits? If so, maybe we could add a |
No, the purpose is just to have a signature on the tag itself. When Github merges PRs, it will sign the resulting commit with its own gpg key. I was hoping that doing |
I think tag signing with |
I have made a test. Only to confirm: is it not work as expected because of this? Git could not determine GitHub bot's email. Maybe we could use |
Yes, using
We're using this tool to create custom statuses on PRs here https://github.com/apache/kafka/blob/trunk/.github/actions/gh-api-update-status/action.yml#L55-L59 |
Oh! I have noted it fails when tag ref already exists. I am working on fix it! |
@fonsdant first off, thanks for all the work on this. I was pondering this yesterday and had an idea. Instead of managing a tag, I think we can use a separate branch, something like In this case, the CI becomes simply
This will improve the developer experience somewhat since it doesn't require explicitly fetching tags. Just a simple Can you give this a try? |
I am happy to help! :) Sure! I will give it a try. It seems simpler for me too! |
Hi, @mumrah! I have made some modifications. I have used |
.github/workflows/ci-complete.yml
Outdated
steps: | ||
- name: Update trunk-cached branch with trunk | ||
run: | | ||
git switch trunk-cached || git switch -c trunk-cached |
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.
Do we need to fetch trunk-cached first? Or does the checkout step fetch everything?
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.
As we are doing a reset
here, it is not needed to do fetch
. Even if we do fetch
, the fetched trunk-cached branch will be reset to github.sha
as well as the unfetched trunk-cached branch. So the fetched trunk-cached does not change the result.
In a way, the github.sha
is already our "fetched branch" or "reference", which the trunk-cached branch should point to. And push -f
guarantees the update will be performed without fast-forward or similar issues.
I have done two tests for this. You can check them here and here.
This is the git log
result:
$ git log --oneline
e8da285 (HEAD -> trunk, origin/trunk-cached, origin/trunk) update ble.txt
d9c105e minimal impl
425d23e replace sha with origin trunk branch
...
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.
Thanks for the explanation. Looks like we're always doing git switch -c
to create a local branch, so maybe we don't need the first git switch
?
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 are right! I will remove the git switch
. Thanks!!
The new
|
Ok, now we need to take the SHA captured by I'd like to see this output:
BTW, does the |
I think it will not work well for all cases. In my local repo,
Yep! :)
|
Good point on different remote names. Let's still attempt to update the ref in this script. If it can't be done, print a warning and recommend to the user to update their remote.
|
committer-tools/update-cache.sh
Outdated
git switch trunk-cached &> /dev/null || git switch -c trunk-cached &> /dev/null | ||
if git merge "$sha" &> /dev/null; then |
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.
Since this script is managing the trunk-cached
ref exclusively, lets just use git update-ref
.
git update-ref -m 'some message' trunk-cached $sha
if the SHA doesn't exist, it will fail with a non-zero exit code
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.
It seems it is not working as expected... I am trying to update to 235cafa, but my trunk-cached still points to 1f04436de1. See:
$ git update-ref -m 'test' trunk-cached 235cafa805
$ echo $?
0
$ git log
...
1f04436de1 (trunk-cached) Merge commit '1854d4b8a11461b53b59fa109b95f2a4f5003997' into trunk-cached
...
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.
But using git branch -f
has worked well:
$ git branch -f trunk-cached 235cafa805
$ git log
...
235cafa805 (trunk-cached) KAFKA-6197: Update Streams API and Javadoc references in documentation (#17215)
...
Signed-off-by: Joao Pedro Fonseca Dantas <fonsdant@gmail.com>
Signed-off-by: Joao Pedro Fonseca Dantas <fonsdant@gmail.com>
Signed-off-by: Joao Pedro Fonseca Dantas <fonsdant@gmail.com>
The script has failed with |
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.
docs/ops.html
Outdated
@@ -1249,7 +1249,7 @@ <h4 class="anchor-heading"><a id="prodconfig" class="anchor-link"></a><a href="# | |||
|
|||
<h3 class="anchor-heading"><a id="java" class="anchor-link"></a><a href="#java">6.6 Java Version</a></h3> | |||
|
|||
Java 8, Java 11, Java 17, and Java 21 are supported. | |||
Java 8, Java 11, Java 17, Java 21, and Java 23 are supported. |
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.
Was this change intentional?
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.
Oh! It should not have been sent actually. Thanks! I will remove it.
committer-tools/update-cache.sh
Outdated
|
||
sha="$(cut -d '-' -f 5 <<< "$key")" | ||
|
||
git fetch &> /dev/null |
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.
The behavior of git fetch
with no args depends on the local config, so it might not be the same for everyone.
Since we are expecting developers to have done the appropriate git fetch
or git pull
prior to running this command, I think we can omit the git fetch
completely from this script.
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.
Make sense, I will proceed this way!
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.
LGTM!
I'm going to go ahead and merge this after incorporating to two minor nitpicks from the last review. Thanks for sticking with us through this PR @fonsdant 😄. I think we ended up trying three totally different approaches before settling on the local script.
@fonsdant thanks for this great contribution! |
No description provided.