Skip to content

Commit 4fd114b

Browse files
committed
Optimize wolfprovider build time
1 parent 01a48e3 commit 4fd114b

17 files changed

Lines changed: 155 additions & 191 deletions

.github/workflows/build-wolfprovider.yml

Lines changed: 99 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,21 @@ on:
1212
outputs:
1313
cache_key:
1414
description: "Cache key for the build artifacts"
15-
value: ${{ jobs.build_wolfprovider.outputs.cache_key }}
15+
value: ${{ jobs.build_wolfprovider_common.outputs.cache_key }}
1616

1717
jobs:
18-
build_wolfprovider:
18+
build_wolfprovider_common:
1919
name: Build wolfProvider
2020
runs-on: ubuntu-22.04
2121
timeout-minutes: 20
2222
outputs:
23-
cache_key: wolfprov-${{ inputs.wolfssl_ref }}-${{ github.sha }}
23+
cache_key: wolfprov-${{ inputs.wolfssl_ref }}-${{ inputs.openssl_ref }}-${{ github.sha }}
2424
steps:
25-
- name: Checkout wolfProvider
26-
uses: actions/checkout@v4
27-
2825
# Check if this version of wolfssl/wolfprovider has already been built,
2926
# mark to cache these items on post if we do end up building
27+
# On a push, the first workflow(s) will complete the build and cache it
28+
# and any delayed workflow will be able to utilize it.
29+
# This is not designed to cache builds across commits.
3030
- name: Checking wolfSSL/wolfProvider in cache
3131
uses: actions/cache@v4
3232
id: wolfprov-cache
@@ -35,30 +35,117 @@ jobs:
3535
wolfssl-source
3636
wolfssl-install
3737
wolfprov-install
38+
openssl-install
3839
provider.conf
3940
40-
key: wolfprov-${{ inputs.wolfssl_ref }}-${{ github.sha }}
41+
key: wolfprov-${{ inputs.wolfssl_ref }}-${{ inputs.openssl_ref }}-${{ github.sha }}
4142
lookup-only: true
4243

43-
# If wolfssl/wolfprovider have not yet been built, pull ossl from cache
44+
# if cache hit, exit the workflow
45+
- name: Exit workflow if cache hit
46+
if: steps.wolfprov-cache.outputs.cache-hit == 'true'
47+
run: |
48+
echo "Found cached build, exiting workflow"
49+
exit 0
50+
51+
- name: Checkout wolfProvider
52+
if: steps.wolfprov-cache.outputs.cache-hit != 'true'
53+
uses: actions/checkout@v4
54+
with:
55+
fetch-depth: 1
56+
57+
# Convert OpenSSL branch name to commit hash if needed
58+
- name: Get OpenSSL commit hash
59+
if: steps.wolfprov-cache.outputs.cache-hit != 'true'
60+
id: openssl-ref
61+
run: |
62+
if [[ "${{ inputs.openssl_ref }}" =~ ^[0-9a-f]{40}$ ]]; then
63+
echo "ref=${{ inputs.openssl_ref }}" >> $GITHUB_OUTPUT
64+
else
65+
sha=$(curl -s "https://api.github.com/repos/openssl/openssl/commits/${{ inputs.openssl_ref }}" | jq -r '.sha')
66+
echo "ref=$sha" >> $GITHUB_OUTPUT
67+
echo "OpenSSL ref ${{ inputs.openssl_ref }} is commit $sha"
68+
fi
69+
70+
# Look for a cached version of OpenSSL
4471
- name: Checking OpenSSL in cache
4572
if: steps.wolfprov-cache.outputs.cache-hit != 'true'
46-
uses: actions/cache@v4
73+
uses: actions/cache/restore@v4
4774
id: openssl-cache
4875
with:
4976
path: |
5077
openssl-source
5178
openssl-install
5279
53-
key: ossl-depends-${{ inputs.openssl_ref }}-${{ github.sha }}
54-
lookup-only: true
80+
key: ossl-depends-${{ steps.openssl-ref.outputs.ref }}
81+
lookup-only: false
82+
83+
# Convert WolfSSL branch name to commit hash if needed
84+
- name: Get WolfSSL commit hash
85+
if: steps.wolfprov-cache.outputs.cache-hit != 'true'
86+
id: wolfssl-ref
87+
run: |
88+
if [[ "${{ inputs.wolfssl_ref }}" =~ ^[0-9a-f]{40}$ ]]; then
89+
echo "ref=${{ inputs.wolfssl_ref }}" >> $GITHUB_OUTPUT
90+
else
91+
sha=$(curl -s "https://api.github.com/repos/wolfssl/wolfssl/commits/${{ inputs.wolfssl_ref }}" | jq -r '.sha')
92+
echo "ref=$sha" >> $GITHUB_OUTPUT
93+
echo "WolfSSL ref ${{ inputs.wolfssl_ref }} is commit $sha"
94+
fi
95+
96+
# Look for a cached version of WolfSSL
97+
- name: Checking WolfSSL in cache
98+
if: steps.wolfprov-cache.outputs.cache-hit != 'true'
99+
uses: actions/cache/restore@v4
100+
id: wolfssl-cache
101+
with:
102+
path: |
103+
wolfssl-source
104+
wolfssl-install
105+
106+
key: wolfssl-depends-${{ steps.wolfssl-ref.outputs.ref }}
107+
lookup-only: false
55108

56-
# If not yet built this version, build it now
57109
- name: Build wolfProvider
58110
if: steps.wolfprov-cache.outputs.cache-hit != 'true'
59111
run: |
60112
OPENSSL_TAG=${{ inputs.openssl_ref }} WOLFSSL_TAG=${{ inputs.wolfssl_ref }} ./scripts/build-wolfprovider.sh
61113
114+
# This is potentially chewing up a lot of cache space.
115+
# Could investigate reducing the size of this cache.
116+
# Note that we use actions/cache/save and actions/cache/restore instead of
117+
# actions/cache to reduce the chance of a cache lock issue.
118+
- name: Save wolfProvider into cache
119+
if: steps.wolfprov-cache.outputs.cache-hit != 'true'
120+
uses: actions/cache/save@v4
121+
with:
122+
path: |
123+
wolfssl-source
124+
wolfssl-install
125+
wolfprov-install
126+
openssl-install
127+
provider.conf
128+
key: wolfprov-${{ inputs.wolfssl_ref }}-${{ inputs.openssl_ref }}-${{ github.sha }}
129+
130+
# If openssl cache miss, save it to the cache
131+
- name: Save OpenSSL into cache
132+
if: steps.openssl-cache.outputs.cache-hit != 'true'
133+
uses: actions/cache/save@v4
134+
with:
135+
path: |
136+
openssl-source
137+
openssl-install
138+
key: ossl-depends-${{ steps.openssl-ref.outputs.ref }}
139+
140+
- name: Save WolfSSL into cache
141+
if: steps.wolfssl-cache.outputs.cache-hit != 'true'
142+
uses: actions/cache/save@v4
143+
with:
144+
path: |
145+
wolfssl-source
146+
wolfssl-install
147+
key: wolfssl-depends-${{ steps.wolfssl-ref.outputs.ref }}
148+
62149
- name: Print errors
63150
if: ${{ failure() }}
64151
run: |

.github/workflows/cjose.yml

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -35,35 +35,23 @@ jobs:
3535
openssl_ref: [ 'openssl-3.5.0' ]
3636
force_fail: [ 'WOLFPROV_FORCE_FAIL=1', '' ]
3737
steps:
38-
# Checkout the source so we can run the check-workflow-result script
3938
- name: Checkout wolfProvider
4039
uses: actions/checkout@v4
4140
with:
42-
sparse-checkout: |
43-
.github
41+
fetch-depth: 1
4442

45-
- name: Retrieving OpenSSL from cache
43+
- name: Retrieving wolfProvider from cache
4644
uses: actions/cache/restore@v4
47-
id: openssl-cache
48-
with:
49-
path: |
50-
openssl-source
51-
openssl-install
52-
53-
key: ossl-depends-${{ matrix.openssl_ref }}-${{ github.sha }}
54-
fail-on-cache-miss: true
55-
56-
- name: Retrieving wolfSSL/wolfProvider from cache
57-
uses: actions/cache/restore@v4
58-
id: wolfprov-cache
45+
id: wolfprov-cache-restore
5946
with:
6047
path: |
6148
wolfssl-source
6249
wolfssl-install
6350
wolfprov-install
51+
openssl-install
6452
provider.conf
6553
66-
key: wolfprov-${{ matrix.wolfssl_ref }}-${{ github.sha }}
54+
key: wolfprov-${{ matrix.wolfssl_ref }}-${{ matrix.openssl_ref }}-${{ github.sha }}
6755
fail-on-cache-miss: true
6856

6957
- name: Install cjose dependencies
@@ -78,12 +66,13 @@ jobs:
7866
repository: OpenIDC/cjose
7967
ref: ${{ matrix.cjose_ref }}
8068
path: cjose
69+
fetch-depth: 1
8170

8271
- name: Build cjose
8372
working-directory: cjose
8473
run: |
8574
# Configure with OpenSSL
86-
./configure CFLAGS="-Wno-error=deprecated-declarations" --with-openssl=/git/wolfProvider/openssl-install
75+
./configure CFLAGS="-Wno-error=deprecated-declarations" --with-openssl=/git/wolfProvider/openssl-install
8776
8877
# Build cjose
8978
make

.github/workflows/curl.yml

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,9 @@ jobs:
4040
steps:
4141
- name: Checkout wolfProvider
4242
uses: actions/checkout@v4
43-
44-
- name: Retrieving OpenSSL from cache
45-
uses: actions/cache/restore@v4
46-
id: openssl-cache
4743
with:
48-
path: |
49-
openssl-source
50-
openssl-install
51-
52-
key: ossl-depends-${{ matrix.openssl_ref }}-${{ github.sha }}
53-
fail-on-cache-miss: true
54-
44+
fetch-depth: 1
45+
5546
- name: Retrieving wolfSSL/wolfProvider from cache
5647
uses: actions/cache/restore@v4
5748
id: wolfprov-cache
@@ -60,9 +51,10 @@ jobs:
6051
wolfssl-source
6152
wolfssl-install
6253
wolfprov-install
54+
openssl-install
6355
provider.conf
6456
65-
key: wolfprov-${{ matrix.wolfssl_ref }}-${{ github.sha }}
57+
key: wolfprov-${{ matrix.wolfssl_ref }}-${{ matrix.openssl_ref }}-${{ github.sha }}
6658
fail-on-cache-miss: true
6759

6860
- name: Install dependencies

.github/workflows/grpc.yml

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,9 @@ jobs:
4444
steps:
4545
- name: Checkout wolfProvider
4646
uses: actions/checkout@v4
47-
48-
- name: Retrieving OpenSSL from cache
49-
uses: actions/cache/restore@v4
50-
id: openssl-cache
5147
with:
52-
path: |
53-
openssl-source
54-
openssl-install
55-
56-
key: ossl-depends-${{ matrix.openssl_ref }}-${{ github.sha }}
57-
fail-on-cache-miss: true
58-
48+
fetch-depth: 1
49+
5950
- name: Retrieving wolfSSL/wolfProvider from cache
6051
uses: actions/cache/restore@v4
6152
id: wolfprov-cache
@@ -64,9 +55,10 @@ jobs:
6455
wolfssl-source
6556
wolfssl-install
6657
wolfprov-install
58+
openssl-install
6759
provider.conf
6860
69-
key: wolfprov-${{ matrix.wolfssl_ref }}-${{ github.sha }}
61+
key: wolfprov-${{ matrix.wolfssl_ref }}-${{ matrix.openssl_ref }}-${{ github.sha }}
7062
fail-on-cache-miss: true
7163

7264
- name: Confirm IPv4 and IPv6 support

.github/workflows/iperf.yml

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,8 @@ jobs:
3737
steps:
3838
- name: Checkout wolfProvider
3939
uses: actions/checkout@v4
40-
41-
- name: Retrieving OpenSSL from cache
42-
uses: actions/cache/restore@v4
43-
id: openssl-cache
4440
with:
45-
path: |
46-
openssl-source
47-
openssl-install
48-
49-
key: ossl-depends-${{ matrix.openssl_ref }}-${{ github.sha }}
50-
fail-on-cache-miss: true
41+
fetch-depth: 1
5142

5243
- name: Retrieving wolfSSL/wolfProvider from cache
5344
uses: actions/cache/restore@v4
@@ -57,9 +48,10 @@ jobs:
5748
wolfssl-source
5849
wolfssl-install
5950
wolfprov-install
51+
openssl-install
6052
provider.conf
6153
62-
key: wolfprov-${{ matrix.wolfssl_ref }}-${{ github.sha }}
54+
key: wolfprov-${{ matrix.wolfssl_ref }}-${{ matrix.openssl_ref }}-${{ github.sha }}
6355
fail-on-cache-miss: true
6456

6557
- name: Install dependencies

.github/workflows/ipmitool.yml

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,8 @@ jobs:
3737
steps:
3838
- name: Checkout wolfProvider
3939
uses: actions/checkout@v4
40-
41-
- name: Retrieving OpenSSL from cache
42-
uses: actions/cache/restore@v4
43-
id: openssl-cache
4440
with:
45-
path: |
46-
openssl-source
47-
openssl-install
48-
49-
key: ossl-depends-${{ matrix.openssl_ref }}-${{ github.sha }}
50-
fail-on-cache-miss: true
41+
fetch-depth: 1
5142

5243
- name: Retrieving wolfSSL/wolfProvider from cache
5344
uses: actions/cache/restore@v4
@@ -57,9 +48,10 @@ jobs:
5748
wolfssl-source
5849
wolfssl-install
5950
wolfprov-install
51+
openssl-install
6052
provider.conf
6153
62-
key: wolfprov-${{ matrix.wolfssl_ref }}-${{ github.sha }}
54+
key: wolfprov-${{ matrix.wolfssl_ref }}-${{ matrix.openssl_ref }}-${{ github.sha }}
6355
fail-on-cache-miss: true
6456

6557
- name: Install dependencies

.github/workflows/liboauth2.yml

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,9 @@ jobs:
3636
steps:
3737
- name: Checkout wolfProvider
3838
uses: actions/checkout@v4
39-
40-
- name: Retrieving OpenSSL from cache
41-
uses: actions/cache/restore@v4
42-
id: openssl-cache
4339
with:
44-
path: |
45-
openssl-source
46-
openssl-install
47-
48-
key: ossl-depends-${{ matrix.openssl_ref }}-${{ github.sha }}
49-
fail-on-cache-miss: true
50-
40+
fetch-depth: 1
41+
5142
- name: Retrieving wolfSSL/wolfProvider from cache
5243
uses: actions/cache/restore@v4
5344
id: wolfprov-cache
@@ -56,9 +47,10 @@ jobs:
5647
wolfssl-source
5748
wolfssl-install
5849
wolfprov-install
50+
openssl-install
5951
provider.conf
6052
61-
key: wolfprov-${{ matrix.wolfssl_ref }}-${{ github.sha }}
53+
key: wolfprov-${{ matrix.wolfssl_ref }}-${{ matrix.openssl_ref }}-${{ github.sha }}
6254
fail-on-cache-miss: true
6355

6456
- name: Install liboauth2 dependencies

.github/workflows/net-snmp.yml

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,8 @@ jobs:
3838
steps:
3939
- name: Checkout wolfProvider
4040
uses: actions/checkout@v4
41-
42-
- name: Retrieving OpenSSL from cache
43-
uses: actions/cache/restore@v4
44-
id: openssl-cache
4541
with:
46-
path: |
47-
openssl-source
48-
openssl-install
49-
50-
key: ossl-depends-${{ matrix.openssl_ref }}-${{ github.sha }}
51-
fail-on-cache-miss: true
42+
fetch-depth: 1
5243

5344
- name: Retrieving wolfSSL/wolfProvider from cache
5445
uses: actions/cache/restore@v4
@@ -58,9 +49,10 @@ jobs:
5849
wolfssl-source
5950
wolfssl-install
6051
wolfprov-install
52+
openssl-install
6153
provider.conf
6254
63-
key: wolfprov-${{ matrix.wolfssl_ref }}-${{ github.sha }}
55+
key: wolfprov-${{ matrix.wolfssl_ref }}-${{ matrix.openssl_ref }}-${{ github.sha }}
6456
fail-on-cache-miss: true
6557

6658
- name: Install dependencies

0 commit comments

Comments
 (0)