2021-11-10 16:59:10 +00:00
|
|
|
name: Package
|
2020-06-27 20:25:33 +00:00
|
|
|
|
|
|
|
# see: https://help.github.com/en/actions/reference/events-that-trigger-workflows
|
2022-09-08 13:29:28 +00:00
|
|
|
on:
|
2020-06-27 20:25:33 +00:00
|
|
|
push:
|
2021-01-12 12:56:20 +00:00
|
|
|
branches: [master, "release/*"]
|
2020-06-27 20:25:33 +00:00
|
|
|
pull_request:
|
2020-11-04 09:08:37 +00:00
|
|
|
branches: [master, "release/*"]
|
2023-09-25 12:34:41 +00:00
|
|
|
types: [opened, reopened, ready_for_review, synchronize] # added `ready_for_review` since draft is skipped
|
2022-10-25 16:34:04 +00:00
|
|
|
paths:
|
2023-06-15 15:25:59 +00:00
|
|
|
- ".actions/*"
|
2023-12-14 13:49:43 +00:00
|
|
|
- "requirements/ci.txt"
|
2022-12-13 05:55:39 +00:00
|
|
|
- ".github/actions/pkg-check/*"
|
|
|
|
- ".github/actions/pkg-install/*"
|
|
|
|
- ".github/workflows/_build-packages.yml"
|
2022-10-25 16:34:04 +00:00
|
|
|
- ".github/workflows/ci-pkg-install.yml"
|
|
|
|
- "setup.py"
|
|
|
|
- "src/**"
|
|
|
|
- "requirements/**"
|
2022-11-26 01:16:48 +00:00
|
|
|
- "!requirements/docs.txt"
|
|
|
|
- "!requirements/*/docs.txt"
|
2022-11-16 10:07:02 +00:00
|
|
|
- "!*.md"
|
|
|
|
- "!**/*.md"
|
2020-06-27 20:25:33 +00:00
|
|
|
|
2022-02-02 19:48:15 +00:00
|
|
|
concurrency:
|
|
|
|
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.head_ref }}
|
2023-12-21 22:49:18 +00:00
|
|
|
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
|
2022-02-02 19:48:15 +00:00
|
|
|
|
2022-06-27 13:34:18 +00:00
|
|
|
defaults:
|
|
|
|
run:
|
|
|
|
shell: bash
|
|
|
|
|
2020-06-27 20:25:33 +00:00
|
|
|
jobs:
|
2022-12-13 05:55:39 +00:00
|
|
|
build-packages:
|
|
|
|
uses: ./.github/workflows/_build-packages.yml
|
|
|
|
with:
|
|
|
|
artifact-name: dist-packages-${{ github.sha }}
|
|
|
|
|
2022-10-25 16:34:04 +00:00
|
|
|
install-pkg:
|
2022-12-13 05:55:39 +00:00
|
|
|
needs: build-packages
|
2020-06-27 20:25:33 +00:00
|
|
|
runs-on: ${{ matrix.os }}
|
|
|
|
strategy:
|
2022-10-27 10:32:49 +00:00
|
|
|
fail-fast: false
|
2020-06-27 20:25:33 +00:00
|
|
|
matrix:
|
2024-11-13 14:00:26 +00:00
|
|
|
os: ["ubuntu-22.04", "macOS-14", "windows-2022"]
|
2024-07-05 11:56:29 +00:00
|
|
|
pkg-name: ["fabric", "pytorch", "lightning", "notset"]
|
2024-07-12 14:33:35 +00:00
|
|
|
python-version: ["3.9", "3.11"]
|
2020-06-27 20:25:33 +00:00
|
|
|
steps:
|
2023-10-03 19:42:18 +00:00
|
|
|
- uses: actions/checkout@v4
|
2024-01-09 13:33:09 +00:00
|
|
|
- uses: actions/setup-python@v5
|
2020-06-27 20:25:33 +00:00
|
|
|
with:
|
2020-08-07 07:08:23 +00:00
|
|
|
python-version: ${{ matrix.python-version }}
|
2022-12-13 05:55:39 +00:00
|
|
|
- uses: actions/download-artifact@v3
|
2022-06-30 13:02:57 +00:00
|
|
|
with:
|
2022-12-13 05:55:39 +00:00
|
|
|
name: dist-packages-${{ github.sha }}
|
|
|
|
path: dist
|
2022-06-30 13:02:57 +00:00
|
|
|
|
2023-08-28 15:28:58 +00:00
|
|
|
- name: Set package dir
|
|
|
|
run: |
|
2022-12-13 05:55:39 +00:00
|
|
|
python -c "print('PKG_DIR=' + {'notset': 'lightning'}.get('${{matrix.pkg-name}}', '${{matrix.pkg-name}}'))" >> $GITHUB_ENV
|
2022-12-21 08:58:32 +00:00
|
|
|
- name: Install package - wheel & archive
|
|
|
|
uses: ./.github/actions/pkg-install
|
2023-10-03 18:40:43 +00:00
|
|
|
timeout-minutes: 25
|
2022-10-31 19:50:51 +00:00
|
|
|
with:
|
2022-12-13 05:55:39 +00:00
|
|
|
pkg-folder: dist/${{ env.PKG_DIR }}
|
2022-11-04 16:51:03 +00:00
|
|
|
pkg-name: ${{ matrix.pkg-name }}
|
2022-12-11 23:01:06 +00:00
|
|
|
|
2022-12-13 05:55:39 +00:00
|
|
|
- name: DocTests actions
|
|
|
|
working-directory: .actions/
|
|
|
|
run: |
|
2023-01-31 11:41:05 +00:00
|
|
|
pip install -q pytest -r requirements.txt
|
2022-12-13 14:47:35 +00:00
|
|
|
python -m pytest assistant.py
|
2023-01-31 11:41:05 +00:00
|
|
|
|
|
|
|
- name: Adjust code for standalone
|
2024-07-05 11:56:29 +00:00
|
|
|
if: contains(fromJSON('["fabric", "pytorch"]'), matrix.pkg-name)
|
2023-01-31 11:41:05 +00:00
|
|
|
run: |
|
|
|
|
python .actions/assistant.py copy_replace_imports --source_dir="./src" \
|
2024-07-05 11:56:29 +00:00
|
|
|
--source_import="lightning.pytorch,lightning.fabric" \
|
|
|
|
--target_import="pytorch_lightning,lightning_fabric"
|
2023-01-31 11:41:05 +00:00
|
|
|
- name: Rename src folders
|
|
|
|
working-directory: src/
|
2023-08-28 15:28:58 +00:00
|
|
|
run: |
|
2024-07-05 11:56:29 +00:00
|
|
|
python -c "n = '${{matrix.pkg-name}}' ; n = n if n in ('fabric', 'pytorch') else '' ; print('PKG_NAME=' + n)" >> $GITHUB_ENV
|
2023-08-28 15:28:58 +00:00
|
|
|
rm -f ./*/__*.py
|
|
|
|
rm -f ./**/__*.py
|
|
|
|
mv lightning lit # rename lightning folder to prevent accidental local imports
|
2024-02-26 13:25:00 +00:00
|
|
|
- name: drop Secondary doctest
|
|
|
|
if: ${{ matrix.pkg-name == 'lightning' || matrix.pkg-name == 'notset' }}
|
2023-08-28 15:28:58 +00:00
|
|
|
working-directory: src/lit
|
|
|
|
run: |
|
2024-07-05 11:56:29 +00:00
|
|
|
items=("data")
|
2024-02-26 13:25:00 +00:00
|
|
|
for item in "${items[@]}"; do
|
|
|
|
echo "Removing $item"
|
|
|
|
rm -rf $item
|
|
|
|
done
|
2023-08-28 15:28:58 +00:00
|
|
|
- name: Install pytest doctest extension
|
|
|
|
run: |
|
2024-03-04 14:09:04 +00:00
|
|
|
pip install -q -r requirements/doctests.txt
|
2023-08-28 15:28:58 +00:00
|
|
|
pip list
|
|
|
|
|
2022-10-27 10:32:49 +00:00
|
|
|
- name: DocTest package
|
2022-11-12 01:39:38 +00:00
|
|
|
env:
|
2023-09-25 12:34:41 +00:00
|
|
|
LIGHTING_TESTING: 1 # path for require wrapper
|
2022-11-12 01:39:38 +00:00
|
|
|
PY_IGNORE_IMPORTMISMATCH: 1
|
2023-08-28 15:28:58 +00:00
|
|
|
run: python -m pytest src/lit/${PKG_NAME} --ignore-glob="**/cli/*-template/**" --doctest-plus
|