-
Notifications
You must be signed in to change notification settings - Fork 260
161 lines (160 loc) · 7.86 KB
/
integration.yml
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
name: Run integration tests
on:
merge_group:
pull_request:
branches:
- main
- '[0-9]+.[0-9]+'
jobs:
integration:
runs-on: ubuntu-24.04
timeout-minutes: 20
container:
image: domjudge/gitlabci:24.04
options: --privileged --cgroupns=host --init
services:
sqlserver:
image: mariadb
ports:
- 3306:3306
env:
MYSQL_ROOT_PASSWORD: root
MYSQL_USER: domjudge
MYSQL_PASSWORD: domjudge
options: --health-cmd="healthcheck.sh --connect --innodb_initialized" --health-interval=10s --health-timeout=5s --health-retries=3
steps:
- uses: actions/checkout@v4
- name: info
run: |
cat /proc/cmdline && echo &&
cat /proc/mounts && echo &&
ls -al /sys/fs/cgroup && echo &&
uname -a && echo &&
stat -fc %T /sys/fs/cgroup && echo &&
cat /proc/self/cgroup && echo &&
cat /proc/cpuinfo
- name: pstree
run: pstree -p
- name: Install DOMjudge
run: .github/jobs/baseinstall.sh all
- name: Set up chroot
run: sudo misc-tools/dj_make_chroot -a amd64
- name: Check nginx
run: curl -v https://localhost/domjudge/
- name: Configure print command
working-directory: submit
run: |
curl --fail -u 'admin:password' -X 'GET' 'http://localhost/domjudge/api/v4/config?strict=false' \
| jq '.print_command |= "cp [file] /tmp/dj-printfile"' \
| curl --fail -u 'admin:password' -X 'PUT' -T - 'http://localhost/domjudge/api/v4/config?strict=false' \
- name: Testing submit client
working-directory: submit
run: make check-full
- name: Configure judgehost
run: sudo cp /opt/domjudge/judgehost/etc/sudoers-domjudge /etc/sudoers.d/ && sudo chmod 400 /etc/sudoers.d/sudoers-domjudge && cat /opt/domjudge/judgehost/etc/sudoers-domjudge
- name: Create user
run: sudo userdel -f -r domjudge-run-0 ; sudo useradd -d /nonexistent -g nogroup -s /bin/false -u 2222 domjudge-run-0
- name: Start judging
run: sudo -u domjudge sh -c 'cd /opt/domjudge/judgehost/ && nohup bin/judgedaemon -n 0 &'
- name: Import Kattis example problems
run: |
cd /tmp
git clone --depth=1 https://github.com/Kattis/problemtools.git
cd problemtools/examples
mv hello hello_kattis
# Remove 2 submissions that will not pass validation. The first is because it is
# a Python 2 submission. The latter has a judgement type we do not understand.
rm different/submissions/accepted/different_py2.py different/submissions/slow_accepted/different_slow.py
for i in hello_kattis different guess; do
(
cd "$i"
zip -r "../${i}.zip" -- *
)
curl --fail -X POST -n -N -F zip=@${i}.zip http://localhost/domjudge/api/contests/demo/problems
done
- name: Monitor judgehost log and stop once all submissions are judged
run: |
tail -f /opt/domjudge/judgehost/log/judge*-0.log | while read line; do
echo "$line"
grep "No submissions in queue" /opt/domjudge/judgehost/log/judge*-0.log && break
done
- name: dump the db
if: ${{ !cancelled() }}
run: mysqldump -uroot -proot --quick --max_allowed_packet=1024M domjudge > /tmp/db.sql
- name: Upload database dump for debugging
if: ${{ !cancelled() }}
uses: actions/upload-artifact@v4
with:
name: DB-dump
path: /tmp/db.sql
- name: Get SQL logs
run: docker logs "${{ job.services.sqlserver.id }}"
- name: Collect docker logs on failure
if: ${{ !cancelled() }}
uses: jwalton/gh-docker-logs@v1
with:
dest: '/tmp/docker-logs'
- name: Upload all logs/artifacts
if: ${{ !cancelled() }}
uses: actions/upload-artifact@v4
with:
name: Logs
path: |
/var/log/nginx
/opt/domjudge/domserver/webapp/var/log/*.log
/tmp/docker-logs
/tmp/artifacts
- name: Verifying submissions
shell: bash
run: |
set -x
export CURLOPTS="--fail -sq -m 30 -b /tmp/cookiejar"
# Make an initial request which will get us a session id, and grab the csrf token from it
CSRFTOKEN=$(curl $CURLOPTS -c /tmp/cookiejar "http://localhost/domjudge/login" | sed -n 's/.*_csrf_token.*value="\(.*\)".*/\1/p')
# Make a second request with our session + csrf token to actually log in
curl $CURLOPTS -c /tmp/cookiejar -F "_csrf_token=$CSRFTOKEN" -F "_username=admin" -F "_password=password" "http://localhost/domjudge/login"
# Send a general clarification to later test if we see the event.
curl $CURLOPTS -F "sendto=" -F "problem=1-" -F "bodytext=Testing" -F "submit=Send" \
"http://localhost/domjudge/jury/clarifications/send" -o /dev/null
curl $CURLOPTS "http://localhost/domjudge/jury/judging-verifier?verify_multiple=1" -o /dev/null
NUMNOTVERIFIED=$(curl $CURLOPTS "http://localhost/domjudge/jury/judging-verifier" | grep "submissions checked" | sed -r 's/^.* ([0-9]+) submissions checked.*$/\1/')
NUMVERIFIED=$( curl $CURLOPTS "http://localhost/domjudge/jury/judging-verifier" | grep "submissions not checked" | sed -r 's/^.* ([0-9]+) submissions not checked.*$/\1/')
NUMNOMAGIC=$( curl $CURLOPTS "http://localhost/domjudge/jury/judging-verifier" | grep "without magic string" | sed -r 's/^.* ([0-9]+) without magic string.*$/\1/')
NUMSUBS=$(curl $CURLOPTS http://localhost/domjudge/api/contests/demo/submissions | python3 -mjson.tool | grep -c '"id":')
# We expect
# - two submissions with ambiguous outcome,
# - one submissions submitted through the submit client, and thus the magic string ignored,
# - and all submissions to be judged.
if [ $NUMNOTVERIFIED -ne 2 ] || [ $NUMNOMAGIC -ne 1 ] || [ $NUMSUBS -gt $((NUMVERIFIED+NUMNOTVERIFIED)) ]; then
echo "verified subs: $NUMVERIFIED, unverified subs: $NUMNOTVERIFIED, total subs: $NUMSUBS"
echo "(expected 2 submissions to be unverified, but all to be processed)"
echo "Of these $NUMNOMAGIC do not have the EXPECTED_RESULTS string (should be 1)."
curl $CURLOPTS "http://localhost/domjudge/jury/judging-verifier?verify_multiple=1" | w3m -dump -T text/html
exit 1
fi
- name: Finalize contest so that awards appear in the feed
shell: bash
run: |
set -x
export CURLOPTS="--fail -m 30 -b $COOKIEJAR"
curl $CURLOPTS http://localhost/domjudge/jury/contests/1/freeze/doNow || true
curl $CURLOPTS http://localhost/domjudge/jury/contests/1/end/doNow || true
curl $CURLOPTS -X POST -d 'finalize_contest[b]=0&finalize_contest[finalizecomment]=gitlab&finalize_contest[finalize]=' http://localhost/domjudge/jury/contests/1/finalize
- name: Verify no errors in symfony {prod,test,dev}.log
shell: bash
run: |
if cat /opt/domjudge/domserver/webapp/var/log/*.log | egrep '(CRITICAL|ERROR):'; then
exit 1
fi
- name: Download and perform API check
shell: bash
run: |
cd $HOME
curl -o yajsv https://github.com/neilpa/yajsv/releases/download/v1.4.1/yajsv.linux.amd64
chmod a+x yajsv
echo -e "\033[0m"
git clone https://github.com/icpc/ccs-specs.git
export CCS_SPECS_PINNED_SHA1='a68aff54c4e60fc2bff2fc5c36c119bffa4d30f1'
( cd ccs-specs && git reset --hard $CCS_SPECS_PINNED_SHA1 )
export CHECK_API="${HOME}/ccs-specs/check-api.sh -j ${HOME}/yajsv"
$CHECK_API -n -C -e -a 'strict=1' http://admin:password@localhost/domjudge/api