Skip to content

Commit 611e9b7

Browse files
committed
Use hardcopy of the GHA jobs on main
Based on: 7d7ed2e
1 parent e153031 commit 611e9b7

33 files changed

+3563
-157
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

+28-14
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

+19-8
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

+9
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

+110-65
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,31 @@
11
#!/bin/sh
22

3-
# Functions to annotate the Github actions logs
4-
alias trace_on='set -x'
5-
alias trace_off='{ set +x; } 2>/dev/null'
6-
7-
section_start_internal () {
8-
echo "::group::$1"
9-
trace_on
10-
}
11-
12-
section_end_internal () {
13-
echo "::endgroup::"
14-
trace_on
15-
}
16-
17-
alias section_start='trace_off ; section_start_internal '
18-
alias section_end='trace_off ; section_end_internal '
3+
. .github/jobs/ci_settings.sh
194

205
export version="$1"
6+
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}"
2110

22-
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
2313

24-
section_start "Update packages"
25-
sudo apt update
26-
section_end
14+
MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD:-root}
2715

28-
section_start "Install needed packages"
29-
sudo apt install -y acl zip unzip nginx php php-fpm php-gd \
30-
php-cli php-intl php-mbstring php-mysql php-curl php-json \
31-
php-xml php-zip ntp make sudo debootstrap \
32-
libcgroup-dev lsof php-cli php-curl php-json php-xml \
33-
php-zip procps gcc g++ default-jre-headless \
34-
default-jdk-headless ghc fp-compiler autoconf automake bats \
35-
python3-sphinx python3-sphinx-rtd-theme rst2pdf fontconfig \
36-
python3-yaml latexmk curl
37-
section_end
16+
set -eux
3817

39-
PHPVERSION=$(php -r 'echo PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION."\n";')
40-
export PHPVERSION
18+
if [ -z "$phpversion" ]; then
19+
phpversion=$(php -r 'echo PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION."\n";')
20+
fi
4121

42-
section_start "Install composer"
43-
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
44-
HASH="$(wget -q -O - https://composer.github.io/installer.sig)"
45-
php -r "if (hash_file('SHA384', 'composer-setup.php') === '$HASH') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
46-
sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer
47-
section_end
22+
show_phpinfo "$phpversion"
4823

4924
section_start "Run composer"
5025
export APP_ENV="dev"
51-
composer install --no-scripts
26+
cd webapp
27+
composer install --no-scripts |tee "$ARTIFACTS"/composer_out.txt
28+
cd ..
5229
section_end
5330

5431
section_start "Set simple admin password"
@@ -58,59 +35,127 @@ section_end
5835

5936
section_start "Install domserver"
6037
make configure
61-
./configure --with-baseurl='https://localhost/domjudge/' --enable-doc-build=no --prefix="/opt/domjudge"
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
59+
section_end
6260

63-
make domserver
64-
sudo make install-domserver
61+
section_start "SQL settings"
62+
cat > ~/.my.cnf <<EOF
63+
[client]
64+
host=sqlserver
65+
user=root
66+
password=${MYSQL_ROOT_PASSWORD}
67+
EOF
68+
cat ~/.my.cnf
69+
70+
mysql_root "CREATE DATABASE IF NOT EXISTS \`$DATABASE_NAME\` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;"
71+
mysql_root "CREATE USER IF NOT EXISTS \`domjudge\`@'%' IDENTIFIED BY 'domjudge';"
72+
mysql_root "GRANT SELECT, INSERT, UPDATE, DELETE ON \`$DATABASE_NAME\`.* TO 'domjudge'@'%';"
73+
mysql_root "FLUSH PRIVILEGES;"
74+
75+
# Show some MySQL debugging
76+
mysql_root "show databases"
77+
mysql_root "SELECT CURRENT_USER();"
78+
mysql_root "SELECT USER();"
79+
mysql_root "SELECT user,host FROM mysql.user"
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
84+
mysql_user "SELECT CURRENT_USER();"
85+
mysql_user "SELECT USER();"
6586
section_end
6687

67-
section_start "Explicit start mysql + install DB"
68-
sudo /etc/init.d/mysql start
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
97+
98+
section_start "Show PHP config"
99+
php -v | tee -a "$ARTIFACTS"/php.txt
100+
php -m | tee -a "$ARTIFACTS"/php.txt
101+
section_end
69102

70-
/opt/domjudge/domserver/bin/dj_setup_database -uroot -proot bare-install
103+
section_start "Show general config"
104+
printenv | tee -a "$ARTIFACTS"/environment.txt
105+
cp /etc/os-release "$ARTIFACTS"/os-release.txt
106+
cp /proc/cmdline "$ARTIFACTS"/cmdline.txt
71107
section_end
72108

73109
section_start "Setup webserver"
74-
sudo 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
75111

76-
sudo rm -f /etc/nginx/sites-enabled/*
77-
sudo cp /opt/domjudge/domserver/etc/nginx-conf /etc/nginx/sites-enabled/domjudge
112+
rm -f /etc/nginx/sites-enabled/*
113+
cp /opt/domjudge/domserver/etc/nginx-conf /etc/nginx/sites-enabled/domjudge
78114

79115
openssl req -nodes -new -x509 -keyout /tmp/server.key -out /tmp/server.crt -subj "/C=NL/ST=Noord-Holland/L=Amsterdam/O=TestingForPR/CN=localhost"
80-
sudo cp /tmp/server.crt /usr/local/share/ca-certificates/
81-
sudo update-ca-certificates
116+
cp /tmp/server.crt /usr/local/share/ca-certificates/
117+
update-ca-certificates
82118
# shellcheck disable=SC2002
83-
cat "$(pwd)/.github/jobs/data/nginx_extra" | sudo tee -a /etc/nginx/sites-enabled/domjudge
84-
sudo nginx -t
119+
cat "$(pwd)/.github/jobs/data/nginx_extra" | tee -a /etc/nginx/sites-enabled/domjudge
120+
nginx -t
85121
section_end
86122

87123
section_start "Show webserver is up"
88-
for service in nginx php${PHPVERSION}-fpm; do
89-
sudo systemctl restart $service
90-
sudo systemctl status $service
124+
for service in nginx php${phpversion}-fpm; do
125+
service "$service" restart
126+
service "$service" status
91127
done
92128
section_end
93129

94-
section_start "Install the example data"
95-
/opt/domjudge/domserver/bin/dj_setup_database -uroot -proot install-examples
96-
section_end
130+
if [ "${db}" = "install" ]; then
131+
section_start "Install the example data"
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"
137+
section_end
138+
fi
97139

98140
section_start "Setup user"
99141
# We're using the admin user in all possible roles
100-
echo "DELETE FROM userrole WHERE userid=1;" | mysql -uroot -proot domjudge
142+
mysql_root "DELETE FROM userrole WHERE userid=1;" $DATABASE_NAME
101143
if [ "$version" = "team" ]; then
102144
# Add team to admin user
103-
echo "INSERT INTO userrole (userid, roleid) VALUES (1, 3);" | mysql -uroot -proot domjudge
104-
echo "UPDATE user SET teamid = 1 WHERE userid = 1;" | mysql -uroot -proot 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
105147
elif [ "$version" = "jury" ]; then
106148
# Add jury to admin user
107-
echo "INSERT INTO userrole (userid, roleid) VALUES (1, 2);" | mysql -uroot -proot domjudge
149+
mysql_root "INSERT INTO userrole (userid, roleid) VALUES (1, 2);" $DATABASE_NAME
108150
elif [ "$version" = "balloon" ]; then
109151
# Add balloon to admin user
110-
echo "INSERT INTO userrole (userid, roleid) VALUES (1, 4);" | mysql -uroot -proot domjudge
152+
mysql_root "INSERT INTO userrole (userid, roleid) VALUES (1, 4);" $DATABASE_NAME
111153
elif [ "$version" = "admin" ]; then
112154
# Add admin to admin user
113-
echo "INSERT INTO userrole (userid, roleid) VALUES (1, 1);" | mysql -uroot -proot 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
114160
fi
115161
section_end
116-

.github/jobs/chroot.bats

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#!/usr/bin/env bats
2+
3+
load 'assert'
4+
5+
CHROOT="/chroot/domjudge"
6+
if [ -n "${GITHUB_REPOSITORY+x}" ]; then
7+
CHROOT="/__w/domjudge/domjudge${CHROOT}"
8+
fi
9+
# Cleanup old dir
10+
rm -rf $CHROOT
11+
12+
COMMANDARGS=""
13+
if [ -n "${ARCH+x}" ]; then
14+
COMMANDARGS="-a $ARCH $COMMANDARGS"
15+
fi
16+
17+
@test "help output" {
18+
run ./dj_make_chroot -h
19+
assert_success
20+
assert_partial "Usage:"
21+
assert_partial "Creates a chroot environment with Java JRE support using the"
22+
assert_partial "Debian or Ubuntu GNU/Linux distribution."
23+
assert_partial "Options"
24+
assert_partial "Available architectures:"
25+
assert_partial "Environment Overrides:"
26+
assert_partial "This script must be run as root"
27+
}
28+
29+
@test "Test chroot fails if unsupported architecture given" {
30+
if [ -n "${ARCH+x}" ]; then
31+
skip "Already an Arch set in the commands."
32+
fi
33+
for unsupported_arch in 'dom04' 'arm' '64' 'namd64' 'amd64v2'; do
34+
run ./dj_make_chroot $COMMANDARGS -a $unsupported_arch
35+
assert_failure
36+
assert_partial "Error: Architecture $unsupported_arch not supported for"
37+
done
38+
}
39+
40+
# Creation of the chroot is slow so we run all tests inside 1 large test to speedup.
41+
@test "Test chroot works with args: $COMMANDARGS" {
42+
run ./dj_make_chroot $COMMANDARGS
43+
assert_partial "Done building chroot in $CHROOT"
44+
assert_success
45+
if [ -n "${ARCH+x}" ]; then
46+
run ./dj_run_chroot "dpkg --print-architecture"
47+
assert_partial "$ARCH"
48+
assert_success
49+
else
50+
HOSTARCH=$(dpkg --print-architecture)
51+
run ./dj_run_chroot "dpkg --print-architecture"
52+
assert_partial "$HOSTARCH"
53+
assert_success
54+
fi
55+
}

0 commit comments

Comments
 (0)