diff --git a/README.md b/README.md index 7a4505d..0b4cc93 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,7 @@ |-----------------|-----------------------------------------------------------------------------------------------------------------|----------| | `timeout` | Duration (in minutes) before the test is terminated. Defaults to 10 minutes with a maximum limit of 6 hours. | Yes | | `max-score` | Points to be awarded if the test passes. | No | +| `setup-command` | Command to execute prior to the test, typically for environment setup or dependency installation. | No | ### Outputs @@ -45,6 +46,7 @@ jobs: with: timeout: '15' max-score: '100' + setup-command: 'pip install -r requirements.txt' - name: Autograding Reporter uses: ... ``` diff --git a/action.yml b/action.yml index c9c1044..b41c688 100644 --- a/action.yml +++ b/action.yml @@ -20,6 +20,6 @@ runs: image: Dockerfile entrypoint: "/opt/test-runner/bin/run.sh" args: - - ${{ inputs.timeout }} - - ${{ inputs.max-score }} - - ${{ inputs.setup-command }} + - "--timeout=${{ inputs.timeout }}" + - "--max-score=${{ inputs.max-score }}" + - "--setup-command=${{ inputs.setup-command }}" diff --git a/bin/run.sh b/bin/run.sh index f1ba82b..c0944d8 100755 --- a/bin/run.sh +++ b/bin/run.sh @@ -5,12 +5,32 @@ export PYTHONPATH="$root:$PYTHONPATH" mkdir autograding_output -TIMEOUT="$1" -MAX_SCORE="${2:-0}" -SETUP_COMMAND="$3" +while [ $# -gt 0 ]; do + case "$1" in + --timeout=*) + TIMEOUT="${1#*=}" + ;; + --max-score=*) + MAX_SCORE="${1#*=}" + MAX_SCORE="${MAX_SCORE:-0}" + ;; + --setup-command=*) + SETUP_COMMAND="${1#*=}" + ;; + *) + printf "***************************\n" + printf "* Warning: Unknown argument.*\n" + printf "***************************\n" + esac + shift +done + +echo "TIMEOUT is $TIMEOUT" +echo "MAX_SCORE is $MAX_SCORE" if [ -n "$SETUP_COMMAND" ]; then - $SETUP_COMMAND + echo "Running setup command: $SETUP_COMMAND" + eval "$SETUP_COMMAND" fi python3 /opt/test-runner/bin/run.py ./ ./autograding_output/ "$MAX_SCORE" "$TIMEOUT"