From e35e139294dfa151c7b8de00f710e1f2ff8aaea9 Mon Sep 17 00:00:00 2001 From: Michael Vasseur <14887731+vmcj@users.noreply.github.com> Date: Mon, 9 Dec 2024 20:57:42 +0100 Subject: [PATCH] Ignore old GitLab tests --- gitlab/base.sh | 83 ------------ gitlab/chroot.bats | 55 -------- gitlab/chroot_checks.sh | 45 ------ gitlab/ci/integration.yml | 64 --------- gitlab/ci/misc.yml | 17 --- gitlab/ci/template.yml | 65 --------- gitlab/ci/unit.yml | 61 --------- gitlab/ci/webstandard.yml | 50 ------- gitlab/ci_settings.sh | 55 -------- gitlab/default-nginx | 12 -- gitlab/integration.sh | 278 -------------------------------------- gitlab/runpipe-tests.sh | 13 -- gitlab/unit-tests.sh | 80 ----------- gitlab/webstandard.sh | 122 ----------------- 14 files changed, 1000 deletions(-) delete mode 100755 gitlab/base.sh delete mode 100644 gitlab/chroot.bats delete mode 100755 gitlab/chroot_checks.sh delete mode 100644 gitlab/ci/integration.yml delete mode 100644 gitlab/ci/misc.yml delete mode 100644 gitlab/ci/template.yml delete mode 100644 gitlab/ci/unit.yml delete mode 100644 gitlab/ci/webstandard.yml delete mode 100755 gitlab/ci_settings.sh delete mode 100644 gitlab/default-nginx delete mode 100755 gitlab/integration.sh delete mode 100755 gitlab/runpipe-tests.sh delete mode 100755 gitlab/unit-tests.sh delete mode 100755 gitlab/webstandard.sh diff --git a/gitlab/base.sh b/gitlab/base.sh deleted file mode 100755 index 383bc0c0f5..0000000000 --- a/gitlab/base.sh +++ /dev/null @@ -1,83 +0,0 @@ -#!/bin/bash - -. gitlab/ci_settings.sh - -lsb_release -a - -# FIXME: This chicken-egg problem is annoying but let us bootstrap for now. -echo "CREATE DATABASE IF NOT EXISTS \`domjudge\` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;" | mysql -echo "CREATE USER 'domjudge'@'%' IDENTIFIED BY 'domjudge';" | mysql -echo "GRANT SELECT, INSERT, UPDATE, DELETE ON \`domjudge\`.* TO 'domjudge'@'%';" | mysql - -# Increase max_allowed_packet for following connections. -echo "SET GLOBAL max_allowed_packet = 100*1024*1024;" | mysql - -# Test that SQL upgrade scripts also work with this setting -if [ -n "${MYSQL_REQUIRE_PRIMARY_KEY:-}" ]; then - echo 'SET GLOBAL sql_require_primary_key = 1;' | mysql -fi - -# Generate a dbpasswords file -echo "unused:sqlserver:domjudge:domjudge:domjudge:3306" > etc/dbpasswords.secret - -# Generate APP_SECRET for symfony -# shellcheck disable=SC2164 -( cd etc ; ./gensymfonysecret > symfony_app.secret ) - -cat > webapp/config/static.yaml <> ~www-data/.netrc -sudo -u www-data bin/dj_setup_database -uroot -p${MYSQL_ROOT_PASSWORD} bare-install - -# shellcheck disable=SC2154 -if [ -n "${integration:-}" ]; then - # Make sure admin has a team associated to insert submissions as well. - echo "UPDATE user SET teamid=1 WHERE userid=1;" | mysql domjudge -fi - -sudo -u www-data bin/dj_setup_database -uroot -p${MYSQL_ROOT_PASSWORD} install-examples diff --git a/gitlab/chroot.bats b/gitlab/chroot.bats deleted file mode 100644 index f27013a97d..0000000000 --- a/gitlab/chroot.bats +++ /dev/null @@ -1,55 +0,0 @@ -#!/usr/bin/env bats - -load 'assert' - -CHROOT="/chroot/domjudge" -if [ -n "${CI_JOB_ID+x}" ]; then - CHROOT="/builds/DOMjudge/domjudge${CHROOT}" -fi -# Cleanup old dir -rm -rf $CHROOT - -COMMANDARGS="" -if [ -n "${ARCH+x}" ]; then - COMMANDARGS="-a $ARCH $COMMANDARGS" -fi - -@test "help output" { - run ./dj_make_chroot -h - assert_success - assert_partial "Usage:" - assert_partial "Creates a chroot environment with Java JRE support using the" - assert_partial "Debian or Ubuntu GNU/Linux distribution." - assert_partial "Options" - assert_partial "Available architectures:" - assert_partial "Environment Overrides:" - assert_partial "This script must be run as root" -} - -@test "Test chroot fails if unsupported architecture given" { - if [ -n "${ARCH+x}" ]; then - skip "Already an Arch set in the commands." - fi - for unsupported_arch in 'dom04' 'arm' '64' 'namd64' 'amd64v2'; do - run ./dj_make_chroot $COMMANDARGS -a $unsupported_arch - assert_failure - assert_partial "Error: Architecture $unsupported_arch not supported for" - done -} - -# Creation of the chroot is slow so we run all tests inside 1 large test to speedup. -@test "Test chroot works with args: $COMMANDARGS" { - run ./dj_make_chroot $COMMANDARGS - assert_partial "Done building chroot in $CHROOT" - assert_success - if [ -n "${ARCH+x}" ]; then - run ./dj_run_chroot "dpkg --print-architecture" - assert_partial "$ARCH" - assert_success - else - HOSTARCH=$(dpkg --print-architecture) - run ./dj_run_chroot "dpkg --print-architecture" - assert_partial "$HOSTARCH" - assert_success - fi -} diff --git a/gitlab/chroot_checks.sh b/gitlab/chroot_checks.sh deleted file mode 100755 index d16adefaed..0000000000 --- a/gitlab/chroot_checks.sh +++ /dev/null @@ -1,45 +0,0 @@ -#!/bin/bash - -. gitlab/ci_settings.sh - -function finish() { - echo -e "\\n\\n=======================================================\\n" - echo "Storing artifacts..." - trace_on - set +e - cp /proc/cmdline "$GITLABARTIFACTS/cmdline" - cp /chroot/domjudge/etc/apt/sources.list "$GITLABARTIFACTS/sources.list" - cp /chroot/domjudge/debootstrap/debootstrap.log "$GITLABARTIFACTS/debootstrap.log" -} -trap finish EXIT - -section_start setup "Setup and install" -lsb_release -a - -# configure, make and install (but skip documentation) -make configure -./configure --with-baseurl='http://localhost/domjudge/' --with-domjudge-user=domjudge --with-judgehost_chrootdir=${DIR}/chroot/domjudge |& tee "$GITLABARTIFACTS/configure.log" -make judgehost |& tee "$GITLABARTIFACTS/make.log" -sudo make install-judgehost |& tee -a "$GITLABARTIFACTS/make.log" -section_end setup - -section_start mount "Show runner mounts" -# Currently gitlab has some runners with noexec/nodev, -# This can be removed if we have more stable runners. -mount -o remount,exec,dev /builds -section_end mount - -section_start chroot "Configure chroot" - -if [ -e ${DIR}/chroot/domjudge ]; then - rm -rf ${DIR}/chroot/domjudge -fi - -cd ${DIR}/misc-tools || exit 1 -section_end chroot - -section_start chroottest "Test chroot contents" -cp ${DIR}/submit/assert.bash ./ -cp ${DIR}/gitlab/chroot.bats ./ -bats ./chroot.bats -section_end chroottest diff --git a/gitlab/ci/integration.yml b/gitlab/ci/integration.yml deleted file mode 100644 index 3c74b82edd..0000000000 --- a/gitlab/ci/integration.yml +++ /dev/null @@ -1,64 +0,0 @@ -.integration_job: - extends: [.long_job,.cached_vendor] - stage: integration - script: - - set -eux - - if [ -z ${PHPVERSION+x} ]; then export PHPVERSION=7.4; fi - - if [ "$TEST" = "E2E" ]; then exit 0; fi - - if [ "$CRAWL_DATASOURCES" != "0" ]; then exit 0; fi - - timeout --signal=15 40m ./gitlab/integration.sh $PHPVERSION - artifacts: - when: always - paths: - - gitlabartifacts - -# TODO: Re-enable when gitlab is in better shape... -# cache: -# key: integration -# paths: -# - chroot - -integration_mysql: - only: - - main - - /^[0-9].[0-9]$/ - extends: [.mysql_job,.integration_job] - variables: - MYSQL_ROOT_PASSWORD: password - MARIADB_PORT_3306_TCP_ADDR: sqlserver - MYSQL_REQUIRE_PRIMARY_KEY: 1 - PIN_JUDGEDAEMON: 1 - TEST: "Unit" - CRAWL_DATASOURCES: "0" - -integration_mariadb_pr: - except: - - main - - /^[0-9].[0-9]$/ - extends: [.mariadb_job,.phpsupported_job_pr,.integration_job] - variables: - MYSQL_ROOT_PASSWORD: password - MARIADB_PORT_3306_TCP_ADDR: sqlserver - PIN_JUDGEDAEMON: 1 - -integration_mariadb: - only: - - main - - /^[0-9].[0-9]$/ - extends: [.mariadb_job,.phpsupported_job,.integration_job] - variables: - MYSQL_ROOT_PASSWORD: password - MARIADB_PORT_3306_TCP_ADDR: sqlserver - PIN_JUDGEDAEMON: 1 - -integration_unpinned_judgehost: - only: - - main - - /^[0-9].[0-9]$/ - extends: [.mariadb_job,.integration_job] - variables: - MYSQL_ROOT_PASSWORD: password - MARIADB_PORT_3306_TCP_ADDR: sqlserver - PIN_JUDGEDAEMON: 0 - TEST: "Unit" - CRAWL_DATASOURCES: "0" diff --git a/gitlab/ci/misc.yml b/gitlab/ci/misc.yml deleted file mode 100644 index f6d6448c3d..0000000000 --- a/gitlab/ci/misc.yml +++ /dev/null @@ -1,17 +0,0 @@ -run chroot script checks: - extends: [.normal_job] - stage: chroot_checks - when: manual - allow_failure: true - parallel: - matrix: - - PLACEHOLDER: - - trigger_with_default_values - - ARCH: - - amd64 - - arm64 - - armhf - - i386 - script: - - ./gitlab/chroot_checks.sh - diff --git a/gitlab/ci/template.yml b/gitlab/ci/template.yml deleted file mode 100644 index 43d88bc5da..0000000000 --- a/gitlab/ci/template.yml +++ /dev/null @@ -1,65 +0,0 @@ -# This placeholder job tries to start as soon as possible -.clean_ordering: - needs: [] - retry: - max: 2 #Max is 2, set when gitlab is flacky - when: - - always - script: - - /bin/true - -.tiny_job: - extends: [.clean_ordering] - timeout: 4m - -.short_job: - extends: [.clean_ordering] - timeout: 7m - -.normal_job: - extends: [.clean_ordering] - timeout: 15m - -.long_job: - extends: [.clean_ordering] - timeout: 30m - -.cached_vendor: - extends: [.clean_ordering] - cache: - key: libvendor-82 - paths: - - lib/vendor/ - -.mysql_job: - script: - - /bin/true - services: - - name: mysql:8.0 - command: ["--default-authentication-plugin=mysql_native_password"] - alias: sqlserver - -.mariadb_job: - script: - - /bin/true - services: - - name: mariadb - alias: sqlserver - -.phpsupported_job: - script: - - /bin/true - parallel: - matrix: - - PHPVERSION: ["7.4","8.0","8.1","8.2"] - TEST: ["E2E","Unit"] - CRAWL_DATASOURCES: ["0","1","2"] - -.phpsupported_job_pr: - script: - - /bin/true - parallel: - matrix: - - PHPVERSION: ["8.2"] - TEST: ["E2E","Unit"] - CRAWL_DATASOURCES: ["0"] diff --git a/gitlab/ci/unit.yml b/gitlab/ci/unit.yml deleted file mode 100644 index 4d8677888d..0000000000 --- a/gitlab/ci/unit.yml +++ /dev/null @@ -1,61 +0,0 @@ -.unit_job: - extends: [.normal_job,.cached_vendor] - stage: unit - # Disabled for now as it drastically speeds up running unit tests and we don't use it yet - # before_script: - # - apt-get update -yqq - # - apt-get install php-xdebug -yqq - variables: - MYSQL_ROOT_PASSWORD: password - MARIADB_PORT_3306_TCP_ADDR: sqlserver - script: - - set -eux - - if [ -z ${PHPVERSION+x} ]; then export PHPVERSION=7.4; fi - - if [ -z ${TEST+x} ]; then export TEST="UNIT"; fi - - if [ "$TEST" = "UNIT" ] && [ "$CRAWL_DATASOURCES" != "0" ]; then exit 0; fi - - if [ "$TEST" = "E2E" ] && [ "$CRAWL_DATASOURCES" != "0" ] && [ "$CI_COMMIT_BRANCH" != "main" ]; then exit 0; fi - - export CRAWL_DATASOURCES - - ./gitlab/unit-tests.sh $PHPVERSION $TEST - artifacts: - when: always - paths: - - unit-tests.xml - - coverage-html - - deprecation.txt - - duration - - gitlabartifacts - reports: - junit: - - unit-tests.xml - -run runpipe tests: - extends: [.normal_job] - stage: unit - script: - - ./gitlab/runpipe-tests.sh - artifacts: - when: always - paths: - - gitlabartifacts - -run unit tests: - only: - - main - - /^[0-9].[0-9]$/ - extends: [.mariadb_job,.phpsupported_job,.unit_job] - -run unit tests (PR): - except: - - main - - /^[0-9].[0-9]$/ - extends: [.mariadb_job,.phpsupported_job_pr,.unit_job] - -run unit tests (MySQL): - only: - - main - - /^[0-9].[0-9]$/ - extends: [.mysql_job,.unit_job] - parallel: - matrix: - - TEST: ["E2E","Unit"] - CRAWL_DATASOURCES: ["0"] diff --git a/gitlab/ci/webstandard.yml b/gitlab/ci/webstandard.yml deleted file mode 100644 index fa0c43f778..0000000000 --- a/gitlab/ci/webstandard.yml +++ /dev/null @@ -1,50 +0,0 @@ -webstandard_check_role: - only: - - main - - /^[0-9].[0-9]$/ - extends: [.short_job,.mariadb_job] - parallel: - matrix: - - ROLE: public - TEST: [w3cval,WCAG2A,WCAG2AA] - - ROLE: team - TEST: [w3cval,WCAG2A,WCAG2AA] - - ROLE: balloon - TEST: [w3cval,WCAG2A,WCAG2AA] - - ROLE: jury - TEST: [w3cval] - - ROLE: admin - TEST: [w3cval] - stage: accessibility - variables: - MYSQL_ROOT_PASSWORD: password - script: - - ./gitlab/webstandard.sh - artifacts: - when: always - paths: - - public - - w3chtmlpublic.json - - w3ccsspublic.json - - w3csvgpublic.json - -webstandard_check_role_PR: - extends: [.short_job,.mariadb_job] - parallel: - matrix: - - ROLE: public - TEST: [w3cval,WCAG2AA] - - ROLE: admin - TEST: [w3cval] - stage: accessibility - variables: - MYSQL_ROOT_PASSWORD: password - script: - - ./gitlab/webstandard.sh - artifacts: - when: always - paths: - - public - - w3chtmlpublic.json - - w3ccsspublic.json - - w3csvgpublic.json diff --git a/gitlab/ci_settings.sh b/gitlab/ci_settings.sh deleted file mode 100755 index dfea8a1925..0000000000 --- a/gitlab/ci_settings.sh +++ /dev/null @@ -1,55 +0,0 @@ -#!/bin/bash - -# Fail pipeline when variable is not set or individual command has an non-zero exitcode. -set -euo pipefail - -shopt -s expand_aliases - -# Shared constants between jobs -DIR=$(pwd) -GITSHA=$(git rev-parse HEAD || true) -export DIR -export GITSHA -export PS4='(${BASH_SOURCE}:${LINENO}): - [$?] $ ' -export LOGFILE="/opt/domjudge/domserver/webapp/var/log/prod.log" - -CCS_SPECS_PINNED_SHA1='a68aff54c4e60fc2bff2fc5c36c119bffa4d30f1' - -# Shared storage for all artifacts -export GITLABARTIFACTS="$DIR/gitlabartifacts" -mkdir -p "$GITLABARTIFACTS" - -# Functions to annotate the GitLab logs -alias trace_on='set -x' -alias trace_off='{ set +x; } 2>/dev/null' -function section_start_internal() { - echo -e "section_start:$(date +%s):$2[collapsed=$1]\r\e[0K$3" - trace_on -} -function section_end_internal() { - echo -e "section_end:$(date +%s):$1\r\e[0K" - trace_on -} -alias section_start_collap='trace_off ; section_start_internal true' -alias section_start='trace_off ; section_start_internal false' -alias section_end='trace_off ; section_end_internal ' - -function log_on_err() { - echo -e "\\n\\n=======================================================\\n" - echo "Symfony log:" - if sudo test -f "$LOGFILE" ; then - sudo cat "$LOGFILE" - fi -} - -function show_phpinfo() { - phpversion=$1 - section_start_collap phpinfo "Show the new PHP info" - update-alternatives --set php /usr/bin/php"${phpversion}" - php -v - php -m - section_end phpinfo -} - -# Show running command -set -x diff --git a/gitlab/default-nginx b/gitlab/default-nginx deleted file mode 100644 index f27f32a0ec..0000000000 --- a/gitlab/default-nginx +++ /dev/null @@ -1,12 +0,0 @@ -server { - listen 80 default_server; - listen [::]:80 default_server; - root /var/www/html; - index index.html index.htm index.nginx-debian.html; - server_name _; - location / { - # First attempt to serve request as file, then - # as directory, then fall back to displaying a 404. - try_files $uri $uri/ =404; - } -} diff --git a/gitlab/integration.sh b/gitlab/integration.sh deleted file mode 100755 index 5a75f90819..0000000000 --- a/gitlab/integration.sh +++ /dev/null @@ -1,278 +0,0 @@ -#!/bin/bash - -. gitlab/ci_settings.sh - -export version=$1 - -show_phpinfo $version - -function finish() { - echo -e "\\n\\n=======================================================\\n" - echo "Storing artifacts..." - trace_on - set +e - mysqldump domjudge > "$GITLABARTIFACTS/db.sql" - cp /var/log/nginx/domjudge.log "$GITLABARTIFACTS/nginx.log" - cp /opt/domjudge/domserver/webapp/var/log/prod.log "$GITLABARTIFACTS/symfony.log" - cp /opt/domjudge/domserver/webapp/var/log/prod.log.errors "$GITLABARTIFACTS/symfony_errors.log" - cp /tmp/judgedaemon.log "$GITLABARTIFACTS/judgedaemon.log" - cp /proc/cmdline "$GITLABARTIFACTS/cmdline" - CHROOTDIR=/chroot/domjudge - if [ -n "${CI+x}" ]; then - CHROOTDIR=${DIR}${CHROOTDIR} - fi - cp $CHROOTDIR/etc/apt/sources.list "$GITLABARTIFACTS/sources.list" - cp $CHROOTDIR/debootstrap/debootstrap.log "$GITLABARTIFACTS/debootstrap.log" - cp "${DIR}"/misc-tools/icpctools/*json "$GITLABARTIFACTS/" -} -trap finish EXIT - -export integration=1 -section_start setup "Setup and install" - -# Set up -"$( dirname "${BASH_SOURCE[0]}" )"/base.sh - -# Add jury to demo user -echo "INSERT INTO userrole (userid, roleid) VALUES (3, 2);" | mysql domjudge - -# Add netrc file for demo user login -echo "machine localhost login demo password demo" > ~/.netrc - -cd /opt/domjudge/domserver - -# This needs to be done before we do any submission. -# 8 hours as a helper so we can adjust contest start/endtime -TIMEHELP=$((8*60*60)) -UNIX_TIMESTAMP=$(date +%s) -STARTTIME=$((UNIX_TIMESTAMP-TIMEHELP)) -export TZ="Europe/Amsterdam" -STARTTIME_STRING="$(date -d @$STARTTIME +'%F %T Europe/Amsterdam')" -FREEZETIME=$((UNIX_TIMESTAMP+TIMEHELP)) -FREEZETIME_STRING="$(date -d @$FREEZETIME +'%F %T Europe/Amsterdam')" -ENDTIME=$((UNIX_TIMESTAMP+TIMEHELP+TIMEHELP)) -ENDTIME_STRING="$(date -d @$ENDTIME +'%F %T Europe/Amsterdam')" -# Database changes to make the REST API and event feed match better. -cat </dev/null; then - userdel -f -r $RUN_USER -fi - -sudo useradd -d /nonexistent -g nogroup -s /bin/false -u $((2000+(RANDOM%1000))) $RUN_USER - -# start judgedaemon -cd /opt/domjudge/judgehost/ - -# Since ubuntu20.04 gitlabci image this is sometimes needed -# It should be safe to remove this when it creates issues -set +e -mount -t proc proc /proc -set -e - -if [ $PIN_JUDGEDAEMON -eq 1 ]; then - PINNING="-n 0" -fi -if [ $cgroupv1 -ne 0 ]; then - sudo -u domjudge bin/judgedaemon $PINNING |& tee /tmp/judgedaemon.log & - sleep 5 -fi - -section_end more_setup - -section_start submitting "Importing Kattis examples" -export SUBMITBASEURL='http://localhost/domjudge/' - -# Prepare to load example problems from Kattis/problemtools -echo "INSERT INTO userrole (userid, roleid) VALUES (3, 1);" | mysql domjudge -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/1/problems -done -section_end submitting - -section_start curlcookie "Preparing cookie jar for curl" -export COOKIEJAR -COOKIEJAR=$(mktemp --tmpdir) -export CURLOPTS="--fail -sq -m 30 -b $COOKIEJAR" - -# Make an initial request which will get us a session id, and grab the csrf token from it -CSRFTOKEN=$(curl $CURLOPTS -c $COOKIEJAR "http://localhost/domjudge/login" 2>/dev/null | sed -n 's/.*_csrf_token.*value="\(.*\)".*/\1/p') -# Make a second request with our session + csrf token to actually log in -curl $CURLOPTS -c $COOKIEJAR -F "_csrf_token=$CSRFTOKEN" -F "_username=admin" -F "_password=$ADMINPASS" "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 - -section_end curlcookie - -if [ $cgroupv1 -ne 0 ]; then - section_start judging "Waiting until all submissions are judged" - # wait for and check results - NUMSUBS=$(curl --fail http://admin:$ADMINPASS@localhost/domjudge/api/contests/1/submissions | python3 -mjson.tool | grep -c '"id":') - - # Don't spam the log. - set +x - - while /bin/true; do - sleep 30s - curl $CURLOPTS "http://localhost/domjudge/jury/judging-verifier?verify_multiple=1" -o /dev/null - - # Check if we are done, i.e. everything is judged or something got disabled by internal error... - if tail /tmp/judgedaemon.log | grep -q "No submissions in queue"; then - break - fi - # ... or something has crashed. - if ! pgrep -f judgedaemon; then - break - fi - done - - 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/') - section_end judging - - # We expect - # - two submissions with ambiguous outcome, - # - no submissions without magic string, - # - and all submissions to be judged. - if [ $NUMNOTVERIFIED -ne 2 ] || [ $NUMNOMAGIC -ne 0 ] || [ $NUMSUBS -gt $((NUMVERIFIED+NUMNOTVERIFIED)) ]; then - section_start error "Short error description" - # We error out below anyway, so no need to fail earlier than that. - set +e - 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 0)." - curl $CURLOPTS "http://localhost/domjudge/jury/judging-verifier?verify_multiple=1" | w3m -dump -T text/html - section_end error - - section_start logfiles "All the more or less useful logfiles" - for i in /opt/domjudge/judgehost/judgings/*/*/*/*/*/compile.out; do - echo $i; - head -n 100 $i; - dir=$(dirname $i) - if [ -r $dir/testcase001/system.out ]; then - head $dir/testcase001/system.out - head $dir/testcase001/runguard.err - head $dir/testcase001/program.err - head $dir/testcase001/program.meta - fi - echo; - done - exit 1; - fi -fi - -section_start api_check "Performing API checks" -# Start logging again -set -x - -# Finalize contest so that awards appear in the feed; first freeze and end the -# contest if that has not already been done. -export CURLOPTS="--fail -m 30 -b $COOKIEJAR" -curl $CURLOPTS -X POST -d 'contest=1&donow[freeze]=freeze now' http://localhost/domjudge/jury/contests || true -curl $CURLOPTS -X POST -d 'contest=1&donow[end]=end now' http://localhost/domjudge/jury/contests || true -curl $CURLOPTS -X POST -d 'finalize_contest[b]=0&finalize_contest[finalizecomment]=gitlab&finalize_contest[finalize]=' http://localhost/domjudge/jury/contests/1/finalize - -# shellcheck disable=SC2002,SC2196 -if cat /opt/domjudge/domserver/webapp/var/log/prod.log | egrep '(CRITICAL|ERROR):'; then - exit 1 -fi - -# Check the Contest API: -if [ $cgroupv1 -ne 0 ]; then - $CHECK_API -n -C -e -a 'strict=1' http://admin:$ADMINPASS@localhost/domjudge/api -else - # With cgroup v1 not being available we don't judge, so we cannot do - # consistency checks, so running the above command without -C. - $CHECK_API -n -e -a 'strict=1' http://admin:$ADMINPASS@localhost/domjudge/api -fi -section_end api_check |& tee "$GITLABARTIFACTS/check_api.log" - -section_start validate_feed "Validate the eventfeed against API (ignoring failures)" -cd ${DIR}/misc-tools -./compare-cds.sh http://localhost/domjudge 1 |& tee "$GITLABARTIFACTS/compare_cds.log" || true -section_end validate_feed diff --git a/gitlab/runpipe-tests.sh b/gitlab/runpipe-tests.sh deleted file mode 100755 index 0e997bd08b..0000000000 --- a/gitlab/runpipe-tests.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash - -. gitlab/ci_settings.sh - -section_start compile "Compile runpipe" -# Configure and make the runpipe binaries. -make configure -./configure --with-baseurl='http://localhost/domjudge/' --with-domjudge-user=domjudge --with-judgehost_chrootdir=${DIR}/chroot/domjudge |& tee "$GITLABARTIFACTS/configure.log" -make judgehost |& tee "$GITLABARTIFACTS/make.log" -section_end compile - -cd judge/runpipe_test || exit 1 -make test |& tee "$GITLABARTIFACTS/test.log" diff --git a/gitlab/unit-tests.sh b/gitlab/unit-tests.sh deleted file mode 100755 index 3f64ecf497..0000000000 --- a/gitlab/unit-tests.sh +++ /dev/null @@ -1,80 +0,0 @@ -#!/bin/bash - -. gitlab/ci_settings.sh - -export version=$1 -unittest=$2 -[ "$version" = "8.1" ] && CODECOVERAGE=1 || CODECOVERAGE=0 - -show_phpinfo $version - -# Set up -"$( dirname "${BASH_SOURCE[0]}" )"/base.sh - -# Add team to admin user -echo "INSERT INTO userrole (userid, roleid) VALUES (1, 3);" | mysql domjudge -echo "UPDATE user SET teamid = 1 WHERE userid = 1;" | mysql domjudge - -# Copy the .env.test file, as this is normally not done during -# installation and we need it. -cp webapp/.env.test /opt/domjudge/domserver/webapp/ - -# We also need the composer.json for PHPunit to detect the correct directory. -cp composer.json /opt/domjudge/domserver/ - -cd /opt/domjudge/domserver - -export APP_ENV="test" - -# Run phpunit tests. -pcov="" -phpcov="" -if [ "$CODECOVERAGE" -eq 1 ]; then - phpcov="-dpcov.enabled=1 -dpcov.directory=webapp/src" - pcov="--coverage-html=${CI_PROJECT_DIR}/coverage-html --coverage-clover coverage.xml" -fi -set +e -php $phpcov lib/vendor/bin/phpunit -c webapp/phpunit.xml.dist webapp/tests/$unittest --log-junit ${CI_PROJECT_DIR}/unit-tests.xml --colors=never $pcov > "$GITLABARTIFACTS"/phpunit.out -UNITSUCCESS=$? -set -e -CNT=0 -if [ $CODECOVERAGE -eq 1 ]; then - CNT=$(sed -n '/Generating code coverage report/,$p' "$GITLABARTIFACTS"/phpunit.out | grep -v DoctrineTestBundle | grep -cv ^$) - FILE=deprecation.txt - sed -n '/Generating code coverage report/,$p' "$GITLABARTIFACTS"/phpunit.out > ${CI_PROJECT_DIR}/$FILE - if [ $CNT -le 12 ]; then - STATE=success - else - STATE=failure - fi - ORIGINAL="gitlab.com/DOMjudge" - REPLACETO="domjudge.gitlab.io/-" - # Copied from CCS - curl https://api.github.com/repos/domjudge/domjudge/statuses/$CI_COMMIT_SHA \ - -X POST \ - -H "Authorization: token $GH_BOT_TOKEN_OBSCURED" \ - -H "Accept: application/vnd.github.v3+json" \ - -d "{\"state\": \"$STATE\", \"target_url\": \"${CI_JOB_URL/$ORIGINAL/$REPLACETO}/artifacts/$FILE\", \"description\":\"Symfony deprecations\", \"context\": \"Symfony deprecation\"}" -fi -if [ $UNITSUCCESS -eq 0 ]; then - STATE=success -else - STATE=failure -fi -curl https://api.github.com/repos/domjudge/domjudge/statuses/$CI_COMMIT_SHA \ - -X POST \ - -H "Authorization: token $GH_BOT_TOKEN_OBSCURED" \ - -H "Accept: application/vnd.github.v3+json" \ - -d "{\"state\": \"$STATE\", \"target_url\": \"${CI_PIPELINE_URL}/test_report\", \"description\":\"Unit tests\", \"context\": \"unit_tests ($version)\"}" -if [ $UNITSUCCESS -ne 0 ]; then - exit 1 -fi - -if [ $CODECOVERAGE -eq 1 ]; then - section_start_collap uploadcoverage "Upload code coverage" - # Only upload when we got working unit-tests. - set +u # Uses some variables which are not set - # shellcheck disable=SC1090 - . $DIR/.github/jobs/uploadcodecov.sh 1>/dev/zero 2>/dev/zero - section_end uploadcoverage -fi diff --git a/gitlab/webstandard.sh b/gitlab/webstandard.sh deleted file mode 100755 index 7adcab46cd..0000000000 --- a/gitlab/webstandard.sh +++ /dev/null @@ -1,122 +0,0 @@ -#!/bin/bash - -. gitlab/ci_settings.sh - -section_start_collap setup "Setup and install" - -export version=7.4 - -# Set up -"$( dirname "${BASH_SOURCE[0]}" )"/base.sh - -trap log_on_err ERR - -cd /opt/domjudge/domserver - -section_end setup - -section_start_collap testuser "Setup the test user" -# We're using the admin user in all possible roles -echo "DELETE FROM userrole WHERE userid=1;" | mysql domjudge -ADMINPASS=$(cat etc/initial_admin_password.secret) -export COOKIEJAR -COOKIEJAR=$(mktemp --tmpdir) -export CURLOPTS="--fail -sq -m 30 -b $COOKIEJAR" -if [ $ROLE = "public" ]; then - ADMINPASS="failedlogin" -elif [ $ROLE = "team" ]; then - # Add team to admin user - echo "INSERT INTO userrole (userid, roleid) VALUES (1, 3);" | mysql domjudge - echo "UPDATE user SET teamid = 1 WHERE userid = 1;" | mysql domjudge -elif [ $ROLE = "jury" ]; then - # Add jury to admin user - echo "INSERT INTO userrole (userid, roleid) VALUES (1, 2);" | mysql domjudge -elif [ $ROLE = "balloon" ]; then - # Add balloon to admin user - echo "INSERT INTO userrole (userid, roleid) VALUES (1, 4);" | mysql domjudge -elif [ $ROLE = "admin" ]; then - # Add admin to admin user - echo "INSERT INTO userrole (userid, roleid) VALUES (1, 1);" | mysql domjudge -fi - -# Make an initial request which will get us a session id, and grab the csrf token from it -CSRFTOKEN=$(curl $CURLOPTS -c $COOKIEJAR "http://localhost/domjudge/login" 2>/dev/null | sed -n 's/.*_csrf_token.*value="\(.*\)".*/\1/p') -# Make a second request with our session + csrf token to actually log in -curl $CURLOPTS -c $COOKIEJAR -F "_csrf_token=$CSRFTOKEN" -F "_username=admin" -F "_password=$ADMINPASS" "http://localhost/domjudge/login" - -cd $DIR - -cp $COOKIEJAR cookies.txt -sed -i 's/#HttpOnly_//g' cookies.txt -sed -i 's/\t0\t/\t1999999999\t/g' cookies.txt -section_end testuser - -# Could try different entrypoints -FOUNDERR=0 -URL=public -mkdir $URL -cd $URL -cp $DIR/cookies.txt ./ -section_start_collap scrape "Scrape the site with the rebuild admin user" -set +e -wget \ --reject-regex logout \ --recursive \ --no-clobber \ --page-requisites \ --html-extension \ --convert-links \ --restrict-file-names=windows \ --domains localhost \ --no-parent \ --load-cookies cookies.txt \ http://localhost/domjudge/$URL -RET=$? -set -e -#https://www.gnu.org/software/wget/manual/html_node/Exit-Status.html -# Exit code 4 is network error which we can ignore -if [ $RET -ne 4 ] && [ $RET -ne 0 ]; then - exit $RET -fi -section_end scrape - -if [ "$TEST" = "w3cval" ]; then - section_start_collap upstream_problems "Remove files from upstream with problems" - rm -rf localhost/domjudge/doc - rm -rf localhost/domjudge/css/fontawesome-all.min.css* - rm -rf localhost/domjudge/bundles/nelmioapidoc* - rm -f localhost/domjudge/css/bootstrap.min.css* - rm -f localhost/domjudge/css/select2-bootstrap.min.css* - rm -f localhost/domjudge/jury/config/check/phpinfo* - section_end upstream_problems - - section_start_collap test_suite "Install testsuite" - cd $DIR - wget https://github.com/validator/validator/releases/latest/download/vnu.linux.zip - unzip -q vnu.linux.zip - section_end test_suite - FLTR='--filterpattern .*autocomplete.*|.*style.*' - for typ in html css svg - do - $DIR/vnu-runtime-image/bin/vnu --errors-only --exit-zero-always --skip-non-$typ --format json $FLTR $URL 2> result.json - NEWFOUNDERRORS=`$DIR/vnu-runtime-image/bin/vnu --errors-only --exit-zero-always --skip-non-$typ --format gnu $FLTR $URL 2>&1 | wc -l` - FOUNDERR=$((NEWFOUNDERRORS+FOUNDERR)) - python3 -m "json.tool" < result.json > w3c$typ$URL.json - trace_off; python3 gitlab/jsontogitlab.py w3c$typ$URL.json; trace_on - done -else - section_start_collap upstream_problems "Remove files from upstream with problems" - rm -rf localhost/domjudge/{doc,api} - section_end upstream_problems - - if [ $TEST == "axe" ]; then - STAN="-e $TEST" - FLTR="" - else - STAN="-s $TEST" - FLTR="-E '#DataTables_Table_0 > tbody > tr > td > a','#menuDefault > a','#filter-card > div > div > div > span > span:nth-child(1) > span > ul > li > input','.problem-badge'" - fi - cd $DIR - ACCEPTEDERR=5 - # shellcheck disable=SC2044,SC2035 - for file in `find $URL -name *.html` - do - section_start ${file//\//} $file - # T is reasonable amount of errors to allow to not break - su domjudge -c "/node_modules/.bin/pa11y $STAN -T $ACCEPTEDERR $FLTR --reporter json ./$file" | python3 -m json.tool - ERR=`su domjudge -c "/node_modules/.bin/pa11y $STAN -T $ACCEPTEDERR $FLTR --reporter csv ./$file" | wc -l` - FOUNDERR=$((ERR+FOUNDERR-1)) # Remove header row - section_end $file - done -fi -echo "Found: " $FOUNDERR -[ "$FOUNDERR" -eq 0 ]