Skip to content

Commit 2c78b1c

Browse files
committed
Implement cacheing for simple.yml and verify with script
1 parent faf06de commit 2c78b1c

File tree

3 files changed

+75
-48
lines changed

3 files changed

+75
-48
lines changed

.github/scripts/check-workflow-result.sh

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22

33
set -e
44

5-
if [ $# -lt 1 ]; then
6-
echo "Usage: $0 <test_result> [WOLFPROV_FORCE_FAIL] [TEST_SUITE]"
5+
if [ $# -lt 2 ]; then
6+
echo "Usage: $0 <build_result> <test_result> [WOLFPROV_FORCE_FAIL] [TEST_SUITE]"
77
exit 1
88
fi
99

10-
TEST_RESULT="$1"
11-
WOLFPROV_FORCE_FAIL="${2:-}"
12-
TEST_SUITE="${3:-}"
10+
BUILD_RESULT="$1"
11+
TEST_RESULT="$2"
12+
WOLFPROV_FORCE_FAIL="${3:-}"
13+
TEST_SUITE="${4:-}"
1314

1415
if [ "$WOLFPROV_FORCE_FAIL" = "1" ]; then
1516
if [ "$TEST_SUITE" = "curl" ]; then
@@ -69,18 +70,33 @@ if [ "$WOLFPROV_FORCE_FAIL" = "1" ]; then
6970
echo "FAIL: Actual failed tests do not match expected."
7071
exit 1
7172
fi
73+
elif [ "$TEST_SUITE" = "simple" ]; then
74+
# --- simple test suite specific logic ---
75+
if [ -f "test-suite.log" ]; then
76+
# For simple tests, we expect all tests to fail when force fail is enabled
77+
if [ $BUILD_RESULT -eq 0 ] || [ $TEST_RESULT -eq 0 ]; then
78+
echo "Simple tests unexpectedly succeeded with force fail enabled"
79+
exit 1
80+
else
81+
echo "Simple tests failed as expected with force fail enabled"
82+
exit 0
83+
fi
84+
else
85+
echo "Error: test-suite.log not found"
86+
exit 1
87+
fi
7288
else
7389
# --- generic force-fail logic for other suites ---
74-
if [ "$TEST_RESULT" -ne 0 ]; then
75-
echo "Tests failed as expected with force fail enabled (suite: $TEST_SUITE)"
76-
exit 0
90+
if [ $BUILD_RESULT -eq 0 ] || [ $TEST_RESULT -eq 0 ]; then
91+
echo "Build/Test unexpectedly succeeded with force fail enabled"
92+
exit 1 # failure was not seen when expected
7793
else
78-
echo "Tests unexpectedly succeeded with force fail enabled (suite: $TEST_SUITE)"
79-
exit 1
94+
echo "Build/Test failed as expected with force fail enabled"
95+
exit 0 # expected failure occurred
8096
fi
8197
fi
82-
elif [ "$TEST_RESULT" -ne 0 ]; then
83-
if [ "$TEST_RESULT" -eq 2 ]; then
98+
elif [ $BUILD_RESULT -ne 0 ] || [ $TEST_RESULT -ne 0 ]; then
99+
if [ $BUILD_RESULT -eq 2 ]; then
84100
echo "Build/test setup failed unexpectedly"
85101
else
86102
echo "Tests failed unexpectedly"

.github/workflows/curl.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ jobs:
7373
matrix:
7474
curl_ref: [ 'master', 'curl-8_4_0' ]
7575
wolfssl_ref: [ 'master', 'v5.7.4-stable' ]
76-
force_fail: [ 1, 0 ]
76+
force_fail: [ 1, 0 ] # ['WOLFPROV_FORCE_FAIL=1', '']
7777
steps:
7878
- name: Checkout wolfProvider
7979
uses: actions/checkout@v4
@@ -118,12 +118,12 @@ jobs:
118118

119119
- name: Generate certificates for curl master force-fail tests
120120
run: |
121-
if [ "${{ matrix.force_fail }}" = "1" ] && [ "${{ matrix.curl_ref }}" = "master" ]; then
121+
if [ "${{ matrix.force_fail }}" = "1" ] &&
122+
[ "${{ matrix.curl_ref }}" = "master" ]; then
122123
cd curl/tests/certs
123124
make test-ca.cacert
124125
cd ../..
125126
fi
126-
127127
- name: Test curl with wolfProvider
128128
working-directory: curl
129129
run: |

.github/workflows/simple.yml

Lines changed: 44 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ name: Simple Tests
33
# START OF COMMON SECTION
44
on:
55
push:
6-
branches: [ '*' ]
7-
# branches: [ 'master', 'main', 'release/**' ]
6+
branches: [ 'master', 'main', 'release/**' ]
87
pull_request:
98
branches: [ '*' ]
109

@@ -14,53 +13,65 @@ concurrency:
1413
# END OF COMMON SECTION
1514

1615
jobs:
17-
make_check:
18-
runs-on: ubuntu-latest
16+
simple_test:
17+
name: Simple Test
18+
runs-on: ubuntu-22.04
1919
timeout-minutes: 20
20-
2120
strategy:
2221
matrix:
23-
config:
22+
build_ref:
2423
- ''
2524
- 'OPENSSL_TAG=master'
2625
- 'WOLFSSL_TAG=master'
2726
- 'OPENSSL_TAG=master WOLFSSL_TAG=master'
28-
force_fail:
29-
- ''
30-
- 'WOLFPROV_FORCE_FAIL=1'
27+
force_fail: [ 1, 0 ] # ['WOLFPROV_FORCE_FAIL=1', '']
3128

3229
steps:
33-
- uses: actions/checkout@v4
34-
name: Checkout repository
30+
- name: Checkout wolfProvider
31+
uses: actions/checkout@v4
3532

36-
- name: Run build and tests
37-
run: |
38-
# Build first with matrix config
39-
${{ matrix.config }} ${{ matrix.force_fail }} ./scripts/build-wolfprovider.sh || BUILD_RESULT=$?
33+
# Check if this version of wolfssl/wolfprovider has already been built,
34+
# mark to cache these items on post if we do end up building
35+
- name: Checking wolfSSL/wolfProvider in cache
36+
uses: actions/cache@v4
37+
id: wolfprov-cache
38+
with:
39+
path: |
40+
wolfssl-source
41+
wolfssl-install
42+
wolfprov-install
43+
provider.conf
4044
41-
# Run all tests regardless of build result
42-
${{ matrix.force_fail }} ./scripts/cmd_test/do-cmd-tests.sh || TEST_RESULT=$?
45+
key: wolfprov-${{ matrix.build_ref }}-${{ github.sha }}
46+
lookup-only: true
4347

44-
# For force_fail, we expect failures (return 1)
45-
if [ -n "${{ matrix.force_fail }}" ]; then
46-
if [ $BUILD_RESULT -eq 0 ] || [ $TEST_RESULT -eq 0 ]; then
47-
echo "Build/Test unexpectedly succeeded with force fail enabled"
48-
exit 1 # failure was not seen when expected
49-
else
50-
echo "Build/Test failed as expected with force fail enabled"
51-
exit 0 # expected failure occurred
52-
fi
53-
else
54-
# Normal case - expect success
55-
if [ $BUILD_RESULT -ne 0 ] || [ $TEST_RESULT -ne 0 ]; then
56-
exit 1 # unexpected failure
57-
fi
58-
fi
48+
# If wolfssl/wolfprovider have not yet been built, pull ossl from cache
49+
- name: Checking OpenSSL in cache
50+
if: steps.wolfprov-${{ matrix.build_ref }}-cache.hit != 'true'
51+
uses: actions/cache@v4
52+
id: openssl-cache
53+
with:
54+
path: |
55+
openssl-source
56+
openssl-install
57+
58+
key: ossl-depends
59+
60+
# If not yet built this version, build it now
61+
- name: Build wolfProvider
62+
if: steps.wolfprov-${{ matrix.build_ref }}-cache.hit != 'true'
63+
run: |
64+
${{ matrix.build_ref.openssl }} ${{ matrix.build_ref.wolfssl }} WOLFPROV_FORCE_FAIL=${{ matrix.force_fail }} ./scripts/build-wolfprovider.sh || BUILD_RESULT=$?
65+
$GITHUB_WORKSPACE/.github/scripts/check-workflow-result.sh $BUILD_RESULT ${{ matrix.force_fail }} simple
66+
67+
- name: Run simple tests
68+
run: |
69+
WOLFPROV_FORCE_FAIL=${{ matrix.force_fail }} ./scripts/cmd_test/do-cmd-tests.sh || TEST_RESULT=$?
70+
$GITHUB_WORKSPACE/.github/scripts/check-workflow-result.sh $TEST_RESULT ${{ matrix.force_fail }} simple
5971
6072
- name: Print test logs
6173
if: always()
6274
run: |
6375
if [ -f test-suite.log ] ; then
6476
cat test-suite.log
6577
fi
66-

0 commit comments

Comments
 (0)