60 lines
2.0 KiB
Bash
Executable File
60 lines
2.0 KiB
Bash
Executable File
ID="$1"
|
|
NAMESPACE="$2"
|
|
PROJECT="$3"
|
|
COMMIT="$4"
|
|
TAG="$5"
|
|
|
|
: "${PIGEON_GITLAB_TOKEN:?}"
|
|
: "${PIGEON_PROJECTS:?}"
|
|
|
|
DIRECTORY="$(mktemp -d /tmp/pigeon.XXXXXXXXXX)"
|
|
trap 'rm -rf "$DIRECTORY"' EXIT
|
|
cd "$DIRECTORY"
|
|
|
|
git -c advice.detachedHead=false clone -q --rev "$COMMIT" --depth 1 \
|
|
"https://oauth2:$PIGEON_GITLAB_TOKEN@gitlab.com/$NAMESPACE/$PROJECT.git" student/
|
|
rm -rf student/.git
|
|
|
|
mkdir -p project/tests project/build
|
|
cp -a "$PIGEON_PROJECTS/$PROJECT"/tests/*.sh project/tests/
|
|
cp -a "$PIGEON_PROJECTS/$PROJECT"/build/. project/build/
|
|
|
|
mkfs.ext4 -q -F -d student student.img 16M
|
|
mkfs.ext4 -q -F -d project project.img 16M
|
|
mkfs.ext4 -q -F results.img 16M
|
|
|
|
cat >vm.json <<'EOF'
|
|
{
|
|
"boot-source": {
|
|
"kernel_image_path": "@kernel@",
|
|
"boot_args": "reboot=k panic=1 init=/init quiet nomodule i8042.noaux i8042.nomux i8042.dumbkbd swiotlb=noforce console=ttyS0"
|
|
},
|
|
"drives": [
|
|
{ "drive_id": "rootfs", "path_on_host": "@rootfs@", "is_root_device": true, "is_read_only": true },
|
|
{ "drive_id": "student", "path_on_host": "student.img", "is_root_device": false, "is_read_only": true },
|
|
{ "drive_id": "project", "path_on_host": "project.img", "is_root_device": false, "is_read_only": true },
|
|
{ "drive_id": "results", "path_on_host": "results.img", "is_root_device": false, "is_read_only": false }
|
|
],
|
|
"machine-config": { "vcpu_count": 1, "mem_size_mib": 512 }
|
|
}
|
|
EOF
|
|
|
|
firecracker --no-api --level Error --config-file vm.json
|
|
|
|
RESULT=""
|
|
TESTS="$PIGEON_PROJECTS/$PROJECT/tests"
|
|
for TEST in "$TESTS"/*.sh ; do
|
|
debugfs -R "cat /$(basename "$TEST" .sh)" results.img >scratch 2>/dev/null
|
|
if cmp scratch "$TESTS/$(basename "$TEST" .sh).expected" ; then
|
|
RESULT="${RESULT}PASS\n"
|
|
else
|
|
RESULT="${RESULT}FAIL: $(cat "$TESTS/$(basename "$TEST" .sh).hint")\n"
|
|
fi
|
|
done
|
|
|
|
curl -s --show-error --out-null --request PUT \
|
|
--header "PRIVATE-TOKEN: $PIGEON_GITLAB_TOKEN" \
|
|
--header 'Content-Type: application/json' \
|
|
--data "{\"description\": \"$RESULT\"}" \
|
|
--url "https://gitlab.com/api/v4/projects/$ID/releases/$TAG"
|