From d5eec84e7b048229414acf4d36fd815aaeca5ffd Mon Sep 17 00:00:00 2001 From: Pikachu920 <28607612+Pikachu920@users.noreply.github.com> Date: Mon, 5 Feb 2024 12:00:52 -0600 Subject: [PATCH] Add action --- .github/workflows/test.yml | 22 ++++++++++++++++++++++ skript-test-acton/Dockerfile | 7 +++++++ skript-test-acton/action.yml | 25 +++++++++++++++++++++++++ skript-test-acton/run-tests.sh | 17 +++++++++++++++++ 4 files changed, 71 insertions(+) create mode 100644 .github/workflows/test.yml create mode 100644 skript-test-acton/Dockerfile create mode 100644 skript-test-acton/action.yml create mode 100644 skript-test-acton/run-tests.sh diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..9279056 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,22 @@ +name: Test action + +on: + - push + - pull_request + +jobs: + test: + runs-on: ubuntu-latest + steps: + - name: Checkout repo + uses: actions/checkout@v3 + - name: Build Dockerfile + run: docker build . --file Dockerfile + - name: Create custom test script + run: | + mkdir test-scripts + printf 'test "github actions":\nassert true is true with "it worked!"' > test-scripts/actions.sk + - name: Run skript-test-action + uses: ./ + with: + test-script-directory: test-scripts diff --git a/skript-test-acton/Dockerfile b/skript-test-acton/Dockerfile new file mode 100644 index 0000000..7403a60 --- /dev/null +++ b/skript-test-acton/Dockerfile @@ -0,0 +1,7 @@ +FROM alpine:3.19.1 +LABEL authors="SkriptLang" + +RUN apk add --no-cache git +COPY run-tests.sh /run-tests.sh + +ENTRYPOINT ["/run-tests.sh"] \ No newline at end of file diff --git a/skript-test-acton/action.yml b/skript-test-acton/action.yml new file mode 100644 index 0000000..cb7ecf4 --- /dev/null +++ b/skript-test-acton/action.yml @@ -0,0 +1,25 @@ +name: 'Skript Tests' +description: 'Runs Skript tests' +inputs: + test-script-directory: + description: 'The directory containing the tests to run' + required: true + skript-repo-ref: + description: 'The Git reference of the Skript version to test with (this can be a commit sha, branch, tag, etc.)' + required: false + run-vanilla-tests: + 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' + +outputs: + passed: + description: 'Whether or not the tests passed' + +runs: + using: 'docker' + image: 'Dockerfile' + args: + - ${{ inputs.test-script-directory }} + - ${{ inputs.skript-repo-ref }} + - ${{ inputs.run-vanilla-tests }} diff --git a/skript-test-acton/run-tests.sh b/skript-test-acton/run-tests.sh new file mode 100644 index 0000000..03b8695 --- /dev/null +++ b/skript-test-acton/run-tests.sh @@ -0,0 +1,17 @@ +#!/bin/sh -l + +test_script_directory="$1" +skript_repo_ref="$2" +run_vanilla_tests="$3" +skript_test_directory="src/test/skript/tests" + +git clone --recurse-submodules https://github.com/SkriptLang/Skript.git +cd Skript || exit 1 +if [ -n "$skript_repo_ref" ]; then + git checkout -f "$skript_repo_ref" +fi +if [ "$run_vanilla_tests" = "false" ]; then + rm -rf "${skript_test_directory:?}/*" +fi +cp "/github/workspace/$test_script_directory" "${skript_test_directory:?}/custom" +./gradlew quickTest