-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
[DO-NOT-MERGE][incubator-kie-drools-6220] Slim down DRL syntax with New Antlr4 Parser #6225
base: main
Are you sure you want to change the base?
[DO-NOT-MERGE][incubator-kie-drools-6220] Slim down DRL syntax with New Antlr4 Parser #6225
Conversation
9fcc046
to
76f8c98
Compare
PR job Reproducerbuild-chain build full_downstream -f 'https://raw.githubusercontent.com/${AUTHOR:apache}/incubator-kie-kogito-pipelines/${BRANCH:main}/.ci/buildchain-config-pr-cdb.yaml' -o 'bc' -p apache/incubator-kie-drools -u #6225 --skipParallelCheckout NOTE: To install the build-chain tool, please refer to https://github.com/kiegroup/github-action-build-chain#local-execution Please look here: https://ci-builds.apache.org/job/KIE/job/drools/job/main/job/pullrequest_jobs/job/drools-pr/job/PR-6225/6/display/redirect Test results:
Those are the test failures: PR check / Build projects / maven.invoker.it.drools-test-coverage-jars-with-invoker.drools-test-coverage-jars-with-invokerThe build exited with code 143. See /home/jenkins/workspace/llrequest_jobs_drools-pr_PR-6225/kogito-pipelines/bc/apache_incubator-kie-drools/drools-test-coverage/test-compiler-integration/../drools-test-coverage-jars/drools-test-coverage-jars-with-invoker/build.log for details. |
1457c6f
to
e59ed36
Compare
- Introduce DRL10 - WIP
fcf232c
to
37a218d
Compare
2559994
to
428a1e6
Compare
PR job Reproducerbuild-chain build full_downstream -f 'https://raw.githubusercontent.com/${AUTHOR:apache}/incubator-kie-kogito-pipelines/${BRANCH:main}/.ci/buildchain-config-pr-cdb.yaml' -o 'bc' -p apache/incubator-kie-drools -u #6225 --skipParallelCheckout NOTE: To install the build-chain tool, please refer to https://github.com/kiegroup/github-action-build-chain#local-execution Please look here: https://ci-builds.apache.org/job/KIE/job/drools/job/main/job/pullrequest_jobs/job/drools-pr/job/PR-6225/14/display/redirect Test results:
Those are the test failures: org.drools.model.codegen.execmodel.generator.drlxparse.ConstraintParserTest.testImplicitCastExpressionWithOrCannot invoke "org.drools.drl.ast.descr.RuleDescr.getName()" because "this.ruleDescr" is nullorg.drools.model.codegen.execmodel.generator.drlxparse.ConstraintParserTest.testNullSafeExpressionsWithOrCannot invoke "org.drools.drl.ast.descr.RuleDescr.getName()" because "this.ruleDescr" is nullorg.kie.maven.plugin.it.kie-maven-plugin-test-kjar-15-yaml.kie-maven-plugin-test-kjar-15-yamlThe build exited with code 143. See /home/jenkins/workspace/llrequest_jobs_drools-pr_PR-6225/kogito-pipelines/bc/apache_incubator-kie-drools/kie-maven-plugin/target/it/kie-maven-plugin-test-kjar-15-yaml/build.log for details. |
After review, revert GHA changes. So this is still "Draft" |
- Disable drools-verifier test for DRL10
- adjust unit tests
8a9bbff
to
b7c1b54
Compare
@@ -61,7 +61,7 @@ jobs: | |||
- name: Build Chain | |||
uses: apache/incubator-kie-kogito-pipelines/.ci/actions/build-chain@main | |||
env: | |||
BUILD_MVN_OPTS_CURRENT: '-Dfull -Dreproducible' | |||
BUILD_MVN_OPTS_CURRENT: '-Dfull -Dreproducible -DenableNewParser' |
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.
This is a temporal change to test the new parser (= DRL10). I'll revert this after review.
private static int logCounterHalfConstraint = 0; | ||
private static int logCounterCustomOperator = 0; | ||
private static int logCounterInfixAnd = 0; | ||
private static int logCounterInfixOr = 0; | ||
private static int logCounterAnnotationInLhsPattern = 0; | ||
private static int logCounterAgendaGroup = 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.
A counter to suppress log flooding. Using static int
is a bit rough way, but ParserHelper
instance is short-living, so we cannot use instance fields. Managing the counter in an external class seems to be too much for logging.
public static void logHalfConstraintWarn(String message) { | ||
if (logCounterHalfConstraint > 10) { | ||
return; // suppress further warnings | ||
} | ||
|
||
logCounterHalfConstraint++; | ||
LOG.warn(message); | ||
if (logCounterHalfConstraint == 10) { | ||
LOG.warn("Further warnings about half constraints will be suppressed."); | ||
} | ||
} |
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 counter usage is repetitive in the log methods. I may be able to refactor them, but I guess it cannot be improved much. If you want me to refactor, I can try and share.
@@ -1558,6 +1558,7 @@ public AttributeDescr attribute(AttributeSupportBuilder<?> as) { | |||
DroolsSoftKeywords.GROUP)) { | |||
attribute = stringAttribute(as, | |||
new String[]{DroolsSoftKeywords.AGENDA, "-", DroolsSoftKeywords.GROUP}); | |||
helper.logAgendaGroupWarn(attribute); |
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.
Note that DRL6Parser.java
was generated from .g
file in the past, and then has been maintained by hard-coding in the java file. So I add the logging directly, not modifying .g
file.
public static String replaceAgendaGroupIfRequired(String drl) { | ||
if (DrlParser.ANTLR4_PARSER_ENABLED) { | ||
// new parser (DRL10) supports only ruleflow-group, dropping agenda-group | ||
return drl.replaceAll("agenda-group", "ruleflow-group"); | ||
} | ||
return drl; | ||
} |
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.
replaceAgendaGroupIfRequired
is defined in 3 places in this PR, because we don't have a common test util module which can access drools-drl-parser
.
kie-test-util
doesn't depend on any drools modulesdrools-legacy-test-util
is meant be 'legacy' (to be removed)
I think this topic should be separated from this PR and I will consult @pibizza .
fileSystem.write(resource); | ||
} | ||
fileSystem.writeKModuleXML(kieModuleModel.toXML()); | ||
return fileSystem; | ||
} | ||
|
||
private static Resource newResourceForNewParserIfRequired(Resource resource) { |
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.
This method is used for the new parser testing (not enabled by default). Actually, only to convert agenda-group
to ruleflow-group
because agenda-group
is not allowed in DRL10, but it's widely used in the test cases (cannot manage with @DisabledIfSystemProperty
). When we drop DRL6 in the future, we will be able to fully replace agenda-group
in test cases and remove this conversion.
<artifactId>maven-surefire-plugin</artifactId> | ||
<configuration> | ||
<!-- drools-verifier doesn't support DRL10 --> | ||
<skipTests>true</skipTests> |
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.
DRLs in drools-verifier
hit the dropped syntax in DRL10 (e.g. half constraint). I can fix them, but probably we want to discuss whether will keep maintaining drools-verifier
or not. So I delay the fix for now.
Hi @mariofusco @porcelli @gitgabrio @baldimir @mdproctor @pibizza , Here is the DRL10 syntax slim down. As written in https://docs.google.com/document/d/1Ibmj-koAMbeaungHuFeQtw2zD03YJcNJkJ-kdN8ugks/edit?tab=t.0 , This PR does:
The Please review, thanks! |
Issue:
Slim down DRL syntax with New Antlr4 Parser #6220
Introduce DRL10
WIP