-
Notifications
You must be signed in to change notification settings - Fork 1.6k
367 lines (336 loc) · 13.8 KB
/
Copy pathtest-target.yml
File metadata and controls
367 lines (336 loc) · 13.8 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
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
# This is a copy of the test target workflow created for testing updates on the workflow without impacting the on used in our PRs.
# Since this workflow is used through workflow dispatch, it needs to be in master to be able tot be executed. This means that we cannot
# easily update it to test someth8ing without impacting onging runs.
name: Test Target
on:
workflow_call:
inputs:
job-name:
required: true
type: string
target:
required: true
type: string
target-env:
description: "Specific target env to run"
required: false
default: ""
type: string
platform:
required: true
type: string
runner:
required: true
type: string
repo:
required: true
type: string
python-version:
required: false
default: "3.13"
type: string
benchmark:
required: false
default: false
type: boolean
latest:
required: false
default: false
type: boolean
minimum-base-package:
required: false
default: false
type: boolean
# integrations-core repo no longer tests Python 2, only Python 3.
# We keep the options in the workflow for community and marketplace partners.
# They may still continue to test Python 2 and Agent 6.
test-py2:
required: false
default: false
type: boolean
test-py3:
required: false
default: true
type: boolean
agent-image:
required: false
default: "registry.datadoghq.com/agent-dev:sarah-go-parser-labels-782-py3"
type: string
agent-image-py2:
required: false
default: "datadog/agent-dev:master-py2"
type: string
agent-image-windows:
required: false
default: "registry.datadoghq.com/agent:7-rc-servercore"
type: string
agent-image-windows-py2:
required: false
default: "datadog/agent-dev:master-py2-win-servercore"
type: string
setup-env-vars:
required: false
default: ""
type: string
pytest-args:
description: "Arguments to pass to pytest"
required: false
type: string
default: ""
context:
description: "Context where the test is run. This is used for CI visibility descovery."
required: false
default: "standard"
type: string
step-timeout-minutes:
description: "Timeout in minutes for ddev test steps"
required: false
default: 60
type: number
defaults:
run:
shell: bash
jobs:
run:
name: "${{ inputs.job-name }}${{ inputs.target-env && format('-{0}', inputs.target-env) || '' }}"
runs-on: ${{ fromJson(inputs.runner) }}
permissions:
# needed for compute-matrix in test-target.yml
contents: read
steps:
- name: Set up Windows
if: runner.os == 'Windows'
run: |-
# Enable disk performance counters
diskperf -y
# On Windows minimum-base-package jobs only, force uv to copy files into
# the venv instead of hardlinking them from its cache. uv's default
# `hardlink` mode on Windows breaks `hatch env remove`, which is invoked
# by `ddev test --compat` (used by the minimum-base-package matrix) at the
# end of the run: extension modules such as `backports.zstd._zstd.pyd`
# (a transitive of `hatch>=1.13`) get loaded by Python during the test
# run, and Windows then refuses to delete the venv's hardlink while the
# cache copy is still pinned, so cleanup fails with
# `PermissionError: [WinError 5]`. We can't influence this from our side:
# the share flags that would allow deletion are set by whoever opens the
# file (CPython's loader, Defender, etc.), not by us.
#
# We only set this for `minimum-base-package` runs because regular test
# jobs never invoke `hatch env remove` and so keep the hardlink speed-up.
# Refs:
# https://github.com/astral-sh/uv/issues/7918
# https://docs.astral.sh/uv/reference/settings/#link-mode
- name: Configure uv link mode (Windows minimum-base-package)
if: runner.os == 'Windows' && inputs.minimum-base-package
shell: bash
run: echo "UV_LINK_MODE=copy" >> "$GITHUB_ENV"
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
# When called as a reusable workflow from other repos, `uses: ./` resolves
# from the caller's repo where the actions don't exist. We checkout the
# actions from integrations-core so they are available locally.
# Note: github.workflow_sha/workflow_ref point to the caller, not to
# integrations-core, so we cannot dynamically pin the ref.
- name: Resolve integrations-core ref
if: inputs.repo != 'core'
id: ic-ref
shell: bash
run: |
# GITHUB_WORKFLOW_REF is available in the environment automatically
echo "GITHUB_WORKFLOW_REF: $GITHUB_WORKFLOW_REF"
echo "ref=${GITHUB_WORKFLOW_REF##*@}" >> "$GITHUB_OUTPUT"
- name: Checkout integrations-core actions
if: inputs.repo != 'core'
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
repository: "DataDog/integrations-core"
ref: master
fetch-depth: 1
sparse-checkout: .github/actions
# Use a specific sub-folder
path: core-temp
- name: Install workflow scripts (core)
if: inputs.repo == 'core'
uses: ./.github/actions/setup-test-target-scripts
- name: Install workflow scripts (non-core)
if: inputs.repo != 'core'
uses: ./core-temp/.github/actions/setup-test-target-scripts
- name: Set environment variables
# This step sets the following environment variables for the entire workflow via setup-test-env.sh:
# FORCE_COLOR
# TEST_RESULTS_BASE_DIR
# PYTHON_VERSION
# PYTHONUNBUFFERED
# SKIP_ENV_NAME
# DDEV_E2E_AGENT
# DDEV_E2E_AGENT_PY2
# DD_ENV
# DD_SERVICE
# DD_TRACE_ANALYTICS_ENABLED
# DD_CIVISIBILITY_ENABLED
# DD_CIVISIBILITY_AGENTLESS_ENABLED
# DD_CIVISIBILITY_AUTO_INSTRUMENTATION_PROVIDER
# DD_PROFILING_ENABLED
# DD_SITE
# DD_API_KEY
# MINIMUM_BASE_PACKAGE_PREFIX
# TEST_RESULTS_DIR
# DD_TAGS
# DOCKER_USERNAME
# DOCKER_ACCESS_TOKEN
# ORACLE_DOCKER_USERNAME
# ORACLE_DOCKER_PASSWORD
# DD_GITHUB_USER
# DD_GITHUB_TOKEN
# INPUT_REPO
# INPUT_TARGET
# INPUT_TARGET_ENV
# INPUT_TARGET_STR
# INPUT_PLATFORM
# INPUT_MINIMUM_BASE_PACKAGE
# INPUT_PYTEST_ARGS
# INPUT_IS_FORK
run: bash .github/workflows/scripts/setup-test-env.sh
env:
INPUT_PYTHON_VERSION: ${{ inputs.python-version }}
INPUT_TEST_PY2: ${{ inputs.test-py2 }}
INPUT_TEST_PY3: ${{ inputs.test-py3 }}
INPUT_PLATFORM: ${{ inputs.platform }}
INPUT_AGENT_IMAGE: ${{ inputs.agent-image }}
INPUT_AGENT_IMAGE_PY2: ${{ inputs.agent-image-py2 }}
INPUT_AGENT_IMAGE_WINDOWS: ${{ inputs.agent-image-windows }}
INPUT_AGENT_IMAGE_WINDOWS_PY2: ${{ inputs.agent-image-windows-py2 }}
INPUT_TARGET: ${{ inputs.target }}
INPUT_TARGET_ENV: ${{ inputs.target-env }}
INPUT_REPO: ${{ inputs.repo }}
INPUT_CONTEXT: ${{ inputs.context }}
INPUT_MINIMUM_BASE_PACKAGE: ${{ inputs.minimum-base-package }}
INPUT_JOB_NAME: "${{ inputs.job-name }}${{ inputs.target-env && format('-{0}', inputs.target-env) || '' }}"
INPUT_PYTEST_ARGS: ${{ inputs.pytest-args }}
INPUT_IS_FORK: ${{ github.event.pull_request.head.repo.fork || false }}
DD_API_KEY_SECRET: ${{ secrets.DD_API_KEY }}
SETUP_ENV_VARS: ${{ inputs.setup-env-vars }}
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_ACCESS_TOKEN: ${{ secrets.DOCKER_ACCESS_TOKEN }}
ORACLE_DOCKER_USERNAME: ${{ secrets.ORACLE_DOCKER_USERNAME }}
ORACLE_DOCKER_PASSWORD: ${{ secrets.ORACLE_DOCKER_PASSWORD }}
DD_GITHUB_USER: ${{ github.actor }}
DD_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Tag job for CI Visibility
# Skip on fork PRs and non-core repos since secrets won't be available
if: env.INPUT_IS_FORK != 'true' && env.INPUT_REPO == 'core'
uses: ./.github/actions/tag-job
with:
tags: ${{ env.DD_TAGS }}
dd_api_key: ${{ secrets.DD_API_KEY }}
dd_site: ${{ env.DD_SITE }}
- name: Set up Python 2.7
if: inputs.test-py2
run: |
if [ "$RUNNER_OS" == "Linux" ]; then
sudo apt update
sudo apt install python2 python2-dev
sudo update-alternatives --install /usr/bin/python python /usr/bin/python2 1
elif [ "$RUNNER_OS" == "Windows" ]; then
choco install python2
else
echo "$RUNNER_OS not supported"
exit 1
fi
shell: bash
- name: Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: "${{ env.PYTHON_VERSION }}"
- name: Install ddev from local folder
if: inputs.repo == 'core'
uses: ./.github/actions/setup-ddev
with:
install-mode: local
cache-profile: local-ddev-base
- name: Install ddev from PyPI
if: inputs.repo != 'core'
uses: ./core-temp/.github/actions/setup-ddev
with:
install-mode: pypi
- name: Configure ddev
run: |-
ddev config set upgrade_check false
ddev config set repos.${{ inputs.repo }} .
ddev config set repo ${{ inputs.repo }}
- name: Lint
timeout-minutes: ${{ inputs.step-timeout-minutes }}
run: |-
ddev test --lint ${{ inputs.target }} || {
echo "::error::Lint failed!"
echo "::error::Please update to the latest version of ddev to ensure you are using the latest linting rules and then run 'ddev test --fmt ${{ inputs.target }}' to fix formatting issues."
exit 1
}
- name: Prepare for testing
timeout-minutes: ${{ inputs.step-timeout-minutes }}
run: ddev ci setup ${{ inputs.target-env && format('{0}:{1}', inputs.target, inputs.target-env) || inputs.target }}
- name: Ensure Docker is running
run: bash .github/workflows/scripts/ensure-docker.sh
- name: Run Unit & Integration tests
if: inputs.latest != true
timeout-minutes: ${{ inputs.step-timeout-minutes }}
run: bash .github/workflows/scripts/run-unit-integration-tests.sh
- name: Run E2E tests
if: (inputs.repo == 'core' && !inputs.minimum-base-package) || inputs.repo != 'core'
timeout-minutes: ${{ inputs.step-timeout-minutes }}
run: bash .github/workflows/scripts/run-e2e-tests.sh
env:
INPUT_SESSION_NAME: "e2e-tests"
- name: Run benchmarks
if: inputs.benchmark
timeout-minutes: ${{ inputs.step-timeout-minutes }}
env:
DDEV_TEST_ENABLE_TRACING: "${{ inputs.repo == 'core' && (inputs.target != 'sqlserver' || inputs.platform != 'windows') && env.INPUT_IS_FORK != 'true' && '1' || '0' }}"
DD_TEST_SESSION_NAME: "benchmarks"
run: ddev test --bench --junit ${{ inputs.target-env && format('{0}:{1}', inputs.target, inputs.target-env) || inputs.target }}
- name: Run tests and verify support for the latest version
if: inputs.latest
timeout-minutes: ${{ inputs.step-timeout-minutes }}
env:
DDEV_TEST_ENABLE_TRACING: "${{ inputs.repo == 'core' && (inputs.target != 'sqlserver' || inputs.platform != 'windows') && env.INPUT_IS_FORK != 'true' && '1' || '0' }}"
DD_TEST_SESSION_NAME: "latest-tests"
run: ddev test --latest --junit ${{ inputs.target-env && format('{0}:{1}', inputs.target, inputs.target-env) || inputs.target }}
- name: Run E2E tests for the latest version
if: inputs.latest
timeout-minutes: ${{ inputs.step-timeout-minutes }}
run: bash .github/workflows/scripts/run-e2e-tests.sh
env:
# Override INPUT_TARGET to include :latest suffix
INPUT_TARGET: "${{ inputs.target }}:latest"
INPUT_SESSION_NAME: "latest-e2e-tests"
INPUT_IS_LATEST: "true"
- name: Finalize test results
if: always()
run: |-
mkdir -p "${{ env.TEST_RESULTS_DIR }}"
if [[ -d ${{ inputs.target }}/junit ]]; then
mv ${{ inputs.target }}/junit/*.xml "${{ env.TEST_RESULTS_DIR }}"
fi
- name: Upload test results
if: always()
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: "${{ env.MINIMUM_BASE_PACKAGE_PREFIX }}test-results-${{ inputs.target }}${{ inputs.target-env && format('-{0}', inputs.target-env) || '' }}-${{ inputs.platform }}"
path: "${{ env.TEST_RESULTS_BASE_DIR }}"
- name: Upload local_clone debug info (ddev only)
if: always() && inputs.target == 'ddev'
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: "${{ env.MINIMUM_BASE_PACKAGE_PREFIX }}local-clone-debug-${{ inputs.platform }}"
path: "local_clone_debug.txt"
if-no-files-found: ignore
- name: Upload coverage data as artifact
if: >
!github.event.repository.private &&
always() &&
inputs.pytest-args != '-m flaky'
# Flaky tests will have low coverage, don't include in artifacts to avoid pipeline issues
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: "${{ env.MINIMUM_BASE_PACKAGE_PREFIX }}coverage-${{ inputs.target }}${{ inputs.target-env && format('-{0}', inputs.target-env) || '' }}-${{ inputs.platform }}"
path: "${{ inputs.target }}/coverage.xml"
if-no-files-found: ignore