-
Notifications
You must be signed in to change notification settings - Fork 10
173 lines (167 loc) · 6.88 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
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-11
log-dir: "/var/log/opentelemetry/dotnet"
runs-on: ${{ matrix.machine }}
steps:
- uses: actions/checkout@v4.0.0
with:
fetch-depth: 0 # fetching all, needed to correctly calculate version
- uses: actions/setup-dotnet@v3.2.0
with:
dotnet-version: |
6.0.413
7.0.400
- 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 net7.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/net7.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}/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/x64/Release/net7.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/x64/Release/net7.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/upload-artifact@v3.1.2
with:
name: bin-${{ matrix.machine }}
path: bin/splunk-*.zip
container-build:
strategy:
fail-fast: false
matrix:
base-image: [ alpine ]
runs-on: ubuntu-20.04
timeout-minutes: 60
steps:
- uses: actions/checkout@v4.0.0
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=linux-musl --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 --mount type=bind,source="${GITHUB_WORKSPACE}",target=/project --rm mybuildimage /bin/sh -c '
set -e
dotnet publish -f net7.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/net7.0/publish/TestApplication.Smoke
test "$(ls -A /var/log/opentelemetry/dotnet )"
'
- uses: actions/upload-artifact@v3.1.2
with:
name: bin-${{ matrix.base-image }}
path: bin/splunk-*.zip
build-nuget-package:
runs-on: windows-2022
steps:
- uses: actions/checkout@v4.0.0
with:
fetch-depth: 0 # fetching all, needed to correctly calculate version
- uses: actions/setup-dotnet@v3.2.0
with:
dotnet-version: |
6.0.413
7.0.400
- run: ./build.cmd NuGetWorkflow
- uses: actions/upload-artifact@v3.1.2
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-11
runs-on: ${{ matrix.machine }}
steps:
- uses: actions/checkout@v4.0.0
with:
fetch-depth: 0 # fetching all, needed to correctly calculate version
- uses: actions/setup-dotnet@v3.2.0
with:
dotnet-version: |
6.0.413
7.0.400
- name: Download NuGet Artifacts from build-nuget-package job
uses: actions/download-artifact@v3.0.2
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/checkout@v4.0.0
- uses: actions/download-artifact@v3.0.2
with:
path: .
- run: cp bin-alpine/splunk-*.zip ./splunk-opentelemetry-dotnet-linux-musl.zip
- run: cp bin-ubuntu-20.04/splunk-*.zip ./splunk-opentelemetry-dotnet-linux-glibc.zip
- run: cp bin-windows-2022/splunk-*.zip ./splunk-opentelemetry-dotnet-windows.zip
- run: cp bin-macos-11/splunk-*.zip ./splunk-opentelemetry-dotnet-macos.zip
- 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
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}