diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..d91b406 --- /dev/null +++ b/.gitattributes @@ -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 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 97f5bfa..2011bdf 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -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 diff --git a/Rotativa.AspNetCore.Tests/Dockerfile b/Rotativa.AspNetCore.Tests/Dockerfile index 323c309..0edf86b 100644 --- a/Rotativa.AspNetCore.Tests/Dockerfile +++ b/Rotativa.AspNetCore.Tests/Dockerfile @@ -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 diff --git a/Rotativa.AspNetCore.Tests/build-demo.sh b/Rotativa.AspNetCore.Tests/build-demo.sh new file mode 100755 index 0000000..81fa990 --- /dev/null +++ b/Rotativa.AspNetCore.Tests/build-demo.sh @@ -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 diff --git a/Rotativa.AspNetCore.Tests/run-tests.sh b/Rotativa.AspNetCore.Tests/run-tests.sh old mode 100644 new mode 100755