Skip to content

Commit

Permalink
feat: Add hidden command that shows project version (#131)
Browse files Browse the repository at this point in the history
  • Loading branch information
siderai authored Jul 17, 2023
1 parent 70d9a76 commit b6110d8
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
17 changes: 12 additions & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ jobs:

- name: Install copier
run: |
pip install copier
pip install copier==7.1.0
pip install copier-templates-extensions
# hardcode pydantic version to avoid dependency conflict with copier
pip install pydantic==1.10.2
- name: Test image
env:
Expand All @@ -37,7 +39,7 @@ jobs:
runs-on: ubuntu-20.04
strategy:
matrix:
python-version: [ "3.8", "3.9", "3.10" ]
python-version: [ "3.8", "3.9", "3.10"]

services:
postgres:
Expand Down Expand Up @@ -68,10 +70,13 @@ jobs:

- name: Install copier
run: |
pip install copier
pip install copier==7.1.0
pip install copier-templates-extensions
# hardcode pydantic version to avoid dependency conflict with copier
pip install pydantic==1.10.2
python -m copier --defaults . bot-example
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
Expand Down Expand Up @@ -112,16 +117,18 @@ jobs:
runs-on: ubuntu-20.04
strategy:
matrix:
python-version: [ "3.8", "3.9", "3.10" ]
python-version: ["3.8", "3.9", "3.10"]

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Install copier
run: |
pip install copier
pip install copier==7.1.0
pip install copier-templates-extensions
# hardcode pydantic version to avoid dependency conflict with copier
pip install pydantic==1.10.2
python -m copier --defaults . bot-example
- name: Set up Python ${{ matrix.python-version }}
Expand Down
9 changes: 9 additions & 0 deletions app/bot/commands/common.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Handlers for default bot commands and system events."""

from os import environ
from subprocess import PIPE, STDOUT, run

from pybotx import (
Bot,
Expand Down Expand Up @@ -60,3 +61,11 @@ async def git_commit_sha(message: IncomingMessage, bot: Bot) -> None:
"""Show git commit SHA."""

await bot.answer_message(environ.get("GIT_COMMIT_SHA", "<undefined>"))


@collector.command("/_debug:version", visible=False)
async def build_version(message: IncomingMessage, bot: Bot) -> None:
"""Show app version."""
cmd = "poetry version --short"
output = run(cmd.split(), stdout=PIPE, stderr=STDOUT, text=True).stdout
await bot.answer_message(output)
4 changes: 2 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ per-file-ignores =
# too many args
# wrong var name
app/services/answer_error.py:WPS110,WPS211,WPS230
# too many imported names
app/bot/commands/common.py:WPS235
# too many imported names, subprocess usage
app/bot/commands/common.py:WPS235,S404,S603
# names shadowing
# `%` string formatting
app/db/sqlalchemy.py:WPS442,WPS323
Expand Down

0 comments on commit b6110d8

Please sign in to comment.