diff --git a/README.md b/README.md index aa9b9bd..f3f55df 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,8 @@ |-----------------|-----------------------------------------------------------------------------------------------------------------|----------| | `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 | +| `setup-command` | Command to execute prior to the test, typically for environment setup or dependency installation. | No | +| `working-directory` | Relative location where pytest should start looking for tests. | No | ### Outputs @@ -47,6 +48,7 @@ jobs: timeout: '15' max-score: '100' setup-command: 'pip install -r requirements.txt' + working-directory: 'some_subdir' - name: Autograding Reporter uses: ... ``` diff --git a/action.yml b/action.yml index b41c688..1e880fa 100644 --- a/action.yml +++ b/action.yml @@ -12,6 +12,9 @@ inputs: setup-command: description: "Command to execute prior to the test, typically for environment setup or dependency installation." required: false + working-directory: + description: "Working directory to start the test." + required: false outputs: result: description: "Runner output" @@ -23,3 +26,4 @@ runs: - "--timeout=${{ inputs.timeout }}" - "--max-score=${{ inputs.max-score }}" - "--setup-command=${{ inputs.setup-command }}" + - "--working-directory=${{ inputs.working-directory }}" diff --git a/bin/run.sh b/bin/run.sh index 7ec6b00..bff2703 100755 --- a/bin/run.sh +++ b/bin/run.sh @@ -3,7 +3,7 @@ root="/opt/test-runner" export PYTHONPATH="$root:$PYTHONPATH" -mkdir autograding_output +mkdir -p autograding_output while [ $# -gt 0 ]; do case "$1" in @@ -17,6 +17,9 @@ while [ $# -gt 0 ]; do --setup-command=*) SETUP_COMMAND="${1#*=}" ;; + --working-directory=*) + WORKING_DIR="${1#*=}" + ;; *) printf "***************************\n" printf "* Warning: Unknown argument.*\n" @@ -34,7 +37,7 @@ if [ -n "$SETUP_COMMAND" ]; then eval "$SETUP_COMMAND" fi -timeout "$TIMEOUT" python3 /opt/test-runner/bin/run.py ./ ./autograding_output/ "$MAX_SCORE" +timeout "$TIMEOUT" python3 /opt/test-runner/bin/run.py ./$WORKING_DIR ./autograding_output/ "$MAX_SCORE" exit_status=$? if [ $exit_status -eq 124 ]; then echo "The command took longer than $TIMEOUT seconds to execute. Please increase the timeout to avoid this error."