diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 448b4503..993650f3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,25 +4,12 @@ on: push: branches: - 'main' - - 'chore/**' - - 'docs/**' - - 'feat/**' - - 'feature/**' - - 'fix/**' - - 'refactor/**' - - 'releases/**' - - 'style/**' - - 'test/**' - - 'tech/**' - -env: - RUST_TARGET_PATH: pact-reference jobs: test: - name: Run ${{ matrix.platform }} on ${{ matrix.host }} + name: "๐Ÿค– Test macOS" runs-on: ${{ matrix.host }} - + strategy: fail-fast: true matrix: @@ -31,14 +18,14 @@ jobs: include: - platform: ios scheme: "PactSwift-iOS" - destination: "platform=iOS Simulator,name=iPhone 14 Pro" + destination: "platform=iOS Simulator,name=iPhone 12 Pro" - platform: macos scheme: "PactSwift-macOS" destination: "arch=x86_64" - - host: macos-12 - xcode: 13.4.1 - host: macos-13 - xcode: 14.3.1 + xcode: 15.0 + - host: macos-12 + xcode: 14.1 env: SCHEME: ${{ matrix.scheme }} @@ -49,32 +36,31 @@ jobs: cancel-in-progress: true steps: - - name: Checkout repository - uses: actions/checkout@v2 + - name: "๐Ÿง‘โ€๐Ÿ’ป Checkout repository" + uses: actions/checkout@v3 - - name: Use Xcode ${{ matrix.xcode }} - run: sudo xcode-select -switch /Applications/Xcode_${{ matrix.xcode }}.app + - name: "๐Ÿญ Use Xcode ${{ matrix.XCODE_VERSION }}" + run: sudo xcode-select -switch /Applications/Xcode_${{ matrix.XCODE_VERSION }}.app - - name: Prepare Tools + - name: "๐Ÿงฐ Prepare tools" run: | Scripts/prepare_build_tools - - name: Run tests (Xcode) + - name: "๐Ÿงช Run tests (xcodebuild)" run: | - set -o pipefail && xcodebuild clean test -project PactSwift.xcodeproj -scheme "$SCHEME" -destination "$DESTINATION" GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=YES GCC_GENERATE_TEST_COVERAGE_FILES=YES | xcbeautify + set -o pipefail && xcodebuild -resolvePackageDependencies && xcodebuild clean test -project PactSwift.xcodeproj -scheme "$SCHEME" -destination "$DESTINATION" GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=YES GCC_GENERATE_TEST_COVERAGE_FILES=YES | xcbeautify - - name: Run tests (CLI - Swift Package) + - name: "โš—๏ธ Run tests (swift)" run: | - swift build - swift test -c release + set -o pipefail && swift test -c release after_success: needs: [test] - name: Build demo projects + name: "๐Ÿšš Build demo projects" if: github.ref == 'refs/heads/main' runs-on: ubuntu-latest steps: - - name: Build demo projects + - name: "๐Ÿšš Build demo projects" run: | curl -X POST https://api.github.com/repos/surpher/pact-swift-examples/dispatches -H 'Accept: application/vnd.github.everest-preview+json' -u ${{ secrets.PACT_SWIFT_TOKEN }} --data '{"event_type":"PactSwift - ${{ github.event.head_commit.message }}"}' diff --git a/.github/workflows/build_pr.yml b/.github/workflows/build_pr.yml index 49186297..d55b28dd 100644 --- a/.github/workflows/build_pr.yml +++ b/.github/workflows/build_pr.yml @@ -1,48 +1,86 @@ -name: Build PR +name: Build Pull Request on: pull_request: branches: - - 'main' - -env: - RUST_TARGET_PATH: pact-reference + - '!main' jobs: - test: - name: Run ${{ matrix.platform }} on ${{ matrix.host }} - runs-on: ${{ matrix.host }} - - strategy: - fail-fast: true - matrix: - host: [macos-12, macos-13] - platform: [ios, macos] - include: - - platform: ios - scheme: "PactSwift-iOS" - destination: "platform=iOS Simulator,name=iPhone 14 Pro" - - platform: macos - scheme: "PactSwift-macOS" - destination: "arch=x86_64" + test_macos: + name: "๐Ÿค– Test macOS" + runs-on: macos-13 env: - SCHEME: ${{ matrix.scheme }} - DESTINATION: ${{ matrix.destination }} + XCODE_VERSION: 14.3.1 + + concurrency: + group: test_macos13_darwin_$SCHEME_${{ github.ref }} + cancel-in-progress: true steps: - - name: Checkout repository - uses: actions/checkout@v2 + - name: "๐Ÿง‘โ€๐Ÿ’ป Checkout repository" + uses: actions/checkout@v3 + + - name: "โš™๏ธ Use Xcode ${{ env.XCODE_VERSION }}" + run: sudo xcode-select -switch /Applications/Xcode_${{ env.XCODE_VERSION }}.app - - name: Prepare Tools + - name: "๐Ÿงฐ Prepare tools" run: | Scripts/prepare_build_tools - - name: Run tests (Xcode) + - name: "๐Ÿงช xcodebuild clean test" run: | - set -o pipefail && xcodebuild clean test -project PactSwift.xcodeproj -scheme "$SCHEME" -destination "$DESTINATION" GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=YES GCC_GENERATE_TEST_COVERAGE_FILES=YES | xcbeautify + set -o pipefail && xcodebuild -resolvePackageDependencies | xcbeautify && xcodebuild clean test -project PactSwift.xcodeproj -scheme "PactSwift-macOS" -destination "arch=x86_64" | xcbeautify - - name: Run tests (CLI - Swift Package) + - name: "โš—๏ธ swift test" + run: | + set -o pipefail && swift test -c release + + test_ios: + name: "๐Ÿค– Test iOS" + runs-on: macos-13 + needs: [test_macos] + + env: + SCHEME: "PactSwift-iOS" + DESTINATION: "platform=iOS Simulator,name=iPhone 14 Pro" + XCODE_VERSION: 14.3.1 + + concurrency: + group: test_macos13_ios_$SCHEME_${{ github.ref }} + cancel-in-progress: true + + steps: + - name: "๐Ÿง‘โ€๐Ÿ’ป Checkout repository" + uses: actions/checkout@v3 + + - name: "โš™๏ธ Use Xcode ${{ env.XCODE_VERSION }}" + run: sudo xcode-select -switch /Applications/Xcode_${{ env.XCODE_VERSION }}.app + + - name: "๐Ÿงฐ Prepare tools" + run: | + Scripts/prepare_build_tools + + - name: "โ™˜ Test for Carthage" + run: | + set -o pipefail && carthage build --no-skip-current --use-xcframeworks + + - name: "๐Ÿงช xcodebuild clean test" + run: | + set -o pipefail && xcodebuild -resolvePackageDependencies | xcbeautify && xcodebuild clean test -project PactSwift.xcodeproj -scheme "PactSwift-iOS" -destination "platform=iOS Simulator,name=iPhone 14 Pro" | xcbeautify + + - name: "โš—๏ธ swift test" run: | - swift build swift test -c release + + after_success: + needs: [test_ios] + name: "๐Ÿšš Build demo projects" + if: github.ref == 'refs/heads/main' + runs-on: ubuntu-latest + + steps: + - name: "๐Ÿšš Build demo projects" + run: | + curl -X POST https://api.github.com/repos/surpher/pact-swift-examples/dispatches -H 'Accept: application/vnd.github.everest-preview+json' -u ${{ secrets.PACT_SWIFT_TOKEN }} --data '{"event_type":"PactSwift - ${{ github.event.head_commit.message }}"}' + \ No newline at end of file diff --git a/Package.resolved b/Package.resolved index c3eff9de..5ec94528 100644 --- a/Package.resolved +++ b/Package.resolved @@ -1,14 +1,16 @@ { - "pins" : [ - { - "identity" : "pactswiftserver", - "kind" : "remoteSourceControl", - "location" : "https://github.com/surpher/PactSwiftServer.git", - "state" : { - "revision" : "a122b04c7ba2f420f256b0657e67ff97ce933279", - "version" : "0.4.7" + "object": { + "pins": [ + { + "package": "PactSwiftMockServer", + "repositoryURL": "https://github.com/surpher/PactSwiftServer.git", + "state": { + "branch": null, + "revision": "12ecc92092ecd3640dcc2dcb98ce6b3d1f2d76f7", + "version": "0.4.7" + } } - } - ], - "version" : 2 + ] + }, + "version": 1 } diff --git a/Package.swift b/Package.swift index 051e9df7..77705d08 100644 --- a/Package.swift +++ b/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:5.8 +// swift-tools-version:5.3 import PackageDescription @@ -19,7 +19,7 @@ let package = Package( ], dependencies: [ - .package(url: "https://github.com/surpher/PactSwiftServer.git", exact: "0.4.7") + .package(url: "https://github.com/surpher/PactSwiftServer.git", .exact("0.4.7")) ], targets: [ diff --git a/PactSwift.xcodeproj/project.pbxproj b/PactSwift.xcodeproj/project.pbxproj index f9623511..4a1d102b 100644 --- a/PactSwift.xcodeproj/project.pbxproj +++ b/PactSwift.xcodeproj/project.pbxproj @@ -125,6 +125,7 @@ AD92805626BE3361004FAA7E /* String+PactSwiftTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD92805426BE3361004FAA7E /* String+PactSwiftTests.swift */; }; AD92805826BE3705004FAA7E /* TransferProtocolTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD92805726BE3705004FAA7E /* TransferProtocolTests.swift */; }; AD92805926BE3705004FAA7E /* TransferProtocolTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD92805726BE3705004FAA7E /* TransferProtocolTests.swift */; }; + AD92E18F2A7DE6E7005C70E5 /* PactSwiftMockServer in Frameworks */ = {isa = PBXBuildFile; productRef = AD92E18E2A7DE6E7005C70E5 /* PactSwiftMockServer */; }; AD957F3228A23A2300860AD1 /* Logger.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD957F3128A23A2300860AD1 /* Logger.swift */; }; AD957F3328A23A2300860AD1 /* Logger.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD957F3128A23A2300860AD1 /* Logger.swift */; }; AD9D7D8D26C8AD3400FE4137 /* ProviderStateGenerator.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD9D7D8C26C8AD3400FE4137 /* ProviderStateGenerator.swift */; }; @@ -185,8 +186,6 @@ ADC3AA38247C8C4B0034446E /* InteractionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = ADC3AA36247C8C4B0034446E /* InteractionTests.swift */; }; ADC3AA3D247CBB550034446E /* IncludesLikeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = ADC3AA3C247CBB550034446E /* IncludesLikeTests.swift */; }; ADC3AA3E247CBB550034446E /* IncludesLikeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = ADC3AA3C247CBB550034446E /* IncludesLikeTests.swift */; }; - ADC50E272A7D2A7B004E1E03 /* PactSwiftMockServer in Frameworks */ = {isa = PBXBuildFile; productRef = ADC50E262A7D2A7B004E1E03 /* PactSwiftMockServer */; }; - ADC50E2B2A7D2D7E004E1E03 /* PactSwiftMockServer in Frameworks */ = {isa = PBXBuildFile; productRef = ADC50E2A2A7D2D7E004E1E03 /* PactSwiftMockServer */; }; ADD0315F2512193500C6099B /* ExampleGeneratorExpressible.swift in Sources */ = {isa = PBXBuildFile; fileRef = ADD0315E2512193500C6099B /* ExampleGeneratorExpressible.swift */; }; ADD031602512193500C6099B /* ExampleGeneratorExpressible.swift in Sources */ = {isa = PBXBuildFile; fileRef = ADD0315E2512193500C6099B /* ExampleGeneratorExpressible.swift */; }; ADD03164251219B700C6099B /* ExampleGenerator.swift in Sources */ = {isa = PBXBuildFile; fileRef = ADD03163251219B700C6099B /* ExampleGenerator.swift */; }; @@ -241,6 +240,7 @@ ADF959CB26C8F6EB00C35536 /* FromProviderStateTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = ADF959C926C8F6EB00C35536 /* FromProviderStateTests.swift */; }; ADF959CD26C8F98800C35536 /* ProviderStateGeneratorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = ADF959CC26C8F98800C35536 /* ProviderStateGeneratorTests.swift */; }; ADF959CE26C8F98800C35536 /* ProviderStateGeneratorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = ADF959CC26C8F98800C35536 /* ProviderStateGeneratorTests.swift */; }; + ADF994CE2A7DE1720011D974 /* PactSwiftMockServer in Frameworks */ = {isa = PBXBuildFile; productRef = ADF994CD2A7DE1720011D974 /* PactSwiftMockServer */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -410,6 +410,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + ADF994CE2A7DE1720011D974 /* PactSwiftMockServer in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -418,7 +419,6 @@ buildActionMask = 2147483647; files = ( AD881808242C715B00BF510D /* PactSwift.framework in Frameworks */, - ADC50E272A7D2A7B004E1E03 /* PactSwiftMockServer in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -426,6 +426,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + AD92E18F2A7DE6E7005C70E5 /* PactSwiftMockServer in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -434,7 +435,6 @@ buildActionMask = 2147483647; files = ( AD8FC7C02463A06F00361854 /* PactSwift.framework in Frameworks */, - ADC50E2B2A7D2D7E004E1E03 /* PactSwiftMockServer in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -791,6 +791,7 @@ ); name = PactSwift_iOS; packageProductDependencies = ( + ADF994CD2A7DE1720011D974 /* PactSwiftMockServer */, ); productName = PACTSwift; productReference = AD8817FE242C715A00BF510D /* PactSwift.framework */; @@ -812,7 +813,6 @@ ); name = PactSwiftTests_iOS; packageProductDependencies = ( - ADC50E262A7D2A7B004E1E03 /* PactSwiftMockServer */, ); productName = PACTSwiftTests; productReference = AD881807242C715B00BF510D /* PactSwiftTests_iOS.xctest */; @@ -836,6 +836,7 @@ ); name = PactSwift_macOS; packageProductDependencies = ( + AD92E18E2A7DE6E7005C70E5 /* PactSwiftMockServer */, ); productName = PactSwift_macOS; productReference = AD8FC7B72463A06F00361854 /* PactSwift.framework */; @@ -856,7 +857,6 @@ ); name = PactSwiftTests_macOS; packageProductDependencies = ( - ADC50E2A2A7D2D7E004E1E03 /* PactSwiftMockServer */, ); productName = PactSwift_macOSTests; productReference = AD8FC7BF2463A06F00361854 /* PactSwiftTests_macOS.xctest */; @@ -898,7 +898,7 @@ ); mainGroup = AD8817F4242C715A00BF510D; packageReferences = ( - ADC50E252A7D2A7B004E1E03 /* XCRemoteSwiftPackageReference "PactSwiftServer" */, + ADF994CC2A7DE1720011D974 /* XCRemoteSwiftPackageReference "PactSwiftServer" */, ); productRefGroup = AD8817FF242C715A00BF510D /* Products */; projectDirPath = ""; @@ -1475,7 +1475,7 @@ /* End XCConfigurationList section */ /* Begin XCRemoteSwiftPackageReference section */ - ADC50E252A7D2A7B004E1E03 /* XCRemoteSwiftPackageReference "PactSwiftServer" */ = { + ADF994CC2A7DE1720011D974 /* XCRemoteSwiftPackageReference "PactSwiftServer" */ = { isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/surpher/PactSwiftServer.git"; requirement = { @@ -1486,14 +1486,14 @@ /* End XCRemoteSwiftPackageReference section */ /* Begin XCSwiftPackageProductDependency section */ - ADC50E262A7D2A7B004E1E03 /* PactSwiftMockServer */ = { + AD92E18E2A7DE6E7005C70E5 /* PactSwiftMockServer */ = { isa = XCSwiftPackageProductDependency; - package = ADC50E252A7D2A7B004E1E03 /* XCRemoteSwiftPackageReference "PactSwiftServer" */; + package = ADF994CC2A7DE1720011D974 /* XCRemoteSwiftPackageReference "PactSwiftServer" */; productName = PactSwiftMockServer; }; - ADC50E2A2A7D2D7E004E1E03 /* PactSwiftMockServer */ = { + ADF994CD2A7DE1720011D974 /* PactSwiftMockServer */ = { isa = XCSwiftPackageProductDependency; - package = ADC50E252A7D2A7B004E1E03 /* XCRemoteSwiftPackageReference "PactSwiftServer" */; + package = ADF994CC2A7DE1720011D974 /* XCRemoteSwiftPackageReference "PactSwiftServer" */; productName = PactSwiftMockServer; }; /* End XCSwiftPackageProductDependency section */ diff --git a/Scripts/build_rust_dependencies b/Scripts/build_rust_dependencies deleted file mode 100755 index f208cc32..00000000 --- a/Scripts/build_rust_dependencies +++ /dev/null @@ -1,101 +0,0 @@ -#!/usr/bin/env bash - -set -e pipefail - -PRODUCT_NAME="PactSwift" -WORKSPACE=${GITHUB_WORKSPACE:-$PWD} -LIBPACT_FFI_DIR="${WORKSPACE}/../pact-reference/rust/pact_ffi" -LIBPACT_PRODUCT_DIR="${WORKSPACE}/../pact-reference/rust/target/debug" -CI=${CI:-"false"} -PACT_FOUNDATION_REPO="https://github.com/pact-foundation/pact-reference.git" - -####################### -# Pre-requisite # -####################### - -if [ ! -d "$PWD/$PRODUCT_NAME.xcodeproj" ] -then - echo "๐Ÿšจ Run this from the same folder where your '$PRODUCT_NAME.xcodeproj' lives." - echo "โš ๏ธ You are runing it in $PWD" - exit 1 -fi - -####################### -# If CI # -####################### - -echo "๐Ÿ‘ฎโ€โ™€๏ธ Verifying project and dependencies' folder setup..." - -if [[ "$CI" == true ]]; then - echo "โ„น๏ธ Adding submodule ${PACT_FOUNDATION_REPO}" - if [ ! -d "$PWD/pact-reference"]; then - git submodule add $PACT_FOUNDATION_REPO - fi - git submodule update --init - cd pact-reference/rust/pact_ffi -elif [ ! -d "$PWD/../pact-reference" ]; then - echo "๐Ÿšจ Missing pact-foundation/pact-reference repo." - echo "โš ๏ธ Make sure you 'git clone ${PACT_FOUNDATION_REPO}' at the same folder level as your $PRODUCT_NAME." - exit 1 -else - echo "๐Ÿ‘ Project setup seems to be in order." - echo "โ„น๏ธ Changing location to ${LIBPACT_FFI_DIR}" - cd $LIBPACT_FFI_DIR -fi - -####################### -# Setup # -####################### - -# Validate dependencies - -echo "๐Ÿ‘ฎโ€โ™€๏ธ Checking if Rust is installed..." -if which cargo >/dev/null; then - echo "๐Ÿ‘ cargo installed" -elif command -v ~/.cargo/bin/cargo &> /dev/null; then - echo "๐Ÿ‘ cargo installed in ~/.cargo/bin/" -else - echo "๐Ÿšจ Rust/Cargo not installed" - echo "ERROR: cargo is required and is was found on this machine. See https://www.rust-lang.org/tools/install" - exit 1 -fi - -############################################## -# Build libpact_ffi libraries # -############################################## - -# Using debug build flag (or not providing it), otherwise libpact_ffi.so must be moved into /usr/local/lib/ -echo "๐Ÿ— Building libpact_ffi for current platform (debug build)" -cargo build -echo "โœ… libpact_ffi built" - -echo "โ„น๏ธ Setting LD_LIBRARY_PATH to include $LIBPACT_PRODUCT_DIR" -if [[ "$CI" == true ]]; then - export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:${WORKSPACE}/pact-reference/rust/target/debug" -else - export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${LIBPACT_PRODUCT_DIR}" -fi - -####################### -# Cleanup # -####################### - -echo "โ„น๏ธ Changing directory back to ${WORKSPACE}" -cd ${WORKSPACE} - -############################################################################################################## -# Run Swift buld and test # -# https://github.com/apple/swift-package-manager/blob/main/Documentation/Usage.md#requiring-system-libraries # -############################################################################################################## - -echo "โ„น๏ธ Running swift build:" -swift build -Xlinker -L$LIBPACT_PRODUCT_DIR - -echo "โ„น๏ธ Running swift test with -Xlinker -L$LIBPACT_PRODUCT_DIR" - -if [[ "$CI" == true ]]; then - BIN_PATH="${WORKSPACE}/pact-reference/rust/target/debug" - swift test -Xlinker -L$BIN_PATH -else - swift test -Xlinker -L$LIBPACT_PRODUCT_DIR -fi diff --git a/Scripts/check_build_tools b/Scripts/check_build_tools index 1c605c49..3e05dc37 100755 --- a/Scripts/check_build_tools +++ b/Scripts/check_build_tools @@ -11,13 +11,6 @@ else echo "warning: SwiftLint not installed, use 'brew install swiftlint' to install it." fi -if which carthage >/dev/null; then - echo "๐Ÿ‘ carthage installed" -else - echo "โš ๏ธ carthage" - echo "warning: carthage not installed, use 'brew install carthage' to install it." -fi - # Checking for xcbeautify if which xcbeautify >/dev/null; then echo "๐Ÿ‘ xcbeautify installed" diff --git a/Scripts/prepare_build_tools b/Scripts/prepare_build_tools index 68ab1ea2..38b8c310 100755 --- a/Scripts/prepare_build_tools +++ b/Scripts/prepare_build_tools @@ -1,6 +1,5 @@ #!/usr/bin/env bash -brew install rust brew tap thii/xcbeautify https://github.com/thii/xcbeautify.git brew install xcbeautify diff --git a/Scripts/run_tests b/Scripts/run_tests index bdbc8ca7..ee84865c 100755 --- a/Scripts/run_tests +++ b/Scripts/run_tests @@ -4,7 +4,7 @@ set -eu set -o pipefail # Overridable Environment -SIMULATOR_NAME=${SIMULATOR_NAME:-'iPhone 12 Pro'} +SIMULATOR_NAME=${SIMULATOR_NAME:-'iPhone 14 Pro'} SCRIPTS_DIR="${BASH_SOURCE[0]%/*}" # Determine architecture of current machine @@ -28,10 +28,10 @@ echo "โ„น๏ธ Resolving package dependencies" xcodebuild -resolvePackageDependencies echo "๐Ÿ— Building" -swift build +swift build | xcbeautify echo "๐Ÿค– Running tests" -swift test +swift test | xcbeautify # Run iOS tests echo "๐Ÿ“ฑ Running iOS tests"