-
Notifications
You must be signed in to change notification settings - Fork 3.4k
175 lines (160 loc) · 6.69 KB
/
ci-tests-app.yml
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
name: Test App
# see: https://help.github.com/en/actions/reference/events-that-trigger-workflows
on:
push:
branches: [master, "release/*"]
pull_request:
branches: [master, "release/*"]
types: [opened, reopened, ready_for_review, synchronize] # added `ready_for_review` since draft is skipped
paths:
- ".actions/*"
- ".github/workflows/ci-tests-app.yml"
- "requirements/ci.txt"
- "src/lightning/app/**"
- "src/lightning_app/*"
- "tests/tests_app/**"
- "requirements/app/**"
- "setup.py"
- "!requirements/*/docs.txt"
- "!*.md"
- "!**/*.md"
schedule:
# At the end of every day
- cron: "0 0 * * *"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.head_ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
defaults:
run:
shell: bash
jobs:
app-pytest:
if: github.event.pull_request.draft == false
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: ["ubuntu-20.04", "macOS-11", "windows-2022"]
pkg-name: ["lightning"]
python-version: ["3.8"]
requires: ["oldest", "latest"]
include:
# only run Python latest, use App scope to limit dependency issues
- { os: "macOS-12", pkg-name: "app", python-version: "3.11", requires: "latest" }
- { os: "ubuntu-22.04", pkg-name: "app", python-version: "3.11", requires: "latest" }
- { os: "windows-2022", pkg-name: "app", python-version: "3.11", requires: "latest" }
# "app" installs the standalone package
- { os: "macOS-11", pkg-name: "app", python-version: "3.9", requires: "latest" }
- { os: "ubuntu-20.04", pkg-name: "app", python-version: "3.9", requires: "latest" }
- { os: "windows-2022", pkg-name: "app", python-version: "3.8", requires: "latest" }
# Timeout: https://stackoverflow.com/a/59076067/4521646
timeout-minutes: 55
env:
PACKAGE_NAME: ${{ matrix.pkg-name }}
FREEZE_REQUIREMENTS: ${{ ! (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/release/')) }}
PYPI_CACHE_DIR: "_pip-wheels"
TORCH_URL: "https://download.pytorch.org/whl/cpu/torch_stable.html"
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: basic setup
run: pip install -q -r .actions/requirements.txt
- name: Set min. dependencies
if: ${{ matrix.requires == 'oldest' }}
run: python .actions/assistant.py replace_oldest_ver
- name: pip wheels cache
uses: actions/cache/restore@v4
with:
path: ${{ env.PYPI_CACHE_DIR }}
key: pypi_wheels
- name: List restored pkgs
run: |
mkdir -p $PYPI_CACHE_DIR
ls -lh $PYPI_CACHE_DIR
- name: Env. variables
run: |
# Switch coverage scope
python -c "print('COVERAGE_SCOPE=' + str('lightning' if '${{matrix.pkg-name}}' == 'lightning' else 'pytorch_lightning'))" >> $GITHUB_ENV
# if you install mono-package set dependency only for this subpackage
python -c "print('EXTRA_PREFIX=' + str('' if '${{matrix.pkg-name}}' != 'lightning' else 'app-'))" >> $GITHUB_ENV
- name: Install package & dependencies
timeout-minutes: 20
run: |
pip install -e ".[${EXTRA_PREFIX}dev]" -U --prefer-binary \
--find-links="${TORCH_URL}" --find-links="${PYPI_CACHE_DIR}"
pip list
- name: Dump handy wheels
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
continue-on-error: true
uses: ./.github/actions/pip-wheels
with:
wheel-dir: ${{ env.PYPI_CACHE_DIR }}
torch-url: ${{ env.TORCH_URL }}
cache-key: "pypi_wheels"
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "16"
- name: Install Yarn
timeout-minutes: 20
run: npm install -g yarn
- name: Adjust imports -> App
if: ${{ matrix.pkg-name != 'lightning' }}
run: |
python .actions/assistant.py copy_replace_imports --source_dir="./tests" \
--source_import="lightning.app,lightning.fabric,lightning.pytorch" \
--target_import="lightning_app,lightning_fabric,pytorch_lightning" \
--lightning_by="lightning_app"
python .actions/assistant.py copy_replace_imports --source_dir="./examples" \
--source_import="lightning.app,lightning.fabric,lightning.pytorch" \
--target_import="lightning_app,lightning_fabric,pytorch_lightning" \
--lightning_by="lightning_app"
- name: Switch coverage scope
run: python -c "print('COVERAGE_SCOPE=' + str('lightning' if '${{matrix.pkg-name}}' == 'lightning' else 'lightning_app'))" >> $GITHUB_ENV
- name: Set parallel for Unix
if: ${{ runner.os != 'windows' }}
# on Win, tests takes even loner then with normal single thread
run: echo "PYTEST_XDIST_ARGS=-n auto --dist=loadfile" >> $GITHUB_ENV
- name: Tests
working-directory: ./tests
run: |
set -e
python -m coverage run --source ${{ env.COVERAGE_SCOPE }} \
-m pytest -m "not cloud" -vvvv tests_app \
--ignore="tests_app/components/python/test_python.py" \
--timeout=120 --durations=50 ${PYTEST_XDIST_ARGS}
pytest -m "not cloud" -v \
tests_app/components/python/test_python.py \
--timeout=120 --durations=50
- name: Statistics
if: success()
working-directory: ./tests
run: |
coverage xml -i
coverage report -i
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: tests/coverage.xml
flags: ${{ env.COVERAGE_SCOPE }},cpu,pytest
env_vars: OS,PYTHON
name: codecov-umbrella
fail_ci_if_error: false
# TODO: figure out why we clone and install quick-start
# - name: Clone Quick Start Example Repo
# uses: actions/checkout@v4
# # TODO: this needs to be git submodule
# if: matrix.os == 'windows-2022' # because the install doesn't work on windows
# with:
# repository: Lightning-AI/lightning-quick-start
# ref: 'main'
# path: lightning-quick-start
#
# - name: Lightning Install quick-start
# if: matrix.os != 'windows-2022' # because the install doesn't work on windows
# run: |
# python -m lightning install app lightning/quick-start -y