Skip to content

Commit d12007a

Browse files
authored
Merge branch 'main' into api_admin_actions
2 parents 11d2823 + fac33fd commit d12007a

File tree

923 files changed

+86679
-9305
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

923 files changed

+86679
-9305
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,32 +7,46 @@ assignees: ''
77

88
---
99

10-
NOTE: If this is a _discussion starter_, you need any _installation help_ or have a _question_ on how to accomplish something,
10+
<!--
11+
NOTE: If this is a _discussion starter_, you need any _installation help_, or have a _question_ on how to accomplish something,
1112
rather post at [our discussion channel](https://www.domjudge.org/chat) or send an email to our
1213
[DOMjudge-devel mailinglist](https://www.domjudge.org/mailman/postorius/lists/domjudge-devel.domjudge.org/)
1314
instead of filing an issue here.
15+
-->
1416

1517
### Description of the problem
16-
> Replace this line with a short description.
18+
<!--
19+
Write here a short description.
20+
-->
1721

1822
### Your environment
19-
> Include details about your installation here.
20-
> - DOMjudge version (e.g. 7.0.0 or a github commit hash)
21-
> - Operating system / Linux distribution and version (e.g. Ubuntu 18.04)
22-
> - Webserver (e.g. Apache or nginx)
23+
<!--
24+
Include details about your installation here.
25+
- DOMjudge version (e.g. 7.0.0 or a github commit hash)
26+
- Operating system / Linux distribution and version (e.g. Ubuntu 18.04)
27+
- Webserver (e.g. Apache or nginx)
28+
-->
2329

2430
### Steps to reproduce
25-
> Replace this with a description how we can reproduce your bug.
26-
> - Step 1
27-
> - Step 2
28-
> - Step 3
31+
<!--
32+
Write here a description how we can reproduce your bug.
33+
1. Step 1
34+
1. Step 2
35+
1. Step 3
36+
-->
2937

3038
### Expected behaviour
31-
> Replace this line with what you would expect to happen.
39+
<!--
40+
Write here what you would expect to happen.
41+
-->
3242

3343
### Actual behaviour
34-
> Replace this line with what happens instead.
44+
<!--
45+
Write here what happens instead.
46+
-->
3547

3648
### Any other information that you want to share?
37-
> Please include webserver, symfony and judgedaemon log snippets here as appropriate.
38-
> Screenshots may help in case of UI bugs.
49+
<!--
50+
Please include webserver, symfony and judgedaemon log snippets here as appropriate.
51+
Screenshots may help in case of UI bugs.
52+
-->

.github/ISSUE_TEMPLATE/feature_request.md

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,36 @@ assignees: ''
77

88
---
99

10-
NOTE: If this is a _discussion starter_, you need any _installation help_ or have a _question_ on how to accomplish something,
10+
<!--
11+
NOTE: If this is a _discussion starter_, you need any _installation help_, or have a _question_ on how to accomplish something,
1112
rather post at [our discussion channel](https://www.domjudge.org/chat) or send an email to our
1213
[DOMjudge-devel mailinglist](https://www.domjudge.org/mailman/postorius/lists/domjudge-devel.domjudge.org/).
1314
1415
Thank you for suggesting ways to improve DOMjudge. Before you file a feature
1516
request, it might be useful to discuss it first via the chat or mailing list
1617
linked above. We can then assess together whether there is
1718
not already a way to accomplish your goal with DOMjudge currently.
19+
-->
1820

1921
### Description of the enhancement request
20-
> Replace this line with a short description.
22+
<!--
23+
Write here a short description.
24+
-->
2125

2226
### The goal you want to achieve
23-
> Please elaborate on the (larger, higher level) goal you want to achieve with this enhancement, so we have a good understanding what this feature would be useful for and how it fits in DOMjudge as a whole.
27+
<!--
28+
Please elaborate on the (larger, higher level) goal you want to achieve with this enhancement, so we have a good understanding what this feature would be useful for and how it fits in DOMjudge as a whole.
29+
-->
2430

2531
### Expected behaviour
26-
> Replace this line with what you would expect to happen.
27-
> Please describe the workflow how you want this feature to work with expected start URL
28-
> - Step 1
29-
> - Step 2
32+
<!--
33+
Write here what you would expect to happen.
34+
For example describe the flow how you want this feature to work.
35+
1. Step 1
36+
2. Step 2
37+
-->
38+
3039
### Any other information that you want to share?
31-
> Screenshots may help in case of UI enhancements with annotated drawings.
40+
<!--
41+
Screenshots with annotated drawings may help in case of UI enhancements.
42+
-->

.github/dependabot.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,12 @@ updates:
4444
allow:
4545
- dependency-type: "all"
4646
target-branch: "8.2"
47+
- package-ecosystem: "composer"
48+
directory: "/"
49+
schedule:
50+
interval: "weekly"
51+
open-pull-requests-limit: 0
52+
versioning-strategy: lockfile-only
53+
allow:
54+
- dependency-type: "all"
55+
target-branch: "8.3"

.github/jobs/baseinstall.sh

Lines changed: 69 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,25 @@
1-
#!/bin/sh
1+
#!/bin/bash
22

33
. .github/jobs/ci_settings.sh
44

55
export version="$1"
66
db=${2:-install}
7+
phpversion="${3:-8.1}"
8+
# If this script is called from unit-tests.sh, we use the test environment
9+
export APP_ENV="${4:-prod}"
710

8-
set -eux
11+
# In the test environment, we need to use a different database
12+
[ "$APP_ENV" = "prod" ] && DATABASE_NAME=domjudge || DATABASE_NAME=domjudge_test
913

10-
PHPVERSION=$(php -r 'echo PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION."\n";')
11-
export PHPVERSION
14+
MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD:-root}
15+
16+
set -euxo pipefail
17+
18+
if [ -z "$phpversion" ]; then
19+
phpversion=$(php -r 'echo PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION."\n";')
20+
fi
21+
22+
show_phpinfo "$phpversion"
1223

1324
section_start "Run composer"
1425
export APP_ENV="dev"
@@ -24,43 +35,65 @@ section_end
2435

2536
section_start "Install domserver"
2637
make configure
27-
./configure \
28-
--with-baseurl='https://localhost/domjudge/' \
29-
--with-domjudge-user=root \
30-
--enable-doc-build=no \
31-
--enable-judgehost-build=no | tee "$ARTIFACTS"/configure.txt
32-
33-
make domserver
34-
make install-domserver
38+
if [ "$version" = "all" ]; then
39+
# Note that we use http instead of https here as python requests doesn't
40+
# like our self-signed cert. We should fix this separately.
41+
./configure \
42+
--with-baseurl='http://localhost/domjudge/' \
43+
--with-domjudge-user=domjudge \
44+
--with-judgehost-chrootdir=/chroot/domjudge | tee "$ARTIFACTS"/configure.txt
45+
make build-scripts domserver judgehost docs
46+
make install-domserver install-judgehost install-docs
47+
else
48+
./configure \
49+
--with-baseurl='https://localhost/domjudge/' \
50+
--with-domjudge-user=root \
51+
--enable-doc-build=no \
52+
--enable-judgehost-build=no | tee "$ARTIFACTS"/configure.txt
53+
make domserver
54+
make install-domserver
55+
rm -rf /opt/domjudge/domserver/webapp/public/doc
56+
cp -r doc /opt/domjudge/domserver/webapp/public/
57+
find /opt/domjudge/domserver -name DOMjudgelogo.pdf
58+
fi
3559
section_end
3660

3761
section_start "SQL settings"
3862
cat > ~/.my.cnf <<EOF
3963
[client]
4064
host=sqlserver
4165
user=root
42-
password=root
66+
password=${MYSQL_ROOT_PASSWORD}
4367
EOF
4468
cat ~/.my.cnf
4569

46-
mysql_root "CREATE DATABASE IF NOT EXISTS \`domjudge\` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;"
70+
mysql_root "CREATE DATABASE IF NOT EXISTS \`$DATABASE_NAME\` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;"
4771
mysql_root "CREATE USER IF NOT EXISTS \`domjudge\`@'%' IDENTIFIED BY 'domjudge';"
48-
mysql_root "GRANT SELECT, INSERT, UPDATE, DELETE ON \`domjudge\`.* TO 'domjudge'@'%';"
72+
mysql_root "GRANT SELECT, INSERT, UPDATE, DELETE ON \`$DATABASE_NAME\`.* TO 'domjudge'@'%';"
4973
mysql_root "FLUSH PRIVILEGES;"
5074

5175
# Show some MySQL debugging
5276
mysql_root "show databases"
5377
mysql_root "SELECT CURRENT_USER();"
5478
mysql_root "SELECT USER();"
5579
mysql_root "SELECT user,host FROM mysql.user"
56-
echo "unused:sqlserver:domjudge:domjudge:domjudge:3306" > /opt/domjudge/domserver/etc/dbpasswords.secret
80+
mysql_root "SET GLOBAL max_allowed_packet=1073741824"
81+
mysql_root "SHOW GLOBAL STATUS LIKE 'Connection_errors_%'"
82+
mysql_root "SHOW VARIABLES LIKE '%_timeout'"
83+
echo "unused:sqlserver:$DATABASE_NAME:domjudge:domjudge:3306" > /opt/domjudge/domserver/etc/dbpasswords.secret
5784
mysql_user "SELECT CURRENT_USER();"
5885
mysql_user "SELECT USER();"
5986
section_end
6087

61-
section_start "Install DOMjudge database"
62-
/opt/domjudge/domserver/bin/dj_setup_database -uroot -proot bare-install
63-
section_end
88+
if [ "${db}" = "install" ]; then
89+
section_start "Install DOMjudge database"
90+
/opt/domjudge/domserver/bin/dj_setup_database -uroot -p${MYSQL_ROOT_PASSWORD} bare-install
91+
section_end
92+
elif [ "${db}" = "upgrade" ]; then
93+
section_start "Upgrade DOMjudge database"
94+
/opt/domjudge/domserver/bin/dj_setup_database -uroot -p${MYSQL_ROOT_PASSWORD} upgrade
95+
section_end
96+
fi
6497

6598
section_start "Show PHP config"
6699
php -v | tee -a "$ARTIFACTS"/php.txt
@@ -74,7 +107,7 @@ cp /proc/cmdline "$ARTIFACTS"/cmdline.txt
74107
section_end
75108

76109
section_start "Setup webserver"
77-
cp /opt/domjudge/domserver/etc/domjudge-fpm.conf /etc/php/"$PHPVERSION"/fpm/pool.d/domjudge.conf
110+
cp /opt/domjudge/domserver/etc/domjudge-fpm.conf /etc/php/"$phpversion"/fpm/pool.d/domjudge.conf
78111

79112
rm -f /etc/nginx/sites-enabled/*
80113
cp /opt/domjudge/domserver/etc/nginx-conf /etc/nginx/sites-enabled/domjudge
@@ -88,34 +121,41 @@ nginx -t
88121
section_end
89122

90123
section_start "Show webserver is up"
91-
for service in nginx php${PHPVERSION}-fpm; do
124+
for service in nginx php${phpversion}-fpm; do
92125
service "$service" restart
93126
service "$service" status
94127
done
95128
section_end
96129

97130
if [ "${db}" = "install" ]; then
98131
section_start "Install the example data"
99-
/opt/domjudge/domserver/bin/dj_setup_database -uroot -proot install-examples | tee -a "$ARTIFACTS/mysql.txt"
132+
if [ "$version" = "unit" ]; then
133+
# Make sure admin has no team associated so we will not insert submissions during unit tests.
134+
mysql_root "UPDATE user SET teamid=null WHERE userid=1;" $DATABASE_NAME
135+
fi
136+
/opt/domjudge/domserver/bin/dj_setup_database -uroot -p${MYSQL_ROOT_PASSWORD} install-examples | tee -a "$ARTIFACTS/mysql.txt"
100137
section_end
101138
fi
102139

103140
section_start "Setup user"
104141
# We're using the admin user in all possible roles
105-
mysql_root "DELETE FROM userrole WHERE userid=1;" domjudge
142+
mysql_root "DELETE FROM userrole WHERE userid=1;" $DATABASE_NAME
106143
if [ "$version" = "team" ]; then
107144
# Add team to admin user
108-
mysql_root "INSERT INTO userrole (userid, roleid) VALUES (1, 3);" domjudge
109-
mysql_root "UPDATE user SET teamid = 1 WHERE userid = 1;" domjudge
145+
mysql_root "INSERT INTO userrole (userid, roleid) VALUES (1, 3);" $DATABASE_NAME
146+
mysql_root "UPDATE user SET teamid = 1 WHERE userid = 1;" $DATABASE_NAME
110147
elif [ "$version" = "jury" ]; then
111148
# Add jury to admin user
112-
mysql_root "INSERT INTO userrole (userid, roleid) VALUES (1, 2);" domjudge
149+
mysql_root "INSERT INTO userrole (userid, roleid) VALUES (1, 2);" $DATABASE_NAME
113150
elif [ "$version" = "balloon" ]; then
114151
# Add balloon to admin user
115-
mysql_root "INSERT INTO userrole (userid, roleid) VALUES (1, 4);" domjudge
152+
mysql_root "INSERT INTO userrole (userid, roleid) VALUES (1, 4);" $DATABASE_NAME
116153
elif [ "$version" = "admin" ]; then
117154
# Add admin to admin user
118-
mysql_root "INSERT INTO userrole (userid, roleid) VALUES (1, 1);" domjudge
155+
mysql_root "INSERT INTO userrole (userid, roleid) VALUES (1, 1);" $DATABASE_NAME
156+
elif [ "$version" = "all" ] || [ "$version" = "unit" ]; then
157+
mysql_root "INSERT INTO userrole (userid, roleid) VALUES (1, 1);" $DATABASE_NAME
158+
mysql_root "INSERT INTO userrole (userid, roleid) VALUES (1, 3);" $DATABASE_NAME
159+
mysql_root "UPDATE user SET teamid = 1 WHERE userid = 1;" $DATABASE_NAME
119160
fi
120161
section_end
121-

gitlab/chroot.bats renamed to .github/jobs/chroot.bats

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
load 'assert'
44

55
CHROOT="/chroot/domjudge"
6-
if [ -n "${CI_JOB_ID+x}" ]; then
7-
CHROOT="/builds/DOMjudge/domjudge${CHROOT}"
6+
if [ -n "${GITHUB_REPOSITORY+x}" ]; then
7+
CHROOT="/__w/domjudge/domjudge${CHROOT}"
88
fi
99
# Cleanup old dir
1010
rm -rf $CHROOT

.github/jobs/chroot_checks.sh

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/bin/bash
2+
3+
. .github/jobs/ci_settings.sh
4+
5+
if [ -n "$1" ] && [ "$1" != "default" ]; then
6+
export ARCH_OPTION="-a $1"
7+
else
8+
export ARCH_OPTION=""
9+
fi
10+
11+
function finish() {
12+
echo -e "\\n\\n=======================================================\\n"
13+
echo "Storing artifacts..."
14+
trace_on
15+
set +e
16+
cp /proc/cmdline "$ARTIFACTS/cmdline"
17+
cp /__w/domjudge/domjudge/chroot/domjudge/etc/apt/sources.list "$ARTIFACTS/sources.list"
18+
cp /__w/domjudge/domjudge/chroot/domjudge/debootstrap/debootstrap.log "$ARTIFACTS/debootstrap.log"
19+
}
20+
21+
FAILED=0
22+
23+
trap finish EXIT
24+
25+
set -euo pipefail
26+
27+
DIR=$PWD
28+
section_start "Debug info"
29+
lsb_release -a | tee -a "$ARTIFACTS/debug-info"
30+
mount | tee -a "$ARTIFACTS/debug-info"
31+
whoami | tee -a "$ARTIFACTS/debug-info"
32+
echo "Dir: $DIR" | tee -a "$ARTIFACTS/debug-info"
33+
section_end
34+
35+
section_start "Basic judgehost install"
36+
chown -R domjudge ./
37+
38+
# configure, make and install (but skip documentation)
39+
sudo -u domjudge make configure
40+
sudo -u domjudge ./configure --with-baseurl='http://localhost/domjudge/' --with-domjudge-user=domjudge --with-judgehost_chrootdir=${DIR}/chroot/domjudge |& tee "$ARTIFACTS/configure.log"
41+
sudo -u domjudge make judgehost |& tee "$ARTIFACTS/make.log"
42+
make install-judgehost |& tee -a "$ARTIFACTS/make.log"
43+
section_end setup
44+
45+
section_start "Configure chroot"
46+
47+
cd /opt/domjudge/judgehost/bin || exit 1
48+
section_end chroot
49+
50+
section_start "Show minimal chroot"
51+
./dj_make_chroot $ARCH_OPTION | tee -a "$ARTIFACTS"/chroot.log
52+
section_end
53+
54+
section_start "Test chroot contents"
55+
set -xe
56+
cp ${DIR}/submit/assert.bash .
57+
cp ${DIR}/.github/jobs/chroot.bats .
58+
bats ./chroot.bats
59+
section_end

.github/jobs/ci_settings.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,15 @@ mysql_user () {
3434
echo "$1" | mysql -udomjudge -pdomjudge ${2:-} | tee -a "$ARTIFACTS"/mysql.txt
3535
}
3636

37+
show_phpinfo() {
38+
phpversion=$1
39+
section_start "Show the new PHP info"
40+
update-alternatives --set php /usr/bin/php"${phpversion}"
41+
php -v
42+
php -m
43+
section_end
44+
}
45+
3746
section_start () {
3847
if [ "$#" -ne 1 ]; then
3948
echo "Only 1 argument is needed for GHA, 2 was needed for GitLab."

.github/jobs/composer_setup.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#!/bin/sh
1+
#!/bin/bash
22

3-
set -eux
3+
set -euxo pipefail
44

55
. .github/jobs/ci_settings.sh
66

0 commit comments

Comments
 (0)