Repository navigation
391 lines (366 loc) · 18.8 KB
/
Copy pathcross-library.yml
File metadata and controls
391 lines (366 loc) · 18.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
name: cross-library (reusable)
# Reusable engine for compile-testing a downstream wolfSSL product against the
# wolfSSL in this checkout. It builds wolfSSL once from this checkout (the PR
# merge commit), then builds the product against that install at both the
# product's default-branch HEAD and its highest release tag. A caller can also
# select an inline Makefile build/test sequence for a project whose native CI
# uses one.
#
# The wolfSSL build runs once and is shared: the build-wolfssl job installs
# wolfSSL and uploads it as an artifact, and the compile matrix (head, latest)
# downloads that artifact instead of rebuilding. This halves the wolfSSL builds
# per product from two to one.
on:
workflow_call:
inputs:
product:
description: 'Short product label (used for the job name)'
required: true
type: string
repo:
description: 'Product source: "owner/repo" shorthand or a full git URL'
required: true
type: string
wolfssl_configure:
description: 'Configure flags for the local wolfSSL build'
required: true
type: string
product_configure:
description: "The product's own ./configure flags"
required: false
default: ''
type: string
script:
description: 'Build script name under .github/workflows/cross-library/scripts/; defaults to <product>.sh in script mode'
required: false
default: ''
type: string
build_mode:
description: 'Build implementation: script (default) or makefile (inline in this workflow)'
required: false
default: 'script'
type: string
jobs:
# Build wolfSSL once and publish the install dir. Both compile legs (head,
# latest) consume it, so this runs a single time per product instead of once
# per leg.
build-wolfssl:
name: Build wolfSSL (${{ inputs.product }})
if: ${{ (github.repository_owner == 'wolfssl') && (github.event_name != 'pull_request' || github.event.pull_request.draft == false) }}
runs-on: ubuntu-24.04
timeout-minutes: 20
steps:
- name: Checkout wolfSSL
uses: actions/checkout@v5
with:
fetch-depth: 1
fetch-tags: false
- name: Install build tools
uses: ./.github/actions/install-apt-deps
with:
packages: build-essential autoconf automake libtool
ghcr-debs-tag: ubuntu-24.04-minimal
# Build wolfSSL and install to a local dir. The configure flags go through
# an env var (not inline ${{ }}) so a quoted CFLAGS/C_EXTRA_FLAGS group
# survives GitHub's expansion intact; the string is trusted caller input
# that build-wolfssl.sh eval's.
- name: Build and install wolfSSL
env:
WOLFSSL_CONFIGURE: ${{ inputs.wolfssl_configure }}
run: |
.github/workflows/cross-library/scripts/build-wolfssl.sh \
"$GITHUB_WORKSPACE" \
"$GITHUB_WORKSPACE/wolfssl-install" \
"$WOLFSSL_CONFIGURE"
# Pack as a tar so libtool symlinks, exec bits, and the absolute-path
# .la/.pc files survive the artifact round-trip. The compile job unpacks to
# the same $GITHUB_WORKSPACE path, so those baked-in paths stay valid.
- name: Pack the wolfSSL install
run: tar -C "$GITHUB_WORKSPACE" -czf wolfssl-install.tar.gz wolfssl-install
- name: Upload the wolfSSL install
uses: actions/upload-artifact@v4
with:
name: wolfssl-install-${{ inputs.product }}
path: wolfssl-install.tar.gz
retention-days: 1
# Compile the product against the shared wolfSSL, once per ref_mode:
# head -> HEAD of the product's default branch (master/main, auto-detected)
# latest -> the product's highest version tag (polled at run time)
compile:
name: Compile ${{ inputs.product }} (${{ matrix.ref_mode }})
needs: build-wolfssl
runs-on: ubuntu-24.04
timeout-minutes: 25
strategy:
fail-fast: false
matrix:
ref_mode: [ head, latest ]
steps:
- name: Checkout wolfSSL
uses: actions/checkout@v5
with:
fetch-depth: 1
fetch-tags: false
- name: Install build tools
if: inputs.product != 'wolfip' && inputs.product != 'wolfprovider'
uses: ./.github/actions/install-apt-deps
with:
packages: build-essential autoconf automake libtool
ghcr-debs-tag: ubuntu-24.04-minimal
# wolfIP uses Check for the unit suite and xxd for the test certificates.
- name: Install wolfIP build and test tools
if: inputs.product == 'wolfip'
uses: ./.github/actions/install-apt-deps
with:
packages: build-essential autoconf automake libtool check xxd
ghcr-debs-tag: ubuntu-24.04-full
- name: Install wolfProvider build tools and OpenSSL headers
if: inputs.product == 'wolfprovider'
uses: ./.github/actions/install-apt-deps
with:
packages: build-essential autoconf automake libtool libssl-dev
ghcr-debs-tag: ubuntu-24.04-full
# The `latest` leg is the only one that reads wolfSSL history: it needs the
# commit messages check-break.sh scans (the last two release cycles) plus
# the two newest release tags, and no file contents, so --filter=tree:0
# fetches commits+tags only and turns a 912 MiB full clone into ~1 MiB on
# top of the source. The exclude boundary is the THIRD-newest release, not
# the scan base, because --shallow-exclude severs the ref it names and
# severing the scan base would drop it from `git tag --merged HEAD` and
# silently halve the window. Tags come in by explicit refspec (never
# --tags, which re-pulls every tag's history), and note a server without
# uploadpack.allowFilter silently ignores the filter and clones in full.
- name: Deepen wolfSSL history for the break check
if: ${{ matrix.ref_mode == 'latest' }}
shell: bash
run: |
set -euo pipefail
# Release-tag selection MUST agree with check-break.sh's
# `--list 'v*-stable' --sort=-v:refname`. `sort -Vr` matches git's
# -v:refname on this tag set (verified incl. double-digit minors,
# e.g. v5.9.10 > v5.9.2). The assertion below catches any drift.
mapfile -t T < <(git ls-remote --tags --refs origin 'v*-stable' \
| sed 's#.*refs/tags/##' | sort -Vr)
echo "Newest release tags: ${T[*]:0:3}"
if [ "${#T[@]}" -lt 3 ]; then
echo "Fewer than three release tags; falling back to full history."
git fetch --unshallow --filter=tree:0 --tags origin
else
# Fetch by ref (not raw SHA) so this does not depend on the server
# allowing reachable-SHA1-in-want.
git fetch --no-tags --filter=tree:0 --shallow-exclude="${T[2]}" origin \
"$GITHUB_REF" \
"refs/tags/${T[0]}:refs/tags/${T[0]}" \
"refs/tags/${T[1]}:refs/tags/${T[1]}"
fi
# Fail LOUD if this step and check-break.sh disagree on the scan base.
# check-break.sh:61 falls back to the NEWEST tag when the second line
# is missing, which would quietly halve the window rather than error.
rel="$(git tag --merged HEAD --sort=-v:refname --list 'v*-stable')"
base="$(printf '%s\n' "$rel" | sed -n '2p')"
echo "Deepened to $(git rev-list --count HEAD) commits; scan base='${base}'"
# The fetch above deepens whatever "$GITHUB_REF" resolves to NOW, but
# actions/checkout pinned a SHA when the job started. GitHub can
# regenerate refs/pull/N/merge in between -- a new commit object with
# the same parents -- and then FETCH_HEAD is not HEAD, HEAD keeps its
# depth-1 graft, and no tag is reachable from it. Deepen the ref we are
# actually on before giving up. Re-running the job cannot clear this:
# a re-run replays the same pinned SHA.
if [ -z "$base" ]; then
echo "Scan base empty (merge ref moved under the checkout?);" \
"retrying with a full deepen."
git fetch --unshallow --filter=tree:0 --tags origin
rel="$(git tag --merged HEAD --sort=-v:refname --list 'v*-stable')"
base="$(printf '%s\n' "$rel" | sed -n '2p')"
echo "Re-deepened to $(git rev-list --count HEAD) commits;" \
"scan base='${base}'"
fi
if [ -z "$base" ]; then
echo "::error::Deepen produced no usable scan base; check-break.sh would scan the wrong window."
printf 'Release tags merged into HEAD: %s\n' "${rel:-<none>}"
exit 1
fi
- name: Download the wolfSSL install
uses: actions/download-artifact@v4
with:
name: wolfssl-install-${{ inputs.product }}
# Unpack to the same path wolfSSL was built at, keeping the .la/.pc
# absolute paths valid.
- name: Unpack the wolfSSL install
run: tar -C "$GITHUB_WORKSPACE" -xzf wolfssl-install.tar.gz
# Resolve the concrete ref to compile: the highest tag (latest) or the
# default branch (head). Used both for the build and the break check.
- name: Resolve product ref
id: ref
env:
REPO: ${{ inputs.repo }}
run: |
ref="$(.github/workflows/cross-library/scripts/resolve-ref.sh "$REPO" "${{ matrix.ref_mode }}")"
echo "Resolved ${{ matrix.ref_mode }} ref for $REPO: $ref"
echo "ref=$ref" >> "$GITHUB_OUTPUT"
# Build the product. Script-mode products use their existing adapters;
# Makefile-mode products run the same commands as their native CI here so
# their integration is reviewable without a second product-specific file.
# A build failure is allowed ONLY if a wolfSSL commit since the last release
# tag declared it with a breaks-<product>=<ref> token (see check-break.sh);
# otherwise the job fails, forcing intentional breaks to be recorded in a
# commit. The output gates the optional maintained-HEAD smoke test.
# PRODUCT_CONFIGURE is intentionally unquoted so multiple flags split.
- name: Compile ${{ inputs.product }} against wolfSSL
id: product_build
shell: bash
env:
BUILD_MODE: ${{ inputs.build_mode }}
REPO: ${{ inputs.repo }}
PRODUCT_CONFIGURE: ${{ inputs.product_configure }}
PRODUCT: ${{ inputs.product }}
PRODUCT_SCRIPT: ${{ inputs.script }}
REF: ${{ steps.ref.outputs.ref }}
MODE: ${{ matrix.ref_mode }}
run: |
S=.github/workflows/cross-library/scripts
set +e
(
set -euo pipefail
case "$BUILD_MODE:$PRODUCT" in
script:*)
# Keep the allowed adapter list explicit: workflow_call inputs
# must not select an arbitrary executable from the checkout.
product_script="${PRODUCT_SCRIPT:-${PRODUCT}.sh}"
case "$product_script" in
wolfclu.sh|wolfmqtt.sh|wolfpkcs11.sh|wolfprovider.sh|wolfssh.sh|wolftpm.sh)
;;
*)
echo "::error::unsupported cross-library product script: $product_script"
exit 2
;;
esac
# shellcheck disable=SC2086 # $PRODUCT_CONFIGURE must word-split into flags
"$S/$product_script" -t "$REF" \
"$GITHUB_WORKSPACE/wolfssl-install" "$REPO" $PRODUCT_CONFIGURE
;;
makefile:wolfcose)
case "$REPO" in
*://*|git@*) product_url="$REPO" ;;
*) product_url="https://github.com/${REPO}.git" ;;
esac
git clone --depth 1 --branch "$REF" "$product_url" wolfCOSE
cd wolfCOSE
# Match wolfCOSE's hosted Makefile build, explicitly using the
# staged wolfSSL instead of a host /usr/local installation.
cflags="-std=c99 -DHAVE_ANONYMOUS_INLINE_AGGREGATES=1 -Os"
cflags+=" -Wall -Wextra -Wpedantic -Wshadow -Wconversion"
cflags+=" -Wvla -Werror=vla -ffunction-sections -fdata-sections -fstack-usage"
cflags+=" -I./include -isystem $GITHUB_WORKSPACE/wolfssl-install/include"
ldflags="-L$GITHUB_WORKSPACE/wolfssl-install/lib -Wl,-rpath,$GITHUB_WORKSPACE/wolfssl-install/lib -lwolfssl"
make "-j$(nproc)" CFLAGS="$cflags" LDFLAGS="$ldflags"
;;
makefile:wolfip)
case "$REPO" in
*://*|git@*) product_url="$REPO" ;;
*) product_url="https://github.com/${REPO}.git" ;;
esac
git clone --depth 1 --branch "$REF" "$product_url" wolfip
cd wolfip
# wolfIP v1.0 predates generic WOLFSSL_PREFIX support on Linux,
# so point its header probe and link step at the staged install.
export WOLFSSL_PREFIX="$GITHUB_WORKSPACE/wolfssl-install"
export PKG_CONFIG_PATH="$WOLFSSL_PREFIX/lib/pkgconfig${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH}"
export EXTRA_CFLAGS="${EXTRA_CFLAGS:+$EXTRA_CFLAGS }-I$WOLFSSL_PREFIX/include"
export LDFLAGS="${LDFLAGS:+$LDFLAGS }-L$WOLFSSL_PREFIX/lib -Wl,-rpath,$WOLFSSL_PREFIX/lib"
# Releases up to v1.1.0 run mkcerts.sh once per cert file under -j.
if [ -x tools/certs/mkcerts.sh ]; then tools/certs/mkcerts.sh; fi
if [ "$REF" = "v1.0" ]; then
# v1.0 predates EXTRA_CFLAGS on Linux, so its header probe
# sees only CFLAGS. Keep its native warning/thread flags.
legacy_cflags="-Wall -Werror -Wextra -I. -D_GNU_SOURCE"
legacy_cflags+=" -g -ggdb -Wdeclaration-after-statement"
legacy_cflags+=" -I$WOLFSSL_PREFIX/include -DWOLFSSL_USE_OPTIONS_H"
legacy_ldflags="-pthread -L$WOLFSSL_PREFIX/lib -Wl,-rpath,$WOLFSSL_PREFIX/lib"
make "-j$(nproc)" build/test-wolfssl \
CFLAGS="$legacy_cflags" LDFLAGS="$legacy_ldflags"
else
make "-j$(nproc)" build/test-wolfssl
fi
;;
*)
echo "::error::unsupported cross-library build mode/product: $BUILD_MODE/$PRODUCT"
exit 2
;;
esac
)
rc=$?
set -e
# The breaks-<product>= mechanism applies ONLY to the latest release
# tag. A head/master break is never waivable, never consults the
# ledger, and must be fixed.
if [ "$rc" -eq 0 ]; then
echo "compiled=true" >> "$GITHUB_OUTPUT"
if [ "$MODE" = "latest" ] && "$S/check-break.sh" "$PRODUCT" "$REF" >/tmp/brk 2>/dev/null; then
echo "::warning::$PRODUCT ($REF) compiled OK but a break is still declared, remove the stale breaks-$PRODUCT=$REF token:"
cat /tmp/brk
fi
exit 0
fi
echo "===== $PRODUCT ($REF) failed to compile against this wolfSSL ====="
if [ "$MODE" = "latest" ]; then
# Released, immutable tag: allowed only if the exact tag is declared.
if "$S/check-break.sh" "$PRODUCT" "$REF"; then
echo "compiled=false" >> "$GITHUB_OUTPUT"
echo "::warning::$PRODUCT $REF failed to compile, but this break is DECLARED (see above). Treating as a known/tracked break."
exit 0
fi
echo "::error::$PRODUCT $REF (latest release) no longer compiles against this wolfSSL and no break is declared."
echo "That tag is a released version and cannot be changed. If wolfSSL is intentionally dropping"
echo "compatibility with it, record the break so CI tracks it and this job passes. Add this exact"
echo "token to a commit message in this PR (the release must be named explicitly):"
echo " breaks-$PRODUCT=$REF"
echo "Otherwise, rework the change so $PRODUCT $REF still builds."
else
# Product master/HEAD: NEVER waivable, no breaks- declaration exists.
echo "::error::$PRODUCT $REF (default branch) no longer compiles against this wolfSSL."
echo "A master/HEAD break cannot be waived; there is no breaks- declaration for it."
echo "$PRODUCT $REF must stay compatible with wolfSSL master. Fix it by either:"
echo " * reworking this PR so $PRODUCT $REF builds against wolfSSL master again, or"
echo " * putting up a matching fix on $PRODUCT's $REF branch, then re-running this job."
fi
exit 1
# The Makefile-mode smoke suite covers the maintained default-branch HEAD,
# after a real successful build. Older releases retain compile-only
# coverage because their own runtime suites may not support the current
# wolfSSL baseline.
- name: Run ${{ inputs.product }} smoke tests
if: ${{ inputs.build_mode == 'makefile' && matrix.ref_mode == 'head' && steps.product_build.outputs.compiled == 'true' }}
shell: bash
env:
PRODUCT: ${{ inputs.product }}
WOLFSSL_INSTALL: ${{ github.workspace }}/wolfssl-install
run: |
set -euxo pipefail
case "$PRODUCT" in
wolfcose)
cd "$GITHUB_WORKSPACE/wolfCOSE"
export LD_LIBRARY_PATH="$WOLFSSL_INSTALL/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
cflags="-std=c99 -DHAVE_ANONYMOUS_INLINE_AGGREGATES=1 -Os"
cflags+=" -Wall -Wextra -Wpedantic -Wshadow -Wconversion"
cflags+=" -Wvla -Werror=vla -ffunction-sections -fdata-sections -fstack-usage"
cflags+=" -I./include -isystem $WOLFSSL_INSTALL/include"
ldflags="-L$WOLFSSL_INSTALL/lib -Wl,-rpath,$WOLFSSL_INSTALL/lib -lwolfssl"
make test CFLAGS="$cflags" LDFLAGS="$ldflags"
make tool-test CFLAGS="$cflags" LDFLAGS="$ldflags"
;;
wolfip)
cd "$GITHUB_WORKSPACE/wolfip"
export WOLFSSL_PREFIX="$WOLFSSL_INSTALL"
export PKG_CONFIG_PATH="$WOLFSSL_PREFIX/lib/pkgconfig${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH}"
export EXTRA_CFLAGS="${EXTRA_CFLAGS:+$EXTRA_CFLAGS }-I$WOLFSSL_PREFIX/include"
export LDFLAGS="${LDFLAGS:+$LDFLAGS }-L$WOLFSSL_PREFIX/lib -Wl,-rpath,$WOLFSSL_PREFIX/lib"
export LD_LIBRARY_PATH="$WOLFSSL_PREFIX/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
make "-j$(nproc)" unit-esp
./build/test/unit-esp
;;
*)
echo "::error::unsupported cross-library smoke test"
exit 1
;;
esac