-
Notifications
You must be signed in to change notification settings - Fork 109
147 lines (130 loc) · 5.75 KB
/
Copy pathci-testing.yml
File metadata and controls
147 lines (130 loc) · 5.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
name: CI Testing
# see: https://help.github.com/en/actions/reference/events-that-trigger-workflows
on: # Trigger the workflow on push or pull request, but only for the main branch
push:
branches: [main]
pull_request:
branches: [main]
types: [opened, reopened, ready_for_review, synchronize]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.head_ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
defaults:
run:
shell: bash
jobs:
torch-support:
runs-on: ubuntu-latest
timeout-minutes: 5
# Keep the supported PyTorch versions in one place and share them with the
# test matrix so CI fails early when the policy and workflow drift apart.
outputs:
latest_spec: ${{ steps.policy.outputs.latest_spec }}
previous_spec: ${{ steps.policy.outputs.previous_spec }}
minimum_spec: ${{ steps.policy.outputs.minimum_spec }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Validate the PyTorch support policy
run: python3 .github/scripts/torch_support.py check
- name: Export the supported PyTorch versions
id: policy
run: python3 .github/scripts/torch_support.py export
pytester:
needs: torch-support
name: pytester (${{ matrix.os }}, ${{ matrix.python-version }}, torch ${{ matrix.torch-spec || needs.torch-support.outputs.latest_spec }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: ["ubuntu-22.04", "macos-14", "windows-2022"]
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
exclude:
- { os: "windows-2022", python-version: "3.13" }
- { os: "windows-2022", python-version: "3.14" }
# every combination tests the `latest` PyTorch from .github/torch-support.json; these entries
# merge into existing combinations (they add no jobs), switching two of them to `previous` and
# to the declared `minimum` — the floor sits on 3.10 because old torch has no newer wheels
include:
- os: "ubuntu-22.04"
python-version: "3.12"
torch-spec: "${{ needs.torch-support.outputs.previous_spec }}"
- os: "ubuntu-22.04"
python-version: "3.10"
torch-spec: "${{ needs.torch-support.outputs.minimum_spec }}"
# Timeout: https://stackoverflow.com/a/59076067/4521646
timeout-minutes: 60
env:
UV_TORCH_BACKEND: "cpu"
# Supply-chain guard: skip PyPI releases newer than this. See https://docs.astral.sh/uv/reference/settings/#exclude-newer
UV_EXCLUDE_NEWER: "2 days"
steps:
# FFmpeg is required for Video Deserializer tests
- name: Setup FFmpeg (shared libs, Linux)
if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get install -y ffmpeg
- name: Setup FFmpeg (shared libs, macOS)
if: runner.os == 'macOS'
run: brew install ffmpeg
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Install uv and setup python ${{ matrix.python-version }}
uses: astral-sh/setup-uv@c18668ad3cf93ea998bef934396af7bb5c839dc7 # v10.2.0
with:
activate-environment: true
python-version: ${{ matrix.python-version }}
enable-cache: true
- name: Install package & dependencies
env:
# the supported PyTorch this job tests, from .github/torch-support.json
TORCH_SPEC: ${{ matrix.torch-spec || needs.torch-support.outputs.latest_spec }}
run: |
test -n "${TORCH_SPEC}" || { echo "::error::TORCH_SPEC is empty, the torch-support job exported no spec"; exit 1; }
uv pip install -U lightning-sdk
uv pip install -e ".[extras]" -r requirements/test.txt "torch==${TORCH_SPEC}" -U -q
uv pip list
python -c "import torch; print('torch', torch.__version__)"
# torchcodec has no build for the oldest supported torch (it starts at 2.5), and uv installs a
# newer one that only fails on import; dropping it lets the video tests skip themselves instead
- name: Drop the video stack on the minimum-PyTorch job
if: matrix.torch-spec == needs.torch-support.outputs.minimum_spec
run: uv pip uninstall torchcodec
- name: Run fast tests in parallel
run: |
pytest tests \
--ignore=tests/processing \
--ignore=tests/raw \
-n 2 --dist=loadgroup --cov=litdata --durations=0 --timeout=120 --capture=no --verbose
- name: Run processing tests sequentially
run: |
# note that the listed test should match ignored in the previous step
pytest \
tests/processing tests/raw \
--cov=litdata --cov-append --durations=0 --timeout=120 --capture=no --verbose
- name: Statistics
continue-on-error: true
run: |
coverage report
coverage xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@303a32d7a59b442fa8d48b6a1cc6825c09c847a5 # v7.1.1
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.xml
flags: unittests,${{ matrix.os }},${{ matrix.python-version }}
env_vars: OS,PYTHON
name: codecov-umbrella
fail_ci_if_error: false
- name: Minimize uv cache
run: uv cache prune --ci
testing-guardian:
runs-on: ubuntu-latest
needs: pytester
if: always()
steps:
- run: echo "${{ needs.pytester.result }}"
- name: failing...
if: needs.pytester.result == 'failure'
run: exit 1
- name: cancelled or skipped...
if: contains(fromJSON('["cancelled", "skipped"]'), needs.pytester.result)
timeout-minutes: 1
run: sleep 90