Repository: pykale/pykale (language: python)

Issue:
[Feature Request] Optimizing functional test time with pytest-testmon
# 🚀 Feature Request

I'm looking to use [Pytest-testmon](https://testmon.org/) to optimize test execution time in the GitHub Action. I use the [GitHub Action Cache](https://github.com/pykale/pykale/actions/caches?query=sort%3Acreated-desc) to manage `.testmondata` storage and restoration. Here's my design approach:

1. The main branch undergoes scheduled tests to generate a new `.testmondata`.
2. Branches within PRs simply restore the generated `.testmondata` for a faster test, without updating it.

## Motivation

**Is your feature request related to a problem? Please describe.**
Nope.

## Pitch

**Describe the solution you'd like**
Using pytest-testmon to test the changed codes only.

1. However, an issue arises when I execute `pytest --testmon-nocollect` within the PR: a new `.testmondata` is unexpectedly generated in the GitHub Action Cache. I'm unsure about the root cause of this.

2. Please note that `pytest-testmon` might not be compatible with `codecov`. (See [Ref. link1](https://github.com/nedbat/coveragepy/issues/774), [Ref. link2](https://github.com/tarpas/pytest-testmon/issues/97) and [Ref. link3](https://github.com/tarpas/pytest-testmon/issues/86)) 

**Are you willing to open a pull request?** (We LOVE contributions!!!)
#413 


Discussion / hints:
This issue has been automatically marked as stale due to lack of activity. It will be closed if no further activity occurs. Thank you!

Fix patch:
diff --git a/setup.py b/setup.py
index abfe701d8..4a9f22b19 100644
--- a/setup.py
+++ b/setup.py
@@ -82,8 +82,6 @@
     "recommonmark",
     "sphinx",
     "sphinx-rtd-theme",
-    "pwlf",
-    "xlsxwriter",
 ]
 
 


Test patch:
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 50539fa5d..9861b7fbe 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -25,6 +25,12 @@ jobs:
             python-version: "3.8"
           - os: windows-latest
             python-version: "3.9"
+        include:
+          - os: ubuntu-latest
+            path: ~/.cache/pip
+          - os: windows-latest
+            path: ~\AppData\Local\pip\Cache
+
     steps:
       - uses: actions/checkout@v2
       - name: Set up Python using Miniconda
@@ -32,6 +38,21 @@ jobs:
         with:
           auto-update-conda: true
           python-version: ${{ matrix.python-version }}
+          miniconda-version: latest
+
+      - name: Cache pip dependencies
+        id: cache_pip
+        uses: actions/cache@v2
+        with:
+          path: ${{ matrix.path }}
+          key: ${{ runner.os }}-python${{ matrix.python-version }}-pip-${{ hashFiles('**/setup.py') }}
+          restore-keys: |
+            ${{ runner.os }}-python${{ matrix.python-version }}-pip-${{ hashFiles('**/setup.py') }}
+          # Using the full hash of setup.py will cause the cache to be invalidated whenever the setup.py file changes.
+          # An alternative is to use 'restore-keys: ${{ runner.os }}-python${{ matrix.python-version }}-pip-', which is
+          # suggested by GitHub (https://github.com/davronaliyev/Cache-dependencies-in-GitHub-Actions/blob/main/examples.md#python---pip).
+          # However, it will restore the saved cache rather than create a new one even when the setup.py file changes.
+
       - name: Install dependencies
         run: |
           pip install rdkit
@@ -51,9 +72,11 @@ jobs:
         run: |
           pytest --nbmake --nbmake-timeout=3000 --cov=kale
         shell: bash -l {0}
+
       - name: Determine coverage
         run: |
           coverage xml
         shell: bash -l {0}
+
       - name: Report coverage
         uses: codecov/codecov-action@v1