Skip to content

Commit

Permalink
Update GHA for NuGet publishing (#1406)
Browse files Browse the repository at this point in the history
* Update GHA for NuGet publishing

Follow-up to #1398

* Only build RabbitMQ.Client for the publish nuget step, and only push version 7 and higher

* Enable RABBITMQ_LONG_RUNNING_TESTS in GHA
  • Loading branch information
lukebakken committed Oct 16, 2023
1 parent 4b3e1ff commit d786db1
Show file tree
Hide file tree
Showing 12 changed files with 188 additions and 161 deletions.
6 changes: 0 additions & 6 deletions .ci/oauth2/setup.sh
Expand Up @@ -14,12 +14,6 @@ declare -r keycloak_image_version='20.0'
declare -r docker_network="$docker_name_prefix-net"
declare -r rabbitmq_docker_name="$docker_name_prefix-rabbitmq"

function err_todo
{
echo '[ERROR] TODO' 1>&2
exit 69
}

function mode_is_uaa
{
[[ $mode == 'uaa' ]]
Expand Down
6 changes: 0 additions & 6 deletions .ci/ubuntu/gha-setup.sh
Expand Up @@ -27,12 +27,6 @@ set -o nounset

declare -r rabbitmq_docker_name="$docker_name_prefix-rabbitmq"

function err_todo
{
echo '[ERROR] TODO' 1>&2
exit 69
}

function start_rabbitmq
{
chmod 0777 "$GITHUB_WORKSPACE/.ci/ubuntu/log"
Expand Down
7 changes: 6 additions & 1 deletion .ci/windows/gha-run-tests.ps1
Expand Up @@ -31,4 +31,9 @@ New-Variable -Name ci_dir -Option Constant -Value (Join-Path -Path $env:GITHUB_W
New-Variable -Name certs_dir -Option Constant -Value (Join-Path -Path $ci_dir -ChildPath 'certs')

$csproj_file = Resolve-Path -LiteralPath (Join-Path -Path $env:GITHUB_WORKSPACE -ChildPath 'projects' | Join-Path -ChildPath 'Unit' | Join-Path -ChildPath 'Unit.csproj')
dotnet test --environment RABBITMQ_RABBITMQCTL_PATH=$rabbitmqctl_path --environment PASSWORD=grapefruit --environment SSL_CERTS_DIR=$certs_dir $csproj_file --no-restore --no-build --logger "console;verbosity=detailed"

dotnet test --environment "RABBITMQ_RABBITMQCTL_PATH=$rabbitmqctl_path" `
--environment 'RABBITMQ_LONG_RUNNING_TESTS=true' `
--environment 'PASSWORD=grapefruit' `
--environment "SSL_CERTS_DIR=$certs_dir" `
$csproj_file --no-restore --no-build --logger "console;verbosity=detailed"
2 changes: 1 addition & 1 deletion .ci/windows/versions.json
@@ -1,4 +1,4 @@
{
"erlang": "26.1.1",
"erlang": "26.1.2",
"rabbitmq": "3.12.6"
}
93 changes: 93 additions & 0 deletions .github/workflows/build-test.yaml
@@ -0,0 +1,93 @@
name: build/test rabbitmq-dotnet-client

on:
- workflow_call

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@v4
with:
submodules: true
- name: Cache installers
uses: actions/cache@v3
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('.ci/versions.json') }}
- name: Cache NuGet packages
uses: actions/cache@v3
with:
path: |
~/.nuget/packages
~/AppData/Local/NuGet/v3-cache
key: ${{ runner.os }}-v1-nuget-${{ hashFiles('**/*.csproj') }}
restore-keys: |
${{ runner.os }}-v1-nuget-
- name: Install and Start RabbitMQ
run: .\.ci\windows\gha-setup.ps1
- name: List NuGet sources
run: dotnet nuget locals all --list
- name: Build
run: dotnet build ${{ github.workspace }}\Build.csproj
- name: Verify
run: dotnet format ${{ github.workspace }}\RabbitMQDotNetClient.sln --verify-no-changes --verbosity=diagnostic
- name: Test
run: .\.ci\windows\gha-run-tests.ps1
- name: Maybe upload RabbitMQ logs
if: failure()
uses: actions/upload-artifact@v3
with:
name: rabbitmq-logs
path: ~/AppData/Roaming/RabbitMQ/log/
build:
name: build/test on ubuntu-latest
runs-on: ubuntu-latest
steps:
- name: Clone repository
uses: actions/checkout@v4
with:
submodules: true
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.x
- name: Cache NuGet packages
uses: actions/cache@v3
with:
path: |
~/.nuget/packages
~/.local/share/NuGet/v3-cache
key: ${{ runner.os }}-v1-nuget-${{ hashFiles('**/*.csproj') }}
restore-keys: |
${{ runner.os }}-v1-nuget-
- name: Start RabbitMQ
id: start-rabbitmq
run: ${{ github.workspace }}/.ci/ubuntu/gha-setup.sh
- name: List NuGet sources
run: dotnet nuget locals all --list
- name: Build
run: dotnet build ${{ github.workspace }}/Build.csproj
- name: Verify
run: dotnet format ${{ github.workspace }}/RabbitMQDotNetClient.sln --verify-no-changes --verbosity=diagnostic
- name: Test
run: |
dotnet test \
--environment "RABBITMQ_RABBITMQCTL_PATH=DOCKER:${{ steps.start-rabbitmq.outputs.id }}" \
--environment 'RABBITMQ_LONG_RUNNING_TESTS=true' \
--environment 'PASSWORD=grapefruit' \
--environment SSL_CERTS_DIR="${{ github.workspace }}/.ci/certs" \
"${{ github.workspace }}/projects/Unit/Unit.csproj" --no-restore --no-build --logger 'console;verbosity=detailed' --framework 'net6.0'
- name: Maybe upload RabbitMQ logs
if: failure()
uses: actions/upload-artifact@v3
with:
name: rabbitmq-logs
path: ${{ github.workspace }}/.ci/ubuntu/log/
94 changes: 2 additions & 92 deletions .github/workflows/main.yaml
Expand Up @@ -7,95 +7,5 @@ on:
branches: [ main ]

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@v4
with:
submodules: true
- name: Cache installers
uses: actions/cache@v3
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('.ci/versions.json') }}
- name: Cache NuGet packages
uses: actions/cache@v3
with:
path: |
~/.nuget/packages
~/AppData/Local/NuGet/v3-cache
key: ${{ runner.os }}-v1-nuget-${{ hashFiles('**/*.csproj') }}
restore-keys: |
${{ runner.os }}-v1-nuget-
- name: Install and Start RabbitMQ
run: .\.ci\windows\gha-setup.ps1
- name: List NuGet sources
run: dotnet nuget locals all --list
- name: Build
run: dotnet build ${{ github.workspace }}\Build.csproj
- name: Verify
run: dotnet format ${{ github.workspace }}\RabbitMQDotNetClient.sln --verify-no-changes --verbosity=diagnostic
- name: Test
run: .\.ci\windows\gha-run-tests.ps1
- name: Maybe upload RabbitMQ logs
if: failure()
uses: actions/upload-artifact@v3
with:
name: rabbitmq-logs
path: ~/AppData/Roaming/RabbitMQ/log/

build:
name: build/test on ubuntu-latest

runs-on: ubuntu-latest

steps:
- name: Clone repository
uses: actions/checkout@v4
with:
submodules: true
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.x
- name: Cache NuGet packages
uses: actions/cache@v3
with:
path: |
~/.nuget/packages
~/.local/share/NuGet/v3-cache
key: ${{ runner.os }}-v0-nuget-${{ hashFiles('**/*.csproj') }}
restore-keys: |
${{ runner.os }}-v0-nuget-
- name: Start RabbitMQ
id: start-rabbitmq
run: ${{ github.workspace }}/.ci/ubuntu/gha-setup.sh
- name: List NuGet sources
run: dotnet nuget locals all --list
- name: Build
run: dotnet build ${{ github.workspace }}/Build.csproj
- name: Verify
run: dotnet format ${{ github.workspace }}/RabbitMQDotNetClient.sln --verify-no-changes --verbosity=diagnostic
- name: Test
run: |
dotnet test \
--environment RABBITMQ_RABBITMQCTL_PATH=DOCKER:${{ steps.start-rabbitmq.outputs.id }} \
--environment PASSWORD=grapefruit \
--environment SSL_CERTS_DIR="${{ github.workspace }}/.ci/certs" \
"${{ github.workspace }}/projects/Unit/Unit.csproj" --no-restore --no-build --logger 'console;verbosity=detailed' --framework 'net6.0'
- name: Maybe upload RabbitMQ logs
if: failure()
uses: actions/upload-artifact@v3
with:
name: rabbitmq-logs
path: ${{ github.workspace }}/.ci/ubuntu/log/
call-build-test:
uses: ./.github/workflows/build-test.yaml
25 changes: 25 additions & 0 deletions .github/workflows/publish-nuget.yaml
@@ -0,0 +1,25 @@
name: publish-nuget

on:
workflow_call:
secrets:
NUGET_API_KEY:
required: true

jobs:
publish-nuget:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v3
with:
path: |
~/.nuget/packages
~/.local/share/NuGet/v3-cache
key: ${{ runner.os }}-v1-nuget-${{ hashFiles('**/*.csproj') }}
restore-keys: |
${{ runner.os }}-v1-nuget-
- name: Build (Release)
run: dotnet build ${{ github.workspace }}\projects\RabbitMQ.Client\RabbitMQ.Client.csproj --verbosity=normal --configuration=Release --property CI=true
- name: Publish to NuGet
run: dotnet nuget push --skip-duplicate --api-key ${{ secrets.NUGET_API_KEY }} --source 'https://api.nuget.org/v3/index.json' ${{ github.workspace }}\packages\RabbitMQ.Client.7.*.nupkg
15 changes: 15 additions & 0 deletions .github/workflows/publish.yaml
@@ -0,0 +1,15 @@
name: publish rabbitmq-dotnet-client

on:
release:
types:
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#release
- published

jobs:
call-build-test:
uses: ./.github/workflows/build-test.yaml
call-publish-nuget:
uses: ./.github/workflows/publish-nuget.yaml
needs: call-build-test
secrets: inherit
15 changes: 5 additions & 10 deletions projects/RabbitMQ.Client.OAuth2/RabbitMQ.Client.OAuth2.csproj
Expand Up @@ -9,7 +9,6 @@
<Company>VMware, Inc. or its affiliates.</Company>
<Copyright>Copyright © 2007-2023 VMware, Inc. or its affiliates.</Copyright>
<Description>The RabbitMQ OAuth2 Client Library for .NET enables OAuth2 token refresh for RabbitMQ.Client</Description>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageIcon>icon.png</PackageIcon>
<PackageLicenseExpression>Apache-2.0 OR MPL-2.0</PackageLicenseExpression>
Expand All @@ -32,19 +31,15 @@
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>

<PropertyGroup Condition="'$(CONCOURSE_CI_BUILD)' == 'true'">
<PropertyGroup Condition="'$(Configuration)' == 'Release' And '$(CI)' == 'true'">
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
<Deterministic>true</Deterministic>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
</PropertyGroup>

<Target Name="SetVersionFromConcourseData" AfterTargets="MinVer" Condition="'$(CONCOURSE_PULL_REQUEST_NUMBER)' != ''">
<PropertyGroup>
<PackageVersion>$(MinVerMajor).$(MinVerMinor).$(MinVerPatch)-$(MinVerPreRelease)-pr.$(CONCOURSE_PULL_REQUEST_NUMBER)</PackageVersion>
<PackageVersion Condition="'$(MinVerBuildMetadata)' != ''">$(PackageVersion)+$(MinVerBuildMetadata)</PackageVersion>
<Version>$(PackageVersion)</Version>
</PropertyGroup>
<Message Importance="normal" Text="SetVersionFromConcourseData: PackageVersion=$(PackageVersion) Version=$(Version)" />
</Target>
<ItemGroup Condition="'$(Configuration)' == 'Release' and '$(SourceRoot)' == ''">
<SourceRoot Include="$(MSBuildThisFileDirectory)/"/>
</ItemGroup>

<ItemGroup>
<None Remove="icon.png" />
Expand Down
15 changes: 5 additions & 10 deletions projects/RabbitMQ.Client/RabbitMQ.Client.csproj
Expand Up @@ -9,7 +9,6 @@
<Company>VMware, Inc. or its affiliates.</Company>
<Copyright>Copyright © 2007-2022 VMware, Inc. or its affiliates.</Copyright>
<Description>The RabbitMQ .NET client is the official client library for C# (and, implicitly, other .NET languages)</Description>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageIcon>icon.png</PackageIcon>
<PackageLicenseExpression>Apache-2.0 OR MPL-2.0</PackageLicenseExpression>
Expand All @@ -32,19 +31,15 @@
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>

<PropertyGroup Condition="'$(CONCOURSE_CI_BUILD)' == 'true'">
<PropertyGroup Condition="'$(Configuration)' == 'Release' And '$(CI)' == 'true'">
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
<Deterministic>true</Deterministic>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
</PropertyGroup>

<Target Name="SetVersionFromConcourseData" AfterTargets="MinVer" Condition="'$(CONCOURSE_PULL_REQUEST_NUMBER)' != ''">
<PropertyGroup>
<PackageVersion>$(MinVerMajor).$(MinVerMinor).$(MinVerPatch)-$(MinVerPreRelease)-pr.$(CONCOURSE_PULL_REQUEST_NUMBER)</PackageVersion>
<PackageVersion Condition="'$(MinVerBuildMetadata)' != ''">$(PackageVersion)+$(MinVerBuildMetadata)</PackageVersion>
<Version>$(PackageVersion)</Version>
</PropertyGroup>
<Message Importance="normal" Text="SetVersionFromConcourseData: PackageVersion=$(PackageVersion) Version=$(Version)" />
</Target>
<ItemGroup Condition="'$(Configuration)' == 'Release' and '$(SourceRoot)' == ''">
<SourceRoot Include="$(MSBuildThisFileDirectory)/"/>
</ItemGroup>

<ItemGroup>
<None Remove="icon.png" />
Expand Down
5 changes: 0 additions & 5 deletions projects/Unit/Fixtures.cs
Expand Up @@ -372,11 +372,6 @@ internal void AssertPreconditionFailed(ShutdownEventArgs args)
AssertShutdownError(args, Constants.PreconditionFailed);
}

internal bool InitiatedByPeerOrLibrary(ShutdownEventArgs evt)
{
return !(evt.Initiator == ShutdownInitiator.Application);
}

//
// Concurrency
//
Expand Down

0 comments on commit d786db1

Please sign in to comment.