Skip to content

Commit

Permalink
Upgrading supporting test & benchmarks to .Net 8.
Browse files Browse the repository at this point in the history
Upgrading GitHub action steps to latest.
Reducing build complexity.
New build to create GitHub release.
Now using deterministic build
Added SourceLink
Added Symbols package on pack
  • Loading branch information
DanHarltey committed Jan 20, 2024
1 parent 4f83ecc commit ba9513e
Show file tree
Hide file tree
Showing 12 changed files with 194 additions and 108 deletions.
118 changes: 59 additions & 59 deletions .github/workflows/main-build.yml
Original file line number Diff line number Diff line change
@@ -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
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
35 changes: 35 additions & 0 deletions .github/workflows/release-build.yml
Original file line number Diff line number Diff line change
@@ -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 }}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
25 changes: 21 additions & 4 deletions appveyor.yml
100644 → 100755
Original file line number Diff line number Diff line change
@@ -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
name: Benchmark results - $(APPVEYOR_BUILD_WORKER_IMAGE)
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
Expand All @@ -20,8 +20,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.12.1" />
<PackageReference Include="F23.StringSimilarity" Version="3.1.0" />
<PackageReference Include="BenchmarkDotNet" Version="0.13.12" />
<PackageReference Include="F23.StringSimilarity" Version="6.0.0" />
<PackageReference Include="FuzzyStrings.NetStandard" Version="1.0.1" />
<PackageReference Include="NinjaNye.SearchExtensions.Levenshtein" Version="3.0.1" />
</ItemGroup>
Expand Down
10 changes: 5 additions & 5 deletions benchmarks/Fastenshtein.Benchmarking/RandomWords.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
12 changes: 0 additions & 12 deletions scripts/benchmark.bat

This file was deleted.

11 changes: 0 additions & 11 deletions scripts/benchmark.sh

This file was deleted.

25 changes: 25 additions & 0 deletions scripts/dotnet_build.sh
Original file line number Diff line number Diff line change
@@ -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
11 changes: 11 additions & 0 deletions scripts/github_release.sh
Original file line number Diff line number Diff line change
@@ -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
35 changes: 28 additions & 7 deletions src/Fastenshtein/Fastenshtein.csproj
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard1.0;netstandard2.0;net452</TargetFrameworks>
<Title>Fastenshtein</Title>
<TargetFrameworks>netstandard1.0;netstandard2.0;net452;net8.0</TargetFrameworks>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
</PropertyGroup>

<PropertyGroup>
<Title>Fastenshtein</Title>
<Authors>DanHartley</Authors>
<Description>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.</Description>
<Description>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.</Description>
<Copyright>Copyright © 2017</Copyright>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<PackageProjectUrl>https://github.com/DanHarltey/Fastenshtein</PackageProjectUrl>
<RepositoryType>GIT</RepositoryType>
<RepositoryUrl>https://github.com/DanHarltey/Fastenshtein.git</RepositoryUrl>
<AssemblyVersion>1.0.0.8</AssemblyVersion>
<FileVersion>1.0.0.8</FileVersion>
<Version>1.0.0.8</Version>
<PackageReleaseNotes>Adding .NetStandard2.0 support.</PackageReleaseNotes>
<AssemblyVersion>1.0.0.9</AssemblyVersion>
<FileVersion>1.0.0.9</FileVersion>
<Version>1.0.0.9</Version>
<PackageReleaseNotes>Adding .Net 8 support</PackageReleaseNotes>
<PackageTags>Levenshtein Distance;String;Fuzzy Matching;Search;netstandard;</PackageTags>
</PropertyGroup>

Expand Down Expand Up @@ -42,4 +45,22 @@
</None>
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<PropertyGroup>
<!-- Optional: Publish the repository URL in the built .nupkg (in the NuSpec <Repository> element) -->
<PublishRepositoryUrl>True</PublishRepositoryUrl>

<!-- Optional: Embed source files that are not tracked by the source control manager in the PDB -->
<EmbedUntrackedSources>True</EmbedUntrackedSources>

<!-- Optional: Build symbol package (.snupkg) to distribute the PDB containing Source Link -->
<IncludeSymbols>True</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
</PropertyGroup>
</Project>
Loading

0 comments on commit ba9513e

Please sign in to comment.