Repository: r5py/r5py (language: python)

Issue:
Set up matrix testing as a GitHub action
Because r5py is a fairly complex pieced-together thing using a Java JDK and being able to run on a range of Python versions (at least 3.8-3.10, as of this writing, probably more), and none of these things are trivial on Windows (slightly better on MacOS and Linux), it might be beneficial to extend testing to use the matrix functionality of GitHub runners to test all possible/likely combinations of Java/Python/OS. 


Discussion / hints:
Might need environment yaml as a precondition (issue #19)
Yes, I think this is a very good idea and hopefully allow us to catch issues with specific versions / OS. 👍🏻 

Fix patch:
diff --git a/.coveragerc b/.coveragerc
new file mode 100644
index 00000000..013dd202
--- /dev/null
+++ b/.coveragerc
@@ -0,0 +1,2 @@
+[report]
+show_missing = True
diff --git a/.gitignore b/.gitignore
index 82148d66..11bbb417 100644
--- a/.gitignore
+++ b/.gitignore
@@ -31,3 +31,5 @@ docs/data/*.mapdb.p
 **/.ipynb_checkpoints
 
 .tox
+.coverage
+coverage.xml
diff --git a/ci/python_310.yaml b/ci/python_310.yaml
new file mode 100644
index 00000000..ec1759b1
--- /dev/null
+++ b/ci/python_310.yaml
@@ -0,0 +1,16 @@
+name: r5py
+
+channels:
+    - conda-forge
+
+dependencies:
+    - python=3.10
+    - configargparse
+    - geopandas
+    - joblib
+    - jpype1
+    - numpy
+    - pandas
+    - psutil
+    - requests
+    - shapely
diff --git a/ci/python_38.yaml b/ci/python_38.yaml
new file mode 100644
index 00000000..fd4c19ab
--- /dev/null
+++ b/ci/python_38.yaml
@@ -0,0 +1,16 @@
+name: r5py
+
+channels:
+    - conda-forge
+
+dependencies:
+    - python=3.8
+    - configargparse
+    - geopandas
+    - joblib
+    - jpype1
+    - numpy
+    - pandas
+    - psutil
+    - requests
+    - shapely
diff --git a/ci/python_39.yaml b/ci/python_39.yaml
new file mode 100644
index 00000000..2324eb27
--- /dev/null
+++ b/ci/python_39.yaml
@@ -0,0 +1,16 @@
+name: r5py
+
+channels:
+    - conda-forge
+
+dependencies:
+    - python=3.9
+    - configargparse
+    - geopandas
+    - joblib
+    - jpype1
+    - numpy
+    - pandas
+    - psutil
+    - requests
+    - shapely
diff --git a/tox.ini b/tox.ini
index 1fa122e4..c213f0a1 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,7 +1,9 @@
 [tox]
-envlist = py3
+envlist = clean,py3
 isolated_build = True
 
 [testenv]
-deps = pytest               # PYPI package providing pytest
-commands = pytest {posargs} # substitute with tox' positional arguments
+deps =
+    pytest
+    pytest-cov
+commands = pytest --cov --cov-report xml


Test patch:
diff --git a/.github/workflows/lint-test-upon-push.yml b/.github/workflows/lint-test-upon-push.yml
index e5ae5cef..59d9e72e 100644
--- a/.github/workflows/lint-test-upon-push.yml
+++ b/.github/workflows/lint-test-upon-push.yml
@@ -1,13 +1,18 @@
 # vim: set tabstop=2 softtabstop=2 shiftwidth=2 expandtab:
 
-name: Lint and test after every push
-on: 
+name: Lint and test after every push or pull request
+on:
   push:
     paths:
       - "*.py"
       - "**/*.py"
+  pull_request:
   workflow_call:
 
+concurrency:
+  group: ${{ github.workflow }}-${{ github.ref }}
+  cancel-in-progress: true
+
 jobs:
   lint:
     name: Linting code
@@ -20,27 +25,77 @@ jobs:
         uses: actions/setup-python@v3
         with:
           python-version: "3.10"
-      - name: Install flake8
-        run: python -m pip install flake8
-      - name: Lint code
-        run: flake8
+      - name: Lint (using pre-commit.com)
+        uses: pre-commit/action@2.0.3
 
   test:
-    name: Run tests
-    runs-on: ubuntu-latest
-    container: python:3
+    name: Run tests (${{ matrix.os }}, ${{ matrix.env }})
+    needs: Linting code
+    runs-on: ${{ matrix.os }}
+    defaults:
+      run:
+        shell: bash -l {0}
+    strategy:
+      fail-fast: false
+      matrix:
+        os: [ubuntu-latest]
+        env:
+          - ci/python_310_dev.yaml
+          - ci/python_310.yaml
+          - ci/python_39.yaml
+          - ci/python_38.yaml
+        include:
+          - env: ci/python_310.yaml
+            os: macos-latest
+          - env: ci/python_310.yaml
+            os: windows-latest
+          - env: ci/python_310.yaml
+            os: ubuntu-latest
+
+          - env: ci/python_39.yaml
+            os: macos-latest
+          - env: ci/python_39.yaml
+            os: windows-latest
+          - env: ci/python_39.yaml
+            os: ubuntu-latest
+
+          - env: ci/python_38.yaml
+            os: macos-latest
+          - env: ci/python_38.yaml
+            os: windows-latest
+          - env: ci/python_38.yaml
+            os: ubuntu-latest
+
     steps:
       - name: Checkout repository
         uses: actions/checkout@v3
+
       - name: Install JVM
         run: |
           apt-get update -qq
           apt-get install -qq openjdk-11-jdk-headless openjdk-11-jre-headless
-      - name: Install Python
-        uses: actions/setup-python@v3
+
+      - name: Setup Conda
+        uses: conda-incubator/setup-miniconda@v2.1.1
         with:
-          python-version: "3.10"
-      - name: Install tox
-        run: python -m pip install tox
-      - name: Run tests
-        run: tox
+          auto-update-conda: true
+          auto-activate-base: false
+          activate-environment: test
+          environment-file: ${{ matrix.env }}
+          channel-priority: strict
+
+      - name: Install ${{GITHUB_REPOSITORY}}
+        shell: bash -l {0}
+        run: pip install .
+
+      - name: Check environment
+        shell: bash -l {0}
+        run: |
+          conda info
+          conda list
+      - name: Test pyrosm
+        shell: bash -l {0}
+        run: pytest --cov --cov-report xml
+
+      - name: Update codecov.io
+        uses: codecov/codecov-action@v3.1.0
diff --git a/tests/conftest.py b/tests/conftest.py
index 8889a74d..88d7767c 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -2,6 +2,12 @@
 
 
 import pytest
+import os
+import sys
+
+
+sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "src"))
+print(sys.path)
 
 
 @pytest.fixture(scope="session", autouse=True)