-
Notifications
You must be signed in to change notification settings - Fork 14.1k
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-17606: Include Rat errors in GitHub workflow summary #17280
Conversation
@chia7712 please take a look,thanks! |
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 patch @LoganZhuZzz!
Left a few minor comments inline. Can you temporarily add a couple of files without a license so we can see the script working in this PR?
.github/workflows/build.yml
Outdated
@@ -68,6 +68,11 @@ jobs: | |||
./gradlew --build-cache --info \ | |||
${{ inputs.is-public-fork && '--no-scan' || '--scan' }} \ | |||
check -x test | |||
- name: Annotate Rat errors |
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.
Can you move this down with the checkstyle step?
.github/workflows/build.yml
Outdated
@@ -68,6 +68,11 @@ jobs: | |||
./gradlew --build-cache --info \ | |||
${{ inputs.is-public-fork && '--no-scan' || '--scan' }} \ | |||
check -x test | |||
- name: Annotate Rat errors | |||
if: ${{ 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.
We should only run this on java 21 to avoid duplicate reports from the parallel builds
…errors' and restrict to Java 21 builds - Moved the 'Annotate Rat errors' step to follow the 'Annotate checkstyle errors' step, ensuring both error annotation steps are grouped for better workflow clarity. - Added a conditional check to only run the 'Annotate Rat errors' step on Java 21 to prevent duplicate reports across parallel builds, in line with the checkstyle step behavior. - Temporarily added test files without licenses to validate that unapproved licenses are correctly summarized in the GitHub workflow, per feedback.
Thank you for the feedback on the patch @mumrah
Please let me know if there’s anything else you would like me to address! |
Thanks @LoganZhuZzz, the script output looks good. Can you try the following for me:
This way, the link to the failed workflow will take us to the Rat output rather than the first failing step. Also, could you include "::notice" output in the script similar to this https://github.com/apache/kafka/blob/trunk/.github/scripts/checkstyle.py#L64? This is how we actually create the annotations. Note that the line number starts with 1. https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions#setting-a-notice-message |
- Added `ignoreRatFailure` parameter to `build.gradle` to control the `failOnError` behavior of the Rat task. - Updated `build.yml` to pass the `ignoreRatFailure` parameter when invoking `check -x test`. - Modified `rat.py` to exit with code 1 if unapproved licenses are found, ensuring that the workflow failure links directly to the Rat output for improved traceability. This change facilitates better handling of Rat reports within the CI/CD pipeline.
Thanks for the guidance. @mumrah |
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 updates @LoganZhuZzz! Just a few small comments.
Can you try this out on your fork and include a link to the results?
build.gradle
Outdated
@@ -210,6 +210,10 @@ def determineCommitId() { | |||
apply from: file('wrapper.gradle') | |||
|
|||
if (repo != null) { | |||
ext { | |||
ignoreRatFailure = project.hasProperty('ignoreRatFailure') ? project.ignoreRatFailure.toBoolean() : false |
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.
Can you relocate this with other property handling? (Along with userMaxForks, etc)
.github/workflows/build.yml
Outdated
@@ -67,7 +67,7 @@ jobs: | |||
run: | | |||
./gradlew --build-cache --info \ | |||
${{ inputs.is-public-fork && '--no-scan' || '--scan' }} \ | |||
check -x test | |||
check -x test -PignoreRatFailure=true |
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.
Can you move the property before the task on a separate line?
.github/scripts/rat.py
Outdated
rel_path = os.path.relpath(file, workspace_path) | ||
print(f"::notice file={rel_path},title=Unapproved License::File with unapproved license") | ||
|
||
exit(1 if total_unapproved_licenses > 0 else 0) |
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.
Can you make this a regular if/else rather than inlined?
- Moved the `ignoreRatFailure` property to a separate line before `check -x test` for clarity. - Added a comment for the `-PignoreRatFailure=true` flag to improve documentation. - Relocated `ext` block configuration for better management alongside other properties
Hi David @mumrah ! Here are the results on my fork: Compile and Validate ResultsAnnotate Rat Errors ResultsQuestions
Root Cause of
|
I see what you mean. In this case, let's do the same as we do for checkstyle and let RAT failures fail the build. Then, we will hit the |
… the build This change aligns the behavior of the RAT task with the checkstyle task, ensuring that any RAT failures will trigger the `failure()` condition in the workflow. This should enable the `Annotate Rat errors step` to execute as expected.
Now, it meets our expectations. Any suggestions? @mumrah Output Results |
@LoganZhuZzz, looks great! Please revert the temporary files and I'll merge this. |
Thanks for the guidance. @mumrah |
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, thanks @LoganZhuZzz!
edit: Also, thanks for the well written and well formatted PR :)
) Reviewers: David Arthur <[email protected]>
In the current GitHub workflow, it has become difficult to locate Rat errors when running
check -x test
. To improve readability and make it easier to identify Rat errors, we need to include them in the workflow summary.Key Modifications
rat.py
in thebuild.yml
file to annotate Rat errors after theCompile and validate
step.Compile and validate
step fails.Purpose
Notes
Committer Checklist (excluded from commit message)