Skip to content

Commit b883628

Browse files
committed
Add matrix job example workflow
Shows how to use unique labels (job-run_id-job-index) to prevent matrix jobs from competing for the same runner.
1 parent 3145cad commit b883628

1 file changed

Lines changed: 43 additions & 0 deletions

File tree

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Matrix Job Example for Modal GitHub Runner
2+
#
3+
# This workflow demonstrates how to run matrix jobs on Modal runners.
4+
#
5+
# IMPORTANT: Each matrix job needs a unique label to get its own runner.
6+
# Without unique labels, multiple matrix jobs compete for the same runner
7+
# and get stuck in "queued" state.
8+
#
9+
# The pattern: job-${{ github.run_id }}-${{ strategy.job-index }}
10+
# - github.run_id = unique per workflow run
11+
# - strategy.job-index = unique per matrix entry (0, 1, 2, ...)
12+
# Combined, they guarantee 1:1 binding between job and runner.
13+
14+
name: Matrix Example
15+
16+
on:
17+
workflow_dispatch:
18+
19+
jobs:
20+
test:
21+
runs-on:
22+
- self-hosted
23+
- modal
24+
- job-${{ github.run_id }}-${{ strategy.job-index }}
25+
timeout-minutes: 15
26+
27+
strategy:
28+
matrix:
29+
python-version: ["3.10", "3.11", "3.12"]
30+
31+
steps:
32+
- uses: actions/checkout@v4
33+
34+
- name: Set up Python ${{ matrix.python-version }}
35+
run: |
36+
python${{ matrix.python-version }} --version || true
37+
echo "Testing with Python ${{ matrix.python-version }}"
38+
39+
- name: Run tests
40+
run: |
41+
echo "Running tests on Python ${{ matrix.python-version }}"
42+
echo "Runner OS: $(uname -s)"
43+
echo "Runner arch: $(uname -m)"

0 commit comments

Comments
 (0)