forked from npgsql/npgsql
-
Notifications
You must be signed in to change notification settings - Fork 0
201 lines (166 loc) · 6.59 KB
/
native-aot.yml
File metadata and controls
201 lines (166 loc) · 6.59 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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
name: NativeAOT
on:
push:
branches:
- main
- 'hotfix/**'
tags:
- '*'
pull_request:
# Cancel previous PR branch commits (head_ref is only defined on PRs)
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
env:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
AOT_Compat: |
param([string]$targetFramework)
$publishOutput = dotnet publish test/Npgsql.NativeAotTests/Npgsql.NativeAotTests.csproj -r linux-x64 -c Release -f $targetFramework -p:RootNpgsql=true
$actualWarningCount = 0
foreach ($line in $($publishOutput -split "`r`n"))
{
if ($line -like "*analysis warning IL*")
{
Write-Host $line
$actualWarningCount += 1
}
}
$testPassed = 0
$binaryPath = "test/Npgsql.NativeAotTests/bin/Release/$targetFramework/linux-x64/native/"
if (-not (Test-Path -LiteralPath $binaryPath))
{
$testPassed = 1
Write-Host "Could not publish app, output was:"
foreach ($line in $($publishOutput -split "`r`n"))
{
Write-Host $line
}
}
Write-Host "Actual warning count is:", $actualWarningCount
$expectedWarningCount = 0
if ($actualWarningCount -ne $expectedWarningCount)
{
$testPassed = 2
Write-Host "Actual warning count:", $actualWarningCount, "is not as expected. Expected warning count is:", $expectedWarningCount
}
Exit $testPassed
# Uncomment and edit the following to use nightly/preview builds
# nuget_config: |
# <?xml version="1.0" encoding="utf-8"?>
# <configuration>
#
# <packageSources>
# <add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
# <add key="dotnet8" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet8/nuget/v3/index.json" />
# </packageSources>
#
# <packageSourceMapping>
# <packageSource key="nuget.org">
# <package pattern="*" />
# </packageSource>
# <packageSource key="dotnet8">
# <package pattern="runtime.*" />
# <package pattern="Microsoft.NETCore.App.Runtime.*" />
# <package pattern="Microsoft.AspNetCore.App.Runtime.*" />
# <package pattern="Microsoft.NET.ILLink.Tasks" />
# <package pattern="Microsoft.DotNet.ILCompiler" />
# </packageSource>
# </packageSourceMapping>
#
# </configuration>
jobs:
full:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ ubuntu-24.04 ]
pg_major: [ 15 ]
tfm: [ net9.0 ]
steps:
- name: Checkout
uses: actions/checkout@v4
# - name: Setup nuget config
# run: echo "$nuget_config" > NuGet.config
- name: NuGet Cache
uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/Directory.Build.targets') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Setup .NET Core SDK
uses: actions/setup-dotnet@v4.3.1
- name: Write script
run: echo "$AOT_Compat" > test-aot-compatibility.ps1
- name: Publish and check for trimmer warnings
run: ./test-aot-compatibility.ps1 ${{ matrix.tfm }}
shell: pwsh
trimmed:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-24.04]
pg_major: [15]
tfm: [ net9.0 ]
steps:
- name: Checkout
uses: actions/checkout@v4
# - name: Setup nuget config
# run: echo "$nuget_config" > NuGet.config
- name: NuGet Cache
uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/Directory.Build.targets') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Setup .NET Core SDK
uses: actions/setup-dotnet@v4.3.1
- name: Start PostgreSQL
run: |
sudo systemctl start postgresql.service
sudo -u postgres psql -c "CREATE USER npgsql_tests SUPERUSER PASSWORD 'npgsql_tests'"
sudo -u postgres psql -c "CREATE DATABASE npgsql_tests OWNER npgsql_tests"
- name: Build
run: dotnet publish test/Npgsql.NativeAotTests/Npgsql.NativeAotTests.csproj -r linux-x64 -c Release -f ${{ matrix.tfm }} -p:OptimizationPreference=Size
shell: bash
# Uncomment the following to SSH into the agent running the build (https://github.com/mxschmitt/action-tmate)
#- uses: actions/checkout@v4
#- name: Setup tmate session
# uses: mxschmitt/action-tmate@v3
- name: Run
run: test/Npgsql.NativeAotTests/bin/Release/${{ matrix.tfm }}/linux-x64/native/Npgsql.NativeAotTests
- name: Write binary size to summary
run: |
size="$(ls -l test/Npgsql.NativeAotTests/bin/Release/net9.0/linux-x64/native/Npgsql.NativeAotTests | cut -d ' ' -f 5)"
echo "Binary size is $size bytes ($((size / (1024 * 1024))) mb)" >> $GITHUB_STEP_SUMMARY
- name: Dump mstat
run: dotnet run --project test/MStatDumper/MStatDumper.csproj -c release -f ${{ matrix.tfm }} -- "test/Npgsql.NativeAotTests/obj/Release/net9.0/linux-x64/native/Npgsql.NativeAotTests.mstat" md >> $GITHUB_STEP_SUMMARY
- name: Upload mstat
uses: actions/upload-artifact@v4
with:
name: npgsql.mstat
path: "test/Npgsql.NativeAotTests/obj/Release/${{ matrix.tfm }}/linux-x64/native/Npgsql.NativeAotTests.mstat"
retention-days: 3
- name: Upload codedgen dgml
uses: actions/upload-artifact@v4
with:
name: npgsql.codegen.dgml.xml
path: "test/Npgsql.NativeAotTests/obj/Release/${{ matrix.tfm }}/linux-x64/native/Npgsql.NativeAotTests.codegen.dgml.xml"
retention-days: 3
- name: Upload scan dgml
uses: actions/upload-artifact@v4
with:
name: npgsql.scan.dgml.xml
path: "test/Npgsql.NativeAotTests/obj/Release/${{ matrix.tfm }}/linux-x64/native/Npgsql.NativeAotTests.scan.dgml.xml"
retention-days: 3
- name: Assert binary size
run: |
size="$(ls -l test/Npgsql.NativeAotTests/bin/Release/${{ matrix.tfm }}/linux-x64/native/Npgsql.NativeAotTests | cut -d ' ' -f 5)"
echo "Binary size is $size bytes ($((size / (1024 * 1024))) mb)"
if (( size > 5242880 )); then
echo "Binary size exceeds 5MB threshold"
exit 1
fi