Skip to content

Commit

Permalink
Switch to GitHub Actions for CI.
Browse files Browse the repository at this point in the history
  • Loading branch information
MrDOS authored and Claudia Pellegrino committed Nov 9, 2023
1 parent b6c9cd3 commit 1b042a0
Show file tree
Hide file tree
Showing 2 changed files with 146 additions and 14 deletions.
146 changes: 146 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
name: Build
on:
- push
- pull_request

jobs:
natives-linux-windows:
name: Linux (x86/ARM/PPC) and Windows native library compilation
runs-on: ubuntu-18.04

defaults:
run:
working-directory: src/main/c

steps:
- name: Checkout the code
uses: actions/checkout@v2
- name: Setup Java
uses: actions/setup-java@v1
with:
java-version: 8
- name: Install build prerequisites
run: |
sudo apt update
sudo make crosstools
- name: Build the Linux and Windows native libraries
run: |
make clean-linux clean-windows
make linux windows
# The names of the artifacts containing native libraries correspond
# exactly to the directories inside `src/main/c/resources/native`. That
# way, the Java build job can pull down all artifacts and unpack them
# into that directory to overwrite the versions in-repo. This is sadly
# necessary because the actions/download-artifact@v2 action flattens
# paths inside artifacts. If it retained full relative paths, we could
# put Linux and Windows natives inside the same artifact, and we could be
# flexible with the artifact names. But it doesn't, so we can't, and we
# can't.
- name: Upload Linux native libraries
uses: actions/upload-artifact@v2
with:
name: linux
path: src/main/c/resources/native/linux
- name: Upload Windows native libraries
uses: actions/upload-artifact@v2
with:
name: windows
path: src/main/c/resources/native/windows

natives-macos:
name: macOS native library compilation
runs-on: macos-10.15

defaults:
run:
working-directory: src/main/c

steps:
- name: Checkout the code
uses: actions/checkout@v2
- name: Setup Java
uses: actions/setup-java@v1
with:
java-version: 8

- name: Build the macOS native libraries
run: |
make clean-osx
make osx
- name: Upload macOS native libraries
uses: actions/upload-artifact@v2
with:
name: osx
path: src/main/c/resources/native/osx/libNRJavaSerial.jnilib

natives-freebsd:
name: FreeBSD native library compilation
runs-on: ubuntu-18.04
container:
image: empterdose/freebsd-cross-build:9.3
env:
JAVA_HOME: /usr/lib/jvm/default-jvm

defaults:
run:
working-directory: src/main/c

steps:
- name: Checkout the code
uses: actions/checkout@v2
- name: Setup Java
# This feels extremely dirty, but the only native header we care about
# is `jni_md.h`, and it is exactly identical between Linux and FreeBSD
# (at least in OpenJDK 8).
run: |
apk add openjdk8
ln -s $JAVA_HOME/include/linux $JAVA_HOME/include/freebsd
- name: Build the FreeBSD native libraries
run: |
make clean-freebsd
settarget i386-freebsd9 make freebsd32
settarget x86_64-freebsd9 make freebsd64
- name: Upload FreeBSD native libraries
uses: actions/upload-artifact@v2
with:
name: freebsd
path: src/main/c/resources/native/freebsd

java:
name: Java compilation
runs-on: ubuntu-18.04

needs:
- natives-linux-windows
- natives-macos
- natives-freebsd

steps:
- name: Checkout the code
uses: actions/checkout@v2
- name: Setup Java
uses: actions/setup-java@v1
with:
java-version: 8

- name: Download native libraries
uses: actions/download-artifact@v2
with:
path: src/main/c/resources/native

- name: Build the Java library
run: ./gradlew build

- name: Determine commit hash for artifact filename
id: vars
run: echo "::set-output name=short-rev::$(git rev-parse --short HEAD)"
- name: Upload build artifacts
uses: actions/upload-artifact@v2
with:
name: nrjavaserial-${{steps.vars.outputs.short-rev}}
path: build/libs/*.jar
14 changes: 0 additions & 14 deletions .travis.yml

This file was deleted.

0 comments on commit 1b042a0

Please sign in to comment.