Skip to content

Commit 938977d

Browse files
Switch from shell script to Python
1 parent 7b78bba commit 938977d

5 files changed

Lines changed: 56 additions & 28 deletions

File tree

.idea/.gitignore

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Dockerfile

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
FROM alpine:3.19.1
1+
FROM python:3.12-alpine3.18
22
LABEL authors="SkriptLang"
33

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

8-
ENTRYPOINT ["/run-tests.sh"]
7+
CMD ["python", "/run-tests.py"]

action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ inputs:
1111
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'
1212
required: false
1313
default: 'true'
14+
extra_plugins_directory:
15+
description: 'The directory containing the plugins to install on the test server alongside Skript'
16+
required: false
1417

1518
#outputs:
1619
# passed:

run-tests.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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)

run-tests.sh

Lines changed: 0 additions & 24 deletions
This file was deleted.

0 commit comments

Comments
 (0)