Skip to content

Commit 8324fa0

Browse files
authored
Merge pull request #1149 from rabbitmq/rabbitmq-dotnet-client-934
Add Windows GitHub build
2 parents 389819a + 6a4f869 commit 8324fa0

File tree

9 files changed

+174
-62
lines changed

9 files changed

+174
-62
lines changed

.github/workflows/main.yaml

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
name: rabbitmq-dotnet-client
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
build-win32:
11+
name: build/test on windows-latest
12+
13+
runs-on: windows-latest
14+
15+
steps:
16+
- name: Clone repository
17+
uses: actions/checkout@v2
18+
with:
19+
submodules: true
20+
- name: Setup .NET
21+
uses: actions/setup-dotnet@v1
22+
with:
23+
dotnet-version: 3.1.x
24+
- name: Cache installers
25+
uses: actions/cache@v2
26+
with:
27+
# Note: the cache path is relative to the workspace directory
28+
# https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#using-the-cache-action
29+
path: ~/installers
30+
key: ${{ runner.os }}-v0-${{ hashFiles('tools/versions.json') }}
31+
- name: Cache NuGet packages
32+
uses: actions/cache@v2
33+
with:
34+
path: |
35+
~/.nuget/packages
36+
~/AppData/Local/NuGet/v3-cache
37+
key: ${{ runner.os }}-v0-nuget-${{ hashFiles('**/*.csproj') }}
38+
restore-keys: |
39+
${{ runner.os }}-v0-nuget-
40+
- name: Install and start RabbitMQ
41+
run: ./tools/install.ps1
42+
- name: List NuGet sources
43+
run: dotnet nuget locals all --list
44+
- name: Restore
45+
run: dotnet restore --verbosity=normal
46+
- name: Build
47+
run: dotnet build --no-restore --verbosity=normal
48+
- name: Test
49+
run: ./tools/gha-run-tests.ps1
50+
51+
build:
52+
name: build/test on ubuntu-latest
53+
54+
runs-on: ubuntu-latest
55+
56+
services:
57+
rabbitmq:
58+
image: rabbitmq:3.9-management
59+
ports:
60+
- 5672:5672
61+
- 15672:15672
62+
63+
steps:
64+
- name: Clone repository
65+
uses: actions/checkout@v2
66+
with:
67+
submodules: true
68+
- name: Setup .NET
69+
uses: actions/setup-dotnet@v1
70+
with:
71+
dotnet-version: 3.1.x
72+
- name: Cache NuGet packages
73+
uses: actions/cache@v2
74+
with:
75+
path: |
76+
~/.nuget/packages
77+
~/.local/share/NuGet/v3-cache
78+
key: ${{ runner.os }}-v0-nuget-${{ hashFiles('**/*.csproj') }}
79+
restore-keys: |
80+
${{ runner.os }}-v0-nuget-
81+
- name: Restore
82+
run: dotnet restore --verbosity=normal
83+
- name: Build
84+
run: dotnet build --no-restore --verbosity=normal
85+
- name: Test
86+
run: dotnet test --no-build --logger "console;verbosity=detailed"
87+
env:
88+
RABBITMQ_RABBITMQCTL_PATH: DOCKER:${{job.services.rabbitmq.id}}

.github/workflows/test-linux.yml

Lines changed: 0 additions & 34 deletions
This file was deleted.

build.bat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
@ECHO OFF
22
set DOTNET_CLI_TELEMETRY_OPTOUT=1
3-
dotnet restore .\RabbitMQDotNetClient.sln
4-
dotnet build .\RabbitMQDotNetClient.sln
3+
dotnet restore --verbosity=normal .\RabbitMQDotNetClient.sln
4+
dotnet build --verbosity=normal .\RabbitMQDotNetClient.sln

projects/RabbitMQ.Client/client/api/BasicGetResult.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ public BasicGetResult(ulong deliveryTag, bool redelivered, string exchange, stri
130130
/// <inheritdoc />
131131
public void Dispose()
132132
{
133-
if (_rentedArray is not null)
133+
if (_rentedArray != null)
134134
{
135135
ArrayPool<byte>.Shared.Return(_rentedArray);
136136
}

projects/RabbitMQ.Client/client/impl/AutorecoveringConnection.Recovery.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,9 @@ private void StopRecoveryLoop()
114114
private static void HandleTopologyRecoveryException(TopologyRecoveryException e)
115115
{
116116
ESLog.Error("Topology recovery exception", e);
117-
if (e.InnerException is AlreadyClosedException or OperationInterruptedException or TimeoutException)
117+
if (e.InnerException is AlreadyClosedException ||
118+
(e.InnerException is OperationInterruptedException) ||
119+
(e.InnerException is TimeoutException))
118120
{
119121
throw e;
120122
}

projects/Unit/RabbitMQCtl.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ private static Func<string, Process> GetRabbitMqCtlInvokeAction()
5050
string precomputedArguments;
5151
string? envVariable = Environment.GetEnvironmentVariable("RABBITMQ_RABBITMQCTL_PATH");
5252

53-
if (envVariable is not null)
53+
if (!string.IsNullOrWhiteSpace(envVariable))
5454
{
5555
const string DockerPrefix = "DOCKER:";
5656
if (envVariable.StartsWith(DockerPrefix))

tools/gha-run-tests.ps1

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
$ProgressPreference = 'Continue'
2+
$ErrorActionPreference = 'Stop'
3+
Set-StrictMode -Version 2.0
4+
5+
$erlang_reg_path = 'HKLM:\SOFTWARE\Ericsson\Erlang'
6+
if (Test-Path 'HKLM:\SOFTWARE\WOW6432Node\')
7+
{
8+
$erlang_reg_path = 'HKLM:\SOFTWARE\WOW6432Node\Ericsson\Erlang'
9+
}
10+
$erlang_erts_version = Get-ChildItem -Path $erlang_reg_path -Name
11+
$erlang_home = (Get-ItemProperty -LiteralPath $erlang_reg_path\$erlang_erts_version).'(default)'
12+
13+
Write-Host "[INFO] Setting ERLANG_HOME to '$erlang_home'..."
14+
$env:ERLANG_HOME = $erlang_home
15+
[Environment]::SetEnvironmentVariable('ERLANG_HOME', $erlang_home, 'Machine')
16+
17+
$regPath = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\RabbitMQ'
18+
if (Test-Path 'HKLM:\SOFTWARE\WOW6432Node\')
19+
{
20+
$regPath = 'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\RabbitMQ'
21+
}
22+
23+
$rabbitmq_base_path = Split-Path -Parent (Get-ItemProperty $regPath 'UninstallString').UninstallString
24+
$rabbitmq_version = (Get-ItemProperty $regPath "DisplayVersion").DisplayVersion
25+
$rabbitmqctl_path = Join-Path -Path $rabbitmq_base_path -ChildPath "rabbitmq_server-$rabbitmq_version" | Join-Path -ChildPath 'sbin' | Join-Path -ChildPath 'rabbitmqctl.bat'
26+
27+
Write-Host "[INFO] Setting RABBITMQ_RABBITMQCTL_PATH to '$rabbitmqctl_path'..."
28+
$env:RABBITMQ_RABBITMQCTL_PATH = $rabbitmqctl_path
29+
[Environment]::SetEnvironmentVariable('RABBITMQ_RABBITMQCTL_PATH', $rabbitmqctl_path, 'Machine')
30+
31+
$solution_file = Join-Path -Path $env:GITHUB_WORKSPACE -ChildPath 'RabbitMQDotNetClient.sln'
32+
dotnet test --no-build --logger "console;verbosity=detailed" $solution_file

tools/appveyor/install.ps1 renamed to tools/install.ps1

Lines changed: 43 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,20 @@ Set-StrictMode -Version 2.0
44

55
[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor 'Tls12'
66

7-
Write-Host '[INFO] Removing all existing versions of Erlang...'
8-
Get-ChildItem -Path 'C:\Program Files\erl*\Uninstall.exe' | %{ Start-Process -Wait -NoNewWindow -FilePath $_ -ArgumentList '/S' }
7+
$versions_path = Join-Path -Path $env:GITHUB_WORKSPACE -ChildPath 'tools' | Join-Path -ChildPath 'versions.json'
8+
$versions = Get-Content $versions_path | ConvertFrom-Json
9+
Write-Host "[INFO] versions: $versions"
10+
$erlang_ver = $versions.erlang
11+
$rabbitmq_ver = $versions.rabbitmq
12+
13+
$base_installers_dir = Join-Path -Path $HOME -ChildPath 'installers'
14+
if (-Not (Test-Path $base_installers_dir))
15+
{
16+
New-Item -Verbose -ItemType Directory $base_installers_dir
17+
}
918

10-
$erlang_download_url = 'https://github.com/erlang/otp/releases/download/OTP-24.2.1/otp_win64_24.2.1.exe'
11-
$erlang_installer_path = Join-Path -Path $HOME -ChildPath 'otp_win64_24.2.1.exe'
19+
$erlang_download_url = "https://github.com/erlang/otp/releases/download/OTP-$erlang_ver/otp_win64_$erlang_ver.exe"
20+
$erlang_installer_path = Join-Path -Path $base_installers_dir -ChildPath "otp_win64_$erlang_ver.exe"
1221
$erlang_install_dir = Join-Path -Path $HOME -ChildPath 'erlang'
1322

1423
Write-Host '[INFO] Downloading Erlang...'
@@ -19,14 +28,14 @@ if (-Not (Test-Path $erlang_installer_path))
1928
}
2029
else
2130
{
22-
Write-Host "[INFO] Found" $erlang_installer_path "in cache."
31+
Write-Host "[INFO] Found '$erlang_installer_path' in cache!"
2332
}
2433

2534
Write-Host "[INFO] Installing Erlang to $erlang_install_dir..."
2635
& $erlang_installer_path '/S' "/D=$erlang_install_dir" | Out-Null
2736

28-
$rabbitmq_installer_download_url = 'https://github.com/rabbitmq/rabbitmq-server/releases/download/v3.9.13/rabbitmq-server-3.9.13.exe'
29-
$rabbitmq_installer_path = Join-Path -Path $HOME -ChildPath 'rabbitmq-server-3.9.13.exe'
37+
$rabbitmq_installer_download_url = "https://github.com/rabbitmq/rabbitmq-server/releases/download/v$rabbitmq_ver/rabbitmq-server-$rabbitmq_ver.exe"
38+
$rabbitmq_installer_path = Join-Path -Path $base_installers_dir -ChildPath "rabbitmq-server-$rabbitmq_ver.exe"
3039

3140
$erlang_reg_path = 'HKLM:\SOFTWARE\Ericsson\Erlang'
3241
if (Test-Path 'HKLM:\SOFTWARE\WOW6432Node\')
@@ -36,22 +45,29 @@ if (Test-Path 'HKLM:\SOFTWARE\WOW6432Node\')
3645
$erlang_erts_version = Get-ChildItem -Path $erlang_reg_path -Name
3746
$erlang_home = (Get-ItemProperty -LiteralPath $erlang_reg_path\$erlang_erts_version).'(default)'
3847

39-
Write-Host "[INFO] Setting ERLANG_HOME to $erlang_home"
48+
Write-Host "[INFO] Setting ERLANG_HOME to '$erlang_home'..."
4049
$env:ERLANG_HOME = $erlang_home
4150
[Environment]::SetEnvironmentVariable('ERLANG_HOME', $erlang_home, 'Machine')
4251

43-
Write-Host '[INFO] Downloading RabbitMQ'
52+
Write-Host "[INFO] Setting RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS..."
53+
$env:RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS = '-rabbitmq_stream advertised_host localhost'
54+
[Environment]::SetEnvironmentVariable('RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS', '-rabbitmq_stream advertised_host localhost', 'Machine')
55+
56+
Write-Host '[INFO] Downloading RabbitMQ...'
4457

4558
if (-Not (Test-Path $rabbitmq_installer_path))
4659
{
4760
Invoke-WebRequest -UseBasicParsing -Uri $rabbitmq_installer_download_url -OutFile $rabbitmq_installer_path
4861
}
4962
else
5063
{
51-
Write-Host "[INFO] Found $rabbitmq_installer_path in cache."
64+
Write-Host "[INFO] Found '$rabbitmq_installer_path' in cache!"
5265
}
5366

54-
Write-Host '[INFO] Creating Erlang cookie files'
67+
Write-Host "[INFO] Installer dir '$base_installers_dir' contents:"
68+
Get-ChildItem -Verbose -Path $base_installers_dir
69+
70+
Write-Host '[INFO] Creating Erlang cookie files...'
5571

5672
function Set-ErlangCookie {
5773
Param($Path, $Value = 'RABBITMQ-COOKIE')
@@ -65,7 +81,7 @@ $erlang_cookie_system = Join-Path -Path $env:SystemRoot -ChildPath 'System32\con
6581
Set-ErlangCookie -Path $erlang_cookie_user
6682
Set-ErlangCookie -Path $erlang_cookie_system
6783

68-
Write-Host '[INFO] Installing and starting RabbitMQ with default config'
84+
Write-Host '[INFO] Installing and starting RabbitMQ with default config...'
6985

7086
& $rabbitmq_installer_path '/S' | Out-Null
7187
(Get-Service -Name RabbitMQ).Status
@@ -79,35 +95,36 @@ $rabbitmq_base_path = Split-Path -Parent (Get-ItemProperty $regPath 'UninstallSt
7995
$rabbitmq_version = (Get-ItemProperty $regPath "DisplayVersion").DisplayVersion
8096

8197
$rabbitmq_home = Join-Path -Path $rabbitmq_base_path -ChildPath "rabbitmq_server-$rabbitmq_version"
82-
Write-Host "[INFO] Setting RABBITMQ_HOME to $rabbitmq_home"
98+
Write-Host "[INFO] Setting RABBITMQ_HOME to '$rabbitmq_home'..."
8399
[Environment]::SetEnvironmentVariable('RABBITMQ_HOME', $rabbitmq_home, 'Machine')
84100
$env:RABBITMQ_HOME = $rabbitmq_home
85101

86102
$rabbitmqctl_path = Join-Path -Path $rabbitmq_base_path -ChildPath "rabbitmq_server-$rabbitmq_version" | Join-Path -ChildPath 'sbin' | Join-Path -ChildPath 'rabbitmqctl.bat'
103+
$rabbitmq_plugins_path = Join-Path -Path $rabbitmq_base_path -ChildPath "rabbitmq_server-$rabbitmq_version" | Join-Path -ChildPath 'sbin' | Join-Path -ChildPath 'rabbitmq-plugins.bat'
87104

88-
[Environment]::SetEnvironmentVariable('RABBITMQ_RABBITMQCTL_PATH', $rabbitmqctl_path, 'Machine')
89-
Write-Host "[INFO] Setting RABBITMQ_RABBITMQCTL_PATH to $rabbitmqctl_path"
105+
Write-Host "[INFO] Setting RABBITMQ_RABBITMQCTL_PATH to '$rabbitmqctl_path'..."
90106
$env:RABBITMQ_RABBITMQCTL_PATH = $rabbitmqctl_path
107+
[Environment]::SetEnvironmentVariable('RABBITMQ_RABBITMQCTL_PATH', $rabbitmqctl_path, 'Machine')
91108

92109
$epmd_running = $false
93110
[int]$count = 1
94111

95112
$epmd_exe = Join-Path -Path $erlang_home -ChildPath "erts-$erlang_erts_version" | Join-Path -ChildPath 'bin' | Join-Path -ChildPath 'epmd.exe'
96113

97-
Write-Host "[INFO] Waiting for epmd ($epmd_exe) to report that RabbitMQ has started"
114+
Write-Host "[INFO] Waiting for epmd ($epmd_exe) to report that RabbitMQ has started..."
98115

99116
Do {
100117
$epmd_running = & $epmd_exe -names | Select-String -CaseSensitive -SimpleMatch -Quiet -Pattern 'name rabbit at port'
101118
if ($epmd_running -eq $true) {
102-
Write-Host '[INFO] epmd reports that RabbitMQ is running'
119+
Write-Host '[INFO] epmd reports that RabbitMQ is running!'
103120
break
104121
}
105122

106123
if ($count -gt 60) {
107-
throw '[ERROR] too many tries waiting for epmd to report RabbitMQ running'
124+
throw '[ERROR] too many tries waiting for epmd to report RabbitMQ running!'
108125
}
109126

110-
Write-Host "[INFO] epmd NOT reporting yet that RabbitMQ is running, count: $count"
127+
Write-Host "[INFO] epmd NOT reporting yet that RabbitMQ is running, count: '$count'..."
111128
$count = $count + 1
112129
Start-Sleep -Seconds 5
113130

@@ -126,16 +143,19 @@ Do {
126143
}
127144

128145
if ($count -gt 120) {
129-
throw '[ERROR] too many tries waiting for just one erl process to be running'
146+
throw '[ERROR] too many tries waiting for just one erl process to be running!'
130147
}
131148

132-
Write-Host '[INFO] multiple erl instances running still'
149+
Write-Host '[INFO] multiple erl instances running still...'
133150
$count = $count + 1
134151
Start-Sleep -Seconds 5
135152

136153
} While ($true)
137154

138155
$ErrorActionPreference = 'Continue'
139-
Write-Host '[INFO] Getting RabbitMQ status in 5 seconds...'
140-
Start-Sleep -Seconds 5
156+
Write-Host '[INFO] Getting RabbitMQ status...'
141157
& $rabbitmqctl_path status
158+
159+
$ErrorActionPreference = 'Continue'
160+
Write-Host '[INFO] Enabling plugins...'
161+
& $rabbitmq_plugins_path enable rabbitmq_management rabbitmq_stream rabbitmq_stream_management

tools/versions.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"erlang": "24.2.1",
3+
"rabbitmq": "3.9.13"
4+
}

0 commit comments

Comments
 (0)