Skip to content

Commit

Permalink
Merge cms-dev/master
Browse files Browse the repository at this point in the history
  • Loading branch information
t-lenz committed Feb 17, 2024
2 parents b102fd1 + b77c87b commit c8ffa00
Show file tree
Hide file tree
Showing 42 changed files with 2,298 additions and 1,127 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
Dockerfile
docker-compose*.yml
.vagrant/
codecov/
6 changes: 5 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,13 @@ jobs:
run: |
mount | grep cgroup
- name: Build docker image
run: |
docker compose -p cms -f docker-compose.test.yml build testcms
- name: Run tests
run: |
docker-compose -f docker-compose.test.yml run cms_test
docker compose -p cms -f docker-compose.test.yml run --rm testcms
- uses: codecov/codecov-action@v3
with:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ lib/
!cmscontrib/gerpythonformat/lib
log/
.vagrant/
codecov/
7 changes: 7 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"recommendations": [
"editorconfig.editorconfig",
"ms-python.python",
"ms-python.vscode-pylance"
]
}
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"python.analysis.typeCheckingMode": "basic"
}
8 changes: 6 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,21 @@ RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
# Set cmsuser as default user
USER cmsuser

COPY --chown=cmsuser:cmsuser . /home/cmsuser/cms
RUN mkdir /home/cmsuser/cms
COPY --chown=cmsuser:cmsuser requirements.txt dev-requirements.txt /home/cmsuser/cms/

WORKDIR /home/cmsuser/cms

RUN sudo pip3 install -r requirements.txt
RUN sudo pip3 install -r dev-requirements.txt

COPY --chown=cmsuser:cmsuser . /home/cmsuser/cms

RUN sudo python3 setup.py install

RUN sudo python3 prerequisites.py --yes --cmsuser=cmsuser install

RUN sudo sed 's/cmsuser:your_password_here@localhost/postgres@db/' ./config/cms.conf.sample \
RUN sudo sed 's|/cmsuser:your_password_here@localhost:5432/cmsdb"|/postgres@testdb:5432/cmsdbfortesting"|' ./config/cms.conf.sample \
| sudo tee /usr/local/etc/cms-testdb.conf

ENV LANG C.UTF-8
Expand Down
2 changes: 1 addition & 1 deletion cms/db/contest.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class Contest(Base):
languages = Column(
ARRAY(String),
nullable=False,
default=["C11 / gcc", "C++11 / g++", "Pascal / fpc"])
default=["C11 / gcc", "C++17 / g++", "Pascal / fpc"])

# Whether contestants allowed to download their submissions.
submissions_download_allowed = Column(
Expand Down
9 changes: 7 additions & 2 deletions cms/db/filecacher.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
# Copyright © 2013 Luca Wehrstedt <[email protected]>
# Copyright © 2016 Luca Versari <[email protected]>
# Copyright © 2021 Fabian Gundlach <[email protected]>
# Copyright © 2023 Manuel Gundlach <[email protected]>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
Expand Down Expand Up @@ -362,8 +363,12 @@ def commit_file(self, fobj, digest, desc=""):
# If someone beat us to adding the same object to the database, we
# should at least drop the large object.
LargeObject.unlink(fobj.loid)
logger.warning("File %s (%s) caused an IntegrityError, ignoring.",
digest, desc)
logger.info("File %s (%s) caused an IntegrityError, ignoring. "
"Note: If the file is a compiled submission "
"executable, this can occur when a contestant has "
"submitted identical source code multiple times, "
"and is harmless in that case.",
digest, desc)
return False
return True

Expand Down
4 changes: 2 additions & 2 deletions cms/db/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ class FilenameSchema(TypeDecorator):
@classmethod
def get_create_command(cls):
return DDL("CREATE DOMAIN %(domain)s VARCHAR "
"CHECK (VALUE ~ '^[A-Za-z0-9_.-]+(\.%%l)?$') "
"CHECK (VALUE ~ '^[A-Za-z0-9_.-]+(.%%l)?$') "
"CHECK (VALUE != '.') "
"CHECK (VALUE != '..')",
context={"domain": cls.domain_name})
Expand Down Expand Up @@ -187,7 +187,7 @@ def get_create_command(cls):
return DDL("CREATE DOMAIN %(domain)s VARCHAR[] "
"CHECK (array_to_string(VALUE, '') ~ '^[A-Za-z0-9_.%%-]*$') "
"CHECK (array_to_string(VALUE, ',') "
" ~ '^([A-Za-z0-9_.-]+(\.%%l)?(,|$))*$') "
" ~ '^([A-Za-z0-9_.-]+(.%%l)?(,|$))*$') "
"CHECK ('.' != ALL(VALUE)) "
"CHECK ('..' != ALL(VALUE))",
context={"domain": cls.domain_name})
Expand Down
1 change: 1 addition & 0 deletions cms/io/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ class Service:

def __init__(self, shard=0):
signal.signal(signal.SIGINT, lambda unused_x, unused_y: self.exit())
signal.signal(signal.SIGTERM, lambda unused_x, unused_y: self.exit())

self.name = self.__class__.__name__
self.shard = shard
Expand Down
Loading

0 comments on commit c8ffa00

Please sign in to comment.