Merge pull request 'Jenkinsfile with SonarQube Analysis' (#33) from f/jenkinsfile into develop
Some checks failed
zdm/event-bus/pipeline/head There was a failure building this commit

Reviewed-on: https://git.kske.dev/zdm/event-bus/pulls/33
Reviewed-by: delvh <leon@kske.dev>
This commit is contained in:
Kai S. K. Engelbart 2022-01-09 11:32:25 +01:00
commit a8810c497f
Signed by: Käfer & Engelbart Git
GPG Key ID: 70F2F9206EDC1FCE
10 changed files with 93 additions and 25 deletions

41
Jenkinsfile vendored Normal file
View File

@ -0,0 +1,41 @@
pipeline {
agent any
options {
ansiColor('xterm')
}
stages {
stage('Build') {
steps {
sh 'mvn -DskipTests clean package'
}
}
stage('Test') {
steps {
sh 'mvn test'
}
post {
always {
junit '*/target/surefire-reports/*.xml'
publishCoverage adapters: [jacocoAdapter(mergeToOneReport: true, path: '*/target/site/jacoco/jacoco.xml')]
}
}
}
stage('SonarQube Analysis') {
when {
branch 'develop'
}
steps {
withSonarQubeEnv('KSKE SonarQube') {
sh "$SONAR_MAVEN_GOAL"
}
}
}
}
post {
success {
archiveArtifacts artifacts: '*/target/event-bus-*.jar'
}
}
}

View File

@ -1,6 +1,4 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" <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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>event-bus-core</artifactId> <artifactId>event-bus-core</artifactId>
@ -26,14 +24,43 @@
<!-- Disable resource folder --> <!-- Disable resource folder -->
<resources /> <resources />
<!-- Run unit tests -->
<plugins> <plugins>
<!-- Run unit tests -->
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId> <artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version> <version>3.0.0-M5</version>
<configuration>
<argLine>
${argLine}
--add-opens dev.kske.eventbus.core/dev.kske.eventbus.core=ALL-UNNAMED
--add-opens dev.kske.eventbus.core/dev.kske.eventbus.core.handler=ALL-UNNAMED
</argLine>
</configuration>
</plugin> </plugin>
</plugins>
<!-- Generate coverage report -->
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.7</version>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build> </build>
</project> </project>

View File

@ -11,7 +11,7 @@ import org.junit.jupiter.api.*;
* @author Leon Hofmeister * @author Leon Hofmeister
* @since 0.1.0 * @since 0.1.0
*/ */
public class CancelTest { class CancelTest {
EventBus bus; EventBus bus;
int hits; int hits;
@ -22,7 +22,7 @@ public class CancelTest {
* @since 0.1.0 * @since 0.1.0
*/ */
@BeforeEach @BeforeEach
public void registerListener() { void registerListener() {
bus = new EventBus(); bus = new EventBus();
bus.registerListener(this); bus.registerListener(this);
} }
@ -34,7 +34,7 @@ public class CancelTest {
* @since 0.1.0 * @since 0.1.0
*/ */
@Test @Test
public void testCancellation() { void testCancellation() {
bus.dispatch(new SimpleEvent()); bus.dispatch(new SimpleEvent());
assertEquals(1, hits); assertEquals(1, hits);
} }

View File

@ -10,7 +10,7 @@ import org.junit.jupiter.api.Test;
* @author Kai S. K. Engelbart * @author Kai S. K. Engelbart
* @since 1.1.0 * @since 1.1.0
*/ */
public class DeadTest { class DeadTest {
EventBus bus = new EventBus(); EventBus bus = new EventBus();
String event = "This event has no handler"; String event = "This event has no handler";
@ -22,7 +22,7 @@ public class DeadTest {
* @since 1.1.0 * @since 1.1.0
*/ */
@Test @Test
public void testDeadEvent() { void testDeadEvent() {
bus.registerListener(this); bus.registerListener(this);
bus.dispatch(event); bus.dispatch(event);
assertTrue(deadEventHandled); assertTrue(deadEventHandled);
@ -36,7 +36,7 @@ public class DeadTest {
* @since 1.1.0 * @since 1.1.0
*/ */
@Test @Test
public void testUnhandledDeadEvent() { void testUnhandledDeadEvent() {
bus.dispatch(event); bus.dispatch(event);
} }

View File

@ -12,7 +12,7 @@ import org.junit.jupiter.api.*;
*/ */
@Polymorphic @Polymorphic
@Priority(150) @Priority(150)
public class DispatchTest { class DispatchTest {
EventBus bus; EventBus bus;
static int hits; static int hits;
@ -23,7 +23,7 @@ public class DispatchTest {
* @since 0.0.1 * @since 0.0.1
*/ */
@BeforeEach @BeforeEach
public void registerListener() { void registerListener() {
bus = new EventBus(); bus = new EventBus();
bus.registerListener(this); bus.registerListener(this);
bus.registerListener(SimpleEvent.class, e -> { bus.registerListener(SimpleEvent.class, e -> {
@ -39,7 +39,7 @@ public class DispatchTest {
* @since 0.0.1 * @since 0.0.1
*/ */
@Test @Test
public void testDispatch() { void testDispatch() {
bus.dispatch(new SimpleEventSub()); bus.dispatch(new SimpleEventSub());
bus.dispatch(new SimpleEvent()); bus.dispatch(new SimpleEvent());
} }
@ -50,7 +50,7 @@ public class DispatchTest {
* @since 1.2.0 * @since 1.2.0
*/ */
@Test @Test
public void testDebugExecutionOrder() { void testDebugExecutionOrder() {
String executionOrder = bus.debugExecutionOrder(SimpleEvent.class); String executionOrder = bus.debugExecutionOrder(SimpleEvent.class);
System.out.println(executionOrder); System.out.println(executionOrder);
assertEquals( assertEquals(

View File

@ -10,7 +10,7 @@ import org.junit.jupiter.api.Test;
* @author Kai S. K. Engelbart * @author Kai S. K. Engelbart
* @since 1.1.0 * @since 1.1.0
*/ */
public class ExceptionTest { class ExceptionTest {
EventBus bus = new EventBus(); EventBus bus = new EventBus();
String event = "This event will cause an exception"; String event = "This event will cause an exception";
@ -23,7 +23,7 @@ public class ExceptionTest {
* @since 1.1.0 * @since 1.1.0
*/ */
@Test @Test
public void testExceptionEvent() { void testExceptionEvent() {
bus.registerListener(this); bus.registerListener(this);
bus.registerListener(new ExceptionListener()); bus.registerListener(new ExceptionListener());
bus.dispatch(event); bus.dispatch(event);
@ -38,7 +38,7 @@ public class ExceptionTest {
* @since 1.1.0 * @since 1.1.0
*/ */
@Test @Test
public void testUnhandledExceptionEvent() { void testUnhandledExceptionEvent() {
bus.registerListener(this); bus.registerListener(this);
bus.dispatch(event); bus.dispatch(event);
bus.removeListener(this); bus.removeListener(this);

View File

@ -10,7 +10,7 @@ import org.junit.jupiter.api.Test;
* @author Kai S. K. Engelbart * @author Kai S. K. Engelbart
* @since 1.2.1 * @since 1.2.1
*/ */
public class ExceptionWrapperTest { class ExceptionWrapperTest {
EventBus bus = new EventBus(); EventBus bus = new EventBus();
String event = "This event will cause an exception"; String event = "This event will cause an exception";
@ -21,7 +21,7 @@ public class ExceptionWrapperTest {
* @since 1.2.1 * @since 1.2.1
*/ */
@Test @Test
public void testExceptionWrapper() { void testExceptionWrapper() {
bus.registerListener(this); bus.registerListener(this);
assertThrows(ExceptionWrapper.class, () -> bus.dispatch(event)); assertThrows(ExceptionWrapper.class, () -> bus.dispatch(event));
} }

View File

@ -10,7 +10,7 @@ import org.junit.jupiter.api.*;
* @author Kai S. K. Engelbart * @author Kai S. K. Engelbart
* @since 1.2.0 * @since 1.2.0
*/ */
public class NestedTest { class NestedTest {
EventBus bus; EventBus bus;
boolean nestedHit; boolean nestedHit;
@ -21,7 +21,7 @@ public class NestedTest {
* @since 1.2.0 * @since 1.2.0
*/ */
@BeforeEach @BeforeEach
public void registerListener() { void registerListener() {
bus = new EventBus(); bus = new EventBus();
bus.registerListener(this); bus.registerListener(this);
} }
@ -34,7 +34,7 @@ public class NestedTest {
* @since 1.2.0 * @since 1.2.0
*/ */
@Test @Test
public void testNestedDispatch() { void testNestedDispatch() {
bus.dispatch(new SimpleEvent()); bus.dispatch(new SimpleEvent());
assertTrue(nestedHit); assertTrue(nestedHit);
} }

View File

@ -6,4 +6,4 @@ package dev.kske.eventbus.core;
* @author Kai S. K. Engelbart * @author Kai S. K. Engelbart
* @since 0.0.1 * @since 0.0.1
*/ */
public class SimpleEvent {} class SimpleEvent {}

View File

@ -6,4 +6,4 @@ package dev.kske.eventbus.core;
* @author Kai S. K. Engelbart * @author Kai S. K. Engelbart
* @since 0.0.4 * @since 0.0.4
*/ */
public class SimpleEventSub extends SimpleEvent {} class SimpleEventSub extends SimpleEvent {}