Skip to content

Commit

Permalink
Merge pull request #12 from HeySlava/pre-test
Browse files Browse the repository at this point in the history
Echo example config before tests
  • Loading branch information
HeySlava authored Oct 7, 2023
2 parents 6e6c6f4 + 180c6dd commit 13f1f7f
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 14 deletions.
9 changes: 9 additions & 0 deletions .github/actions/pre-test/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: Add config example for tests

runs:
using: composite
steps:
- name: Echo example config
shell: bash
run: |
cp example.config.ini config.ini
2 changes: 1 addition & 1 deletion .github/workflows/testing.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ on:

jobs:
main:
uses: heyslava/workflows/.github/workflows/tox.yml@v0.2.0
uses: heyslava/workflows/.github/workflows/tox.yml@v0.3.0
with:
env: '["py39", "py310", "py311"]'
23 changes: 11 additions & 12 deletions bot/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,20 @@
import pytz

_CONFIG_INI_PATH = Path(__file__).absolute().parent.parent / 'config.ini'
_default_token = '22:aa-F-6eNoKY65R-omFA'
_admin_id = 123

configreader = configparser.ConfigParser()
_error_msg = f'Setup {_CONFIG_INI_PATH} for work. See example.config.ini'
if not _CONFIG_INI_PATH.exists():
token = _default_token
admin = _admin_id
else:
configreader.read(_CONFIG_INI_PATH)
try:
admin = int(configreader['config']['admin'])
token = configreader['config']['token']
except (KeyError, ValueError):
print(f"You didn't setup your {_CONFIG_INI_PATH}. See example.config.ini")
raise SystemExit(1)
print(_error_msg)
raise SystemExit(1)

configreader.read(_CONFIG_INI_PATH)
try:
admin = int(configreader['config']['admin'])
token = configreader['config']['token']
except (KeyError, ValueError):
print(_error_msg)
raise SystemExit(1)


@dataclass
Expand Down
1 change: 0 additions & 1 deletion bot/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ def custom_eval(equation: str) -> Optional[int]:


async def on_startup(bot):

Path('./db').mkdir(parents=True, exist_ok=True)
alembic_config = make_alembic_config(
conn_str=config.conn_str,
Expand Down

0 comments on commit 13f1f7f

Please sign in to comment.