diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml new file mode 100644 index 0000000..1366b1c --- /dev/null +++ b/.github/workflows/pr.yml @@ -0,0 +1,28 @@ +name: PR Checks + +on: + push: + branches: [ "develop" ] + pull_request: + branches: [ "develop" ] + +jobs: + unit-tests: + name: Unit Tests + strategy: + matrix: + os: [ubuntu-20.04, macos-latest] + runs-on: ${{ matrix.os }} + + steps: + - uses: actions/checkout@v3 + with: + submodules: recursive + + - name: Run tests + run: ./run_test.sh + shell: bash + + - name: Run Swift build + run: | + swift build diff --git a/.gitignore b/.gitignore index 5b2da3c..32dc2c8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ .idea cmake-build-debug -build \ No newline at end of file +build +.swiftpm/ +.DS_Store \ No newline at end of file diff --git a/Package.swift b/Package.swift new file mode 100644 index 0000000..efe3c4c --- /dev/null +++ b/Package.swift @@ -0,0 +1,27 @@ +// swift-tools-version: 5.7 +// The swift-tools-version declares the minimum version of Swift required to build this package. + +import PackageDescription + +let package = Package( + name: "BloomFilter", + platforms: [ + .iOS(.v14), + .macOS(.v10_15) + ], + products: [ + .library( + name: "BloomFilter", + targets: ["BloomFilter"] + ), + ], + targets: [ + .target( + name: "BloomFilter", + path: "src", + sources: ["BloomFilter.cpp"], + publicHeadersPath: "." + ) + ], + cxxLanguageStandard: .cxx11 +) diff --git a/run_test.sh b/run_test.sh index c703e47..0352699 100755 --- a/run_test.sh +++ b/run_test.sh @@ -1,4 +1,6 @@ -directory=`dirname $0` -mkdir $directory/build; -(cd $directory/build; cmake ..; make all;) -$directory/build/test/RunTests \ No newline at end of file +#!/usr/bin/env bash + +directory=$(dirname "$0") +mkdir "$directory"/build; +(cd "$directory"/build || exit; cmake ..; make all;) +"$directory"/build/test/RunTests diff --git a/utils/CMakeLists.txt b/utils/CMakeLists.txt index ff64c2d..354409a 100644 --- a/utils/CMakeLists.txt +++ b/utils/CMakeLists.txt @@ -1,15 +1,14 @@ cmake_minimum_required(VERSION 3.5) if(APPLE) - include_directories(/usr/local/opt/openssl/include) - link_directories(/usr/local/opt/openssl/lib) + if(EXISTS /usr/local/opt/openssl/) + set(OPENSSL_ROOT_DIR /usr/local/opt/openssl) + elseif(EXISTS /opt/homebrew/opt/openssl@1.1/) + set(OPENSSL_ROOT_DIR /opt/homebrew/opt/openssl@1.1) + endif() endif() -link_libraries(crypto) -add_executable (GenerateFilter GenerateFilter.cpp) +find_package (OpenSSL REQUIRED) -if(APPLE) - target_link_libraries (GenerateFilter LINK_PUBLIC BloomFilter crypto) -else() - target_link_libraries (GenerateFilter LINK_PUBLIC BloomFilter) -endif() \ No newline at end of file +add_executable (GenerateFilter GenerateFilter.cpp) +target_link_libraries (GenerateFilter LINK_PUBLIC BloomFilter OpenSSL::Crypto)