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