diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..d67f2ce --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,85 @@ +# This is a basic workflow to help you get started with Actions +# based on https://github.com/snok/install-poetry + +name: CI + +# Controls when the workflow will run +on: + # Triggers the workflow on push or pull request events but only for the main branch + push: + branches: + - master + paths: + - "src/**" + - "tests/**" + - "pyproject.toml" + - "poetry.toml" + - "poetry.lock" + - "!**.md" + - "!.github/workflows/docs.yml" + pull_request: + paths-ignore: + - "**.md" + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + # This workflow contains a single job called "test" + test: + # The type of runner that the job will run on + strategy: + matrix: + os: ["ubuntu-latest"] #, "macos-latest"] + python-version: ["3.7", "3.8", "3.9"] + runs-on: ${{ matrix.os }} + + steps: + # https://github.com/actions/checkout + - name: Checkout project repository + uses: actions/checkout@v2 + + # https://github.com/actions/setup-python + - name: Install Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + + # https://github.com/snok/install-poetry + - name: Install Poetry + uses: snok/install-poetry@v1 + + # with: + # virtualenvs-create: true + # virtualenvs-in-project: true + + - name: Load cached venv + id: cached-poetry-dependencies + uses: actions/cache@v2 + with: + path: .venv + key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }} + + - name: Install main (non-optional) and dev dependencies + # see [tool.poetry.dependencies] and [tool.poetry.dev-dependencies] + # in pyproject.toml + if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' + run: poetry install --no-root + + - name: Install package + run: poetry install + + - name: Test with pytest and create coverage report + # Configuration of pytest [tool.pytest.ini_options] in pyproject.toml + # https://docs.pytest.org/en/latest/reference/customize.html#pyproject-toml + run: poetry run pytest --cov-report=xml + + - name: Upload coverage to Codecov + # https://docs.codecov.com/docs + # https://github.com/codecov/codecov-action + uses: codecov/codecov-action@v2 + with: + token: ${{ secrets.CODECOV_TOKEN }} + files: ./coverage.xml + # generated using --cov-report=xml above diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 1566862..0000000 --- a/.travis.yml +++ /dev/null @@ -1,44 +0,0 @@ -# The configurations you want to execute -# That is, a combination of operating system and python version -# Please add or remove for your needs. -# Check all possible values for python in here: https://docs.travis-ci.com/user/languages/python/ -# See how to further configure the matrix of combinations in here: https://docs.travis-ci.com/user/multi-os/ -language: python - -sudo: require - -matrix: - include: - # - os: linux - # python: 2.7 - # - os: osx - # language: generic - # env: PYTHON=2.7 - - os: linux - python: 3.6 - # - os: osx - # language: generic - # env: PYTHON=3.4.6 - -# Command to install dependencies for each configuration. -before_install: -# # For OSX, you may want to call a script installing virtual env and so on. - - . ./scripts/install.sh - -install: - - python -m pip install -U pip - - python -m easy_install -U setuptools - - pip install -U pytest - - pip install pytest-cov - - pip install coveralls - # - pip install sphinx - - pip install -e .['zonotope','trees'] - -# Command to run tests. These are run for each configuration -script: - - python --version - - python tests.py # from https://github.com/bhargavvader/pycobra/ - - coverage - # - cd docs && make html && make doctest SPHINXOPTS=-W #Make doctest treat warnings as errors, to detect problems in autodoc -after_success: - - coveralls diff --git a/scripts/install.sh b/scripts/install.sh deleted file mode 100755 index f0a98df..0000000 --- a/scripts/install.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/bash - -if [[ $TRAVIS_OS_NAME == 'osx' ]]; then - # If in OSX, we need to install python by hand. - # We do that using homebrew, pyenv and pyenv-virtualenv - # You should normally not change anything in here - brew update >/dev/null - # Per the `pyenv homebrew recommendations `_. - brew install openssl readline - # See https://docs.travis-ci.com/user/osx-ci-environment/#A-note-on-upgrading-packages. - # I didn't do this above because it works and I'm lazy. - brew outdated pyenv || brew upgrade pyenv - # virtualenv doesn't work without pyenv knowledge. venv in Python 3.3 - # doesn't provide Pip by default. So, use `pyenv-virtualenv `_. - brew install pyenv-virtualenv - PYTHON_CONFIGURE_OPTS="--enable-framework" pyenv install $PYTHON # Try to fix matplotlib backend issue #6, repeated in tests branch - # I would expect something like ``pyenv init; pyenv local $PYTHON`` or - # ``pyenv shell $PYTHON`` would work, but ``pyenv init`` doesn't seem to - # modify the Bash environment. ??? So, I hand-set the variables instead. - export PYENV_VERSION=$PYTHON - export PATH="/Users/travis/.pyenv/shims:${PATH}" - pyenv-virtualenv venv - source venv/bin/activate - # A manual check that the correct version of Python is running. - python --version -else - # Additional installation instructions for UNIX - sudo apt-get install -qq gcc g++ - # https://askubuntu.com/questions/785505/how-to-ensure-matplotlib-in-a-python-3-virtualenv-uses-the-tkagg-backend - # sudo apt install tk-dev - echo "Not on osx" -fi \ No newline at end of file