diff --git a/.env.netdata.template b/.env.netdata.template new file mode 100644 index 00000000..7ca4ee87 --- /dev/null +++ b/.env.netdata.template @@ -0,0 +1,3 @@ +NETDATA_CLAIM_TOKEN= +NETDATA_CLAIM_URL=https://app.netdata.cloud +NETDATA_CLAIM_ROOMS= diff --git a/.env.sentry.template b/.env.sentry.template new file mode 100644 index 00000000..720db38a --- /dev/null +++ b/.env.sentry.template @@ -0,0 +1,13 @@ +SENTRY_DSN= +SENTRY_AUTH_TOKEN= + +SENTRY_CRON_MONITOR_LIST_UPDATE= +SENTRY_CRON_MONITOR_CALENDAR_UPDATE= +SENTRY_CRON_MONITOR_PARSING_STATISTICS= +SENTRY_CRON_MONITOR_SENDING_NOTIFICATIONS= +SENTRY_CRON_MONITOR_CREATING_NOTIFICATIONS= +SENTRY_CRON_MONITOR_PARSING_ACCOUNTS= +SENTRY_CRON_MONITOR_CHECKING_LOGS= +SENTRY_CRON_MONITOR_REINDEX= +SENTRY_CRON_MONITOR_SET_ACCOUNT_RANK= +SENTRY_CRON_MONITOR_UPDATE_AUTO_RATING= diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 55987b23..a0285782 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -33,21 +33,21 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@v2 + uses: github/codeql-action/init@v3 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. # By default, queries listed here will override any specified in a config file. # Prefix the list here with "+" to use these queries and those in the config file. - + # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs # queries: security-extended,security-and-quality - + # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). # If this step fails, then you should remove it and run the build manually (see below) # - name: Autobuild @@ -64,4 +64,4 @@ jobs: # ./location_of_script_within_repo/buildscript.sh - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 + uses: github/codeql-action/analyze@v3 diff --git a/configure.py b/configure.py index e7ac7631..8c94ae5a 100755 --- a/configure.py +++ b/configure.py @@ -6,6 +6,7 @@ import re import string import subprocess +import time def random_string(length=40): @@ -34,7 +35,7 @@ def enter_value(variable, old_value): return value -def fill_template(target_file, accept_default=False): +def fill_template(target_file, accept_default=False, allow_empty=False): template_file = target_file + '.template' if os.path.exists(target_file): logger.info(f'File {target_file} already exists') @@ -64,7 +65,7 @@ def fill_template(target_file, accept_default=False): n_sep_skip += 1 generated += f'{line}\n' continue - if accept_default and old_value: + if accept_default and (allow_empty or old_value): value = old_value logger.info(f'Accept default value "{old_value}" for "{variable}"') else: @@ -80,16 +81,33 @@ def fill_template(target_file, accept_default=False): def run_command(cmd): cmd = cmd.replace('\n', ' ') - logger.info(f'Run command = {cmd}') + not_sensitive_data = re.sub('"[^"]*"', '***', cmd) + logger.info(f'Run command = {not_sensitive_data}') subprocess.run(cmd, shell=True, check=True) +def create_volumes(): + with open('docker-compose.yml', 'r') as fo: + content = fo.read() + folders = re.findall(r'^\s*device:\s*(.*)', content, re.MULTILINE) + for folder in folders: + if not os.path.exists(folder): + logger.info(f'Creating volume {folder}') + os.makedirs(folder) + + def main(): fill_template('.env.db') + fill_template('.env.netdata', accept_default=True, allow_empty=True) + fill_template('.env.sentry', accept_default=True, allow_empty=True) fill_template('src/.env.dev', accept_default=True) fill_template('src/.env.prod', accept_default=True) fill_template('src/pyclist/conf.py') + create_volumes() run_command('docker compose build dev') + run_command('docker compose up --build --detach db') + logger.info('Waiting 30 seconds for database to start') + time.sleep(30) run_command('docker compose run dev ./manage.py migrate contenttypes') run_command('docker compose run dev ./manage.py migrate auth') run_command('docker compose run dev ./manage.py migrate') diff --git a/docker-compose.yml b/docker-compose.yml index 0a13397d..56a04888 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -150,52 +150,52 @@ volumes: driver_opts: type: none o: bind - device: ${PWD}/volumes/postgres_data + device: ./volumes/postgres_data pgadmin_data: driver: local driver_opts: type: none o: bind - device: ${PWD}/volumes/pgadmin + device: ./volumes/pgadmin static_files: driver: local driver_opts: type: none o: bind - device: ${PWD}/volumes/static_files + device: ./volumes/static_files media_files: driver: local driver_opts: type: none o: bind - device: ${PWD}/volumes/media_files + device: ./volumes/media_files certbot_www: driver: local driver_opts: type: none o: bind - device: ${PWD}/volumes/certbot_www + device: ./volumes/certbot_www certbot_conf: driver: local driver_opts: type: none o: bind - device: ${PWD}/volumes/certbot_conf + device: ./volumes/certbot_conf netdata_config: driver: local driver_opts: type: none o: bind - device: ${PWD}/volumes/netdata/config + device: ./volumes/netdata/config netdata_lib: driver: local driver_opts: type: none o: bind - device: ${PWD}/volumes/netdata/lib + device: ./volumes/netdata/lib netdata_cache: driver: local driver_opts: type: none o: bind - device: ${PWD}/volumes/netdata/cache + device: ./volumes/netdata/cache diff --git a/requirements.txt b/requirements.txt index 7105a8df..df74abac 100644 --- a/requirements.txt +++ b/requirements.txt @@ -83,7 +83,7 @@ tailslide==0.1.1 feedgen==0.9.0 pycountry==22.3.5 multiset==3.0.1 -twisted[tls,http2]==22.10.0 +twisted[tls,http2]==24.3.0 uWSGI==2.0.22 supervisor==4.2.5 daphne==4.0.0 diff --git a/src/clist/migrations/0129_contest_n_problems_and_more.py b/src/clist/migrations/0129_contest_n_problems_and_more.py index e4c29a4b..77e15d70 100644 --- a/src/clist/migrations/0129_contest_n_problems_and_more.py +++ b/src/clist/migrations/0129_contest_n_problems_and_more.py @@ -2,10 +2,9 @@ from django.db import migrations, models -from clist.models import Contest - def set_n_problems(apps, schema_editor): + Contest = apps.get_model('clist', 'Contest') for contest in Contest.objects.all(): if hasattr(contest, 'stage'): continue diff --git a/src/pyclist/indexes.py b/src/pyclist/indexes.py index 9c6fd337..d40d93e0 100644 --- a/src/pyclist/indexes.py +++ b/src/pyclist/indexes.py @@ -61,7 +61,7 @@ def __init__(self, expression): condition = self._get_condition_sql(model, schema_editor) statement = schema_editor._create_index_sql( model, - [Descriptor(e) for e in self.expressions], + fields=[Descriptor(e) for e in self.expressions], name=self.name, using=using, db_tablespace=self.db_tablespace,