From 179663663b54a85dec0d3af06d0d08e14d3aceb1 Mon Sep 17 00:00:00 2001 From: Islam <2553451+qalandarov@users.noreply.github.com> Date: Fri, 12 Sep 2025 17:52:07 +0100 Subject: [PATCH] SPM Test target + Github Action to build and test (#585) --- .github/workflows/swift-tests.yml | 27 +++++++++++++++++++++++ Package.swift | 29 ++++++++++++++++++++++--- bitchat/Services/Tor/{ => C}/CTorHost.c | 0 bitchat/Services/Tor/C/include/.gitkeep | 0 4 files changed, 53 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/swift-tests.yml rename bitchat/Services/Tor/{ => C}/CTorHost.c (100%) create mode 100644 bitchat/Services/Tor/C/include/.gitkeep diff --git a/.github/workflows/swift-tests.yml b/.github/workflows/swift-tests.yml new file mode 100644 index 00000000..08ddd0c8 --- /dev/null +++ b/.github/workflows/swift-tests.yml @@ -0,0 +1,27 @@ +name: Build & Test + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + test: + name: Run Swift Tests + runs-on: macos-latest + + steps: + - name: Checkout code + uses: actions/checkout@v5 + + - name: Set up Swift + uses: swift-actions/setup-swift@v2 + + - name: Build the package + run: swift build + + - name: Run Tests + run: swift test --parallel --disable-swift-testing # so it only runs xctests: https://github.com/swiftlang/swift-package-manager/issues/8529#issuecomment-2815711345 diff --git a/Package.swift b/Package.swift index c3e4b26c..661cb3fd 100644 --- a/Package.swift +++ b/Package.swift @@ -15,13 +15,15 @@ let package = Package( ), ], dependencies:[ - .package(url: "https://github.com/21-DOT-DEV/swift-secp256k1", exact: "0.21.1"), + .package(url: "https://github.com/21-DOT-DEV/swift-secp256k1", exact: "0.21.1") ], targets: [ .executableTarget( name: "bitchat", dependencies: [ - .product(name: "P256K", package: "swift-secp256k1") + .product(name: "P256K", package: "swift-secp256k1"), + .target(name: "TorC"), + .target(name: "tor-nolzma") ], path: "bitchat", exclude: [ @@ -29,8 +31,29 @@ let package = Package( "Assets.xcassets", "bitchat.entitlements", "bitchat-macOS.entitlements", - "LaunchScreen.storyboard" + "LaunchScreen.storyboard", + "Services/Tor/C/" + ], + linkerSettings: [ + .linkedLibrary("z") ] ), + .target( + name: "TorC", + path: "bitchat/Services/Tor/C" + ), + .binaryTarget( + name: "tor-nolzma", + path: "Frameworks/tor-nolzma.xcframework" + ), + .testTarget( + name: "bitchatTests", + dependencies: ["bitchat"], + path: "bitchatTests", + exclude: [ + "Info.plist", + "README.md" + ] + ) ] ) diff --git a/bitchat/Services/Tor/CTorHost.c b/bitchat/Services/Tor/C/CTorHost.c similarity index 100% rename from bitchat/Services/Tor/CTorHost.c rename to bitchat/Services/Tor/C/CTorHost.c diff --git a/bitchat/Services/Tor/C/include/.gitkeep b/bitchat/Services/Tor/C/include/.gitkeep new file mode 100644 index 00000000..e69de29b