From 5c794326e9951cc5c3e0ea061e535e40865ea922 Mon Sep 17 00:00:00 2001 From: Ashish Keshan Date: Fri, 29 Mar 2024 13:06:45 -0400 Subject: [PATCH 1/7] try in CI --- action.yml | 6 +++--- bin/run.sh | 28 ++++++++++++++++++++++------ 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/action.yml b/action.yml index c9c1044..6206fd7 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..b09f619 100755 --- a/bin/run.sh +++ b/bin/run.sh @@ -5,13 +5,29 @@ 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#*=}" + ;; + --setup_command=*) + SETUP_COMMAND="${1#*=}" + ;; + *) + printf "***************************\n" + printf "* Error: Invalid argument.*\n" + printf "***************************\n" + exit 1 + esac + shift +done -if [ -n "$SETUP_COMMAND" ]; then - $SETUP_COMMAND -fi +echo "TIMEOUT is $TIMEOUT" +echo "MAX_SCORE is $MAX_SCORE" +echo "SETUP_COMMAND is $SETUP_COMMAND" python3 /opt/test-runner/bin/run.py ./ ./autograding_output/ "$MAX_SCORE" "$TIMEOUT" From 33e0af9ceccef74c6a060e2292d22cbd10e3b4ad Mon Sep 17 00:00:00 2001 From: Ashish Keshan Date: Fri, 29 Mar 2024 13:08:25 -0400 Subject: [PATCH 2/7] try this --- bin/run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/run.sh b/bin/run.sh index b09f619..a835536 100755 --- a/bin/run.sh +++ b/bin/run.sh @@ -18,7 +18,7 @@ while [ $# -gt 0 ]; do ;; *) printf "***************************\n" - printf "* Error: Invalid argument.*\n" + printf "* Warning: Unknown argument.*\n" printf "***************************\n" exit 1 esac From 6d38dd8b019bf6856dc09afe301e1889a45c880c Mon Sep 17 00:00:00 2001 From: Ashish Keshan Date: Fri, 29 Mar 2024 13:09:29 -0400 Subject: [PATCH 3/7] remove exit 1 --- bin/run.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/bin/run.sh b/bin/run.sh index a835536..33a4206 100755 --- a/bin/run.sh +++ b/bin/run.sh @@ -20,7 +20,6 @@ while [ $# -gt 0 ]; do printf "***************************\n" printf "* Warning: Unknown argument.*\n" printf "***************************\n" - exit 1 esac shift done From a8418855b495b59c328444c286a2b81d943344ab Mon Sep 17 00:00:00 2001 From: Ashish Keshan Date: Fri, 29 Mar 2024 13:10:01 -0400 Subject: [PATCH 4/7] run setup_command if it exists --- bin/run.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bin/run.sh b/bin/run.sh index 33a4206..e0ed2e1 100755 --- a/bin/run.sh +++ b/bin/run.sh @@ -26,7 +26,11 @@ done echo "TIMEOUT is $TIMEOUT" echo "MAX_SCORE is $MAX_SCORE" -echo "SETUP_COMMAND is $SETUP_COMMAND" + +if [ -n "$SETUP_COMMAND" ]; then + echo "Running setup command: $SETUP_COMMAND" + eval "$SETUP_COMMAND" +fi python3 /opt/test-runner/bin/run.py ./ ./autograding_output/ "$MAX_SCORE" "$TIMEOUT" From 06226655d68aa1dc962a3b5f596388180afa68b3 Mon Sep 17 00:00:00 2001 From: Ashish Keshan Date: Fri, 29 Mar 2024 13:13:43 -0400 Subject: [PATCH 5/7] try this --- action.yml | 6 +++--- bin/run.sh | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/action.yml b/action.yml index 6206fd7..b41c688 100644 --- a/action.yml +++ b/action.yml @@ -20,6 +20,6 @@ runs: image: Dockerfile entrypoint: "/opt/test-runner/bin/run.sh" args: - - "--timeout ${{ inputs.timeout }}" - - "--max-score ${{ inputs.max-score }}" - - "--setup-command${{ 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 e0ed2e1..51cfaa1 100755 --- a/bin/run.sh +++ b/bin/run.sh @@ -10,10 +10,10 @@ while [ $# -gt 0 ]; do --timeout=*) TIMEOUT="${1#*=}" ;; - --max_score=*) + --max-score=*) MAX_SCORE="${1#*=}" ;; - --setup_command=*) + --setup-command=*) SETUP_COMMAND="${1#*=}" ;; *) From 8c1a08e60ee672b43917d50011755d818abaf24f Mon Sep 17 00:00:00 2001 From: Ashish Keshan Date: Fri, 29 Mar 2024 13:17:27 -0400 Subject: [PATCH 6/7] update README --- README.md | 2 ++ 1 file changed, 2 insertions(+) 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: ... ``` From d0d83a6fa1aa3c173c6e4caca54312bac4deb409 Mon Sep 17 00:00:00 2001 From: Ashish Keshan Date: Fri, 29 Mar 2024 13:22:52 -0400 Subject: [PATCH 7/7] default to 0 if no max_score passed --- bin/run.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/run.sh b/bin/run.sh index 51cfaa1..c0944d8 100755 --- a/bin/run.sh +++ b/bin/run.sh @@ -12,6 +12,7 @@ while [ $# -gt 0 ]; do ;; --max-score=*) MAX_SCORE="${1#*=}" + MAX_SCORE="${MAX_SCORE:-0}" ;; --setup-command=*) SETUP_COMMAND="${1#*=}"