diff --git a/.github/workflows/python-package.yml b/.github/workflows/run_tests.yml similarity index 68% rename from .github/workflows/python-package.yml rename to .github/workflows/run_tests.yml index 8b5c379..e63c1e7 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/run_tests.yml @@ -1,23 +1,20 @@ # This workflow will install Python dependencies, run tests and lint with a variety of Python versions # For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions -name: Python package +name: Run tests on: - push: - branches: [ master, dev ] pull_request: - branches: [ master, dev ] schedule: - cron: "0 2 * * 6" jobs: check_version: - runs-on: ${{ matrix.os }} strategy: matrix: python-version: [ 3.8 ] os: [ ubuntu-latest ] + runs-on: ${{ matrix.os }} steps: - name: Checkout code uses: actions/checkout@v2 @@ -30,38 +27,37 @@ jobs: - name: Check version if: (github.event_name == 'pull_request' && github.base_ref == 'master') run: | - pip install git+https://github.com/google-research/torchsde.git + python -m pip install --upgrade pip + + python -m pip install git+https://github.com/google-research/torchsde.git master_info=$(pip list | grep torchsde) master_version=$(echo ${master_info} | cut -d " " -f2) + python -m pip uninstall -y torchsde - pip uninstall -y torchsde python setup.py install pr_info=$(pip list | grep torchsde) pr_version=$(echo ${pr_info} | cut -d " " -f2) - echo "import itertools as it + python -c "import itertools as it import sys - master_version = sys.argv[1] - pr_version = sys.argv[2] + _, master_version, pr_version = sys.argv master_version_ = [int(i) for i in master_version.split('.')] pr_version_ = [int(i) for i in pr_version.split('.')] master_version__ = tuple(m for p, m in it.zip_longest(pr_version_, master_version_, fillvalue=0)) pr_version__ = tuple(p for p, m in it.zip_longest(pr_version_, master_version_, fillvalue=0)) - sys.exit(pr_version__ < master_version__)" >> check_version.py - - python check_version.py ${master_version} ${pr_version} + sys.exit(pr_version__ < master_version__)" ${master_version} ${pr_version} build: - runs-on: ${{ matrix.os }} + needs: [ check_version ] strategy: matrix: python-version: [ 3.6, 3.8 ] os: [ ubuntu-latest, macOS-latest, windows-latest ] fail-fast: false - needs: [ check_version ] + runs-on: ${{ matrix.os }} steps: - name: Checkout code uses: actions/checkout@v2 @@ -74,21 +70,17 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install flake8 pytest + python -m pip install flake8 pytest - name: Windows patch # Specifically for windows, since pip fails to fetch torch 1.6.0 as of Oct 2020. if: runner.os == 'Windows' - run: pip install torch==1.6.0+cpu torchvision==0.7.0+cpu -f https://download.pytorch.org/whl/torch_stable.html + run: python -m pip install torch==1.6.0+cpu torchvision==0.7.0+cpu -f https://download.pytorch.org/whl/torch_stable.html - name: Lint with flake8 run: | - # stop the build if there are Python syntax errors or undefined names - flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics - # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + python -m flake8 . - name: Test with pytest run: | - python setup.py develop - cd .. - pytest torchsde/tests + python setup.py install + python -m pytest