From 8090b874c3c43356cfb507670879eb4dffdecbd4 Mon Sep 17 00:00:00 2001 From: mdabros Date: Sun, 9 Feb 2025 22:04:04 +0100 Subject: [PATCH 1/6] Update dotnet.yml and add Nerdbank.GitVersioning --- .github/workflows/dotnet.yml | 57 +++++++++++++++---- SharpLearning.sln | 1 + src/Directory.Build.props | 4 -- .../SharpLearning.AdaBoost.csproj | 7 +++ .../SharpLearning.Common.Interfaces.csproj | 7 +++ .../SharpLearning.Containers.csproj | 7 +++ .../SharpLearning.CrossValidation.csproj | 7 +++ .../SharpLearning.DecisionTrees.csproj | 7 +++ .../SharpLearning.Ensemble.csproj | 7 +++ ...harpLearning.FeatureTransformations.csproj | 7 +++ .../SharpLearning.GradientBoost.csproj | 7 +++ .../SharpLearning.InputOutput.csproj | 7 +++ .../SharpLearning.Metrics.csproj | 7 +++ .../SharpLearning.Neural.csproj | 14 +++-- .../SharpLearning.Optimization.csproj | 11 ++-- .../SharpLearning.RandomForest.csproj | 7 +++ .../SharpLearning.XGBoost.csproj | 12 ++-- version.json | 13 +++++ 18 files changed, 162 insertions(+), 27 deletions(-) create mode 100644 version.json diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 3ebe4653..05b8ae5d 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -2,20 +2,18 @@ name: dotnet +permissions: read-all + on: push: branches: [ "master" ] pull_request: branches: [ "master" ] - # workflow_dispatch: - # inputs: - # version: - # description: 'Release version to tag and create' - # required: false env: DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1 DOTNET_NOLOGO: true + NuGetDirectory: ${{ github.workspace }}/nuget jobs: build: @@ -28,6 +26,8 @@ jobs: steps: - uses: actions/checkout@v3 + with: + fetch-depth: 0 # Important for Nerdbank.GitVersioning to calculate versions - name: Setup .NET uses: actions/setup-dotnet@v3 with: @@ -37,8 +37,45 @@ jobs: - name: Build run: dotnet build -c ${{ matrix.configuration }} --no-restore - name: Test - run: dotnet test -c ${{ matrix.configuration }} --no-build --verbosity normal - # - name: Upload coverage reports to Codecov - # uses: codecov/codecov-action@v3 - # with: - # flags: ${{ matrix.os }},${{ matrix.configuration }} + run: dotnet test -c ${{ matrix.configuration }} --no-build --verbosity normal --collect:"XPlat Code Coverage" + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v3 + with: + flags: ${{ matrix.os }},${{ matrix.configuration }} + + format: + strategy: + matrix: + os: [windows-latest] + + runs-on: ${{ matrix.os }} + + steps: + - uses: actions/checkout@v3 + - name: Setup .NET + uses: actions/setup-dotnet@v3 + with: + global-json-file: global.json + - name: Format verify no changes + run: dotnet format --verify-no-changes + + pack: + runs-on: windows-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 # Important for Nerdbank.GitVersioning to calculate versions + - name: Setup .NET + uses: actions/setup-dotnet@v3 + with: + global-json-file: global.json + - name: Pack solution + run: dotnet pack SharpLearning.sln -c Release --output ${{ env.NuGetDirectory }} + - name: Add local package source + run: dotnet nuget add source ${{ env.NuGetDirectory }} --name local + - uses: actions/upload-artifact@v4 + with: + name: nuget + if-no-files-found: error + retention-days: 7 + path: ${{ env.NuGetDirectory }}/*nupkg diff --git a/SharpLearning.sln b/SharpLearning.sln index 99af6458..5f580ccb 100644 --- a/SharpLearning.sln +++ b/SharpLearning.sln @@ -71,6 +71,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "root", "root", "{D83436F7-2 global.json = global.json LICENSE = LICENSE README.md = README.md + version.json = version.json EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{2204FA16-973A-48CF-A9FD-94FA72424BA4}" diff --git a/src/Directory.Build.props b/src/Directory.Build.props index f143dc5d..8bdff634 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -1,9 +1,5 @@ - 0.31.0 - 0.31.10 - $(FileVersion) - $(InformationalVersion) false diff --git a/src/SharpLearning.AdaBoost/SharpLearning.AdaBoost.csproj b/src/SharpLearning.AdaBoost/SharpLearning.AdaBoost.csproj index be58d2fd..b2bae433 100644 --- a/src/SharpLearning.AdaBoost/SharpLearning.AdaBoost.csproj +++ b/src/SharpLearning.AdaBoost/SharpLearning.AdaBoost.csproj @@ -15,4 +15,11 @@ + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + diff --git a/src/SharpLearning.Common.Interfaces/SharpLearning.Common.Interfaces.csproj b/src/SharpLearning.Common.Interfaces/SharpLearning.Common.Interfaces.csproj index bf9b4a20..da16c075 100644 --- a/src/SharpLearning.Common.Interfaces/SharpLearning.Common.Interfaces.csproj +++ b/src/SharpLearning.Common.Interfaces/SharpLearning.Common.Interfaces.csproj @@ -10,4 +10,11 @@ + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + diff --git a/src/SharpLearning.Containers/SharpLearning.Containers.csproj b/src/SharpLearning.Containers/SharpLearning.Containers.csproj index 32cafeab..8e0cd49d 100644 --- a/src/SharpLearning.Containers/SharpLearning.Containers.csproj +++ b/src/SharpLearning.Containers/SharpLearning.Containers.csproj @@ -7,4 +7,11 @@ true + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + diff --git a/src/SharpLearning.CrossValidation/SharpLearning.CrossValidation.csproj b/src/SharpLearning.CrossValidation/SharpLearning.CrossValidation.csproj index f6276eed..ccf199d5 100644 --- a/src/SharpLearning.CrossValidation/SharpLearning.CrossValidation.csproj +++ b/src/SharpLearning.CrossValidation/SharpLearning.CrossValidation.csproj @@ -17,4 +17,11 @@ + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + diff --git a/src/SharpLearning.DecisionTrees/SharpLearning.DecisionTrees.csproj b/src/SharpLearning.DecisionTrees/SharpLearning.DecisionTrees.csproj index 54d64411..80dd2b3e 100644 --- a/src/SharpLearning.DecisionTrees/SharpLearning.DecisionTrees.csproj +++ b/src/SharpLearning.DecisionTrees/SharpLearning.DecisionTrees.csproj @@ -14,4 +14,11 @@ + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + diff --git a/src/SharpLearning.Ensemble/SharpLearning.Ensemble.csproj b/src/SharpLearning.Ensemble/SharpLearning.Ensemble.csproj index eee99815..42ead8a6 100644 --- a/src/SharpLearning.Ensemble/SharpLearning.Ensemble.csproj +++ b/src/SharpLearning.Ensemble/SharpLearning.Ensemble.csproj @@ -15,4 +15,11 @@ + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + diff --git a/src/SharpLearning.FeatureTransformations/SharpLearning.FeatureTransformations.csproj b/src/SharpLearning.FeatureTransformations/SharpLearning.FeatureTransformations.csproj index 314a7c97..92275742 100644 --- a/src/SharpLearning.FeatureTransformations/SharpLearning.FeatureTransformations.csproj +++ b/src/SharpLearning.FeatureTransformations/SharpLearning.FeatureTransformations.csproj @@ -12,4 +12,11 @@ + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + diff --git a/src/SharpLearning.GradientBoost/SharpLearning.GradientBoost.csproj b/src/SharpLearning.GradientBoost/SharpLearning.GradientBoost.csproj index f1d69a71..2e352ab3 100644 --- a/src/SharpLearning.GradientBoost/SharpLearning.GradientBoost.csproj +++ b/src/SharpLearning.GradientBoost/SharpLearning.GradientBoost.csproj @@ -14,4 +14,11 @@ + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + diff --git a/src/SharpLearning.InputOutput/SharpLearning.InputOutput.csproj b/src/SharpLearning.InputOutput/SharpLearning.InputOutput.csproj index dd96a0c9..02ba11d8 100644 --- a/src/SharpLearning.InputOutput/SharpLearning.InputOutput.csproj +++ b/src/SharpLearning.InputOutput/SharpLearning.InputOutput.csproj @@ -11,4 +11,11 @@ + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + diff --git a/src/SharpLearning.Metrics/SharpLearning.Metrics.csproj b/src/SharpLearning.Metrics/SharpLearning.Metrics.csproj index 90ce8d87..08f330b1 100644 --- a/src/SharpLearning.Metrics/SharpLearning.Metrics.csproj +++ b/src/SharpLearning.Metrics/SharpLearning.Metrics.csproj @@ -12,4 +12,11 @@ + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + diff --git a/src/SharpLearning.Neural/SharpLearning.Neural.csproj b/src/SharpLearning.Neural/SharpLearning.Neural.csproj index 3e97e6e4..ae8e455b 100644 --- a/src/SharpLearning.Neural/SharpLearning.Neural.csproj +++ b/src/SharpLearning.Neural/SharpLearning.Neural.csproj @@ -11,15 +11,19 @@ neural network convolutional deep learning machine-learning classification regression - - - - - + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + diff --git a/src/SharpLearning.Optimization/SharpLearning.Optimization.csproj b/src/SharpLearning.Optimization/SharpLearning.Optimization.csproj index f724de17..3d7697f0 100644 --- a/src/SharpLearning.Optimization/SharpLearning.Optimization.csproj +++ b/src/SharpLearning.Optimization/SharpLearning.Optimization.csproj @@ -7,14 +7,17 @@ optimization grid search random particle swarm nelder-mead bayesian-optimization machine-learning - - - - + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + diff --git a/src/SharpLearning.RandomForest/SharpLearning.RandomForest.csproj b/src/SharpLearning.RandomForest/SharpLearning.RandomForest.csproj index afe493c2..9e46dcef 100644 --- a/src/SharpLearning.RandomForest/SharpLearning.RandomForest.csproj +++ b/src/SharpLearning.RandomForest/SharpLearning.RandomForest.csproj @@ -14,4 +14,11 @@ + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + diff --git a/src/SharpLearning.XGBoost/SharpLearning.XGBoost.csproj b/src/SharpLearning.XGBoost/SharpLearning.XGBoost.csproj index c02a7980..56b52356 100644 --- a/src/SharpLearning.XGBoost/SharpLearning.XGBoost.csproj +++ b/src/SharpLearning.XGBoost/SharpLearning.XGBoost.csproj @@ -9,10 +9,6 @@ $(NoWarn);NU1701;MSB3270 - - - - @@ -20,4 +16,12 @@ + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + diff --git a/version.json b/version.json new file mode 100644 index 00000000..d9413139 --- /dev/null +++ b/version.json @@ -0,0 +1,13 @@ +{ + "$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/main/src/NerdBank.GitVersioning/version.schema.json", + "version": "0.40", + "publicReleaseRefSpec": [ + "^refs/heads/master", + "^refs/heads/v\\d+(?:\\.\\d+)?$" + ], + "cloudBuild": { + "buildNumber": { + "enabled": false + } + } +} \ No newline at end of file From fd1242ae23f86aad9937f02fb77e0928e25159da Mon Sep 17 00:00:00 2001 From: mdabros Date: Sun, 9 Feb 2025 22:08:19 +0100 Subject: [PATCH 2/6] Add get version of dll --- .github/workflows/dotnet.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 05b8ae5d..b6f5835b 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -73,6 +73,8 @@ jobs: run: dotnet pack SharpLearning.sln -c Release --output ${{ env.NuGetDirectory }} - name: Add local package source run: dotnet nuget add source ${{ env.NuGetDirectory }} --name local + - name: Get version of dll + run: (Get-Item './build/SharpLearning.AdaBoost_AnyCPU_Release_netstandard2.0/SharpLearning.AdaBoost.dll').VersionInfo.ProductVersion # unified version, so use AdaBoost dll. - uses: actions/upload-artifact@v4 with: name: nuget From 011e3573d7a8ccca85d8e59481a1fd4ca31c35b4 Mon Sep 17 00:00:00 2001 From: mdabros Date: Sat, 15 Feb 2025 18:07:31 +0100 Subject: [PATCH 3/6] Add workflow --- .github/workflows/dotnet.yml | 48 ++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index b6f5835b..84b31bcd 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -9,6 +9,11 @@ on: branches: [ "master" ] pull_request: branches: [ "master" ] + workflow_dispatch: + inputs: + version: + description: 'Release version to tag and create' + required: false env: DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1 @@ -81,3 +86,46 @@ jobs: if-no-files-found: error retention-days: 7 path: ${{ env.NuGetDirectory }}/*nupkg + + create-release-push: + needs: [ build, pack ] + runs-on: windows-latest + permissions: + contents: write + if: ${{ github.event.inputs.version != '' && github.actor == 'mdabros'}} + + steps: + - uses: actions/checkout@v3 + - name: Download nuget packages + uses: actions/download-artifact@v4 + with: + name: nuget + path: ${{ env.NuGetDirectory }} + - name: Create release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.ACTION_GITHUB_TOKEN }} + with: + tag_name: v${{ github.event.inputs.version }} + release_name: ${{ github.event.inputs.version }} + draft: true + - name: Create tag (for release) + run: | + git tag v${{ github.event.inputs.version }} + git push origin v${{ github.event.inputs.version }} + - name: Upload XGBoostSharp package + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.ACTION_GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ${{ env.NuGetDirectory }}/XGBoostSharp.${{ github.event.inputs.version }}.nupkg + asset_name: XGBoostSharp.${{ github.event.inputs.version }}.nupkg + asset_content_type: application/zip + - name: Setup .NET + uses: actions/setup-dotnet@v3 + with: + global-json-file: global.json + - name: Push XGBoostSharp package + run: dotnet nuget push ${{ env.NuGetDirectory }}/XGBoostSharp.${{ github.event.inputs.version }}.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate \ No newline at end of file From 0416dd05b7954cd6696f269107e7ba6cee908763 Mon Sep 17 00:00:00 2001 From: mdabros Date: Sat, 15 Feb 2025 18:08:54 +0100 Subject: [PATCH 4/6] Update create release push --- .github/workflows/dotnet.yml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 84b31bcd..505a34ec 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -114,18 +114,21 @@ jobs: run: | git tag v${{ github.event.inputs.version }} git push origin v${{ github.event.inputs.version }} - - name: Upload XGBoostSharp package + - name: Upload NuGet packages uses: actions/upload-release-asset@v1 env: GITHUB_TOKEN: ${{ secrets.ACTION_GITHUB_TOKEN }} with: upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ${{ env.NuGetDirectory }}/XGBoostSharp.${{ github.event.inputs.version }}.nupkg - asset_name: XGBoostSharp.${{ github.event.inputs.version }}.nupkg + asset_path: ${{ env.NuGetDirectory }}/*.nupkg + asset_name: ${{ env.NuGetDirectory }}/*.nupkg asset_content_type: application/zip - name: Setup .NET uses: actions/setup-dotnet@v3 with: global-json-file: global.json - - name: Push XGBoostSharp package - run: dotnet nuget push ${{ env.NuGetDirectory }}/XGBoostSharp.${{ github.event.inputs.version }}.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate \ No newline at end of file + - name: Push NuGet packages + run: | + for package in ${{ env.NuGetDirectory }}/*.nupkg; do + dotnet nuget push "$package" --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate + done \ No newline at end of file From ae99df570616e9249f13365b39735f242fac675e Mon Sep 17 00:00:00 2001 From: mdabros Date: Sat, 15 Feb 2025 20:03:18 +0100 Subject: [PATCH 5/6] set specific delta --- .../GlobalizedBoundedNelderMeadOptimizerTest.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/SharpLearning.Optimization.Test/GlobalizedBoundedNelderMeadOptimizerTest.cs b/src/SharpLearning.Optimization.Test/GlobalizedBoundedNelderMeadOptimizerTest.cs index 196ac78b..c2a7ecb4 100644 --- a/src/SharpLearning.Optimization.Test/GlobalizedBoundedNelderMeadOptimizerTest.cs +++ b/src/SharpLearning.Optimization.Test/GlobalizedBoundedNelderMeadOptimizerTest.cs @@ -28,9 +28,10 @@ public void GlobalizedBoundedNelderMeadOptimizer_OptimizeBest(int? maxDegreeOfPa Assert.AreEqual(expected: -0.99999960731425908, actual.Error, Delta); Assert.AreEqual(expected: 3, actual.ParameterSet.Length); - Assert.AreEqual(expected: -1.5711056814954487, actual.ParameterSet[0], Delta); - Assert.AreEqual(expected: -6.283490634742785, actual.ParameterSet[1], Delta); - Assert.AreEqual(expected: -2.9822323517533149E-07, actual.ParameterSet[2], Delta); + const double delta = 1e-3; + Assert.AreEqual(expected: -1.5711056814954487, actual.ParameterSet[0], delta); + Assert.AreEqual(expected: -6.283490634742785, actual.ParameterSet[1], delta); + Assert.AreEqual(expected: -2.9822323517533149E-07, actual.ParameterSet[2], delta); } [TestMethod] From 78410253f9acbca37b3ecc7c970b864f6d9d942a Mon Sep 17 00:00:00 2001 From: mdabros Date: Sat, 15 Feb 2025 20:13:00 +0100 Subject: [PATCH 6/6] Use ubuntu-latest --- .github/workflows/dotnet.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 505a34ec..d8bbd89f 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -51,7 +51,7 @@ jobs: format: strategy: matrix: - os: [windows-latest] + os: [ubuntu-latest] runs-on: ${{ matrix.os }}