pytorch-lightning
175 строк · 6.7 Кб
1name: Test App
2
3# see: https://help.github.com/en/actions/reference/events-that-trigger-workflows
4on:
5push:
6branches: [master, "release/*"]
7pull_request:
8branches: [master, "release/*"]
9types: [opened, reopened, ready_for_review, synchronize] # added `ready_for_review` since draft is skipped
10paths:
11- ".actions/*"
12- ".github/workflows/ci-tests-app.yml"
13- "requirements/ci.txt"
14- "src/lightning/app/**"
15- "src/lightning_app/*"
16- "tests/tests_app/**"
17- "requirements/app/**"
18- "setup.py"
19- "!requirements/*/docs.txt"
20- "!*.md"
21- "!**/*.md"
22schedule:
23# At the end of every day
24- cron: "0 0 * * *"
25
26concurrency:
27group: ${{ github.workflow }}-${{ github.ref }}-${{ github.head_ref }}
28cancel-in-progress: ${{ github.event_name == 'pull_request' }}
29
30defaults:
31run:
32shell: bash
33
34jobs:
35app-pytest:
36if: github.event.pull_request.draft == false
37runs-on: ${{ matrix.os }}
38strategy:
39fail-fast: false
40matrix:
41os: ["ubuntu-20.04", "macOS-11", "windows-2022"]
42pkg-name: ["lightning"]
43python-version: ["3.8"]
44requires: ["oldest", "latest"]
45include:
46# only run Python latest, use App scope to limit dependency issues
47- { os: "macOS-12", pkg-name: "app", python-version: "3.11", requires: "latest" }
48- { os: "ubuntu-22.04", pkg-name: "app", python-version: "3.11", requires: "latest" }
49- { os: "windows-2022", pkg-name: "app", python-version: "3.11", requires: "latest" }
50# "app" installs the standalone package
51- { os: "macOS-11", pkg-name: "app", python-version: "3.9", requires: "latest" }
52- { os: "ubuntu-20.04", pkg-name: "app", python-version: "3.9", requires: "latest" }
53- { os: "windows-2022", pkg-name: "app", python-version: "3.8", requires: "latest" }
54# Timeout: https://stackoverflow.com/a/59076067/4521646
55timeout-minutes: 55
56env:
57PACKAGE_NAME: ${{ matrix.pkg-name }}
58FREEZE_REQUIREMENTS: ${{ ! (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/release/')) }}
59PYPI_CACHE_DIR: "_pip-wheels"
60TORCH_URL: "https://download.pytorch.org/whl/cpu/torch_stable.html"
61steps:
62- uses: actions/checkout@v4
63- name: Set up Python ${{ matrix.python-version }}
64uses: actions/setup-python@v5
65with:
66python-version: ${{ matrix.python-version }}
67
68- name: basic setup
69run: pip install -q -r .actions/requirements.txt
70
71- name: Set min. dependencies
72if: ${{ matrix.requires == 'oldest' }}
73run: python .actions/assistant.py replace_oldest_ver
74
75- name: pip wheels cache
76uses: actions/cache/restore@v4
77with:
78path: ${{ env.PYPI_CACHE_DIR }}
79key: pypi_wheels
80- name: List restored pkgs
81run: |
82mkdir -p $PYPI_CACHE_DIR
83ls -lh $PYPI_CACHE_DIR
84
85- name: Env. variables
86run: |
87# Switch coverage scope
88python -c "print('COVERAGE_SCOPE=' + str('lightning' if '${{matrix.pkg-name}}' == 'lightning' else 'pytorch_lightning'))" >> $GITHUB_ENV
89# if you install mono-package set dependency only for this subpackage
90python -c "print('EXTRA_PREFIX=' + str('' if '${{matrix.pkg-name}}' != 'lightning' else 'app-'))" >> $GITHUB_ENV
91
92- name: Install package & dependencies
93timeout-minutes: 20
94run: |
95pip install -e ".[${EXTRA_PREFIX}dev]" -U --prefer-binary \
96--find-links="${TORCH_URL}" --find-links="${PYPI_CACHE_DIR}"
97pip list
98- name: Dump handy wheels
99if: github.event_name == 'push' && github.ref == 'refs/heads/master'
100continue-on-error: true
101uses: ./.github/actions/pip-wheels
102with:
103wheel-dir: ${{ env.PYPI_CACHE_DIR }}
104torch-url: ${{ env.TORCH_URL }}
105cache-key: "pypi_wheels"
106
107- name: Setup Node.js
108uses: actions/setup-node@v4
109with:
110node-version: "16"
111- name: Install Yarn
112timeout-minutes: 20
113run: npm install -g yarn
114
115- name: Adjust imports -> App
116if: ${{ matrix.pkg-name != 'lightning' }}
117run: |
118python .actions/assistant.py copy_replace_imports --source_dir="./tests" \
119--source_import="lightning.app,lightning.fabric,lightning.pytorch" \
120--target_import="lightning_app,lightning_fabric,pytorch_lightning" \
121--lightning_by="lightning_app"
122python .actions/assistant.py copy_replace_imports --source_dir="./examples" \
123--source_import="lightning.app,lightning.fabric,lightning.pytorch" \
124--target_import="lightning_app,lightning_fabric,pytorch_lightning" \
125--lightning_by="lightning_app"
126
127- name: Switch coverage scope
128run: python -c "print('COVERAGE_SCOPE=' + str('lightning' if '${{matrix.pkg-name}}' == 'lightning' else 'lightning_app'))" >> $GITHUB_ENV
129
130- name: Set parallel for Unix
131if: ${{ runner.os != 'windows' }}
132# on Win, tests takes even loner then with normal single thread
133run: echo "PYTEST_XDIST_ARGS=-n auto --dist=loadfile" >> $GITHUB_ENV
134- name: Tests
135working-directory: ./tests
136run: |
137set -e
138python -m coverage run --source ${{ env.COVERAGE_SCOPE }} \
139-m pytest -m "not cloud" -vvvv tests_app \
140--ignore="tests_app/components/python/test_python.py" \
141--timeout=120 --durations=50 ${PYTEST_XDIST_ARGS}
142pytest -m "not cloud" -v \
143tests_app/components/python/test_python.py \
144--timeout=120 --durations=50
145
146- name: Statistics
147if: success()
148working-directory: ./tests
149run: |
150coverage xml -i
151coverage report -i
152
153- name: Upload coverage to Codecov
154uses: codecov/codecov-action@v4
155with:
156token: ${{ secrets.CODECOV_TOKEN }}
157file: tests/coverage.xml
158flags: ${{ env.COVERAGE_SCOPE }},cpu,pytest
159env_vars: OS,PYTHON
160name: codecov-umbrella
161fail_ci_if_error: false
162# TODO: figure out why we clone and install quick-start
163# - name: Clone Quick Start Example Repo
164# uses: actions/checkout@v4
165# # TODO: this needs to be git submodule
166# if: matrix.os == 'windows-2022' # because the install doesn't work on windows
167# with:
168# repository: Lightning-AI/lightning-quick-start
169# ref: 'main'
170# path: lightning-quick-start
171#
172# - name: Lightning Install quick-start
173# if: matrix.os != 'windows-2022' # because the install doesn't work on windows
174# run: |
175# python -m lightning install app lightning/quick-start -y
176