Repository: pysat/pysatMissions (language: python)

Issue:
pysat 3.0.0 -- manual apexpy edition
# Description

Addresses #pysat/pysat#676

Updates tests to use release candidate.

## Type of change

Please delete options that are not relevant.

- Bug fix (non-breaking change which fixes an issue)

# How Has This Been Tested?

via travis CI

# Checklist:

- [ ] Make sure you are merging into the ``develop`` (not ``main``) branch
- [ ] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been merged and published in downstream modules
- [ ] Add a note to ``CHANGELOG.md``, summarizing the changes

pysat 3.0 release preperation
# Description

Addresses #pysat/pysat#676

Updates tests to use release candidate.

## Type of change

Please delete options that are not relevant.

- Bug fix (non-breaking change which fixes an issue)

# How Has This Been Tested?

via travis CI

# Checklist:

- [ ] Make sure you are merging into the ``develop`` (not ``main``) branch
- [ ] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been merged and published in downstream modules
- [ ] Add a note to ``CHANGELOG.md``, summarizing the changes



Discussion / hints:

@aburrell , I'm having issues installing apexpy under the travis environment with numpy 1.19.2.  I've tried the suggestion from the apexpy site to use `pip install --no-binary :apexpy: apexpy`, but travis seems to have issues with this.

I've tried setting up an alternate environment using github actions (#45).  The install environment works there, but would require some changes under pysat to get the directory setup to work properly.
Ok, I checked the apexpy travis and it looks like its using numpy 1.19.5.  Very confused.  What happens if you grab apexpy from github (to see if it's a package issue or a pypi-apexpy combo issue).
It seems to be a numpy issue.  It compiles if I use numpy 1.20, checking other versions now.  The latest version conda has is 1.19.2, which does not work. 
> Ok, I checked the apexpy travis and it looks like its using numpy 1.19.5. Very confused. What happens if you grab apexpy from github (to see if it's a package issue or a pypi-apexpy combo issue).

Installing apexpy by cloning from github works.
Linking to #45 (github actions version) and #46 (manual install of apexpy) for discussion

Fix patch:
diff --git a/.flake8 b/.flake8
deleted file mode 100644
index c2fe4fae..00000000
--- a/.flake8
+++ /dev/null
@@ -1,3 +0,0 @@
-[flake8]
-max-line-length = 90
-exclude = .git,__pycache__,.eggs/,doc/,docs/,build/,dist/,archive/
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
new file mode 100644
index 00000000..85dffcdb
--- /dev/null
+++ b/.github/workflows/main.yml
@@ -0,0 +1,50 @@
+# 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: Pytest with Flake8
+
+on: [push, pull_request]
+
+jobs:
+  build:
+
+    runs-on: ubuntu-latest
+    strategy:
+      fail-fast: false
+      matrix:
+        python-version: [3.7, 3.8, 3.9]
+
+    name: Python ${{ matrix.python-version }}
+    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 dependencies
+      run: |
+        python -m pip install --upgrade pip
+        pip install -r test_requirements.txt
+        pip install -r requirements.txt
+        # Manual installs required
+        pip install --no-binary :pysatMagVect: pysatMagVect
+
+    - name: Set up pysat
+      run: |
+        mkdir pysatData
+        python -c "import pysat; pysat.params['data_dirs'] = './pysatData'"
+
+    - name: Test PEP8 compliance
+      run: flake8 . --count --select=E,F,W --show-source --statistics
+
+    - name: Evaluate complexity
+      run: flake8 . --count --exit-zero --max-complexity=10 --statistics
+
+    - name: Test with pytest
+      run: |
+        pytest --cov=pysatMissions/
+
+    - name: Publish results to coveralls
+      env:
+        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+      run: coveralls --rcfile=setup.cfg --service=github
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index 4b1bf826..00000000
--- a/.travis.yml
+++ /dev/null
@@ -1,84 +0,0 @@
-os: linux
-language: python
-dist: xenial
-jobs:
-  include:
-    - name: 'docs'
-      python: '3.6'
-      script:
-        - sphinx-build -E -b html docs dist/docs
-        - sphinx-build -b linkcheck docs dist/docs
-    - name: '3.6 w/ numpy 1.16 (NEP 029)'
-      python: '3.6'
-      env: NUMPY_VER=1.16
-      script: pytest --cov=pysatMissions/
-    - name: '3.7 with flake8'
-      python: '3.7'
-      script: pytest --flake8 --cov=pysatMissions/
-    - name: '3.8'
-      python: '3.8'
-      script: pytest --cov=pysatMissions/
-
-services: xvfb
-cache: pip
-addons:
-  apt:
-    packages:
-    - gfortran
-
-install:
-  - sudo apt-get update
-  # We do this conditionally because it saves us some downloading if the
-  # version is the same.
-  - wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh
-  - bash miniconda.sh -b -p $HOME/miniconda
-  - source "$HOME/miniconda/etc/profile.d/conda.sh"
-  - hash -r
-  - conda config --set always_yes True --set changeps1 False
-  - conda update -q conda
-  # Useful for debugging any issues with conda
-  - conda info -a
-  # Create conda test environment
-  - conda create -q -n test-environment python=$TRAVIS_PYTHON_VERSION
-  - conda activate test-environment
-  # Once pysat 3.0 is released, remove the custom pysat install and change
-  # this to:
-  # - while read requirement; do conda install --yes $requirement; done < requirements.txt1
-  # Check for custom numpy version install
-  - if [ -z ${NUMPY_VER} ]; then
-      conda install numpy;
-    else
-      conda install numpy==$NUMPY_VER;
-    fi
-  # Dependencies not available through conda, install through pip
-  - pip install apexpy
-  - pip install aacgmv2
-  - pip install pyEphem
-  - pip install sgp4
-
-  # Get dependencies not provided by conda from pip (testing dependencies)
-  - pip install -r test_requirements.txt
-
-  # Prepare modified pysat install
-  - cd ..
-  - echo 'cloning pysat'
-  - git clone --single-branch --branch develop-3 https://github.com/pysat/pysat.git
-  - echo 'installing pysat'
-  - cd ./pysat
-  # set up data directory
-  - mkdir /home/travis/build/pysatData
-  # install pysat
-  # Install the pysat requirements
-  - while read requirement; do conda install --yes $requirement; done < requirements.txt
-  - python setup.py install >/dev/null
-  - export PYTHONPATH=$PYTHONPATH:$(pwd)
-
-  # Install pysatMagVect after pysat
-  - pip install pysatMagVect >/dev/null
-
-  # install pysatMissions
-  - cd ../pysatMissions
-  - python setup.py install
-
-after_success:
-  - coveralls --rcfile=setup.cfg
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b48c4b83..3fd56b27 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
 - Update sat_id to inst_id for pysat 3.0 compatibility
 - migrate pyglow interface to pysatIncubator
 - Style updates for consistency with pysat 3.0
+- Migrate CI testing to Github Actions
 
 ## [0.2.1] - 2020-07-29
 - Use conda to manage Travis CI environment
diff --git a/README.md b/README.md
index 0107302d..5843caff 100644
--- a/README.md
+++ b/README.md
@@ -7,7 +7,7 @@
 [![Documentation Status](https://readthedocs.org/projects/pysatMissions/badge/?version=latest)](http://pysatMissions.readthedocs.io/en/latest/?badge=latest)
 [![DOI](https://zenodo.org/badge/209358908.svg)](https://zenodo.org/badge/latestdoi/209358908)
 
-[![Build Status](https://travis-ci.com/pysat/pysatMissions.svg?branch=main)](https://travis-ci.com/pysat/pysatMissions)
+[![Build Status](https://github.com/github/docs/actions/workflows/main.yml/badge.svg)](https://github.com/github/docs/actions/workflows/main.yml/badge.svg)
 [![Coverage Status](https://coveralls.io/repos/github/pysat/pysatMissions/badge.svg?branch=main)](https://coveralls.io/github/pysat/pysatMissions?branch=main)
 [![Maintainability](https://api.codeclimate.com/v1/badges/83011911691b9d2076e9/maintainability)](https://codeclimate.com/github/pysat/pysatMissions/maintainability)
 
diff --git a/requirements.txt b/requirements.txt
index a368474b..f6a8e2e0 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -5,4 +5,3 @@ sgp4
 pyEphem
 apexpy
 aacgmv2
-pysatMagVect
diff --git a/setup.cfg b/setup.cfg
index 8e782c10..7ce2b138 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -38,6 +38,15 @@ long_description_content_type = text/markdown
   packages = find:
   install_requires = file: requirements.txt
 
+[coverage:report]
+
+[flake8]
+max-line-length = 90
+ignore =
+  W503
+exclude =
+  docs/conf.py
+
 [tool:pytest]
 markers =
     all_inst: tests all instruments
@@ -45,6 +54,3 @@ markers =
     no_download: tests for instruments without download support
     first: first tests to run
     second: second tests to run
-flake8-ignore =
-  *.py W503
-  docs/conf.py ALL


Test patch:
diff --git a/pysatMissions/tests/test_methods_magcoord.py b/pysatMissions/tests/test_methods_magcoord.py
index d1fca705..1ed0e007 100644
--- a/pysatMissions/tests/test_methods_magcoord.py
+++ b/pysatMissions/tests/test_methods_magcoord.py
@@ -11,7 +11,7 @@ class TestBasics():
     def setup(self):
         """Runs before every method to create a clean testing setup."""
         self.testInst = pysat.Instrument(platform='pysat', name='testing',
-                                         inst_id='100', clean_level='clean')
+                                         num_samples=100, clean_level='clean')
 
     def teardown(self):
         """Clean up test environment after tests"""
diff --git a/pysatMissions/tests/test_methods_spacecraft.py b/pysatMissions/tests/test_methods_spacecraft.py
index 75524dca..b169acca 100644
--- a/pysatMissions/tests/test_methods_spacecraft.py
+++ b/pysatMissions/tests/test_methods_spacecraft.py
@@ -31,7 +31,7 @@ class TestBasics():
     def setup(self):
         """Runs before every method to create a clean testing setup."""
         self.testInst = pysat.Instrument(platform='pysat', name='testing',
-                                         inst_id='9', clean_level='clean')
+                                         num_samples=9, clean_level='clean')
         self.testInst.custom_attach(add_eci)
 
     def teardown(self):