-
Notifications
You must be signed in to change notification settings - Fork 7
319 lines (268 loc) · 9.87 KB
/
main.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
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
name: Main
on:
push:
tags: "v[0-9]+.[0-9]+.[0-9]+"
branches: "main"
pull_request:
branches: "*"
schedule:
# every Monday at 3:30 AM
- cron: "30 3 * * 1"
env:
TEST_VERBOSITY: 2
jobs:
license-check:
name: License check
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
persist-credentials: false
- name: License check
run: make license-check
lint-check:
name: Code lint check
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
persist-credentials: false
- name: Setup Python
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5
with:
python-version: "3.13"
- name: Install dependencies
run: make prereq
- name: Lint
run: make lint
unit-tests:
name: Unit tests (${{ matrix.os }}/py-${{ matrix.python-version }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
stack-version: ["8.2.0"]
schema-uri: ["./etc/ecs-v8.2.1.tar.gz"]
python-version: ["3.8", "3.13"]
os: ["ubuntu-latest", "macos-latest"]
steps:
- name: Checkout code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
persist-credentials: false
- name: Setup Python
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: make prereq
- name: Run unit tests
env:
TEST_STACK_VERSION: ${{ matrix.stack-version }}
TEST_SCHEMA_URI: ${{ matrix.schema-uri }}
TEST_DETECTION_RULES_URI: "https://epr.elastic.co/search?package=security_detection_engine&kibana.version=${{ matrix.stack-version }}"
run: make tests
online-tests:
name: Online tests (${{ matrix.stack-version }})
runs-on: "ubuntu-latest"
needs:
- unit-tests
strategy:
fail-fast: false
matrix:
include:
- stack-version: 8.17.0
schema-uri: "./etc/ecs-v8.16.0.tar.gz"
- stack-version: 8.16.0
schema-uri: "./etc/ecs-v8.16.0.tar.gz"
- stack-version: 8.15.0
schema-uri: "./etc/ecs-v8.11.0.tar.gz"
- stack-version: 8.14.0
schema-uri: "./etc/ecs-v8.11.0.tar.gz"
- stack-version: 8.13.0
schema-uri: "./etc/ecs-v8.11.0.tar.gz"
- stack-version: 8.12.0
schema-uri: "./etc/ecs-v8.11.0.tar.gz"
- stack-version: 8.11.0
schema-uri: "./etc/ecs-v8.11.0.tar.gz"
- stack-version: 8.10.1
schema-uri: "./etc/ecs-v8.10.0.tar.gz"
- stack-version: 8.9.0
schema-uri: "./etc/ecs-v8.9.0.tar.gz"
- stack-version: 8.8.0
schema-uri: "./etc/ecs-v8.8.0.tar.gz"
- stack-version: 8.7.0
schema-uri: "./etc/ecs-v8.7.0.tar.gz"
- stack-version: 8.6.0
schema-uri: "./etc/ecs-v8.6.1.tar.gz"
- stack-version: 8.5.0
schema-uri: "./etc/ecs-v8.5.2.tar.gz"
- stack-version: 8.4.0
schema-uri: "./etc/ecs-v8.4.0.tar.gz"
- stack-version: 8.3.0
schema-uri: "./etc/ecs-v8.3.1.tar.gz"
- stack-version: 8.2.0
schema-uri: "./etc/ecs-v8.2.1.tar.gz"
env:
TEST_ELASTICSEARCH_URL: "http://elastic:changeme@localhost:29650"
TEST_KIBANA_URL: "http://elastic:changeme@localhost:65290"
steps:
- name: Checkout code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
persist-credentials: false
- name: Setup Python
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5
with:
python-version: "3.8"
- name: Install dependencies
run: make prereq
- name: Setup cache
id: elastic-stack-cache
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4
with:
key: elastic-stack-cache-${{ matrix.stack-version }}
path: ~/elastic-stack-cache
- name: Reuse Elastic Stack ${{ matrix.stack-version }} Docker images
if: steps.elastic-stack-cache.outputs.cache-hit == 'true'
run: |
docker load -i ~/elastic-stack-cache/elasticsearch-${{ matrix.stack-version }}.tar
docker load -i ~/elastic-stack-cache/kibana-${{ matrix.stack-version }}.tar
- name: Pull Elastic Stack ${{ matrix.stack-version }} Docker images
if: steps.elastic-stack-cache.outputs.cache-hit != 'true'
env:
TEST_STACK_VERSION: ${{ matrix.stack-version }}
run: |
mkdir ~/elastic-stack-cache
docker compose pull -q
docker save -o ~/elastic-stack-cache/elasticsearch-${{ matrix.stack-version }}.tar \
docker.elastic.co/elasticsearch/elasticsearch:${{ matrix.stack-version }}
docker save -o ~/elastic-stack-cache/kibana-${{ matrix.stack-version }}.tar \
docker.elastic.co/kibana/kibana:${{ matrix.stack-version }}
- name: Start Elastic Stack ${{ matrix.stack-version }}
env:
TEST_STACK_VERSION: ${{ matrix.stack-version }}
run: make up
- name: Run online tests
env:
TEST_STACK_VERSION: ${{ matrix.stack-version }}
TEST_SCHEMA_URI: ${{ matrix.schema-uri }}
TEST_SIGNALS_QUERIES: 1
TEST_SIGNALS_RULES: 1
run: make online-tests
- name: Explain shards allocation
if: always()
run: curl -s $TEST_ELASTICSEARCH_URL/_cat/shards?v
- name: Print Stack logs
if: always()
run: docker compose logs
- name: Stop Elastic Stack ${{ matrix.stack-version }}
if: always()
run: |
docker logs geneve-test-es-1 >es-${{ matrix.stack-version }}.log
docker logs geneve-test-kbn-1 >kbn-${{ matrix.stack-version }}.log
make down
- name: Upload logs
if: always()
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4
with:
name: logs-${{ matrix.stack-version }}
path: |
es-*.log
kbn-*.log
- name: Upload reports
if: always()
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4
with:
name: test-reports-${{ matrix.stack-version }}
path: tests/reports/*.new.md
package-build:
name: Package build (${{ matrix.os }}/py-${{ matrix.python-version }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.13"]
os: ["ubuntu-latest", "macos-latest"]
steps:
- name: Checkout code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
persist-credentials: false
- name: Setup Python
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: make prereq
- name: Check versions
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
run: "set -x; [ \"${{ github.ref }}\" = \"refs/tags/v$(python3 -c 'import geneve; print(geneve.version)')\" ]"
- name: Build package
run: make package
- name: Upload artifacts
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4
with:
name: python-package-${{ matrix.python-version }}-${{ matrix.os }}
path: dist/*
package-tests:
name: Package tests (${{ matrix.os }}/py-${{ matrix.python-version }})
runs-on: ${{ matrix.os }}
needs: package-build
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.13"]
os: ["ubuntu-latest", "macos-latest"]
steps:
- name: Checkout code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
path: code
- name: Setup Python
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5
with:
python-version: ${{ matrix.python-version }}
- name: Download artifacts
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4
with:
name: python-package-${{ matrix.python-version }}-${{ matrix.os }}
path: dist
- name: Install package
run: make -f code/Makefile pkg-install
publish:
name: Publish
runs-on: ubuntu-latest
needs:
- license-check
- lint-check
- unit-tests
- online-tests
- package-tests
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
steps:
- name: Setup Python
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5
with:
python-version: "3.8"
- name: Download artifacts
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4
with:
name: python-package-3.8-ubuntu-latest
path: dist
- name: Publish to TestPyPI
uses: pypa/gh-action-pypi-publish@67339c736fd9354cd4f8cb0b744f2b82a74b5c70 # v1.12.3
if: github.repository != 'elastic/geneve'
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
print_hash: true
repository_url: https://test.pypi.org/legacy/
skip_existing: true
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@67339c736fd9354cd4f8cb0b744f2b82a74b5c70 # v1.12.3
if: github.repository == 'elastic/geneve'
with:
password: ${{ secrets.PYPI_API_TOKEN }}
print_hash: true