-
Notifications
You must be signed in to change notification settings - Fork 0
executable file
·66 lines (54 loc) · 1.81 KB
/
UnitTests.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
name: Unit Tests
on:
push:
branches: [ "Future" ]
pull_request:
branches: [ "Future" ]
workflow_dispatch: # Allows the workflow to be triggered manually
jobs:
run-tests:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
configuration: [Debug, Release]
env:
# Define the path to project and test project
PROJECT_PATH: PrettyConsole/PrettyConsole.csproj
TEST_PROJECT_PATH: PrettyConsole.Tests.Unit/PrettyConsole.Tests.Unit.csproj
steps:
# 1. Checkout the repository code
- name: Checkout Repository
uses: actions/checkout@v4
# 2. Cache NuGet packages
- name: Cache NuGet Packages
uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
restore-keys: |
${{ runner.os }}-nuget-
# 3. Setup .NET
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
# 4. Clean
- name: Clean
run: |
dotnet clean ${{ env.PROJECT_PATH }} -c ${{ matrix.configuration }}
dotnet clean ${{ env.TEST_PROJECT_PATH }} -c ${{ matrix.configuration }}
# 5. Restore dependencies
- name: Restore Dependencies
run: |
dotnet restore ${{ env.PROJECT_PATH }}
dotnet restore ${{ env.TEST_PROJECT_PATH }}
# 6. Build
- name: Build
run: |
dotnet build ${{ env.PROJECT_PATH }} -c ${{ matrix.configuration }}
dotnet build ${{ env.TEST_PROJECT_PATH }} -c ${{ matrix.configuration }}
# 7. Run Unit Tests
- name: Run Unit Tests
run: dotnet test ${{ env.TEST_PROJECT_PATH }} -c ${{ matrix.configuration }}