Skip to content

Commit b8c80bb

Browse files
committed
Migrate unit test to be reusable
1 parent 3a5d9ac commit b8c80bb

2 files changed

Lines changed: 81 additions & 50 deletions

File tree

.github/workflows/ci-cd.yml

Lines changed: 6 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -81,57 +81,13 @@ jobs:
8181
run: python -m modal_global_objects.mounts.modal_client_package
8282

8383
client-test:
84-
name: Unit tests on ${{ matrix.python-version }} and ${{ matrix.os }} (protobuf=${{ matrix.proto-version }})
85-
timeout-minutes: 30
86-
87-
strategy:
88-
fail-fast: false # run all variants across python versions/os to completion
89-
matrix:
90-
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
91-
os: ["ubuntu-24.04"]
92-
proto-version: ["latest"]
93-
include:
94-
- os: "macos-15-intel" # x86-64
95-
python-version: "3.10"
96-
proto-version: "latest"
97-
- os: "macos-15" # ARM64 (M1)
98-
python-version: "3.10"
99-
proto-version: "latest"
100-
- os: "windows-latest"
101-
python-version: "3.10"
102-
proto-version: "latest"
103-
- os: "ubuntu-24.04"
104-
python-version: "3.10"
105-
proto-version: "3.20"
106-
107-
runs-on: ${{ matrix.os }}
108-
steps:
109-
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
110-
111-
- uses: ./.github/actions/setup-cached-python
112-
with:
113-
version: ${{ matrix.python-version }}
114-
115-
- if: matrix.proto-version != 'latest'
116-
name: Install protobuf
117-
run: pip install protobuf==${{ matrix.proto-version }}
118-
119-
- name: Build protobuf
120-
run: inv protoc
121-
122-
- name: Build client package (installs all dependencies)
123-
run: pip install -e .
124-
125-
- name: Run client tests
126-
run: inv test
84+
uses: ./github/workflows/unit_test.yml
85+
with:
86+
working_directory: "."
87+
secrets:
88+
MODAL_TOKEN_ID: ${{ secrets.MODAL_TOKEN_ID }}
89+
MODAL_TOKEN_SECRET: ${{ secrets.MODAL_TOKEN_ID }}
12790

128-
- name: Run docstring tests
129-
if: github.event.pull_request.head.repo.fork == false
130-
env:
131-
MODAL_ENVIRONMENT: client-doc-tests
132-
MODAL_TOKEN_ID: ${{ secrets.MODAL_TOKEN_ID }}
133-
MODAL_TOKEN_SECRET: ${{ secrets.MODAL_TOKEN_SECRET }}
134-
run: pytest -v --markdown-docs -m markdown-docs modal
13591

13692
container-dependencies:
13793
name: Check minimal container dependencies for ${{ matrix.python-version }} / ${{ matrix.image-builder-version }}

.github/workflows/unit_test.yml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: Unit tests
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
working_directory:
7+
required: true
8+
type: string
9+
secrets:
10+
MODAL_TOKEN_ID:
11+
required: true
12+
modal_token_secret:
13+
required: true
14+
15+
16+
concurrency:
17+
group: ${{ github.workflow }}-${{ github.ref }}
18+
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
19+
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+
steps:
46+
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
47+
48+
- uses: ${{ inputs.working_directory }}/.github/actions/setup-cached-python
49+
with:
50+
version: ${{ matrix.python-version }}
51+
52+
- if: matrix.proto-version != 'latest'
53+
name: Install protobuf
54+
run: uv pip install protobuf==${{ matrix.proto-version }}
55+
56+
- name: Build protobuf
57+
run: inv protoc
58+
working-directory: ${{ inputs.working_directory }}
59+
60+
- name: Build client package (installs all dependencies)
61+
run: uv pip install -e .
62+
working-directory: ${{ inputs.working_directory }}
63+
64+
- name: Run client tests
65+
run: inv test
66+
working-directory: ${{ inputs.working_directory }}
67+
68+
- name: Run docstring tests
69+
if: github.event.pull_request.head.repo.fork == false
70+
env:
71+
MODAL_ENVIRONMENT: client-doc-tests
72+
MODAL_TOKEN_ID: ${{ secrets.MODAL_TOKEN_ID }}
73+
MODAL_TOKEN_SECRET: ${{ secrets.MODAL_TOKEN_SECRET }}
74+
run: pytest -v --markdown-docs -m markdown-docs modal
75+
working-directory: ${{ inputs.working_directory }}

0 commit comments

Comments
 (0)