-
Notifications
You must be signed in to change notification settings - Fork 212
162 lines (138 loc) · 4.82 KB
/
ci.yml
File metadata and controls
162 lines (138 loc) · 4.82 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
name: CI
on:
push:
branches:
- '**'
- '!integrated/**'
- '!stl-preview-head/**'
- '!stl-preview-base/**'
- '!generated'
- '!codegen/**'
- 'codegen/stl/**'
pull_request:
branches-ignore:
- 'stl-preview-head/**'
- 'stl-preview-base/**'
jobs:
lint:
timeout-minutes: 15
name: lint
runs-on: ${{ github.repository == 'stainless-sdks/openai-java' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
if: (github.event_name == 'push' || github.event.pull_request.head.repo.fork) && (github.event_name != 'push' || github.event.head_commit.message != 'codegen metadata')
steps:
- uses: actions/checkout@v6
- name: Set up Java
uses: actions/setup-java@v5
with:
distribution: temurin
java-version: |
8
21
cache: gradle
- name: Set up Gradle
uses: gradle/actions/setup-gradle@v4
- name: Run lints
run: ./scripts/lint
build:
timeout-minutes: 30
name: build
permissions:
contents: read
id-token: write
runs-on: ${{ github.repository == 'stainless-sdks/openai-java' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
if: (github.event_name == 'push' || github.event.pull_request.head.repo.fork) && (github.event_name != 'push' || github.event.head_commit.message != 'codegen metadata')
steps:
- uses: actions/checkout@v6
- name: Set up Java
uses: actions/setup-java@v5
with:
distribution: temurin
java-version: |
8
21
cache: gradle
- name: Set up Gradle
uses: gradle/actions/setup-gradle@v4
- name: Build SDK
# disable gradle daemon in CI because it is flakey
env:
GRADLE_OPTS: "-Dkotlin.compiler.execution.strategy=in-process"
run: ./scripts/build
- name: Build and upload Maven artifacts
if: |-
github.repository == 'stainless-sdks/openai-java' &&
!startsWith(github.ref, 'refs/heads/stl/')
env:
URL: https://pkg.stainless.com/s
SHA: ${{ github.sha }}
PROJECT: openai-java
run: |
set -euo pipefail
max_retries=5
attempt=1
while true; do
echo "Maven artifact upload attempt ${attempt}/${max_retries}"
oidc_response="$(curl -sSf \
-H "Authorization: bearer ${ACTIONS_ID_TOKEN_REQUEST_TOKEN}" \
"${ACTIONS_ID_TOKEN_REQUEST_URL}")"
github_token="$(printf '%s' "$oidc_response" | jq -er '.value')"
upload_log="$(mktemp)"
set +e
AUTH="$github_token" ./scripts/upload-artifacts 2>&1 | tee "$upload_log"
upload_status=${PIPESTATUS[0]}
set -e
if [ "$upload_status" -eq 0 ]; then
break
fi
if [ "$attempt" -lt "$max_retries" ] && \
grep -q "Failed to get valid signed URL" "$upload_log" && \
grep -q "GitHub JWT is missing or invalid\\." "$upload_log"; then
sleep_seconds=$((3 * (1 << (attempt - 1))))
echo "Retrying after fresh OIDC token due to transient GitHub JWT validation failure"
echo "Sleeping ${sleep_seconds}s before retry"
sleep "$sleep_seconds"
attempt=$((attempt + 1))
continue
fi
exit "$upload_status"
done
test:
timeout-minutes: 30
name: test
runs-on: ${{ github.repository == 'stainless-sdks/openai-java' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
if: github.event_name == 'push' || github.event.pull_request.head.repo.fork
steps:
- uses: actions/checkout@v6
- name: Set up Java
uses: actions/setup-java@v5
with:
distribution: temurin
java-version: |
8
21
cache: gradle
- name: Set up Gradle
uses: gradle/gradle-build-action@v2
- name: Run tests
run: ./scripts/test
examples:
timeout-minutes: 10
name: examples
runs-on: ${{ github.repository == 'stainless-sdks/openai-java' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
if: github.repository == 'openai/openai-java' && (github.event_name == 'push' || github.event.pull_request.head.repo.fork) && (github.event_name != 'push' || github.event.head_commit.message != 'codegen metadata')
steps:
- uses: actions/checkout@v6
- name: Set up Java
uses: actions/setup-java@v5
with:
distribution: temurin
java-version: |
8
21
cache: gradle
- name: Set up Gradle
uses: gradle/gradle-build-action@v2
- env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
run: |
./gradlew :openai-java-example:run