|
| 1 | +import os |
| 2 | +import shutil |
| 3 | +import subprocess |
| 4 | +from pathlib import Path |
| 5 | + |
| 6 | +test_script_directory = Path(f"/github/workspace/{os.environ['INPUT_TEST_SCRIPT_DIRECTORY']}") |
| 7 | +skript_repo_ref = os.environ.get("INPUT_SKRIPT_REPO_REF", None) |
| 8 | +run_vanilla_tests = os.environ.get("INPUT_RUN_VANILLA_TESTS", None) == "true" |
| 9 | +skript_repo_git_url = "https://github.com/SkriptLang/Skript.git" |
| 10 | +skript_repo_path = Path("/skript") |
| 11 | +skript_test_directory = skript_repo_path / "src/test/skript/tests" |
| 12 | +custom_test_directory = skript_test_directory / "custom" |
| 13 | +extra_plugins_directory = None |
| 14 | +if "INPUT_EXTRA_PLUGINS_DIRECTORY" in os.environ: |
| 15 | + extra_plugins_directory = Path(os.environ["INPUT_EXTRA_PLUGINS_DIRECTORY"]) |
| 16 | + |
| 17 | + |
| 18 | +def delete_contents_of_directory(directory: Path) -> None: |
| 19 | + for path in directory.iterdir(): |
| 20 | + if path.is_file(): |
| 21 | + path.unlink() |
| 22 | + elif path.is_dir(): |
| 23 | + shutil.rmtree(path) |
| 24 | + |
| 25 | + |
| 26 | +print("Configuration:") |
| 27 | +print(f" Test script directory: {test_script_directory}") |
| 28 | +print(f" Skript repo ref: {skript_repo_ref}") |
| 29 | +print(f" Run vanilla tests: {run_vanilla_tests}") |
| 30 | +print(f" Extra plugins directory: {extra_plugins_directory}") |
| 31 | + |
| 32 | +subprocess.run(("git", "clone", "--recurse-submodules", skript_repo_git_url, str(skript_repo_path))) |
| 33 | +os.chdir(skript_repo_path) |
| 34 | +if skript_repo_ref is not None: |
| 35 | + subprocess.run(("git", "checkout", "-f", skript_repo_ref)) |
| 36 | +if not run_vanilla_tests: |
| 37 | + print("Deleting vanilla tests") |
| 38 | + delete_contents_of_directory(skript_test_directory) |
| 39 | +custom_test_directory.mkdir(parents=True, exist_ok=True) |
| 40 | +shutil.copytree(test_script_directory, custom_test_directory) |
| 41 | +gradle_test_process = subprocess.run(("./gradlew", "quickTest")) |
| 42 | +exit(gradle_test_process.returncode) |
0 commit comments