openai/openai-java

Public

mirrored from https://github.com/openai/openai-javaAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v4.24.1

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

.github/workflows/ci.yml

158lines · modecode

1name: CI
2on:
3 push:
4 branches-ignore:
5 - 'generated'
6 - 'codegen/**'
7 - 'integrated/**'
8 - 'stl-preview-head/**'
9 - 'stl-preview-base/**'
10 pull_request:
11 branches-ignore:
12 - 'stl-preview-head/**'
13 - 'stl-preview-base/**'
14
15jobs:
16 lint:
17 timeout-minutes: 15
18 name: lint
19 runs-on: ${{ github.repository == 'stainless-sdks/openai-java' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
20 if: github.event_name == 'push' || github.event.pull_request.head.repo.fork
21
22 steps:
23 - uses: actions/checkout@v6
24
25 - name: Set up Java
26 uses: actions/setup-java@v5
27 with:
28 distribution: temurin
29 java-version: |
30 8
31 21
32 cache: gradle
33
34 - name: Set up Gradle
35 uses: gradle/actions/setup-gradle@v4
36
37 - name: Run lints
38 run: ./scripts/lint
39
40 build:
41 timeout-minutes: 30
42 name: build
43 permissions:
44 contents: read
45 id-token: write
46 runs-on: ${{ github.repository == 'stainless-sdks/openai-java' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
47 if: github.event_name == 'push' || github.event.pull_request.head.repo.fork
48
49 steps:
50 - uses: actions/checkout@v6
51
52 - name: Set up Java
53 uses: actions/setup-java@v5
54 with:
55 distribution: temurin
56 java-version: |
57 8
58 21
59 cache: gradle
60
61 - name: Set up Gradle
62 uses: gradle/actions/setup-gradle@v4
63
64 - name: Build SDK
65 # disable gradle daemon in CI because it is flakey
66 env:
67 GRADLE_OPTS: "-Dkotlin.compiler.execution.strategy=in-process"
68 run: ./scripts/build
69
70 - name: Build and upload Maven artifacts
71 if: github.repository == 'stainless-sdks/openai-java'
72 env:
73 URL: https://pkg.stainless.com/s
74 SHA: ${{ github.sha }}
75 PROJECT: openai-java
76 run: |
77 set -euo pipefail
78
79 max_retries=5
80 attempt=1
81
82 while true; do
83 echo "Maven artifact upload attempt ${attempt}/${max_retries}"
84
85 oidc_response="$(curl -sSf \
86 -H "Authorization: bearer ${ACTIONS_ID_TOKEN_REQUEST_TOKEN}" \
87 "${ACTIONS_ID_TOKEN_REQUEST_URL}")"
88 github_token="$(printf '%s' "$oidc_response" | jq -er '.value')"
89
90 upload_log="$(mktemp)"
91 set +e
92 AUTH="$github_token" ./scripts/upload-artifacts 2>&1 | tee "$upload_log"
93 upload_status=${PIPESTATUS[0]}
94 set -e
95
96 if [ "$upload_status" -eq 0 ]; then
97 break
98 fi
99
100 if [ "$attempt" -lt "$max_retries" ] && \
101 grep -q "Failed to get valid signed URL" "$upload_log" && \
102 grep -q "GitHub JWT is missing or invalid\\." "$upload_log"; then
103 sleep_seconds=$((3 * (1 << (attempt - 1))))
104 echo "Retrying after fresh OIDC token due to transient GitHub JWT validation failure"
105 echo "Sleeping ${sleep_seconds}s before retry"
106 sleep "$sleep_seconds"
107 attempt=$((attempt + 1))
108 continue
109 fi
110
111 exit "$upload_status"
112 done
113 test:
114 timeout-minutes: 30
115 name: test
116 runs-on: ${{ github.repository == 'stainless-sdks/openai-java' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
117 if: github.event_name == 'push' || github.event.pull_request.head.repo.fork
118 steps:
119 - uses: actions/checkout@v6
120
121 - name: Set up Java
122 uses: actions/setup-java@v5
123 with:
124 distribution: temurin
125 java-version: |
126 8
127 21
128 cache: gradle
129
130 - name: Set up Gradle
131 uses: gradle/gradle-build-action@v2
132
133 - name: Run tests
134 run: ./scripts/test
135 examples:
136 timeout-minutes: 10
137 name: examples
138 runs-on: ${{ github.repository == 'stainless-sdks/openai-java' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
139 if: github.repository == 'openai/openai-java' && (github.event_name == 'push' || github.event.pull_request.head.repo.fork)
140
141 steps:
142 - uses: actions/checkout@v6
143
144 - name: Set up Java
145 uses: actions/setup-java@v5
146 with:
147 distribution: temurin
148 java-version: |
149 8
150 21
151 cache: gradle
152 - name: Set up Gradle
153 uses: gradle/gradle-build-action@v2
154
155 - env:
156 OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
157 run: |
158 ./gradlew :openai-java-example:run
159