Repository: imAsparky/django-cookiecutter

Issue:
[FEAT]: Add GitHub action test suite  for the Django project.
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.



Discussion:

Resolving patch:
diff --git a/hooks/post_gen_project.py b/hooks/post_gen_project.py
--- a/hooks/post_gen_project.py
+++ b/hooks/post_gen_project.py
@@ -127,9 +127,6 @@ def git_configure_custom_commit_message():
 
 if __name__ == "__main__":
 
-    # if "{{ cookiecutter.create_repo_auto_test_workflow }}" != "y":
-    #     remove_file(".github/workflows/test_contribution.yaml")
-
     # Documentation options
 
     if "{{ cookiecutter.include_sphinx_docs }}" == "n":
@@ -179,3 +176,6 @@ def git_configure_custom_commit_message():
         remove_file("CHANGELOG.md")
         remove_file(".github/semantic.yaml")
         remove_file(".github/workflows/semantic_release.yaml")
+
+    if "{{ cookiecutter.create_repo_auto_test_workflow }}" == "n":
+        remove_file(".github/workflows/test_contribution.yaml")


Test patch:
diff --git a/tests/test_bake_django.py b/tests/test_bake_django.py
--- a/tests/test_bake_django.py
+++ b/tests/test_bake_django.py
@@ -103,8 +103,7 @@ def test_baked_django_with_custom_issue_template_files(cookies):
 
 
 def test_baked_django_without_custom_issue_template_files(cookies):
-    """
-    Test Django project has no custom ISSUE templates generated.
+    """Test Django project has no custom ISSUE templates generated.
 
     Tests that the standard template has the "project name"
     generated correctly, and post-gen deleted the Custom Issue templates.
@@ -256,50 +255,6 @@ def test_baked_django_docs_without_templates(cookies):
     )
 
 
-def test_baked_django_with_read_the_docs(cookies):
-    """Test Django readthedocs config has been generated correctly."""
-    default_django = cookies.bake()
-
-    assert ".readthedocs.yaml" in os.listdir((default_django.project_path))
-
-    rtd_path = default_django.project_path / "README.rst"
-    rtd_file = rtd_path.read_text().splitlines()
-
-    assert (
-        ".. image:: https://readthedocs.org/projects/django-boilerplate/badge/?version=latest"
-        in rtd_file
-    )
-    assert (
-        "   :target: https://django-boilerplate.readthedocs.io/en/latest/?badge=latest"
-        in rtd_file
-    )
-    assert "   :alt: Documentation Status" in rtd_file
-
-
-def test_baked_django_without_read_the_docs(cookies):
-    """Test Django readthedocs config has not been generated correctly."""
-    non_default_django = cookies.bake(
-        extra_context={
-            "use_readthedocs": "n",
-        }
-    )
-
-    assert ".readthedocs.yaml" not in os.listdir((non_default_django.project_path))
-
-    rtd_path = non_default_django.project_path / "README.rst"
-    rtd_file = rtd_path.read_text().splitlines()
-
-    assert (
-        ".. image:: https://readthedocs.org/projects/django-boilerplate/badge/?version=latest"
-        not in rtd_file
-    )
-    assert (
-        "   :target: https://django-boilerplate.readthedocs.io/en/latest/?badge=latest"
-        not in rtd_file
-    )
-    assert "   :alt: Documentation Status" not in rtd_file
-
-
 def test_baked_django_docs_with_references_index(cookies):
     """Test Django docs reference index template file has been generated correctly."""
     default_django = cookies.bake()
@@ -344,7 +299,7 @@ def test_baked_django_with_git_initiated(cookies):
 
 
 def test_baked_django_without_git_initiated(cookies):
-    """Test Django git init has not generated"""
+    """Test Django git init has not generated."""
     non_default_django = cookies.bake(
         extra_context={"automatic_set_up_git_and_initial_commit": "n"}
     )
@@ -352,6 +307,26 @@ def test_baked_django_without_git_initiated(cookies):
     assert ".git" not in os.listdir(non_default_django.project_path)
 
 
+def test_baked_django_with_github_action_test_workflow(cookies):
+    """Test Django GitHub test action file has generated correctly."""
+    default_django = cookies.bake()
+
+    assert "test_contribution.yaml" in os.listdir(
+        default_django.project_path / ".github/workflows"
+    )
+
+
+def test_baked_django_without_github_action_test_workflow(cookies):
+    """Test Django GitHub test action file has not generated"""
+    non_default_django = cookies.bake(
+        extra_context={"create_repo_auto_test_workflow": "n"}
+    )
+
+    assert "test_contribution.yaml" not in os.listdir(
+        non_default_django.project_path / ".github/workflows"
+    )
+
+
 def test_baked_django_init_py_file(cookies):
     """Test Django __init__.py file has been generated correctly."""
     default_django = cookies.bake()
@@ -590,6 +565,50 @@ def test_baked_django_readme_without_precommit_badge(cookies):
     assert "   :alt: pre-commit" not in readme_file
 
 
+def test_baked_django_with_read_the_docs(cookies):
+    """Test Django readthedocs config has been generated correctly."""
+    default_django = cookies.bake()
+
+    assert ".readthedocs.yaml" in os.listdir((default_django.project_path))
+
+    rtd_path = default_django.project_path / "README.rst"
+    rtd_file = rtd_path.read_text().splitlines()
+
+    assert (
+        ".. image:: https://readthedocs.org/projects/django-boilerplate/badge/?version=latest"
+        in rtd_file
+    )
+    assert (
+        "   :target: https://django-boilerplate.readthedocs.io/en/latest/?badge=latest"
+        in rtd_file
+    )
+    assert "   :alt: Documentation Status" in rtd_file
+
+
+def test_baked_django_without_read_the_docs(cookies):
+    """Test Django readthedocs config has not been generated correctly."""
+    non_default_django = cookies.bake(
+        extra_context={
+            "use_readthedocs": "n",
+        }
+    )
+
+    assert ".readthedocs.yaml" not in os.listdir((non_default_django.project_path))
+
+    rtd_path = non_default_django.project_path / "README.rst"
+    rtd_file = rtd_path.read_text().splitlines()
+
+    assert (
+        ".. image:: https://readthedocs.org/projects/django-boilerplate/badge/?version=latest"
+        not in rtd_file
+    )
+    assert (
+        "   :target: https://django-boilerplate.readthedocs.io/en/latest/?badge=latest"
+        not in rtd_file
+    )
+    assert "   :alt: Documentation Status" not in rtd_file
+
+
 def test_baked_django_with_semantic_release(cookies):
     """Test Django semantic-release file has been generated correctly."""
     default_django = cookies.bake()
diff --git a/{{cookiecutter.git_project_name}}/.github/workflows/test_contribution.yaml b/{{cookiecutter.git_project_name}}/.github/workflows/test_contribution.yaml
new file mode 100644
--- /dev/null
+++ b/{{cookiecutter.git_project_name}}/.github/workflows/test_contribution.yaml
@@ -0,0 +1,36 @@
+name: Test Contributions
+
+on:
+    pull_request:
+        branches: [main]
+
+    # push:
+    #     branches: [main]
+
+    workflow_dispatch:
+
+jobs:
+    test_contribs:
+        strategy:
+            matrix:
+                python-version: ["3.6", "3.7", "3.8", "3.9"]
+                os: [macos-latest, ubuntu-latest, windows-latest]
+
+        runs-on: ${{ matrix.os }}
+        steps:
+            - uses: actions/checkout@v2
+              with:
+                  fetch-depth: 0
+
+            - name: Set up Python ${{ matrix.python-version }}
+              uses: actions/setup-python@v2
+              with:
+                  python-version: ${{ matrix.python-version }}
+
+            - name: Install dependencies
+              run: |
+                  python -m pip install --upgrade pip
+                  pip install tox tox-gh-actions
+
+            - name: Test with tox
+              run: tox