lightning/.github/workflows/ci-examples-app.yml

144 lines
5.1 KiB
YAML

name: Test App - examples
# 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-examples-app.yml"
- "src/lightning_app/**"
- "tests/integrations_app/**"
- "examples/app_*/**"
- "requirements/app/**"
- "setup.py"
- "!requirements/*/docs.txt"
- "!*.md"
- "!**/*.md"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.head_ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/master' }}
defaults:
run:
shell: bash
jobs:
app-examples:
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: ["app"]
python-version: ["3.9"]
requires: ["oldest", "latest"]
include:
# "lightning" installs the monolithic package
- {os: "macOS-11", pkg-name: "lightning", python-version: "3.9", requires: "latest"}
- {os: "ubuntu-20.04", pkg-name: "lightning", python-version: "3.9", requires: "latest"}
- {os: "windows-2022", pkg-name: "lightning", python-version: "3.9", requires: "latest"}
# Timeout: https://stackoverflow.com/a/59076067/4521646
timeout-minutes: 15
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: Get pip cache dir
id: pip-cache
run: echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
- name: Cache pip
uses: actions/cache@v3
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: ${{ runner.os }}-pip-py${{ matrix.python-version }}-${{ matrix.pkg-name }}-${{ matrix.requires }}-${{ hashFiles('requirements/app/base.txt') }}
restore-keys: ${{ runner.os }}-pip-py${{ matrix.python-version }}-${{ matrix.pkg-name }}-${{ matrix.requires }}-
- name: Install Lightning package & dependencies
env:
PACKAGE_NAME: ${{ matrix.pkg-name }}
FREEZE_REQUIREMENTS: 1
run: |
# do not use `-e` because it will make both packages available since it adds `src` to `sys.path` automatically
pip install .[dev] --find-links https://download.pytorch.org/whl/cpu/torch_stable.html
pip list
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '16'
- name: Install Yarn
run: npm install -g yarn
- name: Adjust tests
if: ${{ matrix.pkg-name == 'lightning' }}
run: |
python .actions/assistant.py copy_replace_imports --source_dir="./tests" \
--source_import="lightning_app" --target_import="lightning.app"
- name: Adjust examples
if: ${{ matrix.pkg-name != 'lightning' }}
run: |
python .actions/assistant.py copy_replace_imports --source_dir="./examples" \
--source_import="lightning.app,lightning" \
--target_import="lightning_app,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
PYTEST_ARTIFACT: results-${{ runner.os }}-${{ matrix.python-version }}-${{ matrix.requires }}.xml
run: |
python -m coverage run --source ${COVERAGE_SCOPE} \
-m pytest -m "not cloud" integrations_app \
--timeout=300 --durations=0 -vvvv \
--junitxml=$PYTEST_ARTIFACT
- name: Upload pytest test results
uses: actions/upload-artifact@v3
with:
name: unittest-results-${{ runner.os }}-${{ matrix.python-version }}-${{ matrix.requires }}
path: tests/results-${{ runner.os }}-${{ matrix.python-version }}-${{ matrix.requires }}.xml
if: failure()
- 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: cpu,pytest,app,examples
env_vars: OS,PYTHON
name: codecov-umbrella
fail_ci_if_error: false