11import pytest
2- import pytest_copie
32import subprocess
43
54
@@ -19,7 +18,8 @@ def black_runs_successfully(result):
1918 """Test to ensure that the black linter runs successfully on the project"""
2019 # run black with `--check` to look for lint errors, but don't fix them.
2120 black_results = subprocess .run (
22- ["python" , "-m" , "black" , "--check" , (result .project_dir / "src" )], cwd = result .project_dir
21+ ["python" , "-m" , "black" , "--check" , (result .project_dir / "src" )],
22+ cwd = result .project_dir ,
2323 )
2424
2525 return black_results .returncode == 0
@@ -29,7 +29,14 @@ def pylint_runs_successfully(result):
2929 """Test to ensure that the pylint linter runs successfully on the project"""
3030 # run pylint to ensure that the hydrated files are linted correctly
3131 pylint_results = subprocess .run (
32- ["python" , "-m" , "pylint" , "--recursive=y" , "--rcfile=./src/.pylintrc" , (result .project_dir / "src" )],
32+ [
33+ "python" ,
34+ "-m" ,
35+ "pylint" ,
36+ "--recursive=y" ,
37+ "--rcfile=./src/.pylintrc" ,
38+ (result .project_dir / "src" ),
39+ ],
3340 cwd = result .project_dir ,
3441 )
3542
@@ -48,6 +55,19 @@ def unit_tests_in_project_run_successfully(result, package_name="example_package
4855 return pytest_results .returncode == 0
4956
5057
58+ def github_workflows_are_valid (result ):
59+ """Test to ensure that the GitHub workflows are valid"""
60+ workflows_results = subprocess .run (
61+ ["pre-commit" , "run" , "check-github-workflows" ], cwd = result .project_dir
62+ )
63+ return workflows_results .returncode == 0
64+
65+
66+ def initialize_git_project (result ):
67+ """Initializes local git repository (required to run pre-commit)"""
68+ subprocess .call (["git" , "init" , "." ], cwd = result .project_dir )
69+
70+
5171def test_all_defaults (copie ):
5272 """Test that the default values are used when no arguments are given.
5373 Ensure that the project is created and that the basic files exist.
@@ -155,3 +175,14 @@ def test_smoke_test_notification(copie):
155175 assert successfully_created_project (result )
156176 assert directory_structure_is_correct (result )
157177 assert black_runs_successfully (result )
178+
179+
180+ def test_github_workflows_schema (copie ):
181+ """Confirm the current GitHub workflows have valid schemas."""
182+ extra_answers = {
183+ "include_benchmarks" : True ,
184+ "include_docs" : True ,
185+ }
186+ result = copie .copy (extra_answers = extra_answers )
187+ initialize_git_project (result )
188+ assert github_workflows_are_valid (result )
0 commit comments