Skip to content

Commit

Permalink
Avoid asset duplicates; use compression of actions/upload-artifact (#86)
Browse files Browse the repository at this point in the history
  • Loading branch information
sungaila authored Jun 28, 2024
1 parent cff7a4e commit 82b135a
Show file tree
Hide file tree
Showing 22 changed files with 194 additions and 8,871 deletions.
11 changes: 2 additions & 9 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,18 +131,15 @@ jobs:
src/PDFtoImage/bin/${{ github.event_name != 'workflow_dispatch' && 'Debug' || inputs.build_configuration }}/*.nupkg
src/PDFtoImage/bin/${{ github.event_name != 'workflow_dispatch' && 'Debug' || inputs.build_configuration }}/*.snupkg
if-no-files-found: error
- name: Compress tests
shell: pwsh
run: Compress-Archive -Path src/Tests/bin/${{ github.event_name != 'workflow_dispatch' && 'Debug' || inputs.build_configuration }}/* -DestinationPath TestAssemblies.zip -CompressionLevel "Fastest"
- name: Publish tests
uses: actions/upload-artifact@main
if: success() && (github.event_name != 'workflow_dispatch' && true || inputs.run_tests) == true
with:
name: Test assemblies
path: TestAssemblies.zip
path: src/Tests/bin/${{ github.event_name != 'workflow_dispatch' && 'Debug' || inputs.build_configuration }}
if-no-files-found: error
retention-days: 1
compression-level: 0
compression-level: 9
- name: Publish test project MonoConsole
uses: actions/upload-artifact@main
if: success() && (github.event_name != 'workflow_dispatch' && true || inputs.run_tests) == true
Expand Down Expand Up @@ -195,10 +192,6 @@ jobs:
uses: actions/download-artifact@main
with:
name: Test assemblies
- name: Expand tests
if: success() || failure()
shell: pwsh
run: Expand-Archive -Path TestAssemblies.zip -DestinationPath .
- name: .NET Framework 4.6.2
if: runner.os == 'Windows' && (success() || failure())
run: dotnet test net462/*.Tests.dll --logger trx --verbosity detailed --results-directory "${{ matrix.os }}/TestResults" ${{ (github.event_name == 'workflow_dispatch' && inputs.generate_assets) == true && '--settings net462/SaveOutputInGeneratedFolder.runsettings' || '' }}
Expand Down
12 changes: 6 additions & 6 deletions src/Tests/AntiAliasingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ public void Initialize()
[DataRow(PdfAntiAliasing.All, DisplayName = "All")]
public void SaveJpegWithAntiAliasing(PdfAntiAliasing? antiAliasing)
{
var expectedPath = Path.Combine("Assets", "Expected", GetPlatformAsString(), "AntiAliasing", $"hundesteuer-anmeldung_{GetFileName(antiAliasing ?? PdfAntiAliasing.All)}.jpg");
var expectedPath = Path.Combine("..", "Assets", "Expected", GetPlatformAsString(), "AntiAliasing", $"hundesteuer-anmeldung_{GetFileName(antiAliasing ?? PdfAntiAliasing.All)}.jpg");

using var inputStream = GetInputStream(Path.Combine("Assets", "hundesteuer-anmeldung.pdf"));
using var inputStream = GetInputStream(Path.Combine("..", "Assets", "hundesteuer-anmeldung.pdf"));
using var outputStream = CreateOutputStream(expectedPath);

if (antiAliasing == null)
Expand All @@ -59,9 +59,9 @@ public void SaveJpegWithAntiAliasing(PdfAntiAliasing? antiAliasing)
[DataRow(PdfAntiAliasing.All, DisplayName = "All")]
public void SavePngWithAntiAliasing(PdfAntiAliasing? antiAliasing)
{
var expectedPath = Path.Combine("Assets", "Expected", GetPlatformAsString(), "AntiAliasing", $"hundesteuer-anmeldung_{GetFileName(antiAliasing ?? PdfAntiAliasing.All)}.png");
var expectedPath = Path.Combine("..", "Assets", "Expected", GetPlatformAsString(), "AntiAliasing", $"hundesteuer-anmeldung_{GetFileName(antiAliasing ?? PdfAntiAliasing.All)}.png");

using var inputStream = GetInputStream(Path.Combine("Assets", "hundesteuer-anmeldung.pdf"));
using var inputStream = GetInputStream(Path.Combine("..", "Assets", "hundesteuer-anmeldung.pdf"));
using var outputStream = CreateOutputStream(expectedPath);

if (antiAliasing == null)
Expand All @@ -85,9 +85,9 @@ public void SavePngWithAntiAliasing(PdfAntiAliasing? antiAliasing)
[DataRow(PdfAntiAliasing.All, DisplayName = "All")]
public void SaveWebpWithAntiAliasing(PdfAntiAliasing? antiAliasing)
{
var expectedPath = Path.Combine("Assets", "Expected", GetPlatformAsString(), "AntiAliasing", $"hundesteuer-anmeldung_{GetFileName(antiAliasing ?? PdfAntiAliasing.All)}.webp");
var expectedPath = Path.Combine("..", "Assets", "Expected", GetPlatformAsString(), "AntiAliasing", $"hundesteuer-anmeldung_{GetFileName(antiAliasing ?? PdfAntiAliasing.All)}.webp");

using var inputStream = GetInputStream(Path.Combine("Assets", "hundesteuer-anmeldung.pdf"));
using var inputStream = GetInputStream(Path.Combine("..", "Assets", "hundesteuer-anmeldung.pdf"));
using var outputStream = CreateOutputStream(expectedPath);

if (antiAliasing == null)
Expand Down
38 changes: 19 additions & 19 deletions src/Tests/ApiTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ await Assert.ThrowsExceptionAsync<ArgumentNullException>(async () =>
[TestMethod]
public void ToImageStreamLeaveOpenDefault()
{
using var inputStream = GetInputStream(Path.Combine("Assets", "SocialPreview.pdf"));
using var inputStream = GetInputStream(Path.Combine("..", "Assets", "SocialPreview.pdf"));
Assert.IsTrue(inputStream.CanRead);

ToImage(inputStream);
Expand All @@ -186,7 +186,7 @@ public void ToImageStreamLeaveOpenDefault()
[TestMethod]
public void ToImageStreamLeaveOpenFalse()
{
using var inputStream = GetInputStream(Path.Combine("Assets", "SocialPreview.pdf"));
using var inputStream = GetInputStream(Path.Combine("..", "Assets", "SocialPreview.pdf"));
Assert.IsTrue(inputStream.CanRead);

ToImage(inputStream, false);
Expand All @@ -196,7 +196,7 @@ public void ToImageStreamLeaveOpenFalse()
[TestMethod]
public void ToImageStreamLeaveOpenTrue()
{
using var inputStream = GetInputStream(Path.Combine("Assets", "SocialPreview.pdf"));
using var inputStream = GetInputStream(Path.Combine("..", "Assets", "SocialPreview.pdf"));
Assert.IsTrue(inputStream.CanRead);

ToImage(inputStream, true);
Expand All @@ -206,7 +206,7 @@ public void ToImageStreamLeaveOpenTrue()
[TestMethod]
public void ToImagesStreamLeaveOpenDefault()
{
using var inputStream = GetInputStream(Path.Combine("Assets", "SocialPreview.pdf"));
using var inputStream = GetInputStream(Path.Combine("..", "Assets", "SocialPreview.pdf"));
Assert.IsTrue(inputStream.CanRead);

var result = ToImages(inputStream);
Expand All @@ -219,7 +219,7 @@ public void ToImagesStreamLeaveOpenDefault()
[TestMethod]
public void ToImagesStreamLeaveOpenFalse()
{
using var inputStream = GetInputStream(Path.Combine("Assets", "SocialPreview.pdf"));
using var inputStream = GetInputStream(Path.Combine("..", "Assets", "SocialPreview.pdf"));
Assert.IsTrue(inputStream.CanRead);

var result = ToImages(inputStream, false);
Expand All @@ -232,7 +232,7 @@ public void ToImagesStreamLeaveOpenFalse()
[TestMethod]
public void ToImagesStreamLeaveOpenTrue()
{
using var inputStream = GetInputStream(Path.Combine("Assets", "SocialPreview.pdf"));
using var inputStream = GetInputStream(Path.Combine("..", "Assets", "SocialPreview.pdf"));
Assert.IsTrue(inputStream.CanRead);

var result = ToImages(inputStream, true);
Expand All @@ -246,7 +246,7 @@ public void ToImagesStreamLeaveOpenTrue()
[TestMethod]
public async Task ToImagesAsyncStreamLeaveOpenDefault()
{
using var inputStream = GetInputStream(Path.Combine("Assets", "SocialPreview.pdf"));
using var inputStream = GetInputStream(Path.Combine("..", "Assets", "SocialPreview.pdf"));
Assert.IsTrue(inputStream.CanRead);

var result = ToImagesAsync(inputStream);
Expand All @@ -259,7 +259,7 @@ public async Task ToImagesAsyncStreamLeaveOpenDefault()
[TestMethod]
public async Task ToImagesAsyncStreamLeaveOpenFalse()
{
using var inputStream = GetInputStream(Path.Combine("Assets", "SocialPreview.pdf"));
using var inputStream = GetInputStream(Path.Combine("..", "Assets", "SocialPreview.pdf"));
Assert.IsTrue(inputStream.CanRead);

var result = ToImagesAsync(inputStream, false);
Expand All @@ -272,7 +272,7 @@ public async Task ToImagesAsyncStreamLeaveOpenFalse()
[TestMethod]
public async Task ToImagesAsyncStreamLeaveOpenTrue()
{
using var inputStream = GetInputStream(Path.Combine("Assets", "SocialPreview.pdf"));
using var inputStream = GetInputStream(Path.Combine("..", "Assets", "SocialPreview.pdf"));
Assert.IsTrue(inputStream.CanRead);

var result = ToImagesAsync(inputStream, true);
Expand All @@ -286,7 +286,7 @@ public async Task ToImagesAsyncStreamLeaveOpenTrue()
[TestMethod]
public void GetPageCountStreamLeaveOpenDefault()
{
using var inputStream = GetInputStream(Path.Combine("Assets", "SocialPreview.pdf"));
using var inputStream = GetInputStream(Path.Combine("..", "Assets", "SocialPreview.pdf"));
Assert.IsTrue(inputStream.CanRead);

GetPageCount(inputStream);
Expand All @@ -296,7 +296,7 @@ public void GetPageCountStreamLeaveOpenDefault()
[TestMethod]
public void GetPageCountStreamLeaveOpenFalse()
{
using var inputStream = GetInputStream(Path.Combine("Assets", "SocialPreview.pdf"));
using var inputStream = GetInputStream(Path.Combine("..", "Assets", "SocialPreview.pdf"));
Assert.IsTrue(inputStream.CanRead);

GetPageCount(inputStream, false);
Expand All @@ -306,7 +306,7 @@ public void GetPageCountStreamLeaveOpenFalse()
[TestMethod]
public void GetPageCountStreamLeaveOpenTrue()
{
using var inputStream = GetInputStream(Path.Combine("Assets", "SocialPreview.pdf"));
using var inputStream = GetInputStream(Path.Combine("..", "Assets", "SocialPreview.pdf"));
Assert.IsTrue(inputStream.CanRead);

GetPageCount(inputStream, true);
Expand All @@ -316,7 +316,7 @@ public void GetPageCountStreamLeaveOpenTrue()
[TestMethod]
public void GetPageSizeStreamLeaveOpenDefault()
{
using var inputStream = GetInputStream(Path.Combine("Assets", "SocialPreview.pdf"));
using var inputStream = GetInputStream(Path.Combine("..", "Assets", "SocialPreview.pdf"));
Assert.IsTrue(inputStream.CanRead);

GetPageSize(inputStream, page: 0);
Expand All @@ -326,7 +326,7 @@ public void GetPageSizeStreamLeaveOpenDefault()
[TestMethod]
public void GetPageSizeStreamLeaveOpenFalse()
{
using var inputStream = GetInputStream(Path.Combine("Assets", "SocialPreview.pdf"));
using var inputStream = GetInputStream(Path.Combine("..", "Assets", "SocialPreview.pdf"));
Assert.IsTrue(inputStream.CanRead);

GetPageSize(inputStream, false, 0);
Expand All @@ -336,7 +336,7 @@ public void GetPageSizeStreamLeaveOpenFalse()
[TestMethod]
public void GetPageSizeStreamLeaveOpenTrue()
{
using var inputStream = GetInputStream(Path.Combine("Assets", "SocialPreview.pdf"));
using var inputStream = GetInputStream(Path.Combine("..", "Assets", "SocialPreview.pdf"));
Assert.IsTrue(inputStream.CanRead);

GetPageSize(inputStream, true, 0);
Expand All @@ -346,7 +346,7 @@ public void GetPageSizeStreamLeaveOpenTrue()
[TestMethod]
public void GetPageSizesStreamLeaveOpenDefault()
{
using var inputStream = GetInputStream(Path.Combine("Assets", "SocialPreview.pdf"));
using var inputStream = GetInputStream(Path.Combine("..", "Assets", "SocialPreview.pdf"));
Assert.IsTrue(inputStream.CanRead);

GetPageSizes(inputStream);
Expand All @@ -356,7 +356,7 @@ public void GetPageSizesStreamLeaveOpenDefault()
[TestMethod]
public void GetPageSizesStreamLeaveOpenFalse()
{
using var inputStream = GetInputStream(Path.Combine("Assets", "SocialPreview.pdf"));
using var inputStream = GetInputStream(Path.Combine("..", "Assets", "SocialPreview.pdf"));
Assert.IsTrue(inputStream.CanRead);

GetPageSizes(inputStream, false);
Expand All @@ -366,7 +366,7 @@ public void GetPageSizesStreamLeaveOpenFalse()
[TestMethod]
public void GetPageSizesStreamLeaveOpenTrue()
{
using var inputStream = GetInputStream(Path.Combine("Assets", "SocialPreview.pdf"));
using var inputStream = GetInputStream(Path.Combine("..", "Assets", "SocialPreview.pdf"));
Assert.IsTrue(inputStream.CanRead);

GetPageSizes(inputStream, true);
Expand All @@ -376,7 +376,7 @@ public void GetPageSizesStreamLeaveOpenTrue()
[TestMethod]
public void StreamMultipleCallsLeaveOpen()
{
using var inputStream = GetInputStream(Path.Combine("Assets", "SocialPreview.pdf"));
using var inputStream = GetInputStream(Path.Combine("..", "Assets", "SocialPreview.pdf"));
Assert.IsTrue(inputStream.CanRead);

GetPageCount(inputStream, true);
Expand Down
20 changes: 10 additions & 10 deletions src/Tests/AspectRatioTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,9 @@ public class AspectRatioTests : TestBase
[DataRow("Wikimedia_Commons_web.pdf", 2000, 2000, 1200)]
public void WithoutAspectRatio(string fileName, int? width = null, int? height = null, int? dpi = null)
{
var expectedPath = Path.Combine("Assets", "Expected", GetPlatformAsString(), "AspectRatio", GetExpectedFilename(fileName, "jpg", width, height, dpi, false));
var expectedPath = Path.Combine("..", "Assets", "Expected", GetPlatformAsString(), "AspectRatio", GetExpectedFilename(fileName, "jpg", width, height, dpi, false));

using var inputStream = GetInputStream(Path.Combine("Assets", fileName));
using var inputStream = GetInputStream(Path.Combine("..", "Assets", fileName));
using var outputStream = CreateOutputStream(expectedPath);

if (dpi != null)
Expand Down Expand Up @@ -272,9 +272,9 @@ public void WithoutAspectRatio(string fileName, int? width = null, int? height =
[DataRow("Wikimedia_Commons_web.pdf", 2000, 2000, 1200)]
public void WithAspectRatio(string fileName, int? width = null, int? height = null, int? dpi = null)
{
var expectedPath = Path.Combine("Assets", "Expected", GetPlatformAsString(), "AspectRatio", GetExpectedFilename(fileName, "jpg", width, height, dpi, true));
var expectedPath = Path.Combine("..", "Assets", "Expected", GetPlatformAsString(), "AspectRatio", GetExpectedFilename(fileName, "jpg", width, height, dpi, true));

using var inputStream = GetInputStream(Path.Combine("Assets", fileName));
using var inputStream = GetInputStream(Path.Combine("..", "Assets", fileName));
using var outputStream = CreateOutputStream(expectedPath);

if (dpi != null)
Expand Down Expand Up @@ -344,9 +344,9 @@ public void WithAspectRatio(string fileName, int? width = null, int? height = nu
[DataRow("Wikimedia_Commons_web.pdf", 2000, 2000, true)]
public void IgnoreDpi(string fileName, int? width = null, int? height = null, bool withAspectRatio = false)
{
var expectedPath = Path.Combine("Assets", "Expected", GetPlatformAsString(), "AspectRatio", GetExpectedFilename(fileName, "jpg", width, height, 300, withAspectRatio));
var expectedPath = Path.Combine("..", "Assets", "Expected", GetPlatformAsString(), "AspectRatio", GetExpectedFilename(fileName, "jpg", width, height, 300, withAspectRatio));

using var inputStream = GetInputStream(Path.Combine("Assets", fileName));
using var inputStream = GetInputStream(Path.Combine("..", "Assets", fileName));

for (int i = 72; i < 600; i += 100)
{
Expand All @@ -369,9 +369,9 @@ public void IgnoreDpi(string fileName, int? width = null, int? height = null, bo
[DataRow("Wikimedia_Commons_web.pdf", 2000, 2000)]
public void IgnoreAspectRatio(string fileName, int width, int height)
{
var expectedPath = Path.Combine("Assets", "Expected", GetPlatformAsString(), "AspectRatio", GetExpectedFilename(fileName, "jpg", width, height, 300, true));
var expectedPath = Path.Combine("..", "Assets", "Expected", GetPlatformAsString(), "AspectRatio", GetExpectedFilename(fileName, "jpg", width, height, 300, true));

using var inputStream = GetInputStream(Path.Combine("Assets", fileName));
using var inputStream = GetInputStream(Path.Combine("..", "Assets", fileName));
using var outputStream1 = CreateOutputStream(expectedPath);
using var outputStream2 = CreateOutputStream(expectedPath);

Expand All @@ -394,9 +394,9 @@ public void IgnoreAspectRatio(string fileName, int width, int height)
[DataRow("Wikimedia_Commons_web.pdf", 600)]
public void IgnoreAspectRatioWithDpi(string fileName, int dpi)
{
var expectedPath = Path.Combine("Assets", "Expected", GetPlatformAsString(), "AspectRatio", GetExpectedFilename(fileName, "jpg", null, null, dpi, true));
var expectedPath = Path.Combine("..", "Assets", "Expected", GetPlatformAsString(), "AspectRatio", GetExpectedFilename(fileName, "jpg", null, null, dpi, true));

using var inputStream = GetInputStream(Path.Combine("Assets", fileName));
using var inputStream = GetInputStream(Path.Combine("..", "Assets", fileName));
using var outputStream1 = CreateOutputStream(expectedPath);
using var outputStream2 = CreateOutputStream(expectedPath);

Expand Down
12 changes: 6 additions & 6 deletions src/Tests/BackgroundColorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ public void Initialize()
[DataRow((uint)0x00FFFFFF, DisplayName = "Transparent")]
public void SaveJpegWithBackgroundColor(uint? backgroundColor)
{
var expectedPath = Path.Combine("Assets", "Expected", GetPlatformAsString(), "BackgroundColor", $"hundesteuer-anmeldung_{GetFileName(backgroundColor ?? SKColors.White)}.jpg");
var expectedPath = Path.Combine("..", "Assets", "Expected", GetPlatformAsString(), "BackgroundColor", $"hundesteuer-anmeldung_{GetFileName(backgroundColor ?? SKColors.White)}.jpg");

using var inputStream = GetInputStream(Path.Combine("Assets", "hundesteuer-anmeldung.pdf"));
using var inputStream = GetInputStream(Path.Combine("..", "Assets", "hundesteuer-anmeldung.pdf"));
using var outputStream = CreateOutputStream(expectedPath);

if (backgroundColor == null)
Expand Down Expand Up @@ -74,9 +74,9 @@ public void SaveJpegWithBackgroundColor(uint? backgroundColor)
[DataRow((uint)0x00FFFFFF, DisplayName = "Transparent")]
public void SavePngWithBackgroundColor(uint? backgroundColor)
{
var expectedPath = Path.Combine("Assets", "Expected", GetPlatformAsString(), "BackgroundColor", $"hundesteuer-anmeldung_{GetFileName(backgroundColor ?? SKColors.White)}.png");
var expectedPath = Path.Combine("..", "Assets", "Expected", GetPlatformAsString(), "BackgroundColor", $"hundesteuer-anmeldung_{GetFileName(backgroundColor ?? SKColors.White)}.png");

using var inputStream = GetInputStream(Path.Combine("Assets", "hundesteuer-anmeldung.pdf"));
using var inputStream = GetInputStream(Path.Combine("..", "Assets", "hundesteuer-anmeldung.pdf"));
using var outputStream = CreateOutputStream(expectedPath);

if (backgroundColor == null)
Expand Down Expand Up @@ -108,9 +108,9 @@ public void SavePngWithBackgroundColor(uint? backgroundColor)
[DataRow((uint)0x00FFFFFF, DisplayName = "Transparent")]
public void SaveWebpWithBackgroundColor(uint? backgroundColor)
{
var expectedPath = Path.Combine("Assets", "Expected", GetPlatformAsString(), "BackgroundColor", $"hundesteuer-anmeldung_{GetFileName(backgroundColor ?? SKColors.White)}.webp");
var expectedPath = Path.Combine("..", "Assets", "Expected", GetPlatformAsString(), "BackgroundColor", $"hundesteuer-anmeldung_{GetFileName(backgroundColor ?? SKColors.White)}.webp");

using var inputStream = GetInputStream(Path.Combine("Assets", "hundesteuer-anmeldung.pdf"));
using var inputStream = GetInputStream(Path.Combine("..", "Assets", "hundesteuer-anmeldung.pdf"));
using var outputStream = CreateOutputStream(expectedPath);

if (backgroundColor == null)
Expand Down
Loading

0 comments on commit 82b135a

Please sign in to comment.