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
12 changes: 10 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,21 @@ jobs:
run: dotnet build Rotativa.AspNetCore/Rotativa.AspNetCore.csproj -c Release

test:
name: Unit and integration tests (Linux)
name: Tests against ${{ matrix.source }} (Linux)
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
# project: demo app references the library project.
# package: demo app references the packed .nupkg, to test the package itself.
source: [project, package]
steps:
- uses: actions/checkout@v7

- name: Build test image
run: docker build -f Rotativa.AspNetCore.Tests/Dockerfile -t rotativa-tests .
run: >
docker build -f Rotativa.AspNetCore.Tests/Dockerfile -t rotativa-tests
--build-arg USE_ROTATIVA_PACKAGE=${{ matrix.source == 'package' }} .

- name: Run tests
run: docker run --rm rotativa-tests
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,10 @@ docker build -f Rotativa.AspNetCore.Tests/Dockerfile -t rotativa-tests .
docker run --rm rotativa-tests
```

Add `--build-arg USE_ROTATIVA_PACKAGE=true` to the build to pack the library and run the demo app against the `.nupkg` instead of the project, which tests the NuGet package itself.

Packing the library also runs [package validation](https://learn.microsoft.com/dotnet/fundamentals/package-validation/overview): it fails on API differences between target frameworks and on breaking changes since the last published version (`PackageValidationBaselineVersion`). Intentional differences are listed in `Rotativa.AspNetCore/CompatibilitySuppressions.xml`. After publishing a release, update the baseline version to it.


## rotativa.io

Expand Down
12 changes: 11 additions & 1 deletion Rotativa.AspNetCore.DemoApp/Rotativa.AspNetCore.DemoApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,18 @@
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<ItemGroup Condition=" '$(UseRotativaPackage)' != 'true' ">
<ProjectReference Include="..\Rotativa.AspNetCore\Rotativa.AspNetCore.csproj" />
</ItemGroup>

<!-- Build against the packed .nupkg instead of the project, to test the package itself.
Restore with Rotativa.AspNetCore.Tests/package-test.nuget.config and pass RotativaPackageVersion. -->
<ItemGroup Condition=" '$(UseRotativaPackage)' == 'true' ">
<PackageReference Include="Rotativa.AspNetCore" Version="$(RotativaPackageVersion)" />
</ItemGroup>

<Target Name="CheckRotativaPackageVersion" BeforeTargets="CollectPackageReferences" Condition=" '$(UseRotativaPackage)' == 'true' AND '$(RotativaPackageVersion)' == '' ">
<Error Text="Set RotativaPackageVersion when UseRotativaPackage is true." />
</Target>

</Project>
19 changes: 16 additions & 3 deletions Rotativa.AspNetCore.Tests/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Runs the full test suite (unit + integration) on Linux.
# Build from the repository root:
# Build from the repository root (add --build-arg USE_ROTATIVA_PACKAGE=true to test the packed .nupkg):
# docker build -f Rotativa.AspNetCore.Tests/Dockerfile -t rotativa-tests .
# docker run --rm rotativa-tests
FROM debian:bookworm-slim
Expand All @@ -19,16 +19,29 @@ RUN curl -fsSL https://dot.net/v1/dotnet-install.sh -o /tmp/dotnet-install.sh \
&& ln -s /usr/share/dotnet/dotnet /usr/local/bin/dotnet \
&& rm /tmp/dotnet-install.sh

# true: pack the library and run the demo app against the .nupkg instead of the project.
ARG USE_ROTATIVA_PACKAGE=false

ENV DOTNET_NOLOGO=1 \
DOTNET_CLI_TELEMETRY_OPTOUT=1 \
CI=true \
ROTATIVA_DEMO_URL=http://localhost:5000 \
ROTATIVA_CHROME_BINARY=/usr/bin/chromium
ROTATIVA_CHROME_BINARY=/usr/bin/chromium \
UseRotativaPackage=${USE_ROTATIVA_PACKAGE}

WORKDIR /src
COPY . .

RUN dotnet build Rotativa.AspNetCore.DemoApp \
RUN if [ "$UseRotativaPackage" = "true" ]; then \
dotnet pack Rotativa.AspNetCore -c Release -o artifacts/packages -p:GeneratePackageOnBuild=false \
&& version=$(dotnet msbuild Rotativa.AspNetCore/Rotativa.AspNetCore.csproj -getProperty:Version) \
&& dotnet restore Rotativa.AspNetCore.DemoApp --configfile Rotativa.AspNetCore.Tests/package-test.nuget.config -p:RotativaPackageVersion=$version \
&& dotnet build Rotativa.AspNetCore.DemoApp --no-restore -p:RotativaPackageVersion=$version \
&& grep -A1 "\"Rotativa.AspNetCore/$version\": {" Rotativa.AspNetCore.DemoApp/bin/Debug/net10.0/Rotativa.AspNetCore.DemoApp.deps.json \
| grep -q '"type": "package"' ; \
else \
dotnet build Rotativa.AspNetCore.DemoApp ; \
fi \
&& dotnet build Rotativa.AspNetCore.Tests \
&& ln -sf /usr/local/bin/wkhtmltopdf Rotativa.AspNetCore.DemoApp/wwwroot/Rotativa/wkhtmltopdf \
&& ln -sf /usr/local/bin/wkhtmltoimage Rotativa.AspNetCore.DemoApp/wwwroot/Rotativa/wkhtmltoimage
Expand Down
1 change: 1 addition & 0 deletions Rotativa.AspNetCore.Tests/Dockerfile.dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
.git
**/wwwroot/Rotativa/wkhtmltopdf
**/wwwroot/Rotativa/wkhtmltoimage
artifacts
18 changes: 18 additions & 0 deletions Rotativa.AspNetCore.Tests/package-test.nuget.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Used to restore the DemoApp against a locally packed Rotativa.AspNetCore (see run-tests.sh / Dockerfile).
Rotativa.AspNetCore comes only from artifacts/packages; everything else from nuget.org. -->
<configuration>
<packageSources>
<clear />
<add key="local" value="../artifacts/packages" />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
</packageSources>
<packageSourceMapping>
<packageSource key="local">
<package pattern="Rotativa.AspNetCore" />
</packageSource>
<packageSource key="nuget.org">
<package pattern="*" />
</packageSource>
</packageSourceMapping>
</configuration>
16 changes: 16 additions & 0 deletions Rotativa.AspNetCore/CompatibilitySuppressions.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- https://learn.microsoft.com/dotnet/fundamentals/package-validation/diagnostic-ids -->
<Suppressions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:Rotativa.AspNetCore.RotativaAppBuilderExtensions</Target>
<Left>lib/net5.0/Rotativa.AspNetCore.dll</Left>
<Right>lib/net6.0/Rotativa.AspNetCore.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Rotativa.AspNetCore.RotativaConfiguration.Setup(Microsoft.AspNetCore.Hosting.IHostingEnvironment,System.String)</Target>
<Left>lib/netstandard2.0/Rotativa.AspNetCore.dll</Left>
<Right>lib/netcoreapp3.1/Rotativa.AspNetCore.dll</Right>
</Suppression>
</Suppressions>
4 changes: 4 additions & 0 deletions Rotativa.AspNetCore/Rotativa.AspNetCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
<Copyright>2026 Viva Software di Bozio Giorgio</Copyright>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageReadmeFile>README.md</PackageReadmeFile>
<!-- Check the package's API across target frameworks and against the last published release.
Intentional differences are listed in CompatibilitySuppressions.xml. -->
<EnablePackageValidation>true</EnablePackageValidation>
<PackageValidationBaselineVersion>1.4.0</PackageValidationBaselineVersion>
</PropertyGroup>

<!--<ItemGroup>
Expand Down
Loading