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
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Shell scripts must keep LF line endings, also when checked out on Windows (CI runs them with Git Bash).
*.sh text eol=lf
27 changes: 27 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,30 @@ jobs:

- name: Run tests
run: docker run --rm rotativa-tests

test-windows:
name: Tests against ${{ matrix.source }} (Windows)
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
source: [project, package]
env:
# Plain HTTP avoids trusting the dev HTTPS certificate on the runner. CI=true makes Chrome run headless.
ROTATIVA_DEMO_URL: http://localhost:5000
UseRotativaPackage: ${{ matrix.source == 'package' }}
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v7

- uses: actions/setup-dotnet@v6
with:
dotnet-version: 10.0.x

- name: Build
run: bash Rotativa.AspNetCore.Tests/build-demo.sh

- name: Run tests
run: bash Rotativa.AspNetCore.Tests/run-tests.sh
12 changes: 1 addition & 11 deletions Rotativa.AspNetCore.Tests/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,7 @@ ENV DOTNET_NOLOGO=1 \
WORKDIR /src
COPY . .

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 \
RUN bash Rotativa.AspNetCore.Tests/build-demo.sh \
&& 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
22 changes: 22 additions & 0 deletions Rotativa.AspNetCore.Tests/build-demo.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash
# Builds the demo app and the test project. Run from the repository root.
# With UseRotativaPackage=true, packs the library and builds the demo app against the .nupkg instead of the project.
set -euo pipefail

if [ "${UseRotativaPackage:-false}" = "true" ]; then
dotnet pack Rotativa.AspNetCore -c Release -o artifacts/packages -p:GeneratePackageOnBuild=false
version=$(dotnet msbuild Rotativa.AspNetCore/Rotativa.AspNetCore.csproj -getProperty:Version | tr -d '\r')
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"

# Make sure the demo app really uses the package, not the project.
deps=Rotativa.AspNetCore.DemoApp/bin/Debug/net10.0/Rotativa.AspNetCore.DemoApp.deps.json
if ! grep -A1 "\"Rotativa.AspNetCore/$version\": {" "$deps" | grep -q '"type": "package"'; then
echo "The demo app does not reference the Rotativa.AspNetCore $version package." >&2
exit 1
fi
else
dotnet build Rotativa.AspNetCore.DemoApp
fi

dotnet build Rotativa.AspNetCore.Tests
Empty file modified Rotativa.AspNetCore.Tests/run-tests.sh
100644 → 100755
Empty file.
Loading