Skip to content

Commit

Permalink
Add action
Browse files Browse the repository at this point in the history
  • Loading branch information
Pikachu920 committed Feb 5, 2024
1 parent 92f120c commit d5eec84
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 0 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -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
7 changes: 7 additions & 0 deletions skript-test-acton/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
25 changes: 25 additions & 0 deletions skript-test-acton/action.yml
Original file line number Diff line number Diff line change
@@ -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 }}
17 changes: 17 additions & 0 deletions skript-test-acton/run-tests.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit d5eec84

Please sign in to comment.