Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass in named params #8

Merged
merged 7 commits into from
Mar 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -45,6 +46,7 @@ jobs:
with:
timeout: '15'
max-score: '100'
setup-command: 'pip install -r requirements.txt'
- name: Autograding Reporter
uses: ...
```
6 changes: 3 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"
28 changes: 24 additions & 4 deletions bin/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Loading