Skip to content

Commit

Permalink
Merge pull request #65 from cconlon/github-actions
Browse files Browse the repository at this point in the history
Add initial GitHub actions (Linux, Mac)
  • Loading branch information
JacobBarthelmeh authored Feb 15, 2024
2 parents 8bd4189 + 4dc6579 commit 0ed446d
Show file tree
Hide file tree
Showing 5 changed files with 234 additions and 41 deletions.
104 changes: 104 additions & 0 deletions .github/workflows/linux-common.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
name: Common Linux test logic

on:
workflow_call:
inputs:
os:
required: true
type: string
jdk_distro:
required: true
type: string
jdk_version:
required: true
type: string
wolfssl_configure:
required: true
type: string

jobs:
build_wolfcryptjni:
runs-on: ${{ inputs.os }}
steps:
- uses: actions/checkout@v4

- name: Download junit-4.13.2.jar
run: wget --directory-prefix=$GITHUB_WORKSPACE/junit https://repo1.maven.org/maven2/junit/junit/4.13.2/junit-4.13.2.jar
- name: Download hamcrest-all-1.3.jar
run: wget --directory-prefix=$GITHUB_WORKSPACE/junit https://repo1.maven.org/maven2/org/hamcrest/hamcrest-all/1.3/hamcrest-all-1.3.jar

- name: Build native wolfSSL
uses: wolfSSL/actions-build-autotools-project@v1
with:
repository: wolfSSL/wolfssl
ref: master
path: wolfssl
configure: ${{ inputs.wolfssl_configure }}
check: false
install: true

- name: Setup java
uses: actions/setup-java@v4
with:
distribution: ${{ inputs.jdk_distro }}
java-version: ${{ inputs.jdk_version }}

- name: Set JUNIT_HOME
run: |
echo "JUNIT_HOME=$GITHUB_WORKSPACE/junit" >> "$GITHUB_ENV"
- name: Set LD_LIBRARY_PATH
run: |
echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$GITHUB_WORKSPACE/build-dir/lib" >> "$GITHUB_ENV"
# Only copy appropriate makefile for platform currently being tested
- name: Copy makefile
run: |
if [ "$RUNNER_OS" == "Linux" ]; then
cp makefile.linux makefile
elif [ "$RUNNER_OS" == "macOS" ]; then
cp makefile.macosx makefile
else
echo "$RUNNER_OS not supported"
exit 1
fi
shell: bash

- name: Build JNI library
run: PREFIX=$GITHUB_WORKSPACE/build-dir make

# ant build-jni-debug
- name: Build jce-debug JAR (ant build-jni-debug)
run: ant build-jni-debug
- name: Run Java tests (ant test)
run: ant test
- name: Clean JAR
run: ant clean

# ant build-jni-release
- name: Build jce-debug JAR (ant build-jni-release)
run: ant build-jni-release
- name: Run Java tests (ant test)
run: ant test
- name: Clean JAR
run: ant clean

# ant build-jce-debug
- name: Build jce-debug JAR (ant build-jce-debug)
run: ant build-jce-debug
- name: Run Java tests (ant test)
run: ant test
- name: Clean JAR
run: ant clean

# ant build-jce-release
- name: Build jce-debug JAR (ant build-jce-release)
run: ant build-jce-release
- name: Run Java tests (ant test)
run: ant test
- name: Clean JAR
run: ant clean

- name: Show logs on failure
if: failure() || cancelled()
run: |
cat build/reports/*.txt
103 changes: 96 additions & 7 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,102 @@
name: GitHub Actions Demo

name: CI
on:
push:
branches: [ 'master', 'main', 'testactions', 'release/**' ]
branches: [ 'master', 'main', 'release/**' ]
pull_request:
branches: [ '*' ]

jobs:
testjob:
runs-on: ubuntu-latest
steps:
- run: echo "Hello World"
# Oracle JDK (Linux, Mac)
# Oracle JDK requires JAR to be signed for some classes to load/run
# properly, for example KeyAgreement. These tests are commented out
# here until we get a solution in place for CI JAR signing
#linux-oracle:
# strategy:
# matrix:
# os: [ 'ubuntu-latest', 'macos-latest' ]
# jdk_version: [ '17', '21' ]
# wolfssl_configure: [ '--enable-jni' ]
# name: ${{ matrix.os }} (Oracle JDK ${{ matrix.jdk_version }}, ${{ matrix.wolfssl_configure}})
# uses: ./.github/workflows/linux-common.yml
# with:
# os: ${{ matrix.os }}
# jdk_distro: "oracle"
# jdk_version: ${{ matrix.jdk_version }}
# wolfssl_configure: ${{ matrix.wolfssl_configure }}

# Zulu JDK (Linux, Mac)
linux-zulu:
strategy:
matrix:
os: [ 'ubuntu-latest', 'macos-latest' ]
jdk_version: [ '8', '11', '17', '21' ]
wolfssl_configure: [ '--enable-jni' ]
name: ${{ matrix.os }} (Zulu JDK ${{ matrix.jdk_version }}, ${{ matrix.wolfssl_configure}})
uses: ./.github/workflows/linux-common.yml
with:
os: ${{ matrix.os }}
jdk_distro: "zulu"
jdk_version: ${{ matrix.jdk_version }}
wolfssl_configure: ${{ matrix.wolfssl_configure }}

# Corretto JDK (Linux, Mac)
linux-corretto:
strategy:
matrix:
os: [ 'ubuntu-latest', 'macos-latest' ]
jdk_version: [ '8', '11', '17', '21' ]
wolfssl_configure: [ '--enable-jni' ]
name: ${{ matrix.os }} (Corretto JDK ${{ matrix.jdk_version }}, ${{ matrix.wolfssl_configure}})
uses: ./.github/workflows/linux-common.yml
with:
os: ${{ matrix.os }}
jdk_distro: "corretto"
jdk_version: ${{ matrix.jdk_version }}
wolfssl_configure: ${{ matrix.wolfssl_configure }}

# Temurin JDK (Linux, Mac)
linux-temurin:
strategy:
matrix:
os: [ 'ubuntu-latest', 'macos-latest' ]
jdk_version: [ '8', '11', '17', '21' ]
wolfssl_configure: [ '--enable-jni' ]
name: ${{ matrix.os }} (Temurin JDK ${{ matrix.jdk_version }}, ${{ matrix.wolfssl_configure}})
uses: ./.github/workflows/linux-common.yml
with:
os: ${{ matrix.os }}
jdk_distro: "temurin"
jdk_version: ${{ matrix.jdk_version }}
wolfssl_configure: ${{ matrix.wolfssl_configure }}

# Microsoft JDK (Linux, Mac)
linux-microsoft:
strategy:
matrix:
os: [ 'ubuntu-latest', 'macos-latest' ]
jdk_version: [ '11.0.19', '17.0.7', '21.0.0' ]
wolfssl_configure: [ '--enable-jni' ]
name: ${{ matrix.os }} (Microsoft JDK ${{ matrix.jdk_version }}, ${{ matrix.wolfssl_configure}})
uses: ./.github/workflows/linux-common.yml
with:
os: ${{ matrix.os }}
jdk_distro: "microsoft"
jdk_version: ${{ matrix.jdk_version }}
wolfssl_configure: ${{ matrix.wolfssl_configure }}

# -------------------- enable-all sanity checks -----------------------
# Only check one Linux and Mac JDK version with --enable-jni --enable-all
# as sanity. Using Zulu, but this can be expanded if needed.
linux-zulu-all:
strategy:
matrix:
os: [ 'ubuntu-latest', 'macos-latest' ]
jdk_version: [ '11' ]
wolfssl_configure: [ '--enable-jni --enable-all' ]
name: ${{ matrix.os }} (Zulu JDK ${{ matrix.jdk_version }}, ${{ matrix.wolfssl_configure}})
uses: ./.github/workflows/linux-common.yml
with:
os: ${{ matrix.os }}
jdk_distro: "zulu"
jdk_version: ${{ matrix.jdk_version }}
wolfssl_configure: ${{ matrix.wolfssl_configure }}
4 changes: 2 additions & 2 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
<property name="jce.debug" value="false" />

<!-- compatible defaults -->
<property name="java.source" value="1.7" />
<property name="java.target" value="1.7" />
<property name="java.source" value="1.8" />
<property name="java.target" value="1.8" />

<!-- property file for code signing -->
<property file="codeSigning.properties" />
Expand Down
22 changes: 20 additions & 2 deletions makefile.macosx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,24 @@ OUT_PATH = lib
SRC_PATH = jni
INC_PATH = $(SRC_PATH)/include

ifneq ($(PREFIX),)
INSTALL_DIR = $(DESTDIR)$(PREFIX)
else
INSTALL_DIR = $(DESTDIR)/usr/local
endif

ifeq ($(LIBDIR),)
LIBDIR=lib
endif

ifeq ($(INSTALL),)
INSTALL=install
endif

ifeq ($(WOLFSSL_LIBNAME),)
WOLFSSL_LIBNAME=wolfssl
endif

OBJ_LIST = jni_fips.o jni_native_struct.o jni_aes.o jni_aesgcm.o jni_des3.o \
jni_md5.o jni_sha.o jni_hmac.o jni_rng.o jni_rsa.o jni_dh.o \
jni_ecc.o jni_ed25519.o jni_curve25519.o jni_chacha.o jni_error.o \
Expand All @@ -12,8 +30,8 @@ TARGET = $(OUT_PATH)/libwolfcryptjni.dylib
JAVA_HOME ?= $(shell /usr/libexec/java_home)
CC = gcc
override CCFLAGS += -Wall -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/darwin \
-I$(INC_PATH)
override LDFLAGS += -dynamiclib -lwolfssl
-I$(INC_PATH) -I$(INSTALL_DIR)/include
override LDFLAGS += -dynamiclib -L$(INSTALL_DIR)/$(LIBDIR) -l$(WOLFSSL_LIBNAME)

all: $(TARGET)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1842,11 +1842,8 @@ public void testAesGcmNoPaddingWithUpdate()
for (int j = 0; j < fourByteBlocks; j++) {
tmp = enc.update(Arrays.copyOfRange(vIn, inIdx, inIdx + 4));
assertNotNull(tmp);
if (FeatureDetect.AesGcmStreamEnabled()) {
assertEquals(4, tmp.length);
} else {
assertEquals(0, tmp.length);
}
/* AES-GCM stream API not supported in JCE yet */
assertEquals(0, tmp.length);
System.arraycopy(tmp, 0, output, outIdx, tmp.length);
inIdx += 4;
outIdx += tmp.length;
Expand All @@ -1858,11 +1855,8 @@ public void testAesGcmNoPaddingWithUpdate()
tmp = enc.update(Arrays.copyOfRange(vIn, inIdx,
inIdx + remainingBytes));
assertNotNull(tmp);
if (FeatureDetect.AesGcmStreamEnabled()) {
assertEquals(remainingBytes, tmp.length);
} else {
assertEquals(0, tmp.length);
}
/* AES-GCM stream API not supported in JCE yet */
assertEquals(0, tmp.length);
System.arraycopy(tmp, 0, output, outIdx, tmp.length);
inIdx += remainingBytes;
outIdx += tmp.length;
Expand All @@ -1872,11 +1866,8 @@ public void testAesGcmNoPaddingWithUpdate()
* streaming is not enabled at native wolfSSL level) */
tmp = enc.doFinal();
assertNotNull(tmp);
if (FeatureDetect.AesGcmStreamEnabled()) {
assertEquals(vTag.length, tmp.length);
} else {
assertEquals(tmpOut.length, tmp.length);
}
/* AES-GCM stream API not supported in JCE yet */
assertEquals(tmpOut.length, tmp.length);
System.arraycopy(tmp, 0, output, outIdx, tmp.length);
outIdx += tmp.length;

Expand Down Expand Up @@ -1914,11 +1905,8 @@ public void testAesGcmNoPaddingWithUpdate()
for (int j = 0; j < fourByteBlocks; j++) {
tmp = dec.update(Arrays.copyOfRange(output, inIdx, inIdx + 4));
assertNotNull(tmp);
if (FeatureDetect.AesGcmStreamEnabled()) {
assertEquals(4, tmp.length);
} else {
assertEquals(0, tmp.length);
}
/* AES-GCM stream API not supported in JCE yet */
assertEquals(0, tmp.length);
System.arraycopy(tmp, 0, plain, outIdx, tmp.length);
inIdx += 4;
outIdx += tmp.length;
Expand All @@ -1930,11 +1918,8 @@ public void testAesGcmNoPaddingWithUpdate()
tmp = dec.update(Arrays.copyOfRange(output, inIdx,
inIdx + remainingBytes));
assertNotNull(tmp);
if (FeatureDetect.AesGcmStreamEnabled()) {
assertEquals(remainingBytes, tmp.length);
} else {
assertEquals(0, tmp.length);
}
/* AES-GCM stream API not supported in JCE yet */
assertEquals(0, tmp.length);
System.arraycopy(tmp, 0, plain, outIdx, tmp.length);
inIdx += remainingBytes;
outIdx += tmp.length;
Expand All @@ -1944,11 +1929,8 @@ public void testAesGcmNoPaddingWithUpdate()
* streaming is not enabled at native wolfSSL level */
tmp = dec.doFinal();
assertNotNull(tmp);
if (FeatureDetect.AesGcmStreamEnabled()) {
assertEquals(0, tmp.length);
} else {
assertEquals(vIn.length, tmp.length);
}
/* AES-GCM stream API not supported in JCE yet */
assertEquals(vIn.length, tmp.length);
System.arraycopy(tmp, 0, plain, outIdx, tmp.length);
outIdx += tmp.length;

Expand Down

0 comments on commit 0ed446d

Please sign in to comment.