-
Notifications
You must be signed in to change notification settings - Fork 9
135 lines (120 loc) · 4.12 KB
/
ci-testing.yml
File metadata and controls
135 lines (120 loc) · 4.12 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
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: {}
pull_request:
branches: [main]
schedule:
- cron: "0 0 * * *" # every day at midnight UTC
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.head_ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
defaults:
run:
shell: bash
jobs:
pytester:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: ["ubuntu-24.04", "macOS-14", "windows-2022"]
python-version: ["3.10", "3.12"]
requires: ["latest"]
dependency: ["lightning"]
dependency_package: ["lightning"]
include:
- {
os: "ubuntu-22.04",
python-version: "3.10",
requires: "oldest",
dependency: "lightning",
dependency_package: "lightning",
}
- {
os: "ubuntu-24.04",
python-version: "3.12",
requires: "latest",
dependency: "pytorch_lightning",
dependency_package: "pytorch-lightning",
}
- {
os: "windows-2022",
python-version: "3.12",
requires: "latest",
dependency: "pytorch_lightning",
dependency_package: "pytorch-lightning",
}
- {
os: "macOS-14",
python-version: "3.12",
requires: "latest",
dependency: "pytorch_lightning",
dependency_package: "pytorch-lightning",
}
# Timeout: https://stackoverflow.com/a/59076067/4521646
timeout-minutes: 35
env:
TORCH_URL: "https://download.pytorch.org/whl/cpu/torch_stable.html"
DISABLE_MPS: ${{ matrix.os == 'macOS-14' && '1' || '0' }}
UV_TORCH_BACKEND: "cpu"
steps:
- uses: actions/checkout@v5
- name: Install uv and set Python ${{ matrix.python-version }}
uses: astral-sh/setup-uv@v7
with:
python-version: ${{ matrix.python-version }}
activate-environment: true
enable-cache: true
- name: Set min. dependencies
if: matrix.requires == 'oldest'
run: |
uv pip install 'lightning-utilities[cli]'
python -m lightning_utilities.cli requirements set-oldest --req_files='["requirements.txt", "pyproject.toml"]'
- name: Adjust requirements
run: |
uv pip install 'lightning-utilities[cli]' -q
python -m lightning_utilities.cli requirements replace-pkg \
--old_package="lightning" \
--new_package="${{ matrix.dependency_package }}" \
--req_files='["pyproject.toml"]'
- name: Install package & dependencies
run: |
set -e
uv --version
uv pip install -e '.[test,extra]' --find-links="${TORCH_URL}"
uv pip list
# check that right package was installed
python -c "import ${{matrix.dependency}}; print(${{matrix.dependency}}.__version__)"
- name: Tests with mocks
run: |
coverage run --source litmodels -m pytest src tests -v -m "not cloud"
- name: Statistics
run: |
coverage report
coverage xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
continue-on-error: true
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.xml
flags: unittests
env_vars: OS,PYTHON
name: codecov-umbrella
fail_ci_if_error: false
- name: Minimize uv cache
run: uv cache prune --ci
tests-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