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

Build using traversal project #1344

Merged
merged 5 commits into from
May 3, 2023
Merged
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
4 changes: 2 additions & 2 deletions .ci/gha-run-tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ Write-Host "[INFO] Setting RABBITMQ_RABBITMQCTL_PATH to '$rabbitmqctl_path'..."
$env:RABBITMQ_RABBITMQCTL_PATH = $rabbitmqctl_path
[Environment]::SetEnvironmentVariable('RABBITMQ_RABBITMQCTL_PATH', $rabbitmqctl_path, 'Machine')

$solution_file = Join-Path -Path $env:GITHUB_WORKSPACE -ChildPath 'RabbitMQDotNetClient.sln'
dotnet test --no-restore --no-build --logger "console;verbosity=detailed" $solution_file
$build_csproj_file = Join-Path -Path $env:GITHUB_WORKSPACE -ChildPath 'Build.csproj'
dotnet test $build_csproj_file --no-restore --no-build --logger "console;verbosity=detailed"
4 changes: 2 additions & 2 deletions .ci/versions.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"erlang": "25.3",
"rabbitmq": "3.11.11"
"erlang": "25.3.1",
"rabbitmq": "3.11.15"
}
16 changes: 9 additions & 7 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,11 @@ jobs:
- name: List NuGet sources
run: dotnet nuget locals all --list
- name: Restore
run: dotnet restore --verbosity=normal
run: dotnet restore ./Build.csproj --verbosity=normal
- name: Build
run: dotnet build --no-restore --verbosity=normal
run: dotnet build ./Build.csproj --no-restore --verbosity=normal
- name: Verify
run: dotnet format ./RabbitMQDotNetClient.sln --no-restore --verbosity=diagnostic --verify-no-changes
- name: Test
run: ./.ci/gha-run-tests.ps1

Expand Down Expand Up @@ -79,12 +81,12 @@ jobs:
restore-keys: |
${{ runner.os }}-v0-nuget-
- name: Restore
run: dotnet restore --verbosity=normal
run: dotnet restore ./Build.csproj --verbosity=normal
- name: Build
run: dotnet build --no-restore --verbosity=normal
run: dotnet build ./Build.csproj --no-restore --verbosity=normal
- name: Verify
run: dotnet format ./RabbitMQDotNetClient.sln --no-restore --verbosity=diagnostic --verify-no-changes
- name: Test
run: dotnet test --no-restore --no-build --logger "console;verbosity=detailed" --framework "net6.0"
run: dotnet test ./Build.csproj --no-restore --no-build --logger "console;verbosity=detailed" --framework "net6.0"
env:
RABBITMQ_RABBITMQCTL_PATH: DOCKER:${{job.services.rabbitmq.id}}
- name: Verify Formatting
run: dotnet format --verbosity normal --no-restore --verify-no-changes
2 changes: 1 addition & 1 deletion APIDOCS.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pushd _site
git remote add origin-ssh git@github.com:rabbitmq/rabbitmq-dotnet-client.git
git checkout --track origin-ssh/gh-pages
popd
.\build.bat
.\build.ps1 -RunTests:$false
docfx.exe
pushd _site
git commit -a -m 'rabbitmq-dotnet-client docs vX.Y.Z'
Expand Down
16 changes: 16 additions & 0 deletions Build.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<Project Sdk="Microsoft.Build.Traversal/3.2.0">

<PropertyGroup>
<IsPackable>false</IsPackable>
<MinVerSkip>true</MinVerSkip>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="projects/Benchmarks/Benchmarks.csproj" />
<ProjectReference Include="projects/RabbitMQ.Client/RabbitMQ.Client.csproj" />
<ProjectReference Include="projects/TestApplications/CreateChannel/CreateChannel.csproj" />
<ProjectReference Include="projects/TestApplications/MassPublish/MassPublish.csproj" />
<ProjectReference Include="projects/Unit/Unit.csproj" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ Benchmarks can be found under `./projects/Benchmarks`. On the command line, run
like so:

```
dotnet run -c Release -f netcoreapp5.0 --project ./projects/Benchmarks/ --filter Networking_BasicDeliver_LongLivedConnection
dotnet run -c Release -f net6.0 --project ./projects/Benchmarks/ --filter Networking_BasicDeliver_LongLivedConnection
```

## Code of Conduct
Expand Down
65 changes: 35 additions & 30 deletions RUNNING_TESTS.md
Original file line number Diff line number Diff line change
@@ -1,43 +1,42 @@
## Overview
# Overview

.NET client's test suite assumes there's a RabbitMQ node listening on `localhost:5672`
(the default settings). TLS tests require a node listening on the default
[TLS port](https://rabbitmq.com/ssl.html).
The RabbitMQ .NET client's test suite assumes there's a RabbitMQ node listening
on `localhost:5672` (the default settings). TLS tests require a node listening
on the default [TLS port](https://rabbitmq.com/ssl.html).

It is possible to use Visual Studio Community Edition .NET Core, and
`dotnet.exe` in `PATH`, to build the client and run the test suite.
It is possible to use Visual Studio Community Edition and `dotnet.exe` in
`PATH`, to build the client and run the test suite.


## Building

Before this project can be opened in Visual Studio, it's necessary to pull down dependencies
and perform protocol encoder/decoder code generation.

On Windows run:
### Windows

``` powershell
build.bat
```powershell
build.ps1
```

On MacOS and linux run:
### MacOS and Linux

``` shell
./build.sh
```shell
dotnet build ./Build.csproj
```

This will complete the code AMQP 0-9-1 protocol code generation and build all projects. After this open the solution in Visual Studio.
This will build all projects. After this open the solution in Visual Studio.


## Test Environment Requirements

Tests can be run from Visual Studio using the NUnit Test Adapter. Note that it
Tests can be run from Visual Studio using the XUnit Test Adapter. Note that it
may take some time for the adapter to discover tests in the assemblies.

The test suite assumes there's a RabbitMQ node running locally with all
defaults, and the tests will need to be able to run commands against the
[`rabbitmqctl`](https://www.rabbitmq.com/rabbitmqctl.8.html) tool for that node.
Two options to accomplish this are covered below.


### Option One: Using a RabbitMQ Release

It is possible to install and run a node using any [binary build](https://www.rabbitmq.com/download.html)
Expand All @@ -46,16 +45,16 @@ invoked directly without using an absolute file path. Note that this method does

On Windows, you must run unit tests as follows (replace `X.Y.Z` with your RabbitMQ version):

```
set "RABBITMQ_RABBITMQCTL_PATH=C:\Program Files\RabbitMQ Server\rabbitmq_server-X.Y.Z\sbin\rabbitmqctl.bat"
.\run-test.bat
```powershell
$env:RABBITMQ_RABBITMQCTL_PATH='C:\Program Files\RabbitMQ Server\rabbitmq_server-X.Y.Z\sbin\rabbitmqctl.bat'
.\build.ps1 -RunTests
```

### Option Two: Building a RabbitMQ Node from Source

T run a RabbitMQ node [built from source](https://www.rabbitmq.com/build-server.html):

```
```shell
git clone https://github.com/rabbitmq/rabbitmq-server.git rabbitmq-server
cd rabbitmq-server

Expand All @@ -77,26 +76,32 @@ RABBITMQ_RABBITMQCTL_PATH=/path/to/rabbitmqctl dotnet test projects/Unit

### Option Three: Using a Docker Container

It is also possible to run a RabbitMQ node in a [Docker](https://www.docker.com/) container. Set the environment variable `RABBITMQ_RABBITMQCTL_PATH` to `DOCKER:<container_name>` (for example `DOCKER:rabbitmq01`). This tells the unit tests to run the `rabbitmqctl` commands through Docker, in the format `docker exec rabbitmq01 rabbitmqctl <args>`:
It is also possible to run a RabbitMQ node in a
[Docker](https://www.docker.com/) container. Set the environment variable
`RABBITMQ_RABBITMQCTL_PATH` to `DOCKER:<container_name>` (for example
`DOCKER:rabbitmq01`). This tells the unit tests to run the `rabbitmqctl`
commands through Docker, in the format `docker exec rabbitmq01 rabbitmqctl
<args>`:

``` shell
```shell
docker run -d --hostname rabbitmq01 --name rabbitmq01 -p 15672:15672 -p 5672:5672 rabbitmq:3-management
```

## Running All Tests

Then, to run the tests use:

``` powershell
# will run tests on .NET Core and .NET Framework
run-test.bat

### Windows

```powershell
build.ps1 -RunTests
```

On MacOS, Linux, BSD use:
### MacOS, Linux, BSD:

``` shell
# will only run tests on .NET Core
run-test.sh
```shell
dotnet test ./Build.csproj
```

## Running Individual Suites or Test Cases
Expand All @@ -115,5 +120,5 @@ dotnet test projects/Unit --filter "FullyQualifiedName~RabbitMQ.Client.Unit.Test
To run tests targeting .NET 6.0:

``` shell
dotnet test -f ".net6.0" projects/Unit
dotnet test --framework net6.0 projects/Unit
```
4 changes: 0 additions & 4 deletions build.bat

This file was deleted.

25 changes: 25 additions & 0 deletions build.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[CmdletBinding(PositionalBinding=$false)]
param(
[switch]$RunTests
)

Write-Host "Run Parameters:" -ForegroundColor Cyan
Write-Host "`tPSScriptRoot: $PSScriptRoot"
Write-Host "`tRunTests: $RunTests"
Write-Host "`tdotnet --version: $(dotnet --version)"

Write-Host "Building all projects (Build.csproj traversal)..." -ForegroundColor "Magenta"
dotnet build "$PSScriptRoot\Build.csproj"
Write-Host "Done building." -ForegroundColor "Green"

if ($RunTests) {
Write-Host "Running tests: Build.csproj traversal (all frameworks)" -ForegroundColor "Magenta"
dotnet test "$PSScriptRoot\Build.csproj" --no-restore --no-build --logger "console;verbosity=detailed"
if ($LastExitCode -ne 0) {
Write-Host "Error with tests, aborting build." -Foreground "Red"
Exit 1
}
Write-Host "Tests passed!" -ForegroundColor "Green"
}

Write-Host "Done."
17 changes: 0 additions & 17 deletions build.sh

This file was deleted.

5 changes: 5 additions & 0 deletions global.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"sdk": {
"allowPrerelease": false
}
}
3 changes: 0 additions & 3 deletions run-test.bat

This file was deleted.

16 changes: 0 additions & 16 deletions run-test.sh

This file was deleted.