|
| 1 | +name: Unit tests |
| 2 | +on: |
| 3 | + workflow_call: |
| 4 | + inputs: |
| 5 | + working_directory: |
| 6 | + required: true |
| 7 | + type: string |
| 8 | + secrets: |
| 9 | + MODAL_TOKEN_ID: |
| 10 | + required: true |
| 11 | + MODAL_TOKEN_SECRET: |
| 12 | + required: true |
| 13 | + |
| 14 | +env: |
| 15 | + TERM: linux |
| 16 | + TERMINFO: /etc/terminfo |
| 17 | + PYTHONIOENCODING: utf-8 |
| 18 | + |
| 19 | +jobs: |
| 20 | + client-test: |
| 21 | + name: Unit tests on ${{ matrix.python-version }} and ${{ matrix.os }} (protobuf=${{ matrix.proto-version }}) |
| 22 | + timeout-minutes: 30 |
| 23 | + |
| 24 | + strategy: |
| 25 | + fail-fast: false # run all variants across python versions/os to completion |
| 26 | + matrix: |
| 27 | + python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"] |
| 28 | + os: ["ubuntu-24.04"] |
| 29 | + proto-version: ["latest"] |
| 30 | + include: |
| 31 | + - os: "macos-15-intel" # x86-64 |
| 32 | + python-version: "3.10" |
| 33 | + proto-version: "latest" |
| 34 | + - os: "macos-15" # ARM64 (M1) |
| 35 | + python-version: "3.10" |
| 36 | + proto-version: "latest" |
| 37 | + - os: "windows-latest" |
| 38 | + python-version: "3.10" |
| 39 | + proto-version: "latest" |
| 40 | + - os: "ubuntu-24.04" |
| 41 | + python-version: "3.10" |
| 42 | + proto-version: "3.20" |
| 43 | + |
| 44 | + runs-on: ${{ matrix.os }} |
| 45 | + defaults: |
| 46 | + run: |
| 47 | + working-directory: ${{ inputs.working_directory }} |
| 48 | + steps: |
| 49 | + - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3 |
| 50 | + |
| 51 | + - name: Install Python |
| 52 | + uses: actions/setup-python@8d9ed9ac5c53483de85588cdf95a591a75ab9f55 # v5 |
| 53 | + with: |
| 54 | + python-version: ${{ matrix.python-version }} |
| 55 | + |
| 56 | + - name: Setup uv with caching |
| 57 | + uses: astral-sh/setup-uv@85856786d1ce8acfbcc2f13a5f3fbd6b938f9f41 # v7.1.2 |
| 58 | + with: |
| 59 | + enable-cache: true |
| 60 | + version: "0.9.24" |
| 61 | + cache-dependency-glob: | |
| 62 | + ${{ inputs.working_directory }}/requirements.dev.txt |
| 63 | + ${{ inputs.working_directory }}/pyproject.toml |
| 64 | +
|
| 65 | + - name: Install Python packages |
| 66 | + shell: bash |
| 67 | + run: | |
| 68 | + uv pip install --system -r requirements.dev.txt |
| 69 | +
|
| 70 | + - if: matrix.proto-version != 'latest' |
| 71 | + name: Install protobuf |
| 72 | + run: pip install protobuf==${{ matrix.proto-version }} |
| 73 | + |
| 74 | + - name: Build protobuf |
| 75 | + run: inv protoc |
| 76 | + |
| 77 | + - name: Build client package (installs all dependencies) |
| 78 | + run: pip install -e . |
| 79 | + |
| 80 | + - name: Run client tests |
| 81 | + run: inv test |
| 82 | + |
| 83 | + - name: Run docstring tests |
| 84 | + if: github.event.pull_request.head.repo.fork == false |
| 85 | + env: |
| 86 | + MODAL_ENVIRONMENT: client-doc-tests |
| 87 | + MODAL_TOKEN_ID: ${{ secrets.MODAL_TOKEN_ID }} |
| 88 | + MODAL_TOKEN_SECRET: ${{ secrets.MODAL_TOKEN_SECRET }} |
| 89 | + run: pytest -v --markdown-docs -m markdown-docs modal |
| 90 | + |
| 91 | + container-dependencies: |
| 92 | + name: Check minimal container dependencies for ${{ matrix.python-version }} - ${{ matrix.image-builder-version }} |
| 93 | + runs-on: ubuntu-24.04 |
| 94 | + timeout-minutes: 4 |
| 95 | + strategy: |
| 96 | + matrix: |
| 97 | + include: |
| 98 | + - image-builder-version: "2024.04" |
| 99 | + python-version: "3.10" |
| 100 | + - image-builder-version: "2024.04" |
| 101 | + python-version: "3.12" |
| 102 | + - image-builder-version: "2024.10" |
| 103 | + python-version: "3.10" |
| 104 | + - image-builder-version: "2024.10" |
| 105 | + python-version: "3.13" |
| 106 | + - image-builder-version: "2025.06" |
| 107 | + python-version: "3.10" |
| 108 | + - image-builder-version: "2025.06" |
| 109 | + python-version: "3.14" |
| 110 | + |
| 111 | + defaults: |
| 112 | + run: |
| 113 | + working-directory: ${{ inputs.working_directory }} |
| 114 | + |
| 115 | + steps: |
| 116 | + - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3 |
| 117 | + |
| 118 | + - uses: actions/setup-python@8d9ed9ac5c53483de85588cdf95a591a75ab9f55 # v5 |
| 119 | + with: |
| 120 | + python-version: ${{ matrix.python-version }} |
| 121 | + |
| 122 | + - name: Install dependencies |
| 123 | + run: | |
| 124 | + pip install -r modal/builder/${{ matrix.image-builder-version }}.txt |
| 125 | + pip install synchronicity |
| 126 | +
|
| 127 | + - name: Compile protos |
| 128 | + run: | |
| 129 | + python -m venv venv |
| 130 | + source venv/bin/activate |
| 131 | + if [ "${{ matrix.python-version }}" == "3.10" ]; then |
| 132 | + pip install grpcio-tools==1.48.2 grpclib==0.4.7; |
| 133 | + elif [ "${{ matrix.python-version }}" == "3.12" ]; then |
| 134 | + pip install grpcio-tools==1.59.2 grpclib==0.4.7; |
| 135 | + elif [ "${{ matrix.python-version }}" == "3.13" ]; then |
| 136 | + pip install grpcio-tools==1.66.2 grpclib==0.4.7; |
| 137 | + elif [ "${{ matrix.python-version }}" == "3.14" ]; then |
| 138 | + pip install grpcio-tools==1.76.0 grpclib==0.4.9; |
| 139 | + fi |
| 140 | + python -m grpc_tools.protoc --python_out=. --grpclib_python_out=. --grpc_python_out=. -I . modal_proto/api.proto modal_proto/task_command_router.proto |
| 141 | + python -m grpc_tools.protoc --plugin=protoc-gen-modal-grpclib-python=protoc_plugin/plugin.py --modal-grpclib-python_out=. -I . modal_proto/api.proto |
| 142 | + deactivate |
| 143 | +
|
| 144 | + - name: Check entrypoint import |
| 145 | + run: | |
| 146 | + python -c 'import modal._container_entrypoint; import modal._runtime.asgi' |
| 147 | + if [ "${{ matrix.image-builder-version }}" == "2024.04" ]; then python -c 'import fastapi'; fi |
0 commit comments