lightning/.github/workflows/ci-pkg-install.yml

110 lines
3.0 KiB
YAML

name: Package
# see: https://help.github.com/en/actions/reference/events-that-trigger-workflows
on:
push:
branches: [master, "release/*"]
pull_request:
branches: [master, "release/*"]
paths:
- ".actions/**"
- ".github/workflows/ci-pkg-install.yml"
- "setup.py"
- "src/**"
- "requirements/**"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.head_ref }}
cancel-in-progress: ${{ ! (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/release/')) }}
defaults:
run:
shell: bash
jobs:
init-pypi:
runs-on: ubuntu-20.04
steps:
- run: mkdir pypi && touch pypi/.placeholder
- uses: actions/upload-artifact@v3
with:
name: ci-packages-${{ github.sha }}
path: pypi
build-pypi:
needs: init-pypi
# This serves to create packages for potential internal dependencies
runs-on: ubuntu-20.04
strategy:
fail-fast: true
max-parallel: 1
matrix:
pkg: ["lite"]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.8"
- uses: actions/download-artifact@v3
with:
name: ci-packages-${{ github.sha }}
path: pypi
- name: Build package
env:
PACKAGE_NAME: ${{ matrix.pkg }}
run: |
python setup.py sdist
cp dist/* pypi/
- uses: actions/upload-artifact@v3
with:
name: ci-packages-${{ github.sha }}
path: pypi
install-pkg:
needs: build-pypi
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-22.04, macOS-12, windows-2022]
pkg: ["app", "lite", "pytorch", ""]
python-version: ["3.7" , "3.10"]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: DocTests actions
working-directory: .actions/
run: |
pip install pytest -q
python -m pytest setup_tools.py
- run: python -c "print('NB_DIRS=' + str(2 if '${{ matrix.pkg }}' == 'pytorch' else 1))" >> $GITHUB_ENV
- uses: ./.github/actions/pkg-check
with:
pkg-name: ${{ matrix.pkg }}
nb-dirs: ${{ env.NB_DIRS }}
- uses: actions/download-artifact@v3
with:
name: ci-packages-${{ github.sha }}
path: pypi
- run: ls -l pypi/
- uses: ./.github/actions/pkg-install
with:
pip-flags: "--pre --find-links ../pypi/"
- name: Run CLI
# todo: add testing for `lightning_app`
if: ${{ matrix.pkg == '' }}
run: python -m lightning --version
- name: DocTest package
run: |
pip list
scope=$(python -c "lut = {'app': 'lightning_app', 'lite': 'lightning_lite', 'pytorch': 'pytorch_lightning'} ; print(lut.get('${{matrix.pkg}}', 'lightning'))")
python -m pytest src/${scope} --ignore-glob="**/cli/*-template/**"