Simplify gh action CI tests

Change-Id: I86cdd29ced74d114e1ee506c65d2342c3e77f8c3
diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml
index eaa02bc..d0c5dd5 100644
--- a/.github/workflows/pythonpackage.yml
+++ b/.github/workflows/pythonpackage.yml
@@ -9,53 +9,81 @@
     strategy:
       max-parallel: 4
       matrix:
-        python-version: [3.5, 3.6, 3.7, 3.8]
+        python-version: [3.7, 3.8]
         r-version: [3.6, 4.0]
-        os: [macOS-latest, ubuntu-latest, windows-latest]
+        os: [windows-latest, macOS-latest, ubuntu-20.04]
         exclude:
-            # os: windows-latest
-            # python-version: 3.8
-          - python-version: 3.5
+          - os: macOS-latest
+            python-version: 3.7
           - os: windows-latest
+            python-version: 3.7
+          - os: windows-latest
+            r-version: 3.6
+          - os: ubuntu-20.04
+            r-version: 4.0
     steps:
-    - uses: actions/checkout@v1
+    - uses: actions/checkout@v2
     - name: Set up Python ${{ matrix.python-version }}
-      uses: actions/setup-python@v1
+      uses: actions/setup-python@v2
       with:
         python-version: ${{ matrix.python-version }}
+    - name: Cache pip
+      uses: actions/cache@v2
+      with:
+        # This path is specific to Ubuntu
+        path: ~/.cache/pip
+        # Look to see if there is a cache hit for the corresponding requirements file
+        key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}
+        restore-keys: |
+          ${{ runner.os }}-pip-
+          ${{ runner.os }}-
     - name: Set up R ${{ matrix.r-version }}
       uses: r-lib/actions/setup-r@master
       with:
         r-version: ${{ matrix.r-version }}
+      if: runner.os != 'Linux'
+    - name: Set up package maintainers R on Linux
+      run: |
+        sudo apt-get update -y
+        sudo apt-get install -y r-base r-base-dev r-cran-tidyverse r-cran-r.utils r-cran-pixmap r-cran-webshot r-cran-ade4 r-cran-segmented r-cran-purrr r-cran-dygraphs r-cran-cvst r-cran-quantmod r-cran-graphlayouts r-cran-rappdirs r-cran-ggdendro r-cran-seqinr r-cran-heatmaply r-cran-igraph r-cran-plotly libcurl4-gnutls-dev libssl-dev libxml2-dev libsodium-dev python3-pip python3-rpy2 python3-pandas
+        sudo chown $USER /usr/local/lib/R/site-library
+        export R_LIBS_USER=/usr/local/lib/R/site-library
+      if: runner.os == 'Linux'
+    - name: Install R dependencies
+      run: Rscript -e "install.packages('RKorAPClient')"
+    - name: Cache R packages on Linux
+      uses: actions/cache@v1
+      with:
+        path: /usr/local/lib/R/site-library
+        key: ${{ runner.os }}-r-${{ matrix.config.r }}-${{ hashFiles('DESCRIPTION') }}
+      if: runner.os == 'Linux'
     - name: Cache R packages
       uses: actions/cache@v1
       with:
         path: ${{ env.R_LIBS_USER }}
         key: ${{ runner.os }}-r-${{ matrix.config.r }}-${{ hashFiles('DESCRIPTION') }}
-    - name: Install Linux system dependencies
-      if: runner.os == 'Linux'
-      run: |
-        sudo apt-get update -y
-        sudo apt-get install -y libglpk-dev libjq-dev libv8-dev libprotobuf-dev protobuf-compiler libudunits2-dev libgdal-dev libcurl4-gnutls-dev libssl-dev libxml2-dev libsodium-dev python3-rpy2 python3-pandas
+      if: runner.os != 'Linux'
     - name: Install dependencies
       run: |
         python -m pip install --upgrade pip
-    - name: Install windows dependencies
-      if: runner.os == 'Windows' && matrix.python-version == '3.8'
-      run: |
-        echo "Bug in setuptools requires update"
-        python -m pip install --upgrade setuptools pycparser wheel
+        pip install wheel
     - name: Install package
       run: |
-        python setup.py install
+        pip install .
     - name: Test with pytest on POSIX
       if: runner.os != 'Windows'
       run: |
         export LD_LIBRARY_PATH=$(python -m rpy2.situation LD_LIBRARY_PATH):${LD_LIBRARY_PATH}
-        pip install pytest codecov pytest-cov ipython
-        ./scripts/run_tests.sh
+        pip install pytest
+        pytest KorAPClient/tests  --junitxml=junit/test-results-${{ matrix.python-version }}.xml
     - name: Test with pytest on Windows
       if: runner.os == 'Windows'
       run: |
-        pip install pytest codecov pytest-cov ipython
-        ./scripts/run_tests.sh
+        ./scripts/R_run.bat setup.py test
+    - name: Upload check results
+      if: failure()
+      uses: actions/upload-artifact@master
+      with:
+        name: pytest-results-${{ matrix.python-version }}
+        path: junit/test-results-${{ matrix.python-version }}.xml
+
diff --git a/install_r_packages.r b/install_r_packages.r
deleted file mode 100755
index 56f81ce..0000000
--- a/install_r_packages.r
+++ /dev/null
@@ -1,5 +0,0 @@
-args <- commandArgs(trailingOnly = TRUE)
-
-repos <- "https://cran.rstudio.com" 
-
-install.packages(args, repos = repos)
diff --git a/scripts/R_run.bat b/scripts/R_run.bat
index 499708e..d10b1da 100755
--- a/scripts/R_run.bat
+++ b/scripts/R_run.bat
@@ -1,6 +1,11 @@
+Rscript -e '.libPaths()'
 set R_USER=C:\R
 set R_HOME=C:\R
 set PATH=%R_HOME%\bin\i386;%PATH%
+set PATH=%R_HOME%\bin;%PATH%
+set PATH=%R_HOME%\bin\x64;%PATH%
+set PATH=%R_HOME%;%PATH%
+echo %PATH%
 set
 python %1 %2 %3 %4 %5 %6
 
diff --git a/scripts/run_tests.sh b/scripts/run_tests.sh
index f49f844..15a73d2 100755
--- a/scripts/run_tests.sh
+++ b/scripts/run_tests.sh
@@ -1,7 +1,5 @@
 #!/bin/bash
 
-sudo Rscript ./install_r_packages.r RKorAPClient
-
 pytest \
     --cov-append \
     KorAPClient/tests