forked from signalfx/splunk-otel-collector
-
Notifications
You must be signed in to change notification settings - Fork 0
190 lines (167 loc) · 6.33 KB
/
auto-instrumentation.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
name: auto-instrumentation
on:
push:
branches:
- main
pull_request:
paths:
- '.github/workflows/auto-instrumentation.yml'
- 'cmd/otelcol/**'
- 'instrumentation/**'
- 'internal/**'
- '!**.md'
- 'packaging/**'
- '!packaging/technical-addon/**'
concurrency:
group: auto-instrumentation-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
PYTHON_VERSION: '3.13'
PIP_VERSION: '24.2'
REQUIREMENTS_PATH: "packaging/tests/requirements.txt"
GO_VERSION: 1.22.7
jobs:
cross-compile:
runs-on: ubuntu-24.04
strategy:
matrix:
SYS_BINARIES: [ "binaries-linux_amd64", "binaries-linux_arm64" ]
steps:
- name: Check out the codebase.
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache-dependency-path: '**/go.sum'
- name: Build Collector
run: |
make ${{ matrix.SYS_BINARIES }}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.SYS_BINARIES }}
path: |
./bin/*
build-package:
runs-on: ubuntu-24.04
strategy:
matrix:
SYS_PACKAGE: [ "deb", "rpm" ]
ARCH: [ "amd64", "arm64"]
steps:
- name: Check out the codebase.
uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: docker/setup-qemu-action@v3
if: ${{ matrix.ARCH != 'amd64' }}
with:
platforms: ${{ matrix.ARCH }}
image: tonistiigi/binfmt:qemu-v7.0.0
- name: Run tests
run: make -C instrumentation tests ARCH=${{ matrix.ARCH }}
- name: Build ${{ matrix.ARCH }} ${{ matrix.SYS_PACKAGE }} package
run: make -C instrumentation/ ${{ matrix.SYS_PACKAGE }}-package ARCH="${{ matrix.ARCH }}"
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: splunk-otel-auto-instrumentation-${{ matrix.ARCH }}-${{ matrix.SYS_PACKAGE }}
path: ./instrumentation/dist/*.${{ matrix.SYS_PACKAGE }}
test-package-matrix:
runs-on: ubuntu-24.04
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Get matrix
id: get-matrix
run: |
# create test matrix for distro and arch
dockerfiles=$(find packaging/tests/instrumentation/images/ -name "Dockerfile.*" | cut -d '.' -f2- | sort -u)
if [ -z "$dockerfiles" ]; then
echo "Failed to get dockerfiles from packaging/tests/instrumentation/images!" >&2
exit 1
fi
distro=$(for d in $dockerfiles; do echo -n "\"$d\","; done)
arch="\"amd64\", \"arm64\""
testcase="\"express\",\"tomcat\",\"dotnet\""
exclude='{"ARCH": "arm64", "TESTCASE": "dotnet"}' # splunk-otel-dotnet currently not supported on arm64
matrix="{\"DISTRO\": [${distro%,}], \"ARCH\": [${arch}], \"TESTCASE\": [${testcase}], \"exclude\": [${exclude}]}"
echo "$matrix" | jq
echo "matrix=${matrix}" >> $GITHUB_OUTPUT
outputs:
matrix: ${{ steps.get-matrix.outputs.matrix }}
test-package:
# Use 20.04.5 until https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/16450 is resolved
runs-on: ${{ fromJSON('["ubuntu-20.04", "ubuntu-22.04"]')[matrix.DISTRO == 'amazonlinux-2023'] }}
timeout-minutes: 60
needs: [cross-compile, build-package, test-package-matrix]
strategy:
matrix: ${{ fromJSON(needs.test-package-matrix.outputs.matrix) }}
fail-fast: false
steps:
- name: Check out the codebase.
uses: actions/checkout@v4
- name: Get package type for ${{ matrix.DISTRO }}
run: |
for pkg in "deb" "rpm"; do
if [[ -f "packaging/tests/instrumentation/images/${pkg}/Dockerfile.${{ matrix.DISTRO }}" ]]; then
echo "SYS_PACKAGE=${pkg}" >> $GITHUB_ENV
exit 0
fi
done
echo "Unknown distro '${{ matrix.DISTRO }}'!"
exit 1
- uses: actions/download-artifact@v4
with:
name: binaries-linux_${{ matrix.ARCH }}
path: ./bin
- uses: actions/download-artifact@v4
with:
name: splunk-otel-auto-instrumentation-${{ matrix.ARCH }}-${{ env.SYS_PACKAGE }}
path: ./instrumentation/dist
- uses: docker/setup-qemu-action@v3
if: ${{ matrix.ARCH != 'amd64' }}
with:
platforms: ${{ matrix.ARCH }}
image: tonistiigi/binfmt:qemu-v7.0.0
- name: Setup python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: 'pip'
cache-dependency-path: ${{ env.REQUIREMENTS_PATH }}
- name: Install pytest
run: |
if which pip; then
pip install --upgrade 'pip==${{ env.PIP_VERSION }}'
else
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python get-pip.py 'pip==${{ env.PIP_VERSION }}'
fi
pip install -r "${{ env.REQUIREMENTS_PATH }}"
- name: Test ${{ env.SYS_PACKAGE }} on ${{ matrix.DISTRO }} ${{ matrix.ARCH }}
id: pytest
continue-on-error: true
run: |
distro="${{ matrix.DISTRO }}"
if [[ "$distro" = "amazonlinux-2" ]]; then
# workaround for pytest substring matching
distro="amazonlinux-2 and not amazonlinux-2023"
fi
testcase="${{ matrix.TESTCASE }} or uninstall"
python3 -u -m pytest -s --verbose -k "$distro and ${{ matrix.ARCH }} and ($testcase)" \
packaging/tests/instrumentation/instrumentation_test.py
# qemu, networking, running systemd in containers, etc., can be flaky
- name: Re-run failed tests
if: ${{ steps.pytest.outcome == 'failure' }}
run: |
distro="${{ matrix.DISTRO }}"
if [[ "$distro" = "amazonlinux-2" ]]; then
# workaround for pytest substring matching
distro="amazonlinux-2 and not amazonlinux-2023"
fi
testcase="${{ matrix.TESTCASE }} or uninstall"
python3 -u -m pytest -s --verbose -k "$distro and ${{ matrix.ARCH }} and ($testcase)" \
--last-failed \
packaging/tests/instrumentation/instrumentation_test.py