Development¶
This page is for contributors who change, test, or release the Mankai gems. It shows you how to set up the repository, run the tests and linters, build these docs, add a changelog entry, and release a gem. For the contribution workflow and pull request rules, see Contribute.
The repository holds six gems in gems/, a separate Hanami demo app in examples/demo_app, and
this documentation site in docs/. One root Gemfile loads all six gems from their directories;
the gems have no Gemfiles of their own.
Every task is a make target. To list them, run make. Pass settings as make arguments, for
example make test/jobs RSPEC_ARGS="spec/unit/mankai/jobs/enqueuer_spec.rb".
Set up the repository¶
Before you begin, install the tools pinned in mise.toml: Ruby 4.0.10, Python 3.14.10,
changie 1.26.0, and ShellCheck 0.11.0. The browser client's tests also need
Node.
To install the root bundle and the demo app's separate bundle, run:
Run the tests¶
To run every gem's specs, with the SQL gems on SQLite, plus the browser client's Node tests, run:
Each gem also has its own target. The following table lists the test targets:
| Target | Runs |
|---|---|
make test/jobs |
The mankai-jobs specs |
make test/jobs-sql |
The mankai-jobs-sql specs, on DATABASE_URL (default: SQLite) |
make test/cache |
The mankai-cache specs |
make test/cache-sql |
The mankai-cache-sql specs, on DATABASE_URL (default: SQLite) |
make test/sockets |
The mankai-sockets specs |
make test/sockets-sql |
The mankai-sockets-sql specs, on DATABASE_URL (default: SQLite) |
make test/js |
The browser client's Node tests |
make test/sql-all |
All three SQL gems' specs, on one DATABASE_URL |
make test/demo |
The demo app's specs, on PostgreSQL at DEMO_DATABASE_URL |
test/core and test/sql are aliases for test/jobs and test/jobs-sql.
Run one spec¶
Each gem's .rspec file requires spec_helper, so RSpec fails if you run it from the repository
root. To run one spec, pass RSPEC_ARGS to the gem's target, or run RSpec from the gem's
directory:
make test/jobs RSPEC_ARGS="spec/unit/mankai/jobs/enqueuer_spec.rb:42"
cd gems/mankai-jobs && bundle exec rspec spec/unit/mankai/jobs/enqueuer_spec.rb:42
Run the SQL gems on another database¶
To run the SQL gems on another database, set DATABASE_URL:
An empty DATABASE_URL counts as unset. The test helper adds fractional_seconds=true to MySQL and
MariaDB URLs.
Run the demo app's specs¶
make test/demo needs PostgreSQL at DEMO_DATABASE_URL (default: postgres:///demo_app_test),
with the demo app's migrations applied.
-
Prepare the test database:
-
From the repository root, run the specs:
Run the linters¶
To run every linter, run:
The following table lists the lint targets:
| Target | Description |
|---|---|
make lint/all |
Runs ShellCheck on every script, then RuboCop in each gem and the demo app. |
make lint/shell |
Runs ShellCheck only, at style level. |
make lint/fix |
Applies RuboCop's safe autocorrections in every gem. |
make lint/config |
Downloads Hanakai's shared RuboCop config into each gem's .rubocop.yml. |
Each gem's .rubocop.yml is a pinned copy of the shared RuboCop config from
Hanakai, the organization behind Hanami, dry-rb, and ROM. Don't edit it by
hand; to update it, run make lint/config.
To lint one gem, run RuboCop from its directory:
Shell scripts follow the Google Shell Style Guide,
except that they keep the #!/usr/bin/env bash shebang.
Test against other databases¶
The database matrix runs the SQL gems against several versions of PostgreSQL, MySQL, and MariaDB in Docker containers. Before you begin, install Docker.
-
Start the databases:
-
Run the SQL gems on SQLite and on every database that
db/upstarted:The logs are in
tmp/matrix/. -
Stop the databases:
To print the connection URLs, run make db/list. To choose the versions, set
DB_POSTGRES_VERSIONS, DB_MYSQL_VERSIONS, and DB_MARIADB_VERSIONS.
Continuous integration¶
The workflows live in .github/workflows/:
lint.ymlrunsmake lint/allon Ruby 4.0.10. On pull requests, it also runsscripts/changelog-check, which fails when a gem'slib/changed without a changelog entry.test.ymlrunsmake test/allon Ruby 4.0.10 and 3.4.13, builds every gem, and runs the demo app's specs against a PostgreSQL service container.db-matrix.ymlruns the SQL gems on every database in the matrix every night, when you start it by hand, or when a pull request has thefull-db-matrixlabel.docs.ymlbuilds the docs site withmake docs/buildon pull requests. On pushes tomain, it also deploys the site to GitHub Pages.release.ymlpublishes a gem when you push its release tag.
Build the docs¶
This site is built with Zensical, pinned in requirements-docs.txt. To
install it and preview the site at http://localhost:8000, run:
To build the site into site/, run make docs/build. The build fails on broken internal links.
The gem reference pages include each gem's README, so edit the README, not a copy. The site follows these sections:
- Tutorials, which teach by building one thing, go in
docs/get-started/tutorials/. Installation goes indocs/get-started/. - Guides, which cover one task each, go in
docs/guides/<feature>/. Production guides go indocs/guides/production/. - Reference pages go in
docs/reference/. Each gem page includes the gem's README. - Explanation pages, which cover concepts and design, go in
docs/explanation/.
Add a changelog entry¶
Each gem owns its version (lib/**/version.rb) and its changelog state (.changie.yaml and
.changes/). Mankai uses changie to collect changelog entries as small files
called fragments. A pull request that changes a gem's lib/ adds a fragment to that gem.
To add a fragment, run the following command and answer the prompts:
Replace GEM_NAME with the gem's name, for example mankai-jobs.
Don't edit CHANGELOG.md by hand; changie generates it when you release.
Release a gem¶
Each gem is released on its own. Release core gems before the SQL gems that depend on them.
Before you begin, check the SQL gem's dependency. Each SQL gem depends on its core gem with a
~> x.y.0 constraint. If you bump a core gem's minor or major version, update that constraint in
the SQL gem's gemspec, and release the SQL gem too.
In the following steps, replace these placeholders:
GEM_NAME: the gem's name, for examplemankai-jobs.-
VERSION: the new version, for example0.2.0. -
Prepare the release:
This command batches the unreleased fragments into
.changes/VERSION.md, sets the version inlib/**/version.rb, merges the notes intoCHANGELOG.md, and refreshes the root and demo app lockfiles. -
Check the release:
The check fails if the version file, the
CHANGELOG.mdsection, or.changes/VERSION.mdis missing, or if any unreleased fragments remain. -
Commit
CHANGELOG.md,.changes/,version.rb,Gemfile.lock, andexamples/demo_app/Gemfile.lock. - Merge the commit to
main. -
Tag the merged commit, and push the tag:
Pushing the tag starts the release.yml workflow. The workflow runs in the release environment,
so a reviewer must approve it first. The workflow then does the following:
- Checks the tag, and checks that
gems/GEM_NAME/.changes/VERSION.mdexists. - Gets short-lived RubyGems credentials through trusted publishing.
- Runs
make release/check. - Runs
make release/publish, which builds the gem intopkg/, checks its version, and pushes it to RubyGems. - Creates a GitHub release with
gems/GEM_NAME/.changes/VERSION.mdas its notes.
CI runs make release/publish for you. If CI can't publish, set GEM_HOST_API_KEY, and run
make release/publish GEM_NAME=GEM_NAME VERSION=VERSION yourself.