-
Notifications
You must be signed in to change notification settings - Fork 62
384 lines (330 loc) · 17 KB
/
build_profiler.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
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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
name: Build and Package Profiler
on:
# run this workflow on a push to any branch so we can get code coverage reports
#
# NOTE: On a push, only the build jobs will execute; the NuGet jobs will not run.
# Manually run this workflow on your branch when you want it to update the
# NuGet package and create a PR to update the package version reference in
# Home.csproj.
push:
branches:
- main
- "feature/**"
paths-ignore:
- ".github/**" # skip changes to the .github branch (workflows, etc.)
pull_request:
paths-ignore:
- ".github/**" # skip changes to the .github branch (workflows, etc.)
# this workflow can be called from another workflow
workflow_call:
inputs:
deploy:
description: 'Deploy NuGet Package'
required: true
default: false
type: boolean
# this workflow can be invoked manually
workflow_dispatch:
inputs:
deploy:
description: 'Deploy NuGet Package'
required: true
default: false
type: boolean
permissions:
contents: read
# only allow one instance of this workflow to be running per PR or branch, cancels any that are already running
concurrency:
group: build-profiler-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
scripts_path: ${{ github.workspace }}\build\scripts
tools_path: ${{ github.workspace }}\build\Tools
DOTNET_NOLOGO: true
jobs:
build-windows-profiler:
name: Build Windows Profiler & Run Unit Tests / Code Coverage
runs-on: windows-latest
env:
tests_base_path: ${{ github.workspace }}\src\Agent\NewRelic
profiler_solution_path: ${{ github.workspace }}\src\Agent\NewRelic\Profiler\NewRelic.Profiler.sln
output_path: ${{ github.workspace }}\src\Agent\_profilerBuild
test_results_path: ${{ github.workspace }}\src\Agent\NewRelic\TestResults
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@6fb02220983dee41ce7ae257b6f4d8f9bf5ed4ce # v2.0.0
- name: Clean out _profilerBuild directory
run: |
Remove-Item -Path "${{ github.workspace }}\src\Agent\_profilerBuild\*.*" -Force -Recurse -ErrorAction SilentlyContinue
shell: powershell
- name: Build x64
run: |
Write-Host "List NuGet Sources"
dotnet nuget list source # For unknown reasons, this step is necessary to avoid subsequent problems with NuGet package restore
Write-Host "MSBuild.exe -restore -m -p:Platform=x64 -p:Configuration=Release ${{ env.profiler_solution_path }}"
MSBuild.exe -restore -m -p:Platform=x64 -p:Configuration=Release ${{ env.profiler_solution_path }}
shell: powershell
- name: Build x86
run: |
Write-Host "MSBuild.exe -restore -m -p:Platform=Win32 -p:Configuration=Release ${{ env.profiler_solution_path }}"
MSBuild.exe -restore -m -p:Platform=Win32 -p:Configuration=Release ${{ env.profiler_solution_path }}
shell: powershell
- name: Setup VSTest and add to PATH
uses: darenm/Setup-VSTest@3a16d909a1f3bbc65b52f8270d475d905e7d3e44 # 1.3
id: setup_vstest
- name: Setup OpenCppCoverage and add to PATH
id: setup_opencppcoverage
run: |
choco install OpenCppCoverage -y
echo "C:\Program Files\OpenCppCoverage" >> $env:GITHUB_PATH
- name: Generate Report
id: generate_test_report
shell: cmd
run: |
cd ${{ env.tests_base_path }}
OpenCppCoverage.exe --sources Profiler --excluded_sources rapidxml --excluded_sources Profiler\SystemCalls.h --excluded_sources test --modules NewRelic\Profiler --export_type cobertura:${{ env.test_results_path }}\profilerx86.xml -- "vstest.console.exe" /Platform:x86 "Profiler\CommonTest\bin\x86\Release\CommonTest.dll" "Profiler\ConfigurationTest\bin\x86\Release\ConfigurationTest.dll" "Profiler\LoggingTest\bin\x86\Release\LoggingTest.dll" "Profiler\MethodRewriterTest\bin\x86\Release\MethodRewriterTest.dll" "Profiler\SignatureParserTest\bin\x86\Release\SignatureParserTest.dll" "Profiler\Sicily\SicilyTest\bin\x86\Release\SicilyTest.dll"
mv ${{ env.tests_base_path}}\LastCoverageResults.log ${{ env.tests_base_path}}\LastCoverageResults_x86.log
OpenCppCoverage.exe --sources Profiler --cover_children --excluded_sources rapidxml --excluded_sources Profiler\SystemCalls.h --excluded_sources test --modules NewRelic\Profiler --export_type cobertura:${{ env.test_results_path }}\profilerx64.xml -- "vstest.console.exe" /Platform:x64 "Profiler\CommonTest\bin\x64\Release\CommonTest.dll" "Profiler\ConfigurationTest\bin\x64\Release\ConfigurationTest.dll" "Profiler\LoggingTest\bin\x64\Release\LoggingTest.dll" "Profiler\MethodRewriterTest\bin\x64\Release\MethodRewriterTest.dll" "Profiler\SignatureParserTest\bin\x64\Release\SignatureParserTest.dll" "Profiler\Sicily\SicilyTest\bin\x64\Release\SicilyTest.dll"
mv ${{ env.tests_base_path}}\LastCoverageResults.log ${{ env.tests_base_path}}\LastCoverageResults_x64.log
- name: Upload coverage reports to Codecov.io
uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 # v4.6.0
with:
flags: Profiler
files: ${{ env.test_results_path }}/profilerx86.xml,${{ env.test_results_path }}/profilerx64.xml
token: ${{ secrets.CODECOV_TOKEN }}
- name: Archive Build Artifacts
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with:
name: profiler-windows
path: ${{ github.workspace }}\src\Agent\_profilerBuild\**\*
if-no-files-found: error
- name: Archive Code Coverage Artifacts
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with:
name: profiler-code-coverage
path: |
${{ env.test_results_path }}\*.xml
${{ env.tests_base_path }}\*.log
if-no-files-found: error
build-linux-x64-profiler:
name: Build Linux x64 Profiler
runs-on: ubuntu-22.04
permissions:
contents: read
env:
profiler_path: ${{ github.workspace }}/src/Agent/NewRelic/Profiler
CORECLR_NEW_RELIC_HOME: ${{ github.workspace }}/src/Agent/NewRelic/newrelichome_x64_coreclr_linux # not used but required by Profiler/docker-compose.yml
steps:
# intentionally disabled for this job, when enabled it causes a failure in the Build Linux Profiler step
# - name: Harden Runner
# uses: step-security/harden-runner@03bee3930647ebbf994244c21ddbc0d4933aab4f # v2.3.0
# with:
# egress-policy: audit
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
- name: Clean out _profilerBuild directory
run: |
rm -f ${{ github.workspace }}/src/Agent/_profilerBuild/*.* || true
rm -rf ${{ github.workspace }}/src/Agent/_profilerBuild/linux-x64-release || true
rm -rf ${{ github.workspace }}/src/Agent/_profilerBuild/linux-arm64-release || true
rm -rf ${{ github.workspace }}/src/Agent/_profilerBuild/x64-Release || true
rm -rf ${{ github.workspace }}/src/Agent/_profilerBuild/x86-Release || true
shell: bash
- name: Build Linux Profiler
run: |
cd ${{ env.profiler_path }}
docker compose build build
docker compose run build
shell: bash
- name: Move Profiler to staging folder
run: |
mkdir --parents ${{ github.workspace }}/src/Agent/_profilerBuild/linux-x64-release/
mv -f ${{ env.profiler_path }}/libNewRelicProfiler.so ${{ github.workspace }}/src/Agent/_profilerBuild/linux-x64-release/libNewRelicProfiler.so
shell: bash
- name: Archive Artifacts
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with:
name: profiler-amd64
path: ${{ github.workspace }}/src/Agent/_profilerBuild/
if-no-files-found: error
build-linux-arm64-profiler:
name: Build Linux ARM64 Profiler
runs-on: ubuntu-22.04
permissions:
contents: read # for actions/checkout to fetch code
packages: write # for uraimo/run-on-arch-action to cache docker images
env:
profiler_path: ${{ github.workspace }}/src/Agent/NewRelic/Profiler
steps:
- name: Harden Runner
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
with:
egress-policy: audit
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
- name: Clean out _profilerBuild directory
run: |
rm -f ${{ github.workspace }}/src/Agent/_profilerBuild/*.* || true
rm -rf ${{ github.workspace }}/src/Agent/_profilerBuild/linux-x64-release || true
rm -rf ${{ github.workspace }}/src/Agent/_profilerBuild/linux-arm64-release || true
rm -rf ${{ github.workspace }}/src/Agent/_profilerBuild/x64-Release || true
rm -rf ${{ github.workspace }}/src/Agent/_profilerBuild/x86-Release || true
shell: bash
- uses: uraimo/run-on-arch-action@5397f9e30a9b62422f302092631c99ae1effcd9e # v2.8.1
name: Run commands
id: runcmd
with:
arch: aarch64
distro: ubuntu18.04
githubToken: ${{ github.token }}
install: |
apt-get update -q -y
apt-get install -q -y wget curl git dos2unix software-properties-common make binutils libc++-dev clang-3.9 lldb-3.9 build-essential
echo "deb https://apt.llvm.org/trusty/ llvm-toolchain-trusty-3.9 main" | tee /etc/apt/sources.list.d/llvm.list
wget --no-cache --no-cookies -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add -
mkdir /root/git
cd /root/git
git clone --branch release/3.1 https://github.com/dotnet/coreclr.git
curl -sSL https://virtuoso-testing.s3.us-west-2.amazonaws.com/cmake-3.9.0-rc3-aarch64.tar.gz | tar -xzC ~
chmod 777 ~/cmake-3.9.0-rc3-aarch64/bin/cmake
ln -s ~/cmake-3.9.0-rc3-aarch64/bin/cmake /usr/bin/cmake || true
rm /usr/bin/cc || true
ln -s /usr/bin/clang-3.9 /usr/bin/cc
rm /usr/bin/c++ || true
ln -s /usr/bin/clang++-3.9 /usr/bin/c++
dockerRunArgs: |
--volume "${{ env.profiler_path }}:/profiler"
run: |
cd /profiler
chmod 777 ./linux/build_profiler.sh
./linux/build_profiler.sh
- name: Move Profiler to staging folder
run: |
mkdir --parents ${{ github.workspace }}/src/Agent/_profilerBuild/linux-arm64-release/
mv -f ${{ env.profiler_path }}/libNewRelicProfiler.so ${{ github.workspace }}/src/Agent/_profilerBuild/linux-arm64-release/libNewRelicProfiler.so
shell: bash
- name: Archive Artifacts
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with:
name: profiler-arm64
path: ${{ github.workspace }}/src/Agent/_profilerBuild/
if-no-files-found: error
package-and-deploy:
needs:
[
build-windows-profiler,
build-linux-x64-profiler,
build-linux-arm64-profiler,
]
if: ${{ inputs.deploy }}
name: Package and Deploy Profiler NuGet
runs-on: windows-2022
env:
nuget_source: https://www.nuget.org
outputs:
package_version: ${{ steps.agentVersion.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
- name: Download Windows Profiler Artifacts to working Directory
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: profiler-windows
path: ${{ github.workspace }}/_workingDir
- name: Download Linux amd64 Profiler Artifacts to working Directory
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: profiler-amd64
path: ${{ github.workspace }}/_workingDir
- name: Download Linux arm64 Profiler Artifacts to working Directory
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: profiler-arm64
path: ${{ github.workspace }}/_workingDir
- name: Determine Package Version from Git history
id: agentVersion
run: |
# get latest agent version tag
$agentVersion = git describe --match v* --abbrev=0 HEAD --tags
# get commit count since that tag
$getRevCmd = "git rev-list $agentVersion..HEAD --count HEAD"
$agentRev = Invoke-Expression $getRevCmd
# if count is > 0, add the rev to the version
if ($agentRev -gt 0) { $agentVersion = $agentVersion + "." + $agentRev}
# remove the leading "v" from the version number
$agentVersion = $agentVersion.substring(1)
echo "version=$agentVersion" >> $env:GITHUB_OUTPUT
shell: powershell
- name: Stage files in working directory
run: |
New-Item "${{ github.workspace }}/_workingDir/images" -Type "directory"
Copy-Item -Path "${{ github.workspace }}/build/Packaging/NugetProfiler/images/*.*" -Destination "${{ github.workspace }}/_workingDir/images"
New-Item "${{ github.workspace }}/_workingDir/build" -Type "directory"
Copy-Item -Path "${{ github.workspace }}/build/Packaging/NugetProfiler/build/*.*" -Destination "${{ github.workspace }}/_workingDir/build"
Copy-Item -Path "${{ github.workspace }}/build/Packaging/NugetProfiler/readme.md" -Destination "${{ github.workspace }}/_workingDir"
- name: Pack Profiler NuGet Package
run: |
New-Item "${{ github.workspace }}/_workingDir/NugetProfiler" -Type "directory"
nuget pack ${{ github.workspace }}/build/Packaging/NugetProfiler/NewRelic.Profiler.nuspec -BasePath ${{ github.workspace }}/_workingDir -OutputDirectory ${{ github.workspace }}/_workingDir/NugetProfiler -Version ${{ steps.agentVersion.outputs.version }} -Verbosity detailed
shell: powershell
- name: Setup NuGet API Key
run: |
nuget.exe setApiKey ${{ secrets.NUGET_APIKEY }} -Source ${{ env.nuget_source }}
shell: pwsh
- name: Deploy Profiler Package to Nuget
run: |
$packageName = Get-ChildItem ${{ github.workspace }}/_workingDir/NugetProfiler/NewRelic.Agent.Internal.Profiler.*.nupkg -Name
$packagePath = Convert-Path ${{ github.workspace }}//_workingDir/NugetProfiler/$packageName
$version = $packageName.TrimStart('NewRelic.Agent.Internal.Profiler').TrimStart('.').TrimEnd('.nupkg')
nuget.exe push $packagePath -Source ${{ env.nuget_source }}
shell: powershell
update-nuget-reference:
name: Update Profiler Nuget Reference
runs-on: ubuntu-22.04
needs: package-and-deploy
if: ${{ inputs.deploy }}
permissions:
contents: write
pull-requests: write
steps:
- name: Harden Runner
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
with:
egress-policy: audit
- name: Install xmlstarlet
run: |
sudo apt-get install -y xmlstarlet
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
- name: Update Profiler Package Reference to Latest Version
run: |
cat ${{ github.workspace }}/src/Agent/NewRelic/Home/Home.csproj | \
xmlstarlet edit --pf --omit-decl \
--update "//PackageReference[@Include='NewRelic.Agent.Internal.Profiler']/@Version" \
--value "${{ needs.package-and-deploy.outputs.package_version }}" > ${{ github.workspace }}/src/Agent/NewRelic/Home/_temp &&
cat ${{ github.workspace }}/src/Agent/NewRelic/Home/_temp > ${{ github.workspace }}/src/Agent/NewRelic/Home/Home.csproj &&
rm -f ${{ github.workspace }}/src/Agent/NewRelic/Home/_temp
- name: Create Pull Request
uses: peter-evans/create-pull-request@5e914681df9dc83aa4e4905692ca88beb2f9e91f # v7.0.5
with:
commit-message: "chore: Update Profiler NuGet Package Reference to v${{ needs.package-and-deploy.outputs.package_version }}."
title: "chore: Update Profiler NuGet Package Reference to v${{ needs.package-and-deploy.outputs.package_version }}"
branch: profiler-nuget-updates/${{ github.ref_name }}
labels: |
profiler nuget
automated pr
delete-branch: true
add-paths: |
src/Agent/NewRelic/Home/Home.csproj