@@ -2,9 +2,10 @@ name: cross-library (reusable)
22
33# Reusable engine for compile-testing a downstream wolfSSL product against the
44# wolfSSL in this checkout. It builds wolfSSL once from this checkout (the PR
5- # merge commit) with the flags a product needs, then compiles the product
6- # against that install at both the product's default-branch HEAD and its highest
7- # release tag (compile-only, no `make check`).
5+ # merge commit), then builds the product against that install at both the
6+ # product's default-branch HEAD and its highest release tag. A caller can also
7+ # select an inline Makefile build/test sequence for a project whose native CI
8+ # uses one.
89#
910# The wolfSSL build runs once and is shared: the build-wolfssl job installs
1011# wolfSSL and uploads it as an artifact, and the compile matrix (head, latest)
3233 default : ' '
3334 type : string
3435 script :
35- description : ' Build script name under .github/workflows/cross-library/scripts/'
36- required : true
36+ description : ' Build script name under .github/workflows/cross-library/scripts/; defaults to <product>.sh in script mode'
37+ required : false
38+ default : ' '
39+ type : string
40+ build_mode :
41+ description : ' Build implementation: script (default) or makefile (inline in this workflow)'
42+ required : false
43+ default : ' script'
3744 type : string
3845 apt_packages :
3946 description : ' Extra apt packages needed to build the product'
@@ -240,31 +247,91 @@ jobs:
240247 echo "Resolved ${{ matrix.ref_mode }} ref for $REPO: $ref"
241248 echo "ref=$ref" >> "$GITHUB_OUTPUT"
242249
243- # Compile-only (never `make check`). A compile failure is allowed ONLY if
244- # a wolfSSL commit since the last release tag declared it with a
245- # `breaks-<product>=<ref>` token (see check-break.sh); otherwise the job
246- # fails, forcing intentional breaks to be recorded in a commit.
250+ # Build the product. Script-mode products use their existing adapters;
251+ # Makefile-mode products run the same commands as their native CI here so
252+ # their integration is reviewable without a second product-specific file.
253+ # A build failure is allowed ONLY if a wolfSSL commit since the last release
254+ # tag declared it with a breaks-<product>=<ref> token (see check-break.sh);
255+ # otherwise the job fails, forcing intentional breaks to be recorded in a
256+ # commit. The output gates the optional maintained-HEAD smoke test.
247257 # PRODUCT_CONFIGURE is intentionally unquoted so multiple flags split.
248258 - name : Compile ${{ inputs.product }} against wolfSSL
259+ id : product_build
249260 env :
261+ BUILD_MODE : ${{ inputs.build_mode }}
250262 REPO : ${{ inputs.repo }}
251263 PRODUCT_CONFIGURE : ${{ inputs.product_configure }}
252264 PRODUCT : ${{ inputs.product }}
265+ PRODUCT_SCRIPT : ${{ inputs.script }}
253266 REF : ${{ steps.ref.outputs.ref }}
254267 MODE : ${{ matrix.ref_mode }}
255268 run : |
256269 S=.github/workflows/cross-library/scripts
257270 set +e
258- # shellcheck disable=SC2086 # $PRODUCT_CONFIGURE must word-split into flags
259- "$S/${{ inputs.script }}" -t "$REF" \
260- "$GITHUB_WORKSPACE/wolfssl-install" "$REPO" $PRODUCT_CONFIGURE
271+ (
272+ set -euo pipefail
273+ case "$BUILD_MODE:$PRODUCT" in
274+ script:*)
275+ # Keep the allowed adapter list explicit: workflow_call inputs
276+ # must not select an arbitrary executable from the checkout.
277+ product_script="${PRODUCT_SCRIPT:-${PRODUCT}.sh}"
278+ case "$product_script" in
279+ wolfclu.sh|wolfmqtt.sh|wolfpkcs11.sh|wolfprovider.sh|wolfssh.sh|wolftpm.sh)
280+ ;;
281+ *)
282+ echo "::error::unsupported cross-library product script: $product_script"
283+ exit 2
284+ ;;
285+ esac
286+ # shellcheck disable=SC2086 # $PRODUCT_CONFIGURE must word-split into flags
287+ "$S/$product_script" -t "$REF" \
288+ "$GITHUB_WORKSPACE/wolfssl-install" "$REPO" $PRODUCT_CONFIGURE
289+ ;;
290+ makefile:wolfcose)
291+ case "$REPO" in
292+ *://*|git@*) product_url="$REPO" ;;
293+ *) product_url="https://github.com/${REPO}.git" ;;
294+ esac
295+ git clone --depth 1 --branch "$REF" "$product_url" wolfCOSE
296+ cd wolfCOSE
297+ # Match wolfCOSE's hosted Makefile build, explicitly using the
298+ # staged wolfSSL instead of a host /usr/local installation.
299+ cflags="-std=c99 -DHAVE_ANONYMOUS_INLINE_AGGREGATES=1 -Os"
300+ cflags+=" -Wall -Wextra -Wpedantic -Wshadow -Wconversion"
301+ cflags+=" -Wvla -Werror=vla -ffunction-sections -fdata-sections -fstack-usage"
302+ cflags+=" -I./include -isystem $GITHUB_WORKSPACE/wolfssl-install/include"
303+ ldflags="-L$GITHUB_WORKSPACE/wolfssl-install/lib -Wl,-rpath,$GITHUB_WORKSPACE/wolfssl-install/lib -lwolfssl"
304+ make "-j$(nproc)" CFLAGS="$cflags" LDFLAGS="$ldflags"
305+ ;;
306+ makefile:wolfip)
307+ case "$REPO" in
308+ *://*|git@*) product_url="$REPO" ;;
309+ *) product_url="https://github.com/${REPO}.git" ;;
310+ esac
311+ git clone --depth 1 --branch "$REF" "$product_url" wolfip
312+ cd wolfip
313+ # wolfIP v1.0 predates generic WOLFSSL_PREFIX support on Linux,
314+ # so point its header probe and link step at the staged install.
315+ export WOLFSSL_PREFIX="$GITHUB_WORKSPACE/wolfssl-install"
316+ export PKG_CONFIG_PATH="$WOLFSSL_PREFIX/lib/pkgconfig${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH}"
317+ export EXTRA_CFLAGS="${EXTRA_CFLAGS:+$EXTRA_CFLAGS }-I$WOLFSSL_PREFIX/include"
318+ export LDFLAGS="${LDFLAGS:+$LDFLAGS }-L$WOLFSSL_PREFIX/lib -Wl,-rpath,$WOLFSSL_PREFIX/lib"
319+ make "-j$(nproc)" build/test-wolfssl
320+ ;;
321+ *)
322+ echo "::error::unsupported cross-library build mode/product: $BUILD_MODE/$PRODUCT"
323+ exit 2
324+ ;;
325+ esac
326+ )
261327 rc=$?
262328 set -e
263329
264330 # The breaks-<product>= mechanism applies ONLY to the latest release
265331 # tag. A head/master break is never waivable, never consults the
266332 # ledger, and must be fixed.
267333 if [ "$rc" -eq 0 ]; then
334+ echo "compiled=true" >> "$GITHUB_OUTPUT"
268335 if [ "$MODE" = "latest" ] && "$S/check-break.sh" "$PRODUCT" "$REF" >/tmp/brk 2>/dev/null; then
269336 echo "::warning::$PRODUCT ($REF) compiled OK but a break is still declared, remove the stale breaks-$PRODUCT=$REF token:"
270337 cat /tmp/brk
@@ -277,6 +344,7 @@ jobs:
277344 if [ "$MODE" = "latest" ]; then
278345 # Released, immutable tag: allowed only if the exact tag is declared.
279346 if "$S/check-break.sh" "$PRODUCT" "$REF"; then
347+ echo "compiled=false" >> "$GITHUB_OUTPUT"
280348 echo "::warning::$PRODUCT $REF failed to compile, but this break is DECLARED (see above). Treating as a known/tracked break."
281349 exit 0
282350 fi
@@ -295,3 +363,42 @@ jobs:
295363 echo " * putting up a matching fix on $PRODUCT's $REF branch, then re-running this job."
296364 fi
297365 exit 1
366+
367+ # The Makefile-mode smoke suite covers the maintained default-branch HEAD,
368+ # after a real successful build. Older releases retain compile-only
369+ # coverage because their own runtime suites may not support the current
370+ # wolfSSL baseline.
371+ - name : Run ${{ inputs.product }} smoke tests
372+ if : ${{ inputs.build_mode == 'makefile' && matrix.ref_mode == 'head' && steps.product_build.outputs.compiled == 'true' }}
373+ env :
374+ PRODUCT : ${{ inputs.product }}
375+ WOLFSSL_INSTALL : ${{ github.workspace }}/wolfssl-install
376+ run : |
377+ set -euxo pipefail
378+ case "$PRODUCT" in
379+ wolfcose)
380+ cd "$GITHUB_WORKSPACE/wolfCOSE"
381+ export LD_LIBRARY_PATH="$WOLFSSL_INSTALL/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
382+ cflags="-std=c99 -DHAVE_ANONYMOUS_INLINE_AGGREGATES=1 -Os"
383+ cflags+=" -Wall -Wextra -Wpedantic -Wshadow -Wconversion"
384+ cflags+=" -Wvla -Werror=vla -ffunction-sections -fdata-sections -fstack-usage"
385+ cflags+=" -I./include -isystem $WOLFSSL_INSTALL/include"
386+ ldflags="-L$WOLFSSL_INSTALL/lib -Wl,-rpath,$WOLFSSL_INSTALL/lib -lwolfssl"
387+ make test CFLAGS="$cflags" LDFLAGS="$ldflags"
388+ make tool-test CFLAGS="$cflags" LDFLAGS="$ldflags"
389+ ;;
390+ wolfip)
391+ cd "$GITHUB_WORKSPACE/wolfip"
392+ export WOLFSSL_PREFIX="$WOLFSSL_INSTALL"
393+ export PKG_CONFIG_PATH="$WOLFSSL_PREFIX/lib/pkgconfig${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH}"
394+ export EXTRA_CFLAGS="${EXTRA_CFLAGS:+$EXTRA_CFLAGS }-I$WOLFSSL_PREFIX/include"
395+ export LDFLAGS="${LDFLAGS:+$LDFLAGS }-L$WOLFSSL_PREFIX/lib -Wl,-rpath,$WOLFSSL_PREFIX/lib"
396+ export LD_LIBRARY_PATH="$WOLFSSL_PREFIX/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
397+ make "-j$(nproc)" unit-esp
398+ ./build/test/unit-esp
399+ ;;
400+ *)
401+ echo "::error::unsupported cross-library smoke test"
402+ exit 1
403+ ;;
404+ esac
0 commit comments