Testing: run Infer over Java sources only, without native build and tests

pull/386/head
Chris Conlon 2026-07-21 14:46:49 -06:00
parent fa0e902f23
commit 92919ca055
2 changed files with 50 additions and 111 deletions

View File

@ -12,9 +12,6 @@ on:
jdk_version:
required: true
type: string
wolfssl_configure:
required: true
type: string
jobs:
build_wolfssljni:
@ -22,30 +19,66 @@ jobs:
steps:
- uses: actions/checkout@v4
# Infer runs javac directly over the Java sources (see
# scripts/infer.sh), so this job does not need native wolfSSL,
# the JNI library, JUnit, or the test suite. Tests for this
# configuration run in the main CI matrix (linux-zulu-all).
# Cache the extracted Infer release (~100MB download per run).
- name: Restore cached Infer
id: cache-infer
uses: actions/cache/restore@v4
with:
path: infer-*-v1.2.0
key: infer-v1.2.0-${{ runner.os }}-${{ runner.arch }}
# Download Facebook Infer (Linux)
- name: Download Infer (Linux)
if: runner.os == 'Linux'
if: >-
steps.cache-infer.outputs.cache-hit != 'true' &&
runner.os == 'Linux'
run: wget https://github.com/facebook/infer/releases/download/v1.2.0/infer-linux-x86_64-v1.2.0.tar.xz
- name: Extract Infer (Linux)
if: runner.os == 'Linux'
if: >-
steps.cache-infer.outputs.cache-hit != 'true' &&
runner.os == 'Linux'
run: tar -xvf infer-linux-x86_64-v1.2.0.tar.xz
- name: Symlink Infer (Linux)
if: runner.os == 'Linux'
run: ln -s "$GITHUB_WORKSPACE/infer-linux-x86_64-v1.2.0/bin/infer" /usr/local/bin/infer
# Download Facebook Infer (macOS)
- name: Download Infer (macOS x86_64)
if: runner.os == 'macOS' && runner.arch == 'X64'
if: >-
steps.cache-infer.outputs.cache-hit != 'true' &&
runner.os == 'macOS' && runner.arch == 'X64'
run: wget https://github.com/facebook/infer/releases/download/v1.2.0/infer-osx-x86_64-v1.2.0.tar.xz
- name: Download Infer (macOS ARM64)
if: runner.os == 'macOS' && runner.arch == 'ARM64'
if: >-
steps.cache-infer.outputs.cache-hit != 'true' &&
runner.os == 'macOS' && runner.arch == 'ARM64'
run: wget https://github.com/facebook/infer/releases/download/v1.2.0/infer-osx-arm64-v1.2.0.tar.xz
- name: Extract Infer (macOS x86_64)
if: runner.os == 'macOS' && runner.arch == 'X64'
if: >-
steps.cache-infer.outputs.cache-hit != 'true' &&
runner.os == 'macOS' && runner.arch == 'X64'
run: tar -xvf infer-osx-x86_64-v1.2.0.tar.xz
- name: Extract Infer (macOS ARM64)
if: runner.os == 'macOS' && runner.arch == 'ARM64'
if: >-
steps.cache-infer.outputs.cache-hit != 'true' &&
runner.os == 'macOS' && runner.arch == 'ARM64'
run: tar -xvf infer-osx-arm64-v1.2.0.tar.xz
# Save right after extracting so a failed Infer run (issues
# found) does not prevent the cache from being populated.
- name: Save Infer to cache
if: steps.cache-infer.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: infer-*-v1.2.0
key: infer-v1.2.0-${{ runner.os }}-${{ runner.arch }}
# Symlink Infer into PATH
- name: Symlink Infer (Linux)
if: runner.os == 'Linux'
run: ln -s "$GITHUB_WORKSPACE/infer-linux-x86_64-v1.2.0/bin/infer" /usr/local/bin/infer
- name: Symlink Infer (macOS x86_64)
if: runner.os == 'macOS' && runner.arch == 'X64'
run: ln -s "$GITHUB_WORKSPACE/infer-osx-x86_64-v1.2.0/bin/infer" /usr/local/bin/infer
@ -56,68 +89,6 @@ jobs:
- name: Test Infer get version
run: infer --version
# Cache and Download Junit JARs
- name: Cache JUnit dependencies
uses: actions/cache@v4
id: cache-junit
with:
path: junit
key: junit-jars-v1
- name: Download junit-4.13.2.jar
if: steps.cache-junit.outputs.cache-hit != 'true'
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
if: steps.cache-junit.outputs.cache-hit != 'true'
run: wget --directory-prefix=$GITHUB_WORKSPACE/junit https://repo1.maven.org/maven2/org/hamcrest/hamcrest-all/1.3/hamcrest-all-1.3.jar
# Cache the installed wolfSSL build. It depends only on the wolfSSL
# commit, configure flags, and OS/arch, so jobs across workflows
# can share one build.
- name: Resolve wolfSSL cache key
id: wolfssl-key
env:
WOLFSSL_CONFIGURE: ${{ inputs.wolfssl_configure }}
run: |
SHA=$(git ls-remote https://github.com/wolfSSL/wolfssl.git \
refs/heads/master | cut -f1)
if [ -z "$SHA" ]; then
echo "Failed to resolve wolfSSL master SHA" >&2
exit 1
fi
CFG_HASH=$(printf '%s' "$WOLFSSL_CONFIGURE" | \
shasum -a 256 | cut -c1-16)
KEY="wolfssl-${{ runner.os }}-${{ runner.arch }}-$SHA-$CFG_HASH"
echo "key=$KEY" >> "$GITHUB_OUTPUT"
- name: Restore cached wolfSSL install
id: cache-wolfssl
uses: actions/cache/restore@v4
with:
path: build-dir
key: ${{ steps.wolfssl-key.outputs.key }}
# Build native wolfSSL
- name: Build native wolfSSL
if: steps.cache-wolfssl.outputs.cache-hit != 'true'
uses: wolfSSL/actions-build-autotools-project@v1
with:
repository: wolfSSL/wolfssl
ref: master
path: wolfssl
configure: ${{ inputs.wolfssl_configure }}
check: false
install: true
# Save right after building (not at job end) so a later test
# failure does not prevent the cache from being populated.
- name: Save wolfSSL install to cache
if: steps.cache-wolfssl.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: build-dir
key: ${{ steps.wolfssl-key.outputs.key }}
# Setup Java
- name: Setup java
uses: actions/setup-java@v4
@ -125,37 +96,6 @@ jobs:
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 (Linux)
if: runner.os == 'Linux'
run: |
echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$GITHUB_WORKSPACE/build-dir/lib" >> "$GITHUB_ENV"
- name: Set DYLD_LIBRARY_PATH (macOS)
if: runner.os == 'macOS'
run: |
echo "DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:$GITHUB_WORKSPACE/build-dir/lib" >> "$GITHUB_ENV"
# Build wolfssljni JNI library (libwolfssljni.so)
- name: Build JNI library
run: ./java.sh $GITHUB_WORKSPACE/build-dir
# Build wolfssljni JAR (wolfssljni.jar)
- name: Build JAR (ant)
run: ant
# Run ant tests
- name: Run Java tests (ant test)
run: ant test
- name: Show logs on failure
if: failure() || cancelled()
run: |
cat build/reports/*.txt
# Run Facebook Infer
- name: Run Facebook Infer
run: ./scripts/infer.sh
@ -163,4 +103,3 @@ jobs:
- name: Shows Infer report on failure
if: failure()
run: cat infer-out/report.txt

View File

@ -210,21 +210,21 @@ jobs:
javash_cflags: ${{ matrix.javash_cflags }}
# ------------------ Facebook Infer static analysis -------------------
# Run Facebook infer over PR code on both Linux and macOS to catch
# platform-specific issues.
# Run Facebook Infer over the Java sources on both Linux and macOS.
# Infer only compiles the .java files with javac, so no native
# wolfSSL build or test run is needed here. Tests for the equivalent
# configuration run in linux-zulu-all above.
fb-infer:
strategy:
matrix:
os: [ 'ubuntu-latest', 'macos-latest' ]
jdk_version: [ '11' ]
wolfssl_configure: [ '--enable-jni --enable-all' ]
name: Facebook Infer (${{ matrix.os }} Zulu JDK ${{ matrix.jdk_version }}, ${{ matrix.wolfssl_configure }})
name: Facebook Infer (${{ matrix.os }} Zulu JDK ${{ matrix.jdk_version }})
uses: ./.github/workflows/infer.yml
with:
os: ${{ matrix.os }}
jdk_distro: "zulu"
jdk_version: ${{ matrix.jdk_version }}
wolfssl_configure: ${{ matrix.wolfssl_configure }}
# --------------------- Maven build - test pom.xml --------------------
# Run Maven build over PR code, running on Linux and Mac with only one