|
| 1 | +name: Run integration tests |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches-ignore: |
| 5 | + - main |
| 6 | + - '[0-9]+.[0-9]+' |
| 7 | + - gh-readonly-queue/main/* |
| 8 | + - gh-readonly-queue/main/[0-9]+.[0-9]+ |
| 9 | + pull_request: |
| 10 | + branches: |
| 11 | + - main |
| 12 | + - '[0-9]+.[0-9]+' |
| 13 | + |
| 14 | +jobs: |
| 15 | + integration: |
| 16 | + runs-on: ubuntu-24.04 |
| 17 | + container: |
| 18 | + image: domjudge/gitlabci:24.04 |
| 19 | + options: --privileged --cgroupns=host --init |
| 20 | + services: |
| 21 | + sqlserver: |
| 22 | + image: mariadb |
| 23 | + ports: |
| 24 | + - 3306:3306 |
| 25 | + env: |
| 26 | + MYSQL_ROOT_PASSWORD: root |
| 27 | + MYSQL_USER: domjudge |
| 28 | + MYSQL_PASSWORD: domjudge |
| 29 | + options: --health-cmd="healthcheck.sh --connect --innodb_initialized" --health-interval=10s --health-timeout=5s --health-retries=3 |
| 30 | + steps: |
| 31 | + - uses: actions/checkout@v4 |
| 32 | + - name: info |
| 33 | + 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 && cat /proc/cpuinfo |
| 34 | + - name: pstree |
| 35 | + run: pstree -p |
| 36 | + - name: Install DOMjudge |
| 37 | + run: .github/jobs/baseinstall.sh all |
| 38 | + - name: Set up chroot |
| 39 | + run: sudo misc-tools/dj_make_chroot -a amd64 |
| 40 | + - name: Check nginx |
| 41 | + run: curl -v https://localhost/domjudge/ |
| 42 | + - name: Testing submit client |
| 43 | + working-directory: submit |
| 44 | + run: make check-full |
| 45 | + - name: Configure judgehost |
| 46 | + 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 |
| 47 | + - name: Create user |
| 48 | + run: sudo userdel -f -r domjudge-run-0 ; sudo useradd -d /nonexistent -g nogroup -s /bin/false -u 2222 domjudge-run-0 |
| 49 | + - name: Start judging |
| 50 | + run: sudo -u domjudge sh -c 'cd /opt/domjudge/judgehost/ && nohup bin/judgedaemon -n 0 &' |
| 51 | + - name: Import Kattis example problems |
| 52 | + run: | |
| 53 | + cd /tmp |
| 54 | + git clone --depth=1 https://github.com/Kattis/problemtools.git |
| 55 | + cd problemtools/examples |
| 56 | + mv hello hello_kattis |
| 57 | + # Remove 2 submissions that will not pass validation. The first is because it is |
| 58 | + # a Python 2 submission. The latter has a judgement type we do not understand. |
| 59 | + rm different/submissions/accepted/different_py2.py different/submissions/slow_accepted/different_slow.py |
| 60 | + for i in hello_kattis different guess; do |
| 61 | + ( |
| 62 | + cd "$i" |
| 63 | + zip -r "../${i}.zip" -- * |
| 64 | + ) |
| 65 | + curl --fail -X POST -n -N -F zip=@${i}.zip http://localhost/domjudge/api/contests/demo/problems |
| 66 | + done |
| 67 | + - name: Monitor judgehost log and stop once all submissions are judged |
| 68 | + run: | |
| 69 | + tail -f /opt/domjudge/judgehost/log/judge*-0.log | while read line; do |
| 70 | + echo "$line" |
| 71 | + grep "No submissions in queue" /opt/domjudge/judgehost/log/judge*-0.log && break |
| 72 | + done |
| 73 | + - name: dump the db |
| 74 | + run: mysqldump -uroot -proot domjudge > /tmp/db.sql |
| 75 | + - name: Upload artifact for debugging |
| 76 | + uses: actions/upload-artifact@v3 |
| 77 | + with: |
| 78 | + name: DB-dump |
| 79 | + path: /tmp/db.sql |
| 80 | + - name: Verifying submissions |
| 81 | + shell: bash |
| 82 | + run: | |
| 83 | + set -x |
| 84 | + export CURLOPTS="--fail -sq -m 30 -b /tmp/cookiejar" |
| 85 | + # Make an initial request which will get us a session id, and grab the csrf token from it |
| 86 | + CSRFTOKEN=$(curl $CURLOPTS -c /tmp/cookiejar "http://localhost/domjudge/login" | sed -n 's/.*_csrf_token.*value="\(.*\)".*/\1/p') |
| 87 | + # Make a second request with our session + csrf token to actually log in |
| 88 | + curl $CURLOPTS -c /tmp/cookiejar -F "_csrf_token=$CSRFTOKEN" -F "_username=admin" -F "_password=password" "http://localhost/domjudge/login" |
| 89 | + # Send a general clarification to later test if we see the event. |
| 90 | + curl $CURLOPTS -F "sendto=" -F "problem=1-" -F "bodytext=Testing" -F "submit=Send" \ |
| 91 | + "http://localhost/domjudge/jury/clarifications/send" -o /dev/null |
| 92 | + curl $CURLOPTS "http://localhost/domjudge/jury/judging-verifier?verify_multiple=1" -o /dev/null |
| 93 | + NUMNOTVERIFIED=$(curl $CURLOPTS "http://localhost/domjudge/jury/judging-verifier" | grep "submissions checked" | sed -r 's/^.* ([0-9]+) submissions checked.*$/\1/') |
| 94 | + NUMVERIFIED=$( curl $CURLOPTS "http://localhost/domjudge/jury/judging-verifier" | grep "submissions not checked" | sed -r 's/^.* ([0-9]+) submissions not checked.*$/\1/') |
| 95 | + NUMNOMAGIC=$( curl $CURLOPTS "http://localhost/domjudge/jury/judging-verifier" | grep "without magic string" | sed -r 's/^.* ([0-9]+) without magic string.*$/\1/') |
| 96 | + NUMSUBS=$(curl $CURLOPTS http://localhost/domjudge/api/contests/demo/submissions | python3 -mjson.tool | grep -c '"id":') |
| 97 | + # We expect |
| 98 | + # - two submissions with ambiguous outcome, |
| 99 | + # - one submissions submitted through the submit client, and thus the magic string ignored, |
| 100 | + # - and all submissions to be judged. |
| 101 | + if [ $NUMNOTVERIFIED -ne 2 ] || [ $NUMNOMAGIC -ne 1 ] || [ $NUMSUBS -gt $((NUMVERIFIED+NUMNOTVERIFIED)) ]; then |
| 102 | + echo "verified subs: $NUMVERIFIED, unverified subs: $NUMNOTVERIFIED, total subs: $NUMSUBS" |
| 103 | + echo "(expected 2 submissions to be unverified, but all to be processed)" |
| 104 | + echo "Of these $NUMNOMAGIC do not have the EXPECTED_RESULTS string (should be 1)." |
| 105 | + curl $CURLOPTS "http://localhost/domjudge/jury/judging-verifier?verify_multiple=1" | w3m -dump -T text/html |
| 106 | + exit 1 |
| 107 | + fi |
| 108 | + - name: Finalize contest so that awards appear in the feed |
| 109 | + shell: bash |
| 110 | + run: | |
| 111 | + set -x |
| 112 | + export CURLOPTS="--fail -m 30 -b $COOKIEJAR" |
| 113 | + curl $CURLOPTS http://localhost/domjudge/jury/contests/1/freeze/doNow || true |
| 114 | + curl $CURLOPTS http://localhost/domjudge/jury/contests/1/end/doNow || true |
| 115 | + curl $CURLOPTS -X POST -d 'finalize_contest[b]=0&finalize_contest[finalizecomment]=gitlab&finalize_contest[finalize]=' http://localhost/domjudge/jury/contests/1/finalize |
| 116 | + - name: Verify no errors in prod.log |
| 117 | + shell: bash |
| 118 | + run: | |
| 119 | + if cat /opt/domjudge/domserver/webapp/var/log/prod.log | egrep '(CRITICAL|ERROR):'; then |
| 120 | + exit 1 |
| 121 | + fi |
| 122 | + - name: Download and perform API check |
| 123 | + shell: bash |
| 124 | + run: | |
| 125 | + cd $HOME |
| 126 | + curl -o yajsv https://github.com/neilpa/yajsv/releases/download/v1.4.1/yajsv.linux.amd64 |
| 127 | + chmod a+x yajsv |
| 128 | + echo -e "\033[0m" |
| 129 | + git clone https://github.com/icpc/ccs-specs.git |
| 130 | + export CCS_SPECS_PINNED_SHA1='a68aff54c4e60fc2bff2fc5c36c119bffa4d30f1' |
| 131 | + ( cd ccs-specs && git reset --hard $CCS_SPECS_PINNED_SHA1 ) |
| 132 | + export CHECK_API="${HOME}/ccs-specs/check-api.sh -j ${HOME}/yajsv" |
| 133 | + $CHECK_API -n -C -e -a 'strict=1' http://admin:password@localhost/domjudge/api |
0 commit comments