Skip to content

Commit 019070a

Browse files
authored
add net9 target and tests (#692)
* net9 * different build leg * fix proj * fix test * default concurrency * correct version * more tests * cleanup * publish coverage for net6
1 parent 28e4692 commit 019070a

File tree

6 files changed

+59
-15
lines changed

6 files changed

+59
-15
lines changed

.github/workflows/gate.yml

Lines changed: 49 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@ jobs:
2222
with:
2323
dotnet-version: |
2424
3.1.x
25-
6.0.x
26-
8.0.x
27-
9.0.x
25+
2826
- name: Install dependencies
2927
run: dotnet restore
3028
- name: Build
@@ -55,6 +53,32 @@ jobs:
5553
flag-name: win3
5654
parallel: true
5755

56+
- name: Publish NuGet artifacts
57+
uses: actions/upload-artifact@v4
58+
with:
59+
name: NuGet package
60+
path: BitFaster.Caching/bin/Release/
61+
win2:
62+
63+
runs-on: windows-latest
64+
65+
permissions:
66+
checks: write
67+
68+
steps:
69+
- uses: actions/checkout@v4
70+
- name: Setup .NET Core
71+
uses: actions/setup-dotnet@v4
72+
with:
73+
dotnet-version: |
74+
6.0.x
75+
8.0.x
76+
9.0.x
77+
- name: Install dependencies
78+
run: dotnet restore
79+
- name: Build
80+
run: dotnet build --configuration Release --no-restore
81+
5882
- name: Test (6.0)
5983
run: dotnet test --no-restore --verbosity normal -f net6.0 /p:CollectCoverage=true /p:CoverletOutput=TestResults/ /p:CoverletOutputFormat=lcov --logger "trx;LogFileName=results6.trx"
6084
- name: Upload test results (6.0)
@@ -69,7 +93,7 @@ jobs:
6993
with:
7094
name: test-results-win6-std
7195
path: BitFaster.Caching.UnitTests.Std/TestResults/results6.trx
72-
96+
7397
- name: Publish coverage report to coveralls.io (6.0)
7498
uses: coverallsapp/github-action@master
7599
with:
@@ -78,11 +102,28 @@ jobs:
78102
flag-name: win6
79103
parallel: true
80104

81-
- name: Publish NuGet artifacts
105+
- name: Test (9.0)
106+
run: dotnet test --no-restore --verbosity normal -f net9.0 /p:CollectCoverage=true /p:CoverletOutput=TestResults/ /p:CoverletOutputFormat=lcov --logger "trx;LogFileName=results9.trx"
107+
- name: Upload test results (9.0)
108+
uses: actions/upload-artifact@v4 # upload test results
109+
if: success() || failure() # run this step even if previous step failed
110+
with:
111+
name: test-results-win9
112+
path: BitFaster.Caching.UnitTests/TestResults/results9.trx
113+
- name: Upload test results (9.0 .NET Std)
82114
uses: actions/upload-artifact@v4
115+
if: success() || failure()
83116
with:
84-
name: NuGet package
85-
path: BitFaster.Caching/bin/Release/
117+
name: test-results-win9-std
118+
path: BitFaster.Caching.UnitTests.Std/TestResults/results9.trx
119+
120+
- name: Publish coverage report to coveralls.io (9.0)
121+
uses: coverallsapp/github-action@master
122+
with:
123+
github-token: ${{ secrets.GITHUB_TOKEN }}
124+
path-to-lcov: BitFaster.Caching.UnitTests/TestResults/coverage.net9.0.info
125+
flag-name: win9
126+
parallel: true
86127

87128
mac:
88129

@@ -170,7 +211,7 @@ jobs:
170211

171212
coverage:
172213

173-
needs: [win, mac, linux]
214+
needs: [win, win2, mac, linux]
174215

175216
runs-on: ubuntu-latest
176217

BitFaster.Caching.UnitTests/BitFaster.Caching.UnitTests.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net48;netcoreapp3.1;net6.0</TargetFrameworks>
5-
<LangVersion>9.0</LangVersion>
4+
<TargetFrameworks>net48;netcoreapp3.1;net6.0;net9.0</TargetFrameworks>
5+
<LangVersion>10.0</LangVersion>
66
</PropertyGroup>
77

88
<ItemGroup>

BitFaster.Caching.UnitTests/Lfu/ConcurrentLfuBuilderTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public class ConcurrentLfuBuilderTests
1313
public void TestConcurrencyLevel()
1414
{
1515
var b = new ConcurrentLfuBuilder<int, int>()
16-
.WithConcurrencyLevel(-1);
16+
.WithConcurrencyLevel(0);
1717

1818
Action constructor = () => { var x = b.Build(); };
1919

BitFaster.Caching.UnitTests/Lru/ConcurrentLruBuilderTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public void TestComparer()
109109
public void TestConcurrencyLevel()
110110
{
111111
var b = new ConcurrentLruBuilder<int, int>()
112-
.WithConcurrencyLevel(-1);
112+
.WithConcurrencyLevel(0);
113113

114114
Action constructor = () => { var x = b.Build(); };
115115

BitFaster.Caching/BitFaster.Caching.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>netstandard2.0;netcoreapp3.1;net6.0</TargetFrameworks>
4+
<TargetFrameworks>netstandard2.0;netcoreapp3.1;net6.0;net9.0</TargetFrameworks>
55
<LangVersion>11.0</LangVersion>
66
<Authors>Alex Peck</Authors>
77
<Company />

BitFaster.Caching/Lru/Defaults.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
using System;
2-
using System.Collections.Generic;
3-
using System.Text;
42

53
namespace BitFaster.Caching.Lru
64
{
75
internal static class Defaults
86
{
7+
#if NET8_0_OR_GREATER
8+
// Note that on .net8+, -1 indicates the default concurrency level
9+
public static int ConcurrencyLevel => -1;
10+
#else
911
public static int ConcurrencyLevel => Environment.ProcessorCount;
12+
#endif
1013
}
1114
}

0 commit comments

Comments
 (0)