diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml
new file mode 100644
index 0000000000..c843abb2d5
--- /dev/null
+++ b/.github/workflows/main.yaml
@@ -0,0 +1,88 @@
+name: rabbitmq-dotnet-client
+
+on:
+ push:
+ branches: [ main ]
+ pull_request:
+ branches: [ main ]
+
+jobs:
+ build-win32:
+ name: build/test on windows-latest
+
+ runs-on: windows-latest
+
+ steps:
+ - name: Clone repository
+ uses: actions/checkout@v2
+ with:
+ submodules: true
+ - name: Setup .NET
+ uses: actions/setup-dotnet@v1
+ with:
+ dotnet-version: 3.1.x
+ - name: Cache installers
+ uses: actions/cache@v2
+ with:
+ # Note: the cache path is relative to the workspace directory
+ # https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#using-the-cache-action
+ path: ~/installers
+ key: ${{ runner.os }}-v0-${{ hashFiles('tools/versions.json') }}
+ - name: Cache NuGet packages
+ uses: actions/cache@v2
+ with:
+ path: |
+ ~/.nuget/packages
+ ~/AppData/Local/NuGet/v3-cache
+ key: ${{ runner.os }}-v0-nuget-${{ hashFiles('**/*.csproj') }}
+ restore-keys: |
+ ${{ runner.os }}-v0-nuget-
+ - name: Install and start RabbitMQ
+ run: ./tools/install.ps1
+ - name: List NuGet sources
+ run: dotnet nuget locals all --list
+ - name: Restore
+ run: dotnet restore --verbosity=normal
+ - name: Build
+ run: dotnet build --no-restore --verbosity=normal
+ - name: Test
+ run: ./tools/gha-run-tests.ps1
+
+ build:
+ name: build/test on ubuntu-latest
+
+ runs-on: ubuntu-latest
+
+ services:
+ rabbitmq:
+ image: rabbitmq:3.9-management
+ ports:
+ - 5672:5672
+ - 15672:15672
+
+ steps:
+ - name: Clone repository
+ uses: actions/checkout@v2
+ with:
+ submodules: true
+ - name: Setup .NET
+ uses: actions/setup-dotnet@v1
+ with:
+ dotnet-version: 3.1.x
+ - name: Cache NuGet packages
+ uses: actions/cache@v2
+ with:
+ path: |
+ ~/.nuget/packages
+ ~/.local/share/NuGet/v3-cache
+ key: ${{ runner.os }}-v0-nuget-${{ hashFiles('**/*.csproj') }}
+ restore-keys: |
+ ${{ runner.os }}-v0-nuget-
+ - name: Restore
+ run: dotnet restore --verbosity=normal
+ - name: Build
+ run: dotnet build --no-restore --verbosity=normal
+ - name: Test
+ run: dotnet test --no-build --logger "console;verbosity=detailed"
+ env:
+ RABBITMQ_RABBITMQCTL_PATH: DOCKER:${{job.services.rabbitmq.id}}
diff --git a/.github/workflows/test-linux.yml b/.github/workflows/test-linux.yml
deleted file mode 100644
index 4263ec96ac..0000000000
--- a/.github/workflows/test-linux.yml
+++ /dev/null
@@ -1,34 +0,0 @@
-name: Build (Linux)
-
-on:
- push:
- branches: [ master ]
- pull_request:
- branches: [ master ]
-
-jobs:
- build:
- runs-on: ubuntu-latest
-
- services:
- rabbitmq:
- image: rabbitmq:3.8.9-management
- ports:
- - 5672:5672
- - 15672:15672
-
- steps:
- - uses: actions/checkout@v2
-
- - name: Setup .NET Core
- uses: actions/setup-dotnet@v1
- with:
- dotnet-version: 3.1.x
-
- - name: Build
- run: dotnet build --configuration Release
-
- - name: Test
- run: dotnet test --configuration Release --framework 'netcoreapp3.1' --no-build --logger:'console;verbosity=normal'
- env:
- RABBITMQ_RABBITMQCTL_PATH: DOCKER:${{job.services.rabbitmq.id}}
diff --git a/build.bat b/build.bat
index add2a96ff9..9f1ed2e2ae 100644
--- a/build.bat
+++ b/build.bat
@@ -1,4 +1,4 @@
@ECHO OFF
set DOTNET_CLI_TELEMETRY_OPTOUT=1
-dotnet restore .\RabbitMQDotNetClient.sln
-dotnet build .\RabbitMQDotNetClient.sln
+dotnet restore --verbosity=normal .\RabbitMQDotNetClient.sln
+dotnet build --verbosity=normal .\RabbitMQDotNetClient.sln
diff --git a/projects/RabbitMQ.Client/client/api/BasicGetResult.cs b/projects/RabbitMQ.Client/client/api/BasicGetResult.cs
index 04dfa7f07e..fc79fa6f06 100644
--- a/projects/RabbitMQ.Client/client/api/BasicGetResult.cs
+++ b/projects/RabbitMQ.Client/client/api/BasicGetResult.cs
@@ -130,7 +130,7 @@ public BasicGetResult(ulong deliveryTag, bool redelivered, string exchange, stri
///
public void Dispose()
{
- if (_rentedArray is not null)
+ if (_rentedArray != null)
{
ArrayPool.Shared.Return(_rentedArray);
}
diff --git a/projects/RabbitMQ.Client/client/impl/AutorecoveringConnection.Recovery.cs b/projects/RabbitMQ.Client/client/impl/AutorecoveringConnection.Recovery.cs
index d285c4f385..e7e5ac3ec2 100644
--- a/projects/RabbitMQ.Client/client/impl/AutorecoveringConnection.Recovery.cs
+++ b/projects/RabbitMQ.Client/client/impl/AutorecoveringConnection.Recovery.cs
@@ -114,7 +114,9 @@ private void StopRecoveryLoop()
private static void HandleTopologyRecoveryException(TopologyRecoveryException e)
{
ESLog.Error("Topology recovery exception", e);
- if (e.InnerException is AlreadyClosedException or OperationInterruptedException or TimeoutException)
+ if (e.InnerException is AlreadyClosedException ||
+ (e.InnerException is OperationInterruptedException) ||
+ (e.InnerException is TimeoutException))
{
throw e;
}
diff --git a/projects/Unit/RabbitMQCtl.cs b/projects/Unit/RabbitMQCtl.cs
index a62ada13c2..83bb65891b 100644
--- a/projects/Unit/RabbitMQCtl.cs
+++ b/projects/Unit/RabbitMQCtl.cs
@@ -50,7 +50,7 @@ private static Func GetRabbitMqCtlInvokeAction()
string precomputedArguments;
string? envVariable = Environment.GetEnvironmentVariable("RABBITMQ_RABBITMQCTL_PATH");
- if (envVariable is not null)
+ if (!string.IsNullOrWhiteSpace(envVariable))
{
const string DockerPrefix = "DOCKER:";
if (envVariable.StartsWith(DockerPrefix))
diff --git a/tools/gha-run-tests.ps1 b/tools/gha-run-tests.ps1
new file mode 100644
index 0000000000..47843602f4
--- /dev/null
+++ b/tools/gha-run-tests.ps1
@@ -0,0 +1,32 @@
+$ProgressPreference = 'Continue'
+$ErrorActionPreference = 'Stop'
+Set-StrictMode -Version 2.0
+
+$erlang_reg_path = 'HKLM:\SOFTWARE\Ericsson\Erlang'
+if (Test-Path 'HKLM:\SOFTWARE\WOW6432Node\')
+{
+ $erlang_reg_path = 'HKLM:\SOFTWARE\WOW6432Node\Ericsson\Erlang'
+}
+$erlang_erts_version = Get-ChildItem -Path $erlang_reg_path -Name
+$erlang_home = (Get-ItemProperty -LiteralPath $erlang_reg_path\$erlang_erts_version).'(default)'
+
+Write-Host "[INFO] Setting ERLANG_HOME to '$erlang_home'..."
+$env:ERLANG_HOME = $erlang_home
+[Environment]::SetEnvironmentVariable('ERLANG_HOME', $erlang_home, 'Machine')
+
+$regPath = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\RabbitMQ'
+if (Test-Path 'HKLM:\SOFTWARE\WOW6432Node\')
+{
+ $regPath = 'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\RabbitMQ'
+}
+
+$rabbitmq_base_path = Split-Path -Parent (Get-ItemProperty $regPath 'UninstallString').UninstallString
+$rabbitmq_version = (Get-ItemProperty $regPath "DisplayVersion").DisplayVersion
+$rabbitmqctl_path = Join-Path -Path $rabbitmq_base_path -ChildPath "rabbitmq_server-$rabbitmq_version" | Join-Path -ChildPath 'sbin' | Join-Path -ChildPath 'rabbitmqctl.bat'
+
+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-build --logger "console;verbosity=detailed" $solution_file
diff --git a/tools/appveyor/install.ps1 b/tools/install.ps1
similarity index 63%
rename from tools/appveyor/install.ps1
rename to tools/install.ps1
index b4cebcfc53..50a5e03fd7 100644
--- a/tools/appveyor/install.ps1
+++ b/tools/install.ps1
@@ -4,11 +4,20 @@ Set-StrictMode -Version 2.0
[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor 'Tls12'
-Write-Host '[INFO] Removing all existing versions of Erlang...'
-Get-ChildItem -Path 'C:\Program Files\erl*\Uninstall.exe' | %{ Start-Process -Wait -NoNewWindow -FilePath $_ -ArgumentList '/S' }
+$versions_path = Join-Path -Path $env:GITHUB_WORKSPACE -ChildPath 'tools' | Join-Path -ChildPath 'versions.json'
+$versions = Get-Content $versions_path | ConvertFrom-Json
+Write-Host "[INFO] versions: $versions"
+$erlang_ver = $versions.erlang
+$rabbitmq_ver = $versions.rabbitmq
+
+$base_installers_dir = Join-Path -Path $HOME -ChildPath 'installers'
+if (-Not (Test-Path $base_installers_dir))
+{
+ New-Item -Verbose -ItemType Directory $base_installers_dir
+}
-$erlang_download_url = 'https://github.com/erlang/otp/releases/download/OTP-24.2.1/otp_win64_24.2.1.exe'
-$erlang_installer_path = Join-Path -Path $HOME -ChildPath 'otp_win64_24.2.1.exe'
+$erlang_download_url = "https://github.com/erlang/otp/releases/download/OTP-$erlang_ver/otp_win64_$erlang_ver.exe"
+$erlang_installer_path = Join-Path -Path $base_installers_dir -ChildPath "otp_win64_$erlang_ver.exe"
$erlang_install_dir = Join-Path -Path $HOME -ChildPath 'erlang'
Write-Host '[INFO] Downloading Erlang...'
@@ -19,14 +28,14 @@ if (-Not (Test-Path $erlang_installer_path))
}
else
{
- Write-Host "[INFO] Found" $erlang_installer_path "in cache."
+ Write-Host "[INFO] Found '$erlang_installer_path' in cache!"
}
Write-Host "[INFO] Installing Erlang to $erlang_install_dir..."
& $erlang_installer_path '/S' "/D=$erlang_install_dir" | Out-Null
-$rabbitmq_installer_download_url = 'https://github.com/rabbitmq/rabbitmq-server/releases/download/v3.9.13/rabbitmq-server-3.9.13.exe'
-$rabbitmq_installer_path = Join-Path -Path $HOME -ChildPath 'rabbitmq-server-3.9.13.exe'
+$rabbitmq_installer_download_url = "https://github.com/rabbitmq/rabbitmq-server/releases/download/v$rabbitmq_ver/rabbitmq-server-$rabbitmq_ver.exe"
+$rabbitmq_installer_path = Join-Path -Path $base_installers_dir -ChildPath "rabbitmq-server-$rabbitmq_ver.exe"
$erlang_reg_path = 'HKLM:\SOFTWARE\Ericsson\Erlang'
if (Test-Path 'HKLM:\SOFTWARE\WOW6432Node\')
@@ -36,11 +45,15 @@ if (Test-Path 'HKLM:\SOFTWARE\WOW6432Node\')
$erlang_erts_version = Get-ChildItem -Path $erlang_reg_path -Name
$erlang_home = (Get-ItemProperty -LiteralPath $erlang_reg_path\$erlang_erts_version).'(default)'
-Write-Host "[INFO] Setting ERLANG_HOME to $erlang_home"
+Write-Host "[INFO] Setting ERLANG_HOME to '$erlang_home'..."
$env:ERLANG_HOME = $erlang_home
[Environment]::SetEnvironmentVariable('ERLANG_HOME', $erlang_home, 'Machine')
-Write-Host '[INFO] Downloading RabbitMQ'
+Write-Host "[INFO] Setting RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS..."
+$env:RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS = '-rabbitmq_stream advertised_host localhost'
+[Environment]::SetEnvironmentVariable('RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS', '-rabbitmq_stream advertised_host localhost', 'Machine')
+
+Write-Host '[INFO] Downloading RabbitMQ...'
if (-Not (Test-Path $rabbitmq_installer_path))
{
@@ -48,10 +61,13 @@ if (-Not (Test-Path $rabbitmq_installer_path))
}
else
{
- Write-Host "[INFO] Found $rabbitmq_installer_path in cache."
+ Write-Host "[INFO] Found '$rabbitmq_installer_path' in cache!"
}
-Write-Host '[INFO] Creating Erlang cookie files'
+Write-Host "[INFO] Installer dir '$base_installers_dir' contents:"
+Get-ChildItem -Verbose -Path $base_installers_dir
+
+Write-Host '[INFO] Creating Erlang cookie files...'
function Set-ErlangCookie {
Param($Path, $Value = 'RABBITMQ-COOKIE')
@@ -65,7 +81,7 @@ $erlang_cookie_system = Join-Path -Path $env:SystemRoot -ChildPath 'System32\con
Set-ErlangCookie -Path $erlang_cookie_user
Set-ErlangCookie -Path $erlang_cookie_system
-Write-Host '[INFO] Installing and starting RabbitMQ with default config'
+Write-Host '[INFO] Installing and starting RabbitMQ with default config...'
& $rabbitmq_installer_path '/S' | Out-Null
(Get-Service -Name RabbitMQ).Status
@@ -79,35 +95,36 @@ $rabbitmq_base_path = Split-Path -Parent (Get-ItemProperty $regPath 'UninstallSt
$rabbitmq_version = (Get-ItemProperty $regPath "DisplayVersion").DisplayVersion
$rabbitmq_home = Join-Path -Path $rabbitmq_base_path -ChildPath "rabbitmq_server-$rabbitmq_version"
-Write-Host "[INFO] Setting RABBITMQ_HOME to $rabbitmq_home"
+Write-Host "[INFO] Setting RABBITMQ_HOME to '$rabbitmq_home'..."
[Environment]::SetEnvironmentVariable('RABBITMQ_HOME', $rabbitmq_home, 'Machine')
$env:RABBITMQ_HOME = $rabbitmq_home
$rabbitmqctl_path = Join-Path -Path $rabbitmq_base_path -ChildPath "rabbitmq_server-$rabbitmq_version" | Join-Path -ChildPath 'sbin' | Join-Path -ChildPath 'rabbitmqctl.bat'
+$rabbitmq_plugins_path = Join-Path -Path $rabbitmq_base_path -ChildPath "rabbitmq_server-$rabbitmq_version" | Join-Path -ChildPath 'sbin' | Join-Path -ChildPath 'rabbitmq-plugins.bat'
-[Environment]::SetEnvironmentVariable('RABBITMQ_RABBITMQCTL_PATH', $rabbitmqctl_path, 'Machine')
-Write-Host "[INFO] Setting RABBITMQ_RABBITMQCTL_PATH to $rabbitmqctl_path"
+Write-Host "[INFO] Setting RABBITMQ_RABBITMQCTL_PATH to '$rabbitmqctl_path'..."
$env:RABBITMQ_RABBITMQCTL_PATH = $rabbitmqctl_path
+[Environment]::SetEnvironmentVariable('RABBITMQ_RABBITMQCTL_PATH', $rabbitmqctl_path, 'Machine')
$epmd_running = $false
[int]$count = 1
$epmd_exe = Join-Path -Path $erlang_home -ChildPath "erts-$erlang_erts_version" | Join-Path -ChildPath 'bin' | Join-Path -ChildPath 'epmd.exe'
-Write-Host "[INFO] Waiting for epmd ($epmd_exe) to report that RabbitMQ has started"
+Write-Host "[INFO] Waiting for epmd ($epmd_exe) to report that RabbitMQ has started..."
Do {
$epmd_running = & $epmd_exe -names | Select-String -CaseSensitive -SimpleMatch -Quiet -Pattern 'name rabbit at port'
if ($epmd_running -eq $true) {
- Write-Host '[INFO] epmd reports that RabbitMQ is running'
+ Write-Host '[INFO] epmd reports that RabbitMQ is running!'
break
}
if ($count -gt 60) {
- throw '[ERROR] too many tries waiting for epmd to report RabbitMQ running'
+ throw '[ERROR] too many tries waiting for epmd to report RabbitMQ running!'
}
- Write-Host "[INFO] epmd NOT reporting yet that RabbitMQ is running, count: $count"
+ Write-Host "[INFO] epmd NOT reporting yet that RabbitMQ is running, count: '$count'..."
$count = $count + 1
Start-Sleep -Seconds 5
@@ -126,16 +143,19 @@ Do {
}
if ($count -gt 120) {
- throw '[ERROR] too many tries waiting for just one erl process to be running'
+ throw '[ERROR] too many tries waiting for just one erl process to be running!'
}
- Write-Host '[INFO] multiple erl instances running still'
+ Write-Host '[INFO] multiple erl instances running still...'
$count = $count + 1
Start-Sleep -Seconds 5
} While ($true)
$ErrorActionPreference = 'Continue'
-Write-Host '[INFO] Getting RabbitMQ status in 5 seconds...'
-Start-Sleep -Seconds 5
+Write-Host '[INFO] Getting RabbitMQ status...'
& $rabbitmqctl_path status
+
+$ErrorActionPreference = 'Continue'
+Write-Host '[INFO] Enabling plugins...'
+& $rabbitmq_plugins_path enable rabbitmq_management rabbitmq_stream rabbitmq_stream_management
diff --git a/tools/versions.json b/tools/versions.json
new file mode 100644
index 0000000000..a0fe62947a
--- /dev/null
+++ b/tools/versions.json
@@ -0,0 +1,4 @@
+{
+ "erlang": "24.2.1",
+ "rabbitmq": "3.9.13"
+}