Skip to content

Commit 4f68c3f

Browse files
committed
Add GitHub action for unit tests
1 parent b8e81c3 commit 4f68c3f

1 file changed

Lines changed: 101 additions & 0 deletions

File tree

.github/workflows/unit-tests.yml

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
name: Unit Tests
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
workflow_dispatch:
9+
10+
env:
11+
DOTNET_NOLOGO: true
12+
DOTNET_CLI_TELEMETRY_OPTOUT: true
13+
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
14+
15+
jobs:
16+
test:
17+
name: ${{ matrix.os }}-${{ matrix.arch }} / ${{ matrix.framework }}
18+
runs-on: ${{ matrix.runner }}
19+
strategy:
20+
fail-fast: false
21+
matrix:
22+
include:
23+
# ---------- Windows x64 ----------
24+
- { runner: windows-latest, os: windows, arch: x64, framework: net462 }
25+
- { runner: windows-latest, os: windows, arch: x64, framework: net6.0 }
26+
- { runner: windows-latest, os: windows, arch: x64, framework: net8.0 }
27+
- { runner: windows-latest, os: windows, arch: x64, framework: net9.0 }
28+
29+
# ---------- Windows ARM64 ----------
30+
# .NET Framework (net462) is not supported on ARM64.
31+
- { runner: windows-11-arm, os: windows, arch: arm64, framework: net6.0 }
32+
- { runner: windows-11-arm, os: windows, arch: arm64, framework: net8.0 }
33+
- { runner: windows-11-arm, os: windows, arch: arm64, framework: net9.0 }
34+
35+
# ---------- Linux x64 ----------
36+
- { runner: ubuntu-latest, os: linux, arch: x64, framework: net6.0 }
37+
- { runner: ubuntu-latest, os: linux, arch: x64, framework: net8.0 }
38+
- { runner: ubuntu-latest, os: linux, arch: x64, framework: net9.0 }
39+
40+
# ---------- Linux ARM64 ----------
41+
- { runner: ubuntu-24.04-arm, os: linux, arch: arm64, framework: net6.0 }
42+
- { runner: ubuntu-24.04-arm, os: linux, arch: arm64, framework: net8.0 }
43+
- { runner: ubuntu-24.04-arm, os: linux, arch: arm64, framework: net9.0 }
44+
45+
# ---------- macOS ARM64 (Apple Silicon) ----------
46+
- { runner: macos-latest, os: macos, arch: arm64, framework: net6.0 }
47+
- { runner: macos-latest, os: macos, arch: arm64, framework: net8.0 }
48+
- { runner: macos-latest, os: macos, arch: arm64, framework: net9.0 }
49+
50+
# ---------- macOS x64 (Intel) ----------
51+
- { runner: macos-13, os: macos, arch: x64, framework: net6.0 }
52+
- { runner: macos-13, os: macos, arch: x64, framework: net8.0 }
53+
- { runner: macos-13, os: macos, arch: x64, framework: net9.0 }
54+
55+
steps:
56+
- name: Checkout
57+
uses: actions/checkout@v4
58+
59+
- name: Setup .NET
60+
uses: actions/setup-dotnet@v4
61+
with:
62+
dotnet-version: |
63+
6.0.x
64+
8.0.x
65+
9.0.x
66+
67+
- name: NuGet cache
68+
uses: actions/cache@v4
69+
with:
70+
path: ~/.nuget/packages
71+
key: nuget-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('**/*.csproj') }}
72+
restore-keys: |
73+
nuget-${{ runner.os }}-${{ runner.arch }}-
74+
75+
- name: Restore
76+
run: dotnet restore UglyToad.PdfPig.Rendering.Skia.Tests/UglyToad.PdfPig.Rendering.Skia.Tests.csproj
77+
78+
- name: Build
79+
run: >
80+
dotnet build UglyToad.PdfPig.Rendering.Skia.Tests/UglyToad.PdfPig.Rendering.Skia.Tests.csproj
81+
--framework ${{ matrix.framework }}
82+
--configuration Release
83+
--no-restore
84+
85+
- name: Test
86+
run: >
87+
dotnet test UglyToad.PdfPig.Rendering.Skia.Tests/UglyToad.PdfPig.Rendering.Skia.Tests.csproj
88+
--framework ${{ matrix.framework }}
89+
--configuration Release
90+
--no-build
91+
--logger "trx;LogFileName=test-results.trx"
92+
--logger "console;verbosity=normal"
93+
--results-directory ./TestResults
94+
95+
- name: Upload test results
96+
if: always()
97+
uses: actions/upload-artifact@v4
98+
with:
99+
name: test-results-${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.framework }}
100+
path: ./TestResults/**/*.trx
101+
if-no-files-found: ignore

0 commit comments

Comments
 (0)