-
Notifications
You must be signed in to change notification settings - Fork 12
Submission tests to greatly pinp our CI #297
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
Merged
charliemirabile
merged 4 commits into
master
from
submission_test_good_fixed_correct_branch_pls_merge
Oct 5, 2025
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
0874153
denis: move and rephrase deadline handler messages
theyoyojo 24e439e
mailman: suppress output from underlying git commands
theyoyojo f048c9d
mailman: print original Message-ID header after processing
theyoyojo 5b2c003
Add a bunch of new tests to exercise submission codepaths and workflow
theyoyojo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,195 @@ | ||
| # This line: | ||
| # - aborts the script after any pipeline returns nonzero (e) | ||
| # - shows all commands as they are run (x) | ||
| # - sets any dereference of an unset variable to trigger an error (u) | ||
| # - enables job control (m) | ||
| # - causes the return value of a pipeline to be the nonzero return value | ||
| # of the furthest right failing command or zero if no command failed (o pipefail) | ||
| set -exumo pipefail | ||
|
|
||
| PODMAN=${PODMAN:-podman} | ||
| PODMAN_COMPOSE=${PODMAN_COMPOSE:-podman-compose} | ||
| SCRIPT_DIR=$(dirname "$(readlink -f "$0")") | ||
| WORKDIR=$(mktemp -d) | ||
|
|
||
| PINP_CONFIG='-c user.name=PINP -c user.email=podman@podman' | ||
|
|
||
| HOSTNAME_FROM_DOTENV="$(sh -c ' | ||
| set -o allexport | ||
| . ./.env | ||
| exec jq -r -n "env.SINGULARITY_HOSTNAME" | ||
| ')" | ||
|
|
||
| SINGULARITY_HOSTNAME=${SINGULARITY_HOSTNAME:-"${HOSTNAME_FROM_DOTENV}"} | ||
|
|
||
| setup_testdir() { | ||
| # Create test dir if it does not exist yet | ||
| mkdir -p test | ||
|
|
||
| # Reset the test directory | ||
| rm -f test/* | ||
|
|
||
| # put the cert in there | ||
| ${PODMAN} cp singularity_nginx_1:/etc/ssl/nginx/fullchain.pem test/ca_cert.pem | ||
| } | ||
|
|
||
| CURL_OPTS=( \ | ||
| --verbose \ | ||
| --cacert test/ca_cert.pem \ | ||
| --fail \ | ||
| --no-progress-meter \ | ||
| ) | ||
|
|
||
|
|
||
| get_git_port() { pushd "$SCRIPT_DIR" > /dev/null ; podman-compose port git 8000 ; popd > /dev/null ; } ; | ||
|
|
||
| # preconditions: | ||
| # - SCRIPT_DIR defined (singularity repo root) | ||
| # - WORKDIR defined (arbitrary) temp directory | ||
| setup_submissions_and_grading_repo() { | ||
| pushd "$SCRIPT_DIR" | ||
| # crete and push fresh submissions repo | ||
| rm -rf repos/submissions | ||
| git/admin.sh submissions "course submissions repository" | ||
| pushd repos | ||
| git init --bare submissions | ||
| echo "course submissions repository" > submissions/description | ||
| # create a temporary workdir to push an initial commit to the submission repo | ||
| git init submissions_init | ||
| pushd submissions_init | ||
| echo "# submissions" > README.md | ||
| git add README.md | ||
| git status | ||
| git -c user.name=singularity -c user.email=singularity@singularity commit -sm 'init submissions repo' | ||
| git push ../submissions master | ||
| popd | ||
| rm -rf submissions_init | ||
| pushd submissions | ||
| git push --mirror http://localhost:"$(get_git_port)"/cgi-bin/git-receive-pack/submissions | ||
| popd | ||
| popd | ||
| popd | ||
|
|
||
| pushd "$WORKDIR" | ||
| mkdir certs | ||
| pushd certs | ||
| ${PODMAN} volume export singularity_ssl-certs > certs.tar | ||
| tar xf certs.tar | ||
| popd | ||
| git clone http://localhost:"$(get_git_port)"/submissions | ||
| popd | ||
| } | ||
|
|
||
| # create or recreate dummy assignment | ||
| create_dummy_assignment() { | ||
| test -n "$1" | ||
| local asn="$1" | ||
|
|
||
| pushd "$SCRIPT_DIR" | ||
| if denis/configure.sh dump | grep -q "^$asn:"; then | ||
| denis/configure.sh remove -a "$asn" | ||
| fi | ||
| denis/configure.sh dummy -a "$asn" | ||
| popd | ||
| } | ||
|
|
||
| # create or recreate dummy assignment | ||
| trigger_deadline() { | ||
| test -n "$1" | ||
| test -n "$2" | ||
| local asn="$1" | ||
| local cmp="$2" | ||
|
|
||
| pushd "$SCRIPT_DIR" | ||
| denis/configure.sh trigger -a "$asn" -c "$cmp" | ||
| if [ "$cmp" == "peer" ]; then | ||
| cmp="$cmp review" | ||
| fi | ||
| podman-compose logs -f denis | ( sed "/completed $asn assignment processing for $cmp submission deadline/ q" && kill 0 ) || true | ||
| popd | ||
| } | ||
|
|
||
| # preconditions: | ||
| # - called after setup_submissions_and_grading_repo | ||
| setup_submissions_for() { | ||
| test -n "$1" | ||
| local user="$1" | ||
|
|
||
| pushd "$SCRIPT_DIR" | ||
| orbit/warpdrive.sh -u "$user" -p builder -n || orbit/warpdrive.sh -u "$user" -p builder -m | ||
| popd | ||
|
|
||
| pushd "$WORKDIR"/submissions | ||
| git config user.name "$user" | ||
| git config user.email "$user"@localhost.localdomain | ||
| git config sendemail.smtpUser "$user" | ||
| git config sendemail.smtpPass builder | ||
| git config sendemail.smtpserver localhost.localdomain | ||
| git config sendemail.smtpserverport 1465 | ||
| git config sendemail.smtpencryption ssl | ||
| popd | ||
| } | ||
|
|
||
| # preconditions: | ||
| # - no non-tracked files in submissions repo | ||
| # - called after setup_submissions_for | ||
| enter_and_checkout() { | ||
| test -n "$1" | ||
| local branch="$1" | ||
|
|
||
| pushd "$WORKDIR"/submissions | ||
| git checkout --orphan "$1" | ||
| if [ -n "$(ls)" ] | ||
| then | ||
| git rm -rf ./* | ||
| fi | ||
| } | ||
|
|
||
| # preconditions: | ||
| # - called after a call to enter_and_checkout | ||
| exit_after_sending() { | ||
| test -n "$1" | ||
| local asn="$1" | ||
|
|
||
| git send-email \ | ||
| --confirm=never \ | ||
| --smtp-ssl-cert-path="$WORKDIR"/certs/fullchain.pem \ | ||
| --to "$asn"@localhost.localdomain \ | ||
| ./*.patch | tee "$WORKDIR"/last_email | ||
| last_id=$(grep -m 1 "Message-ID" "$WORKDIR"/last_email) | ||
| rm ./*.patch | ||
| popd | ||
| podman-compose logs -f mailman | ( sed "/finished processing $last_id/ q" && kill 0 ) || true | ||
| } | ||
|
|
||
| # preconditions: | ||
| # - called after a call to enter_and_checkout | ||
| write_commit_to() { | ||
| test -n "$1" && test -n "$2" | ||
| local content="$1" | ||
| local file="$2" | ||
| set +u # necessary since $3 is unbound in 2 arg case | ||
| local opt="$3" | ||
| set -x | ||
|
|
||
| mkdir -p $(dirname "$file") | ||
|
|
||
| if [ "$opt" == "append" ]; then | ||
| echo "$content" >> "$file" | ||
| else | ||
| echo "$content" > "$file" | ||
| fi | ||
|
|
||
| git add "$file" | ||
| git commit -sm "add $content to $file" | ||
| } | ||
|
|
||
| # preconditions: | ||
| # - called after a call to write_commit_to | ||
| fixup_cover() { | ||
| test -n "$1" | ||
| sed -i "s/\*\*\* SUBJECT HERE \*\*\*/$1/g" *0000-cover-letter.patch | ||
| sed -i "s/\*\*\* BLURB HERE \*\*\*/$1/g" *0000-cover-letter.patch | ||
| sed -i "\$a\\Signed-off-by: $(git config user.name) <$(git config user.email)>" *0000-cover-letter.patch | ||
| } | ||
|
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.