diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8bb76ee6..936ebe25 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -58,7 +58,7 @@ jobs: enableCrossOsArchive: true path: | build/linux - build/osx + build/macos build/windows - name: Set up QEMU diff --git a/.gitignore b/.gitignore index 1b0b07fa..9cc9bc67 100644 --- a/.gitignore +++ b/.gitignore @@ -55,7 +55,7 @@ PactNet/Files/pact/ tools/ build/tools/ build/linux/ -build/osx/ +build/macos/ build/windows/ dist/ diff --git a/README.md b/README.md index 7870d381..85c0eb75 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ Watch our [series](https://www.youtube.com/playlist?list=PLwy9Bnco-IpfZ72VQ7hce8 ### Tutorial (60 minutes) -[Learn everything in Pact Net in 60 minutes](https://github.com/DiUS/pact-workshop-dotnet-core-v3/) +[Learn everything in Pact Net in 60 minutes](https://github.com/pact-foundation/pact-workshop-dotnet) ### Upgrade Guides diff --git a/build/download-native-libs.sh b/build/download-native-libs.sh index d654b7d1..04d51d7a 100755 --- a/build/download-native-libs.sh +++ b/build/download-native-libs.sh @@ -1,8 +1,8 @@ #!/usr/bin/env bash set -euo pipefail -FFI_VERSION="0.4.22" -FFI_BASE_URL="https://github.com/you54f/pact-reference/releases/download/libpact_ffi-v$FFI_VERSION" +FFI_VERSION="0.4.23" +FFI_BASE_URL="https://github.com/pact-foundation/pact-reference/releases/download/libpact_ffi-v$FFI_VERSION" GREEN="\e[32m" YELLOW="\e[33m" @@ -20,58 +20,62 @@ download_native() { # e.g. # pact_ffi-windows-x86_64.dll.gz # libpact_ffi-linux-x86_64.so.gz - # libpact_ffi-osx-x86_64.dylib.gz - src_file="$file-$os-$platform.$extension.gz" - url="$FFI_BASE_URL/$src_file" + # libpact_ffi-macos-x86_64.dylib.gz + src_file="$file-$os-$platform.$extension" + src_archive="$src_file.gz" + src_sha="$src_archive.sha256" + dest_file="$file.$extension" + url="$FFI_BASE_URL/$src_archive" sha="$url.sha256" path="$base_path/$os/$platform" - dest_file="$file.$extension.gz" mkdir -p "$path" + pushd $path > /dev/null echo -e "Downloading FFI library for ${YELLOW}$os/$platform${CLEAR}" - echo -e " Destination: ${BLUE}$path/$dest_file${CLEAR}" + echo -e " Destination: ${BLUE}$path/$src_archive${CLEAR}" echo -e " URL: ${BLUE}$url${CLEAR}" echo -n " Downloading... " - curl --silent -L "$url" -o "$path/$dest_file" - curl --silent -L "$sha" -o "$path/$dest_file.sha256" + curl --silent -L "$url" -o "$src_archive" + curl --silent -L "$sha" -o "$src_archive.sha256" echo -e "${GREEN}OK${CLEAR}" echo -n " Verifying... " if [[ "$OSTYPE" == "darwin"* ]]; then - # OSX requires an empty arg passed to -i, but this doesn't work on Lin/Win - sed -Ei '' "s|\*(.*)$|\*$path/$dest_file|" "$path/$dest_file.sha256" - shasum -a 256 --check --quiet "$path/$dest_file.sha256" + shasum -a 256 --check --quiet "$src_sha" else - sed -Ei "s|\*(.*)$|\*$path/$dest_file|" "$path/$dest_file.sha256" if [[ "$OSTYPE" == "linux"* ]]; then if ldd /bin/ls >/dev/null 2>&1; then ldd_output=$(ldd /bin/ls) case "$ldd_output" in *musl*) - sha256sum -c -s "$path/$dest_file.sha256" + sha256sum -c -s "$src_sha" ;; *) - sha256sum --check --quiet "$path/$dest_file.sha256" + sha256sum --check --quiet "$src_sha" ;; esac else - sha256sum --check --quiet "$path/$dest_file.sha256" + sha256sum --check --quiet "$src_sha" fi else - sha256sum --check --quiet "$path/$dest_file.sha256" + sha256sum --check --quiet "$src_sha" fi fi - rm "$path/$dest_file.sha256" echo -e "${GREEN}OK${CLEAR}" echo -n " Extracting... " - gunzip -f "$path/$dest_file" + gunzip -f "$src_archive" echo -e "${GREEN}OK${CLEAR}" echo "" + + mv "$src_file" "$dest_file" + rm "$src_sha" + + popd > /dev/null } download_native "pact_ffi" "windows" "x86_64" "dll" @@ -79,5 +83,7 @@ download_native "libpact_ffi" "linux" "x86_64" "so" download_native "libpact_ffi" "linux" "aarch64" "so" download_native "libpact_ffi" "linux" "x86_64-musl" "so" download_native "libpact_ffi" "linux" "aarch64-musl" "so" -download_native "libpact_ffi" "osx" "x86_64" "dylib" -download_native "libpact_ffi" "osx" "aarch64-apple-darwin" "dylib" +download_native "libpact_ffi" "macos" "x86_64" "dylib" +download_native "libpact_ffi" "macos" "aarch64" "dylib" + +echo "Successfully downloaded FFI libraries" diff --git a/samples/OrdersApi/Consumer.Tests/pacts/Fulfilment API-Orders API.json b/samples/OrdersApi/Consumer.Tests/pacts/Fulfilment API-Orders API.json index 00079231..3296cc2a 100644 --- a/samples/OrdersApi/Consumer.Tests/pacts/Fulfilment API-Orders API.json +++ b/samples/OrdersApi/Consumer.Tests/pacts/Fulfilment API-Orders API.json @@ -199,8 +199,8 @@ ], "metadata": { "pactRust": { - "ffi": "0.4.21", - "models": "1.2.0" + "ffi": "0.4.23", + "models": "1.2.5" }, "pactSpecification": { "version": "4.0" diff --git a/src/PactNet.Abstractions/Exceptions/PactVerificationFailedException.cs b/src/PactNet.Abstractions/Exceptions/PactVerificationFailedException.cs new file mode 100644 index 00000000..63daa057 --- /dev/null +++ b/src/PactNet.Abstractions/Exceptions/PactVerificationFailedException.cs @@ -0,0 +1,36 @@ +using System; + +namespace PactNet.Exceptions +{ + /// + /// Pact verification failed + /// + [Serializable] + public class PactVerificationFailedException : PactFailureException + { + /// + /// Initializes a new instance of the class + /// + public PactVerificationFailedException() + : this("The pact failed verification") + { + } + + /// + /// Initializes a new instance of the class + /// + /// The message that describes the error + public PactVerificationFailedException(string message) : base(message) + { + } + + /// + /// Initializes a new instance of the class + /// + /// The error message that explains the reason for the exception + /// The exception that is the cause of the current exception, or a null reference (Nothing in Visual Basic) if no inner exception is specified + public PactVerificationFailedException(string message, Exception innerException) : base(message, innerException) + { + } + } +} diff --git a/src/PactNet/PactNet.csproj b/src/PactNet/PactNet.csproj index 9a67c967..7fce90b1 100644 --- a/src/PactNet/PactNet.csproj +++ b/src/PactNet/PactNet.csproj @@ -60,14 +60,14 @@ PreserveNewest false - + libpact_ffi.dylib runtimes/osx-x64/native true PreserveNewest false - + libpact_ffi.dylib runtimes/osx-arm64/native true diff --git a/src/PactNet/Verifier/InteropVerifierProvider.cs b/src/PactNet/Verifier/InteropVerifierProvider.cs index a30a5b34..c0245296 100644 --- a/src/PactNet/Verifier/InteropVerifierProvider.cs +++ b/src/PactNet/Verifier/InteropVerifierProvider.cs @@ -235,7 +235,7 @@ public void Execute() string error = result switch { - 1 => "Pact verification failed", + 1 => throw new PactVerificationFailedException("Pact verification failed"), 2 => "Failed to run the verification", _ => $"An unknown error occurred: {result}" }; diff --git a/tests/PactNet.Tests/Verifier/InteropVerifierProviderTests.cs b/tests/PactNet.Tests/Verifier/InteropVerifierProviderTests.cs index 5a8d5088..91d4b023 100644 --- a/tests/PactNet.Tests/Verifier/InteropVerifierProviderTests.cs +++ b/tests/PactNet.Tests/Verifier/InteropVerifierProviderTests.cs @@ -53,7 +53,7 @@ public void HappyPathIntegrationTest() Action action = () => provider.Execute(); - action.Should().Throw(); + action.Should().Throw(); } [Fact] @@ -73,7 +73,7 @@ public void SetPublishOptions_NoBuildUri_IsValid() Action action = () => provider.Execute(); - action.Should().Throw(); + action.Should().Throw(); } } } diff --git a/tests/PactNet.Tests/data/v2-consumer-integration.json b/tests/PactNet.Tests/data/v2-consumer-integration.json index 2d38dcef..27a97e44 100644 --- a/tests/PactNet.Tests/data/v2-consumer-integration.json +++ b/tests/PactNet.Tests/data/v2-consumer-integration.json @@ -74,8 +74,8 @@ ], "metadata": { "pactRust": { - "ffi": "0.4.21", - "models": "1.2.0" + "ffi": "0.4.23", + "models": "1.2.5" }, "pactSpecification": { "version": "2.0.0" diff --git a/tests/PactNet.Tests/data/v3-consumer-integration.json b/tests/PactNet.Tests/data/v3-consumer-integration.json index fe699d08..fbdb566e 100644 --- a/tests/PactNet.Tests/data/v3-consumer-integration.json +++ b/tests/PactNet.Tests/data/v3-consumer-integration.json @@ -96,9 +96,7 @@ } ] } - }, - "header": {}, - "query": {} + } }, "method": "POST", "path": "/things", @@ -132,8 +130,8 @@ ], "metadata": { "pactRust": { - "ffi": "0.4.21", - "models": "1.2.0" + "ffi": "0.4.23", + "models": "1.2.5" }, "pactSpecification": { "version": "3.0.0" diff --git a/tests/PactNet.Tests/data/v3-message-consumer-integration.json b/tests/PactNet.Tests/data/v3-message-consumer-integration.json index be660b0d..2819d19c 100644 --- a/tests/PactNet.Tests/data/v3-message-consumer-integration.json +++ b/tests/PactNet.Tests/data/v3-message-consumer-integration.json @@ -36,8 +36,8 @@ "language": "C#" }, "pactRust": { - "ffi": "0.4.21", - "models": "1.2.0" + "ffi": "0.4.23", + "models": "1.2.5" }, "pactSpecification": { "version": "3.0.0" diff --git a/tests/PactNet.Tests/data/v3-message-integration.json b/tests/PactNet.Tests/data/v3-message-integration.json index b2ed0dab..783a6cf0 100644 --- a/tests/PactNet.Tests/data/v3-message-integration.json +++ b/tests/PactNet.Tests/data/v3-message-integration.json @@ -16,8 +16,8 @@ ], "metadata": { "pactRust": { - "ffi": "0.4.21", - "models": "1.2.0" + "ffi": "0.4.23", + "models": "1.2.5" }, "pactSpecification": { "version": "3.0.0" diff --git a/tests/PactNet.Tests/data/v3-server-integration.json b/tests/PactNet.Tests/data/v3-server-integration.json index b2652df8..e1e23302 100644 --- a/tests/PactNet.Tests/data/v3-server-integration.json +++ b/tests/PactNet.Tests/data/v3-server-integration.json @@ -46,8 +46,8 @@ ], "metadata": { "pactRust": { - "ffi": "0.4.21", - "models": "1.2.0" + "ffi": "0.4.23", + "models": "1.2.5" }, "pactSpecification": { "version": "3.0.0" diff --git a/tests/PactNet.Tests/data/v4-combined-integration.json b/tests/PactNet.Tests/data/v4-combined-integration.json index db795d37..ee46b3f3 100644 --- a/tests/PactNet.Tests/data/v4-combined-integration.json +++ b/tests/PactNet.Tests/data/v4-combined-integration.json @@ -106,9 +106,7 @@ } ] } - }, - "header": {}, - "query": {} + } }, "method": "POST", "path": "/things", @@ -187,8 +185,8 @@ "language": "C#" }, "pactRust": { - "ffi": "0.4.21", - "models": "1.2.0" + "ffi": "0.4.23", + "models": "1.2.5" }, "pactSpecification": { "version": "4.0" diff --git a/tests/PactNet.Tests/data/v4-consumer-integration.json b/tests/PactNet.Tests/data/v4-consumer-integration.json index 8ae7ea04..d706aebe 100644 --- a/tests/PactNet.Tests/data/v4-consumer-integration.json +++ b/tests/PactNet.Tests/data/v4-consumer-integration.json @@ -106,9 +106,7 @@ } ] } - }, - "header": {}, - "query": {} + } }, "method": "POST", "path": "/things", @@ -152,8 +150,8 @@ ], "metadata": { "pactRust": { - "ffi": "0.4.21", - "models": "1.2.0" + "ffi": "0.4.23", + "models": "1.2.5" }, "pactSpecification": { "version": "4.0" diff --git a/tests/PactNet.Tests/data/v4-message-consumer-integration.json b/tests/PactNet.Tests/data/v4-message-consumer-integration.json index 5b83ed5b..6dc2bd5e 100644 --- a/tests/PactNet.Tests/data/v4-message-consumer-integration.json +++ b/tests/PactNet.Tests/data/v4-message-consumer-integration.json @@ -41,8 +41,8 @@ "language": "C#" }, "pactRust": { - "ffi": "0.4.21", - "models": "1.2.0" + "ffi": "0.4.23", + "models": "1.2.5" }, "pactSpecification": { "version": "4.0"