Skip to content
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

Use github actions for testing PRs #151

Merged
merged 2 commits into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 90 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: build

on: [push, pull_request]

env:
MAVEN_OPTS: -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn

jobs:
ubuntu:
runs-on: [ubuntu-latest]
strategy:
fail-fast: false
matrix:
include:
- profile: x86
packages: g++-multilib

- profile: x86_64
packages: g++-

- profile: armhf
packages: g++-arm-linux-gnueabihf

- profile: aarch64
packages: g++-aarch64-linux-gnu

- profile: riscv64
packages: g++-riscv64-linux-gnu

- profile: ppc64
packages: g++-powerpc64le-linux-gnu

- profile: mingw32
packages: g++-mingw-w64-i686

- profile: mingw64
packages: g++-mingw-w64-x86-64

- profile: mingwaarch64
packages: clang
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup Java
uses: actions/setup-java@v3
with:
java-version: 11
distribution: temurin

- run: sudo apt-get install socat ${{ matrix.packages }}
- run: mvn -P "${{ matrix.profile }}" --batch-mode

macos:
runs-on: [macos-latest]
strategy:
fail-fast: false
matrix:
include:
- profile: aarch64
- profile: x86_64

steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
java-version: 11
distribution: temurin

- run: brew install socat
- run: mvn -P "${{ matrix.profile }}" --batch-mode

windows:
runs-on: [windows-latest]
strategy:
fail-fast: false
matrix:
include:
- profile: aarch64

- profile: x86_64

steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
java-version: 11
distribution: temurin

- run: mvn -P "${{ matrix.profile }}" --batch-mode
88 changes: 0 additions & 88 deletions .travis.yml

This file was deleted.

5 changes: 4 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,12 @@ if(CMAKE_STRIP AND NOT CMAKE_BUILD_TYPE MATCHES "Deb")
add_custom_command(TARGET jssc POST_BUILD COMMAND "${CMAKE_STRIP}" ${STRIP_ARGS} $<TARGET_FILE:jssc>)
endif()

# Copy native library back to source tree

add_custom_command(TARGET jssc POST_BUILD
# Copy native library back to source tree
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_BINARY_DIR}/natives/ ${CMAKE_CURRENT_SOURCE_DIR}/src/main/resources-precompiled/natives/
# Copy native library back to target/classes tree
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_BINARY_DIR}/natives/ ${CMAKE_CURRENT_BINARY_DIR}/../classes/natives/
)

# Handle compiler warnings
Expand Down
27 changes: 27 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@
<artifactId>maven-surefire-plugin</artifactId>
<version>${plugin.surfire.version}</version>
<configuration>
<!-- Separate JVMs between classes; Needed for "jssc.boot.library.path" test to be effective -->
<reuseForks>false</reuseForks>
<excludes>
<!--suppress UnresolvedMavenProperty -->
Expand Down Expand Up @@ -495,6 +496,32 @@
</properties>
</profile>

<!-- Cross compile for riscv32 -->
<profile>
<id>riscv64</id>
<properties>
<os.target.toolchain>Riscv64</os.target.toolchain>

<os.target.name>linux</os.target.name>
<os.target.arch>riscv64</os.target.arch>
<os.target.bitness>64</os.target.bitness>
</properties>
</profile>

<!-- Cross compile for riscv32 -->
<profile>
<id>riscv32</id>
<properties>
<os.target.toolchain>Riscv32</os.target.toolchain>

<os.target.name>linux</os.target.name>
<os.target.arch>riscv32</os.target.arch>
<os.target.bitness>32</os.target.bitness>
</properties>
</profile>



<!-- Cross compile for x86_64 -->
<profile>
<id>x86_64</id>
Expand Down
3 changes: 3 additions & 0 deletions src/test/java/jssc/SerialNativeInterfaceTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package jssc;

import org.junit.Assume;
import org.junit.Test;

import static org.hamcrest.CoreMatchers.is;
Expand Down Expand Up @@ -41,6 +42,8 @@ public void testPrintVersion() {

@Test(expected = java.io.IOException.class)
public void reportsWriteErrorsAsIOException() throws Exception {
Assume.assumeFalse(SerialNativeInterface.getOsType() == SerialNativeInterface.OS_WINDOWS);

long fd = -1; /*bad file by intent*/
byte[] buf = new byte[]{ 0x6A, 0x73, 0x73, 0x63, 0x0A };
SerialNativeInterface testTarget = new SerialNativeInterface();
Expand Down
10 changes: 10 additions & 0 deletions toolchain/Riscv32.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
set(CMAKE_SYSTEM_NAME Linux)
set(TOOLCHAIN_PREFIX riscv32-linux-gnu)
set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc)
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++)
set(CMAKE_STRIP ${TOOLCHAIN_PREFIX}-strip CACHE FILEPATH "" FORCE)
set(CMAKE_FIND_ROOT_PATH /usr/${TOOLCHAIN_PREFIX}/)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH)

10 changes: 10 additions & 0 deletions toolchain/Riscv64.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
set(CMAKE_SYSTEM_NAME Linux)
set(TOOLCHAIN_PREFIX riscv64-linux-gnu)
set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc)
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++)
set(CMAKE_STRIP ${TOOLCHAIN_PREFIX}-strip CACHE FILEPATH "" FORCE)
set(CMAKE_FIND_ROOT_PATH /usr/${TOOLCHAIN_PREFIX}/)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH)