wolfssljni/.github/workflows/linux-common.yml

98 lines
2.9 KiB
YAML

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
javash_cflags:
required: false
type: string
jobs:
build_wolfssljni:
runs-on: ${{ inputs.os }}
steps:
- uses: actions/checkout@v4
- name: Setup JUnit
uses: ./.github/actions/setup-junit
# Cache the installed wolfSSL build. It depends only on the wolfSSL
# commit, configure flags, and OS/arch, not on the JDK in use, so
# jobs across the matrix (and other 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 }}
- 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 }}
- name: Setup java
uses: actions/setup-java@v4
with:
distribution: ${{ inputs.jdk_distro }}
java-version: ${{ inputs.jdk_version }}
- name: Set LD_LIBRARY_PATH
run: |
echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$GITHUB_WORKSPACE/build-dir/lib" >> "$GITHUB_ENV"
- name: Build JNI library
run: CFLAGS="${{ inputs.javash_cflags }}" ./java.sh $GITHUB_WORKSPACE/build-dir
- name: Build JAR (ant)
run: ant
- name: Run Java tests (ant test)
run: ant test
- name: Show logs on failure
if: failure() || cancelled()
run: |
cat build/reports/*.txt