-
Notifications
You must be signed in to change notification settings - Fork 5
327 lines (281 loc) · 8.67 KB
/
build.yaml
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
name: Build and test
on:
push:
branches:
- master
tags:
- "v*"
pull_request:
branches:
- master
env:
# TODO: Allow to pass logging level as a variable
GRADLE_ARGS: ""
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
java-version: [11]
steps:
- uses: actions/checkout@v3
- name: Setup
uses: ./.github/setup
with:
java-version: ${{ matrix.java-version }}
- name: Load caches
uses: ./.github/cache
- name: Compile JVM
run: |
set -eux
./gradlew compileTestKotlinJvm $GRADLE_ARGS
- name: Compile native
run: |
set -eux
./gradlew linkDebugTestNative $GRADLE_ARGS
- name: Compile JS
run: |
set -eux
./gradlew compileTestKotlinJs $GRADLE_ARGS
- name: Compile samples
run: |
set -eux
./gradlew compileKotlinJvm compileKotlinNative -p samples $GRADLE_ARGS
- name: Upload build artifact
uses: ./.github/upload-artifact
unit-tests:
needs: build
if: |
!contains(github.event.head_commit.message, '[skip tests]')
runs-on: ubuntu-latest
strategy:
matrix:
java-version: [11]
steps:
- uses: actions/checkout@v3
- name: Setup
uses: ./.github/setup
with:
java-version: ${{ matrix.java-version }}
- name: Load caches
uses: ./.github/cache
- name: Download build artifact
uses: ./.github/download-artifact
- name: Run linter
run: |
set -eux
./gradlew detekt $GRADLE_ARGS
- name: Check ABI compatibility
run: |
set -eux
./gradlew apiCheck $GRADLE_ARGS
- name: Run unit tests
run: |
set -eux
./gradlew allTests -PshowPassedTests -x integ-tests:allTests $GRADLE_ARGS
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true
integ-tests:
needs: unit-tests
if: |
!contains(github.event.head_commit.message, '[skip tests]')
runs-on: ubuntu-latest
strategy:
matrix:
include:
- es-distribution: elasticsearch
es-major-version: 6
es-image: elasticsearch:6.8.23
es-url: http://localhost:9200
- es-distribution: elasticsearch
es-major-version: 7
es-image: elasticsearch:7.17.10
es-url: http://localhost:9200
- es-distribution: elasticsearch
es-major-version: 8
es-image: elasticsearch:8.7.1
es-url: https://localhost:9200
- es-distribution: opensearch
es-major-version: 2
es-image: opensearchproject/opensearch:2.4.0
es-url: https://localhost:9200
steps:
- uses: actions/checkout@v3
- name: Start Elasticsearch
run: |
set -eu
docker run -d \
--name elasticsearch \
-p 9200:9200 \
-e "discovery.type=single-node" \
-e "ES_JAVA_OPTS=-Xms128m -Xmx256m" \
--health-cmd="curl ${{ matrix.es-url }} --insecure" \
--health-interval=5s \
--health-timeout=2s \
--health-retries=10 \
${{ matrix.es-image }}
echo -n "Waiting Elasticsearch "
until [ $(docker inspect -f '{{.State.Health.Status}}' elasticsearch) == "healthy" ]; do
sleep 1
echo -n .
done
echo "ELASTIC_URL=http://localhost:9200" >> $GITHUB_ENV
- name: Setup Elasticsearch password
if: matrix.es-distribution == 'elasticsearch' && matrix.es-major-version >= 8
run: |
set -eu
ELASTIC_PASSWORD=$( \
docker exec elasticsearch \
/usr/share/elasticsearch/bin/elasticsearch-reset-password --batch -u elastic | \
awk 'BEGIN { FS=": "; } /^New value:/ { print $2; }' \
)
echo "ELASTIC_URL=https://localhost:9200" >> $GITHUB_ENV
echo "ELASTIC_USER=elastic" >> $GITHUB_ENV
echo "ELASTIC_PASSWORD=$ELASTIC_PASSWORD" >> $GITHUB_ENV
- name: Opensearch settings
if: matrix.es-distribution == 'opensearch'
run: |
set -eu
echo "ELASTIC_URL=https://localhost:9200" >> $GITHUB_ENV
echo "ELASTIC_USER=admin" >> $GITHUB_ENV
echo "ELASTIC_PASSWORD=admin" >> $GITHUB_ENV
- name: Setup
uses: ./.github/setup
with:
java-version: 11
- name: Load caches
uses: ./.github/cache
- name: Download build artifact
uses: ./.github/download-artifact
- name: Run integration tests
run: |
set -eux
# Allow self-signed certificates for JS engine: https://stackoverflow.com/a/66476468/473308
export NODE_TLS_REJECT_UNAUTHORIZED=0
export ELASTIC_URL='${{ env.ELASTIC_URL }}'
export ELASTIC_USER='${{ env.ELASTIC_USER }}'
export ELASTIC_PASSWORD='${{ env.ELASTIC_PASSWORD }}'
./gradlew :integ-tests:check -PshowPassedTests $GRADLE_ARGS
- name: Run samples JVM
run: |
set -eux
export ELASTIC_URL='${{ env.ELASTIC_URL }}'
export ELASTIC_USER='${{ env.ELASTIC_USER }}'
export ELASTIC_PASSWORD='${{ env.ELASTIC_PASSWORD }}'
./gradlew run -p samples $GRADLE_ARGS
- name: Run samples native
run: |
set -eux
export ELASTIC_URL='${{ env.ELASTIC_URL }}'
export ELASTIC_USER='${{ env.ELASTIC_USER }}'
export ELASTIC_PASSWORD='${{ env.ELASTIC_PASSWORD }}'
./gradlew runDebugExecutableNative -p samples $GRADLE_ARGS
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true
publish:
needs: integ-tests
if: |
always() &&
github.event_name == 'push' &&
startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup
uses: ./.github/setup
with:
java-version: 11
- name: Load caches
uses: ./.github/cache
- name: Download build artifact
uses: ./.github/download-artifact
- name: Prepare publishing
run: |
set -eux
echo '${{ secrets.SIGNING_KEY_CONTENT }}' | base64 -d > signing.gpg
- name: Publish
if: |
github.event_name == 'push' &&
startsWith(github.ref, 'refs/tags/v')
run: |
set -eux
./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository \
$GRADLE_ARGS \
-Psigning.secretKeyRingFile="$PWD/signing.gpg" \
-Psigning.keyId='${{ secrets.SIGNING_KEY_ID }}' \
-Psigning.password='${{ secrets.SIGNING_KEY_PASSPHRASE }}' \
-PsonatypeUser='${{ secrets.SONATYPE_USER }}' \
-PsonatypePassword='${{ secrets.SONATYPE_PASSWORD }}'
docs:
needs: integ-tests
if: |
always() &&
!contains(github.event.head_commit.message, '[skip docs]')
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
# We need to fetch last tag for version
fetch-depth: 0
- name: Setup
uses: ./.github/setup
with:
java-version: 11
- name: Load caches
uses: ./.github/cache
- name: Download build artifact
uses: ./.github/download-artifact
- name: Build docs
run: |
set -eux
./gradlew mkdocsBuild $GRADLE_ARGS
./gradlew mkdocsVersionsFile $GRADLE_ARGS
- name: Review generated docs
run: |
set -eux
ls -l build/mkdocs
cat build/mkdocs/versions.json | jq
- name: Build API docs
run: ./gradlew dokkaHtmlMultiModule $GRADLE_ARGS
- name: Copy docs
if: |
github.event_name == 'push' && (
startsWith(github.ref, 'refs/tags/v') ||
github.ref == 'refs/heads/master' ||
github.ref == 'refs/heads/docs'
)
run: ./gradlew gitPublishCopy $GRADLE_ARGS
- name: Review publishing docs
run: |
set -eux
ls -l .gradle/gh-pages
cat .gradle/gh-pages/versions.json | jq
- name: Publish documentation
if: |
github.event_name == 'push' && (
startsWith(github.ref, 'refs/tags/v') ||
github.ref == 'refs/heads/master' ||
github.ref == 'refs/heads/docs'
)
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./.gradle/gh-pages
# keep_files: true
full_commit_message: Publish documentation for ${{ github.ref }}
cleanup:
if: always()
runs-on: ubuntu-latest
needs: [publish, docs]
steps:
- uses: geekyeggo/delete-artifact@v2
with:
name: Build
failOnError: false