Skip to content

Commit 3e8e7f8

Browse files
authored
Merge pull request #226 from aidangarske/opensc-workflow
Add opensc/opensc-pkcs11 Github CI workflow
2 parents 1f262ac + 95a5788 commit 3e8e7f8

1 file changed

Lines changed: 116 additions & 0 deletions

File tree

.github/workflows/opensc.yml

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
name: OpenSC Tests
2+
3+
# START OF COMMON SECTION
4+
on:
5+
push:
6+
branches: [ 'master', 'main', 'release/**' ]
7+
pull_request:
8+
branches: [ '*' ]
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.ref }}
12+
cancel-in-progress: true
13+
# END OF COMMON SECTION
14+
15+
jobs:
16+
build_wolfprovider:
17+
uses: ./.github/workflows/build-wolfprovider.yml
18+
with:
19+
wolfssl_ref: ${{ matrix.wolfssl_ref }}
20+
openssl_ref: ${{ matrix.openssl_ref }}
21+
strategy:
22+
matrix:
23+
wolfssl_ref: [ 'master', 'v5.8.0-stable' ]
24+
openssl_ref: [ 'openssl-3.5.0' ]
25+
26+
test_opensc:
27+
runs-on: ubuntu-22.04
28+
needs: build_wolfprovider
29+
# This should be a safe limit for the tests to run.
30+
timeout-minutes: 30
31+
strategy:
32+
matrix:
33+
opensc_ref: [ '0.25.1' ]
34+
wolfssl_ref: [ 'master', 'v5.8.0-stable' ]
35+
openssl_ref: [ 'openssl-3.5.0' ]
36+
force_fail: [ 'WOLFPROV_FORCE_FAIL=1', '' ]
37+
steps:
38+
- name: Checkout wolfProvider
39+
uses: actions/checkout@v4
40+
with:
41+
fetch-depth: 1
42+
43+
- name: Retrieving wolfSSL/wolfProvider from cache
44+
uses: actions/cache/restore@v4
45+
id: wolfprov-cache
46+
with:
47+
path: |
48+
wolfssl-install
49+
wolfprov-install
50+
openssl-install/lib64
51+
openssl-install/include
52+
openssl-install/bin
53+
key: wolfprov-${{ matrix.wolfssl_ref }}-${{ matrix.openssl_ref }}-${{ github.sha }}
54+
fail-on-cache-miss: true
55+
56+
- name: Install OpenSC dependencies
57+
run: |
58+
sudo apt-get update
59+
sudo apt-get install -y \
60+
autotools-dev libtool automake autoconf make pkg-config \
61+
libeac-dev gengetopt libpcsclite-dev libreadline-dev \
62+
zlib1g-dev docbook-xsl xsltproc pcscd softhsm2 opensc pcsc-tools \
63+
vim libcmocka-dev libjson-c-dev libp11-dev
64+
65+
- name: Download OpenSC
66+
uses: actions/checkout@v4
67+
with:
68+
repository: OpenSC/OpenSC
69+
ref: ${{ matrix.opensc_ref }}
70+
path: opensc
71+
fetch-depth: 1
72+
73+
- name: Checkout OSP
74+
uses: actions/checkout@v4
75+
with:
76+
repository: wolfssl/osp
77+
path: osp
78+
fetch-depth: 1
79+
run: |
80+
cd opensc
81+
patch -p1 < $GITHUB_WORKSPACE/osp/wolfProvider/opensc/opensc-${{ matrix.opensc_ref }}-wolfprovider.patch
82+
83+
- name: Build OpenSC
84+
working-directory: opensc
85+
run: |
86+
# Configure with custom OpenSSL and wolfProvider
87+
./bootstrap
88+
OPENSSL_CFLAGS="-I$GITHUB_WORKSPACE/openssl-install/include" \
89+
OPENSSL_LIBS="-L$GITHUB_WORKSPACE/openssl-install/lib64 -lcrypto" \
90+
./configure \
91+
--enable-openssl \
92+
--enable-pcsc \
93+
--disable-doc \
94+
--prefix=$GITHUB_WORKSPACE/opensc-install \
95+
--with-completiondir="$GITHUB_WORKSPACE/opensc-install/share/completions" \
96+
CFLAGS="-Wno-error" \
97+
LDFLAGS="-L$GITHUB_WORKSPACE/openssl-install/lib64" \
98+
CPPFLAGS="-I$GITHUB_WORKSPACE/openssl-install/include"
99+
100+
# Build OpenSC
101+
make -j$(nproc)
102+
sudo make install
103+
104+
- name: Run OpenSC tests
105+
working-directory: opensc
106+
run: |
107+
# Set up the environment for wolfProvider
108+
source $GITHUB_WORKSPACE/scripts/env-setup
109+
export ${{ matrix.force_fail }}
110+
111+
# Run tests and save output
112+
make check | tee opensc-test.log
113+
114+
# Check for expected test results in the test log (18 passes, 2 expected failures, with WPFF we expect 6 failures)
115+
TEST_RESULT=$(((grep -q "# PASS: 10" opensc-test.log) && (grep -q "# PASS: 8" opensc-test.log) && (grep -q "# XFAIL: 2" opensc-test.log)) && echo "0" || echo "1")
116+
$GITHUB_WORKSPACE/.github/scripts/check-workflow-result.sh $TEST_RESULT ${{ matrix.force_fail }} opensc

0 commit comments

Comments
 (0)