Skip to content

Commit

Permalink
Improved CI workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
olszomal committed Dec 4, 2024
1 parent 2209d86 commit b10669b
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 28 deletions.
60 changes: 46 additions & 14 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,39 +9,72 @@ env:
version: 0.4.13_git

jobs:
unix:
build:
strategy:
fail-fast: false
matrix:
include:
- os: 'ubuntu-22.04'
- os: 'ubuntu-20.04'
- os: 'macOS-latest'
- id: ubuntu-24.04
triplet: x64-linux
compiler: gcc
os: ubuntu-24.04
generator: Unix Makefiles
- id: ubuntu-22.04
triplet: x64-linux
compiler: gcc
os: ubuntu-22.04
generator: Unix Makefiles
- id: ubuntu-20.04
triplet: x64-linux
compiler: gcc
os: ubuntu-20.04
generator: Unix Makefiles
- id: macOS-3
openssl: 'openssl@3'
- os: 'macOS-latest'
triplet: x64-osx
compiler: clang
os: macOS-latest
generator: Unix Makefiles
- id: macOS-1.1
openssl: 'openssl@1.1'
triplet: x64-osx
compiler: clang
os: macOS-latest
generator: Unix Makefiles

runs-on: ${{matrix.os}}

env:
PKG_CONFIG_PATH: /usr/local/opt/${{matrix.openssl}}/lib/pkgconfig

steps:
- uses: actions/checkout@v4

- name: Install apt dependencies (Linux)
if: runner.os == 'Linux'
run: sudo apt-get install -y libssl-dev opensc softhsm
run: |
sudo apt-get update
sudo apt-get install -y libssl-dev opensc softhsm2
- name: Install brew dependencies (macOS)
if: runner.os == 'macOS'
run: |
brew install libtool automake ${{matrix.openssl}} softhsm
brew install libtool automake softhsm
brew install --cask opensc
echo "/usr/local/opt/${{matrix.openssl}}/bin" >> $GITHUB_PATH
- name: List files (macOS)
if: runner.os == 'macOS'
run: find /System/Volumes/Data/opt/homebrew/Cellar/${{matrix.openssl}} -ls

- name: Set environment variables (macOS)
if: runner.os == 'macOS'
run: |
echo "/opt/homebrew/bin" >> $GITHUB_PATH
echo "/opt/homebrew/opt/${{matrix.openssl}}/bin" >> $GITHUB_PATH
echo "PKG_CONFIG_PATH=/opt/homebrew/opt/${{matrix.openssl}}/lib/pkgconfig" >> $GITHUB_ENV
- name: System information
run: |
which pkcs11-tool
which softhsm2-util
which openssl
openssl version -a
echo "PATH=$PATH"
Expand All @@ -58,9 +91,8 @@ jobs:
timeout-minutes: 5
run: make check

- name: Results of failed tests
if: failure()
run: cat tests/test-suite.log || true
- name: Results of tests
run: cat ${{github.workspace}}/tests/test-suite.log || true

windows:
strategy:
Expand Down
47 changes: 33 additions & 14 deletions tests/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,29 @@ echo "Output directory: ${outdir}"

mkdir -p ${outdir}

for i in /usr/local/lib/softhsm /opt/local/lib/softhsm /usr/lib64/pkcs11 \
/usr/lib64/softhsm /usr/lib/x86_64-linux-gnu/softhsm /usr/lib/softhsm /usr/lib; do
if [[ -f "$i/libsofthsm2.so" ]]; then
MODULE="$i/libsofthsm2.so"
break
else
if [[ -f "$i/libsofthsm.so" ]]; then
MODULE="$i/libsofthsm.so"
break
fi
fi
done
#!/bin/bash

# List of directories to search
SEARCH_PATHS=(
"/usr/local"
"/opt/local"
"/usr/lib"
"/usr/lib64"
"/usr/lib/x86_64-linux-gnu"
"/opt/homebrew"
"/opt"
)

# Use 'find' to locate the library
MODULE=$(find "${SEARCH_PATHS[@]}" -type f -name "libsofthsm2.so" 2>/dev/null | head -n 1)

# Output the result
if [[ -n "${MODULE}" ]]; then
echo "SoftHSM library found: ${MODULE}"
else
echo "SoftHSM library not found. Please install SoftHSM to proceed."
exit 77
fi

if [[ ! -x /usr/bin/pkcs11-tool && ! -x /usr/local/bin/pkcs11-tool ]]; then
echo "Skipping test: 'pkcs11-tool' not found. Please install the tool to proceed."
Expand All @@ -58,8 +69,10 @@ export LD_LIBRARY_PATH=${TEMP_LD_LIBRARY_PATH}
# Check for ldd command
if command -v ldd >/dev/null 2>&1; then
LIBCRYPTO_VER=$(ldd "${MODULE}" | grep 'libcrypto' | awk '{print $1}')
elif command -v otool >/dev/null 2>&1; then
LIBCRYPTO_VER=$(otool -L "${MODULE}" | grep 'libcrypto' | awk '{print $1}')
else
echo "Warning: ldd command not found. Skipping library version detection."
echo "Warning: Neither ldd nor otool command found. Skipping library version detection."
LIBCRYPTO_VER="unknown"
fi

Expand Down Expand Up @@ -122,6 +135,12 @@ init_db () {
SLOT="--free "
fi

if [[ -x "/opt/homebrew/bin/softhsm2-util" ]]; then
export SOFTHSM2_CONF="$outdir/softhsm-testpkcs11.config"
SOFTHSM_TOOL="/opt/homebrew/bin/softhsm2-util"
SLOT="--free "
fi

if [[ -z ${SOFTHSM_TOOL} ]]; then
echo "Could not find softhsm(2) tool"
exit 77
Expand Down Expand Up @@ -226,7 +245,7 @@ import_objects () {
echo -n "* Importing the ${key_type} ${param} object id=${obj_id}"
echo -n " into the token ${token_label} ... "
pkcs11-tool --login --pin ${PIN} --module ${MODULE} \
--token-label "${token_label}"\
--token-label "${token_label}" \
--write-object "${srcdir}/${key_type}-${param}.der" \
--type ${param} \
--id ${obj_id} --label "${obj_label}" >/dev/null
Expand Down

0 comments on commit b10669b

Please sign in to comment.