Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
140 changes: 140 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
mono_crash.*

# Build results
N.png
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
Expand Down
2 changes: 1 addition & 1 deletion NLog.PerformanceCounter.sln
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

[![Version](https://badge.fury.io/nu/NLog.PerformanceCounter.svg)](https://www.nuget.org/packages/NLog.PerformanceCounter)
[![AppVeyor](https://img.shields.io/appveyor/ci/nlog/NLog-PerformanceCounter/master.svg)](https://ci.appveyor.com/project/nlog/NLog-PerformanceCounter/branch/master)
[![CI](https://github.com/NLog/NLog.PerformanceCounter/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/NLog/NLog.PerformanceCounter/actions/workflows/ci.yml)


### How to install
Expand Down
21 changes: 0 additions & 21 deletions appveyor.yml

This file was deleted.

12 changes: 12 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
coverage:
precision: 2
round: down
range: "60...70"
status:
project:
default:
target: 70%
patch:
default:
target: auto
threshold: 1%
8 changes: 8 additions & 0 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project>
<PropertyGroup>
<NuGetAudit>true</NuGetAudit>
<NuGetAuditMode>all</NuGetAuditMode>
<NuGetAuditLevel>low</NuGetAuditLevel>
<WarningsAsErrors>$(WarningsAsErrors);NU1900;NU1901;NU1902;NU1903;NU1904</WarningsAsErrors>
</PropertyGroup>
</Project>
8 changes: 2 additions & 6 deletions src/NLog.PerformanceCounter/NLog.PerformanceCounter.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,12 @@

<AssemblyVersion>5.0.0.0</AssemblyVersion>
<!-- AssemblyVersion must be fixed on 5.0.0.0 -->
<AppVeyorBuildNumber>$(APPVEYOR_BUILD_NUMBER)</AppVeyorBuildNumber>
<AppVeyorBuildNumber Condition="'$(AppVeyorBuildNumber)' == ''">0</AppVeyorBuildNumber>
<FileVersion>$(VersionPrefix).$(AppVeyorBuildNumber)</FileVersion>
<FileVersion>$(VersionPrefix).0</FileVersion>

<Title>NLog Windows PerformanceCounter</Title>
<Company>NLog</Company>
<Description>NLog.PerformanceCounter provides support for Windows Performance Counters</Description>
<Product>NLog.PerformanceCounter v$(ProductVersion)</Product>
<InformationalVersion>$(ProductVersion)</InformationalVersion>
<Product>NLog.PerformanceCounter v$(VersionPrefix)</Product>
<Authors>Jarek Kowalski,Kim Christensen,Julian Verdurmen</Authors>
<CurrentYear>$([System.DateTime]::Now.ToString(yyyy))</CurrentYear>
<Copyright>Copyright (c) 2004-$(CurrentYear) NLog Project - https://nlog-project.org/ </Copyright>
Expand Down Expand Up @@ -75,7 +72,6 @@ https://github.com/NLog/NLog/wiki/PerformanceCounter-Layout-Renderer
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
<PackageReference Include="NLog" Version="5.2.2" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageReference Include="coverlet.collector" Version="10.1.0" PrivateAssets="all" />
<PackageReference Include="GitHubActionsTestLogger" Version="3.0.5" PrivateAssets="all" />
<PackageReference Include="xunit" Version="2.8.1" />
<PackageReference Include="Xunit.SkippableFact" Version="1.4.13" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ namespace NLog.PerformanceCounter.Tests
{
using Xunit;
using NLog.LayoutRenderers;
using System;

public class PerformanceCounterLayoutRendererTests
{
Expand All @@ -43,9 +44,11 @@ public PerformanceCounterLayoutRendererTests()
LogManager.ThrowExceptions = true;
}

[Fact]
[SkippableFact]
public void PerformanceCounterLayoutRendererTest()
{
Skip.IfNot(Environment.OSVersion.Platform == PlatformID.Win32NT, "Performance counters are only supported on Windows.");

var logFactory = new LogFactory().Setup().SetupExtensions(ext => ext.RegisterLayoutRenderer<PerformanceCounterLayoutRenderer>("performancecounter")).
LoadConfigurationFromXml(@"
<nlog>
Expand Down
Loading