Skip to content

Commit

Permalink
Merge branch 'main' into footer_summary_scoreboard
Browse files Browse the repository at this point in the history
  • Loading branch information
vmcj authored Mar 24, 2024
2 parents 87e591b + 7e1430f commit 52f0f1b
Show file tree
Hide file tree
Showing 79 changed files with 1,511 additions and 546 deletions.
20 changes: 10 additions & 10 deletions etc/db-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -111,16 +111,9 @@
type: int
default_value: 50000
public: false
description: Maximum size of error/system output stored in the database (in bytes); use `-1` to disable any limits.
regex: /^[1-9]\d*$/
error_message: A positive number is required.
- name: output_display_limit
type: int
default_value: 2000
public: false
description: Maximum size of run/diff/error/system output shown in the jury interface (in bytes); use `-1` to disable any limits.
regex: /^[1-9]\d*$/
error_message: A positive number is required.
description: Maximum size of error/system output stored in the database (in bytes); use `-1` to disable any limits. See `Display` / `output_display_limit` for how to control the output *shown*.
regex: /^([1-9]\d*|-1)$/
error_message: A positive number or -1 is required.
- name: lazy_eval_results
type: int
default_value: 1
Expand Down Expand Up @@ -208,6 +201,13 @@
- category: Display
description: Options related to the DOMjudge user interface.
items:
- name: output_display_limit
type: int
default_value: 2000
public: false
description: Maximum size of run/diff/error/system output shown in the jury interface (in bytes); use `-1` to disable any limits.
regex: /^([1-9]\d*|-1)$/
error_message: A positive number or -1 is required.
- name: show_pending
type: bool
default_value: true
Expand Down
4 changes: 2 additions & 2 deletions gitlab/integration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,8 @@ 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 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

# shellcheck disable=SC2002,SC2196
Expand Down
2 changes: 2 additions & 0 deletions gitlab/unit-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ if [ $UNITSUCCESS -eq 0 ]; then
else
STATE=failure
fi
cp webapp/var/log/test.log "$GITLABARTIFACTS"/test.log

curl https://api.github.com/repos/domjudge/domjudge/statuses/$CI_COMMIT_SHA \
-X POST \
-H "Authorization: token $GH_BOT_TOKEN_OBSCURED" \
Expand Down
2 changes: 1 addition & 1 deletion judge/runpipe.cc
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,7 @@ struct state_t {
int time_millis = time % 1000;
char direction = from.index == 0 ? ']' : '[';
char eofbuf[128];
sprintf(eofbuf, "[%3d.%03ds/%ld]%c", time_sec, time_millis, 0LL, direction);
sprintf(eofbuf, "[%3d.%03ds/%ld]%c", time_sec, time_millis, 0L, direction);
write_all(output_file.output_file, eofbuf, strlen(eofbuf));

warning(0, "EOF from process #%ld", from.index);
Expand Down
2 changes: 1 addition & 1 deletion misc-tools/configure-domjudge.in
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ if os.path.exists('languages.json'):
dj_utils.upload_file(f'languages/{langid}/executable', 'executable', f'executables/{langid}.zip')
for langid in executables:
os.remove(f'executables/{langid}.zip')
if dj_utils.confirm(' - Upload configuration changes?', True):
if dj_utils.confirm(' - Upload language configuration changes?', True):
actual_config = _keyify_list(dj_utils.upload_file(f'languages', 'json', f'languages.json'))
diffs, new_keys, missing_keys = compare_configs(
actual_config=actual_config,
Expand Down
9 changes: 7 additions & 2 deletions misc-tools/dj_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import requests.utils
import subprocess
import sys
from urllib.parse import urlparse

_myself = os.path.basename(sys.argv[0])
_default_user_agent = requests.utils.default_user_agent()
Expand Down Expand Up @@ -76,12 +77,16 @@ def do_api_request(name: str, method: str = 'GET', jsonData: dict = {}):
else:
global ca_check
url = f'{domjudge_webapp_folder_or_api_url}/{name}'
parsed = urlparse(domjudge_webapp_folder_or_api_url)
auth = None
if parsed.username or parsed.password:
auth = (parsed.username, parsed.password)

try:
if method == 'GET':
response = requests.get(url, headers=headers, verify=ca_check)
response = requests.get(url, headers=headers, verify=ca_check, auth=auth)
elif method == 'PUT':
response = requests.put(url, headers=headers, verify=ca_check, json=jsonData)
response = requests.put(url, headers=headers, verify=ca_check, json=jsonData, auth=auth)
except requests.exceptions.SSLError as e:
ca_check = not confirm(
"Can not verify certificate, ignore certificate check?", False)
Expand Down
19 changes: 19 additions & 0 deletions misc-tools/import-contest.in
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,24 @@ def import_contest_banner(cid: str):
else:
print('Skipping contest banner import.')

def import_contest_text(cid: str):
"""Import the contest text"""

files = ['contest.pdf', 'contest-web.pdf', 'contest.html', 'contest.txt']

text_file = None
for file in files:
if os.path.isfile(file):
text_file = file
break

if text_file:
if dj_utils.confirm(f'Import {text_file} for contest?', False):
dj_utils.upload_file(f'contests/{cid}/text', 'text', text_file)
print('Contest text imported.')
else:
print('Skipping contest text import.')

if len(sys.argv) == 1:
dj_utils.domjudge_webapp_folder_or_api_url = webappdir
elif len(sys.argv) == 2:
Expand Down Expand Up @@ -154,6 +172,7 @@ else:
if cid is not None:
print(f' -> cid={cid}')
import_contest_banner(cid)
import_contest_text(cid)

# Problem import is also special: we need to upload each individual problem and detect what they are
if os.path.exists('problems.yaml') or os.path.exists('problems.json') or os.path.exists('problemset.yaml'):
Expand Down
70 changes: 0 additions & 70 deletions phpstan-baseline.neon

This file was deleted.

1 change: 0 additions & 1 deletion phpstan.dist.neon
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,4 @@ parameters:
message: "#Method .* return type has no value type specified in iterable type array#"
path: webapp/src/DataFixtures/Test
includes:
- phpstan-baseline.neon
- lib/vendor/phpstan/phpstan-doctrine/extension.neon
40 changes: 40 additions & 0 deletions webapp/migrations/Version20240322100827.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

declare(strict_types=1);

namespace DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20240322100827 extends AbstractMigration
{
public function getDescription(): string
{
return 'Add contest text table and type to contests.';
}

public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE TABLE contest_text_content (cid INT UNSIGNED NOT NULL COMMENT \'Contest ID\', content LONGBLOB NOT NULL COMMENT \'Text content(DC2Type:blobtext)\', PRIMARY KEY(cid)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB COMMENT = \'Stores contents of contest texts\' ');
$this->addSql('ALTER TABLE contest_text_content ADD CONSTRAINT FK_6680FE6A4B30D9C4 FOREIGN KEY (cid) REFERENCES contest (cid) ON DELETE CASCADE');
$this->addSql('ALTER TABLE contest ADD contest_text_type VARCHAR(4) DEFAULT NULL COMMENT \'File type of contest text\'');
}

public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE contest_text_content DROP FOREIGN KEY FK_6680FE6A4B30D9C4');
$this->addSql('DROP TABLE contest_text_content');
$this->addSql('ALTER TABLE contest DROP contest_text_type');
}

public function isTransactional(): bool
{
return false;
}
}
3 changes: 3 additions & 0 deletions webapp/public/style_domjudge.css
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,9 @@ blockquote {
font-size: smaller;
}

.right {
text-align: right;
}

/* Disable the sticky footer on mobile */
@media only screen and (min-width: 600px) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,38 +27,38 @@ protected function execute(InputInterface $input, OutputInterface $output): int
foreach ($this->config->getConfigSpecification() as $specification) {
$message = sprintf(
'Configuration %s (in category %s) is of type %s but has wrong type for default_value (%s)',
$specification['name'],
$specification['category'],
$specification['type'],
json_encode($specification['default_value'], JSON_THROW_ON_ERROR)
$specification->name,
$specification->category,
$specification->type,
json_encode($specification->defaultValue, JSON_THROW_ON_ERROR)
);
switch ($specification['type']) {
switch ($specification->type) {
case 'bool':
if (!is_bool($specification['default_value'])) {
if (!is_bool($specification->defaultValue)) {
$messages[] = $message;
}
break;
case 'int':
if (!is_int($specification['default_value'])) {
if (!is_int($specification->defaultValue)) {
$messages[] = $message;
}
break;
case 'string':
if (!is_string($specification['default_value'])) {
if (!is_string($specification->defaultValue)) {
$messages[] = $message;
}
break;
case 'array_val':
if (!(empty($specification['default_value']) || (
is_array($specification['default_value']) &&
is_int(key($specification['default_value']))))) {
if (!(empty($specification->defaultValue) || (
is_array($specification->defaultValue) &&
is_int(key($specification->defaultValue))))) {
$messages[] = $message;
}
break;
case 'array_keyval':
if (!(empty($specification['default_value']) || (
is_array($specification['default_value']) &&
is_string(key($specification['default_value']))))) {
if (!(empty($specification->defaultValue) || (
is_array($specification->defaultValue) &&
is_string(key($specification->defaultValue))))) {
$messages[] = $message;
}
break;
Expand Down
2 changes: 1 addition & 1 deletion webapp/src/Command/ImportEventFeedCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$dataSource = (int)$this->config->get('data_source');
$importDataSource = DOMJudgeService::DATA_SOURCE_CONFIGURATION_AND_LIVE_EXTERNAL;
if ($dataSource !== $importDataSource) {
$dataSourceOptions = $this->config->getConfigSpecification()['data_source']['options'];
$dataSourceOptions = $this->config->getConfigSpecification()['data_source']->options;
$this->style->error(sprintf(
"data_source configuration setting is set to '%s' but should be '%s'.",
$dataSourceOptions[$dataSource],
Expand Down
Loading

0 comments on commit 52f0f1b

Please sign in to comment.