-
Notifications
You must be signed in to change notification settings - Fork 10
198 lines (192 loc) · 8.25 KB
/
ci.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
name: ci
on:
push:
branches: [ main ]
tags: [ v* ]
pull_request:
workflow_dispatch:
jobs:
build:
strategy:
fail-fast: false
matrix:
include:
- machine: windows-2022
log-dir: "/c/ProgramData/OpenTelemetry .NET AutoInstrumentation/logs"
- machine: ubuntu-20.04
log-dir: "/var/log/opentelemetry/dotnet"
- machine: macos-12
log-dir: "/var/log/opentelemetry/dotnet"
runs-on: ${{ matrix.machine }}
steps:
- uses: actions/[email protected]
with:
fetch-depth: 0 # fetching all, needed to correctly calculate version
- uses: actions/[email protected]
with:
dotnet-version: |
6.0.427
7.0.410
8.0.403
- run: ./build.cmd Workflow
- run: brew install coreutils
if: ${{ runner.os == 'macOS' }}
- name: Create test directory
run: sudo mkdir -p ${{ matrix.log-dir }} && sudo chmod a+rwx ${{ matrix.log-dir }} # workaround before next release
if: ${{ runner.os != 'Windows' }}
- name: Test the Shell scripts from README.md
shell: bash
run: |
set -e
dotnet publish -f net8.0 -c Release ./test/test-applications/integrations/TestApplication.Smoke
export OTEL_DOTNET_AUTO_HOME="${PWD}/OpenTelemetryDistribution"
. ./instrument.sh
./test/test-applications/integrations/TestApplication.Smoke/bin/Release/net8.0/publish/TestApplication.Smoke
test "$(ls -A '${{ matrix.log-dir }}' )"
- name: Test the PowerShell module instructions from README.md
if: ${{ runner.os == 'Windows' }}
shell: powershell
run: |
$log_path = "C:\ProgramData\OpenTelemetry .NET AutoInstrumentation\logs\*"
Import-Module "${PWD}/bin/InstallationScripts/Splunk.OTel.DotNet.psm1"
[System.Environment]::SetEnvironmentVariable("SPLUNK_OTEL_DOTNET_AUTO_INSTALL_DIR", "${PWD}\OpenTelemetryDistribution", [System.EnvironmentVariableTarget]::Machine)
Register-OpenTelemetryForCurrentSession -OTelServiceName "MyServiceDisplayName"
./test/test-applications/integrations/TestApplication.Smoke/bin/Release/net8.0/TestApplication.Smoke.exe
if (-not $?) { throw "dotnet help returned exit code: $LASTEXITCODE" }
if (-not (Test-Path $log_path)) { throw "Log file does not exist. Instrumentation test failed." }
Remove-Item $log_path
Unregister-OpenTelemetryForCurrentSession
./test/test-applications/integrations/TestApplication.Smoke/bin/Release/net8.0/TestApplication.Smoke.exe
if (-not $?) { throw "dotnet help returned exit code: $LASTEXITCODE" }
if (Test-Path $log_path) { throw "Log file exists. Instrumentation unregister failed." }
- uses: actions/[email protected]
with:
name: bin-${{ matrix.machine }}
path: |
bin/splunk-*.zip
bin/InstallationScripts/splunk-otel-dotnet-install.sh
bin/InstallationScripts/Splunk.OTel.DotNet.psm1
bin/Matrix/splunk-otel-dotnet-metadata.yaml
container-build:
strategy:
fail-fast: false
matrix:
include:
- machine: ubuntu-20.04
base-image: alpine-x64
os-type: linux-musl
# architecture: "x64"
- machine: [self-hosted, Linux, ARM64]
base-image: alpine-arm64
os-type: linux-musl
# architecture: "arm64"
- machine: [self-hosted, Linux, ARM64]
base-image: debian-arm64
os-type: linux-glibc
# architecture: "arm64"
runs-on: ${{ matrix.machine }}
timeout-minutes: 60
steps:
- uses: actions/[email protected]
with:
fetch-depth: 0 # fetching all, needed to correctly calculate version
- name: Build Docker image
run: |
docker build \
--tag splunk-otel-dotnet/${{ matrix.base-image }} \
--file "./docker/${{ matrix.base-image }}.dockerfile" \
./build
- name: Build in Docker container
run: |
docker run --rm \
-e OS_TYPE=${{ matrix.os-type }} --mount type=bind,source="${GITHUB_WORKSPACE}",target=/project \
splunk-otel-dotnet/${{ matrix.base-image }} \
/bin/sh -c 'git config --global --add safe.directory /project && ./build.sh Workflow'
- name: Test the Shell scripts from README.md in Docker container
run: |
set -e
docker build -t mybuildimage -f "./docker/${{ matrix.base-image }}.dockerfile" .
docker run -e OTEL_DOTNET_AUTO_LOG_DIRECTORY=/home/user/opentelemetry/log/dotnet --mount type=bind,source="${GITHUB_WORKSPACE}",target=/project --rm mybuildimage /bin/sh -c '
set -e
dotnet publish -f net8.0 -c Release ./test/test-applications/integrations/TestApplication.Smoke
export OTEL_DOTNET_AUTO_HOME="${PWD}/OpenTelemetryDistribution"
. ./instrument.sh
./test/test-applications/integrations/TestApplication.Smoke/bin/Release/net8.0/publish/TestApplication.Smoke
test "$(ls -A /home/user/opentelemetry/log )"
'
- uses: actions/[email protected]
if: (${{ job.status }} != 'cancelled')
with:
name: bin-${{ matrix.base-image }}
path: bin/splunk-*.zip
build-nuget-package:
runs-on: windows-2022
steps:
- uses: actions/[email protected]
with:
fetch-depth: 0 # fetching all, needed to correctly calculate version
- uses: actions/[email protected]
with:
dotnet-version: |
6.0.427
7.0.410
8.0.403
- run: ./build.cmd NuGetWorkflow
- uses: actions/[email protected]
with:
name: nuget-package
path: NuGetPackage/
test-nuget-package:
needs: build-nuget-package
strategy:
fail-fast: false
matrix:
include:
- machine: ubuntu-20.04
- machine: macos-12
runs-on: ${{ matrix.machine }}
steps:
- uses: actions/[email protected]
with:
fetch-depth: 0 # fetching all, needed to correctly calculate version
- uses: actions/[email protected]
with:
dotnet-version: |
6.0.427
7.0.410
8.0.403
- name: Download NuGet Artifacts from build-nuget-package job
uses: actions/[email protected]
with:
name: nuget-package
path: NuGetPackage/
- name: Test NuGet Package
run: ./build.cmd TestNuGetPackage
create-release:
if: github.ref_type == 'tag'
name: Create GitHub release
runs-on: ubuntu-20.04
needs: [ build, container-build, build-nuget-package, test-nuget-package ]
permissions:
contents: write
timeout-minutes: 10
steps:
- uses: actions/[email protected]
- uses: actions/[email protected]
with:
path: .
- run: cp bin-alpine-x64/splunk-*.zip ./splunk-opentelemetry-dotnet-linux-musl-x64.zip
- run: cp bin-alpine-arm64/splunk-*.zip ./splunk-opentelemetry-dotnet-linux-musl-arm64.zip
- run: cp bin-ubuntu-20.04/splunk-*.zip ./splunk-opentelemetry-dotnet-linux-glibc-x64.zip
- run: cp bin-debian-arm64/splunk-*.zip ./splunk-opentelemetry-dotnet-linux-glibc-arm64.zip
- run: cp bin-windows-2022/splunk-*.zip ./splunk-opentelemetry-dotnet-windows.zip
- run: cp bin-macos-12/splunk-*.zip ./splunk-opentelemetry-dotnet-macos.zip
- run: cp bin-windows-2022/InstallationScripts/splunk-otel-dotnet-install.sh ./splunk-otel-dotnet-install.sh
- run: cp bin-windows-2022/InstallationScripts/Splunk.OTel.DotNet.psm1 ./Splunk.OTel.DotNet.psm1
- run: cp bin-windows-2022/Matrix/splunk-otel-dotnet-metadata.yaml ./splunk-otel-dotnet-metadata.yaml
- name: Calculate checksum
run: sha256sum ./*.zip ./nuget-package/*.nupkg ./splunk-otel-dotnet-install.sh ./Splunk.OTel.DotNet.psm1 >> checksum.txt
- name: Create Release
run: gh release create ${{ github.ref_name }} --title ${{ github.ref_name }} --verify-tag --draft ./*.zip ./nuget-package/*.nupkg ./splunk-otel-dotnet-install.sh ./Splunk.OTel.DotNet.psm1 checksum.txt ./splunk-otel-dotnet-metadata.yaml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}