-
Notifications
You must be signed in to change notification settings - Fork 247
291 lines (243 loc) · 9.19 KB
/
Copy pathci.yml
File metadata and controls
291 lines (243 loc) · 9.19 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
name: CI
on:
push:
branches:
- main
- next
pull_request:
branches:
- main
- next
workflow_dispatch:
permissions:
contents: read
concurrency:
group: ci-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
lint:
name: CI / lint
runs-on: ${{ vars.SDK_GHA_RUNNER || 'ubuntu-24.04' }}
timeout-minutes: 15
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
persist-credentials: false
- name: Set up Java
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5
with:
distribution: temurin
java-version: |
8
21
- name: Set up Gradle
uses: gradle/actions/setup-gradle@0723195856401067f7a2779048b490ace7a47d7c # v5.0.2
- name: Run lints
run: ./scripts/lint
build:
name: CI / build + Jackson compatibility
runs-on: ${{ vars.SDK_GHA_RUNNER || 'ubuntu-24.04' }}
timeout-minutes: 30
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
persist-credentials: false
- name: Set up Java
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5
with:
distribution: temurin
java-version: |
8
21
- name: Set up Gradle
uses: gradle/actions/setup-gradle@0723195856401067f7a2779048b490ace7a47d7c # v5.0.2
- name: Build SDK and run compatibility tests
env:
GRADLE_OPTS: -Dkotlin.compiler.execution.strategy=in-process
run: ./scripts/build
- name: Collect exact-run Gradle build cache
env:
CACHE_ARTIFACT_PATH: ${{ runner.temp }}/ci-gradle-build-cache
GRADLE_OPTS: -Dkotlin.compiler.execution.strategy=in-process
run: ./scripts/collect-gradle-build-cache "$CACHE_ARTIFACT_PATH"
# setup-gradle's cross-run cache is read-only on pull requests. Publish this run's local
# build cache explicitly so downstream jobs can restore the exact compilation that passed.
- name: Upload exact-run Gradle build cache
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: ci-gradle-build-cache-${{ github.run_id }}
path: ${{ runner.temp }}/ci-gradle-build-cache
if-no-files-found: error
retention-days: 1
compression-level: 0
overwrite: true
test:
name: CI / tests
runs-on: ${{ vars.SDK_GHA_RUNNER || 'ubuntu-24.04' }}
timeout-minutes: 30
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
persist-credentials: false
- name: Set up Java
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5
with:
distribution: temurin
java-version: |
8
21
- name: Set up Gradle
uses: gradle/actions/setup-gradle@0723195856401067f7a2779048b490ace7a47d7c # v5.0.2
- name: Run tests
run: ./scripts/test
api_compatibility:
name: CI / API compatibility
needs: build
if: >-
needs.build.result == 'success' &&
github.event_name == 'pull_request'
permissions:
contents: read
pull-requests: read
runs-on: ${{ vars.SDK_GHA_RUNNER || 'ubuntu-24.04' }}
timeout-minutes: 20
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
fetch-depth: 0
persist-credentials: false
- name: Set up Java
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5
with:
distribution: temurin
java-version: |
8
21
- name: Set up Gradle
uses: gradle/actions/setup-gradle@0723195856401067f7a2779048b490ace7a47d7c # v5.0.2
with:
cache-read-only: true
- name: Restore exact-run Gradle build cache
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: ci-gradle-build-cache-${{ github.run_id }}
path: ~/.gradle/caches/build-cache-1
- name: Compile previous tests against the proposed SDK
env:
BASE_COMMIT: ${{ github.event.pull_request.base.sha }}
GRADLE_OPTS: -Dkotlin.compiler.execution.strategy=in-process
run: |
set -euo pipefail
# The proposed detector verifies the current compatibility policy. Running the baseline
# detector as well prevents a PR from weakening that policy to hide an SDK break.
./scripts/detect-breaking-changes "$BASE_COMMIT"
BASE_DETECTOR="$(mktemp ./scripts/detect-breaking-changes.baseline.XXXXXX)"
trap 'rm -f "$BASE_DETECTOR"' EXIT
git show "${BASE_COMMIT}:scripts/detect-breaking-changes" > "$BASE_DETECTOR"
chmod +x "$BASE_DETECTOR"
"$BASE_DETECTOR" "$BASE_COMMIT"
version_support_matrix:
name: CI / version support matrix
runs-on: ${{ vars.SDK_GHA_RUNNER || 'ubuntu-24.04' }}
timeout-minutes: 5
outputs:
runtime-matrix: ${{ steps.matrix.outputs.runtime-matrix }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
persist-credentials: false
- name: Set up Java
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5
with:
distribution: temurin
java-version: 21
- name: Set up Gradle
uses: gradle/actions/setup-gradle@0723195856401067f7a2779048b490ace7a47d7c # v5.0.2
- name: Read version support policy
id: matrix
run: |
./scripts/gradle generateVersionSupportMatrix -PversionSupportMatrix=pull-request
echo "runtime-matrix=$(< build/version-support-matrix.json)" >> "$GITHUB_OUTPUT"
runtime_compatibility:
name: CI / runtime compatibility / Java ${{ matrix.java }}
needs:
- build
- version_support_matrix
if: >-
always() &&
needs.version_support_matrix.result == 'success' &&
needs.build.result == 'success'
runs-on: ${{ vars.SDK_GHA_RUNNER || 'ubuntu-24.04' }}
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
java: ${{ fromJSON(needs.version_support_matrix.outputs.runtime-matrix) }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
persist-credentials: false
- name: Set up consumer Java
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5
with:
distribution: temurin
java-version: ${{ matrix.java }}
- name: Set up build Java
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5
with:
distribution: temurin
java-version: 21
- name: Set up Gradle
uses: gradle/actions/setup-gradle@0723195856401067f7a2779048b490ace7a47d7c # v5.0.2
with:
cache-read-only: ${{ needs.build.result == 'success' }}
- name: Restore exact-run Gradle build cache
if: needs.build.result == 'success'
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: ci-gradle-build-cache-${{ github.run_id }}
path: ~/.gradle/caches/build-cache-1
- name: Run consumer compatibility smoke test
env:
RUNTIME_JAVA_VERSION: ${{ matrix.java }}
run: >-
./scripts/gradle
:openai-java-runtime-compatibility:runRuntimeCompatibility
-PruntimeJavaVersion="$RUNTIME_JAVA_VERSION"
required:
name: CI / required
if: always()
needs:
- lint
- build
- test
- api_compatibility
- runtime_compatibility
runs-on: ${{ vars.SDK_GHA_RUNNER || 'ubuntu-24.04' }}
timeout-minutes: 5
steps:
- name: Verify required jobs succeeded
env:
EVENT_NAME: ${{ github.event_name }}
LINT_RESULT: ${{ needs.lint.result }}
BUILD_RESULT: ${{ needs.build.result }}
TEST_RESULT: ${{ needs.test.result }}
API_COMPATIBILITY_RESULT: ${{ needs.api_compatibility.result }}
RUNTIME_COMPATIBILITY_RESULT: ${{ needs.runtime_compatibility.result }}
run: |
set -euo pipefail
failed_jobs=()
[[ "$LINT_RESULT" == "success" ]] || failed_jobs+=("lint: $LINT_RESULT")
[[ "$BUILD_RESULT" == "success" ]] || failed_jobs+=("build: $BUILD_RESULT")
[[ "$TEST_RESULT" == "success" ]] || failed_jobs+=("test: $TEST_RESULT")
if [[ "$EVENT_NAME" == "pull_request" &&
"$API_COMPATIBILITY_RESULT" != "success" ]]; then
failed_jobs+=("API compatibility: $API_COMPATIBILITY_RESULT")
fi
[[ "$RUNTIME_COMPATIBILITY_RESULT" == "success" ]] ||
failed_jobs+=("runtime compatibility: $RUNTIME_COMPATIBILITY_RESULT")
if (( ${#failed_jobs[@]} > 0 )); then
printf 'Required CI job did not succeed: %s\n' "${failed_jobs[@]}"
exit 1
fi
echo "All required CI jobs succeeded."