Skip to content

Commit

Permalink
Merge pull request #1149 from rabbitmq/rabbitmq-dotnet-client-934
Browse files Browse the repository at this point in the history
Add Windows GitHub build

(cherry picked from commit 8324fa0)

Attempt to speed up nuget package restort, Unit project updates

Update docker image

Set Repo URL in project
  • Loading branch information
lukebakken committed Feb 23, 2022
1 parent 0c95330 commit eb035d6
Show file tree
Hide file tree
Showing 10 changed files with 184 additions and 35 deletions.
92 changes: 92 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
name: rabbitmq-dotnet-client

on:
push:
branches: [ 6.x ]
pull_request:
branches: [ 6.x ]

jobs:
build-win32:
name: build/test on windows-latest

runs-on: windows-latest

# https://github.com/NuGet/Home/issues/11548
env:
NUGET_CERT_REVOCATION_MODE: offline

steps:
- name: Clone repository
uses: actions/checkout@v2
with:
submodules: true
- 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: ApiGen
run: dotnet run --project ./projects/Apigen/Apigen.csproj --apiName:AMQP_0_9_1 ./projects/specs/amqp0-9-1.stripped.xml ./gensrc/autogenerated-api-0-9-1.cs
- 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: pivotalrabbitmq/rabbitmq:master-otp-max
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: ApiGen
run: dotnet run --project ./projects/Apigen/Apigen.csproj --apiName:AMQP_0_9_1 ./projects/specs/amqp0-9-1.stripped.xml ./gensrc/autogenerated-api-0-9-1.cs
- name: Build
run: dotnet build --no-restore --verbosity=normal
- name: Test
run: dotnet test --no-restore --no-build --logger "console;verbosity=detailed" --framework "netcoreapp3.1"
env:
RABBITMQ_RABBITMQCTL_PATH: DOCKER:${{job.services.rabbitmq.id}}
2 changes: 1 addition & 1 deletion _site
Submodule _site updated 166 files
6 changes: 3 additions & 3 deletions build.bat
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@ECHO OFF
set DOTNET_CLI_TELEMETRY_OPTOUT=1
dotnet restore .\RabbitMQDotNetClient.sln
dotnet run --project .\projects\Apigen\Apigen.csproj --apiName:AMQP_0_9_1 .\projects\specs\amqp0-9-1.stripped.xml .\gensrc\autogenerated-api-0-9-1.cs
dotnet build .\RabbitMQDotNetClient.sln
dotnet restore --verbosity=normal .\RabbitMQDotNetClient.sln
dotnet run --verbosity=normal --project .\projects\Apigen\Apigen.csproj --apiName:AMQP_0_9_1 .\projects\specs\amqp0-9-1.stripped.xml .\gensrc\autogenerated-api-0-9-1.cs
dotnet build --verbosity=normal .\RabbitMQDotNetClient.sln
1 change: 1 addition & 0 deletions projects/RabbitMQ.Client/RabbitMQ.Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<PackageTags>rabbitmq, amqp</PackageTags>
<Product>RabbitMQ</Product>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<RepositoryUrl>https://github.com/rabbitmq/rabbitmq-dotnet-client.git</RepositoryUrl>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<AssemblyOriginatorKeyFile>../rabbit.snk</AssemblyOriginatorKeyFile>
Expand Down
6 changes: 3 additions & 3 deletions projects/Unit/APIApproval.Approve.verified.txt
Original file line number Diff line number Diff line change
Expand Up @@ -847,13 +847,13 @@ namespace RabbitMQ.Client.Logging
{
public static RabbitMQ.Client.Logging.RabbitMqClientEventSource Log;
public RabbitMqClientEventSource() { }
[System.Diagnostics.Tracing.Event(3, Keywords=System.Diagnostics.Tracing.EventKeywords.None | System.Diagnostics.Tracing.EventKeywords.All, Level=System.Diagnostics.Tracing.EventLevel.Error, Message="ERROR")]
[System.Diagnostics.Tracing.Event(3, Keywords=System.Diagnostics.Tracing.EventKeywords.None, Level=System.Diagnostics.Tracing.EventLevel.Error, Message="ERROR")]
public void Error(string message, RabbitMQ.Client.Logging.RabbitMqExceptionDetail ex) { }
[System.Diagnostics.Tracing.NonEvent]
public void Error(string message, System.Exception ex) { }
[System.Diagnostics.Tracing.Event(1, Keywords=System.Diagnostics.Tracing.EventKeywords.None | System.Diagnostics.Tracing.EventKeywords.All, Level=System.Diagnostics.Tracing.EventLevel.Informational, Message="INFO")]
[System.Diagnostics.Tracing.Event(1, Keywords=System.Diagnostics.Tracing.EventKeywords.None, Level=System.Diagnostics.Tracing.EventLevel.Informational, Message="INFO")]
public void Info(string message) { }
[System.Diagnostics.Tracing.Event(2, Keywords=System.Diagnostics.Tracing.EventKeywords.None | System.Diagnostics.Tracing.EventKeywords.All, Level=System.Diagnostics.Tracing.EventLevel.Warning, Message="WARN")]
[System.Diagnostics.Tracing.Event(2, Keywords=System.Diagnostics.Tracing.EventKeywords.None, Level=System.Diagnostics.Tracing.EventLevel.Warning, Message="WARN")]
public void Warn(string message) { }
public class Keywords
{
Expand Down
2 changes: 1 addition & 1 deletion projects/Unit/APIApproval.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
namespace RabbitMQ.Client.Unit
{
[TestFixture]
[Platform(Exclude="Mono")]
[Platform(Exclude="Mono,Linux")]
public class APIApproval
{
[Test]
Expand Down
8 changes: 4 additions & 4 deletions projects/Unit/Unit.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" />
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.2" />
<PackageReference Include="NUnit" Version="3.13.2" />
<PackageReference Include="NUnit3TestAdapter" Version="3.17.0" />
<PackageReference Include="PublicApiGenerator" Version="10.2.0" />
<PackageReference Include="Verify.NUnit" Version="11.18.2" />
<PackageReference Include="NUnit3TestAdapter" Version="4.2.1" />
<PackageReference Include="PublicApiGenerator" Version="10.3.0" />
<PackageReference Include="Verify.NUnit" Version="12.2" />
</ItemGroup>

</Project>
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-restore --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 eb035d6

Please sign in to comment.