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
1717jobs :
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 : |
0 commit comments