-
Notifications
You must be signed in to change notification settings - Fork 55
285 lines (266 loc) · 10.4 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
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
# This workflow will do a clean install of node dependencies, build the source code and run tests
name: Continuous Integration
on: push
jobs:
build-and-test:
strategy:
fail-fast: false
matrix:
version: [14, 16, 18, 20]
name: Build and test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install node
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.version }}
- run: yarn install --immutable
- run: yarn build
- name: Run yarn lint:ci
run: |
if ! yarn lint:ci ; then
echo "ESLint failed with the following errors:"
jq '.runs[].results' sarif-datadog-ci.sarif
echo ""
echo "Find the full SARIF report in the Artifacts section here: https://github.com/DataDog/datadog-ci/actions/runs/${{ github.run_id }}"
echo "You can fix this by running ==> yarn format <=="
echo ""
exit 1
fi
- run: yarn no-only-in-tests
- run: yarn test
env:
CI: true
DD_SERVICE: datadog-ci-tests
DD_CIVISIBILITY_AGENTLESS_ENABLED: 1
DD_API_KEY: ${{ secrets.DATADOG_API_KEY_MAIN_ACCOUNT }}
DD_APP_KEY: ${{ secrets.DATADOG_APP_KEY_MAIN_ACCOUNT }}
DD_ENV: ci
NODE_OPTIONS: -r dd-trace/ci/init
- run: mkdir artifacts
- run: yarn pack --filename artifacts/datadog-ci-${{ matrix.version }}.tgz
- run: cp -r .github/workflows/e2e artifacts/
- uses: actions/upload-artifact@v4
with:
name: artifacts-${{ matrix.version }}
path: artifacts/
- uses: actions/upload-artifact@v4
if: always()
with:
name: sarif-datadog-ci-${{ matrix.version }}.sarif
path: sarif-datadog-ci.sarif
if-no-files-found: error
e2e-test:
strategy:
matrix:
version: [14, 16, 18, 20]
name: End-to-end test the package
runs-on: ubuntu-latest
needs: build-and-test
env:
FORCE_COLOR: 1
steps:
- uses: actions/checkout@v4
- name: Install node
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.version }}
- uses: actions/download-artifact@v4
with:
name: artifacts-${{ matrix.version }}
path: artifacts/
- run: yarn add ./artifacts/datadog-ci-${{ matrix.version }}.tgz
- name: Run synthetics test
run: yarn datadog-ci synthetics run-tests --config artifacts/e2e/global.config.json
env:
DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY_E2E }}
DATADOG_APP_KEY: ${{ secrets.DATADOG_APP_KEY_E2E }}
- name: Run sourcemaps upload test
run: yarn datadog-ci sourcemaps upload artifacts/e2e/sourcemaps/ --release-version=e2e --service=e2e-tests --minified-path-prefix=https://e2e-tests.datadoghq.com/static/
env:
DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY_E2E }}
DATADOG_APP_KEY: ${{ secrets.DATADOG_APP_KEY_E2E }}
- name: Run junit upload test (measures)
run: yarn datadog-ci junit upload --service=datadog-ci-e2e-tests-junit **/junit-reports/**/*.xml --measures testmeasure1:20 --report-measures sessionmeasure1:40
env:
DD_API_KEY: ${{ secrets.DD_API_KEY_CI_VISIBILITY }}
- name: Check that test data can be queried (measures)
run: |
yarn add @datadog/datadog-api-client
yarn check-junit-upload
env:
EXTRA_TEST_QUERY_FILTER: '@testmeasure1:20'
EXTRA_SESSION_QUERY_FILTER: '@sessionmeasure1:40'
DD_API_KEY: ${{ secrets.DD_API_KEY_CI_VISIBILITY }}
DD_APP_KEY: ${{ secrets.DD_APP_KEY_CI_VISIBILITY }}
DD_SERVICE: datadog-ci-e2e-tests-junit
- name: Run junit upload test (metrics), passing glob as literal string
run: yarn datadog-ci junit upload --service=datadog-ci-e2e-tests-junit '**/junit-reports/**' --metrics testmeasure2:60 --report-metrics sessionmeasure2:80
env:
DD_API_KEY: ${{ secrets.DD_API_KEY_CI_VISIBILITY }}
- name: Check that test data can be queried (metrics)
run: |
yarn add @datadog/datadog-api-client
yarn check-junit-upload
env:
EXTRA_TEST_QUERY_FILTER: '@testmeasure2:60'
EXTRA_SESSION_QUERY_FILTER: '@sessionmeasure2:80'
DD_API_KEY: ${{ secrets.DD_API_KEY_CI_VISIBILITY }}
DD_APP_KEY: ${{ secrets.DD_APP_KEY_CI_VISIBILITY }}
DD_SERVICE: datadog-ci-e2e-tests-junit
- name: Run sarif upload test
run: yarn datadog-ci sarif upload --service=datadog-ci-e2e-tests-sarif artifacts/e2e/sarif-reports
env:
DD_API_KEY: ${{ secrets.DD_API_KEY_CI_VISIBILITY }}
- name: Run sbom upload test
run: yarn datadog-ci sbom upload --service=datadog-ci-e2e-tests-sbom --env test artifacts/e2e/sbom-reports/sbom.json
env:
DD_API_KEY: ${{ secrets.DD_API_KEY_CI_VISIBILITY }}
DD_APP_KEY: ${{ secrets.DD_APP_KEY_CI_VISIBILITY }}
standalone-binary-test-ubuntu:
name: Test standalone binary in ubuntu
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install node
uses: actions/setup-node@v4
with:
node-version: 20.11.0 # Use newer version to build the standalone binary
- run: yarn install --immutable
- run: yarn build
- name: Create standalone binary
run: yarn dist-standalone -t node14-linux-x64 -o datadog-ci_linux-x64
- name: Remove dist and src folder to check that binary can stand alone
run: |
rm -rf dist
rm -rf src
- name: Test generated standalone binary
run: yarn dist-standalone:test
standalone-binary-test-ubuntu-arm:
name: Test standalone binary in ARM ubuntu
runs-on:
group: ARM LINUX SHARED
labels: arm-4core-linux
steps:
- uses: actions/checkout@v4
- name: Install node
uses: actions/setup-node@v4
with:
node-version: 20.11.0 # Use newer version to build the standalone binary
- run: npm install -g yarn
name: Install Yarn # Yarn is not installed by default in this runner
- run: yarn install --immutable
- run: yarn build
- name: Create standalone binary
run: yarn dist-standalone -t node14-linux-arm64 -o datadog-ci_linux-arm64
- name: Remove dist and src folder to check that binary can stand alone
run: |
rm -rf dist
rm -rf src
- name: Test generated standalone binary
run: yarn dist-standalone:test
standalone-binary-test-windows:
name: Test standalone binary in windows
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- name: Install node
uses: actions/setup-node@v4
with:
node-version: 20.11.0 # Use newer version to build the standalone binary
- run: yarn install --immutable
- run: yarn build:win
- name: Create standalone binary
run: yarn dist-standalone -t node14-win-x64 -o datadog-ci_win-x64
- name: Remove dist and src folder to check that binary can stand alone
run: |
rm dist -r
rm src -r
- name: Test generated standalone binary
run: yarn dist-standalone:test
standalone-binary-test-macos:
name: Test standalone binary in macOS
# `macos-latest-large` is an x64 image, and we need it to run the standalone tests
# https://github.com/actions/runner-images#available-images
runs-on: macos-latest-large
steps:
- uses: actions/checkout@v4
- name: Install node
uses: actions/setup-node@v4
with:
node-version: 20.11.0 # Use newer version to build the standalone binary
- run: yarn install --immutable
- run: yarn build
- name: Create standalone binary
run: yarn dist-standalone -t node14-macos-x64 -o datadog-ci_darwin-x64
- name: Remove dist and src folder to check that binary can stand alone
run: |
rm -rf dist
rm -rf src
- name: Test generated standalone binary
run: yarn dist-standalone:test
standalone-binary-test-macos-arm:
name: Test standalone binary in ARM macOS
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- name: Install node
uses: actions/setup-node@v4
with:
node-version: 20.11.0 # Use newer version to build the standalone binary
- run: yarn install --immutable
- run: yarn build
- name: Create standalone binary
run: yarn dist-standalone -t node14-macos-arm64 -o datadog-ci_darwin-arm64
- name: Remove dist and src folder to check that binary can stand alone
run: |
rm -rf dist
rm -rf src
- name: Test generated standalone binary
run: yarn dist-standalone:test
datadog-static-analyzer:
runs-on: ubuntu-latest
name: Static Analyzer - Diff Aware
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Run Datadog static analyzer
id: datadog-static-analysis
uses: DataDog/datadog-static-analyzer-github-action@main
with:
dd_app_key: ${{ secrets.DATADOG_APP_KEY_MAIN_ACCOUNT }}
dd_api_key: ${{ secrets.DATADOG_API_KEY_MAIN_ACCOUNT }}
dd_service: 'datadog-ci'
dd_env: 'ci'
cpu_count: 2
diff_aware: true
datadog-static-analyzer-non-diff-aware:
runs-on: ubuntu-latest
name: Static Analyzer - Non Diff Aware
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Run Datadog static analyzer
id: datadog-static-analysis
uses: DataDog/datadog-static-analyzer-github-action@main
with:
dd_app_key: ${{ secrets.DATADOG_APP_KEY_MAIN_ACCOUNT }}
dd_api_key: ${{ secrets.DATADOG_API_KEY_MAIN_ACCOUNT }}
dd_service: 'datadog-ci'
dd_env: 'ci-no-da'
cpu_count: 2
diff_aware: false
check-licenses:
name: Check licenses
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install node
uses: actions/setup-node@v4
with:
node-version: 14.18.3
# The install step has been added here such that the `.yarn/install-state.gz` file is generated. This file is used
# by the script `check-licenses` below.
- run: yarn install --immutable
- run: yarn check-licenses