From 21d0f320470fcd7827300a92d8f8f567af433a00 Mon Sep 17 00:00:00 2001 From: Jirka Borovec Date: Wed, 12 Feb 2020 17:28:47 +0100 Subject: [PATCH] Add GitHub Actions build (#823) * init GH building * try run * circleci: install * add cache * add artifacts * fix cache * update --- .circleci/config.yml | 17 +++++++ .github/workflows/ci-testing.yml | 82 ++++++++++++++++++++++++++++++++ .run_local_tests.sh | 2 +- tox.ini | 4 +- 4 files changed, 102 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/ci-testing.yml diff --git a/.circleci/config.yml b/.circleci/config.yml index 988a93ce93..84e11e7eed 100755 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -24,6 +24,14 @@ references: py.test pytorch_lightning tests pl_examples -v --doctest-modules --junitxml=test-reports/pytest_junit.xml no_output_timeout: 15m + install_pkg: &install_pkg + run: + name: Install package + command: | + virtualenv vEnv ; source vEnv/bin/activate + pip install --editable . ; cd .. & python -c "import pytorch_lightning ; print(pytorch_lightning.__version__)" + deactivate ; rm -rf vEnv + format: &format run: name: Formatting @@ -104,6 +112,14 @@ jobs: - TORCH_VERSION: "torch>=1.4, <1.5" steps: *steps + Install-pkg: + docker: + - image: circleci/python:3.7 + steps: + - checkout + - *install_pkg + + workflows: version: 2 build: @@ -114,3 +130,4 @@ workflows: - PyTorch-v1.2 - PyTorch-v1.3 - PyTorch-v1.4 + - Install-pkg diff --git a/.github/workflows/ci-testing.yml b/.github/workflows/ci-testing.yml new file mode 100644 index 0000000000..4e6c268532 --- /dev/null +++ b/.github/workflows/ci-testing.yml @@ -0,0 +1,82 @@ +name: CI testing + +on: [push, pull_request] + +jobs: + build: + + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + # max-parallel: 6 + matrix: + os: [ubuntu-18.04, windows-2016, macOS-10.15] + python-version: [3.6, 3.7] + requires: ['minimal', 'latest'] + + steps: + - uses: actions/checkout@v1 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v1 + with: + python-version: ${{ matrix.python-version }} + + - name: Set min. dependencies + if: matrix.requires == 'minimal' + run: | + python -c "req = open('requirements.txt').read().replace('>', '=') ; open('requirements.txt', 'w').write(req)" + + - name: Cache pip + uses: actions/cache@v1 + with: + path: ~/.cache/pip # This path is specific to Ubuntu + # Look to see if there is a cache hit for the corresponding requirements file + key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('requirements.txt') }} + restore-keys: | + ${{ runner.os }}-pip-${{ matrix.python-version }}- + ${{ runner.os }}-${{ matrix.python-version }}- + + - name: Install dependencies + run: | + # python -m pip install --upgrade --user pip + pip install -r requirements.txt -U -f https://download.pytorch.org/whl/torch_stable.html + pip install -r ./tests/requirements.txt + # pip install tox coverage + python --version + pip --version + pip list + + - name: Lint and Tests + # env: + # TOXENV: py${{ matrix.python-version }} + run: | + # tox --sitepackages + flake8 . + coverage run --source pytorch_lightning -m py.test pytorch_lightning tests pl_examples -v --doctest-modules --junitxml=junit/test-results-${{ runner.os }}-${{ matrix.python-version }}.xml + + - name: Upload pytest test results + uses: actions/upload-artifact@master + with: + name: pytest-results-${{ runner.os }}-${{ matrix.python-version }} + path: junit/test-results-${{ runner.os }}-${{ matrix.python-version }}.xml + # Use always() to always run this step to publish test results when there are test failures + if: always() + + - name: Package Setup + run: | + check-manifest + python setup.py check --metadata --strict + python setup.py sdist + twine check dist/* + + #- name: Try install package + # if: ! startsWith(matrix.os, 'windows') + # run: | + # virtualenv vEnv ; source vEnv/bin/activate + # pip install --editable . ; cd .. & python -c "import pytorch_lightning ; print(pytorch_lightning.__version__)" + # deactivate ; rm -rf vEnv + + - name: Statistics + if: success() + run: | + coverage report diff --git a/.run_local_tests.sh b/.run_local_tests.sh index 6e09ed1cc7..ce7fce58ce 100644 --- a/.run_local_tests.sh +++ b/.run_local_tests.sh @@ -8,5 +8,5 @@ rm -rf ./tests/cometruns* rm -rf ./tests/wandb* rm -rf ./tests/tests/* rm -rf ./lightning_logs -coverage run --source pytorch_lightning -m py.test pytorch_lightning tests pl_examples -v --doctest-modules +coverage run --source pytorch_lightning -m py.test pytorch_lightning tests pl_examples -v --doctest-modules --flake8 coverage report -m diff --git a/tox.ini b/tox.ini index 953374bc6a..3243beb420 100644 --- a/tox.ini +++ b/tox.ini @@ -32,11 +32,11 @@ basepython = py38: python3.8 deps = # this is derived requirements - -r requirements-ci.txt + -r requirements.txt -r ./tests/requirements.txt commands = pip list - check-manifest --ignore requirements-ci.txt + check-manifest python setup.py check --metadata --strict flake8 . coverage run --source pytorch_lightning -m py.test pytorch_lightning tests pl_examples -v --doctest-modules