Skip to content

Commit

Permalink
Merge remote-tracking branch 'pf/master' into feat/musl
Browse files Browse the repository at this point in the history
  • Loading branch information
YOU54F committed Feb 22, 2024
2 parents afaf864 + 09ee818 commit 118ff5b
Show file tree
Hide file tree
Showing 76 changed files with 807 additions and 333 deletions.
8 changes: 4 additions & 4 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ BUILD_TEST_TASK_TEMPLATE: &BUILD_TEST_TASK_TEMPLATE
linux_arm64_task:
arm_container:
image: mcr.microsoft.com/dotnet/sdk:7.0
image: mcr.microsoft.com/dotnet/sdk:8.0
<< : *BUILD_TEST_TASK_TEMPLATE

linux_amd64_task:
container:
image: mcr.microsoft.com/dotnet/sdk:7.0
image: mcr.microsoft.com/dotnet/sdk:8.0
<< : *BUILD_TEST_TASK_TEMPLATE

linux_arm64_alpine_task:
arm_container:
image: mcr.microsoft.com/dotnet/sdk:7.0-alpine
image: mcr.microsoft.com/dotnet/sdk:8.0-alpine
setup_alpine_script: apk add --no-cache curl bash gzip
# patch_cs_proj_script: |
# # cat src/PactNet/PactNet.csproj | grep musl
Expand All @@ -35,7 +35,7 @@ linux_arm64_alpine_task:

linux_amd64_alpine_task:
container:
image: mcr.microsoft.com/dotnet/sdk:7.0-alpine
image: mcr.microsoft.com/dotnet/sdk:8.0-alpine
setup_alpine_script: apk add --no-cache curl bash gzip
# patch_cs_proj_script: sed -Ei "s|x86_64\\\libpact_ffi.so|x86_64-musl\\\libpact_ffi.so|" src/PactNet/PactNet.csproj
<< : *BUILD_TEST_TASK_TEMPLATE
4 changes: 4 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
* text=auto

*.sh text eol=lf
*.sln text eol=crlf
32 changes: 32 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: bug, triage
assignees: ''

---

**Previous issues**
Have you searched the issue tracker to ensure this hasn't been discussed before?

**Version information:**
- OS: (e.g. MacOS ARM, Windows x64)
- PactNet Version:
- .Net Version:
- Pact Broker Version (if applicable):

**Describe the bug**
A clear and concise description of what the bug is.

**Steps To Reproduce**
Steps to reproduce the issue, including code snippets or preferably a link to a repository which reproduces the issue.

**Expected behavior**
A clear and concise description of what you expected to happen.

**Log Output**
Applicable log output. Please ensure you remove any sensitive information.

**Additional context**
Add any other context about the problem here.
29 changes: 29 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
name: Feature request
about: Suggest an idea for this project
title: 'RFC: <title>'
labels: triage
assignees: ''

---

**Previous issues**
Have you searched the issue tracker to ensure this hasn't been discussed before?

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Breaking Changes**
Does your proposed change include anything which would require a major version bump? If so, please detail them here. Please read the SemVer spec if you are unsure what this means.

**Potential Downsides/Caveats**
A clear and concise description of any downsides or caveats your change would introduce.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
41 changes: 25 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,35 +19,44 @@ jobs:
- ubuntu-latest
- macos-12
alpine: [false]
arch: ["x86_64"]
include:
- arch: x64
- arch: ARM64
os: macos-14
- os: ubuntu-latest
alpine: true
arch: x86_64
- os: ubuntu-latest
alpine: true
arch: aarch64
- os: macos-14
alpine: false
arch: aarch64

runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Setup .NET Core SDK
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
with:
dotnet-version: "7.0.x" # runners already have .Net Framework installed as well

dotnet-version: "8.0.x" # runners already have .Net Framework installed as well

- name: Cache FFI dependencies
id: cache
uses: actions/cache@v4
with:
key: cache-ffi-${{ hashFiles('build/download-native-libs.sh') }}
enableCrossOsArchive: true
path: |
build/linux
build/osx
build/windows
- name: Set up QEMU
if: matrix.alpine == true
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
if: matrix.alpine == true
uses: docker/setup-buildx-action@v3
- name: Pull interop dependencies
if: matrix.alpine != true
if: matrix.alpine != true && ${{ steps.cache.outputs.cache-hit != 'true' }}
run: bash -c "build/download-native-libs.sh"

- name: Restore
Expand All @@ -60,7 +69,7 @@ jobs:

- name: Test
if: matrix.alpine != true
run: dotnet test --no-build --verbosity normal
run: dotnet test --no-build --verbosity normal -- RunConfiguration.TargetPlatform=${{matrix.arch}}

# - name: Patch PactNet.csproj
# if: matrix.alpine == true
Expand All @@ -69,19 +78,19 @@ jobs:
- name: test linux amd64 musl
if: matrix.alpine == true && matrix.arch == 'x86_64'
run: |
docker run --platform=linux/amd64 --rm -v $PWD:/app mcr.microsoft.com/dotnet/sdk:7.0-alpine /bin/sh -c 'apk add --no-cache curl bash gzip && cd /app && build/download-native-libs.sh && dotnet restore && dotnet build --no-restore && dotnet test --no-build --verbosity normal'
docker run --platform=linux/amd64 --rm -v $PWD:/app mcr.microsoft.com/dotnet/sdk:8.0-alpine /bin/sh -c 'apk add --no-cache curl bash gzip && cd /app && build/download-native-libs.sh && dotnet restore && dotnet build --no-restore && dotnet test --no-build --verbosity normal'
- name: test linux arm64 musl
if: matrix.alpine == true && matrix.arch == 'aarch64'
run: |
docker run --platform=linux/arm64 --rm -v $PWD:/app mcr.microsoft.com/dotnet/sdk:7.0-alpine /bin/sh -c 'apk add --no-cache curl bash gzip && cd /app && build/download-native-libs.sh && dotnet restore && dotnet build --no-restore && dotnet test --no-build --verbosity normal'
docker run --platform=linux/arm64 --rm -v $PWD:/app mcr.microsoft.com/dotnet/sdk:8.0-alpine /bin/sh -c 'apk add --no-cache curl bash gzip && cd /app && build/download-native-libs.sh && dotnet restore && dotnet build --no-restore && dotnet test --no-build --verbosity normal'
- name: Pack
if: matrix.os == 'windows-latest'
run: dotnet pack --verbosity normal -c Release --no-restore --include-source --version-suffix alpha.${{ github.run_number }} -o ./dist

- name: Upload Artifact
if: matrix.os == 'windows-latest'
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: nupkgs
path: ./dist/*.*
Expand All @@ -91,12 +100,12 @@ jobs:
if: github.ref_type == 'tag'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Setup .NET Core
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
with:
dotnet-version: "7.0.x" # runners already have .Net Framework installed as well
dotnet-version: "8.0.x" # runners already have .Net Framework installed as well

- name: Pull interop dependencies
run: bash -c "build/download-native-libs.sh"
Expand Down
86 changes: 86 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
Contributing to PactNet
=======================

Raising Issues
--------------

Please don't raise issues for general queries (e.g. usage queries) and instead check the [Pact Docs] site or ask on the [Pact Foundation Slack].

Before raising any issues, please make as much effort as you can to rule out issues in your own environment as much as possible.
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:

- PactNet version
- Your operating system and version
- .Net version
- Log output
- Steps to reproduce and/or a repository link which reproduces the issue
- Expected outcome
- Actual outcome

Due to the way that PactNet works, often issues that are found are not in PactNet itself but instead in the [pact-reference]
native FFI libraries. If this is the case then an upstream issue will be raised in the FFI repository and PactNet will have to
wait until the fix is available in a new FFI release.

Raising Pull Requests
---------------------

For new contributors it is recommended that you start a discussion with a core maintainer prior to raising a PR. This
is for your own benefit so that you don't waste time implementing changes which don't align with the project in general
or will require significant changes afterwards.

The best way to achieve this is to open an issue detailing:

- The problem you see at the moment
- The solution you propose to fix this problem (e.g. adding a new feature, refactoring an existing API, etc)
- Any downsides you can foresee as a result of this change

If an issue already exists for the change you wish to contribute, please comment on the existing issue.

After raising your PR, a core maintainer will review your change and may request/suggest changes. Please take the
feedback in the spirit intended so that the PR can be merged as quickly as possible whilst still meeting established
conventions within the project such as architecture, code style, test style/coverage and API evolution.

In particular it is much harder to make any changes which involve a breaking change, so please set expectations accordingly
if your change requires a new major version. A large and/or potentially disruptive change should typically take the form of
an RFC issue.

A good example of an RFC issue preceding a major change is [PR 457].

Building PactNet
----------------

In order to build PactNet you must first download the native Rust FFI libraries. You can pull the current supported
version by executing the script in Bash (or Git Bash on Windows):

```bash
build/download-native-libs.sh
```

Alternatively you can download a particular FFI version from the [pact-referece] 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
```

After the native libraries are in the expected places then the solution can be built in your IDE or on the command
line using `dotnet build` as normal.

[pact-reference]: https://github.com/pact-foundation/pact-reference/releases
[Pact Docs]: https://docs.pact.io/
[Pact Foundation Slack]: https://pact-foundation.slack.com/
[PR 457]: https://github.com/pact-foundation/pact-net/issues/457
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ Due to using a shared native library instead of C# for the main Pact logic only
| Linux (libc) | x64 | ✔️ Yes |
| Linux (musl) | Any |[No](https://github.com/pact-foundation/pact-net/issues/374) |
| OSX | x64 | ✔️ Yes |
| OSX | ARM (M1/M2) | ⚠️ [Alpha](https://github.com/pact-foundation/pact-net/issues/451) |
| OSX | ARM (M1/M2) | ✔️ Yes |

### Pact Specification

Expand Down
5 changes: 3 additions & 2 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.16"
FFI_BASE_URL="https://github.com/you54f/pact-reference/releases/download/libpact_ffi-v$FFI_VERSION"
FFI_VERSION="0.4.17"
FFI_BASE_URL="https://github.com/pact-foundation/pact-reference/releases/download/libpact_ffi-v$FFI_VERSION"

GREEN="\e[32m"
YELLOW="\e[33m"
Expand Down Expand Up @@ -47,6 +47,7 @@ download_native() {
else
sed -Ei "s|../release_artifacts/.+$|$path/$dest_file|" "$path/$dest_file.sha256"
# sha256sum -c -s "$path/$dest_file.sha256"
sha256sum --check --quiet "$path/$dest_file.sha256"
fi

rm "$path/$dest_file.sha256"
Expand Down
21 changes: 9 additions & 12 deletions docs/messaging-pacts.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ types use two different names, for example "Stock Broker API" and "Stock Broker
Sample
------

See the [sample](../samples/Messaging/) for additional detail.
See the [sample](../samples/OrdersApi/) for additional detail.

Consumer Tests
--------------
Expand All @@ -26,24 +26,24 @@ In code, this is:
```csharp
public class StockEventProcessorTests
{
private readonly IMessagePactBuilderV3 messagePact;
private readonly IMessagePactBuilderV4 messagePact;

public StockEventProcessorTests(ITestOutputHelper output)
{
IPactV3 v3 = Pact.V3("Stock Event Consumer", "Stock Event Producer", new PactConfig
IPactV4 v4 = Pact.V4("Stock Event Consumer", "Stock Event Producer", new PactConfig
{
PactDir = "../../../pacts/",
DefaultJsonSettings = new JsonSerializerSettings
DefaultJsonSettings = new JsonSerializerOptions
{
ContractResolver = new CamelCasePropertyNamesContractResolver()
PropertyNamingPolicy = JsonNamingPolicy.CamelCase
},
Outputters = new[]
{
new XUnitOutput(output)
}
});

this.messagePact = v3.WithMessageInteractions();
this.messagePact = v4.WithMessageInteractions();
}

[Fact]
Expand Down Expand Up @@ -119,16 +119,13 @@ public class StockEventGeneratorTests : IDisposable
"pacts",
"Stock Event Consumer-Stock Event Producer.json");

var defaultSettings = new JsonSerializerSettings
var defaultSettings = new JsonSerializerOptions
{
ContractResolver = new CamelCasePropertyNamesContractResolver(),
DefaultValueHandling = DefaultValueHandling.Ignore,
NullValueHandling = NullValueHandling.Ignore,
Formatting = Formatting.Indented
PropertyNamingPolicy = JsonNamingPolicy.CamelCase
};

this.verifier
.MessagingProvider(scenarios =>
.WithMessages(scenarios =>
{
// register the responses to each interaction
// the descriptions must match those in the pact file(s)
Expand Down
Loading

0 comments on commit 118ff5b

Please sign in to comment.