Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add linux-musl-x64 runtime support #497

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# directories
**/bin/
**/obj/
**/out/

# files
Dockerfile*
**/*.trx
**/*.md
**/*.ps1
**/*.cmd
**/*.sh
29 changes: 15 additions & 14 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Before raising any issues, please make as much effort as you can to rule out iss
For example, if you are using a self-hosted Pact Broker instance and PactNet is failing to connect, please ensure things like the
authentication token and SSL certificate are valid.

If you are sure that the issye is with PactNet then please raise an issue, including as many of the following details as you can:
If you are sure that the issue is with PactNet then please raise an issue, including as many of the following details as you can:

- PactNet version
- Your operating system and version
Expand Down Expand Up @@ -59,22 +59,23 @@ version by executing the script in Bash (or Git Bash on Windows):
build/download-native-libs.sh
```

Alternatively you can download a particular FFI version from the [pact-referece] releases or build your own version
Alternatively you can download a particular FFI version from the [pact-reference] releases or build your own version
locally, and then copy the artifacts into the folders:

```
build/
linux/
x86_64/
libpact_ffi.so
osx/
aarch64-apple-darwin/
libpact_ffi.dylib
x86_64/
libpact_ffi.dylib
windows/
x86_64/
pact_ffi.dll
├── linux
│ ├── x86_64
│ │ └── libpact_ffi.so
│ └── x86_64-musl
│ └── libpact_ffi.so
├── osx
│ ├── aarch64-apple-darwin
│ │ └── libpact_ffi.dylib
│ └── x86_64
│ └── libpact_ffi.dylib
└── windows
└── x86_64
└── pact_ffi.dll
```

After the native libraries are in the expected places then the solution can be built in your IDE or on the command
Expand Down
8 changes: 8 additions & 0 deletions Dockerfile.alpine
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM mcr.microsoft.com/dotnet/sdk:8.0-alpine
WORKDIR /home/app

COPY packages packages
COPY samples samples

RUN dotnet test samples/OrdersApi/Consumer.Tests/Consumer.Tests.csproj
RUN dotnet test samples/OrdersApi/Provider.Tests/Provider.Tests.csproj
10 changes: 10 additions & 0 deletions Dockerfile.debian
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM mcr.microsoft.com/dotnet/sdk:8.0-bookworm-slim
WORKDIR /home/app

RUN apt-get update && apt-get install tree

COPY packages packages
COPY samples samples

RUN dotnet test samples/OrdersApi/Consumer.Tests/Consumer.Tests.csproj
RUN dotnet test samples/OrdersApi/Provider.Tests/Provider.Tests.csproj
429 changes: 252 additions & 177 deletions PactNet.sln

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions build/download-native-libs.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash
set -euo pipefail

FFI_VERSION="0.4.16"
FFI_VERSION="0.4.19"
FFI_BASE_URL="https://github.com/pact-foundation/pact-reference/releases/download/libpact_ffi-v$FFI_VERSION"

GREEN="\e[32m"
Expand Down Expand Up @@ -42,10 +42,10 @@ download_native() {

if [[ "$OSTYPE" == "darwin"* ]]; then
# OSX requires an empty arg passed to -i, but this doesn't work on Lin/Win
sed -Ei '' "s|../release_artifacts/.+$|$path/$dest_file|" "$path/$dest_file.sha256"
sed -Ei '' "s|\s+.+$|\ *$path/$dest_file|" "$path/$dest_file.sha256"
shasum -a 256 --check --quiet "$path/$dest_file.sha256"
else
sed -Ei "s|../release_artifacts/.+$|$path/$dest_file|" "$path/$dest_file.sha256"
sed -Ei "s|\s+.+$|\ *$path/$dest_file|" "$path/$dest_file.sha256"
sha256sum --check --quiet "$path/$dest_file.sha256"
fi

Expand All @@ -60,5 +60,6 @@ download_native() {

download_native "pact_ffi" "windows" "x86_64" "dll"
download_native "libpact_ffi" "linux" "x86_64" "so"
download_native "libpact_ffi" "linux" "x86_64-musl" "so"
download_native "libpact_ffi" "osx" "x86_64" "dylib"
download_native "libpact_ffi" "osx" "aarch64-apple-darwin" "dylib"
10 changes: 10 additions & 0 deletions pack.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash

dotnet pack src/PactNet.Output.Xunit
dotnet pack src/PactNet.Abstractions
dotnet pack src/PactNet.runtime.linux-musl-x64
dotnet pack src/PactNet.runtime.linux-x64
dotnet pack src/PactNet.runtime.osx-arm64
dotnet pack src/PactNet.runtime.osx-x64
dotnet pack src/PactNet.runtime.win-x64
dotnet pack src/PactNet
5 changes: 3 additions & 2 deletions samples/OrdersApi/Consumer.Tests/Consumer.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<IsPackable>false</IsPackable>
<RestoreAdditionalProjectSources>../../../packages</RestoreAdditionalProjectSources>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="FluentAssertions" Version="6.12.0" />
Expand All @@ -12,10 +13,10 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="PactNet" Version="5.1.0" />
<PackageReference Include="PactNet.Output.Xunit" Version="1.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\src\PactNet.Output.Xunit\PactNet.Output.Xunit.csproj" />
<ProjectReference Include="..\..\..\src\PactNet\PactNet.csproj" />
<ProjectReference Include="..\Consumer\Consumer.csproj" />
</ItemGroup>
<ItemGroup>
Expand Down
5 changes: 3 additions & 2 deletions samples/OrdersApi/Provider.Tests/Provider.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<IsPackable>false</IsPackable>
<RestoreAdditionalProjectSources>../../../packages</RestoreAdditionalProjectSources>
</PropertyGroup>

<ItemGroup>
Expand All @@ -11,11 +12,11 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="PactNet" Version="5.1.0" />
<PackageReference Include="PactNet.Output.Xunit" Version="1.0.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\src\PactNet.Output.Xunit\PactNet.Output.Xunit.csproj" />
<ProjectReference Include="..\..\..\src\PactNet\PactNet.csproj" />
<ProjectReference Include="..\Provider\Provider.csproj" />
</ItemGroup>

Expand Down
13 changes: 3 additions & 10 deletions src/NuGet.targets
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,10 @@
<DebugSymbols>true</DebugSymbols>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<VersionPrefix>5.0.0</VersionPrefix>
<VersionPrefix>5.1.0</VersionPrefix>
<PackageReleaseNotes>
v5.0.0
- BREAKING CHANGE: Remove obsolete WithNativeBackend calls
- BREAKING CHANGE: Remove obsolete IMessagePact and MessagePact
- BREAKING CHANGE: Refactor verifier to support verifying combined HTTP and message pacts
- BREAKING CHANGE: Replace Newtonsoft with System.Text.Json
- BREAKING CHANGE: Minimum supported .Net Framework version is now 4.6.2 instead of 4.6.1
- feat: Add Pact Specification v4 support
- feat: MacOS ARM64 target is now fully supported
- feat: More efficient and robust messaging interaction verification
v5.1.0
- feat: Add linux-musl-x64 runtime support
</PackageReleaseNotes>
</PropertyGroup>
<PropertyGroup Condition="'$(GITHUB_ACTIONS)' == 'true'">
Expand Down
1 change: 1 addition & 0 deletions src/PactNet.Abstractions/PactNet.Abstractions.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<NoWarn>CS1591;NU5105</NoWarn>
<OutputType>Library</OutputType>
<RootNamespace>PactNet</RootNamespace>
<PackageOutputPath>../../packages</PackageOutputPath>
</PropertyGroup>

<Import Project="../NuGet.targets" />
Expand Down
1 change: 1 addition & 0 deletions src/PactNet.Output.Xunit/PactNet.Output.Xunit.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<NoWarn>CS1591;NU5105</NoWarn>
<OutputType>Library</OutputType>
<PackageOutputPath>../../packages</PackageOutputPath>
</PropertyGroup>

<Import Project="../NuGet.targets" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFramework>netstandard2.0</TargetFramework>
<RuntimeIdentifier>linux-musl-x64</RuntimeIdentifier>
<PackageId>PactNet.runtime.linux-musl-x64</PackageId>
<Version>0.4.19</Version>
<PackageTags>native</PackageTags>
<PackageOutputPath>../../packages</PackageOutputPath>
<IncludeBuildOutput>false</IncludeBuildOutput>
</PropertyGroup>

<ItemGroup>
<Content Include="$(MSBuildProjectDirectory)/../../build/linux/x86_64-musl/libpact_ffi.so">
<PackagePath>runtimes/linux-musl-x64/native</PackagePath>
<Pack>true</Pack>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
</Project>
21 changes: 21 additions & 0 deletions src/PactNet.runtime.linux-x64/PactNet.runtime.linux-x64.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFramework>netstandard2.0</TargetFramework>
<RuntimeIdentifier>linux-x64</RuntimeIdentifier>
<PackageId>PactNet.runtime.linux-x64</PackageId>
<Version>0.4.19</Version>
<PackageTags>native</PackageTags>
<PackageOutputPath>../../packages</PackageOutputPath>
<IncludeBuildOutput>false</IncludeBuildOutput>
</PropertyGroup>

<ItemGroup>
<Content Include="$(MSBuildProjectDirectory)/../../build/linux/x86_64/libpact_ffi.so">
<PackagePath>runtimes/linux-x64/native</PackagePath>
<Pack>true</Pack>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
</Project>
21 changes: 21 additions & 0 deletions src/PactNet.runtime.osx-arm64/PactNet.runtime.osx-arm64.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFramework>netstandard2.0</TargetFramework>
<RuntimeIdentifier>osx-arm64</RuntimeIdentifier>
<PackageId>PactNet.runtime.osx-arm64</PackageId>
<Version>0.4.19</Version>
<PackageTags>native</PackageTags>
<PackageOutputPath>../../packages</PackageOutputPath>
<IncludeBuildOutput>false</IncludeBuildOutput>
</PropertyGroup>

<ItemGroup>
<Content Include="$(MSBuildProjectDirectory)/../../build/osx/aarch64-apple-darwin/libpact_ffi.dylib">
<PackagePath>runtimes/osx-arm64/native</PackagePath>
<Pack>true</Pack>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
</Project>
21 changes: 21 additions & 0 deletions src/PactNet.runtime.osx-x64/PactNet.runtime.osx-x64.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFramework>netstandard2.0</TargetFramework>
<RuntimeIdentifier>osx-x64</RuntimeIdentifier>
<PackageId>PactNet.runtime.osx-x64</PackageId>
<Version>0.4.19</Version>
<PackageTags>native</PackageTags>
<PackageOutputPath>../../packages</PackageOutputPath>
<IncludeBuildOutput>false</IncludeBuildOutput>
</PropertyGroup>

<ItemGroup>
<Content Include="$(MSBuildProjectDirectory)/../../build/osx/x86_64/libpact_ffi.dylib">
<PackagePath>runtimes/osx-x64/native</PackagePath>
<Pack>true</Pack>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
</Project>
21 changes: 21 additions & 0 deletions src/PactNet.runtime.win-x64/PactNet.runtime.win-x64.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFramework>netstandard2.0</TargetFramework>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<PackageId>PactNet.runtime.win-x64</PackageId>
<Version>0.4.19</Version>
<PackageTags>native</PackageTags>
<PackageOutputPath>../../packages</PackageOutputPath>
<IncludeBuildOutput>false</IncludeBuildOutput>
</PropertyGroup>

<ItemGroup>
<Content Include="$(MSBuildProjectDirectory)/../../build/windows/x86_64/pact_ffi.dll">
<PackagePath>runtimes/win-x64/native</PackagePath>
<Pack>true</Pack>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
</Project>
52 changes: 13 additions & 39 deletions src/PactNet/PactNet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,50 +6,24 @@
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<NoWarn>NU5105</NoWarn>
<OutputType>Library</OutputType>
<RestoreAdditionalProjectSources>../../packages</RestoreAdditionalProjectSources>
<PackageOutputPath>../../packages</PackageOutputPath>
</PropertyGroup>

<Import Project="../NuGet.targets" />

<PropertyGroup>
<IsWindows>False</IsWindows>
<IsLinux>False</IsLinux>
<IsOSX>False</IsOSX>
<IsArm64>False</IsArm64>
<IsWindows Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Windows)))' == 'True'">True</IsWindows>
<IsLinux Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'True'">True</IsLinux>
<IsOSX Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::OSX)))' == 'True'">True</IsOSX>
<IsArm64 Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)' == 'Arm64'">True</IsArm64>
</PropertyGroup>

<ItemGroup>
<Content Include="$(MSBuildProjectDirectory)\..\..\build\windows\x86_64\pact_ffi.dll">
<Link>pact_ffi.dll</Link>
<PackagePath>runtimes/win-x64/native</PackagePath>
<Pack>true</Pack>
<CopyToOutputDirectory Condition="'$(IsWindows)'">PreserveNewest</CopyToOutputDirectory>
<Visible>false</Visible>
</Content>
<Content Include="$(MSBuildProjectDirectory)\..\..\build\linux\x86_64\libpact_ffi.so">
<Link>libpact_ffi.so</Link>
<PackagePath>runtimes/linux-x64/native</PackagePath>
<Pack>true</Pack>
<CopyToOutputDirectory Condition="'$(IsLinux)'">PreserveNewest</CopyToOutputDirectory>
<Visible>false</Visible>
</Content>
<Content Include="$(MSBuildProjectDirectory)\..\..\build\osx\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">
<Link>libpact_ffi.dylib</Link>
<PackagePath>runtimes/osx-arm64/native</PackagePath>
<Pack>true</Pack>
<CopyToOutputDirectory Condition="'$(IsOSX)' == 'True' And '$(IsArm64)' == 'True'">PreserveNewest</CopyToOutputDirectory>
<Visible>false</Visible>
</Content>
<RuntimeLinuxMusl Include="../../packages/PactNet.runtime.linux-musl-x64.*.nupkg"/>
<RuntimeLinux Include="../../packages/PactNet.runtime.linux-x64.*.nupkg"/>
<RuntimeOsxArm Include="../../packages/PactNet.runtime.osx-arm64.*.nupkg"/>
<RuntimeOsx Include="../../packages/PactNet.runtime.osx-x64.*.nupkg"/>
<RuntimeWin Include="../../packages/PactNet.runtime.win-x64.*.nupkg"/>

<PackageReference Include="PactNet.runtime.linux-musl-x64" Version="0.4.19" Condition="Exists('@(RuntimeLinuxMusl)')"/>
<PackageReference Include="PactNet.runtime.linux-x64" Version="0.4.19" Condition="Exists('@(RuntimeLinux)')"/>
<PackageReference Include="PactNet.runtime.osx-arm64" Version="0.4.19" Condition="Exists('@(RuntimeOsxArm)')"/>
<PackageReference Include="PactNet.runtime.osx-x64" Version="0.4.19" Condition="Exists('@(RuntimeOsx)')"/>
<PackageReference Include="PactNet.runtime.win-x64" Version="0.4.19" Condition="Exists('@(RuntimeWin)')"/>
</ItemGroup>

<ItemGroup>
Expand Down