Skip to content

Commit

Permalink
Switch from shell script to Python
Browse files Browse the repository at this point in the history
  • Loading branch information
Pikachu920 committed Feb 5, 2024
1 parent 7b78bba commit 938977d
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 28 deletions.
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
FROM alpine:3.19.1
FROM python:3.12-alpine3.18
LABEL authors="SkriptLang"

RUN apk add --no-cache git openjdk17
COPY run-tests.sh /run-tests.sh
RUN chmod +x /run-tests.sh
COPY run-tests.py /run-tests.py

ENTRYPOINT ["/run-tests.sh"]
CMD ["python", "/run-tests.py"]
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ inputs:
description: 'Controls whether or not the vanilla Skript tests are run. It is recommended you keep this on to ensure your addon doesn''t change vanilla behavior'
required: false
default: 'true'
extra_plugins_directory:
description: 'The directory containing the plugins to install on the test server alongside Skript'
required: false

#outputs:
# passed:
Expand Down
42 changes: 42 additions & 0 deletions run-tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import os
import shutil
import subprocess
from pathlib import Path

test_script_directory = Path(f"/github/workspace/{os.environ['INPUT_TEST_SCRIPT_DIRECTORY']}")
skript_repo_ref = os.environ.get("INPUT_SKRIPT_REPO_REF", None)
run_vanilla_tests = os.environ.get("INPUT_RUN_VANILLA_TESTS", None) == "true"
skript_repo_git_url = "https://github.com/SkriptLang/Skript.git"
skript_repo_path = Path("/skript")
skript_test_directory = skript_repo_path / "src/test/skript/tests"
custom_test_directory = skript_test_directory / "custom"
extra_plugins_directory = None
if "INPUT_EXTRA_PLUGINS_DIRECTORY" in os.environ:
extra_plugins_directory = Path(os.environ["INPUT_EXTRA_PLUGINS_DIRECTORY"])


def delete_contents_of_directory(directory: Path) -> None:
for path in directory.iterdir():
if path.is_file():
path.unlink()
elif path.is_dir():
shutil.rmtree(path)


print("Configuration:")
print(f" Test script directory: {test_script_directory}")
print(f" Skript repo ref: {skript_repo_ref}")
print(f" Run vanilla tests: {run_vanilla_tests}")
print(f" Extra plugins directory: {extra_plugins_directory}")

subprocess.run(("git", "clone", "--recurse-submodules", skript_repo_git_url, str(skript_repo_path)))
os.chdir(skript_repo_path)
if skript_repo_ref is not None:
subprocess.run(("git", "checkout", "-f", skript_repo_ref))
if not run_vanilla_tests:
print("Deleting vanilla tests")
delete_contents_of_directory(skript_test_directory)
custom_test_directory.mkdir(parents=True, exist_ok=True)
shutil.copytree(test_script_directory, custom_test_directory)
gradle_test_process = subprocess.run(("./gradlew", "quickTest"))
exit(gradle_test_process.returncode)
24 changes: 0 additions & 24 deletions run-tests.sh

This file was deleted.

0 comments on commit 938977d

Please sign in to comment.