Chuckle is our in-house Discord bot for our internal company server. We weren't a huge fan of Slack and, most of our target demographic uses Discord.
A few of our favorite (and only :p) features include:
- Circle Back, create reminders to revisit a specific message
- PR Comments, stream PR reviews and updates to a configured thread
/hexil
, allow each member to set a custom role/name color
These are some broad, general requirements for running Chuckle.
Before you can actually setup... we have some setup to do!
- Install
cargo-make
(cargo install --force cargo-make
)
Cargo doesn't have a native "scripts" feature like Yarn or NPM. Thus, we use cargo-make
and Makefile.toml
.
2. Install pre-commit
(pip install pre-commit
)
We use this for running git hooks. This is handled by the next step.
- Run
cargo make setup
This installs necessary components for other scripts and development fun.
If it weren't for sqlx
and it's inability to play nice with direnv
, we wouldn't also need an .env
file containing just the DATABASE_URL
.
- Install direnv.
It automatically loads our .direnv
file.
-
Copy
.envrc.example
to.envrc
and fill with your environment variables. -
Ensure
.env
houses yourDATABASE_URL
address.
We utilize sqlx
's compile-time checked queries, which requires a database connection during development.
Additionally, we use sqlx
's migrations tool, which is just a treat!
-
Start the database with
docker compose up -d
. -
Run
sqlx migrate run
This applies our database migrations.
Now, running the bot should be as easy as:
cargo make dev
When making changes to Chuckle, there are a few things you must take into consideration.
If you make any query changes, you must run cargo sqlx prepare
to create an entry in .sqlx
to support SQLX_OFFLINE
.
If you make any command/interaction data changes, you must run cargo make commands-lockfile
to remake the commands.lock.json file.
Regardless, of what scope, you must always ensure Clippy, Rustfmt and cargo-check are satisified, as done with pre-commit hooks.
We currently host Chuckle on our Google Kubernetes Engine cluster.
flowchart TD
commands["
Update Discord
Commands
"]
test["
Lint, Format
and Build
"]
commit[Push to main] --> test
commit ---> deploy[Deploy to GCR]
commit -- "
commands.lock.json
updated?
" ---> commands
commit -- "
migrations
updated?
" --> cloudsql[Connect to Cloud SQL]
--> migrations[Apply Migrations]
todo, see our .github/workflows