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" - "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.ref != 'refs/heads/master' }} 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: # "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: 30 env: PACKAGE_NAME: ${{ matrix.pkg-name }} FREEZE_REQUIREMENTS: ${{ ! (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/release/')) }} PYPI_CACHE_DIR: "_pip-wheels" steps: - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v4 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@v3 with: path: ${{ env.PYPI_CACHE_DIR }} key: pypi_wheels - run: | mkdir -p $PYPI_CACHE_DIR ls -lh $PYPI_CACHE_DIR - name: Switch PyTorch URL run: python -c "print('TORCH_URL=https://download.pytorch.org/whl/' + str('test/cpu/torch_test.html' if '${{matrix.release}}' == 'pre' else 'cpu/torch_stable.html'))" >> $GITHUB_ENV - name: Install package & dependencies run: | python -m pip install -q pip -U extra=$(python -c "print({'lightning': 'app-'}.get('${{ matrix.pkg-name }}', ''))") pip install -e ".[${extra}dev]" -U -f ${TORCH_URL} -f ${PYPI_CACHE_DIR} --prefer-binary 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@v3 with: node-version: '16' - name: Install Yarn 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: Tests working-directory: ./tests env: AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} AWS_DEFAULT_REGION: us-east-1 run: | python -m coverage run --source ${{ env.COVERAGE_SCOPE }} \ -m pytest -m "not cloud" tests_app --timeout=300 -vvvv --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@v3 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@v3 # # 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