-
Notifications
You must be signed in to change notification settings - Fork 132
156 lines (137 loc) · 5.32 KB
/
reusable-test.yml
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
name: 🔒Reusable Workflow Test
# We build the binaries for all os and configurations
# So we don't have to do that on each test run
on:
workflow_call:
inputs:
image:
required: true
type: string
description: 'The image to use'
architecture:
required: true
type: string
description: 'The architecture to use'
dotnet_target_frameworks:
required: true
type: string
description: 'The target frameworks to use'
build_configuration:
required: true
type: string
description: 'The build configuration to use'
is_experimental:
required: false
type: boolean
default: false
description: 'Whether the tests are mandatory for the build to pass'
skip_experimental:
required: false
type: boolean
default: false
description: 'Whether to skip the experimental tests'
env:
# Disable the .NET logo in the console output.
DOTNET_NOLOGO: true
# Disable the .NET first time experience to skip caching NuGet packages and speed up the build.
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
# Disable sending .NET CLI telemetry to Microsoft.
DOTNET_CLI_TELEMETRY_OPTOUT: true
jobs:
test:
name: Execute Tests
runs-on: ${{inputs.image}}
continue-on-error: ${{inputs.is_experimental}}
timeout-minutes: 10
if: ${{ !inputs.is_experimental || (inputs.is_experimental && !inputs.skip_experimental) }}
steps:
- uses: actions/checkout@v4
- name: Install Rosetta 2 on OS X
if: ${{inputs.image == 'macos-14' && inputs.architecture == 'x64'}}
run: /usr/sbin/softwareupdate --install-rosetta --agree-to-license
# Wine
- name: Setup Wine on Ubuntu
if: ${{runner.os == 'Linux'}}
uses: ./.github/actions/setup-wine-ubuntu
- name: Setup Wine on OS X
if: ${{runner.os == 'macOS'}}
uses: ./.github/actions/setup-wine-macos
- name: Get Installed Wine Information
if: ${{runner.os == 'Linux' || runner.os == 'macOS'}}
run: wine --version
- name: Get Installed Wine Programs Information
if: ${{runner.os == 'Linux' || runner.os == 'macOS'}}
run: wine uninstaller --list
# Wine
# .NET
- name: Setup .NET on Ubuntu and OS X (Intel/Arm)
if: ${{runner.os == 'Linux' || (inputs.image == 'macos-13' || (inputs.image == 'macos-14' && inputs.architecture == 'arm64'))}}
uses: ./.github/actions/setup-dotnet-unix
with:
target_framework: ''
target_framework_array: ${{inputs.dotnet_target_frameworks}}
- name: Setup .NET on OS X (Arm) Rosetta 2
if: ${{inputs.image == 'macos-14' && inputs.architecture == 'x64'}}
uses: ./.github/actions/setup-dotnet-macos-rosetta
with:
target_framework: ''
target_framework_array: ${{inputs.dotnet_target_frameworks}}
- name: Setup .NET on Windows
if: ${{runner.os == 'Windows'}}
uses: ./.github/actions/setup-dotnet-windows
with:
architecture: ${{inputs.architecture}}
target_framework: ''
target_framework_array: ${{inputs.dotnet_target_frameworks}}
- name: Get .NET path for ${{inputs.architecture}}
uses: ./.github/actions/get-dotnet-path
id: get-dotnet-path
with:
architecture: ${{inputs.architecture}}
- name: Get Installed .NET Information for ${{inputs.architecture}}
run: '& "${{steps.get-dotnet-path.outputs.path}}" --info'
shell: pwsh
# .NET
# Mono
- name: Setup Mono on Windows
if: ${{runner.os == 'Windows'}}
uses: ./.github/actions/setup-mono-windows
with:
architecture: ${{inputs.architecture}}
- name: Get Mono path for ${{inputs.architecture}}
uses: ./.github/actions/get-mono-path
id: get-mono-path
with:
architecture: ${{inputs.architecture}}
- name: Get Installed Mono Information
run: '& "${{steps.get-mono-path.outputs.path}}" --version'
shell: pwsh
# Mono
- name: Download Build Cache
uses: ./.github/actions/test-build-cache-download
with:
image: 'windows-2022'
architecture: ${{(inputs.architecture == 'arm64' && 'x64') || inputs.architecture}}
build_configuration: ${{inputs.build_configuration}}
# TODO: Cover Mono on Windows
- name: Test
run: |
$files = Get-ChildItem -Path ./test -Recurse -Filter *.csproj | ? { $_.FullName -inotmatch 'TestBinaries' };
$hasError = $false;
foreach ($file in $files) {
& "${{steps.get-dotnet-path.outputs.path}}" test $file.FullName -c ${{inputs.build_configuration}} -l trx -l 'console;verbosity=normal';
Write-Host "Exit code for $($file.FullName): $exitCode"
$hasError = $hasError -or $LASTEXITCODE -ne 0;
}
if ($hasError) {
throw 'Tests failed';
}
shell: pwsh
- name: Upload Test Results
if: always()
uses: ./.github/actions/test-results-upload
with:
image: ${{inputs.image}}
architecture: ${{inputs.architecture}}
build_configuration: ${{inputs.build_configuration}}
experimental: ${{inputs.is_experimental}}