From 549798b51558927df2d9fa5b96e548a3623793d1 Mon Sep 17 00:00:00 2001 From: Miguel Angel Quinones Date: Thu, 19 May 2022 22:15:43 +0200 Subject: [PATCH] [ADD] Run Linux CI --- .github/workflows/CI.yml | 25 +++++++ .github/workflows/swift.yml | 19 ----- Package.resolved | 9 +++ Package.swift | 71 +++++++++++-------- docker-run.sh | 8 +++ .../src/Client/EthereumClient+Call.swift | 8 +++ 6 files changed, 93 insertions(+), 47 deletions(-) create mode 100644 .github/workflows/CI.yml delete mode 100644 .github/workflows/swift.yml create mode 100755 docker-run.sh diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml new file mode 100644 index 00000000..fd091596 --- /dev/null +++ b/.github/workflows/CI.yml @@ -0,0 +1,25 @@ +name: CI + +on: + pull_request: + branches: [ develop ] + +jobs: + macos: + runs-on: macos-latest + steps: + - uses: actions/checkout@v3 + - name: Build + run: swift build -v + - name: Tests + run: swift test -v + linux: + runs-on: ubuntu-latest + container: + image: swift:5.5-bionic + steps: + - uses: actions/checkout@v3 + - name: Build + run: swift build -v + - name: Tests + run: swift test -v \ No newline at end of file diff --git a/.github/workflows/swift.yml b/.github/workflows/swift.yml deleted file mode 100644 index a9c0c81c..00000000 --- a/.github/workflows/swift.yml +++ /dev/null @@ -1,19 +0,0 @@ -name: Swift - -on: - push: - branches: [ develop ] - pull_request: - branches: [ develop ] - -jobs: - build: - - runs-on: macos-latest - - steps: - - uses: actions/checkout@v3 - - name: Build - run: swift build -v - - name: Run tests - run: swift test -v diff --git a/Package.resolved b/Package.resolved index 309c126e..ebbd8518 100644 --- a/Package.resolved +++ b/Package.resolved @@ -19,6 +19,15 @@ "version": "2.0.1" } }, + { + "package": "OpenCombine", + "repositoryURL": "https://github.com/OpenCombine/OpenCombine.git", + "state": { + "branch": null, + "revision": "9cf67e363738dbab61b47fb5eaed78d3db31e5ee", + "version": "0.13.0" + } + }, { "package": "secp256k1", "repositoryURL": "https://github.com/Boilertalk/secp256k1.swift", diff --git a/Package.swift b/Package.swift index 9639b587..42b97517 100644 --- a/Package.swift +++ b/Package.swift @@ -13,35 +13,50 @@ let package = Package( dependencies: [ .package(name: "BigInt", url: "https://github.com/attaswift/BigInt", from: "5.0.0"), .package(name: "GenericJSON", url: "https://github.com/zoul/generic-json-swift", from: "2.0.0"), - .package(name: "secp256k1", url: "https://github.com/Boilertalk/secp256k1.swift", from: "0.1.0") + .package(name: "secp256k1", url: "https://github.com/Boilertalk/secp256k1.swift", from: "0.1.0"), + .package(url: "https://github.com/OpenCombine/OpenCombine.git", from: "0.13.0") ], targets: [ - .target(name: "web3", - dependencies: - [.target(name: "keccaktiny"), - .target(name: "aes"), - .target(name: "Internal_CryptoSwift_PBDKF2"), - "BigInt", - "GenericJSON", - "secp256k1"], - path: "web3swift/src"), - .target(name: "keccaktiny", - dependencies: [], - path: "web3swift/lib/keccak-tiny", - exclude: ["module.map"]), - .target(name: "aes", - dependencies: [], - path: "web3swift/lib/aes", - exclude: ["module.map"]), - .target(name: "Internal_CryptoSwift_PBDKF2", - dependencies: [], - path: "web3swift/lib/CryptoSwift"), - .testTarget(name: "web3swiftTests", - dependencies: ["web3"], - path: "web3sTests", - resources: [ - .copy("Resources/rlptests.json"), - .copy("Account/cryptofights_712.json") - ]), + .target( + name: "web3", + dependencies: + [ + .target(name: "keccaktiny"), + .target(name: "aes"), + .target(name: "Internal_CryptoSwift_PBDKF2"), + "BigInt", + "GenericJSON", + "secp256k1", + "OpenCombine", + .product(name: "OpenCombineFoundation", package: "OpenCombine"), + ], + path: "web3swift/src" + ), + .target( + name: "keccaktiny", + dependencies: [], + path: "web3swift/lib/keccak-tiny", + exclude: ["module.map"] + ), + .target( + name: "aes", + dependencies: [], + path: "web3swift/lib/aes", + exclude: ["module.map"] + ), + .target( + name: "Internal_CryptoSwift_PBDKF2", + dependencies: [], + path: "web3swift/lib/CryptoSwift" + ), + .testTarget( + name: "web3swiftTests", + dependencies: ["web3"], + path: "web3sTests", + resources: [ + .copy("Resources/rlptests.json"), + .copy("Account/cryptofights_712.json") + ] + ), ] ) diff --git a/docker-run.sh b/docker-run.sh new file mode 100755 index 00000000..dd7a153a --- /dev/null +++ b/docker-run.sh @@ -0,0 +1,8 @@ +#/bin/bash + +docker run --rm --privileged \ + --interactive --tty \ + --name swift-5.5-bionic \ + --volume "$(pwd):/web3swift" \ + --workdir "/web3swift" \ + swift:latest /bin/bash \ No newline at end of file diff --git a/web3swift/src/Client/EthereumClient+Call.swift b/web3swift/src/Client/EthereumClient+Call.swift index a14e2644..0d130938 100644 --- a/web3swift/src/Client/EthereumClient+Call.swift +++ b/web3swift/src/Client/EthereumClient+Call.swift @@ -7,7 +7,15 @@ // import Foundation +#if canImport(Combine) import Combine +#else +import OpenCombine +import OpenCombineFoundation +#endif +#if canImport(FoundationNetworking) +import FoundationNetworking +#endif public enum OffchainReadError: Error { case network