Skip to content

Add CI that builds and runs every example #2

Add CI that builds and runs every example

Add CI that builds and runs every example #2

Workflow file for this run

name: Android
on:
push:
paths:
- 'android/**'
- '.github/workflows/android.yml'
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
schedule:
- cron: '45 6 * * *'
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
resolve:
uses: ./.github/workflows/_resolve-wolfssl.yml
with:
stable_count: 1
android:
needs: resolve
name: android (${{ matrix.example }}) wolfSSL ${{ matrix.wolfssl_ref }}
runs-on: ubuntu-24.04
timeout-minutes: 40
strategy:
fail-fast: false
matrix:
wolfssl_ref: ${{ fromJson(needs.resolve.outputs.refs_json) }}
example:
- android/wolfcryptjni-ndk-gradle
- android/wolfssljni-ndk-gradle
- android/wolfssljni-ndk-sample
steps:
- uses: actions/checkout@v5
with:
submodules: recursive
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: '17'
# The projects pin wolfssl as a submodule; android/README.md documents
# `git submodule update --remote` for tracking upstream instead. Point it
# at the ref under test so this catches wolfSSL drift like every other job.
- name: Check out the wolfSSL ref under test
run: |
set -euo pipefail
cd '${{ matrix.example }}'
if [ -d wolfssl/.git ]; then
cd wolfssl
git fetch -q --depth 1 origin '${{ matrix.wolfssl_ref }}'
git checkout -q FETCH_HEAD
echo "wolfssl now at ${{ matrix.wolfssl_ref }}: $(git rev-parse --short HEAD)"
fi
# android/README.md step 3: wolfSSL release tarballs ship wolfssl/options.h
# but a GitHub clone does not, and the jni sources include it.
- name: Create the stub options.h the README documents
run: |
set -euo pipefail
cd '${{ matrix.example }}'
if [ -f wolfssl/wolfssl/options.h.in ] && [ ! -f wolfssl/wolfssl/options.h ]; then
cp wolfssl/wolfssl/options.h.in wolfssl/wolfssl/options.h
echo "created wolfssl/wolfssl/options.h"
fi
# These are Studio projects with no instrumentation harness, so a build is
# the honest ceiling.
- name: Build ${{ matrix.example }}
run: |
set -euo pipefail
cd '${{ matrix.example }}'
if [ -f gradlew ]; then
chmod +x gradlew
./gradlew assembleDebug --no-daemon
else
# the older standalone-toolchain sample: Android.mk + ndk-build
"${ANDROID_NDK_HOME:-$ANDROID_NDK_ROOT}/ndk-build"
fi
- name: Assert an apk or .so came out
run: |
set -euo pipefail
cd '${{ matrix.example }}'
find . \( -name '*.apk' -o -name '*.so' \) | head -n3 | grep -q . \
|| { echo "FAIL: no apk/.so produced"; exit 1; }
find . \( -name '*.apk' -o -name '*.so' \) | head -n3