-
Notifications
You must be signed in to change notification settings - Fork 81
178 lines (154 loc) · 6.77 KB
/
test-package-integration.yml
File metadata and controls
178 lines (154 loc) · 6.77 KB
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
name: Test package integration
run-name: TestPackageIntegration_${{ github.ref_name }}_${{ vars.LIBRARY_VERSION }}_${{ github.run_number }}
on:
workflow_dispatch:
push:
branches:
- master
- develop
paths:
- 'DryWetMidi/**'
- '.github/workflows/test-package-integration.yml'
- '.github/workflows/build-native-libs.yml'
- '.github/workflows/build-package.yml'
- '.github/actions/**'
- 'Resources/PackageIntegrationTestUtilities/DwmNetConsoleApp/**'
- 'Resources/Native/**'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build-native-libs:
name: Build Native Libraries
uses: ./.github/workflows/build-native-libs.yml
build-package:
name: Build NuGet Package
needs: build-native-libs
uses: ./.github/workflows/build-package.yml
secrets: inherit
test-package-integration:
name: Test package integration (${{ matrix.os }})
needs: build-package
runs-on: ${{ matrix.os }}
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
include:
#- os: windows-11-arm
# framework: Net
# rid: win-arm64
- os: macos-latest
framework: Net
rid: osx-arm64
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download NuGet package
uses: actions/download-artifact@v4
with:
name: NuGetPackage
path: ${{ github.workspace }}/NuGetPackage
- name: Setup framework
id: framework
uses: ./.github/actions/setup-framework
with:
framework: ${{ matrix.framework }}
net-tfm: ${{ vars.BUILD_FRAMEWORK_NET_TFM || 'net8.0' }}
net-sdk-version: ${{ vars.BUILD_FRAMEWORK_NET_SDK_VERSION || '8.0.x' }}
netframework-tfm: ${{ vars.BUILD_FRAMEWORK_NETFRAMEWORK_TFM || 'net48' }}
netframework-sdk-version: ${{ vars.BUILD_FRAMEWORK_NETFRAMEWORK_SDK_VERSION || '8.0.x' }}
- name: Add package to the project
shell: pwsh
run: |
Write-Host "Adding local NuGet source with the package..."
dotnet nuget add source "${{ github.workspace }}/NuGetPackage"
Write-Host "Adding Melanchall.DryWetMidi.${{ vars.LIBRARY_VERSION }} package reference to the project..."
$path = Resolve-Path 'Resources\PackageIntegrationTestUtilities\DwmNetConsoleApp\DwmNetConsoleApp\DwmNetConsoleApp.csproj'
dotnet add "$path" package Melanchall.DryWetMidi -v ${{ vars.LIBRARY_VERSION }} -s "${{ github.workspace }}/NuGetPackage"
- name: Check csproj package reference
shell: pwsh
run: |
$path = Resolve-Path "Resources\PackageIntegrationTestUtilities\DwmNetConsoleApp\DwmNetConsoleApp\DwmNetConsoleApp.csproj"
$expected = '<PackageReference Include="Melanchall.DryWetMidi" Version="${{ vars.LIBRARY_VERSION }}" />'
Write-Host "Expecting: $expected"
$found = Select-String -Path $path -Pattern $expected -SimpleMatch -Quiet
if (-not $found) {
Write-Error "Package reference not found: $expected"
exit 1
}
Write-Host "Package reference found."
- name: Create MIDI ports (Windows)
if: runner.os == 'Windows'
uses: ./.github/actions/create-ports-windows
with:
enabled: 'true'
ports-names: 'MIDI A,MIDI B,MIDI C'
- name: Create MIDI ports (macOS)
if: runner.os == 'macOS'
uses: ./.github/actions/create-ports-macos
with:
enabled: 'true'
- name: Run app via dotnet
shell: pwsh
run: |
$path = Resolve-Path 'Resources/PackageIntegrationTestUtilities/DwmNetConsoleApp/DwmNetConsoleApp/DwmNetConsoleApp.csproj'
dotnet run --project "$path" --configuration ${{ vars.BUILD_CONFIGURATION }}
- name: Run app after publish
shell: pwsh
run: |
$projectPath = "Resources/PackageIntegrationTestUtilities/DwmNetConsoleApp/DwmNetConsoleApp/DwmNetConsoleApp.csproj"
foreach ($psf in @('true', 'false')) {
foreach ($prtr in @('true', 'false')) {
foreach ($inlfse in @('true', 'false')) {
foreach ($sc in @('true', 'false')) {
foreach ($pt in @('true', 'false')) {
$publishOptions = @"
SelfContained = $sc
PublishSingleFile = $psf
PublishReadyToRun = $prtr
IncludeNativeLibrariesForSelfExtract = $inlfse
PublishTrimmed = $pt
"@
Write-Host "$publishOptions"
$outputPath = "${{ runner.temp }}/publish/$rid/sc-$sc-psf-$psf-prtr-$prtr-inlfse-$inlfse-pt-$pt"
Write-Host "Output path set to '$outputPath'"
Write-Host "Publishing the app..."
dotnet publish `
--configuration ${{ vars.BUILD_CONFIGURATION }} `
--runtime ${{ matrix.rid }} `
--self-contained=$sc `
-p:PublishSingleFile=$psf `
-p:PublishReadyToRun=$prtr `
-p:IncludeNativeLibrariesForSelfExtract=$inlfse `
-p:PublishTrimmed=$pt `
-p:SolutionDir="${{ github.workspace }}/" `
--output $outputPath `
$projectPath
if ($LASTEXITCODE -ne 0) {
Write-Error "Publish failed with exit code $LASTEXITCODE"
exit $LASTEXITCODE
}
Write-Host "Listing published files..."
Write-Host ""
Get-ChildItem -Recurse -Force -Path "$outputPath" | Format-Table @{Label="File Name"; Expression={$_.Name}}, @{Label="Size (KB)"; Expression={"{0:N2}" -f ($_.Length / 1KB)}}
Write-Host ""
Write-Host "Running the app..."
Write-Host ""
if ($IsWindows) {
& "$outputPath/DwmNetConsoleApp.exe"
} else {
& "$outputPath/DwmNetConsoleApp"
}
if ($LASTEXITCODE -ne 0) {
Write-Error "App execution failed with exit code $LASTEXITCODE"
exit $LASTEXITCODE
}
Write-Host ""
Write-Host "Configuration test completed successfully"
Write-Host ""
}
}
}
}
}