-
Notifications
You must be signed in to change notification settings - Fork 81
Expand file tree
/
Copy pathtest-nativeless-package-integration.yml
More file actions
173 lines (150 loc) · 6.98 KB
/
test-nativeless-package-integration.yml
File metadata and controls
173 lines (150 loc) · 6.98 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
name: Test nativeless package integration
run-name: TestNativelessPackageIntegration_${{ github.ref_name }}_${{ vars.LIBRARY_VERSION }}_${{ github.run_number }}
on:
workflow_dispatch:
push:
branches:
- master
- develop
- nativeless-pack-integ
paths:
- 'DryWetMidi/**'
- '.github/workflows/test-nativeless-package-integration.yml'
- '.github/workflows/build-native-libs.yml'
- '.github/workflows/build-package.yml'
- '.github/actions/**'
- 'Resources/PackageIntegrationTestUtilities/DwmNativelessNetConsoleApp/**'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build-package:
name: Build NuGet Package
uses: ./.github/workflows/build-package.yml
secrets: inherit
with:
package-type: 'Nativeless'
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: 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.Nativeless.${{ vars.LIBRARY_VERSION }} package reference to the project..."
$path = Resolve-Path 'Resources/PackageIntegrationTestUtilities/DwmNativelessNetConsoleApp/DwmNativelessNetConsoleApp/DwmNativelessNetConsoleApp.csproj'
dotnet add "$path" package Melanchall.DryWetMidi.Nativeless -v ${{ vars.LIBRARY_VERSION }} -s "${{ github.workspace }}/NuGetPackage"
- name: Check csproj package reference
shell: pwsh
run: |
$path = "Resources/PackageIntegrationTestUtilities/DwmNativelessNetConsoleApp/DwmNativelessNetConsoleApp/DwmNativelessNetConsoleApp.csproj"
$expected = '<PackageReference Include="Melanchall.DryWetMidi.Nativeless" 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: Run app via dotnet
shell: pwsh
run: |
$path = Resolve-Path 'Resources/PackageIntegrationTestUtilities/DwmNativelessNetConsoleApp/DwmNativelessNetConsoleApp/DwmNativelessNetConsoleApp.csproj'
dotnet run --project "$path" --configuration ${{ vars.BUILD_CONFIGURATION }}
- name: Run app after publish
shell: pwsh
run: |
$projectPath = "Resources/PackageIntegrationTestUtilities/DwmNativelessNetConsoleApp/DwmNativelessNetConsoleApp/DwmNativelessNetConsoleApp.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 ""
$dllFile = Join-Path "$outputPath" "Melanchall_DryWetMidi_Native.dll"
$dylibFile = Join-Path "$outputPath" "Melanchall_DryWetMidi_Native.dylib"
if ((Test-Path $dllFile) -or (Test-Path $dylibFile)) {
Write-Output "Some native binaries exist."
exit 1
} else {
Write-Output "There are no native binaries and that's OK.'"
Write-Host ""
}
Write-Host "Running the app..."
Write-Host ""
if ($IsWindows) {
& "$outputPath/DwmNativelessNetConsoleApp.exe"
} else {
& "$outputPath/DwmNativelessNetConsoleApp"
}
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 ""
}
}
}
}
}