Skip to content

Commit

Permalink
Merge branch 'master-pf' into feat/binary_matching
Browse files Browse the repository at this point in the history
  • Loading branch information
YOU54F committed Sep 24, 2024
2 parents 627111b + 8f98cb5 commit 98ca596
Show file tree
Hide file tree
Showing 17 changed files with 92 additions and 56 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
enableCrossOsArchive: true
path: |
build/linux
build/osx
build/macos
build/windows
- name: Set up QEMU
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ PactNet/Files/pact/
tools/
build/tools/
build/linux/
build/osx/
build/macos/
build/windows/
dist/

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
48 changes: 27 additions & 21 deletions build/download-native-libs.sh
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -20,64 +20,70 @@ 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"
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"
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System;

namespace PactNet.Exceptions
{
/// <summary>
/// Pact verification failed
/// </summary>
[Serializable]
public class PactVerificationFailedException : PactFailureException
{
/// <summary>
/// Initializes a new instance of the <see cref="PactVerificationFailedException" /> class
/// </summary>
public PactVerificationFailedException()
: this("The pact failed verification")
{
}

/// <summary>
/// Initializes a new instance of the <see cref="PactVerificationFailedException" /> class
/// </summary>
/// <param name="message">The message that describes the error</param>
public PactVerificationFailedException(string message) : base(message)
{
}

/// <summary>
/// Initializes a new instance of the <see cref="PactVerificationFailedException" /> class
/// </summary>
/// <param name="message">The error message that explains the reason for the exception</param>
/// <param name="innerException">The exception that is the cause of the current exception, or a null reference (Nothing in Visual Basic) if no inner exception is specified</param>
public PactVerificationFailedException(string message, Exception innerException) : base(message, innerException)
{
}
}
}
4 changes: 2 additions & 2 deletions src/PactNet/PactNet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@
<CopyToOutputDirectory Condition="'$(IsLinuxMuslArm64)' == 'True'">PreserveNewest</CopyToOutputDirectory>
<Visible>false</Visible>
</Content>
<Content Include="$(MSBuildProjectDirectory)\..\..\build\osx\x86_64\libpact_ffi.dylib">
<Content Include="$(MSBuildProjectDirectory)\..\..\build\macos\x86_64\libpact_ffi.dylib">
<Link>libpact_ffi.dylib</Link>
<PackagePath>runtimes/osx-x64/native</PackagePath>
<Pack>true</Pack>
<CopyToOutputDirectory Condition="'$(IsOSX)' == 'True' And '$(IsArm64)' == 'False'">PreserveNewest</CopyToOutputDirectory>
<Visible>false</Visible>
</Content>
<Content Include="$(MSBuildProjectDirectory)\..\..\build\osx\aarch64-apple-darwin\libpact_ffi.dylib">
<Content Include="$(MSBuildProjectDirectory)\..\..\build\macos\aarch64\libpact_ffi.dylib">
<Link>libpact_ffi.dylib</Link>
<PackagePath>runtimes/osx-arm64/native</PackagePath>
<Pack>true</Pack>
Expand Down
2 changes: 1 addition & 1 deletion src/PactNet/Verifier/InteropVerifierProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
};
Expand Down
4 changes: 2 additions & 2 deletions tests/PactNet.Tests/Verifier/InteropVerifierProviderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public void HappyPathIntegrationTest()

Action action = () => provider.Execute();

action.Should().Throw<PactFailureException>();
action.Should().Throw<PactVerificationFailedException>();
}

[Fact]
Expand All @@ -73,7 +73,7 @@ public void SetPublishOptions_NoBuildUri_IsValid()

Action action = () => provider.Execute();

action.Should().Throw<PactFailureException>();
action.Should().Throw<PactVerificationFailedException>();
}
}
}
4 changes: 2 additions & 2 deletions tests/PactNet.Tests/data/v2-consumer-integration.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
8 changes: 3 additions & 5 deletions tests/PactNet.Tests/data/v3-consumer-integration.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,7 @@
}
]
}
},
"header": {},
"query": {}
}
},
"method": "POST",
"path": "/things",
Expand Down Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions tests/PactNet.Tests/data/v3-message-consumer-integration.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions tests/PactNet.Tests/data/v3-message-integration.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions tests/PactNet.Tests/data/v3-server-integration.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
8 changes: 3 additions & 5 deletions tests/PactNet.Tests/data/v4-combined-integration.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,7 @@
}
]
}
},
"header": {},
"query": {}
}
},
"method": "POST",
"path": "/things",
Expand Down Expand Up @@ -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"
Expand Down
8 changes: 3 additions & 5 deletions tests/PactNet.Tests/data/v4-consumer-integration.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,7 @@
}
]
}
},
"header": {},
"query": {}
}
},
"method": "POST",
"path": "/things",
Expand Down Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions tests/PactNet.Tests/data/v4-message-consumer-integration.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 98ca596

Please sign in to comment.