Skip to content

Commit 57d21ca

Browse files
committed
Merge branch 'master' into notifications-python
2 parents 57d3ed7 + eeb5e62 commit 57d21ca

File tree

695 files changed

+23421
-26867
lines changed

Some content is hidden

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

695 files changed

+23421
-26867
lines changed

.git-blame-ignore-revs

Lines changed: 0 additions & 2 deletions
This file was deleted.

.github/workflows/ruff.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Ruff
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
workflow_dispatch:
9+
10+
jobs:
11+
ruff:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
- uses: astral-sh/ruff-action@v3
16+
with:
17+
src: "./oioioi"
18+
version: 0.11.12

.pep8rc

Lines changed: 0 additions & 18 deletions
This file was deleted.

.pre-commit-config.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
repos:
2+
- repo: https://github.com/astral-sh/ruff-pre-commit
3+
rev: v0.11.12
4+
hooks:
5+
- id: ruff-check
6+
files: ^oioioi/
7+
args: [ --fix, --exit-non-zero-on-fix ]
8+
- id: ruff-format

.pylintrc

Lines changed: 0 additions & 138 deletions
This file was deleted.

Dockerfile

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,13 @@ RUN rm /bin/sh && ln -s /bin/bash /bin/sh && \
4747
RUN sed -i -e "s/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/" /etc/locale.gen && \
4848
locale-gen
4949

50-
COPY ./entrypoint_checks.sh /entrypoint_checks.sh
51-
RUN chmod +x /entrypoint_checks.sh && chown oioioi /entrypoint_checks.sh
52-
5350
# Installing python dependencies
5451
USER oioioi
5552

5653
ENV PATH $PATH:/home/oioioi/.local/bin/
5754

5855
ENV BERKELEYDB_DIR /usr
59-
RUN pip3 install --user psycopg2-binary==2.9.5 twisted uwsgi
56+
RUN pip3 install --user psycopg2-binary twisted uwsgi
6057
RUN pip3 install --user bsddb3==6.2.7
6158

6259
WORKDIR /sio2/oioioi
@@ -65,6 +62,7 @@ COPY --chown=oioioi:oioioi setup.py requirements.txt ./
6562
RUN pip3 install -r requirements.txt --user filetracker[server]
6663
COPY --chown=oioioi:oioioi requirements_static.txt ./
6764
RUN pip3 install -r requirements_static.txt --user
65+
RUN pip3 install --user -U "gevent==25.5.1" # override version of gevent
6866

6967
# Installing node dependencies
7068
ENV PATH $PATH:/sio2/oioioi/node_modules/.bin

README.rst

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -85,27 +85,6 @@ you are connected to after using docker exec -it “web” /bin/bash. The defaul
8585
docker compose -f docker-compose-dev.yml exec "web" ../oioioi/test.sh
8686
docker compose -f docker-compose-dev.yml exec "web" ../oioioi/test.sh oioioi/{name_of_the_app}/
8787

88-
Running static code analysis tools locally (requires Docker)
89-
~~~~~~~~~~~~~~~~~~~~~~~
90-
91-
The static code analysis tools currently in use for python code are black, isort, pep8 and pylint.
92-
All of them can be run locally using the `run_static.sh` shell script.
93-
In order for the script to work the `web` container from docker-compose-dev.yml needs to be running.
94-
The docker image for the project needs to be rebuild if you are migrating from and older Dockerfile version (rebuild the image if you are getting error messages that isort or black are not installed).
95-
Commands for building the image and starting up the containers are listed in the paragraphs above.
96-
97-
When running all tools at once or when running pep8 and pylint independently only the recently modified files (files modified in the most recent commit or staged changes) will be processed.
98-
99-
To run all tools at once::
100-
101-
./run_static.sh
102-
103-
To run one of the tools::
104-
105-
./run_static.sh black
106-
./run_static.sh isort
107-
./run_static.sh pylint
108-
./run_static.sh pep8
10988

11089
Script toolbox for Docker (development)
11190
~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -121,6 +100,37 @@ Developer environment can be easily set up by running::
121100

122101
For system requirements check `easy_toolbox.py`.
123102

103+
Running static code analysis tools locally
104+
~~~~~~~~~~~~~~~~~~~~~~~
105+
.. _ruff: https://github.com/astral-sh/ruff
106+
107+
The static code analysis tool (linter and formatter) currently in use for Python code is `ruff`_.
108+
109+
It can can be run locally using the::
110+
111+
./easy_toolbox.py ruff
112+
113+
In order for the script to work the `web` container from `docker-compose-dev.yml` needs to be running.
114+
115+
To allow ruff to fix the errors, add the `--fix` flag::
116+
117+
./easy_toolbox.py ruff --fix
118+
119+
To avoid having to run this command every time before committing, you can install `pre-commit` along with ruff::
120+
121+
pip install -r requirements_static.txt
122+
123+
Then simply run the following command::
124+
125+
pre-commit install
126+
127+
From now on, ruff will run automatically before each commit - just keep in mind
128+
that ruff will only run on the files you have modified.
129+
130+
If you want to check all files, not just the modified ones, you can run::
131+
132+
pre-commit run --all-files
133+
124134
Manual installation (deprecated)
125135
~~~~~~~~~~~~~~~~~~~
126136

conftest.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,8 @@
88

99

1010
def pytest_addoption(parser):
11-
parser.addoption(
12-
'--runslow', action='store_true', default=False, help="run slow tests"
13-
)
14-
parser.addoption(
15-
'--strict-template-vars', action='store_true', help="Raise errors for undefined template variables")
11+
parser.addoption("--runslow", action="store_true", default=False, help="run slow tests")
12+
parser.addoption("--strict-template-vars", action="store_true", help="Raise errors for undefined template variables")
1613

1714

1815
# called for running each test
@@ -24,12 +21,12 @@ def pytest_runtest_setup(item):
2421
def pytest_configure(config):
2522
if config.getoption("--strict-template-vars"):
2623
# this will raise an error if a template variable is not defined
27-
settings.TEMPLATES[0]['OPTIONS']['string_if_invalid'] = '{% templatetag openvariable %} INVALID_VAR: %s {% templatetag closevariable %}'
28-
24+
settings.TEMPLATES[0]["OPTIONS"]["string_if_invalid"] = "{% templatetag openvariable %} INVALID_VAR: %s {% templatetag closevariable %}"
25+
2926

3027
def pytest_collection_modifyitems(config, items):
3128
# --runslow flag: do not skip slow tests
32-
if config.getoption('--runslow', False):
29+
if config.getoption("--runslow", False):
3330
return
3431
skip_slow = pytest.mark.skip(reason="need --runslow option to run")
3532
for item in items:
@@ -47,3 +44,12 @@ def pytest_html_results_table_header(cells):
4744
@pytest.hookimpl(optionalhook=True)
4845
def pytest_html_results_table_row(report, cells):
4946
cells.pop()
47+
48+
49+
@pytest.fixture()
50+
def require_migrations_flag(request):
51+
config = request.config
52+
nomigrations_enabled_flag = config.getoption("nomigrations")
53+
54+
if nomigrations_enabled_flag:
55+
pytest.skip("Test requires the --migrations flag to run.")

0 commit comments

Comments
 (0)