Add gh action ci tests from rpy2
Change-Id: I18196d84f8668fb22cc7c149565e7c94abe666e0
diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml
new file mode 100644
index 0000000..eaa02bc
--- /dev/null
+++ b/.github/workflows/pythonpackage.yml
@@ -0,0 +1,61 @@
+name: PythonKorAPClient CI unit test
+
+on: [push, pull_request]
+
+jobs:
+ build:
+
+ runs-on: ${{ matrix.os }}
+ strategy:
+ max-parallel: 4
+ matrix:
+ python-version: [3.5, 3.6, 3.7, 3.8]
+ r-version: [3.6, 4.0]
+ os: [macOS-latest, ubuntu-latest, windows-latest]
+ exclude:
+ # os: windows-latest
+ # python-version: 3.8
+ - python-version: 3.5
+ - os: windows-latest
+ steps:
+ - uses: actions/checkout@v1
+ - name: Set up Python ${{ matrix.python-version }}
+ uses: actions/setup-python@v1
+ with:
+ python-version: ${{ matrix.python-version }}
+ - name: Set up R ${{ matrix.r-version }}
+ uses: r-lib/actions/setup-r@master
+ with:
+ r-version: ${{ matrix.r-version }}
+ - 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
+ - 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
+ - name: Install package
+ run: |
+ python setup.py 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
+ - name: Test with pytest on Windows
+ if: runner.os == 'Windows'
+ run: |
+ pip install pytest codecov pytest-cov ipython
+ ./scripts/run_tests.sh
diff --git a/install_r_packages.r b/install_r_packages.r
new file mode 100755
index 0000000..56f81ce
--- /dev/null
+++ b/install_r_packages.r
@@ -0,0 +1,5 @@
+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
new file mode 100755
index 0000000..499708e
--- /dev/null
+++ b/scripts/R_run.bat
@@ -0,0 +1,7 @@
+set R_USER=C:\R
+set R_HOME=C:\R
+set PATH=%R_HOME%\bin\i386;%PATH%
+set
+python %1 %2 %3 %4 %5 %6
+
+
diff --git a/scripts/run_tests.sh b/scripts/run_tests.sh
new file mode 100755
index 0000000..f49f844
--- /dev/null
+++ b/scripts/run_tests.sh
@@ -0,0 +1,7 @@
+#!/bin/bash
+
+sudo Rscript ./install_r_packages.r RKorAPClient
+
+pytest \
+ --cov-append \
+ KorAPClient/tests