Repository: NREL/bifacial_radiance (language: python)

Issue:
Sensors change
Updating analysis.moduleAnalysis and analysis1axis to remove sensorsy_front, sensorsy_back, sensorsx_front, sensorsx_back.  Instsead, sensorsy and sensorsx can accept either a numeric value, or a list or tuple.  If list or tuple is used, the first element is the number of front sensors.  The second element is the number of back sensors.
Migrate from Travis to GitHub Actions
This PR adds GitHub Actions workflows for running the test suite and deploying releases to PyPI.  It was made much easier by having the current Travis config as a reference!

There is one test failure (`test_readWeatherFile_subhourly`) that I think is not a problem with the CI configuration but instead some other issue.  Seems like #340 ran into the same thing, so I figured I'd leave it alone here.  

Also, the eager-upgrade variant is failing the `test_SingleModule_gencumsky_modelchain` test -- is that a problem here?

To-do:
- [ ] remove `.travis.yml` and disable travis
- [ ] add PyPI deploy secrets to repo settings


Discussion / hints:
Hey @shirubana - this is going to change behavior of the development branch, but I think it's for the better.  Instead of coming up with four new kwargs (sensorsy_front, sensorsy_back, etc) it reuses the normal sensorsy, but allows you to pass two values into it.  Second value is the rear scan number.  What do you think?
Good point, I'll make sure to allow that in the GUI and modelchain.


Fix patch:
diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml
new file mode 100644
index 00000000..1a202f81
--- /dev/null
+++ b/.github/workflows/deploy.yaml
@@ -0,0 +1,33 @@
+name: Deploy Python Package
+
+on:
+  release:
+    types: [published]
+
+jobs:
+  deploy:
+    name: Deploy to PyPI
+    runs-on: ubuntu-latest
+
+    steps:
+    - uses: actions/checkout@v2
+    - name: Set up Python
+      uses: actions/setup-python@v2
+      with:
+        python-version: '3.7'
+    - name: Install dependencies
+      run: |
+        python -m pip install --upgrade pip
+        pip install setuptools wheel twine
+    - name: Build and publish
+      env:
+        TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
+        TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
+      run: |
+        python setup.py sdist bdist_wheel
+        twine upload dist/*
+    - uses: actions/upload-artifact@v2
+      with:
+        name: dist
+        path: |
+          dist/*
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index ed9a87e8..00000000
--- a/.travis.yml
+++ /dev/null
@@ -1,87 +0,0 @@
-sudo: false
-
-language: python
-
-python:
-#  - "3.6"
-  - "3.7"
-
-# Test two environments:
-# 1) dependencies with pinned versions from requirements.txt
-# 2) 'pip install --upgrade --upgrade-strategy=eager .' to install upgraded
-#    dependencies from PyPi using version ranges defined within setup.py
-env:
-  - REQ_ENV='-r requirements.txt .[all]'
-  - REQ_ENV='--upgrade --upgrade-strategy=eager .[all]'
-
-# GUI testing requires xvfb
-dist: xenial
-services:
-  - xvfb
-
-# Radiance is required to run tests. Download and setup v5.2
-
-before_install:
-  - pwd
-  - wget https://github.com/NREL/Radiance/releases/download/5.2/radiance-5.2.dd0f8e38a7-Linux.tar.gz -O /tmp/radiance.tar.gz
-  - tar -xvf /tmp/radiance.tar.gz
-  - export PATH=$PATH:$PWD/radiance-5.2.dd0f8e38a7-Linux/usr/local/radiance/bin
-  - export RAYPATH=.:$PWD/radiance-5.2.dd0f8e38a7-Linux/usr/local/radiance/lib
-  - export MANPATH=$MANPATH:$PWD/radiance-5.2.dd0f8e38a7-Linux/usr/local/radiance/man
-
-# Copy gencumulativesky into RAYPATH...
-  - ls -l /home/travis/build/NREL/bifacial_radiance/bifacial_radiance/data
-  - cp $PWD/bifacial_radiance/data/gencumulativesky $PWD/radiance-5.2.dd0f8e38a7-Linux/usr/local/radiance/bin/
-# - ls -l $PWD/radiance-5.2.dd0f8e38a7-Linux/usr/local/radiance/bin
-# Get SMARTS 2.9.5
-  - wget https://www.nrel.gov/grid/solar-resource/assets/data/smarts-295-linux-tar.gz -O /tmp/smarts.tar.gz
-  - tar -xvf /tmp/smarts.tar.gz
-  - export SMARTSPATH=/home/travis/build/NREL/bifacial_radiance/SMARTS_295_Linux
-  - export PATH=$PATH:/home/travis/build/NREL/bifacial_radiance/SMARTS_295_Linux
-# Try compiling from source
-  - unlink $PWD/SMARTS_295_Linux/smarts295bat
-  - sed -i 's/batch=.FALSE./batch=.TRUE./g' $PWD/SMARTS_295_Linux/Source_code/smarts295.f
-  - sudo apt-get install gfortran
-  - gfortran -o $PWD/SMARTS_295_Linux/smarts295bat $PWD/SMARTS_295_Linux/Source_code/smarts295.f
-#  - $PWD/SMARTS_295_Linux/smarts295bat
-#  - ldd $PWD/SMARTS_295_Linux/smarts295bat
-  - ls -l $PWD/SMARTS_295_Linux/
-
-
-# Example from TravisCI: https://docs.travis-ci.com/user/installing-dependencies
-#before_install:
-#  - wget https://github.com/n1k0/casperjs/archive/1.0.2.tar.gz -O /tmp/casper.tar.gz
-#  - tar -xvf /tmp/casper.tar.gz
-#  - export PATH=$PATH:$PWD/casperjs-1.0.2/bin/
-  
-install:
-  - pip install $REQ_ENV
-  - pip install coveralls
-
-script:
-#  - pytest -v -k "test_generate_spectra"
-  - pytest --cov=bifacial_radiance
-after_success:
-  - coveralls
-after_script:
-# debug what's going on - try to ls-l the tests folder to see where things are saved
-  - pwd
-  - ls -l /home/travis/build/NREL/bifacial_radiance/SMARTS_295_Linux
-  - ls -l /home/travis/build/NREL/bifacial_radiance/SMARTS_295_Linux/OUTPUT
-  - cd /home/travis/build/NREL/bifacial_radiance/SMARTS_295_Linux
-  - $PWD/smarts295bat
-  
-# Deploy to pypi on the python 3.6 build with upgraded dependencies when 
-# a new version is tagged on github from the master branch. Example from Rdtools
-deploy:
-  provider: pypi
-  user: cdeline
-  password:
-    secure:  NIZJOZDH0YH0v6oXAP9OZtwimBWWqXd//3LlaUP4mBnEiJtZ/aCh1LKMTviPYJGuzt9eLroUyAlZGw1lEkGi8dK+z1MS4WFm8HiQn/Y1lAfP9GuZz5eh8rqPSW8WwEl/BnqZoEFYZ4KD7PW/4utoVLfvLVIXsb24beUklDavhr7BAhUp1wQDK25t2hAiiJu7NdWA9Rnw30aPA0dZe2uFCBZOwBNd/ePWBnVUngUbQxZF34DhUOwcOWX+9jFTwbnH8jEa6wVXV6jWNJ34ZuLUrTqiDQLiTkvFVNtlJO+4Ja7zxJPmLQjSCM4rQ5bod0PAJwoAOfOgjT2YWZRrI7Ia9FDjSDDrT8A7S56WnzRuMNBzGkQrPYEDYPtCVmdRSw8k09HKXPaO6RGy6nZzm6SXGKLISJkDnHG7YjpUsXVOuOv8JC9khCM6DdXAVwi5hTWouNz/MUwx/mW8DW1lwLEZZEsnFLoja9hSYEnfFl3TMguQKJFL7l94U8Dz78iAuCMqN6zcOn1yHrVEat2cMLD2LbsEEImFcBqwf0N3kh6VFGk4oi9FUbBMOifXrkMUlJ/tkUPYCxG5kmANtEe26a8Ak/6RM8WZ0IVb5xdf28CmgTGYHneQqORpkj5yYC6Le6YYHIhfhQt9gZcnhHyKVqOCL6GA9HNSrKk0/mLwi/VpRqU=
-  distributions: "sdist bdist_wheel"
-  on:
-    tags: true
-    branch: master
-    #python: 3.7
-    condition: $REQ_ENV == '--upgrade --upgrade-strategy=eager .'
-  #skip_cleanup:  true
\ No newline at end of file


Test patch:
diff --git a/.github/workflows/pytest.yaml b/.github/workflows/pytest.yaml
new file mode 100644
index 00000000..ddda8b15
--- /dev/null
+++ b/.github/workflows/pytest.yaml
@@ -0,0 +1,72 @@
+name: test
+
+on: [pull_request, push]
+
+jobs:
+  pytest:
+
+    runs-on: ubuntu-latest
+    strategy:
+      fail-fast: false  # don't cancel other matrix jobs when one fails
+      matrix:
+        python-version: ["3.7"]
+        # Test two environments:
+        # 1) dependencies with pinned versions from requirements.txt
+        # 2) 'pip install --upgrade --upgrade-strategy=eager .' to install upgraded
+        #    dependencies from PyPi using version ranges defined within setup.py
+        env: [
+          '-r requirements.txt .[all]',
+          '--upgrade --upgrade-strategy=eager .[all]'
+        ]
+
+    steps:
+    - uses: actions/checkout@v2
+
+    - name: Set up Python ${{ matrix.python-version }}
+      uses: actions/setup-python@v2
+      with:
+        python-version: ${{ matrix.python-version }}
+
+    - name: Install Radiance v5.2
+      run: |
+        wget https://github.com/NREL/Radiance/releases/download/5.2/radiance-5.2.dd0f8e38a7-Linux.tar.gz -O /tmp/radiance.tar.gz
+        tar -xvf /tmp/radiance.tar.gz
+
+    - name: Copy gencumulativesky into radiance /bin
+      run: |
+        cp $PWD/bifacial_radiance/data/gencumulativesky $PWD/radiance-5.2.dd0f8e38a7-Linux/usr/local/radiance/bin/
+
+    - name: Install SMARTS 2.9.5
+      run: |
+        wget https://www.nrel.gov/grid/solar-resource/assets/data/smarts-295-linux-tar.gz -O /tmp/smarts.tar.gz
+        tar -xvf /tmp/smarts.tar.gz
+        unlink $PWD/SMARTS_295_Linux/smarts295bat
+        sed -i 's/batch=.FALSE./batch=.TRUE./g' $PWD/SMARTS_295_Linux/Source_code/smarts295.f
+        sudo apt-get install gfortran
+        gfortran -o $PWD/SMARTS_295_Linux/smarts295bat $PWD/SMARTS_295_Linux/Source_code/smarts295.f
+        ls -l $PWD/SMARTS_295_Linux/
+
+    - name: Install ${{ matrix.env }}
+      run: |
+        pip install ${{ matrix.env }}
+        pip install coveralls wheel
+
+    - name: Set environment variables
+      run: |
+        # https://docs.github.com/en/actions/learn-github-actions/workflow-commands-for-github-actions#adding-a-system-path
+        echo "/home/runner/work/bifacial_radiance/bifacial_radiance/radiance-5.2.dd0f8e38a7-Linux/usr/local/radiance/bin" >> $GITHUB_PATH
+        echo "/home/runner/work/bifacial_radiance/bifacial_radiance/SMARTS_295_Linux" >> $GITHUB_PATH
+
+    - name: Test with pytest ${{ matrix.env }}
+      uses: GabrielBB/xvfb-action@v1  # GUI testing requires xvfb
+      with:
+        run: |
+          pytest --cov=bifacial_radiance
+      env:  # environment variables available to this step
+        RAYPATH: .:/home/runner/work/bifacial_radiance/bifacial_radiance/radiance-5.2.dd0f8e38a7-Linux/usr/local/radiance/lib
+        SMARTSPATH: /home/runner/work/bifacial_radiance/bifacial_radiance/SMARTS_295_Linux
+
+    - name: Coveralls
+      run: |
+        coveralls
+