openai/openai-python
Publicmirrored from https://github.com/openai/openai-pythonAvailable
.github/workflows/ci.yml
133lines · modecode
| 1 | name: CI |
| 2 | on: |
| 3 | push: |
| 4 | branches: |
| 5 | - '**' |
| 6 | - '!integrated/**' |
| 7 | - '!stl-preview-head/**' |
| 8 | - '!stl-preview-base/**' |
| 9 | - '!generated' |
| 10 | - '!codegen/**' |
| 11 | - 'codegen/stl/**' |
| 12 | pull_request: |
| 13 | branches-ignore: |
| 14 | - 'stl-preview-head/**' |
| 15 | - 'stl-preview-base/**' |
| 16 | |
| 17 | jobs: |
| 18 | lint: |
| 19 | timeout-minutes: 10 |
| 20 | name: lint |
| 21 | runs-on: ${{ github.repository == 'stainless-sdks/openai-python' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} |
| 22 | if: (github.event_name == 'push' || github.event.pull_request.head.repo.fork) && (github.event_name != 'push' || github.event.head_commit.message != 'codegen metadata') |
| 23 | steps: |
| 24 | - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 |
| 25 | |
| 26 | - name: Install Rye |
| 27 | run: | |
| 28 | curl -sSf https://rye.astral.sh/get | bash |
| 29 | echo "$HOME/.rye/shims" >> $GITHUB_PATH |
| 30 | env: |
| 31 | RYE_VERSION: '0.44.0' |
| 32 | RYE_INSTALL_OPTION: '--yes' |
| 33 | |
| 34 | - name: Install dependencies |
| 35 | run: rye sync --all-features |
| 36 | |
| 37 | - name: Run lints |
| 38 | run: ./scripts/lint |
| 39 | |
| 40 | build: |
| 41 | if: (github.event_name == 'push' || github.event.pull_request.head.repo.fork) && (github.event_name != 'push' || github.event.head_commit.message != 'codegen metadata') |
| 42 | timeout-minutes: 10 |
| 43 | name: build |
| 44 | permissions: |
| 45 | contents: read |
| 46 | id-token: write |
| 47 | runs-on: ${{ github.repository == 'stainless-sdks/openai-python' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} |
| 48 | steps: |
| 49 | - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 |
| 50 | |
| 51 | - name: Install Rye |
| 52 | run: | |
| 53 | curl -sSf https://rye.astral.sh/get | bash |
| 54 | echo "$HOME/.rye/shims" >> $GITHUB_PATH |
| 55 | env: |
| 56 | RYE_VERSION: '0.44.0' |
| 57 | RYE_INSTALL_OPTION: '--yes' |
| 58 | |
| 59 | - name: Install dependencies |
| 60 | run: rye sync --all-features |
| 61 | |
| 62 | - name: Run build |
| 63 | run: rye build |
| 64 | |
| 65 | - name: Get GitHub OIDC Token |
| 66 | if: |- |
| 67 | github.repository == 'stainless-sdks/openai-python' && |
| 68 | !startsWith(github.ref, 'refs/heads/stl/') |
| 69 | id: github-oidc |
| 70 | uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8 |
| 71 | with: |
| 72 | script: core.setOutput('github_token', await core.getIDToken()); |
| 73 | |
| 74 | - name: Upload tarball |
| 75 | if: |- |
| 76 | github.repository == 'stainless-sdks/openai-python' && |
| 77 | !startsWith(github.ref, 'refs/heads/stl/') |
| 78 | env: |
| 79 | URL: https://pkg.stainless.com/s |
| 80 | AUTH: ${{ steps.github-oidc.outputs.github_token }} |
| 81 | SHA: ${{ github.sha }} |
| 82 | run: ./scripts/utils/upload-artifact.sh |
| 83 | |
| 84 | test: |
| 85 | timeout-minutes: 10 |
| 86 | name: test |
| 87 | runs-on: ${{ github.repository == 'stainless-sdks/openai-python' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} |
| 88 | if: github.event_name == 'push' || github.event.pull_request.head.repo.fork |
| 89 | steps: |
| 90 | - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 |
| 91 | |
| 92 | - name: Install Rye |
| 93 | run: | |
| 94 | curl -sSf https://rye.astral.sh/get | bash |
| 95 | echo "$HOME/.rye/shims" >> $GITHUB_PATH |
| 96 | env: |
| 97 | RYE_VERSION: '0.44.0' |
| 98 | RYE_INSTALL_OPTION: '--yes' |
| 99 | |
| 100 | - name: Bootstrap |
| 101 | run: ./scripts/bootstrap |
| 102 | |
| 103 | - name: Run tests |
| 104 | run: ./scripts/test |
| 105 | |
| 106 | examples: |
| 107 | timeout-minutes: 10 |
| 108 | name: examples |
| 109 | runs-on: ${{ github.repository == 'stainless-sdks/openai-python' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} |
| 110 | if: github.repository == 'openai/openai-python' && (github.event_name == 'push' || github.event.pull_request.head.repo.fork) && (github.event_name != 'push' || github.event.head_commit.message != 'codegen metadata') |
| 111 | |
| 112 | steps: |
| 113 | - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 |
| 114 | |
| 115 | - name: Install Rye |
| 116 | run: | |
| 117 | curl -sSf https://rye.astral.sh/get | bash |
| 118 | echo "$HOME/.rye/shims" >> $GITHUB_PATH |
| 119 | env: |
| 120 | RYE_VERSION: '0.44.0' |
| 121 | RYE_INSTALL_OPTION: '--yes' |
| 122 | - name: Install dependencies |
| 123 | run: | |
| 124 | rye sync --all-features |
| 125 | |
| 126 | - env: |
| 127 | OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} |
| 128 | run: | |
| 129 | rye run python examples/demo.py |
| 130 | - env: |
| 131 | OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} |
| 132 | run: | |
| 133 | rye run python examples/async_demo.py |