-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Sergey Natalenko
committed
Nov 23, 2023
1 parent
c61bf72
commit 3c0f96b
Showing
22 changed files
with
209 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
name: Make release | ||
|
||
env: | ||
PROJECT_NAME: inclusive_dance_bot | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
checking: | ||
name: Check repository | ||
uses: ./.github/workflows/check.yml | ||
|
||
build_and_push: | ||
name: Build and push AMD64 and ARM64 images | ||
needs: checking | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v2 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
- name: Login to Docker Hub | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
- name: Build and push | ||
uses: docker/build-push-action@v4 | ||
with: | ||
push: true | ||
platforms: linux/amd64,linux/arm64 | ||
tags: andytakker/${{ env.PROJECT_NAME }}:latest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#! /usr/bin/env bash | ||
alembic -c /app/inclusive_dance_bot/alembic.ini upgrade head | ||
python -m inclusive_dance_bot.db | ||
|
||
python /app/inclusive_dance_bot/init_data.py |
2 changes: 0 additions & 2 deletions
2
inclusive_dance_bot/bot/dialogs/admins/url/update/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 0 additions & 2 deletions
2
inclusive_dance_bot/bot/dialogs/users/registration/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import argparse | ||
import logging | ||
import os | ||
|
||
from alembic.config import CommandLine | ||
|
||
from inclusive_dance_bot.db.utils import make_alembic_config | ||
|
||
DEFAULT_PG_URL = "postgresql://user:secret@localhost/inclusive_dance_bot" | ||
|
||
|
||
def main() -> None: | ||
logging.basicConfig(level=logging.DEBUG) | ||
|
||
alembic = CommandLine() | ||
alembic.parser.formatter_class = argparse.ArgumentDefaultsHelpFormatter | ||
alembic.parser.add_argument( | ||
"--pg-url", | ||
default=os.getenv("POSTGRES_URL", DEFAULT_PG_URL), | ||
help="Database URL [env var: POSTGRES_URL]", | ||
) | ||
|
||
options = alembic.parser.parse_args() | ||
if "cmd" not in options: | ||
alembic.parser.error("too few arguments") | ||
exit(128) | ||
else: | ||
config = make_alembic_config(options) | ||
alembic.run_cmd(config, options) | ||
exit() | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
2 changes: 1 addition & 1 deletion
2
inclusive_dance_bot/alembic.ini → inclusive_dance_bot/db/alembic.ini
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import os | ||
from argparse import Namespace | ||
from pathlib import Path | ||
from typing import Any | ||
|
||
from alembic.config import Config | ||
from sqlalchemy.ext.asyncio import ( | ||
AsyncEngine, | ||
AsyncSession, | ||
async_sessionmaker, | ||
create_async_engine, | ||
) | ||
|
||
import inclusive_dance_bot | ||
|
||
PROJECT_PATH = Path(inclusive_dance_bot.__file__).parent.parent.resolve() | ||
|
||
|
||
def create_engine(connection_uri: str, **engine_kwargs: Any) -> AsyncEngine: | ||
return create_async_engine(url=connection_uri, **engine_kwargs, pool_pre_ping=True) | ||
|
||
|
||
def create_session_factory(engine: AsyncEngine) -> async_sessionmaker[AsyncSession]: | ||
return async_sessionmaker( | ||
bind=engine, | ||
class_=AsyncSession, | ||
expire_on_commit=False, | ||
) | ||
|
||
|
||
def make_alembic_config(cmd_opts: Namespace, base_path: Path = PROJECT_PATH) -> Config: | ||
if not os.path.isabs(cmd_opts.config): | ||
cmd_opts.config = str(base_path / "inclusive_dance_bot/db" / cmd_opts.config) | ||
|
||
config = Config( | ||
file_=cmd_opts.config, | ||
ini_section=cmd_opts.name, | ||
cmd_opts=cmd_opts, | ||
) | ||
|
||
alembic_location = config.get_main_option("script_location") | ||
if not alembic_location: | ||
raise ValueError | ||
print(alembic_location) | ||
if not os.path.isabs(alembic_location): | ||
config.set_main_option("script_location", str(base_path / alembic_location)) | ||
|
||
if cmd_opts.pg_url: | ||
config.set_main_option("sqlalchemy.url", cmd_opts.pg_url) | ||
|
||
config.attributes["configure_logger"] = False | ||
|
||
return config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.