Skip to content

Commit

Permalink
Add Windows GitHub build
Browse files Browse the repository at this point in the history
Fixes #934

Check out submodules, ensure that preview language features are not used

Ensure that preview language features are not used

Run tests on Windows using powershell to set the rabbitmqctl.bat path

Gotta set ERLANG_HOME too...
  • Loading branch information
lukebakken committed Feb 22, 2022
1 parent 389819a commit 6a4f869
Show file tree
Hide file tree
Showing 9 changed files with 174 additions and 62 deletions.
88 changes: 88 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -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}}
34 changes: 0 additions & 34 deletions .github/workflows/test-linux.yml

This file was deleted.

4 changes: 2 additions & 2 deletions build.bat
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion projects/RabbitMQ.Client/client/api/BasicGetResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public BasicGetResult(ulong deliveryTag, bool redelivered, string exchange, stri
/// <inheritdoc />
public void Dispose()
{
if (_rentedArray is not null)
if (_rentedArray != null)
{
ArrayPool<byte>.Shared.Return(_rentedArray);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion projects/Unit/RabbitMQCtl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ private static Func<string, Process> 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))
Expand Down
32 changes: 32 additions & 0 deletions tools/gha-run-tests.ps1
Original file line number Diff line number Diff line change
@@ -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
66 changes: 43 additions & 23 deletions tools/appveyor/install.ps1 → tools/install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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...'
Expand All @@ -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\')
Expand All @@ -36,22 +45,29 @@ 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))
{
Invoke-WebRequest -UseBasicParsing -Uri $rabbitmq_installer_download_url -OutFile $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')
Expand All @@ -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
Expand All @@ -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

Expand All @@ -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
4 changes: 4 additions & 0 deletions tools/versions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"erlang": "24.2.1",
"rabbitmq": "3.9.13"
}

0 comments on commit 6a4f869

Please sign in to comment.