Skip to content

Commit

Permalink
[DROOLS-6495] Implement backward compatibility test for compiled kjar
Browse files Browse the repository at this point in the history
- WIP
  • Loading branch information
tkobayas committed Aug 9, 2023
1 parent 766b2d0 commit a54e753
Show file tree
Hide file tree
Showing 14 changed files with 490 additions and 0 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/pr-drools-backward-compatibility.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Drools Backward Compatibility

on:
pull_request:
paths-ignore:
- 'LICENSE'
- '**/.gitignore'
- '**.md'
- '**.adoc'
- '*.txt'
- 'docsimg/**'
- '.ci/jenkins/**'

jobs:
drools-build:
concurrency:
group: pr-drools-backward-compatibility_${{ matrix.os }}_${{ matrix.java-version }}_${{ matrix.maven-version }}_${{ github.head_ref }}
cancel-in-progress: true
timeout-minutes: 120
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
java-version: [11]
maven-version: ['3.8.7']
fail-fast: false
runs-on: ${{ matrix.os }}
name: ${{ matrix.os }} / Java-${{ matrix.java-version }} / Maven-${{ matrix.maven-version }}
steps:
- name: Clean Disk Space
uses: kiegroup/kie-ci/.ci/actions/ubuntu-disk-space@main
if: ${{ matrix.os == 'ubuntu-latest' }}
- name: Support long paths
if: ${{ matrix.os == 'windows-latest' }}
uses: kiegroup/kie-ci/.ci/actions/long-paths@main
- name: Checkout
uses: actions/checkout@v3
- name: Java and Maven Setup
uses: kiegroup/kie-ci/.ci/actions/maven@main
with:
java-version: ${{ matrix.java-version }}
maven-version: ${{ matrix.maven-version }}
cache-key-prefix: ${{ runner.os }}-${{ matrix.java-version }}-maven${{ matrix.maven-version }}
- name: Build Drools
run: mvn -B clean install -DskipTests
- name: Backward Compatibility Test with previous minor version
run: |
CURRENT_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
PREVIOUS_VERSION=$(script/utils/get_previous_version.sh $CURRENT_VERSION)
mvn -B clean install --file drools-reference-examples/pom.xml -Preference -Dreference.kjar.drools.version=$PREVIOUS_VERSION
35 changes: 35 additions & 0 deletions bom/drools-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1026,6 +1026,41 @@
<version>${project.version}</version>
<classifier>sources</classifier>
</dependency>

<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-reference-examples-common</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-reference-examples-common</artifactId>
<version>${project.version}</version>
<classifier>sources</classifier>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-reference-examples-kjar</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-reference-examples-kjar</artifactId>
<version>${project.version}</version>
<classifier>sources</classifier>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-reference-examples-runner</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-reference-examples-runner</artifactId>
<version>${project.version}</version>
<classifier>sources</classifier>
</dependency>

<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-docs</artifactId>
Expand Down
11 changes: 11 additions & 0 deletions drools-reference-examples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
`drools-reference-examples` contains internal reference examples which can be used for smoke tests, backward compatibility tests, etc.

To run the project, enable the `reference` profile:

cd drools-reference-examples
mvn clean install -Preference

By default, kjar projects are built with the current project version of `kie-maven-plugin`. To build with a specific version of `kie-maven-plugin`, use `reference.kjar.drools.version` property:

mvn clean install -Preference -Dreference.kjar.drools.version=8.39.0.Final

22 changes: 22 additions & 0 deletions drools-reference-examples/drools-reference-examples-common/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.drools</groupId>
<artifactId>drools-reference-examples</artifactId>
<version>8.43.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

<groupId>org.drools</groupId>
<artifactId>drools-reference-examples-common</artifactId>

<name>Drools reference examples :: Common</name>
<description>Pojo classes for kjar and runner</description>

<properties>
<java.module.name>org.drools.reference.examples.common</java.module.name>
</properties>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Copyright 2023 Red Hat, Inc. and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.drools.reference.examples.helloworld;

public class Message {

public static final int HELLO = 0;
public static final int GOODBYE = 1;

private String message;

private int status;

public Message() {

}

public String getMessage() {
return this.message;
}

public void setMessage(final String message) {
this.message = message;
}

public int getStatus() {
return this.status;
}

public void setStatus(final int status) {
this.status = status;
}
}
74 changes: 74 additions & 0 deletions drools-reference-examples/drools-reference-examples-kjar/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.drools</groupId>
<artifactId>drools-reference-examples</artifactId>
<version>8.43.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

<groupId>org.drools</groupId>
<artifactId>drools-reference-examples-kjar</artifactId>
<packaging>kjar</packaging>

<name>Drools reference examples :: kjar</name>
<description>Reference example kjar</description>

<properties>
<java.module.name>org.drools.reference.examples.kjar</java.module.name>
</properties>

<dependencies>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-reference-examples-common</artifactId>
</dependency>

<!-- use specified drools version to build a kjar -->
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-engine</artifactId>
<version>${reference.kjar.drools.version}</version>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-model-compiler</artifactId>
<version>${reference.kjar.drools.version}</version>
</dependency>

<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<executions>
<execution>
<!-- suppress enforcer no-managed-deps -->
<id>no-managed-deps</id>
<phase>none</phase>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.kie</groupId>
<artifactId>kie-maven-plugin</artifactId>
<version>${reference.kjar.drools.version}</version>
<extensions>true</extensions>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<kmodule xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.drools.org/xsd/kmodule">
<kbase name="HelloWorldKB" packages="org.drools.reference.examples.helloworld">
<ksession name="HelloWorldKS"/>
</kbase>
</kmodule>
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Copyright 2023 Red Hat, Inc. and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.drools.reference.examples.helloworld

import org.drools.reference.examples.helloworld.Message;

global java.util.List list

rule "Hello World"
dialect "mvel"
when
m : Message( status == Message.HELLO, message : message )
then
System.out.println( message );
list.add( message );
modify ( m ) { message = "Goodbye cruel world",
status = Message.GOODBYE };
end

rule "Good Bye"
dialect "java"
when
Message( status == Message.GOODBYE, message : message )
then
System.out.println( message );
list.add( message );
end
69 changes: 69 additions & 0 deletions drools-reference-examples/drools-reference-examples-runner/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.drools</groupId>
<artifactId>drools-reference-examples</artifactId>
<version>8.43.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

<groupId>org.drools</groupId>
<artifactId>drools-reference-examples-runner</artifactId>

<name>Drools reference examples :: runner</name>
<description>Reference example runner</description>

<properties>
<java.module.name>org.drools.reference.examples.runner</java.module.name>
</properties>

<dependencies>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-reference-examples-common</artifactId>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-reference-examples-kjar</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-xml-support</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.kie</groupId>
<artifactId>kie-ci</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

</project>
Loading

0 comments on commit a54e753

Please sign in to comment.