-
Notifications
You must be signed in to change notification settings - Fork 4
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
Support of config bundles with extra configuration files #219
Conversation
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.
Items
|
||
// Verify that the generated config includes the external file reference | ||
assertThat(generatedConfigContent) | ||
.contains("<property name=\"headerFile\" value=\"config/java.header\"/>"); |
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 need path that will work for diff tool.
I think we can value=\"${execution.path}/config/java.header\"/>"
And we will set this variable when we start diff tool, so internal checkstyle execution will not have problems to find this header file.
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.
done
extractor/src/test/java/com/example/extractor/MainsLauncherTest.java
Outdated
Show resolved
Hide resolved
6de8ea6
to
5cf16c2
Compare
@romani, please review. |
@relentless-pursuit , please disable execution of cron action in your fork, to avoid extra commits. |
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.
Items
@@ -147,6 +172,19 @@ public static void main(final String[] args) throws Exception { | |||
// Output default projects list | |||
outputDefaultProjectsList(projectsOutputPath); | |||
} | |||
else if (args.length == CONFIG_FILE_ARG_COUNT | |||
&& "--config-file".equals(args[CONFIG_FILE_FLAG_INDEX])) { |
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 should not be any different from regular execution on Input.
We should have a some structure inside that describe all Checks properties that having external property files. We do not have much of them, better to hard code them for now.
We might need to simply update examples in main repository to reference same config name and use the same system variable and path in config.
So we can simply put a predefined file to generation target folder.
If some module define content of config and we need to use it, we can rename them to be predictable and just use specific logic for module that is registered as external file module.
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.
https://checkstyle.org/checks/header/regexpheader.html#Example2-config
We can make it:
<module name="Checker">
<module name="RegexpHeader">
<property name="headerFile" value="${config.path}/java.header"/>
<property name="multiLines" value="10, 13"/>
</module>
</module>
in main repository.
And in test-configs project just parse Input as regular Input, if we detect special module like this, we copy config files that are hard coded path to them in our code structure.
During execution of test bundle we just always define this system variable, even it will not be in use by module.
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.
@relentless-pursuit , ping. Do you need any assistance?
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.
@relentless-pursuit , ping. Do you need any assistance?
@romani, can you re-review?
4351c8a
to
bee1587
Compare
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.
items:
String updatedContent = configContent; | ||
|
||
// Regular expression to find properties with external file references | ||
final Pattern pattern = Pattern.compile("<property name=\"([^\"]+)\" value=\"([^\"]+)\"/>"); |
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.
lets simply hardcode in this project properties with files, there only few of them, and unlikely to grow a lot.
// Replace the path with ${config.path} | ||
final String newPropertyValue = propertyValue | ||
.replace("${execution.path}", CONFIG_PATH_VARIABLE) | ||
.replace("config/java.header", CONFIG_PATH_VARIABLE + "/java.header"); |
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 do not need to hack path in extractor.
We can put this variable to ExampleX in checkstyle repo.
// Write the java.header file inside the 'config' directory | ||
final String headerFileContent = """ | ||
^// Copyright \\(C\\) (\\d\\d\\d\\d -)? 2004 MyCompany$ | ||
^// All rights reserved$ | ||
"""; |
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.
please make it as static file in repo, that you will use during test execution.
same for config file.
processInputFile(inputFile, configOutputFile); | ||
outputDefaultProjectsList(projectsOutputFile.toString()); | ||
} | ||
else if ("--config-file".equals(option)) { |
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 do not need any few argument in CLI.
as we come to extraction of Check that is in our hardcoded map/collection of modules that have external files, we just put specific file to result folder.
path to it defined by variable, variable already in config for ExampleX.java.
During execution of regression testing we just need to set varable to required value, and download such extra file.
18fbd83
to
e1c5904
Compare
@relentless-pursuit , CI is red. |
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.
Items
RegexpHeader/Example2/config.xml
Outdated
@@ -17,7 +17,7 @@ | |||
</module> | |||
|
|||
<module name="RegexpHeader"> | |||
<property name="headerFile" value="config/java.header"/> | |||
<property name="headerFile" value="java.header"/> |
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.
Please send PR to checkstyle project
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.
@romani , finally got the CI working. There is somethign wrong with local code base, not being able to see failures, need to delete and clone fresh, please re-review.
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.
Ok, but still this change is not expected.
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.
Please send update to main repository
<property name="headerFile" value="${config.folder}/java.header"/>
Extractor should not do any changes.
Config should stay unchanged.
GitHub workflow should define system variable config.folder
and propagate it to checkstyle execution.
0440669
to
26cbd35
Compare
updating this PR as we have decided to change the approach. made changes to the pom's template file. generate report phase was working. |
26cbd35
to
b005b7e
Compare
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.
good.
item:
@@ -16,6 +16,7 @@ | |||
<sevntu-checkstyle.version>1.44.1</sevntu-checkstyle.version> | |||
<checkstyle.config.location>https://raw.githubusercontent.com/checkstyle/checkstyle/master/src/main/resources/google_checks.xml</checkstyle.config.location> | |||
<checkstyle.failsOnError>true</checkstyle.failsOnError> | |||
<config.folder>${project.basedir}/config</config.folder> |
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.
an we avoid this default value ?
or please explain why have it.
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.
@romani
We store a java.header
file under our config folder. Without the config.folder property and its reference, Checkstyle might not know where to locate java.header—it would either default to a different configuration or fail if it cannot find a valid header. By explicitly setting config.folder=${project.basedir}/config and using in the Checkstyle plugin, we ensure that our local java.header is always picked up during the build.
Please correct me if i am wrong or missing anything.
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.
Does it make more sense to rely on the project for the defaults?
For 3rd party projects, we define a properties file with basically these defaults.
https://github.com/sevntu-checkstyle/sevntu.checkstyle/blob/f01cb81dd1bb771f8471196a7787630f2a84861e/sevntu-checkstyle-sonar-plugin/checkstyle.properties
Main repo doesn't have this file and it is embedded into the ant process.
https://github.com/checkstyle/checkstyle/blob/master/config/ant-phase-verify.xml#L48
So it would require a change to main repo.
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 need to download such file like we do with configs NEW_MODULE_CONFIG="${{ github.workspace }}/.ci-temp/new_module_config.xml"
https://github.com/checkstyle/checkstyle/blob/d1523dab4bbd520340336912ca6974905b4f41ec/.github/workflows/regression-report.yml#L555
to execute on them https://github.com/checkstyle/checkstyle/blob/d1523dab4bbd520340336912ca6974905b4f41ec/.github/workflows/regression-report.yml#L575
java.header
should be file file in test-configs repository that is downloadable together with other files and java -jar "$DIFFTOOL_JAR"
should execute with this variable defined to let checkstyle find java.header
I am not sure what is /config
folder ?
diff-java-tool/src/main/resources/pom_template.xml
is pom.xml that will be placed to filesystem during run of java -jar "$DIFFTOOL_JAR"
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.
Check is updated to have property #224
please proceed to update workflow.
Part of: #214