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

Feature/356/add checkstyle GitHub action to Java-SDK pipeline #142

Conversation

We2Am-BaSsem
Copy link
Contributor

@We2Am-BaSsem We2Am-BaSsem commented Mar 6, 2023

Related Issue

  • This issue is to setup a proper java based linter that enforce the conventional java coding standards and add an action for code style check to the pipeline.
    I chose checkstyle as it's most popular tool for checking java code and it's very easy and usable to be configured

Closes: #356

Describe the changes you've made

I added a the checkstyle plugin in pom.xml and configured it to use a specific configuration file I added so we can add and configure a proper set of rules (or we can use a common configuration file such as sun_check.xml).
I added an action in the pipeline as well to check the code using the configuration file added by me too so the same rules check applied both on the pipeline action or locally.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Code style update (formatting, local variables)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How did you test your code changes?

I tried those changes on a forked repo and tried to make a PR with the empty configuration file to check it should pass as there are no rules to check then added a rule that should fail the pipeline and pushed it and checked that the pipeline did fail.
when tried to apply rules on agent module this is what I got:
image
and pipeline failed
image

Signed-off-by: We'am Bassem <58189568+We2Am-BaSsem@users.noreply.github.com>
Signed-off-by: We'am Bassem <58189568+We2Am-BaSsem@users.noreply.github.com>
Signed-off-by: We'am Bassem <58189568+We2Am-BaSsem@users.noreply.github.com>
Signed-off-by: We'am Bassem <58189568+We2Am-BaSsem@users.noreply.github.com>
@We2Am-BaSsem We2Am-BaSsem force-pushed the feature/129/add-checkstyle-github-action branch from b61f839 to f55c53b Compare March 6, 2023 01:47
Signed-off-by: We'am Bassem <58189568+We2Am-BaSsem@users.noreply.github.com>
Signed-off-by: We'am Bassem <58189568+We2Am-BaSsem@users.noreply.github.com>
@Sonichigo
Copy link
Member

@charankamarapu Can you please review the PR ?

@charankamarapu
Copy link
Member

Will review it by tomorrow 12 pm.

@charankamarapu charankamarapu self-requested a review March 6, 2023 12:43
@We2Am-BaSsem
Copy link
Contributor Author

@charankamarapu
Is there any required changes?

pom.xml Outdated
<artifactId>checkstyle</artifactId>
<version>8.31</version>
</dependency>
<dependency>
Copy link
Member

Choose a reason for hiding this comment

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

Why is Java SDK added over here ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this runs checkstyle check during release
but including it in build only would be enough I guess.

Copy link
Member

Choose a reason for hiding this comment

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

we use profiles to change default build config . As you have already added plugins in . I don't think there is a need to mention them again in profile . Please check this once and remove plugin from profile

<!-- </module>-->
<!-- <module name="BeforeExecutionExclusionFileFilter">-->
<!-- <property name="fileNamePattern" value="/agent/"/>-->
<!-- </module>-->
Copy link
Member

Choose a reason for hiding this comment

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

Where are the checks like - AvoidStarImport

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@charankamarapu
I avoided to add rules right now to avoid pipeline failure
when I tried to run check it resulted +15K rule violation which won't be practical to solve in one issue and we don't have unit tests to to verify that everything still works as expected after such significant changes.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah I get it but u can use BeforeExecutionExclusionFileFilter - exclude all files and add all the rules so that there will be no errors. Then other developers will see the rules include each module and work on it . I mean If we don't specify rules what will we be benchmarking our code against? Please add the rules and exclude all the modules/files and also add a screenshot by including one module/file which shows all the errors.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure on it

- uses: actions/checkout@v2
- uses: dbelyaev/action-checkstyle@v0.6.1
with:
github_token: ${{ secrets.github_token }}
Copy link
Member

Choose a reason for hiding this comment

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

Is github_token mandatory over here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this only to catch info for PR but it's not mandatory even when I deleted this line things still work.

Copy link
Member

Choose a reason for hiding this comment

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

I dont think that is required . Remove it if it is not necessary.

Signed-off-by: We'am Bassem <58189568+We2Am-BaSsem@users.noreply.github.com>
Signed-off-by: We'am Bassem <58189568+We2Am-BaSsem@users.noreply.github.com>
@We2Am-BaSsem
Copy link
Contributor Author

@charankamarapu
please review changes.

@charankamarapu
Copy link
Member

Ship it!

@charankamarapu charankamarapu added Accepted PR is reviewed and Accepted Don't Merge Not to be merged until gsoc results labels Mar 10, 2023
@charankamarapu charankamarapu merged commit 09fa4d1 into keploy:main May 24, 2023
@charankamarapu charankamarapu removed the Don't Merge Not to be merged until gsoc results label May 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Accepted PR is reviewed and Accepted
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[feature]: create a github action for running java based linters in pipeline
3 participants