diff --git a/.github/workflows/main-build.yml b/.github/workflows/main-build.yml index 745f8eb..a1c8a18 100644 --- a/.github/workflows/main-build.yml +++ b/.github/workflows/main-build.yml @@ -1,73 +1,73 @@ name: GitHub action build - -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] +on: push jobs: - Main-build_windows: - - runs-on: windows-latest + main-build: - steps: - - uses: actions/checkout@v2 - - name: Setup .NET 5 - uses: actions/setup-dotnet@v1 - with: - dotnet-version: 5.0.x - - name: Install dependencies - run: dotnet restore - - name: Build - run: dotnet build --configuration Release --no-restore - - name: Test - run: dotnet test --configuration Release --no-build --no-restore --verbosity normal /p:CollectCoverage=true /p:CoverletOutput=TestResults /p:CoverletOutputFormat=lcov - - name: Upload net5.0 unit test code coverage to Coveralls - uses: coverallsapp/github-action@master - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - path-to-lcov: .\tests\Fastenshtein.Tests\TestResults.net5.0.info - - name: Upload net48 unit test code coverage to Coveralls - uses: coverallsapp/github-action@master - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - path-to-lcov: .\tests\Fastenshtein.Tests\TestResults.net48.info - - name: Pack - run: dotnet pack --configuration Release --no-build --no-restore --nologo - - name: Upload Artifact - uses: actions/upload-artifact@v2 - with: - name: Fastenshtein.nupkg - path: src\Fastenshtein\bin\Release\Fastenshtein.*.nupkg - - name: Run benchmark - run: .\benchmarks\Fastenshtein.Benchmarking\bin\Release\net5.0\Fastenshtein.Benchmarking.exe - - name: Upload benchmarks-results to Artifacts - uses: actions/upload-artifact@v2 - with: - name: benchmarks-results-windows-latest - path: BenchmarkDotNet.Artifacts - - benchmarks: - runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: - os: [ubuntu-latest, macos-latest] + os: [ubuntu-latest, windows-latest, macos-latest] steps: - - uses: actions/checkout@v2 - - name: Setup .NET 5 - uses: actions/setup-dotnet@v1 + - name: GIT checkout + uses: actions/checkout@v4 + + - name: Setup .NET 8 + uses: actions/setup-dotnet@v3 with: - dotnet-version: 5.0.x - - name: Run benchmarks script + dotnet-version: 8.0.x + + - name: Run build script + working-directory: scripts + shell: bash run: | - cd scripts - ./benchmark.sh - - name: Upload benchmarks-results to Artifacts - uses: actions/upload-artifact@v2 + if [ "$RUNNER_OS" == "Linux" ]; then + ./dotnet_build.sh code_coverage + else + ./dotnet_build.sh + fi + + - name: Run benchmarks + working-directory: release + shell: bash + run: dotnet ../benchmarks/Fastenshtein.Benchmarking/bin/Release/net8.0/Fastenshtein.Benchmarking.dll + + - name: Upload benchmarks results + uses: actions/upload-artifact@v4 with: name: benchmarks-results-${{ matrix.os }} - path: scripts/BenchmarkDotNet.Artifacts \ No newline at end of file + path: release/BenchmarkDotNet.Artifacts + if-no-files-found: error + + - name: Upload test coverage to Coveralls + if: runner.os == 'Linux' + uses: coverallsapp/github-action@v2 + with: + format: lcov + files: release/coverage.net8.info release/coverage.net48.info + + - name: Upload dotnet info + uses: actions/upload-artifact@v4 + if: runner.os == 'Linux' + with: + name: Built with + path: release/dotnet_info.txt + if-no-files-found: error + + - name: Upload test coverage + uses: actions/upload-artifact@v4 + if: runner.os == 'Linux' + with: + name: test coverage + path: release/coverage.*.info + if-no-files-found: error + + - name: Upload NuGet packages + uses: actions/upload-artifact@v4 + if: runner.os == 'Linux' + with: + name: NuGet packages + path: release/Fastenshtein.*upkg + if-no-files-found: error diff --git a/.github/workflows/release-build.yml b/.github/workflows/release-build.yml new file mode 100644 index 0000000..1e47db2 --- /dev/null +++ b/.github/workflows/release-build.yml @@ -0,0 +1,35 @@ +name: GitHub Release + +on: + push: + tags: + - '1.*' + +jobs: + build: + name: Relase build + runs-on: ubuntu-latest + + env: + DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1 + DOTNET_CLI_TELEMETRY_OPTOUT: 1 + DOTNET_NOLOGO: true + + steps: + - name: Git checkout + uses: actions/checkout@v4 + + - name: Setup .NET 8 + uses: actions/setup-dotnet@v3 + with: + dotnet-version: 8.0.x + + - name: Run build script + working-directory: scripts + run: ./dotnet_build.sh code_coverage + + - name: Create GitHub release + working-directory: scripts + run: ./github_release.sh ${{ github.ref_name }} + env: + GH_TOKEN: ${{ github.token }} \ No newline at end of file diff --git a/README.md b/README.md index 1d287ad..cbba0f7 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # Fastenshtein -[![NuGet](https://img.shields.io/nuget/v/Fastenshtein.svg)](https://www.nuget.org/packages/Fastenshtein/) ![GitHub action build](https://github.com/DanHarltey/Fastenshtein/workflows/GitHub%20action%20build/badge.svg) [![AppVeyor Build](https://ci.appveyor.com/api/projects/status/xrq5c00ager222i8/branch/master?svg=true)](https://ci.appveyor.com/project/DanHarltey/fastenshtein/branch/master) [![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE) [![Unit test coverage](https://coveralls.io/repos/github/DanHarltey/Fastenshtein/badge.svg?branch=master)](https://coveralls.io/github/DanHarltey/Fastenshtein?branch=master) +[![NuGet](https://img.shields.io/nuget/v/Fastenshtein.svg)](https://www.nuget.org/packages/Fastenshtein/) ![GitHub action build](https://github.com/DanHarltey/Fastenshtein/workflows/GitHub%20action%20build/badge.svg) [![AppVeyor Build](https://ci.appveyor.com/api/projects/status/my7qghoen4pofb3h?svg=true)](https://ci.appveyor.com/project/DanHarltey/fastenshtein) [![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE) [![Unit test coverage](https://coveralls.io/repos/github/DanHarltey/Fastenshtein/badge.svg?branch=master)](https://coveralls.io/github/DanHarltey/Fastenshtein?branch=master) One of the fastest .Net Levenshtein projects around. diff --git a/appveyor.yml b/appveyor.yml old mode 100644 new mode 100755 index 743448a..9db55d9 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,11 +1,28 @@ image: - - Visual Studio 2019 + - Visual Studio 2022 - Ubuntu - macOS +install: + - pwsh: | + if ($isWindows) { + Invoke-WebRequest "https://dot.net/v1/dotnet-install.ps1" -OutFile "./dotnet-install.ps1" + ./dotnet-install.ps1 -InstallDir 'C:\Program Files\dotnet' + } + else { + Invoke-WebRequest "https://dot.net/v1/dotnet-install.sh" -OutFile "./dotnet-install.sh" + sudo chmod u+x dotnet-install.sh + if ($isMacOS) { + sudo ./dotnet-install.sh --install-dir '/usr/local/share/dotnet' + } else { + sudo ./dotnet-install.sh --install-dir '/usr/share/dotnet' + } + } build_script: - cd scripts - - cmd: .\benchmark.bat - - sh: ./benchmark.sh + - cmd: bash -c "./dotnet_build.sh" + - sh: ./dotnet_build.sh + - dotnet ../benchmarks/Fastenshtein.Benchmarking/bin/Release/net8.0/Fastenshtein.Benchmarking.dll + artifacts: - path: scripts/BenchmarkDotNet.Artifacts - name: Benchmark results \ No newline at end of file + name: Benchmark results - $(APPVEYOR_BUILD_WORKER_IMAGE) \ No newline at end of file diff --git a/benchmarks/Fastenshtein.Benchmarking/Fastenshtein.Benchmarking.csproj b/benchmarks/Fastenshtein.Benchmarking/Fastenshtein.Benchmarking.csproj index aedbd77..ecb8a47 100644 --- a/benchmarks/Fastenshtein.Benchmarking/Fastenshtein.Benchmarking.csproj +++ b/benchmarks/Fastenshtein.Benchmarking/Fastenshtein.Benchmarking.csproj @@ -2,7 +2,7 @@ Exe - net5.0 + net8.0 @@ -20,8 +20,8 @@ - - + + diff --git a/benchmarks/Fastenshtein.Benchmarking/RandomWords.cs b/benchmarks/Fastenshtein.Benchmarking/RandomWords.cs index 585c0d2..906cd09 100644 --- a/benchmarks/Fastenshtein.Benchmarking/RandomWords.cs +++ b/benchmarks/Fastenshtein.Benchmarking/RandomWords.cs @@ -8,18 +8,18 @@ public static class RandomWords public static string[] Create(int size, int maxWordSize) { - string[] words = new string[size]; + var words = new string[size]; // using a const seed to make sure runs of the performance tests are consistent. var random = new Random(69); - for (int i = 0; i < words.Length; i++) + for (var i = 0; i < words.Length; i++) { - int wordSize = random.Next(3, maxWordSize); + var wordSize = random.Next(3, maxWordSize); - words[i] = string.Create(wordSize, random, (word, r) => + words[i] = string.Create(wordSize, random, static (word, r) => { - for (int j = 0; j < word.Length; j++) + for (var j = 0; j < word.Length; j++) { var index = r.Next(0, Letters.Length); word[j] = Letters[index]; diff --git a/scripts/benchmark.bat b/scripts/benchmark.bat deleted file mode 100644 index d2f3557..0000000 --- a/scripts/benchmark.bat +++ /dev/null @@ -1,12 +0,0 @@ -dotnet restore ..\ || goto :error -dotnet build ..\src\Fastenshtein --configuration Release --framework netstandard1.0 --nologo --no-restore || goto :error -dotnet build ..\benchmarks\Fastenshtein.Benchmarking --configuration Release --framework net5.0 --nologo --no-restore || goto :error -dotnet build ..\tests\Fastenshtein.Tests --configuration Release --framework net5.0 --nologo --no-restore || goto :error -dotnet test ..\tests\Fastenshtein.Tests --configuration Release --framework net5.0 --nologo --no-build --no-restore --verbosity normal || goto :error -..\benchmarks\Fastenshtein.Benchmarking\bin\Release\net5.0\Fastenshtein.Benchmarking.exe || goto :error - -goto :EOF - -:error -echo Failed with error #%errorlevel%. -exit /b %errorlevel% \ No newline at end of file diff --git a/scripts/benchmark.sh b/scripts/benchmark.sh deleted file mode 100755 index 1f1df26..0000000 --- a/scripts/benchmark.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash - -# Stop on any errors -set -e - -dotnet restore ../ -dotnet build ../src/Fastenshtein --configuration Release --framework netstandard1.0 --nologo --no-restore -dotnet build ../benchmarks/Fastenshtein.Benchmarking --configuration Release --framework net5.0 --nologo --no-restore -dotnet build ../tests/Fastenshtein.Tests --configuration Release --framework net5.0 --nologo --no-restore -dotnet test ../tests/Fastenshtein.Tests --configuration Release --framework net5.0 --nologo --no-build --no-restore --verbosity normal -dotnet ../benchmarks/Fastenshtein.Benchmarking/bin/Release/net5.0/Fastenshtein.Benchmarking.dll \ No newline at end of file diff --git a/scripts/dotnet_build.sh b/scripts/dotnet_build.sh new file mode 100755 index 0000000..b1cc978 --- /dev/null +++ b/scripts/dotnet_build.sh @@ -0,0 +1,25 @@ +#!/bin/bash +set -e + +rm -rf ../release +mkdir ../release + +dotnet --info > ../release/dotnet_info.txt + +dotnet restore ../ +dotnet build ../ --configuration Release --no-restore -p:ContinuousIntegrationBuild=true + +if [[ $1 = "code_coverage" ]]; then + dotnet test ../ --configuration Release --no-build --verbosity normal --framework net8.0 --collect:"XPlat Code Coverage;Format=lcov" + find ../tests/Fastenshtein.Tests/TestResults/ -name "coverage.info" -type f -exec mv {} ../release/coverage.net8.info \; + + dotnet test ../ --configuration Release --no-build --verbosity normal --framework net48 --collect:"XPlat Code Coverage;Format=lcov" + find ../tests/Fastenshtein.Tests/TestResults/ -name "coverage.info" -type f -exec mv {} ../release/coverage.net48.info \; +else + dotnet test ../ --configuration Release --no-build --verbosity normal +fi + +dotnet pack ../ --configuration Release --no-build + +cp ../src/Fastenshtein/bin/Release/Fastenshtein.*.nupkg ../release/Fastenshtein.nupkg +cp ../src/Fastenshtein/bin/Release/Fastenshtein.*.snupkg ../release/Fastenshtein.snupkg \ No newline at end of file diff --git a/scripts/github_release.sh b/scripts/github_release.sh new file mode 100755 index 0000000..2f18820 --- /dev/null +++ b/scripts/github_release.sh @@ -0,0 +1,11 @@ +#!/bin/bash +set -e + +gh release create $1 \ + "../release/Fastenshtein.nupkg" \ + "../release/Fastenshtein.snupkg" \ + "../release/coverage.net48.info#Code coverage report net48" \ + "../release/coverage.net8.info#Code coverage report net8" \ + "../release/dotnet_info.txt#Built with" \ + --draft \ + --generate-notes \ No newline at end of file diff --git a/src/Fastenshtein/Fastenshtein.csproj b/src/Fastenshtein/Fastenshtein.csproj index 2fd6afe..138cb26 100644 --- a/src/Fastenshtein/Fastenshtein.csproj +++ b/src/Fastenshtein/Fastenshtein.csproj @@ -1,20 +1,23 @@  - netstandard1.0;netstandard2.0;net452 - Fastenshtein + netstandard1.0;netstandard2.0;net452;net8.0 false + + + + Fastenshtein DanHartley - The one of the fastest Levenshtein distance packages on NuGet. Supports .NET Framework and .NET (.NET Standard 1.0/2.0). Levenshtein calculates the shortest possible distance between two strings. Producing a count of the number of insertions, deletions and substitutions to make one string into another. + The one of the fastest Levenshtein distance packages on NuGet. Supports .NET Framework and .NET. Levenshtein calculates the shortest possible distance between two strings. Producing a count of the number of insertions, deletions and substitutions to make one string into another. Copyright © 2017 LICENSE https://github.com/DanHarltey/Fastenshtein GIT https://github.com/DanHarltey/Fastenshtein.git - 1.0.0.8 - 1.0.0.8 - 1.0.0.8 - Adding .NetStandard2.0 support. + 1.0.0.9 + 1.0.0.9 + 1.0.0.9 + Adding .Net 8 support Levenshtein Distance;String;Fuzzy Matching;Search;netstandard; @@ -42,4 +45,22 @@ + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + True + + + True + + + True + snupkg + diff --git a/tests/Fastenshtein.Tests/Fastenshtein.Tests.csproj b/tests/Fastenshtein.Tests/Fastenshtein.Tests.csproj index 7dcc583..0d3c65f 100644 --- a/tests/Fastenshtein.Tests/Fastenshtein.Tests.csproj +++ b/tests/Fastenshtein.Tests/Fastenshtein.Tests.csproj @@ -1,7 +1,7 @@  - net5.0;net48 + net8.0;net48 false @@ -14,17 +14,17 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive