openai/openai-python
Publicmirrored from https://github.com/openai/openai-pythonAvailable
.github/workflows/ci.yml
152lines · 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: Set up uv |
| 27 | uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # setup-uv v8.1.0; uv 0.11.8 |
| 28 | with: |
| 29 | version: "0.11.8" |
| 30 | enable-cache: true |
| 31 | |
| 32 | - name: Set up Python |
| 33 | run: uv python install |
| 34 | |
| 35 | - name: Install dependencies |
| 36 | run: uv sync --locked --all-extras --group dev |
| 37 | |
| 38 | - name: Run lints |
| 39 | run: ./scripts/lint |
| 40 | |
| 41 | build: |
| 42 | if: (github.event_name == 'push' || github.event.pull_request.head.repo.fork) && (github.event_name != 'push' || github.event.head_commit.message != 'codegen metadata') |
| 43 | timeout-minutes: 10 |
| 44 | name: build |
| 45 | permissions: |
| 46 | contents: read |
| 47 | id-token: write |
| 48 | runs-on: ${{ github.repository == 'stainless-sdks/openai-python' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} |
| 49 | steps: |
| 50 | - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 |
| 51 | |
| 52 | - name: Set up uv |
| 53 | uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # setup-uv v8.1.0; uv 0.11.8 |
| 54 | with: |
| 55 | version: "0.11.8" |
| 56 | enable-cache: true |
| 57 | |
| 58 | - name: Set up Python |
| 59 | run: uv python install |
| 60 | |
| 61 | - name: Install dependencies |
| 62 | run: uv sync --locked --all-extras --group dev |
| 63 | |
| 64 | - name: Run build |
| 65 | run: uv build |
| 66 | |
| 67 | - name: Get GitHub OIDC Token |
| 68 | if: |- |
| 69 | github.repository == 'stainless-sdks/openai-python' && |
| 70 | !startsWith(github.ref, 'refs/heads/stl/') |
| 71 | id: github-oidc |
| 72 | uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8 |
| 73 | with: |
| 74 | script: core.setOutput('github_token', await core.getIDToken()); |
| 75 | |
| 76 | - name: Upload tarball |
| 77 | if: |- |
| 78 | github.repository == 'stainless-sdks/openai-python' && |
| 79 | !startsWith(github.ref, 'refs/heads/stl/') |
| 80 | env: |
| 81 | URL: https://pkg.stainless.com/s |
| 82 | AUTH: ${{ steps.github-oidc.outputs.github_token }} |
| 83 | SHA: ${{ github.sha }} |
| 84 | run: ./scripts/utils/upload-artifact.sh |
| 85 | |
| 86 | test: |
| 87 | timeout-minutes: 10 |
| 88 | name: test |
| 89 | runs-on: ${{ github.repository == 'stainless-sdks/openai-python' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} |
| 90 | if: github.event_name == 'push' || github.event.pull_request.head.repo.fork |
| 91 | steps: |
| 92 | - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 |
| 93 | |
| 94 | - name: Set up pnpm |
| 95 | uses: pnpm/action-setup@903f9c1a6ebcba6cf41d87230be49611ac97822e # pnpm/action-setup v6.0.3 |
| 96 | with: |
| 97 | run_install: false |
| 98 | |
| 99 | - name: Set up Node |
| 100 | uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # setup-node v6.4.0 |
| 101 | with: |
| 102 | node-version-file: .node-version |
| 103 | cache: pnpm |
| 104 | cache-dependency-path: pnpm-lock.yaml |
| 105 | |
| 106 | - name: Set up uv |
| 107 | uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # setup-uv v8.1.0; uv 0.11.8 |
| 108 | with: |
| 109 | version: "0.11.8" |
| 110 | enable-cache: true |
| 111 | |
| 112 | - name: Set up Python |
| 113 | run: uv python install |
| 114 | |
| 115 | - name: Install Python dependencies |
| 116 | run: uv sync --locked --all-extras --group dev |
| 117 | |
| 118 | - name: Install steady CLI |
| 119 | run: pnpm install --frozen-lockfile |
| 120 | |
| 121 | - name: Run tests |
| 122 | run: ./scripts/test |
| 123 | |
| 124 | examples: |
| 125 | timeout-minutes: 10 |
| 126 | name: examples |
| 127 | runs-on: ${{ github.repository == 'stainless-sdks/openai-python' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} |
| 128 | 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') |
| 129 | |
| 130 | steps: |
| 131 | - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 |
| 132 | |
| 133 | - name: Set up uv |
| 134 | uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # setup-uv v8.1.0; uv 0.11.8 |
| 135 | with: |
| 136 | version: "0.11.8" |
| 137 | enable-cache: true |
| 138 | |
| 139 | - name: Set up Python |
| 140 | run: uv python install |
| 141 | |
| 142 | - name: Install dependencies |
| 143 | run: uv sync --locked --all-extras --group dev |
| 144 | |
| 145 | - env: |
| 146 | OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} |
| 147 | run: | |
| 148 | uv run python examples/demo.py |
| 149 | - env: |
| 150 | OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} |
| 151 | run: | |
| 152 | uv run python examples/async_demo.py |