diff --git a/.github/workflows/flownet.yml b/.github/workflows/flownet.yml new file mode 100644 index 000000000..347017323 --- /dev/null +++ b/.github/workflows/flownet.yml @@ -0,0 +1,77 @@ +name: CI + +on: + pull_request: + branches: + - master + +jobs: + FlowNet: + runs-on: ubuntu-18.04 + strategy: + matrix: + python-version: ['3.6', '3.7'] + env: + VENV_PATH: ${{ github.workspace }}/flownet_venv + PYTHONPATH: ${{ github.workspace }}/flownet_venv/lib/python${{ matrix.python-version }}/dist-packages + steps: + - name: Checkout commit locally + uses: actions/checkout@v2 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v1 + with: + python-version: ${{ matrix.python-version }} + + - name: Cache virtual environment + id: cache-venv + uses: actions/cache@v1 + with: + path: $VENV_PATH + key: ${{ runner.os }}-${{ hashFiles('setup.py') }}-${{ hashFiles('build_environment.sh') }} + + - name: Build venv and install non-python dependencies + run: bash ./build_environment.sh $VENV_PATH ${{ steps.cache-venv.outputs.cache-hit }} + + - name: Install FlowNet + run: | + source $VENV_PATH/bin/activate + pip install . + + - name: Install test dependencies + run: | + source $VENV_PATH/bin/activate + pip install .[tests] + + - name: List all installed packages + run: | + source $VENV_PATH/bin/activate + pip freeze + + - name: Check code style & linting + run: | + source $VENV_PATH/bin/activate + black --check examples/ tests/ src/ setup.py + pylint src/ tests/ setup.py + mypy --ignore-missing-imports src/ tests/ setup.py + + - name: Run tests + run: | + source $VENV_PATH/bin/activate + webviz certificate --force + pytest --cov=flownet --cov-fail-under=50 ./tests + + - name: Run full FlowNet example + run: | + source $VENV_PATH/bin/activate + pushd examples + flownet ahm ../tests/configs/norne_parameters.yml ./some_ahm_run + flownet pred ../tests/configs/norne_pred.yml ./some_pred_run ./some_ahm_run + popd + + - name: Build documentation + run: | + source $VENV_PATH/bin/activate + pushd docs + make html + popd diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index b5d29cb52..000000000 --- a/.travis.yml +++ /dev/null @@ -1,58 +0,0 @@ -language: python -dist: bionic - -os: - - linux - -cache: - directories: - - $VIRTUAL_ENV - -python: - - "3.6" - - "3.7" - -env: - # These are calculated by running e.g. "md5sum ./setup.py" - - SETUP_MD5="fa95e17e1836b433f275d695c62b21b1" BUILD_SCRIPT_MD5="51ac979535fec015e2e630bf5622a3bb" - -before_install: - - echo "Checking that current md5sum (`md5sum ./setup.py`) equals $SETUP_MD5" - - md5sum -c <<<"$SETUP_MD5 *setup.py" # If this fails, update md5 sum of setup.py - - echo "Checksum correct for setup.py" - - - echo "Checking that current md5sum (`md5sum ./build_environment.sh`) equals $BUILD_SCRIPT_MD5" - - md5sum -c <<<"$BUILD_SCRIPT_MD5 *build_environment.sh" # If this fails, update md5sum of build_environment.sh - - echo "Checksum correct for build_environment.sh" - - - sudo apt-get -qq update - - export PYTHONPATH=$VIRTUAL_ENV/lib/python$TRAVIS_PYTHON_VERSION/dist-packages:$PYTHONPATH - - echo "The virtual env is $VIRTUAL_ENV" - - | - if [ -f "$VIRTUAL_ENV/lib/libecl.so" ]; then - echo "Cached virtual environment exists... reuse" - bash ./build_environment.sh $VIRTUAL_ENV true; - else - echo "Cached virtual environment does NOT exist... compile and install" - pip freeze | grep -vw "pip" | xargs pip uninstall -y; - pip install --upgrade pip; - bash ./build_environment.sh $VIRTUAL_ENV; - fi - -install: - - pip install . - - pip install .[tests] - - webviz certificate --auto-install --force - -script: - - black --check examples/ tests/ src/ setup.py - - pylint src/ tests/ setup.py - - mypy --ignore-missing-imports src/ tests/ setup.py - - pytest --cov=flownet --cov-fail-under=50 ./tests - - pushd examples - - flownet ahm ../tests/configs/norne_parameters.yml ./some_ahm_run - - flownet pred ../tests/configs/norne_pred.yml ./some_pred_run ./some_ahm_run - - popd - - pushd docs - - make html - - popd diff --git a/README.md b/README.md index 36890f67a..fb271365b 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ [![Build Status](https://travis-ci.com/equinor/flownet.svg?token=zKASDqz9PfgMt9WutZq4&branch=master)](https://travis-ci.com/equinor/flownet) -[![Python 3.6 | 3.7 | 3.8](https://img.shields.io/badge/python-3.6%20|%203.7%20|%203.8-blue.svg)](https://www.python.org/) +[![Python 3.6 | 3.7](https://img.shields.io/badge/python-3.6%20|%203.7-blue.svg)](https://www.python.org/) [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) # _FlowNet_ diff --git a/build_environment.sh b/build_environment.sh index daf229321..d2f30c154 100644 --- a/build_environment.sh +++ b/build_environment.sh @@ -59,10 +59,9 @@ if [[ ! -d "$INSTALL_ENV" ]]; then python3 -m venv $INSTALL_ENV - echo "export PYTHONPATH=''" >> $INSTALL_ENV/bin/activate - echo "setenv PYTHONPATH ''" >> $INSTALL_ENV/bin/activate.csh - source $INSTALL_ENV/bin/activate + pip install --upgrade pip + fi ##################