Repository: OceanParcels/Parcels (language: python)

Issue:
Fixing the vonmises distribution tests in test_diffusion
Because of a change to the vonmises distribution implementation in scipy v1.10.0. This fixes #1274 


Discussion / hints:

Fix patch:
diff --git a/.github/actions/install-parcels/action.yml b/.github/actions/install-parcels/action.yml
new file mode 100644
index 000000000..ed682f5ba
--- /dev/null
+++ b/.github/actions/install-parcels/action.yml
@@ -0,0 +1,44 @@
+name: Setup Anaconda and install parcels
+description: > 
+  In-repo composite action to setup Anaconda and install parcels. Installation of parcels relies on
+  `setup.py` file being available in the root. For general setup of Anaconda environments, just use
+  the `conda-incubator/setup-miniconda` action (setting C variables as required)
+inputs:
+  environment-file:
+    description: "Anaconda environment file"
+    required: true
+  environment-name:
+    description: "Anaconda environment name"
+    required: true
+runs:
+  using: "composite"
+  steps:
+    - name: Configure pagefile # Windows compatability fix as per PR #1279
+      if: ${{ runner.os == 'Windows' }}
+      uses: al-cheb/configure-pagefile-action@v1.3
+      with:
+        minimum-size: 8GB
+    - name: Setup Miniconda
+      uses: conda-incubator/setup-miniconda@v2.2.0
+      with:
+        miniconda-version: "latest"
+        activate-environment: ${{ inputs.environment-name }} # Needs to be the same as listed in the env file
+        environment-file: ${{ inputs.environment-file }}
+        auto-activate-base: false
+        auto-update-conda: true
+    - run: conda info
+      shell: bash -el {0}
+    - name: Install parcels
+      run: python setup.py install
+      shell: bash -el {0}
+    - name: Set env variables for macos
+      run: |
+        if [[ "${{ runner.os }}" == macOS ]]; then
+          echo "Setting CONDA_BUILD_SYSROOT and C_INCLUDE_PATH for macos"
+          echo "CONDA_BUILD_SYSROOT=/" >> $GITHUB_ENV
+          echo "C_INCLUDE_PATH=$C_INCLUDE_PATH:/Applications/Xcode.app/Contents//Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/" >> $GITHUB_ENV
+          echo "CC=gcc" >> $GITHUB_ENV
+        else
+          echo "Platform not macos."
+        fi
+      shell: bash
diff --git a/.github/scripts/install_miniconda.ps1 b/.github/scripts/install_miniconda.ps1
deleted file mode 100755
index 296ff804e..000000000
--- a/.github/scripts/install_miniconda.ps1
+++ /dev/null
@@ -1,106 +0,0 @@
-# Sample script to install Python and pip under Windows
-# Authors: Olivier Grisel, Jonathan Helmus, Kyle Kastner, and Alex Willmer
-# License: CC0 1.0 Universal: http://creativecommons.org/publicdomain/zero/1.0/
-
-$MINICONDA_URL = "http://repo.continuum.io/miniconda/"
-$BASE_URL = "https://www.python.org/ftp/python/"
-$GET_PIP_URL = "https://bootstrap.pypa.io/get-pip.py"
-$GET_PIP_PATH = "C:\get-pip.py"
-
-$PYTHON_PRERELEASE_REGEX = @"
-(?x)
-(?<major>\d+)
-\.
-(?<minor>\d+)
-\.
-(?<micro>\d+)
-(?<prerelease>[a-z]{1,2}\d+)
-"@
-
-
-function Download ($filename, $url) {
-    $webclient = New-Object System.Net.WebClient
-
-    $basedir = $pwd.Path + "\"
-    $filepath = $basedir + $filename
-    if (Test-Path $filename) {
-        Write-Host "Reusing" $filepath
-        return $filepath
-    }
-
-    # Download and retry up to 3 times in case of network transient errors.
-    Write-Host "Downloading" $filename "from" $url
-    $retry_attempts = 2
-    for ($i = 0; $i -lt $retry_attempts; $i++) {
-        try {
-            $webclient.DownloadFile($url, $filepath)
-            break
-        }
-        Catch [Exception]{
-            Start-Sleep 1
-        }
-    }
-    if (Test-Path $filepath) {
-        Write-Host "File saved at" $filepath
-    } else {
-        # Retry once to get the error message if any at the last try
-        $webclient.DownloadFile($url, $filepath)
-    }
-    return $filepath
-}
-
-
-function ParsePythonVersion ($python_version) {
-    if ($python_version -match $PYTHON_PRERELEASE_REGEX) {
-        return ([int]$matches.major, [int]$matches.minor, [int]$matches.micro,
-                $matches.prerelease)
-    }
-    $version_obj = [version]$python_version
-    return ($version_obj.major, $version_obj.minor, $version_obj.build, "")
-}
-
-
-function DownloadMiniconda ($python_version, $platform_suffix) {
-    if ($python_version -like "3*") {
-        $filename = "Miniconda3-latest-Windows-" + $platform_suffix + ".exe"
-    } else {
-        $filename = "Miniconda2-latest-Windows-" + $platform_suffix + ".exe"
-    }
-    $url = $MINICONDA_URL + $filename
-    $filepath = Download $filename $url
-    return $filepath
-}
-
-
-function InstallMiniconda ($python_version, $architecture, $python_home) {
-    Write-Host "Installing Python" $python_version "for" $architecture "bit architecture to" $python_home
-    if (Test-Path $python_home) {
-        Write-Host $python_home "already exists, skipping."
-        return $false
-    }
-    if ($architecture -eq "32") {
-        $platform_suffix = "x86"
-    } else {
-        $platform_suffix = "x86_64"
-    }
-    $filepath = DownloadMiniconda $python_version $platform_suffix
-    Write-Host "Installing" $filepath "to" $python_home
-    $install_log = $python_home + ".log"
-    $args = "/S /D=$python_home"
-    Write-Host $filepath $args
-    Start-Process -FilePath $filepath -ArgumentList $args -Wait -Passthru
-    if (Test-Path $python_home) {
-        Write-Host "Python $python_version ($architecture) installation complete"
-    } else {
-        Write-Host "Failed to install Python in $python_home"
-        Get-Content -Path $install_log
-        Exit 1
-    }
-}
-
-
-function main () {
-    InstallMiniconda $env:PY_VERSION $env:PYTHON_ARCH $env:PYTHON
-}
-
-main
diff --git a/.github/scripts/linux_install.sh b/.github/scripts/linux_install.sh
deleted file mode 100755
index 78905b734..000000000
--- a/.github/scripts/linux_install.sh
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/bash
-
-wget http://repo.continuum.io/miniconda/${MINICONDA_NAME} -O miniconda.sh;
-bash miniconda.sh -b -p $HOME/miniconda
-export PATH="$HOME/miniconda/bin:$PATH"
-conda env create --name parcels --file environment_py${PY_VERSION}_${OS_NAME}.yml
-source activate parcels
-python setup.py install
diff --git a/.github/scripts/windows_install.bat b/.github/scripts/windows_install.bat
deleted file mode 100755
index 09ea28db6..000000000
--- a/.github/scripts/windows_install.bat
+++ /dev/null
@@ -1,5 +0,0 @@
-SET PATH=%PYTHON%;%PYTHON%\Scripts;%PATH%
-conda update -q --yes conda
-conda env create -f environment_py%PY_VERSION%_%OS_NAME%.yml -n parcels
-call activate parcels
-python setup.py install
diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml
new file mode 100644
index 000000000..848da76ea
--- /dev/null
+++ b/.github/workflows/linting.yml
@@ -0,0 +1,19 @@
+name: linting
+on:
+  pull_request:
+  push:
+jobs:
+  linting:
+    name: Linting with flake8
+    runs-on: ubuntu-latest
+    steps:
+      - name: Checkout
+        uses: actions/checkout@master
+      - name: Python setup
+        run: |
+          pip install wheel
+          pip install flake8
+      - name: flake8
+        run: |
+          python -m flake8 parcels
+          python -m flake8 tests
\ No newline at end of file
diff --git a/environment_py3_linux.yml b/environment_py3_linux.yml
index bbc9be01d..16c2e1169 100644
--- a/environment_py3_linux.yml
+++ b/environment_py3_linux.yml
@@ -25,6 +25,7 @@ dependencies:
   - cftime>=1.3.1
   - dask>=2.0
   - pytest
+  - pytest-html
   - nbval
   - scikit-learn
   - pykdtree
diff --git a/environment_py3_osx.yml b/environment_py3_osx.yml
index 120571fb5..10563da66 100644
--- a/environment_py3_osx.yml
+++ b/environment_py3_osx.yml
@@ -25,6 +25,7 @@ dependencies:
   - dask>=2.0
   - cftime>=1.3.1
   - pytest
+  - pytest-html
   - nbval
   - scikit-learn
   - pykdtree
diff --git a/environment_py3_win.yml b/environment_py3_win.yml
index f4ecf30fd..1dccbe0f3 100644
--- a/environment_py3_win.yml
+++ b/environment_py3_win.yml
@@ -23,6 +23,7 @@ dependencies:
   - cftime>=1.3.1
   - ipykernel
   - pytest
+  - pytest-html
   - nbval
   - pykdtree
   - zarr


Test patch:
diff --git a/.github/scripts/linux_integrationtest.sh b/.github/scripts/linux_integrationtest.sh
deleted file mode 100755
index 5cfcf094f..000000000
--- a/.github/scripts/linux_integrationtest.sh
+++ /dev/null
@@ -1,11 +0,0 @@
-#!/bin/bash
-export PATH="$HOME/miniconda/bin:$PATH"
-source activate parcels
-
-# Set up display to be able to plot in linux
-export DISPLAY=:99.0;
-sh -e /etc/init.d/xvfb start;
-sleep 3;
-
-parcels_get_examples examples/;
-pytest -v -s --nbval-lax -k "not documentation" examples/;
diff --git a/.github/scripts/linux_unittest.sh b/.github/scripts/linux_unittest.sh
deleted file mode 100755
index 372f0dcba..000000000
--- a/.github/scripts/linux_unittest.sh
+++ /dev/null
@@ -1,10 +0,0 @@
-#!/bin/bash
-export PATH="$HOME/miniconda/bin:$PATH"
-source activate parcels
-
-# Set up display to be able to plot in linux
-export DISPLAY=:99.0;
-sh -e /etc/init.d/xvfb start;
-sleep 3;
-
-pytest -v -s tests/ ;
diff --git a/.github/scripts/osx_integrationtest.sh b/.github/scripts/osx_integrationtest.sh
deleted file mode 100755
index 4be3991cf..000000000
--- a/.github/scripts/osx_integrationtest.sh
+++ /dev/null
@@ -1,8 +0,0 @@
-export PATH="$HOME/miniconda/bin:$PATH"
-source activate parcels
-
-export CONDA_BUILD_SYSROOT=/
-export C_INCLUDE_PATH=$C_INCLUDE_PATH:/Applications/Xcode.app/Contents//Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/
-
-parcels_get_examples examples/;
-pytest -v -s --nbval-lax -k "not documentation" examples/;
diff --git a/.github/scripts/osx_unittest.sh b/.github/scripts/osx_unittest.sh
deleted file mode 100755
index 0301eab89..000000000
--- a/.github/scripts/osx_unittest.sh
+++ /dev/null
@@ -1,7 +0,0 @@
-export PATH="$HOME/miniconda/bin:$PATH"
-source activate parcels
-
-export CONDA_BUILD_SYSROOT=/
-export C_INCLUDE_PATH=$C_INCLUDE_PATH:/Applications/Xcode.app/Contents//Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/
-
-pytest -v -s tests/;
diff --git a/.github/scripts/windows_integrationtest.bat b/.github/scripts/windows_integrationtest.bat
deleted file mode 100755
index 968f6ea65..000000000
--- a/.github/scripts/windows_integrationtest.bat
+++ /dev/null
@@ -1,4 +0,0 @@
-SET PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%
-call activate parcels
-parcels_get_examples examples/;
-pytest -v -s --nbval-lax -k "not documentation" examples/;
diff --git a/.github/scripts/windows_unittest.bat b/.github/scripts/windows_unittest.bat
deleted file mode 100755
index 1c4723296..000000000
--- a/.github/scripts/windows_unittest.bat
+++ /dev/null
@@ -1,3 +0,0 @@
-SET PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%
-call activate parcels
-pytest -v -s tests/
diff --git a/.github/workflows/ci-workflow-integrationtests.yml b/.github/workflows/ci-workflow-integrationtests.yml
deleted file mode 100644
index 910d87f92..000000000
--- a/.github/workflows/ci-workflow-integrationtests.yml
+++ /dev/null
@@ -1,56 +0,0 @@
-name: integration-tests
-on:
-  pull_request:
-jobs:
-  test_macOS:
-    name: Integration testing on macOS python latest
-    if: github.event.pull_request.draft == false
-    runs-on: macOS-latest
-    steps:
-      - uses: actions/checkout@master
-      - name: Test OSX
-        env:
-          OS_NAME: osx
-          PY_VERSION: 3
-          MINICONDA_NAME: Miniconda3-latest-MacOSX-x86_64.sh
-          CC: gcc
-        run: |
-          ./.github/scripts/linux_install.sh
-          ./.github/scripts/osx_integrationtest.sh
-        shell: bash
-  test_linux:
-    name: Integration testing on Linux python latest
-    if: github.event.pull_request.draft == false
-    runs-on: ubuntu-latest
-    steps:
-      - uses: actions/checkout@master
-      - name: Test linux
-        env:
-          OS_NAME: linux
-          PY_VERSION: 3
-          MINICONDA_NAME: Miniconda3-latest-Linux-x86_64.sh
-        run: |
-          ./.github/scripts/linux_install.sh
-          ./.github/scripts/linux_integrationtest.sh
-        shell: bash
-  test_windows:
-    name: Integration testing on Windows python latest
-    if: github.event.pull_request.draft == false
-    runs-on: windows-latest
-    steps:
-      - uses: actions/checkout@master
-      - name: Configure pagefile
-        uses: al-cheb/configure-pagefile-action@v1.2
-        with:
-          minimum-size: 8GB
-      - name: Test Windows
-        env:
-          OS_NAME: win
-          PY_VERSION: 3
-          PYTHON_ARCH: 64
-          PYTHON: C:\Miniconda36-x64
-        run: |
-          ./.github/scripts/install_miniconda.ps1
-          ./.github/scripts/windows_install.bat
-          ./.github/scripts/windows_integrationtest.bat
-        shell: powershell
diff --git a/.github/workflows/ci-workflow-unittests.yml b/.github/workflows/ci-workflow-unittests.yml
deleted file mode 100644
index 5c80ecfae..000000000
--- a/.github/workflows/ci-workflow-unittests.yml
+++ /dev/null
@@ -1,65 +0,0 @@
-name: unit-tests
-on:
-  pull_request:
-jobs:
-  pep8-linter:
-    name: Testing PEP8 linter
-    runs-on: ubuntu-latest
-    steps:
-      - uses: actions/checkout@master
-      - name: Lint with flake8
-        run: |
-          pip install wheel
-          pip install flake8
-          python -m flake8 parcels/
-          python -m flake8 tests/
-        shell: bash
-  test_macOS:
-    name: Unittesting on macOS python latest
-    runs-on: macOS-latest
-    steps:
-      - uses: actions/checkout@master
-      - name: Test OSX
-        env:
-          OS_NAME: osx
-          PY_VERSION: 3
-          MINICONDA_NAME: Miniconda3-latest-MacOSX-x86_64.sh
-          CC: gcc
-        run: |
-          ./.github/scripts/linux_install.sh
-          ./.github/scripts/osx_unittest.sh
-        shell: bash
-  test_linux:
-    name: Unittesting on Linux python latest
-    runs-on: ubuntu-latest
-    steps:
-      - uses: actions/checkout@master
-      - name: Test linux
-        env:
-          OS_NAME: linux
-          PY_VERSION: 3
-          MINICONDA_NAME: Miniconda3-latest-Linux-x86_64.sh
-        run: |
-          ./.github/scripts/linux_install.sh
-          ./.github/scripts/linux_unittest.sh
-        shell: bash
-  test_windows:
-    name: Unittesting on Windows python latest
-    runs-on: windows-latest
-    steps:
-      - uses: actions/checkout@master
-      - name: Configure pagefile
-        uses: al-cheb/configure-pagefile-action@v1.2
-        with:
-          minimum-size: 8GB
-      - name: Test Windows
-        env:
-          OS_NAME: win
-          PY_VERSION: 3
-          PYTHON_ARCH: 64
-          PYTHON: C:\Miniconda36-x64
-        run: |
-          ./.github/scripts/install_miniconda.ps1
-          ./.github/scripts/windows_install.bat
-          ./.github/scripts/windows_unittest.bat
-        shell: powershell
diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml
new file mode 100644
index 000000000..1fe5e0bd1
--- /dev/null
+++ b/.github/workflows/integration-tests.yml
@@ -0,0 +1,51 @@
+name: integration-tests
+on:
+  push:
+    branches:
+      - "master"
+      - "test-me/*"
+  pull_request:
+    branches:
+      - "*"
+  schedule:
+    - cron: "0 7 * * 1" # Run every Monday at 7:00 UTC
+
+defaults:
+  run:
+    shell: bash -el {0}
+    
+jobs:
+  integration-test:
+    if: github.event.pull_request.draft == false
+    name: ${{ matrix.os }} integration tests
+    runs-on: ${{ matrix.os }}-latest
+    strategy:
+      fail-fast: false
+      matrix:
+        os: [macos, ubuntu, windows]
+        include:
+          - os: macos
+            os-short: osx
+          - os: ubuntu
+            os-short: linux
+          - os: windows
+            os-short: win
+    steps:
+      - name: Checkout
+        uses: actions/checkout@v3
+      - name: Setup Miniconda and parcels
+        uses: ./.github/actions/install-parcels
+        with:
+          environment-file: environment_py3_${{ matrix.os-short }}.yml
+          environment-name: py3_parcels
+      - name: Integration test
+        run: |
+          parcels_get_examples examples
+          pytest -v -s --nbval-lax -k "not documentation" --html="${{ matrix.os }}_integration_test_report.html" --self-contained-html examples
+      - name: Upload test results
+        if: ${{ always() }} # Always run this step, even if tests fail
+        uses: actions/upload-artifact@v3.1.2
+        with:
+          name: Integration test report
+          path: ${{ matrix.os }}_integration_test_report.html
+
diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml
new file mode 100644
index 000000000..2ddd4f75e
--- /dev/null
+++ b/.github/workflows/unit-tests.yml
@@ -0,0 +1,48 @@
+name: unit-tests
+on:
+  push:
+    branches:
+      - "master"
+      - "test-me/*"
+  pull_request:
+    branches:
+      - "*"
+  schedule:
+    - cron: "0 7 * * 1" # Run every Monday at 7:00 UTC
+
+defaults:
+  run:
+    shell: bash -el {0}
+    
+jobs:
+  unit-test:
+    name: Unittesting on ${{ matrix.os }} with python latest
+    runs-on: ${{ matrix.os }}-latest
+    strategy:
+      fail-fast: false
+      matrix:
+        os: [macos, ubuntu, windows]
+        include:
+          - os: macos
+            os-short: osx
+          - os: ubuntu
+            os-short: linux
+          - os: windows
+            os-short: win
+    steps:
+      - name: Checkout
+        uses: actions/checkout@v3
+      - name: Setup Miniconda and parcels
+        uses: ./.github/actions/install-parcels
+        with:
+          environment-file: environment_py3_${{ matrix.os-short }}.yml
+          environment-name: py3_parcels
+      - name: Unit test
+        run: |
+          pytest -v -s --html=${{ matrix.os }}_unit_test_report.html --self-contained-html tests
+      - name: Upload test results
+        if: ${{ always() }} # Always run this step, even if tests fail
+        uses: actions/upload-artifact@v3.1.2
+        with:
+          name: Unittest report
+          path: ${{ matrix.os }}_unit_test_report.html