Skip to content

Commit f2b46ef

Browse files
authored
Bump PuppeteerSharp from 6.2.0 to 7.0.0
2 parents 01ff6d1 + 5df7b36 commit f2b46ef

File tree

12 files changed

+146
-84
lines changed

12 files changed

+146
-84
lines changed

.github/dependabot.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
version: 2
22
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: weekly
7+
rebase-strategy: auto
8+
39
- package-ecosystem: "nuget" # See documentation for possible values
410
directory: "/" # Location of package manifests
511
schedule:
@@ -15,6 +21,6 @@ updates:
1521
- dependency-name: "xunit.runner.visualstudio"
1622
- dependency-name: "MSTest.TestAdapter"
1723
- dependency-name: "MSTest.TestFramework"
18-
- dependency-name: "ImageSharpCompare"
19-
- dependency-name: "PdfjsSharp"
24+
- dependency-name: "Codeuctivity.ImageSharpCompare"
25+
- dependency-name: "Codeuctivity.PdfjsSharp"
2026
- dependency-name: "Microsoft.SourceLink.GitHub"

.github/workflows/dotnet.yml

Lines changed: 75 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: .NET build and test
22
env:
3-
CURRENT_VERSION: 2.0.${{ github.run_number }}
3+
CURRENT_VERSION: 2.1.${{ github.run_number }}
44
LAST_COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
55

66
on:
@@ -14,78 +14,90 @@ jobs:
1414
matrix:
1515
os: [windows-latest, ubuntu-latest]
1616
steps:
17-
- uses: actions/checkout@v2
18-
- name: Setup .NET
19-
uses: actions/setup-dotnet@v1
20-
with:
21-
dotnet-version: 6.0.x
22-
- uses: actions/setup-node@v2
23-
with:
24-
node-version: 14
25-
- name: Restore dependencies
26-
run: dotnet restore
27-
- name: Build
28-
run: dotnet build --configuration Release --no-restore
29-
- name: Test
30-
run: dotnet test --no-build --verbosity normal --configuration Release
17+
- uses: actions/checkout@v3
18+
- name: Setup .NET
19+
uses: actions/setup-dotnet@v2
20+
with:
21+
dotnet-version: 6.0.x
22+
- uses: actions/setup-node@v2
23+
with:
24+
node-version: 14
25+
- name: Restore dependencies
26+
run: dotnet restore
27+
- name: Build
28+
run: dotnet build --configuration Release --no-restore
29+
- name: Test
30+
run: dotnet test --no-build --verbosity normal --configuration Release
31+
- name: Publish Unit Test Results
32+
uses: actions/upload-artifact@v3
33+
if: failure()
34+
with:
35+
name: TestResult
36+
path: "TestResult/**/*"
3137

3238
deployRelease:
3339
if: github.ref == 'refs/heads/main'
3440
runs-on: ubuntu-latest
35-
needs: build
41+
needs: build
3642
steps:
37-
- uses: actions/checkout@v2
38-
- name: Setup .NET
39-
uses: actions/setup-dotnet@v1
40-
with:
41-
dotnet-version: 6.0.x
42-
- name: Restore dependencies
43-
run: dotnet restore
44-
- name: Build
45-
run: dotnet build --configuration Release --no-restore
46-
- name: Publish
47-
run: dotnet publish ./Codeuctivity.HtmlRendererCli --configuration Release -p:PublishProfile=FolderProfile
48-
- name: NugetPush
49-
run: |
43+
- uses: actions/checkout@v3
44+
- name: Setup .NET
45+
uses: actions/setup-dotnet@v2
46+
with:
47+
dotnet-version: 6.0.x
48+
- name: Restore dependencies
49+
run: dotnet restore
50+
- name: Build
51+
run: dotnet build --configuration Release --no-restore
52+
- name: Publish
53+
run: dotnet publish ./Codeuctivity.HtmlRendererCli --configuration Release -p:PublishProfile=FolderProfile
54+
- name: NugetPush
55+
env:
56+
NUGET_TOKEN_EXISTS: ${{ secrets.NUGET_TOKEN }}
57+
if: env.NUGET_TOKEN_EXISTS != ''
58+
run: |
5059
dotnet nuget push ./Codeuctivity.HtmlRenderer/bin/Release/*.nupkg --skip-duplicate --api-key ${{secrets.NUGET_TOKEN}} --source https://api.nuget.org/v3/index.json
51-
- uses: "marvinpinto/action-automatic-releases@latest"
52-
with:
53-
repo_token: "${{ secrets.GITHUB_TOKEN }}"
54-
automatic_release_tag: ${{ env.CURRENT_VERSION }}
55-
prerelease: false
56-
title: "Release Build"
57-
files: |
58-
./Codeuctivity.HtmlRenderer/bin/Release/*.nupkg
59-
./Codeuctivity.HtmlRenderer/bin/Release/*.snupkg
60-
./Codeuctivity.HtmlRendererCli/bin/Release/net6.0/publish/win-x86/Codeuctivity.HtmlRendererCli.exe
60+
- uses: "marvinpinto/action-automatic-releases@latest"
61+
with:
62+
repo_token: "${{ secrets.GITHUB_TOKEN }}"
63+
automatic_release_tag: ${{ env.CURRENT_VERSION }}
64+
prerelease: false
65+
title: "Release Build"
66+
files: |
67+
./Codeuctivity.HtmlRenderer/bin/Release/*.nupkg
68+
./Codeuctivity.HtmlRenderer/bin/Release/*.snupkg
69+
./Codeuctivity.HtmlRendererCli/bin/Release/net6.0/publish/win-x86/Codeuctivity.HtmlRendererCli.exe
6170
6271
deployTest:
6372
if: github.ref != 'refs/heads/main'
6473
runs-on: ubuntu-latest
65-
needs: build
74+
needs: build
6675
steps:
67-
- uses: actions/checkout@v2
68-
- name: Setup .NET
69-
uses: actions/setup-dotnet@v1
70-
with:
71-
dotnet-version: 6.0.x
72-
- name: Restore dependencies
73-
run: dotnet restore
74-
- name: Build
75-
run: dotnet build --configuration Release --no-restore
76-
- name: Publish
77-
run: dotnet publish ./Codeuctivity.HtmlRendererCli --configuration Release -p:PublishProfile=FolderProfile
78-
- name: NugetPush
79-
run: |
76+
- uses: actions/checkout@v3
77+
- name: Setup .NET
78+
uses: actions/setup-dotnet@v2
79+
with:
80+
dotnet-version: 6.0.x
81+
- name: Restore dependencies
82+
run: dotnet restore
83+
- name: Build
84+
run: dotnet build --configuration Release --no-restore
85+
- name: Publish
86+
run: dotnet publish ./Codeuctivity.HtmlRendererCli --configuration Release -p:PublishProfile=FolderProfile
87+
- name: NugetPush
88+
env:
89+
NUGET_TOKEN_EXISTS: ${{ secrets.NUGET_TEST_TOKEN }}
90+
if: env.NUGET_TOKEN_EXISTS != ''
91+
run: |
8092
ls ./Codeuctivity.HtmlRenderer/bin/Release
8193
dotnet nuget push ./Codeuctivity.HtmlRenderer/bin/Release/*.nupkg --skip-duplicate --api-key ${{secrets.NUGET_TEST_TOKEN}} --source https://apiint.nugettest.org/v3/index.json
82-
- uses: "marvinpinto/action-automatic-releases@latest"
83-
with:
84-
repo_token: "${{ secrets.GITHUB_TOKEN }}"
85-
automatic_release_tag: "latest-prerelease"
86-
prerelease: true
87-
title: "Prerelease Build"
88-
files: |
89-
./Codeuctivity.HtmlRenderer/bin/Release/*.nupkg
90-
./Codeuctivity.HtmlRenderer/bin/Release/*.snupkg
91-
./Codeuctivity.HtmlRendererCli/bin/Release/net6.0/publish/win-x86/Codeuctivity.HtmlRendererCli.exe
94+
- uses: "marvinpinto/action-automatic-releases@latest"
95+
with:
96+
repo_token: "${{ secrets.GITHUB_TOKEN }}"
97+
automatic_release_tag: "latest-prerelease"
98+
prerelease: true
99+
title: "Prerelease Build"
100+
files: |
101+
./Codeuctivity.HtmlRenderer/bin/Release/*.nupkg
102+
./Codeuctivity.HtmlRenderer/bin/Release/*.snupkg
103+
./Codeuctivity.HtmlRendererCli/bin/Release/net6.0/publish/win-x86/Codeuctivity.HtmlRendererCli.exe

Codeuctivity.HtmlRenderer/Codeuctivity.HtmlRenderer.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@
3838

3939
<ItemGroup>
4040
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="all" />
41-
<PackageReference Include="PuppeteerSharp" Version="6.2.0" />
42-
<PackageReference Include="SonarAnalyzer.CSharp" Version="8.36.1.44192">
41+
<PackageReference Include="PuppeteerSharp" Version="7.0.0" />
42+
<PackageReference Include="SonarAnalyzer.CSharp" Version="8.37.0.45539">
4343
<PrivateAssets>all</PrivateAssets>
4444
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
4545
</PackageReference>

Codeuctivity.HtmlRenderer/Renderer.cs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System;
33
using System.IO;
44
using System.Net;
5+
using System.Runtime.InteropServices;
56
using System.Threading.Tasks;
67

78
namespace Codeuctivity.HtmlRenderer
@@ -41,14 +42,29 @@ public static Task<Renderer> CreateAsync(BrowserFetcher browserFetcher)
4142

4243
private async Task<Renderer> InitializeAsync(BrowserFetcher browserFetcher)
4344
{
44-
BrowserFetcher = browserFetcher;
45+
BrowserFetcher = browserFetcher ?? throw new ArgumentNullException(nameof(browserFetcher));
4546
BrowserFetcher.DownloadProgressChanged += DownloadProgressChanged;
4647

4748
await BrowserFetcher.DownloadAsync(BrowserFetcher.DefaultChromiumRevision);
48-
Browser = await Puppeteer.LaunchAsync(new LaunchOptions { Headless = true });
49+
Browser = await Puppeteer.LaunchAsync(SystemSpecificConfig());
4950
return this;
5051
}
5152

53+
private static LaunchOptions SystemSpecificConfig()
54+
{
55+
if (IsRunningOnWsl())
56+
{
57+
return new LaunchOptions { Headless = true, Args = new string[] { "--no-sandbox" } };
58+
}
59+
60+
return new LaunchOptions { Headless = true };
61+
}
62+
63+
private static bool IsRunningOnWsl()
64+
{
65+
return RuntimeInformation.IsOSPlatform(OSPlatform.Linux) && File.ReadAllText("/proc/version").Contains("Microsoft");
66+
}
67+
5268
/// <summary>
5369
/// Converts a HTML file to a PDF
5470
/// </summary>

Codeuctivity.HtmlRendererCliTests/Codeuctivity.HtmlRendererCliTests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
<ItemGroup>
1010
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
11-
<PackageReference Include="SonarAnalyzer.CSharp" Version="8.36.1.44192">
11+
<PackageReference Include="SonarAnalyzer.CSharp" Version="8.37.0.45539">
1212
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1313
<PrivateAssets>all</PrivateAssets>
1414
</PackageReference>

Codeuctivity.HtmlRendererTests/Codeuctivity.HtmlRendererTests.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
</ItemGroup>
1717

1818
<ItemGroup>
19-
<PackageReference Include="Codeuctivity.ImageSharpCompare" Version="2.0.18" />
19+
<PackageReference Include="Codeuctivity.ImageSharpCompare" Version="2.0.25" />
2020
<PackageReference Include="Codeuctivity.PdfjsSharp" Version="1.2.27" />
21-
<PackageReference Include="SonarAnalyzer.CSharp" Version="8.36.1.44192">
21+
<PackageReference Include="SonarAnalyzer.CSharp" Version="8.37.0.45539">
2222
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2323
<PrivateAssets>all</PrivateAssets>
2424
</PackageReference>
11.5 KB
Loading
463 Bytes
Loading

Codeuctivity.HtmlRendererTests/Infrastrukture/ChromiumProcessDisposedAsserter.cs renamed to Codeuctivity.HtmlRendererTests/Infrastructure/ChromiumProcessDisposedAsserter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
using System.Threading.Tasks;
44
using Xunit;
55

6-
namespace Codeuctivity.HtmlRendererTests.Infrastrukture
6+
namespace Codeuctivity.HtmlRendererTests.Infrastructure
77
{
88
public static class ChromiumProcessDisposedAsserter
99
{

Codeuctivity.HtmlRendererTests/Infrastrukture/DocumentAsserter.cs renamed to Codeuctivity.HtmlRendererTests/Infrastructure/DocumentAsserter.cs

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
using System;
2-
using System.IO;
1+
using System.IO;
32
using System.Runtime.InteropServices;
43
using Xunit;
54

6-
namespace Codeuctivity.HtmlRendererTests.Infrastrukture
5+
namespace Codeuctivity.HtmlRendererTests.Infrastructure
76
{
87
internal static class DocumentAsserter
98
{
9+
private const string TestOutputFirectory = "../../../../TestResult";
10+
1011
internal static void AssertImageIsEqual(string actualImagePath, string expectImageFilePath, int allowedPixelErrorCount)
1112
{
1213
var actualFullPath = Path.GetFullPath(actualImagePath);
1314
var expectFullPath = Path.GetFullPath(expectImageFilePath);
1415

1516
Assert.True(File.Exists(actualFullPath), $"actualImagePath not found {actualFullPath}");
1617
Assert.True(File.Exists(expectFullPath), $"ExpectReferenceImagePath not found \n{expectFullPath}\n copy over \n{actualFullPath}\n if this is a new test case.");
17-
var base64fyedActualImage = Convert.ToBase64String(File.ReadAllBytes(actualFullPath));
1818

1919
if (ImageSharpCompare.ImageSharpCompare.ImagesAreEqual(actualFullPath, expectFullPath))
2020
{
@@ -30,13 +30,19 @@ internal static void AssertImageIsEqual(string actualImagePath, string expectIma
3030
{
3131
SixLabors.ImageSharp.ImageExtensions.SaveAsPng(maskImage, fileStreamDifferenceMask);
3232
}
33-
var base64fyedImageDiff = Convert.ToBase64String(File.ReadAllBytes(newDiffImage));
3433

3534
if (File.Exists(allowedDiffImage))
3635
{
3736
var resultWithAllowedDiff = ImageSharpCompare.ImageSharpCompare.CalcDiff(actualFullPath, expectFullPath, allowedDiffImage);
3837

39-
Assert.True(resultWithAllowedDiff.PixelErrorCount <= allowedPixelErrorCount, $"Expected PixelErrorCount beyond {allowedPixelErrorCount} but was {resultWithAllowedDiff.PixelErrorCount}\nExpected {expectFullPath}\ndiffers to actual {actualFullPath}\n {base64fyedActualImage}\n \n Diff is {newDiffImage} \n {base64fyedImageDiff}\n");
38+
if (allowedPixelErrorCount < resultWithAllowedDiff.PixelErrorCount)
39+
{
40+
CopyToTestOutput(actualImagePath);
41+
CopyToTestOutput(expectImageFilePath);
42+
CopyToTestOutput(newDiffImage);
43+
}
44+
45+
Assert.True(resultWithAllowedDiff.PixelErrorCount <= allowedPixelErrorCount, $"Expected PixelErrorCount beyond {allowedPixelErrorCount} but was {resultWithAllowedDiff.PixelErrorCount}\nExpected {expectFullPath}\ndiffers to actual {actualFullPath}\n Diff is {newDiffImage}");
4046
return;
4147
}
4248

@@ -48,7 +54,26 @@ internal static void AssertImageIsEqual(string actualImagePath, string expectIma
4854

4955
var result = ImageSharpCompare.ImageSharpCompare.CalcDiff(actualFullPath, expectFullPath);
5056

51-
Assert.True(result.PixelErrorCount <= allowedPixelErrorCount, $"Expected PixelErrorCount beyond {allowedPixelErrorCount} but was {result.PixelErrorCount}\nExpected {expectFullPath}\ndiffers to actual {actualFullPath}\n {base64fyedActualImage}\n \n Diff is {newDiffImage} \n {base64fyedImageDiff}\nReplace {actualFullPath} with the new value or store the diff as {allowedDiffImage}.");
57+
if (allowedPixelErrorCount < result.PixelErrorCount)
58+
{
59+
CopyToTestOutput(newDiffImage);
60+
CopyToTestOutput(actualImagePath);
61+
}
62+
63+
Assert.True(result.PixelErrorCount <= allowedPixelErrorCount, $"Expected PixelErrorCount beyond {allowedPixelErrorCount} but was {result.PixelErrorCount}\nExpected {expectFullPath}\ndiffers to actual {actualFullPath}\n Diff is {newDiffImage}\nReplace {actualFullPath} with the new value or store the diff as {allowedDiffImage}.");
64+
}
65+
66+
private static void CopyToTestOutput(string testOutputFile)
67+
{
68+
if (string.IsNullOrEmpty(testOutputFile))
69+
{
70+
throw new System.ArgumentException($"'{nameof(testOutputFile)}' cannot be null or empty.", nameof(testOutputFile));
71+
}
72+
73+
if (!Directory.Exists(TestOutputFirectory))
74+
Directory.CreateDirectory(TestOutputFirectory);
75+
76+
File.Copy(testOutputFile, Path.Combine(TestOutputFirectory, Path.GetFileName(testOutputFile)), true);
5277
}
5378
}
5479
}

0 commit comments

Comments
 (0)