name: CI complete testing # see: https://help.github.com/en/actions/reference/events-that-trigger-workflows on: # Trigger the workflow on push or pull request, but only for the master branch push: branches: [master, "release/*"] pull_request: branches: [master, "release/*"] jobs: pytest: runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: os: [ubuntu-18.04, windows-2019, macOS-10.15] python-version: [3.6, 3.7, 3.8] requires: ['minimal', 'latest'] exclude: # # todo: segmentation fault for minimal and hanging for latest - python-version: 3.8 os: ubuntu-18.04 # Timeout: https://stackoverflow.com/a/59076067/4521646 timeout-minutes: 35 # TODO: the macOS is taking too long, probably caching did not work... steps: - uses: actions/checkout@v2 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} - name: Update Pip run: | # todo: unfreeze PIP after resolving minimal dependencies pip install --quiet "pip==20.1" --upgrade --user # needed for get pip cacher folder # Github Actions: Run step on specific OS: https://stackoverflow.com/a/57948488/4521646 - name: Setup macOS if: runner.os == 'macOS' run: | brew install libomp # https://github.com/pytorch/pytorch/issues/20030 brew install openmpi libuv # Horovod on macOS requires OpenMPI, Gloo not currently supported - name: Setup Windows if: runner.os == 'windows' run: | # remove Horovod from requirements fname = 'requirements/extra.txt' lines = [line for line in open(fname).readlines() if not line.startswith('horovod')] open(fname, 'w').writelines(lines) shell: python - name: Set min. dependencies if: matrix.requires == 'minimal' run: | files = ( 'requirements.txt', 'requirements/extra.txt', 'requirements/loggers.txt', 'requirements/test.txt', 'requirements/examples.txt', ) for fname in files: req = open(fname).read().replace('>=', '==') open(fname, 'w').write(req) # remove Fairscale from requirements fname = 'requirements/extra.txt' lines = [line for line in open(fname).readlines() if 'fairscale' not in line] open(fname, 'w').writelines(lines) shell: python # Note: This uses an internal pip API and may not always work # https://github.com/actions/cache/blob/master/examples.md#multiple-oss-in-a-workflow - name: Get pip cache dir id: pip-cache run: | echo "::set-output name=dir::$(pip cache dir)" - name: pip cache uses: actions/cache@v2 with: path: ${{ steps.pip-cache.outputs.dir }} key: ${{ runner.os }}-pip-py${{ matrix.python-version }}-${{ matrix.requires }}-${{ hashFiles('requirements.txt') }}-${{ hashFiles('requirements/extra.txt') }} restore-keys: | ${{ runner.os }}-pip-py${{ matrix.python-version }}-${{ matrix.requires }}- - name: Pull checkpoints from S3 # todo: consider adding some caching, but ATM all models have less then 100KB run: | cd legacy # wget is simpler but does not work on Windows python -c "from urllib.request import urlretrieve ; urlretrieve('https://pl-public-data.s3.amazonaws.com/legacy/checkpoints.zip', 'checkpoints.zip')" ls -l . unzip -o checkpoints.zip ls -l checkpoints/ - name: Install dependencies env: # MAKEFLAGS: "-j2" HOROVOD_BUILD_ARCH_FLAGS: "-mfma" HOROVOD_WITHOUT_MXNET: 1 HOROVOD_WITHOUT_TENSORFLOW: 1 run: | # python -m pip install --upgrade --user pip pip install --requirement requirements.txt --find-links https://download.pytorch.org/whl/cpu/torch_stable.html --quiet --upgrade pip install --requirement ./requirements/devel.txt --find-links https://download.pytorch.org/whl/cpu/torch_stable.html --quiet --upgrade python --version pip --version pip list shell: bash - name: Reinstall Horovod if necessary if: runner.os != 'windows' env: HOROVOD_BUILD_ARCH_FLAGS: "-mfma" run: | HOROVOD_BUILT=$(python -c "import horovod.torch; horovod.torch.nccl_built(); print('SUCCESS')" || true) if [[ $HOROVOD_BUILT != "SUCCESS" ]]; then pip uninstall -y horovod echo $(grep "horovod" requirements/extra.txt) > requirements/horovod.txt pip install --no-cache-dir -r requirements/horovod.txt fi horovodrun --check-build shell: bash - name: Cache datasets uses: actions/cache@v2 with: path: Datasets key: pl-dataset - name: Tests run: | # NOTE: do not include coverage report here, see: https://github.com/nedbat/coveragepy/issues/1003 coverage run --source pytorch_lightning -m pytest pytorch_lightning tests pl_examples -v --durations=50 --junitxml=junit/test-results-${{ runner.os }}-${{ matrix.python-version }}-${{ matrix.requires }}.xml - name: Upload pytest test results uses: actions/upload-artifact@v2 with: name: pytest-results-${{ runner.os }}-${{ matrix.python-version }}-${{ matrix.requires }} path: junit/test-results-${{ runner.os }}-${{ matrix.python-version }}-${{ matrix.requires }}.xml if: failure() - name: Statistics if: success() run: | coverage report coverage xml - name: Upload coverage to Codecov uses: codecov/codecov-action@v1 if: always() # see: https://github.com/actions/toolkit/issues/399 continue-on-error: true with: token: ${{ secrets.CODECOV_TOKEN }} file: coverage.xml flags: cpu,pytest name: CPU-coverage fail_ci_if_error: false