Repository: ymyzk/tox-gh-actions

Issue:
Add Pyston support
Pyston is part of the python action but it is still installable. It'd be great if you could add a way to detect Pyston and use that.

I tried using using `TOXENV` to make my tests run using Pyston but it kept creating a Python 3.8 virtual environment rather than using my Pyston environment

```yaml
      - name: Set up Pyston
        if: ${{ matrix.python-version == 'pyston' }}
        env:
          TOXENV: pyston,pyston-setproctitle,pyston-uvloop
        run: |
          git clone https://github.com/pyenv/pyenv.git ~/.pyenv
          ~/.pyenv/bin/pyenv install pyston-2.2
          ~/.pyenv/bin/pyenv local pyston-2.2
      - name: unittest
        run: tox -vv
```

This was the tox verbose output

`tox-gh-actions config: {'python': {'3.7': ['py37', 'py37-setproctitle', 'py37-uvloop'], '3.8': ['py38', 'py38-setproctitle', 'py38-uvloop'], '3.9': ['py39', 'py39-setproctitle', 'py39-uvloop'], 'pypy-3.7': ['pypy3', 'pypy3-setproctitle', 'pypy3-uvloop'], 'pyston': ['pyston', 'pyston-setproctitle', 'pyston-uvloop']}, 'env': {}}`

I had to resort to adding an if statement and calling `tox -e env,list` to make it work. I suspect this is due to the scoping of `env` and it only applying to the current step.

Discussion:

Patch:
diff --git a/README.md b/README.md
index b6fc90a..dac3f2d 100644
--- a/README.md
+++ b/README.md
@@ -165,11 +165,12 @@ python =
 ```
 
 PyPy is also supported in the `python` configuration key.
+Support of Pyston is experimental and not tested by our CI.
 
  `tox.ini`:
 ```ini
 [tox]
-envlist = py27, py38, pypy2, pypy3
+envlist = py27, py38, pypy2, pypy3, pyston38
 
 [gh-actions]
 python =
@@ -177,9 +178,13 @@ python =
     3.8: py38, mypy
     pypy-2.7: pypy2
     pypy-3.7: pypy3
+    pyston-3.8: python38
 
 [testenv]
 ...
+
+[testenv:pyston38]
+basepython = pyston38
 ```
 
 You can also specify without minor versions in the `python` configuration key.
diff --git a/src/tox_gh_actions/plugin.py b/src/tox_gh_actions/plugin.py
index 66af2b1..6824525 100644
--- a/src/tox_gh_actions/plugin.py
+++ b/src/tox_gh_actions/plugin.py
@@ -120,6 +120,7 @@ def get_python_version_keys():
     - CPython 3.8.z => [3.8, 3]
     - PyPy 2.7 (v7.3.z) => [pypy-2.7, pypy-2, pypy2]
     - PyPy 3.6 (v7.3.z) => [pypy-3.6, pypy-3, pypy3]
+    - Pyston based on Python CPython 3.8.8 (v2.2) => [pyston-3.8, pyston-3]
 
     Support of "pypy2" and "pypy3" is for backward compatibility with
     tox-gh-actions v2.2.0 and before.
@@ -132,6 +133,11 @@ def get_python_version_keys():
             "pypy-" + major_version,
             "pypy" + major_version,
         ]
+    elif hasattr(sys, "pyston_version_info"):  # Pyston
+        return [
+            "pyston-" + major_minor_version,
+            "pyston-" + major_version,
+        ]
     else:
         # Assume this is running on CPython
         return [major_minor_version, major_version]


Test patch:
diff --git a/tests/test_plugin.py b/tests/test_plugin.py
index 1b5b19b..62796f5 100644
--- a/tests/test_plugin.py
+++ b/tests/test_plugin.py
@@ -332,6 +332,24 @@ def test_get_version_keys(mocker, version, info, expected):
     assert plugin.get_python_version_keys() == expected
 
 
+def test_get_version_keys_on_pyston(mocker):
+    mocker.patch(
+        "tox_gh_actions.plugin.sys.pyston_version_info",
+        (2, 2, 0, "final", 0),
+        create=True,  # For non-Pyston implementation
+    )
+    mocker.patch(
+        "tox_gh_actions.plugin.sys.version",
+        "3.8.8 (heads/rel2.2:6287d61, Apr 29 2021, 15:46:12)\n"
+        "[Pyston 2.2.0, GCC 9.3.0]",
+    )
+    mocker.patch(
+        "tox_gh_actions.plugin.sys.version_info",
+        (3, 8, 8, "final", 0),
+    )
+    assert plugin.get_python_version_keys() == ["pyston-3.8", "pyston-3"]
+
+
 @pytest.mark.parametrize(
     "environ,expected",
     [