-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·61 lines (54 loc) · 1.8 KB
/
build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#! /bin/bash -
CLASSPATH=$PWD/objectdraw-ku20180313.jar
REPO=`basename $PWD`
GENMAIN="$(cd $(dirname $0);pwd)/genMain.sh"
ASSIGNEE=""
REV=`git log submission --pretty=format:"%h" -n 1`
if [ -e ./local.sh ]; then
. local.sh
else
echo "local.sh is needed. See local.sh.temp for variables to set."
exit 1
fi
usage_exit() {
echo "Usage: $0 [-h] [-t token] [-i] [-c class path] [-a assignee]" 1>&2
exit 1
}
while getopts c:t:k:ia:h OPT
do
case $OPT in
t) TOKEN=$OPTARG
;;
c) CLASSPATH=$OPTARG
;;
i) ISSUE=1
;;
a) ASSIGNEE=$OPTARG
;;
h) usage_exit
;;
\?) usage_exit
;;
esac
done
echo "Compiling:" *.java 1>&2
git checkout -f $REV
if javac -cp $CLASSPATH *.java; then
echo "Build succeeded!" 1>&2
if ((${ISSUE})) && [[ $ASSIGNEE != "" ]]; then
echo "Creating an issue..." 1>&2
curl -H "Content-Type: application/json" \
-H "Authorization: token $TOKEN" \
--data "{\"title\": \"Grading has started\", \"assignees\" : [\"$ASSIGNEE\"], \"body\": \"Compilation of $REV has succeeded. Watch this issue until grading ends.\" }" \
https://api.github.com/repos/$ORG/$REPO/issues
fi
else
echo "Build failed ;-("
if ((${ISSUE})) && [[ $ASSIGNEE != "" ]]; then
echo "Creating an issue..." 1>&2
curl -H "Content-Type: application/json" \
-H "Authorization: token $TOKEN" \
--data "{\"title\": \"Grading has started\", \"assignees\" : [\"$ASSIGNEE\"], \"body\": \"Compilation of $REV has FAILED. Please fix your source files and tell us the new SHA to be graded by adding a new comment to this issue.\" }" \
https://api.github.com/repos/$ORG/$REPO/issues
fi
fi