Skip to content

Commit

Permalink
Github actions pipeline for integration testing
Browse files Browse the repository at this point in the history
  • Loading branch information
pietrygamat committed Aug 15, 2021
1 parent c444e64 commit 82cb982
Show file tree
Hide file tree
Showing 4 changed files with 170 additions and 1 deletion.
79 changes: 79 additions & 0 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: Integration test
on: workflow_dispatch

env:
MAVEN_OPTS: -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn
JAVA_32: https://cdn.azul.com/zulu/bin/zulu11.50.19-ca-jre11.0.12-win_i686.zip
JAVA_64: https://cdn.azul.com/zulu/bin/zulu11.50.19-ca-jre11.0.12-win_x64.zip

jobs:
test-on-wine:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v2
with:
java-version: 11
distribution: temurin

- name: Build main package
run: mvn -B install -Ppackage -DskipTests

- name: Build test project runnable jar
run: mvn -B -f integration-test/library-compatibility/pom.xml compile assembly:single

- name: Install dependencies
run: |
sudo dpkg --add-architecture i386
sudo apt-get -qq update
sudo apt-get -qq install -y socat wine > /dev/null
- name: Get Java 32 for Windows
run: |
wget -qO jre32.zip ${JAVA_32}
unzip -qq jre32.zip -d $HOME/win32
mv $(ls -d $HOME/win32/*/) $HOME/win32/jre
- name: Get Java 64 for Windows
run: |
wget -qO jre64.zip ${JAVA_64}
unzip -qq jre64.zip -d $HOME/win64
mv $(ls -d $HOME/win64/*/) $HOME/win64/jre
- name: Setup wine
run: |
WINEPREFIX=~/win32/.wine WINEARCH=win32 wine wineboot
WINEPREFIX=~/win64/.wine WINEARCH=win64 wine wineboot
- name: Set up serial port pair
run: |
( socat -d -d PTY,link=$HOME/com1,raw,echo=0 PTY,link=$HOME/com2,raw,echo=0) &
sleep 1
export COM1=$( readlink $HOME/com1 )
export COM2=$( readlink $HOME/com2 )
export WINEPREFIX=~/win32/.wine
wine reg add "HKLM\\Software\\Wine\\Ports" /v "COM1" /t REG_SZ /d "${COM1}"
wine reg add "HKLM\\Software\\Wine\\Ports" /v "COM2" /t REG_SZ /d "${COM2}"
ln -fs ${COM1} ${WINEPREFIX}/dosdevices/com1
ln -fs ${COM2} ${WINEPREFIX}/dosdevices/com2
export WINEPREFIX=~/win64/.wine
wine reg add "HKLM\\Software\\Wine\\Ports" /v "COM1" /t REG_SZ /d "${COM1}"
wine reg add "HKLM\\Software\\Wine\\Ports" /v "COM2" /t REG_SZ /d "${COM2}"
ln -fs ${COM1} ${WINEPREFIX}/dosdevices/com1
ln -fs ${COM2} ${WINEPREFIX}/dosdevices/com2
- name: Run test project under wine32
run: |
export WINEPREFIX=~/win32/.wine
wine ~/win32/jre/bin/java.exe -jar $( winepath -w integration-test/library-compatibility/target/runme.jar )
- name: Run test project under wine64
run: |
export WINEPREFIX=~/win64/.wine
wine ~/win64/jre/bin/java.exe -jar $( winepath -w integration-test/library-compatibility/target/runme.jar )
- name: Cleanup
run: pkill socat || true
49 changes: 49 additions & 0 deletions integration-test/library-compatibility/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.IntegrationTest</groupId>
<artifactId>jssc-test</artifactId>
<version>2.9.4-SNAPSHOT</version>

<properties>
<maven.compiler.source>6</maven.compiler.source>
<maven.compiler.target>6</maven.compiler.target>
</properties>

<dependencies>
<dependency>
<groupId>net.jockx</groupId>
<artifactId>test-jssc</artifactId>
<version>2.9.4-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.30</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>com.example.Main</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<finalName>runme</finalName>
<appendAssemblyId>false</appendAssemblyId>
</configuration>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package com.example;

import jssc.*;

import java.util.Arrays;

public class Main {

static SerialPortEventListener listener = new SerialPortEventListener() {
@Override
public void serialEvent(SerialPortEvent serialPortEvent) {
System.err.println("Event type " + serialPortEvent.getEventType());
try {
System.out.println(serialPortEvent.getPort().readString());
} catch (SerialPortException e) {
e.printStackTrace();
}
}
};

public static void main(String... args) throws SerialPortException, InterruptedException {
String[] serialPorts = SerialPortList.getPortNames();
String portAName = serialPorts[0];
String portBName = serialPorts[1];
System.out.println("Serial ports: " + Arrays.asList(SerialPortList.getPortNames()));
final SerialPort portA = new SerialPort(portAName);
final SerialPort portB = new SerialPort(portBName);
portA.openPort();
portB.openPort();

portA.addEventListener(listener);
portB.addEventListener(listener);

portA.writeBytes("Hello, it's A".getBytes());
portB.writeBytes("Hello, it's B".getBytes());

Thread.sleep(1000);
portA.closePort();
portB.closePort();
}
}
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>net.jockx</groupId>
<artifactId>test-jssc</artifactId>
<version>2.9.3-SNAPSHOT</version>
<version>2.9.4-SNAPSHOT</version>

<name>Java Simple Serial Connector</name>
<description>
Expand Down

0 comments on commit 82cb982

Please sign in to comment.