Skip to content

Commit

Permalink
Fixed configure
Browse files Browse the repository at this point in the history
  • Loading branch information
aropan committed Mar 9, 2024
1 parent a8f96f5 commit e33b996
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 21 deletions.
3 changes: 3 additions & 0 deletions .env.netdata.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
NETDATA_CLAIM_TOKEN=
NETDATA_CLAIM_URL=https://app.netdata.cloud
NETDATA_CLAIM_ROOMS=
13 changes: 13 additions & 0 deletions .env.sentry.template
Original file line number Diff line number Diff line change
@@ -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=
10 changes: 5 additions & 5 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
24 changes: 21 additions & 3 deletions configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import re
import string
import subprocess
import time


def random_string(length=40):
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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:
Expand All @@ -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')
Expand Down
18 changes: 9 additions & 9 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions src/clist/migrations/0129_contest_n_problems_and_more.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/pyclist/indexes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit e33b996

Please sign in to comment.