From ee28cea69073c147f258ec64ce94b4cbb5b28370 Mon Sep 17 00:00:00 2001 From: Ashley Mannix Date: Tue, 21 Jan 2025 09:03:35 +1000 Subject: [PATCH 1/7] port to GitHub Actions --- .github/workflows/ci.yml | 40 +++++++++++++++++ Build.ps1 | 92 ++++++++++++++++++++++++++-------------- appveyor.yml | 23 ---------- 3 files changed, 101 insertions(+), 54 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 appveyor.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..d580450 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,40 @@ +# If this file is renamed, the incrementing run attempt number will be reset. + +name: CI + +on: + push: + branches: [ "dev", "main" ] + pull_request: + branches: [ "dev", "main" ] + +env: + CI_BUILD_NUMBER_BASE: ${{ github.run_number }} + CI_TARGET_BRANCH: ${{ github.head_ref || github.ref_name }} + +jobs: + build: + + runs-on: windows-latest + + permissions: + contents: write + + steps: + - uses: actions/checkout@v4 + - name: Setup + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 9.0.x + - name: Compute build number + shell: bash + run: | + echo "CI_BUILD_NUMBER=$(($CI_BUILD_NUMBER_BASE+2300))" >> $GITHUB_ENV + - name: Build and Publish + env: + DOTNET_CLI_TELEMETRY_OPTOUT: true + NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + shell: pwsh + run: | + ./Build.ps1 diff --git a/Build.ps1 b/Build.ps1 index dc24499..e798284 100644 --- a/Build.ps1 +++ b/Build.ps1 @@ -1,49 +1,79 @@ -# This script originally (c) 2016 Serilog Contributors - license Apache 2.0 +Write-Output "build: Tool versions follow" -echo "build: Build started" +dotnet --version +dotnet --list-sdks + +Write-Output "build: Build started" Push-Location $PSScriptRoot +try { + if(Test-Path .\artifacts) { + Write-Output "build: Cleaning ./artifacts" + Remove-Item ./artifacts -Force -Recurse + } -if(Test-Path .\artifacts) { - echo "build: Cleaning .\artifacts" - Remove-Item .\artifacts -Force -Recurse -} + & dotnet restore --no-cache + + $dbp = [Xml] (Get-Content .\Directory.Version.props) + $versionPrefix = $dbp.Project.PropertyGroup.VersionPrefix -& dotnet restore --no-cache -if($LASTEXITCODE -ne 0) { exit 1 } + Write-Output "build: Package version prefix is $versionPrefix" -$branch = @{ $true = $env:APPVEYOR_REPO_BRANCH; $false = $(git symbolic-ref --short -q HEAD) }[$env:APPVEYOR_REPO_BRANCH -ne $NULL]; -$revision = @{ $true = "{0:00000}" -f [convert]::ToInt32("0" + $env:APPVEYOR_BUILD_NUMBER, 10); $false = "local" }[$env:APPVEYOR_BUILD_NUMBER -ne $NULL]; -$suffix = @{ $true = ""; $false = "$($branch.Substring(0, [math]::Min(10,$branch.Length)))-$revision"}[$branch -eq "main" -and $revision -ne "local"] + $branch = @{ $true = $env:CI_TARGET_BRANCH; $false = $(git symbolic-ref --short -q HEAD) }[$NULL -ne $env:CI_TARGET_BRANCH]; + $revision = @{ $true = "{0:00000}" -f [convert]::ToInt32("0" + $env:CI_BUILD_NUMBER, 10); $false = "local" }[$NULL -ne $env:CI_BUILD_NUMBER]; + $suffix = @{ $true = ""; $false = "$($branch.Substring(0, [math]::Min(10,$branch.Length)) -replace '([^a-zA-Z0-9\-]*)', '')-$revision"}[$branch -eq "main" -and $revision -ne "local"] + $commitHash = $(git rev-parse --short HEAD) + $buildSuffix = @{ $true = "$($suffix)-$($commitHash)"; $false = "$($branch)-$($commitHash)" }[$suffix -ne ""] -echo "build: Version suffix is $suffix" + Write-Output "build: Package version suffix is $suffix" + Write-Output "build: Build version suffix is $buildSuffix" -foreach ($src in ls src/*) { - Push-Location $src + & dotnet build -c Release --version-suffix=$buildSuffix /p:ContinuousIntegrationBuild=true + if($LASTEXITCODE -ne 0) { throw "Build failed" } - echo "build: Packaging project in $src" + foreach ($src in Get-ChildItem src/*) { + Push-Location $src - if ($suffix) { - & dotnet publish -c Release -o ./obj/publish --version-suffix=$suffix - & dotnet pack -c Release -o ..\..\artifacts --no-build --version-suffix=$suffix - } else { - & dotnet publish -c Release -o ./obj/publish - & dotnet pack -c Release -o ..\..\artifacts --no-build + Write-Output "build: Packaging project in $src" + + if ($suffix) { + & dotnet pack -c Release --no-build --no-restore -o ../../artifacts --version-suffix=$suffix + } else { + & dotnet pack -c Release --no-build --no-restore -o ../../artifacts + } + if($LASTEXITCODE -ne 0) { throw "Packaging failed" } + + Pop-Location } - if($LASTEXITCODE -ne 0) { exit 1 } - Pop-Location -} + foreach ($test in Get-ChildItem test/*.Tests) { + Push-Location $test -foreach ($test in ls test/*.Tests) { - Push-Location $test + Write-Output "build: Testing project in $test" - echo "build: Testing project in $test" + & dotnet test -c Release --no-build --no-restore + if($LASTEXITCODE -ne 0) { throw "Testing failed" } - & dotnet test -c Release - if($LASTEXITCODE -ne 0) { exit 3 } + Pop-Location + } + + if ($env:NUGET_API_KEY) { + # GitHub Actions will only supply this to branch builds and not PRs. We publish + # builds from any branch this action targets (i.e. main and dev). + + Write-Output "build: Publishing NuGet packages" + + foreach ($nupkg in Get-ChildItem artifacts/*.nupkg) { + & dotnet nuget push -k $env:NUGET_API_KEY -s https://api.nuget.org/v3/index.json "$nupkg" + if($LASTEXITCODE -ne 0) { throw "Publishing failed" } + } + if (!($suffix)) { + Write-Output "build: Creating release for version $versionPrefix" + + iex "gh release create v$versionPrefix --title v$versionPrefix --generate-notes $(get-item ./artifacts/*.nupkg) $(get-item ./artifacts/*.snupkg)" + } + } +} finally { Pop-Location } - -Pop-Location diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 4db264c..0000000 --- a/appveyor.yml +++ /dev/null @@ -1,23 +0,0 @@ -version: '{build}' -skip_tags: true -image: Visual Studio 2022 -install: -build_script: -- ps: ./Build.ps1 -test: off -artifacts: -- path: artifacts/Seq.Input.RabbitMQ.*.nupkg -deploy: -- provider: NuGet - api_key: - secure: HDcRadKRDne9Gd1vEQwZknRQz63ZbZMJh6e4sFmiXCpjkxC5WCoQ0ZecWBHtVulX - skip_symbols: true - on: - branch: /^(main|dev)$/ -- provider: GitHub - auth_token: - secure: hX+cZmW+9BCXy7vyH8myWsYdtQHyzzil9K5yvjJv7dK9XmyrGYYDj/DPzMqsXSjo - artifact: /Seq.Input.RabbitMQ.*\.nupkg/ - tag: v$(appveyor_build_version) - on: - branch: main From d194181d42c4ee3cb26daf0fc32175dba860f791 Mon Sep 17 00:00:00 2001 From: Ashley Mannix Date: Tue, 21 Jan 2025 10:39:41 +1000 Subject: [PATCH 2/7] try running CI on ubuntu --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d580450..b15d368 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,7 +15,7 @@ env: jobs: build: - runs-on: windows-latest + runs-on: ubuntu-latest permissions: contents: write From 15f43afc37853e38a4458ff79c690bf64e255c7e Mon Sep 17 00:00:00 2001 From: Ashley Mannix Date: Tue, 21 Jan 2025 10:44:17 +1000 Subject: [PATCH 3/7] add version props --- Directory.Version.props | 5 +++++ src/Seq.Input.RabbitMQ/Seq.Input.RabbitMQ.csproj | 1 - 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 Directory.Version.props diff --git a/Directory.Version.props b/Directory.Version.props new file mode 100644 index 0000000..e7bbeca --- /dev/null +++ b/Directory.Version.props @@ -0,0 +1,5 @@ + + + 1.0.0 + + diff --git a/src/Seq.Input.RabbitMQ/Seq.Input.RabbitMQ.csproj b/src/Seq.Input.RabbitMQ/Seq.Input.RabbitMQ.csproj index 133247d..136eb18 100644 --- a/src/Seq.Input.RabbitMQ/Seq.Input.RabbitMQ.csproj +++ b/src/Seq.Input.RabbitMQ/Seq.Input.RabbitMQ.csproj @@ -1,7 +1,6 @@ netstandard2.0 - 1.0.0 Ingest events into Seq directly from RabbitMQ Datalust and Contributors seq-app From 9158d6a3a419092d04310a9f3cfdf40ec9b2581f Mon Sep 17 00:00:00 2001 From: Ashley Mannix Date: Tue, 21 Jan 2025 10:48:51 +1000 Subject: [PATCH 4/7] remove stubbed test project --- seq-input-rabbitmq.sln | 4 ---- .../Seq.Input.RabbitMQ.Tests.csproj | 15 --------------- test/Seq.Input.RabbitMQ.Tests/UnitTest1.cs | 14 -------------- 3 files changed, 33 deletions(-) delete mode 100644 test/Seq.Input.RabbitMQ.Tests/Seq.Input.RabbitMQ.Tests.csproj delete mode 100644 test/Seq.Input.RabbitMQ.Tests/UnitTest1.cs diff --git a/seq-input-rabbitmq.sln b/seq-input-rabbitmq.sln index 18c6811..aa66fa0 100644 --- a/seq-input-rabbitmq.sln +++ b/seq-input-rabbitmq.sln @@ -12,12 +12,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "sln", "sln", "{7D1D14F7-D40 EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{704915B0-6D95-4CF8-ACC2-5ED939A2913C}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{BE42997A-5927-46E1-AFB5-C1D7A255212E}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Seq.Input.RabbitMQ", "src\Seq.Input.RabbitMQ\Seq.Input.RabbitMQ.csproj", "{E80E7949-A3AE-4C7C-9083-9FE9EE1F78E0}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Seq.Input.RabbitMQ.Tests", "test\Seq.Input.RabbitMQ.Tests\Seq.Input.RabbitMQ.Tests.csproj", "{9FF2C707-DD8D-4B9C-97A7-4E9F0D9D0008}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "example", "example", "{584683E5-0578-42F0-A958-3AAB3661AA9E}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Demo", "example\Demo\Demo.csproj", "{99D4AAE3-35B3-4BE1-AA5F-7CC8E6B49A07}" diff --git a/test/Seq.Input.RabbitMQ.Tests/Seq.Input.RabbitMQ.Tests.csproj b/test/Seq.Input.RabbitMQ.Tests/Seq.Input.RabbitMQ.Tests.csproj deleted file mode 100644 index 4ec64e7..0000000 --- a/test/Seq.Input.RabbitMQ.Tests/Seq.Input.RabbitMQ.Tests.csproj +++ /dev/null @@ -1,15 +0,0 @@ - - - - netcoreapp2.1 - - false - - - - - - - - - diff --git a/test/Seq.Input.RabbitMQ.Tests/UnitTest1.cs b/test/Seq.Input.RabbitMQ.Tests/UnitTest1.cs deleted file mode 100644 index 1cac84f..0000000 --- a/test/Seq.Input.RabbitMQ.Tests/UnitTest1.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; -using Xunit; - -namespace Seq.Input.RabbitMQ.Tests -{ - public class UnitTest1 - { - [Fact] - public void Test1() - { - - } - } -} From 92b49fc12244a0aef991428fa5d72653c8935f03 Mon Sep 17 00:00:00 2001 From: Ashley Mannix Date: Tue, 21 Jan 2025 10:52:41 +1000 Subject: [PATCH 5/7] more project updates --- example/Demo/Demo.csproj | 2 +- seq-input-rabbitmq.sln | 5 ----- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/example/Demo/Demo.csproj b/example/Demo/Demo.csproj index 4686712..6f5ce49 100644 --- a/example/Demo/Demo.csproj +++ b/example/Demo/Demo.csproj @@ -1,7 +1,7 @@  - netcoreapp2.1 + net9.0 Exe diff --git a/seq-input-rabbitmq.sln b/seq-input-rabbitmq.sln index aa66fa0..089c208 100644 --- a/seq-input-rabbitmq.sln +++ b/seq-input-rabbitmq.sln @@ -28,10 +28,6 @@ Global {E80E7949-A3AE-4C7C-9083-9FE9EE1F78E0}.Debug|Any CPU.Build.0 = Debug|Any CPU {E80E7949-A3AE-4C7C-9083-9FE9EE1F78E0}.Release|Any CPU.ActiveCfg = Release|Any CPU {E80E7949-A3AE-4C7C-9083-9FE9EE1F78E0}.Release|Any CPU.Build.0 = Release|Any CPU - {9FF2C707-DD8D-4B9C-97A7-4E9F0D9D0008}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {9FF2C707-DD8D-4B9C-97A7-4E9F0D9D0008}.Debug|Any CPU.Build.0 = Debug|Any CPU - {9FF2C707-DD8D-4B9C-97A7-4E9F0D9D0008}.Release|Any CPU.ActiveCfg = Release|Any CPU - {9FF2C707-DD8D-4B9C-97A7-4E9F0D9D0008}.Release|Any CPU.Build.0 = Release|Any CPU {99D4AAE3-35B3-4BE1-AA5F-7CC8E6B49A07}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {99D4AAE3-35B3-4BE1-AA5F-7CC8E6B49A07}.Debug|Any CPU.Build.0 = Debug|Any CPU {99D4AAE3-35B3-4BE1-AA5F-7CC8E6B49A07}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -42,7 +38,6 @@ Global EndGlobalSection GlobalSection(NestedProjects) = preSolution {E80E7949-A3AE-4C7C-9083-9FE9EE1F78E0} = {704915B0-6D95-4CF8-ACC2-5ED939A2913C} - {9FF2C707-DD8D-4B9C-97A7-4E9F0D9D0008} = {BE42997A-5927-46E1-AFB5-C1D7A255212E} {99D4AAE3-35B3-4BE1-AA5F-7CC8E6B49A07} = {584683E5-0578-42F0-A958-3AAB3661AA9E} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution From 3969e43165978fe740cb17be82e99d80c312bb63 Mon Sep 17 00:00:00 2001 From: Ashley Mannix Date: Tue, 21 Jan 2025 10:54:27 +1000 Subject: [PATCH 6/7] make test running conditional --- Build.ps1 | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Build.ps1 b/Build.ps1 index e798284..5439920 100644 --- a/Build.ps1 +++ b/Build.ps1 @@ -46,15 +46,17 @@ try { Pop-Location } - foreach ($test in Get-ChildItem test/*.Tests) { - Push-Location $test + if(Test-Path .\test) { + foreach ($test in Get-ChildItem test/*.Tests) { + Push-Location $test - Write-Output "build: Testing project in $test" + Write-Output "build: Testing project in $test" - & dotnet test -c Release --no-build --no-restore - if($LASTEXITCODE -ne 0) { throw "Testing failed" } + & dotnet test -c Release --no-build --no-restore + if($LASTEXITCODE -ne 0) { throw "Testing failed" } - Pop-Location + Pop-Location + } } if ($env:NUGET_API_KEY) { From a61fb1fb02d12b093379ec7133e50d3632d7de7f Mon Sep 17 00:00:00 2001 From: Ashley Mannix Date: Tue, 21 Jan 2025 10:57:26 +1000 Subject: [PATCH 7/7] update build badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 34a1eb3..dab0623 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Seq.Input.RabbitMQ [![Build status](https://ci.appveyor.com/api/projects/status/lxab9qqdtqupk6y4?svg=true)](https://ci.appveyor.com/project/datalust/seq-input-rabbitmq) +# Seq.Input.RabbitMQ [![CI](https://github.com/datalust/seq-input-rabbitmq/actions/workflows/ci.yml/badge.svg)](https://github.com/datalust/seq-input-rabbitmq/actions/workflows/ci.yml) A Seq custom input that pulls events from RabbitMQ. **Requires Seq 5.1+.**