From 663aecedd1c80cdc5906723d2980d7541b5c1bac Mon Sep 17 00:00:00 2001
From: Julian Verdurmen <5808377+304NotModified@users.noreply.github.com>
Date: Mon, 9 Nov 2026 16:23:21 +0100
Subject: [PATCH 1/2] Migrate CI from AppVeyor to GitHub Actions
---
.github/workflows/ci.yml | 140 ++++++++++++++++++
.gitignore | 1 +
NLog.PerformanceCounter.sln | 2 +-
README.md | 2 +-
appveyor.yml | 21 ---
codecov.yml | 12 ++
src/Directory.Build.props | 8 +
.../NLog.PerformanceCounter.csproj | 5 +-
.../NLog.PerformanceCounter.Tests.csproj | 3 +
.../PerformanceCounterLayoutRendererTests.cs | 5 +-
10 files changed, 171 insertions(+), 28 deletions(-)
create mode 100644 .github/workflows/ci.yml
delete mode 100644 appveyor.yml
create mode 100644 codecov.yml
create mode 100644 src/Directory.Build.props
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
new file mode 100644
index 0000000..81b4179
--- /dev/null
+++ b/.github/workflows/ci.yml
@@ -0,0 +1,140 @@
+name: CI
+
+on:
+ push:
+ branches:
+ - master
+ pull_request:
+ workflow_dispatch:
+ inputs:
+ force_nuget_publish:
+ description: Force NuGet publish for non-master builds
+ type: boolean
+ default: false
+
+env:
+ SOLUTION: NLog.PerformanceCounter.sln
+ TEST_PROJECT: tests/NLog.PerformanceCounter.Tests/NLog.PerformanceCounter.Tests.csproj
+
+jobs:
+ build:
+ name: ${{ matrix.name }}
+ strategy:
+ matrix:
+ include:
+ - os: windows-latest
+ name: Build & test (Windows)
+ upload_coverage: true
+ - os: ubuntu-latest
+ name: Build & test (Ubuntu)
+ upload_coverage: false
+ runs-on: ${{ matrix.os }}
+ permissions:
+ contents: read
+
+ steps:
+ - uses: actions/checkout@v7
+
+ - name: Restore
+ run: dotnet restore ${{ env.SOLUTION }}
+
+ - name: Build
+ if: runner.os == 'Windows'
+ run: dotnet build ${{ env.SOLUTION }} --configuration Release --no-restore
+
+ - name: Build net8.0
+ if: runner.os == 'Linux'
+ run: dotnet build ${{ env.TEST_PROJECT }} --framework net8.0 --configuration Release --no-restore
+
+ - name: Test net461
+ if: runner.os == 'Windows'
+ run: dotnet test ${{ env.TEST_PROJECT }} --framework net461 --configuration Release --no-restore --no-build --logger GitHubActions
+
+ - name: Test net8.0 with coverage
+ if: runner.os == 'Windows'
+ run: dotnet test ${{ env.TEST_PROJECT }} --framework net8.0 --configuration Release --no-restore --no-build --collect:"XPlat Code Coverage" --logger GitHubActions
+
+ - name: Test net8.0 on Linux
+ if: runner.os == 'Linux'
+ run: dotnet test ${{ env.TEST_PROJECT }} --framework net8.0 --configuration Release --no-restore --no-build --logger GitHubActions
+
+ - name: Upload coverage to Codecov
+ if: matrix.upload_coverage
+ uses: codecov/codecov-action@303a32d7a59b442fa8d48b6a1cc6825c09c847a5 # https://github.com/codecov/codecov-action/releases/tag/v7.1.1
+ with:
+ token: ${{ secrets.CODECOV_TOKEN }}
+ files: tests/**/TestResults/**/coverage.cobertura.xml
+ fail_ci_if_error: true
+
+ pack:
+ name: Create NuGet package
+ runs-on: windows-latest
+ permissions:
+ contents: read
+
+ steps:
+ - uses: actions/checkout@v7
+
+ - name: Restore
+ run: dotnet restore ${{ env.SOLUTION }}
+
+ - name: Determine version suffix
+ id: version
+ shell: pwsh
+ env:
+ REF: ${{ github.ref }}
+ PR_NUMBER: ${{ github.event.pull_request.number }}
+ RUN_NUMBER: ${{ github.run_number }}
+ run: |
+ if ($env:REF -eq "refs/heads/master") {
+ echo "suffix=" >> $env:GITHUB_OUTPUT
+ } elseif ($env:PR_NUMBER) {
+ echo "suffix=pr.$($env:PR_NUMBER).ci.$($env:RUN_NUMBER)" >> $env:GITHUB_OUTPUT
+ } else {
+ echo "suffix=ci.$($env:RUN_NUMBER)" >> $env:GITHUB_OUTPUT
+ }
+
+ - name: Create NuGet package
+ shell: pwsh
+ env:
+ VERSION_SUFFIX: ${{ steps.version.outputs.suffix }}
+ run: dotnet pack $env:SOLUTION --no-restore --configuration Release --output artifacts -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg -p:EmbedUntrackedSources=true -p:PublishRepositoryUrl=true -p:ContinuousIntegrationBuild=true --version-suffix "$env:VERSION_SUFFIX"
+
+ - name: Upload NuGet package
+ uses: actions/upload-artifact@v7
+ with:
+ name: NuGetPackages
+ path: |
+ artifacts/*.nupkg
+ artifacts/*.snupkg
+ if-no-files-found: error
+
+ publish:
+ name: Publish NuGet package
+ needs: [build, pack]
+ if: >-
+ (github.event_name == 'push' && github.ref == 'refs/heads/master') ||
+ (github.event_name == 'workflow_dispatch' && inputs.force_nuget_publish)
+ runs-on: ubuntu-latest
+ permissions:
+ contents: read
+ id-token: write
+
+ steps:
+ - name: Download NuGet package
+ uses: actions/download-artifact@v7
+ with:
+ name: NuGetPackages
+ path: artifacts
+
+ - name: NuGet login
+ uses: NuGet/login@8d196754b4036150537f80ac539e15c2f1028841 # v1.2
+ id: login
+ with:
+ user: ${{ secrets.NUGET_USER }}
+
+ - name: Push to NuGet.org
+ shell: pwsh
+ env:
+ NUGET_API_KEY: ${{ steps.login.outputs.NUGET_API_KEY }}
+ run: dotnet nuget push "artifacts/*.nupkg" --api-key $env:NUGET_API_KEY --source https://api.nuget.org/v3/index.json --skip-duplicate
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
index dfcfd56..fadd366 100644
--- a/.gitignore
+++ b/.gitignore
@@ -17,6 +17,7 @@
mono_crash.*
# Build results
+N.png
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
diff --git a/NLog.PerformanceCounter.sln b/NLog.PerformanceCounter.sln
index f7520c7..7744951 100644
--- a/NLog.PerformanceCounter.sln
+++ b/NLog.PerformanceCounter.sln
@@ -9,7 +9,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NLog.PerformanceCounter.Tes
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{B9CD43EE-2A8A-4AB8-B2CA-2A3C9190A08D}"
ProjectSection(SolutionItems) = preProject
- appveyor.yml = appveyor.yml
+ .github\workflows\ci.yml = .github\workflows\ci.yml
README.md = README.md
EndProjectSection
EndProject
diff --git a/README.md b/README.md
index ff3ca34..92d5ddc 100644
--- a/README.md
+++ b/README.md
@@ -2,7 +2,7 @@
NLog extensions to [Display Windows Performance Counters](https://github.com/NLog/NLog/wiki/PerformanceCounter-Layout-Renderer) and [Update Windows Performance Counters](https://github.com/NLog/NLog/wiki/PerfCounter-target)
[](https://www.nuget.org/packages/NLog.PerformanceCounter)
-[](https://ci.appveyor.com/project/nlog/NLog-PerformanceCounter/branch/master)
+[](https://github.com/NLog/NLog.PerformanceCounter/actions/workflows/ci.yml)
### How to install
diff --git a/appveyor.yml b/appveyor.yml
deleted file mode 100644
index 9bd49ac..0000000
--- a/appveyor.yml
+++ /dev/null
@@ -1,21 +0,0 @@
-version: 5.0.0.{build}
-image: Visual Studio 2022
-configuration: Release
-platform: Any CPU
-skip_tags: true
-skip_branch_with_pr: true
-nuget:
- disable_publish_on_pr: true
-build_script:
-- ps: msbuild /t:restore,pack /p:Configuration=Release /p:IncludeSymbols=true /p:SymbolPackageFormat=snupkg /p:ContinuousIntegrationBuild=true /p:EmbedUntrackedSources=true /p:PublishRepositoryUrl=true /verbosity:minimal
-test_script:
-- ps: dotnet test tests\NLog.PerformanceCounter.Tests\NLog.PerformanceCounter.Tests.csproj
-artifacts:
- - path: '**\NLog.*.nupkg'
- - path: '**\NLog.*.snupkg'
-deploy:
-- provider: NuGet
- api_key:
- secure: FStb6Kr5sjHdPq4EzjHeXkW4DQDlS92kM9ZWDhApT68+j4WN7J7cnvvk3fj/hMxi
- on:
- branch: master
diff --git a/codecov.yml b/codecov.yml
new file mode 100644
index 0000000..0ff4876
--- /dev/null
+++ b/codecov.yml
@@ -0,0 +1,12 @@
+coverage:
+ precision: 2
+ round: down
+ range: "60...70"
+ status:
+ project:
+ default:
+ target: 70%
+ patch:
+ default:
+ target: auto
+ threshold: 1%
\ No newline at end of file
diff --git a/src/Directory.Build.props b/src/Directory.Build.props
new file mode 100644
index 0000000..552d14f
--- /dev/null
+++ b/src/Directory.Build.props
@@ -0,0 +1,8 @@
+