Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
milindpatel63 committed Jun 7, 2023
2 parents 2f1bffa + 51e23b7 commit 568286d
Show file tree
Hide file tree
Showing 519 changed files with 27,195 additions and 10,143 deletions.
78 changes: 52 additions & 26 deletions .github/workflows/sonar-scan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,37 @@ name: .NET Build Test and Sonar Scan

on:
push:
branches: '*'
branches: '**'
pull_request:
branches: [ main, develop ]
types: [synchronize]
workflow_dispatch:


jobs:
check_pr:
runs-on: ubuntu-latest
steps:
- name: Check PR Body
uses: JJ/github-pr-contains-action@releases/v10
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
bodyDoesNotContain: "[\"|`]"
build:
name: Build .Net
runs-on: windows-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup .NET Core
uses: actions/setup-dotnet@v2
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.x
dotnet-version: 7.0.x

- name: Install Swashbuckle CLI
shell: powershell
run: dotnet tool install -g --version 6.4.0 Swashbuckle.AspNetCore.Cli
run: dotnet tool install -g --version 6.5.0 Swashbuckle.AspNetCore.Cli

- name: Install dependencies
run: dotnet restore
Expand Down Expand Up @@ -75,24 +82,23 @@ jobs:
- name: Test
run: dotnet test --no-restore --verbosity normal


version:
name: Bump version on Develop push
needs: [ build ]
runs-on: ubuntu-latest
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/develop' }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup .NET Core
uses: actions/setup-dotnet@v2
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.x
dotnet-version: 7.0.x

- name: Install Swashbuckle CLI
run: dotnet tool install -g --version 6.4.0 Swashbuckle.AspNetCore.Cli
run: dotnet tool install -g --version 6.5.0 Swashbuckle.AspNetCore.Cli

- name: Install dependencies
run: dotnet restore
Expand All @@ -111,6 +117,9 @@ jobs:
name: Build Nightly Docker if Develop push
needs: [ build, version ]
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/develop' }}
steps:
- name: Find Current Pull Request
Expand Down Expand Up @@ -140,7 +149,7 @@ jobs:
echo "::set-output name=BODY::$body"
- name: Check Out Repo
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
ref: develop

Expand All @@ -151,7 +160,7 @@ jobs:
- run: |
cd UI/Web || exit
echo 'Installing web dependencies'
npm ci --legacy-peer-deps
npm ci
echo 'Building UI'
npm run prod
Expand All @@ -177,21 +186,28 @@ jobs:
run: echo "${{steps.get-version.outputs.assembly-version}}"

- name: Compile dotnet app
uses: actions/setup-dotnet@v2
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.x
dotnet-version: 7.0.x

- name: Install Swashbuckle CLI
run: dotnet tool install -g --version 6.4.0 Swashbuckle.AspNetCore.Cli
run: dotnet tool install -g --version 6.5.0 Swashbuckle.AspNetCore.Cli

- run: ./monorepo-build.sh

- name: Login to Docker Hub
uses: docker/login-action@v1
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set up QEMU
uses: docker/setup-qemu-action@v1

Expand All @@ -206,7 +222,7 @@ jobs:
context: .
platforms: linux/amd64,linux/arm/v7,linux/arm64
push: true
tags: milindpatel63/dianakavita:nightly, milindpatel63/dianakavita:nightly-${{ steps.parse-version.outputs.VERSION }}
tags: milindpatel63/dianakavita:nightly, milindpatel63/dianakavita:nightly-${{ steps.parse-version.outputs.VERSION }}, ghcr.io/milindpatel63/dianakavita:nightly, ghcr.io/milindpatel63/dianakavita:nightly-${{ steps.parse-version.outputs.VERSION }}

- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
Expand All @@ -224,6 +240,9 @@ jobs:
name: Build Stable Docker if Main push
needs: [ build ]
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
steps:

Expand Down Expand Up @@ -254,7 +273,7 @@ jobs:
echo "::set-output name=BODY::$body"
- name: Check Out Repo
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
ref: main

Expand All @@ -266,7 +285,7 @@ jobs:
cd UI/Web || exit
echo 'Installing web dependencies'
npm ci --legacy-peer-deps
npm install
echo 'Building UI'
npm run prod
Expand Down Expand Up @@ -294,20 +313,27 @@ jobs:
id: parse-version

- name: Compile dotnet app
uses: actions/setup-dotnet@v2
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.x
dotnet-version: 7.0.x
- name: Install Swashbuckle CLI
run: dotnet tool install -g --version 6.4.0 Swashbuckle.AspNetCore.Cli
run: dotnet tool install -g --version 6.5.0 Swashbuckle.AspNetCore.Cli

- run: ./monorepo-build.sh

- name: Login to Docker Hub
uses: docker/login-action@v1
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set up QEMU
uses: docker/setup-qemu-action@v1

Expand All @@ -322,7 +348,7 @@ jobs:
context: .
platforms: linux/amd64,linux/arm/v7,linux/arm64
push: true
tags: milindpatel63/dianakavita:latest, milindpatel63/dianakavita:${{ steps.parse-version.outputs.VERSION }}
tags: milindpatel63/dianakavita:latest, milindpatel63/dianakavita:${{ steps.parse-version.outputs.VERSION }}, ghcr.io/milindpatel63/dianakavita:nightly, ghcr.io/milindpatel63/dianakavita:nightly-${{ steps.parse-version.outputs.VERSION }}

- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
Expand Down
8 changes: 4 additions & 4 deletions API.Benchmark/API.Benchmark.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<OutputType>Exe</OutputType>
</PropertyGroup>

Expand All @@ -10,9 +10,9 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.13.2" />
<PackageReference Include="BenchmarkDotNet.Annotations" Version="0.13.2" />
<PackageReference Include="NSubstitute" Version="4.4.0" />
<PackageReference Include="BenchmarkDotNet" Version="0.13.5" />
<PackageReference Include="BenchmarkDotNet.Annotations" Version="0.13.5" />
<PackageReference Include="NSubstitute" Version="5.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion API.Benchmark/ArchiveServiceBenchmark.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace API.Benchmark;
[MemoryDiagnoser]
[RankColumn]
[Orderer(SummaryOrderPolicy.FastestToSlowest)]
[SimpleJob(launchCount: 1, warmupCount: 5, targetCount: 20)]
[SimpleJob(launchCount: 1, warmupCount: 5, invocationCount: 20)]
public class ArchiveServiceBenchmark
{
private readonly ArchiveService _archiveService;
Expand Down
5 changes: 1 addition & 4 deletions API.Benchmark/CleanTitleBenchmark.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.IO;
using System.Text.RegularExpressions;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Order;

namespace API.Benchmark;

Expand Down
17 changes: 3 additions & 14 deletions API.Benchmark/EpubBenchmark.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,11 @@ namespace API.Benchmark;
[MemoryDiagnoser]
[RankColumn]
[Orderer(SummaryOrderPolicy.FastestToSlowest)]
[SimpleJob(launchCount: 1, warmupCount: 5, targetCount: 20)]
[SimpleJob(launchCount: 1, warmupCount: 5, invocationCount: 20)]
public class EpubBenchmark
{
private const string FilePath = @"E:\Books\Invaders of the Rokujouma\Invaders of the Rokujouma - Volume 01.epub";
private readonly Regex WordRegex = new Regex(@"\b\w+\b", RegexOptions.Compiled | RegexOptions.IgnoreCase);

// [Benchmark]
// public async Task GetWordCount_PassByString()
// {
// using var book = await EpubReader.OpenBookAsync(FilePath, BookService.BookReaderOptions);
// foreach (var bookFile in book.Content.Html.Values)
// {
// GetBookWordCount_PassByString(await bookFile.ReadContentAsTextAsync());
// ;
// }
// }
private readonly Regex _wordRegex = new Regex(@"\b\w+\b", RegexOptions.Compiled | RegexOptions.IgnoreCase);

[Benchmark]
public async Task GetWordCount_PassByRef()
Expand Down Expand Up @@ -111,6 +100,6 @@ private async Task<int> GetBookWordCount_Regex(EpubContentFileRef bookFile)


return doc.DocumentNode.SelectNodes("//body//text()[not(parent::script)]")
.Sum(node => WordRegex.Matches(node.InnerText).Count);
.Sum(node => _wordRegex.Matches(node.InnerText).Count);
}
}
19 changes: 19 additions & 0 deletions API.Benchmark/ParserBenchmarks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,24 @@ public void TestIsEpub_New()
}
}

[Benchmark]
public void Test_CharacterReplace()
{
foreach (var name in _names)
{
var d = name.Contains('a');
}
}

[Benchmark]
public void Test_StringReplace()
{
foreach (var name in _names)
{

var d = name.Contains("a");
}
}


}
20 changes: 10 additions & 10 deletions API.Tests/API.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>

<TargetFramework>net7.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="6.0.10" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="7.0.5" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
<PackageReference Include="Moq" Version="4.18.4" />
<PackageReference Include="NSubstitute" Version="4.4.0" />
<PackageReference Include="System.IO.Abstractions.TestingHelpers" Version="17.2.3" />
<PackageReference Include="System.IO.Abstractions.TestingHelpers" Version="19.2.11" />
<PackageReference Include="TestableIO.System.IO.Abstractions.Wrappers" Version="19.2.11" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="3.1.2">
<PackageReference Include="coverlet.collector" Version="3.2.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\API\API.csproj" />
<ProjectReference Include="..\API\API.csproj" />
</ItemGroup>

<ItemGroup>
<Folder Include="Services\Test Data\ArchiveService\ComicInfos" />
<Folder Include="Services\Test Data\ScannerService\Manga" />
<Folder Include="Services\Test Data\ArchiveService\ComicInfos" />
<Folder Include="Services\Test Data\ScannerService\Manga" />
</ItemGroup>

<ItemGroup>
<None Remove="Extensions\Test Data\modified on run.txt" />
<None Remove="Extensions\Test Data\modified on run.txt" />
</ItemGroup>

</Project>
Loading

0 comments on commit 568286d

Please sign in to comment.