Skip to content

Commit

Permalink
Upgrade CI build to .Net 9.0
Browse files Browse the repository at this point in the history
  • Loading branch information
xaviersolau committed Dec 16, 2024
1 parent e7deb0b commit 871ffe4
Show file tree
Hide file tree
Showing 6 changed files with 111 additions and 75 deletions.
79 changes: 51 additions & 28 deletions .github/workflows/build-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,60 +6,83 @@ on:

jobs:
build-ci:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.101
dotnet-version: 9.0.101
- name: Install dependencies
run: dotnet restore
- name: Build
run: dotnet build --configuration Release --no-restore
- name: Test
run: dotnet test --configuration Release --no-restore --no-build

- name: Test Coverage SoloX.TableModel.UTests
id: coverage-utest
run: |
dotnet test ./src/tests/SoloX.TableModel.UTests --configuration Release --no-restore --no-build --collect:"XPlat Code Coverage" --settings coverlet.runsettings
echo "::set-output name=FILE::$(find ./src/tests/SoloX.TableModel.UTests -name 'coverage.info' -print)"
- name: Send to coverals
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: ${{ steps.coverage-utest.outputs.FILE }}
flag-name: coverage-utest
parallel: true
coverage-ci:
needs: build-ci
runs-on: ubuntu-latest

strategy:
matrix:
test_path:
- src/tests/SoloX.TableModel.UTests
- src/tests/SoloX.TableModel.Server.UTests

- name: Test Coverage SoloX.TableModel.Server.UTests
id: coverage-utest-server
run: |
dotnet test ./src/tests/SoloX.TableModel.Server.UTests --configuration Release --no-restore --no-build --collect:"XPlat Code Coverage" --settings coverlet.runsettings
echo "::set-output name=FILE::$(find ./src/tests/SoloX.TableModel.Server.UTests -name 'coverage.info' -print)"
steps:
- uses: actions/checkout@v2
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 9.0.101
- name: Install dependencies ${{ matrix.test_path }}
run: dotnet restore ${{ matrix.test_path }}
- name: Build ${{ matrix.test_path }}
run: dotnet build ${{ matrix.test_path }} --configuration Release --no-restore
- name: Test Coverage ${{ matrix.test_path }}
run: dotnet test ${{ matrix.test_path }} --configuration Release --no-restore --no-build --collect:"XPlat Code Coverage" --settings coverlet.runsettings
- name: Moving test results
run: mv ${{ matrix.test_path }}/TestResults/**/coverage.cobertura.xml ${{ matrix.test_path }}/TestResults/coverage.cobertura.xml
- name: Send to coverals
uses: coverallsapp/github-action@master
uses: coverallsapp/github-action@v2.2.3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: ${{ steps.coverage-utest-server.outputs.FILE }}
flag-name: coverage-utest-server
file: ${{ matrix.test_path }}/TestResults/coverage.cobertura.xml
format: cobertura
flag-name: test-${{ matrix.test_path }}
parallel: true

end-coverage-ci:
needs: coverage-ci
runs-on: ubuntu-latest
steps:
- name: Finish coverals
uses: coverallsapp/github-action@master
uses: coverallsapp/github-action@v2.2.3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
parallel-finished: true

pack-ci:
needs: build-ci
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 9.0.101
- name: Install dependencies
run: dotnet restore
- name: Build
run: dotnet build --configuration Release --no-restore
- name: Pack
run: |
dotnet pack ./src/libs/SoloX.TableModel/SoloX.TableModel.csproj --configuration Release --no-restore --no-build
dotnet pack ./src/libs/SoloX.TableModel.Server/SoloX.TableModel.Server.csproj --configuration Release --no-restore --no-build
run: dotnet pack --configuration Release --no-restore --no-build
- name: Upload Packages
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: 'NugetPackages'
path: 'src/libs/**/*.nupkg'
path: |
src/libs/**/*.nupkg
56 changes: 33 additions & 23 deletions .github/workflows/build-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,50 +6,60 @@ on:

jobs:
build-pr:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.101
dotnet-version: 9.0.101
- name: Install dependencies
run: dotnet restore
- name: Build
run: dotnet build --configuration Release --no-restore
- name: Test
run: dotnet test --configuration Release --no-restore --no-build

- name: Test Coverage SoloX.TableModel.UTests
id: coverage-utest
run: |
dotnet test ./src/tests/SoloX.TableModel.UTests --configuration Release --no-restore --no-build --collect:"XPlat Code Coverage" --settings coverlet.runsettings
echo "::set-output name=FILE::$(find ./src/tests/SoloX.TableModel.UTests -name 'coverage.info' -print)"
- name: Send to coverals
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: ${{ steps.coverage-utest.outputs.FILE }}
flag-name: coverage-utest
parallel: true
coverage-pr:
needs: build-pr
runs-on: ubuntu-latest

strategy:
matrix:
test_path:
- src/tests/SoloX.TableModel.UTests
- src/tests/SoloX.TableModel.Server.UTests

- name: Test Coverage SoloX.TableModel.Server.UTests
id: coverage-utest-server
run: |
dotnet test ./src/tests/SoloX.TableModel.Server.UTests --configuration Release --no-restore --no-build --collect:"XPlat Code Coverage" --settings coverlet.runsettings
echo "::set-output name=FILE::$(find ./src/tests/SoloX.TableModel.Server.UTests -name 'coverage.info' -print)"
steps:
- uses: actions/checkout@v2
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 9.0.101
- name: Install dependencies ${{ matrix.test_path }}
run: dotnet restore ${{ matrix.test_path }}
- name: Build ${{ matrix.test_path }}
run: dotnet build ${{ matrix.test_path }} --configuration Release --no-restore
- name: Test Coverage ${{ matrix.test_path }}
run: dotnet test ${{ matrix.test_path }} --configuration Release --no-restore --no-build --collect:"XPlat Code Coverage" --settings coverlet.runsettings
- name: Moving test results
run: mv ${{ matrix.test_path }}/TestResults/**/coverage.cobertura.xml ${{ matrix.test_path }}/TestResults/coverage.cobertura.xml
- name: Send to coverals
uses: coverallsapp/github-action@master
uses: coverallsapp/github-action@v2.2.3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: ${{ steps.coverage-utest-server.outputs.FILE }}
flag-name: coverage-utest-server
file: ${{ matrix.test_path }}/TestResults/coverage.cobertura.xml
format: cobertura
flag-name: test-${{ matrix.test_path }}
parallel: true

end-coverage-pr:
needs: coverage-pr
runs-on: ubuntu-latest
steps:
- name: Finish coverals
uses: coverallsapp/github-action@master
uses: coverallsapp/github-action@v2.2.3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
parallel-finished: true
10 changes: 5 additions & 5 deletions coverlet.runsettings
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
<RunSettings>
<DataCollectionRunSettings>
<DataCollectors>
<DataCollector friendlyName="XPlat code coverage">
<DataCollector friendlyName="XPlat Code Coverage">
<Configuration>
<Format>lcov</Format>
<Format>cobertura</Format>
<SingleHit>false</SingleHit>
<UseSourceLink>true</UseSourceLink>
<Exclude>[*.UTests.Samples]*</Exclude>
<UseSourceLink>false</UseSourceLink>
<IncludeTestAssembly>false</IncludeTestAssembly>
<SkipAutoProps>true</SkipAutoProps>
<DeterministicReport>false</DeterministicReport>
<DeterministicReport>true</DeterministicReport>
<Exclude>[*.UTests.Samples]*</Exclude>
</Configuration>
</DataCollector>
</DataCollectors>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public async Task ItShouldGetTableStructureFromController()
okResult.Value.Should().BeEquivalentTo(strDto);
}

private class TableStructureController : TableStructureControllerBase
private sealed class TableStructureController : TableStructureControllerBase
{
public TableStructureController(ITableStructureEndPointService tableStructureEndPointService)
: base(tableStructureEndPointService)
Expand Down
35 changes: 19 additions & 16 deletions src/tests/SoloX.TableModel.UTests/AQueryableTableDataTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ await SetupDbContextAndRunTestAsync(async dbContext =>
result.Should().NotBeNull();

result.Select(p => p.FirstName).Should().BeEquivalentTo(dbContext.Persons.Select(p => p.FirstName));
}).ConfigureAwait(false);
});
}

[Theory]
Expand All @@ -66,7 +66,7 @@ await SetupDbContextAndRunTestAsync(async dbContext =>

result.Select(p => p.FirstName).Should().BeEquivalentTo(
dbContext.Persons.Skip(offset).Take(size).Select(p => p.FirstName));
}).ConfigureAwait(false);
});
}

[Fact]
Expand All @@ -91,7 +91,7 @@ await SetupDbContextAndRunTestAsync(async dbContext =>
result.Should().NotBeNull();

result.Select(p => p.FirstName).Should().BeEquivalentTo(dbContext.Persons.Where(p => p.Family.Name == "Dolittle").Select(p => p.FirstName));
}).ConfigureAwait(false);
});
}

[Fact]
Expand All @@ -115,7 +115,7 @@ await SetupDbContextAndRunTestAsync(async dbContext =>
dbContext.Persons
.Where(p => p.Family.Name == "Dolittle" && p.FirstName == "Lisa")
.Select(p => p.FirstName));
}).ConfigureAwait(false);
});
}

[Fact]
Expand All @@ -140,7 +140,7 @@ await SetupDbContextAndRunTestAsync(async dbContext =>
result.Should().NotBeNull();

result.Select(p => p.FirstName).Should().BeEquivalentTo(dbContext.Persons.Where(p => p.FirstName.Contains("an")).Select(p => p.FirstName));
}).ConfigureAwait(false);
});
}

[Fact]
Expand All @@ -163,7 +163,7 @@ await SetupDbContextAndRunTestAsync(async dbContext =>
result.Should().NotBeNull();

result.Select(p => p.FirstName).Should().BeEquivalentTo(dbContext.Persons.OrderByDescending(p => p.FirstName).Select(p => p.FirstName));
}).ConfigureAwait(false);
});
}

[Fact]
Expand All @@ -190,7 +190,7 @@ await SetupDbContextAndRunTestAsync(async dbContext =>
result.Should().NotBeNull();

result.Select(p => p.FirstName).Should().BeEquivalentTo(dbContext.Persons.Where(p => p.SomeGuid == null || p.SomeGuid == guid).Select(p => p.FirstName));
}).ConfigureAwait(false);
});
}

[Fact]
Expand All @@ -210,7 +210,8 @@ await SetupDbContextAndRunTestAsync(async dbContext =>
});
});

await using var sp = services.BuildServiceProvider();
var sp = services.BuildServiceProvider();
await using var _ = sp.ConfigureAwait(false);

var tableDataRepository = sp.GetService<ITableDataRepository>();

Expand All @@ -220,7 +221,7 @@ await SetupDbContextAndRunTestAsync(async dbContext =>

Assert.NotNull(tableData);
Assert.IsType<FamilyMemberTableData>(tableData);
}).ConfigureAwait(false);
});
}

[Fact]
Expand All @@ -237,7 +238,8 @@ await SetupDbContextAndRunTestAsync(async dbContext =>
builder.UseQueryableTableData<FamilyMemberDto, FamilyMemberTableData>("MyTableId");
});

await using var sp = services.BuildServiceProvider();
var sp = services.BuildServiceProvider();
await using var _ = sp.ConfigureAwait(false);

var tableDataRepository = sp.GetService<ITableDataRepository>();

Expand All @@ -247,7 +249,7 @@ await SetupDbContextAndRunTestAsync(async dbContext =>

Assert.NotNull(tableData);
Assert.Equal("MyTableId", tableData.Id);
}).ConfigureAwait(false);
});
}

[Fact]
Expand All @@ -264,7 +266,8 @@ await SetupDbContextAndRunTestAsync(async dbContext =>
builder.UseQueryableTableData<FamilyMemberDto, FamilyMemberTableData>();
});

await using var sp = services.BuildServiceProvider();
var sp = services.BuildServiceProvider();
await using var _ = sp.ConfigureAwait(false);

var tableDataRepository = sp.GetService<ITableDataRepository>();

Expand All @@ -275,7 +278,7 @@ await SetupDbContextAndRunTestAsync(async dbContext =>
Assert.NotNull(tableData);
Assert.Equal(typeof(FamilyMemberDto).FullName, tableData.Id);
Assert.IsType<FamilyMemberTableData>(tableData);
}).ConfigureAwait(false);
});
}

[Fact]
Expand All @@ -295,7 +298,7 @@ await SetupDbContextAndRunTestAsync(async dbContext =>

result.Select(p => p.FirstName).Should().BeEquivalentTo(dbContext.Persons.Select(p => p.FirstName.ToUpper(CultureInfo.InvariantCulture)));

}).ConfigureAwait(false);
});
}

[Fact]
Expand All @@ -314,7 +317,7 @@ await SetupDbContextAndRunTestAsync(async dbContext =>
result.Select(p => p.FirstName).Should().BeEquivalentTo(
dbContext.Persons.Where(p => p.Family.Name.StartsWith("Do")).Select(p => p.FirstName));

}).ConfigureAwait(false);
});
}

private async Task SetupDbContextAndRunTestAsync(Func<FamilyDbContext, Task> testHandler)
Expand Down Expand Up @@ -344,7 +347,7 @@ private async Task SetupDbContextAndRunTestAsync(Func<FamilyDbContext, Task> tes
}
}

internal class FamilyMemberTableData : AQueryableTableData<FamilyMemberDto>
internal sealed class FamilyMemberTableData : AQueryableTableData<FamilyMemberDto>
{
private readonly FamilyDbContext familyDbContext;
private readonly Func<FamilyMemberDto, FamilyMemberDto> postProcessing;
Expand Down
4 changes: 2 additions & 2 deletions src/tests/SoloX.TableModel.UTests/RemoteTableDataTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ private static async Task ProvideRemoteFilteredDataCount(Mock<ITableFilter<strin

var dataTable = new RemoteTableData<string>("RemotePersonData", httpClient, "Data", "Count");

var resultData = await dataTable.GetDataCountAsync(filterMock.Object);
var resultData = await dataTable.GetDataCountAsync(filterMock.Object).ConfigureAwait(false);

resultData.Should().Be(6);
}
Expand Down Expand Up @@ -265,7 +265,7 @@ private static async Task ProvideRemoteDataFiltered(Mock<ITableFilter<string>> f

var dataTable = new RemoteTableData<string>("RemotePersonData", httpClient, "Data", "Count");

var resultData = await dataTable.GetDataPageAsync(filterMock.Object, 1, 2);
var resultData = await dataTable.GetDataPageAsync(filterMock.Object, 1, 2).ConfigureAwait(false);

resultData.Should().NotBeNull();
resultData.Should().BeEquivalentTo(
Expand Down

0 comments on commit 871ffe4

Please sign in to comment.