-
Notifications
You must be signed in to change notification settings - Fork 6.8k
218 lines (191 loc) · 7.7 KB
/
Copy pathrun-telemetry-tests.yml
File metadata and controls
218 lines (191 loc) · 7.7 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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
# Copyright The OpenTelemetry Authors
# SPDX-License-Identifier: Apache-2.0
name: Telemetry Tests
on:
# Run on every approved PR review (covers human-reviewed PRs).
pull_request_review:
types: [submitted]
# Run on dependabot PRs without requiring approval. The `gate` job below
# restricts this to dependabot only; other PRs are tested via review approval.
pull_request:
branches: [main]
paths:
- 'src/**'
- 'test/telemetry/**'
- 'compose.yaml'
- 'compose.full.yaml'
- 'compose.observability.yaml'
- 'compose.extras.yaml'
- '.env'
- '.github/workflows/run-telemetry-tests.yml'
# Post-merge validation on main.
push:
branches: [main]
paths:
- 'src/**'
- 'test/telemetry/**'
- 'compose.yaml'
- 'compose.full.yaml'
- 'compose.observability.yaml'
- 'compose.extras.yaml'
- '.env'
- '.github/workflows/run-telemetry-tests.yml'
workflow_dispatch:
permissions:
contents: read
# Coalesce concurrent runs on the same PR or branch so an approval right
# after a push doesn't fire two builds in parallel.
concurrency:
group: telemetry-tests-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
# Single source of truth for when the telemetry test jobs should run:
# - approved PR reviews on open non-dependabot PRs, OR
# - dependabot PRs (tested on open/sync, not on approval), OR
# - push to main / manual dispatch
gate:
name: "Telemetry Test Gate"
runs-on: ubuntu-latest
outputs:
should_run: ${{ steps.check.outputs.should_run }}
steps:
- id: check
# Pass GitHub-context values through env: rather than expanding them
# directly into the shell command, so a hostile fork can't sneak shell
# metacharacters into a context field and break out of the comparison.
env:
EVENT_NAME: ${{ github.event_name }}
REVIEW_STATE: ${{ github.event.review.state }}
PR_STATE: ${{ github.event.pull_request.state }}
PR_AUTHOR: ${{ github.event.pull_request.user.login }}
run: |
if [[ "$EVENT_NAME" == "workflow_dispatch" || "$EVENT_NAME" == "push" ]] \
|| [[ "$EVENT_NAME" == "pull_request_review" && "$REVIEW_STATE" == "approved" && "$PR_STATE" == "open" && "$PR_AUTHOR" != "dependabot[bot]" ]] \
|| [[ "$EVENT_NAME" == "pull_request" && "$PR_AUTHOR" == "dependabot[bot]" ]]; then
echo "should_run=true" >> "$GITHUB_OUTPUT"
else
echo "should_run=false" >> "$GITHUB_OUTPUT"
fi
# Build the demo images from the PR's source ONCE, then hand them to the test
# jobs as an artifact. Without this the test jobs ran `docker compose up`,
# which pulls the released `ghcr.io/open-telemetry/demo:latest-*` images from
# the registry — so a PR's own changes were never actually exercised.
build-images:
name: "Build demo images"
needs: gate
if: ${{ needs.gate.outputs.should_run == 'true' }}
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: check out code
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
# On pull_request_review the default ref is the base branch; check out
# the PR head so we build the proposed changes. Falls back to the
# default ref for push and workflow_dispatch events.
ref: ${{ github.event.pull_request.head.sha || github.ref }}
persist-credentials: false
- name: Free disk space
run: |
sudo rm -rf /usr/local/lib/android /usr/share/dotnet /opt/ghc
docker system prune -af
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@d7f5e7f509e45cec5c76c4d5afdd7de93d0b3df5 # v4.1.0
- name: Create .env.override if missing
run: touch .env.override
- name: Build demo images
run: make build
- name: Save demo images to an artifact tarball
run: |
# Only the images we build (demo:latest-*) need shipping; third-party
# images (jaeger, prometheus, grafana, ...) are pulled from their own
# registries by each test job, so leave them out to keep the tarball small.
IMAGES=$(docker images 'ghcr.io/open-telemetry/demo:latest-*' --format '{{.Repository}}:{{.Tag}}')
echo "Saving images:"; echo "$IMAGES"
docker save $IMAGES | zstd -3 -T0 -o demo-images.tar.zst
ls -lh demo-images.tar.zst
- name: Upload demo images artifact
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: demo-images-${{ github.run_id }}
path: demo-images.tar.zst
retention-days: 1
compression-level: 0 # already zstd-compressed
telemetry-tests-full:
needs: [gate, build-images]
if: ${{ needs.gate.outputs.should_run == 'true' }}
runs-on: ubuntu-latest
timeout-minutes: 30
name: "Telemetry Tests (full)"
steps:
- name: check out code
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
ref: ${{ github.event.pull_request.head.sha || github.ref }}
persist-credentials: false
- name: Free disk space
run: |
sudo rm -rf /usr/local/lib/android /usr/share/dotnet /opt/ghc
docker system prune -af
- name: Download demo images artifact
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: demo-images-${{ github.run_id }}
- name: Load demo images
run: zstd -d -c demo-images.tar.zst | docker load
- name: Create .env.override if missing
run: touch .env.override
- name: Run telemetry tests
timeout-minutes: 15
env:
# Give backends more headroom on slow shared runners before the
# per-test polls begin; the warmup gate waits for all three backends.
WARMUP_SECONDS: "300"
POLL_TIMEOUT: "240"
WARMUP_PROBE_TIMEOUT: "180"
PYTEST_ADDOPTS: "--capture=tee-sys --maxfail=1"
run: make run-telemetry-tests
- name: Print service logs on failure
if: failure()
run: docker compose logs --tail=50
- name: Stop demo
if: always()
run: make stop
telemetry-tests-minimal:
needs: [gate, build-images]
if: ${{ needs.gate.outputs.should_run == 'true' }}
runs-on: ubuntu-latest
timeout-minutes: 30
name: "Telemetry Tests (minimal)"
steps:
- name: check out code
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
ref: ${{ github.event.pull_request.head.sha || github.ref }}
persist-credentials: false
- name: Free disk space
run: |
sudo rm -rf /usr/local/lib/android /usr/share/dotnet /opt/ghc
docker system prune -af
- name: Download demo images artifact
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: demo-images-${{ github.run_id }}
- name: Load demo images
run: zstd -d -c demo-images.tar.zst | docker load
- name: Create .env.override if missing
run: touch .env.override
- name: Run telemetry tests (minimal)
timeout-minutes: 15
env:
WARMUP_SECONDS: "300"
POLL_TIMEOUT: "240"
WARMUP_PROBE_TIMEOUT: "180"
PYTEST_ADDOPTS: "--capture=tee-sys --maxfail=1"
run: make run-telemetry-tests-minimal
- name: Print service logs on failure
if: failure()
run: docker compose logs --tail=50
- name: Stop demo
if: always()
run: make stop