wolfssljni/.github/workflows/stable-wolfssl-releases.yml

112 lines
3.8 KiB
YAML

name: Test Against Stable wolfSSL Releases
on:
pull_request:
branches: [ 'master' ]
# Cancel superseded in-progress runs for the same PR.
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
# First job: dynamically fetch the last 5 stable wolfSSL release tags
get-stable-releases:
runs-on: ubuntu-latest
outputs:
versions: ${{ steps.get-versions.outputs.versions }}
steps:
- name: Get last 5 stable wolfSSL releases
id: get-versions
run: |
# Fetch tags from wolfSSL/wolfssl that end with "-stable"
# Sort by version number and take the last 5
VERSIONS=$(curl -s "https://api.github.com/repos/wolfSSL/wolfssl/tags?per_page=100" | \
jq -r '.[].name | select(endswith("-stable"))' | \
sort -V | \
tail -n 5 | \
jq -R -s -c 'split("\n") | map(select(length > 0))')
echo "Found stable versions: $VERSIONS"
echo "versions=$VERSIONS" >> $GITHUB_OUTPUT
# Second job: build and test against each stable release
test-stable-release:
needs: get-stable-releases
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
wolfssl_version: ${{ fromJson(needs.get-stable-releases.outputs.versions) }}
jdk_version: [ '21' ]
wolfssl_configure: [ '--enable-jni', '--enable-jni --enable-all' ]
name: wolfSSL ${{ matrix.wolfssl_version }} (JDK ${{ matrix.jdk_version }}, ${{ matrix.wolfssl_configure }})
steps:
- uses: actions/checkout@v4
- name: Setup JUnit
uses: ./.github/actions/setup-junit
# Cache the installed wolfSSL build. Stable release tags do not
# move, so these entries stay valid indefinitely.
- name: Compute wolfSSL cache key
id: wolfssl-key
env:
WOLFSSL_CONFIGURE: ${{ matrix.wolfssl_configure }}
run: |
CFG_HASH=$(printf '%s' "$WOLFSSL_CONFIGURE" | \
shasum -a 256 | cut -c1-16)
KEY="wolfssl-${{ runner.os }}-${{ runner.arch }}"
KEY="$KEY-${{ matrix.wolfssl_version }}-$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 ${{ matrix.wolfssl_version }}
if: steps.cache-wolfssl.outputs.cache-hit != 'true'
uses: wolfSSL/actions-build-autotools-project@v1
with:
repository: wolfSSL/wolfssl
ref: ${{ matrix.wolfssl_version }}
path: wolfssl
configure: ${{ matrix.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: zulu
java-version: ${{ matrix.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: ./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