Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Module-ify and add some type hinting; move to async sqlite3 lib #572

Merged
merged 127 commits into from
Sep 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
127 commits
Select commit Hold shift + click to select a range
eb70cd7
relocate all files into an actual overarching python module
davidlougheed Sep 3, 2022
d58a14f
rename main and add some hints/format strings
davidlougheed Sep 3, 2022
09d9bca
linting and hinting
davidlougheed Sep 3, 2022
1e8201c
aaaaa
davidlougheed Sep 3, 2022
9ccd8e5
lint
davidlougheed Sep 3, 2022
4ba48d3
docs: reformat readme and update a few things
davidlougheed Sep 3, 2022
edf919b
add script for running the bot and install uvloop in actual main func…
davidlougheed Sep 3, 2022
a557ed6
fstrings
davidlougheed Sep 3, 2022
2a6f749
typing/linting
davidlougheed Sep 3, 2022
d785868
type hinting work
davidlougheed Sep 3, 2022
5b2f5d4
linting / code style / small fixes to strings
davidlougheed Sep 3, 2022
a85d893
hinting
davidlougheed Sep 4, 2022
d898859
add aiosqlite and mypy typings for (optional) typechecking
davidlougheed Sep 4, 2022
6a1a6ea
relocate config & remove configurable schema location
davidlougheed Sep 4, 2022
745c20c
oop
davidlougheed Sep 4, 2022
2b1efcc
add new base cog which factors out some common functionality
davidlougheed Sep 4, 2022
74452c0
relocate schema
davidlougheed Sep 4, 2022
1baa455
add package manifest
davidlougheed Sep 4, 2022
fd957ed
docs: update info on config
davidlougheed Sep 4, 2022
413491f
rewrite bot.py with async database + some code style changes
davidlougheed Sep 4, 2022
ac22e95
rewrite main.py with aiosqlite and code style changes
davidlougheed Sep 4, 2022
e290cb0
rewrite banner cog with aiosqlite and code style changes
davidlougheed Sep 4, 2022
7513cec
rewrite currency cog with aiosqlite and code style changes
davidlougheed Sep 4, 2022
0d20ab1
rewrite customreactions cog with aiosqlite and refactoring
davidlougheed Sep 4, 2022
3223b0b
rewrite games cog with new base cog
davidlougheed Sep 4, 2022
fa3b42a
rewrite helpers cog and images cog with new base cog
davidlougheed Sep 4, 2022
79ca287
rewrite mod cog with aiosqlite and new base cog
davidlougheed Sep 4, 2022
e32f5ae
change music cog to use new base cog
davidlougheed Sep 4, 2022
bb068ab
change quote cog to use aiosqlite and new base cog
davidlougheed Sep 4, 2022
2b35739
change reminder cog to use new base cog
davidlougheed Sep 4, 2022
b0785e1
make add_member_if_needed util async
davidlougheed Sep 4, 2022
80f2e5b
change score cog to new base cog + aiosqlite
davidlougheed Sep 4, 2022
90e2e87
comment
davidlougheed Sep 4, 2022
11e73c5
move Reminder.check_reminders to aiosqlite
davidlougheed Sep 4, 2022
b81a026
convert mod cog to use aiosqlite
davidlougheed Sep 4, 2022
800612c
convert reminder cog to use aiosqlite
davidlougheed Sep 4, 2022
1fa6c87
type hints for roles cog
davidlougheed Sep 4, 2022
9292a23
remove unused import in score cog
davidlougheed Sep 4, 2022
c21329d
cleanup in role check utils
davidlougheed Sep 4, 2022
d05f596
add settings key del function in base cog
davidlougheed Sep 4, 2022
852d36b
convert games cog to aiosqlite
davidlougheed Sep 4, 2022
06306c7
convert helpers cog to aiosqlite
davidlougheed Sep 4, 2022
fa93f1b
convert role restoration to aiosqlite
davidlougheed Sep 4, 2022
91805c7
fix fetch_saved_roles not being async
davidlougheed Sep 4, 2022
cce5b95
respond with error msg if keydates encounters an http error
davidlougheed Sep 4, 2022
889f252
add error message if tex rendering fails
davidlougheed Sep 4, 2022
f6518c8
linting and autoformatting fixes
davidlougheed Sep 4, 2022
21c6a7b
type fixes
davidlougheed Sep 4, 2022
76ca136
lint
davidlougheed Sep 4, 2022
f30e0f2
fix some typing complaints
davidlougheed Sep 4, 2022
8b50a1a
fix another typing complaint
davidlougheed Sep 4, 2022
31c5c1e
add bot health check function which checks if guild ID is set right
davidlougheed Sep 4, 2022
ec3ac91
switch subscribers cog to new base cog
davidlougheed Sep 4, 2022
2e4b886
change: switched to using lxml parser instead of python html.parser w…
namemcguffin Sep 4, 2022
f03a3db
fix STM subscriber (?) by disabling content type checking in custom r…
davidlougheed Sep 4, 2022
227d2ab
add hashbang to hangman
davidlougheed Sep 4, 2022
df4aa31
mild refactor of customreactions cog
davidlougheed Sep 4, 2022
9a948f3
feat: higher level abstraction for fetching lists
davidlougheed Sep 4, 2022
ad8d20f
lint
davidlougheed Sep 4, 2022
008460c
score code style
davidlougheed Sep 4, 2022
52d1f55
score reformatting
davidlougheed Sep 5, 2022
0b714c9
fix some funky strings
davidlougheed Sep 5, 2022
8f88bc4
add a fetch_one higher level fn to base cog
davidlougheed Sep 5, 2022
d5916d8
clarifying parens
davidlougheed Sep 5, 2022
d29f534
more reminders refactoring + lint
davidlougheed Sep 5, 2022
2f1a864
add (de)serialization to settings key methods; some related refactoring
davidlougheed Sep 5, 2022
05ec215
f string
davidlougheed Sep 5, 2022
ebf5dd7
chore: more typing
davidlougheed Nov 12, 2022
5f680b9
chore: update dev dependencies & lockfile
davidlougheed Nov 19, 2022
57d2d2b
lint
davidlougheed Nov 19, 2022
605cccb
lint&hint
davidlougheed Nov 19, 2022
eb2817a
banner cog cleanup
davidlougheed Nov 19, 2022
205fc29
more banner cleanup
davidlougheed Nov 20, 2022
b976113
currency cleanup
davidlougheed Nov 20, 2022
f1fd108
a bit of spacing
davidlougheed Nov 20, 2022
81e1b11
lint
davidlougheed Nov 20, 2022
9ffaf8f
update bot.py year
le-potate May 12, 2023
6a307d7
redo config class
davidlougheed May 13, 2023
0856545
type hint context in main.load fn
davidlougheed May 13, 2023
fd4cc9d
update dependencies, require poetry 1.4+
davidlougheed May 13, 2023
07c16b5
update python & actions ver
davidlougheed May 13, 2023
a9cf62f
new config integration work
davidlougheed May 13, 2023
19d873b
single year range var for course url templates
davidlougheed May 13, 2023
d1604a6
new config: impl bet roll
davidlougheed May 13, 2023
39162ea
ignore poetry toml
davidlougheed May 13, 2023
1cfd552
add example env file
davidlougheed May 13, 2023
22c7e06
fix supported python ver
davidlougheed May 13, 2023
87f780e
ci: remove old ubuntus from matrix
davidlougheed May 13, 2023
f097959
chore [noci]: update copyright
davidlougheed May 13, 2023
5b47816
chore: update more deps
davidlougheed May 13, 2023
a2da07f
chore: update pillow
davidlougheed May 13, 2023
2720499
lint
davidlougheed May 13, 2023
0f12138
lint
davidlougheed May 13, 2023
a23ce83
fix: defaults for currency and music nested settings
davidlougheed Jun 3, 2023
2bc742d
fix: setting log levels with new config
davidlougheed Jun 3, 2023
59832b5
fix: developer/moderator role checks
davidlougheed Jun 3, 2023
ac93f3a
chore: port image config to new config object
davidlougheed Jun 3, 2023
5bab9d4
fix: missing await for db fetchone
davidlougheed Jun 3, 2023
f012de6
chore: port games config to new config model
davidlougheed Jun 3, 2023
0c5d87b
fix: muted role checks
davidlougheed Jun 3, 2023
178a8a1
fix: music config model default start vol value
davidlougheed Jun 3, 2023
8792524
chore: port legacy assignable roles config to new config model
davidlougheed Jun 3, 2023
253f504
ci: tweak formatting check
davidlougheed Jun 3, 2023
1e16edd
fix: music config access
davidlougheed Jun 3, 2023
3254f5c
chore: update discordpy to 1.7.3
davidlougheed Jun 3, 2023
0d4a715
fix: type hints causing bad conversions in currency cog
davidlougheed Jun 3, 2023
d3ee5b4
fix: type hints causing bad conversions in memes and roles cogs
davidlougheed Jun 3, 2023
f4f5c2b
chore: add log webhook env vars to example env
davidlougheed Jun 3, 2023
7624fb2
chore: remove old config class
davidlougheed Jun 3, 2023
df41acc
fix: listing all roles not working
davidlougheed Jun 3, 2023
7cf6dda
example env wording
davidlougheed Jun 3, 2023
6bc59f7
[fix]: fixed field name in example.env
namemcguffin Jun 29, 2023
69cda94
update course year range to 24-25
davidlougheed Sep 4, 2024
0594656
steal https://github.com/idoneam/Canary/pull/519
davidlougheed Sep 4, 2024
55a261a
update dependencies
davidlougheed Sep 4, 2024
4efd41c
dockerfile work
davidlougheed Sep 4, 2024
4c15035
some paginator type hinting
davidlougheed Sep 4, 2024
7681882
fix add_quote full name
davidlougheed Sep 4, 2024
a1a59e0
fix some member converters in currency/quotes
davidlougheed Sep 5, 2024
a07addd
custom reactions elifs
davidlougheed Sep 5, 2024
63bca21
lint: run black
davidlougheed Sep 5, 2024
7c33822
remove old config.ini
davidlougheed Sep 5, 2024
9d62e54
docs: update config / deployment details
davidlougheed Sep 5, 2024
bb156fc
ci: update actions
davidlougheed Sep 7, 2024
a222928
chore: clear apt lists + combine apt RUN statements
davidlougheed Sep 7, 2024
5839f88
chore(deps): update uvloop
davidlougheed Sep 7, 2024
bceb4b5
ci: build an edge (master-branch) image too
davidlougheed Sep 7, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
config/config.ini
canary/config/config.ini
data/runtime/*.db
data/runtime/*.obj
env/
tests/
venv/
9 changes: 4 additions & 5 deletions .github/workflows/formatting_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@ name: formatting check
on:
push:
paths:
"**.py"
- "**.py"

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- uses: psf/black@stable
with:
options: "--diff --check -t py310 --fast"

options: "--diff --check -t py311 canary"
15 changes: 6 additions & 9 deletions .github/workflows/poetry-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,16 @@ jobs:
strategy:
matrix:
os:
- 'ubuntu-20.04'
- 'ubuntu-18.04'
# - 'macos-10.15'
- 'macos-11.0'
- 'windows-2019'
- 'ubuntu-24.04'
- 'macos-14.0'
- 'windows-2022'
python-version:
- '3.10'
- '3.11'
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

Expand All @@ -50,4 +48,3 @@ jobs:

- name: install canary development dependencies
run: poetry install --no-interaction

10 changes: 4 additions & 6 deletions .github/workflows/poetry-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,14 @@ jobs:
strategy:
matrix:
os:
- 'ubuntu-20.04'
- 'ubuntu-18.04'
- 'ubuntu-24.04'
python-version:
- '3.10'
- '3.11'
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

Expand All @@ -40,4 +39,3 @@ jobs:

- name: install canary production dependencies
run: poetry install --no-dev --no-interaction

54 changes: 42 additions & 12 deletions .github/workflows/publish-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,64 @@ on:
release:
types: [published]

push:
branches:
- master

jobs:
publish:
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: actions/checkout@v4

- name: Set up master (edge) image metadata
id: meta-master
uses: docker/metadata-action@v5
if: ${{ github.event_name != 'release' }}
with:
python-version: '3.10'
- run: pip install poetry && poetry update && poetry export -f requirements.txt > requirements.txt
- uses: docker/metadata-action@v3
id: meta
images: |
${{ inputs.image-name }}
flavor: |
latest=false
tags: |
type=raw,value=master,enable={{is_default_branch}}
type=sha,prefix=sha-

- name: Set up release image metadata
id: meta-release
uses: docker/metadata-action@v5
if: ${{ github.event_name == 'release' }}
with:
images: ghcr.io/idoneam/Canary
flavor: |
latest=true
tags: |
type=semver,pattern={{major}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{version}}
- uses: docker/setup-buildx-action@v1
- uses: docker/login-action@v1

- uses: docker/setup-buildx-action@v3

- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ github.token }}
- uses: docker/build-push-action@v2
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push master (edge) image
uses: docker/build-push-action@v6
if: ${{ github.event_name != 'release' }}
with:
context: .
push: true
tags: ${{ steps.meta-master.outputs.tags }}

- uses: docker/build-push-action@v6
if: ${{ github.event_name == 'release' }}
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
tags: ${{ steps.meta-release.outputs.tags }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ ENV/

# configuration files
**/*.ini
poetry.toml

# other
*~
Expand Down
52 changes: 31 additions & 21 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,28 +1,38 @@
FROM python:3.10-slim-bullseye
FROM python:3.11-slim-bookworm

# Install base apt dependencies
RUN apt-get update && apt-get install -y git sqlite3
# Install base apt dependencies + auxiliary dependencies (for GL, Tex, etc.)
RUN apt-get update && \
apt-get install -y \
git \
sqlite3 \
libgl1-mesa-glx \
texlive-latex-extra \
texlive-fonts-extra \
texlive-lang-greek \
dvipng \
ffmpeg \
gcc && \
rm -rf /var/lib/apt/lists/*

# Install auxiliary dependencies (for GL, Tex, etc.)
RUN apt-get install -y \
libgl1-mesa-glx \
texlive-latex-extra \
texlive-fonts-extra \
texlive-lang-greek \
dvipng \
ffmpeg \
gcc
# Update pip, install poetry
RUN pip install --no-cache-dir -U pip; \
pip install --no-cache-dir poetry==1.8.3

# Install requirements with pip to use Docker cache independent of project metadata
COPY requirements.txt /
RUN pip install -r /requirements.txt
COPY pyproject.toml .
COPY poetry.lock .
RUN poetry config virtualenvs.create false && \
poetry --no-cache install --no-root --without dev

# Copy code to the `canary` directory in the image and run the bot from there
COPY . /canary
WORKDIR /canary
# Copy code and pre-made data to the /app directory, where the bot will be run from
WORKDIR /app
COPY canary canary
COPY data data

RUN pip install -e .

# Notes:
# Users will have to mount their config.ini in by hand
# Users should mount a read/writable volume for /canary/data/runtime
# Users will have to configure their instance using environment variables, described by the Pydantic settings object
# in /app/canary/config/config.py
# Users should mount a read/writable volume for /app/data/runtime

CMD ["python3.10", "Main.py"]
CMD ["canary"]
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include canary/Martlet.schema
Loading
Loading