Skip to content

Commit c8f7e00

Browse files
committed
[GHA] Cache built crypto libraries
Change-Id: Ie21fdb01b843a7af09fcd469b08c775eee7e3745
1 parent 735bc9c commit c8f7e00

File tree

1 file changed

+45
-8
lines changed

1 file changed

+45
-8
lines changed

.github/workflows/build.yaml

Lines changed: 45 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -328,29 +328,41 @@ jobs:
328328
LDFLAGS: ${{ matrix.ldflags }}
329329
CC: ${{matrix.cc}}
330330
UBSAN_OPTIONS: print_stacktrace=1
331+
LIBRESSL_VERSION: v4.2.1
331332

332333
steps:
333334
- name: Install dependencies
334335
run: sudo apt update && sudo apt install -y liblzo2-dev libpam0g-dev liblz4-dev linux-libc-dev man2html clang libcmocka-dev python3-docutils libtool automake autoconf pkg-config libcap-ng-dev libnl-genl-3-dev
336+
- name: Restore libressl from cache
337+
uses: actions/cache@v5
338+
id: libressl-cache
339+
with:
340+
path: /opt
341+
key: ${{ matrix.os }}-libressl-${{ env.LIBRESSL_VERSION }}
335342
- name: "libressl: checkout"
343+
if: steps.libressl-cache.outputs.cache-hit != 'true'
336344
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
337345
with:
338346
path: libressl
339347
# versioning=semver-coerced
340348
repository: libressl/portable
341-
ref: v4.2.1
349+
ref: ${{ env.LIBRESSL_VERSION }}
342350
- name: "libressl: autogen.sh"
351+
if: steps.libressl-cache.outputs.cache-hit != 'true'
343352
env:
344353
LIBRESSL_GIT_OPTIONS: "--no-single-branch"
345354
run: ./autogen.sh
346355
working-directory: libressl
347356
- name: "libressl: configure"
348-
run: ./configure
357+
if: steps.libressl-cache.outputs.cache-hit != 'true'
358+
run: ./configure --prefix=/opt
349359
working-directory: libressl
350360
- name: "libressl: make all"
361+
if: steps.libressl-cache.outputs.cache-hit != 'true'
351362
run: make -j3
352363
working-directory: libressl
353364
- name: "libressl: make install"
365+
if: steps.libressl-cache.outputs.cache-hit != 'true'
354366
run: sudo make install
355367
working-directory: libressl
356368
- name: "ldconfig"
@@ -360,7 +372,11 @@ jobs:
360372
- name: autoconf
361373
run: autoreconf -fvi
362374
- name: configure
363-
run: ./configure --with-crypto-library=openssl ${{matrix.configureflags}} --enable-werror
375+
run: |
376+
OPENSSL_CFLAGS="-I/opt/include" \
377+
OPENSSL_LIBS="-L/opt/lib -lssl -lcrypto" \
378+
LDFLAGS="-Wl,-rpath=/opt/lib" \
379+
./configure --with-crypto-library=openssl --enable-werror ${{matrix.configureflags}}
364380
- name: make all
365381
run: make -j3
366382
- name: Ensure the build uses LibreSSL
@@ -396,27 +412,39 @@ jobs:
396412
LDFLAGS: ${{ matrix.ldflags }}
397413
CC: ${{matrix.cc}}
398414
UBSAN_OPTIONS: print_stacktrace=1
415+
PKG_CONFIG_PATH: /opt/lib/pkgconfig
416+
MBEDTLS_VERSION: 4.0.0
399417

400418
steps:
401419
- name: Install dependencies
402420
run: sudo apt update && sudo apt install -y liblzo2-dev libpam0g-dev liblz4-dev linux-libc-dev man2html clang libcmocka-dev python3-docutils python3-jinja2 python3-jsonschema libtool automake autoconf pkg-config libcap-ng-dev libnl-genl-3-dev
421+
- name: Restore mbed TLS from cache
422+
uses: actions/cache@v5
423+
id: mbedtls-cache
424+
with:
425+
path: /opt/
426+
key: ${{ matrix.os }}-mbedtls-${{ env.MBEDTLS_VERSION }}
403427
- name: "mbedtls: checkout"
428+
if: steps.mbedtls-cache.outputs.cache-hit != 'true'
404429
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
405430
with:
406431
path: mbedtls
407432
submodules: recursive
408433
# versioning=semver-coerced
409434
repository: Mbed-TLS/mbedtls
410-
ref: v4.0.0
435+
ref: v${{ env.MBEDTLS_VERSION }}
411436
- uses: lukka/get-cmake@f176ccd3f28bda569c43aae4894f06b2435a3375 # v4.2.3
412437
- name: "mbedtls: cmake"
413-
run: cmake -B build
438+
if: steps.mbedtls-cache.outputs.cache-hit != 'true'
439+
run: cmake -B build -DCMAKE_INSTALL_PREFIX=/opt
414440
working-directory: mbedtls
415441
- name: "mbedtls: cmake --build"
442+
if: steps.mbedtls-cache.outputs.cache-hit != 'true'
416443
run: cmake --build build
417444
working-directory: mbedtls
418445
- name: "mbedtls: cmake --install"
419-
run: sudo cmake --install build --prefix /usr
446+
if: steps.mbedtls-cache.outputs.cache-hit != 'true'
447+
run: sudo cmake --install build
420448
working-directory: mbedtls
421449
- name: Checkout OpenVPN
422450
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
@@ -426,7 +454,7 @@ jobs:
426454
run: ./configure --with-crypto-library=mbedtls --enable-werror
427455
- name: make all
428456
run: make -j3
429-
- name: Ensure the build uses mbed TLS 4.x
457+
- name: Ensure the build uses mbed TLS ${{ env.MBEDTLS_VERSION }}
430458
run: |
431459
./src/openvpn/openvpn --version
432460
./src/openvpn/openvpn --version | grep -q "library versions: mbed TLS 4."
@@ -463,19 +491,28 @@ jobs:
463491
CXX: ${{matrix.cxx}}
464492
UBSAN_OPTIONS: print_stacktrace=1
465493
AWS_LC_INSTALL: /opt/aws-lc
494+
AWS_LC_VERSION: v1.70.0
466495

467496
steps:
468497
- name: Install dependencies
469498
run: sudo apt update && sudo apt install -y gcc golang make liblzo2-dev libpam0g-dev liblz4-dev linux-libc-dev man2html clang libcmocka-dev python3-docutils python3-jinja2 python3-jsonschema libtool automake autoconf pkg-config libcap-ng-dev libnl-genl-3-dev
499+
- name: Restore AWS-LC from cache
500+
uses: actions/cache@v5
501+
id: aws-lc-cache
502+
with:
503+
path: ${{ env.AWS_LC_INSTALL }}
504+
key: ${{ matrix.os }}-aws-lc-${{ env.AWS_LC_VERSION }}
470505
- name: "AWS-LC: checkout"
506+
if: steps.aws-lc-cache.outputs.cache-hit != 'true'
471507
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
472508
with:
473509
path: aws-lc
474510
# versioning=semver-coerced
475511
repository: aws/aws-lc
476-
ref: v1.70.0
512+
ref: ${{ env.AWS_LC_VERSION }}
477513
- uses: lukka/get-cmake@f176ccd3f28bda569c43aae4894f06b2435a3375 # v4.2.3
478514
- name: "AWS-LC: build"
515+
if: steps.aws-lc-cache.outputs.cache-hit != 'true'
479516
run: |
480517
mkdir build
481518
cd build

0 commit comments

Comments
 (0)