|
| 1 | +name: Continuous Integration |
| 2 | +on: |
| 3 | + pull_request: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + - "releases/*" |
| 8 | + |
| 9 | +env: |
| 10 | + COLUMNS: 120 |
| 11 | + |
| 12 | +jobs: |
| 13 | + # Build and test the project |
| 14 | + build-lint-test: |
| 15 | + timeout-minutes: 30 |
| 16 | + strategy: |
| 17 | + fail-fast: false |
| 18 | + matrix: |
| 19 | + python: ["3.9", "3.13"] |
| 20 | + os: [ubuntu-latest, ubuntu-arm, macos-intel, macos-arm, windows-latest] |
| 21 | + include: |
| 22 | + # On 3.9 there is a problem with import errors caused by pytests' loader that surface due |
| 23 | + # to a bug in CPython (https://github.com/python/cpython/issues/91351), so we avoid using |
| 24 | + # the assert rewriter. |
| 25 | + - python: "3.9" |
| 26 | + pytestExtraArgs: "--assert=plain" |
| 27 | + - os: ubuntu-latest |
| 28 | + python: "3.13" |
| 29 | + docsTarget: true |
| 30 | + cloudTestTarget: true |
| 31 | + openaiTestTarget: true |
| 32 | + clippyLinter: true |
| 33 | + - os: ubuntu-latest |
| 34 | + python: "3.9" |
| 35 | + protoCheckTarget: true |
| 36 | + - os: ubuntu-arm |
| 37 | + runsOn: ubuntu-24.04-arm64-2-core |
| 38 | + - os: macos-intel |
| 39 | + runsOn: macos-13 |
| 40 | + # On 3.13.3 there is some issue with macOS intel where it hangs after pytest with some |
| 41 | + # test that may have a worker that cannot properly shutdown, but it does not occur on |
| 42 | + # other versions, platforms, etc. See https://github.com/temporalio/sdk-python/issues/834. |
| 43 | + - os: macos-intel |
| 44 | + python: "3.13" |
| 45 | + pythonOverride: "3.13.2" |
| 46 | + - os: macos-arm |
| 47 | + runsOn: macos-latest |
| 48 | + # On 3.13.5, python3.lib is missing for the linker |
| 49 | + - os: windows-latest |
| 50 | + python: "3.13" |
| 51 | + pythonOverride: "3.13.4" |
| 52 | + runs-on: ${{ matrix.runsOn || matrix.os }} |
| 53 | + steps: |
| 54 | + - uses: actions/checkout@v4 |
| 55 | + with: |
| 56 | + submodules: recursive |
| 57 | + - uses: dtolnay/rust-toolchain@stable |
| 58 | + - uses: Swatinem/rust-cache@v2 |
| 59 | + with: |
| 60 | + workspaces: temporalio/bridge -> target |
| 61 | + - uses: actions/setup-python@v5 |
| 62 | + with: |
| 63 | + python-version: ${{ matrix.pythonOverride || matrix.python }} |
| 64 | + - uses: arduino/setup-protoc@v3 |
| 65 | + with: |
| 66 | + # TODO(cretz): Can upgrade proto when https://github.com/arduino/setup-protoc/issues/99 fixed |
| 67 | + version: "23.x" |
| 68 | + repo-token: ${{ secrets.GITHUB_TOKEN }} |
| 69 | + - uses: astral-sh/setup-uv@v5 |
| 70 | + - run: uv tool install poethepoet |
| 71 | + - run: uv sync --all-extras |
| 72 | + - run: poe bridge-lint |
| 73 | + if: ${{ matrix.clippyLinter }} |
| 74 | + - run: poe lint |
| 75 | + - run: poe build-develop |
| 76 | + - run: mkdir junit-xml |
| 77 | + - run: poe test ${{matrix.pytestExtraArgs}} -s --junit-xml=junit-xml/${{ matrix.python }}--${{ matrix.os }}.xml |
| 78 | + timeout-minutes: 15 |
| 79 | + # Time skipping doesn't yet support ARM |
| 80 | + - if: ${{ !endsWith(matrix.os, '-arm') }} |
| 81 | + run: poe test ${{matrix.pytestExtraArgs}} -s --workflow-environment time-skipping --junit-xml=junit-xml/${{ matrix.python }}--${{ matrix.os }}--time-skipping.xml |
| 82 | + timeout-minutes: 10 |
| 83 | + # Check cloud if proper target and not on fork |
| 84 | + - if: ${{ matrix.cloudTestTarget && (github.event.pull_request.head.repo.full_name == '' || github.event.pull_request.head.repo.full_name == 'temporalio/sdk-python') }} |
| 85 | + run: poe test ${{matrix.pytestExtraArgs}} -s -k test_cloud_client --junit-xml=junit-xml/${{ matrix.python }}--${{ matrix.os }}--cloud.xml |
| 86 | + timeout-minutes: 10 |
| 87 | + env: |
| 88 | + TEMPORAL_CLIENT_CLOUD_API_KEY: ${{ secrets.TEMPORAL_CLIENT_CLOUD_API_KEY }} |
| 89 | + TEMPORAL_CLIENT_CLOUD_API_VERSION: 2024-05-13-00 |
| 90 | + TEMPORAL_CLIENT_CLOUD_NAMESPACE: sdk-ci.a2dd6 |
| 91 | + - if: ${{ matrix.openaiTestTarget && (github.event.pull_request.head.repo.full_name == '' || github.event.pull_request.head.repo.full_name == 'temporalio/sdk-python') }} |
| 92 | + run: poe test tests/contrib/openai_agents/test_openai.py ${{matrix.pytestExtraArgs}} -s --junit-xml=junit-xml/${{ matrix.python }}--${{ matrix.os }}--openai.xml |
| 93 | + timeout-minutes: 10 |
| 94 | + env: |
| 95 | + OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} |
| 96 | + - name: "Upload junit-xml artifacts" |
| 97 | + uses: actions/upload-artifact@v4 |
| 98 | + if: always() |
| 99 | + with: |
| 100 | + name: junit-xml--${{github.run_id}}--${{github.run_attempt}}--${{ matrix.python }}--${{ matrix.os }} |
| 101 | + path: junit-xml |
| 102 | + retention-days: 14 |
| 103 | + |
| 104 | + # Confirm protos are already generated properly with older protobuf |
| 105 | + # library and run test with that older version. We must downgrade protobuf |
| 106 | + # so we can generate 3.x and 4.x compatible API. We have to use older |
| 107 | + # Python to run this check because the grpcio-tools version we use |
| 108 | + # is <= 3.10. |
| 109 | + - name: Check generated protos and test protobuf 3.x |
| 110 | + if: ${{ matrix.protoCheckTarget }} |
| 111 | + env: |
| 112 | + TEMPORAL_TEST_PROTO3: 1 |
| 113 | + run: | |
| 114 | + uv add --python 3.9 "protobuf<4" |
| 115 | + uv sync --all-extras |
| 116 | + poe build-develop |
| 117 | + poe gen-protos |
| 118 | + poe format |
| 119 | + [[ -z $(git status --porcelain temporalio) ]] || (git diff temporalio; echo "Protos changed"; exit 1) |
| 120 | + poe test -s |
| 121 | + timeout-minutes: 10 |
| 122 | + |
| 123 | + # Do docs stuff (only on one host) |
| 124 | + - name: Build API docs |
| 125 | + if: ${{ matrix.docsTarget }} |
| 126 | + run: poe gen-docs |
| 127 | + - name: Deploy prod API docs |
| 128 | + if: ${{ github.ref == 'refs/heads/main' && matrix.docsTarget }} |
| 129 | + env: |
| 130 | + VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} |
| 131 | + VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} |
| 132 | + run: npx vercel deploy build/apidocs -t ${{ secrets.VERCEL_TOKEN }} --prod --yes |
| 133 | + |
| 134 | + # Confirm README ToC is generated properly |
| 135 | + - uses: actions/setup-node@v4 |
| 136 | + - name: Check generated README ToC |
| 137 | + if: ${{ matrix.docsTarget }} |
| 138 | + run: | |
| 139 | + npx doctoc README.md |
| 140 | + [[ -z $(git status --porcelain README.md) ]] || (git diff README.md; echo "README changed"; exit 1) |
| 141 | + test-latest-deps: |
| 142 | + timeout-minutes: 30 |
| 143 | + runs-on: ubuntu-latest |
| 144 | + steps: |
| 145 | + - uses: actions/checkout@v4 |
| 146 | + with: |
| 147 | + submodules: recursive |
| 148 | + - uses: dtolnay/rust-toolchain@stable |
| 149 | + - uses: Swatinem/rust-cache@v2 |
| 150 | + with: |
| 151 | + workspaces: temporalio/bridge -> target |
| 152 | + - uses: actions/setup-python@v5 |
| 153 | + with: |
| 154 | + python-version: "3.13" |
| 155 | + - uses: arduino/setup-protoc@v3 |
| 156 | + with: |
| 157 | + # TODO(cretz): Can upgrade proto when https://github.com/arduino/setup-protoc/issues/99 fixed |
| 158 | + version: "23.x" |
| 159 | + repo-token: ${{ secrets.GITHUB_TOKEN }} |
| 160 | + - uses: astral-sh/setup-uv@v5 |
| 161 | + - run: uv tool install poethepoet |
| 162 | + - run: uv lock --upgrade |
| 163 | + - run: uv sync --all-extras |
| 164 | + - run: poe lint |
| 165 | + - run: poe build-develop |
| 166 | + - run: mkdir junit-xml |
| 167 | + - run: poe test -s --junit-xml=junit-xml/latest-deps.xml |
| 168 | + timeout-minutes: 10 |
| 169 | + - name: "Upload junit-xml artifacts" |
| 170 | + uses: actions/upload-artifact@v4 |
| 171 | + if: always() |
| 172 | + with: |
| 173 | + name: junit-xml--${{github.run_id}}--${{github.run_attempt}}--latest-deps--time-skipping |
| 174 | + path: junit-xml |
| 175 | + retention-days: 14 |
| 176 | + |
| 177 | + # Runs the sdk features repo tests with this repo's current SDK code |
| 178 | + features-tests: |
| 179 | + uses: temporalio/features/.github/workflows/python.yaml@main |
| 180 | + with: |
| 181 | + python-repo-path: ${{github.event.pull_request.head.repo.full_name}} |
| 182 | + version: ${{github.event.pull_request.head.ref}} |
| 183 | + version-is-repo-ref: true |
0 commit comments