Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
on:
push:
branches:
- "main"
pull_request:
branches:
- "main"

env:
TEST_TAG: corefiling/pdf2html:test

jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
lfs: true
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build and export to Docker
uses: docker/build-push-action@v4
with:
context: ./src/Pdf2Html
load: true
tags: ${{ env.TEST_TAG }}
- name: Set up dotnet
uses: actions/setup-dotnet@v3
with:
dotnet-version: "7.x"
- name: E2E tests
run: |
docker run --rm --detach -p 8080:8080 --name pdf2html ${{ env.TEST_TAG }}
dotnet test --filter "FullyQualifiedName=E2E.Tests"
docker stop pdf2html
1 change: 0 additions & 1 deletion src/Pdf2Html/Controllers/RootController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ public RootController(ILogger<RootController> logger)
_logger = logger;
}


[HttpGet]
public ActionResult Get()
{
Expand Down
2 changes: 1 addition & 1 deletion src/Pdf2Html/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ WORKDIR /app
COPY --from=build /app ./
ENV ASPNETCORE_URLS=http://+:8080
EXPOSE 8080
CMD ["./pdf2html"]
CMD ["./Pdf2Html"]
4 changes: 2 additions & 2 deletions src/Pdf2Html/Pdf2Html.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<Version>1.0.0</Version>
<AssemblyName>Pdf2html</AssemblyName>
<RootNamespace>Pdf2html</RootNamespace>
<AssemblyName>Pdf2Html</AssemblyName>
<RootNamespace>Pdf2Html</RootNamespace>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
using System.Net;
using System.Text.RegularExpressions;

namespace E2E.Tests;

public class ConvertPdfTest
public partial class ConvertPdfTest
{
[GeneratedRegex("^@font-face{.*$", RegexOptions.Multiline)]
private static partial Regex FontFaceRegex();

private HttpClient _client = null!;

[SetUp]
Expand Down Expand Up @@ -32,8 +36,14 @@ public async Task TestConvertPdf()
var response = await _client.PostAsync("/", new StreamContent(GetResourceStream("CS_cheat_sheet.pdf")));
Assert.Multiple(async () =>
{
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK));
Assert.That(await response.Content.ReadAsStreamAsync(), Is.EqualTo(GetResourceStream("CS_cheat_sheet.html")));
var responseStream = await response.Content.ReadAsStreamAsync();
var content = await new StreamReader(responseStream).ReadToEndAsync();
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK),
() => $"Conversion failed: {content}");
var expected = await new StreamReader(GetResourceStream("CS_cheat_sheet.html")).ReadToEndAsync();

string RemoveFonts(string input) => FontFaceRegex().Replace(input, "");
Assert.That(RemoveFonts(content), Is.EqualTo(RemoveFonts(expected)));
});
}

Expand Down