Repository navigation
feat: --once single-cycle mode + commented config templates - #29
Merged
Merged
Conversation
Validating a bot token or a new feed meant starting the scheduler and watching logs for minutes. --once runs exactly one cycle and returns: 0 on success, 1 when the cycle crashed, 2 on a configuration error (unchanged). It short-circuits before signal and scheduler setup, so it never leaves a stray timer behind, and it honours HEARTBEAT_FILE like the scheduled job.
…point configuration.toml and .env are git-ignored by design (they hold the bot token), so a fresh clone had no template at all and the README only showed the TOML inline. Adds configuration.toml.example and .env.example, both carrying the feed list from the README as a TOML array (and the comma-separated form for env), plus a 'Running the bot' section covering python -m bot, --config resolution and --once. Two tests parse both committed examples and assert they yield the identical 8-feed list, so the templates rot loudly instead of quietly.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
configuration.tomldoes not exist anywhere — it never was committed, and it is git-ignored onpurpose because it holds the bot token. So after cloning there is no template, and the README only
shows the TOML inline in prose. Two consequences: the entry point is not obvious, and there is
nothing to copy.
What
1. Commented templates (
configuration.toml.example,.env.example)Both carry the feed list from the README, as a real list rather than a single URL:
.env.exampleuses the comma-separated form and says why one line beats a quoted multi-line valueonce a shell or a ConfigMap renders it. Every key is documented: units (
TIME_INTERVAL_MINinminutes,
ENTRY_MAX_TIME_OLDin seconds),@channelvs numeric id, the admin requirement, and theoptional
LOG_LEVEL/HEARTBEAT_FILE.Why
.exampleand not.toml/.env: the namesconfiguration.example.tomland.envare bothmatched by existing
.gitignorerules (lines 132 and 168), so a template with either name would besilently uncommittable and would never reach the repo.
2. Two tests so the templates cannot rot
test_toml_example_committed_in_repo_is_validparses the committed TOML;test_env_example_committed_in_repo_is_validasserts.env.exampleyields the exact same feedtuple. Edit one list without the other, or break a URL, and CI fails. An example nobody executes is
an example that lies.
3.
--once: one cycle, then exitValidating a token or a new feed meant starting the scheduler and watching logs for minutes.
python -m bot --once # 0 published OK, 1 cycle crashed, 2 bad configurationIt short-circuits before the signal handlers and the scheduler are installed, honours
HEARTBEAT_FILE, and takes the same injectable clock asrun_cycle, so the tests are deterministic(the fixture clock is in the future relative to the wall clock, which
is_recentcorrectly rejects —that surfaced immediately and is why the signature carries
now).Written TDD:
test(cli): … (red)(ImportError onrun_once), thenfeat(cli): …(green).4. README "Running the bot"
bot/is a package, sopython bot/telegram_rss_bot.pyfails withModuleNotFoundError: No module named 'bot'. Documented:python -m botfrom the repository root —the same command as the Docker
ENTRYPOINTand Kubernetes — plus the fact that--configresolvesagainst the current directory, not the repo, which is the usual cause of a confusing
"Missing required environment variables" after editing a TOML file that is then silently ignored.
Checks
ruff check,ruff format --check,mypyclean; 89 passed, of which 5 are the new--oncetests and 2 the config-template guards.
Deliberately not done
No
configuration.tomlis created or committed, and.gitignoreis untouched: ignoring the realfile is the point. Nothing here changes runtime behaviour unless you pass
--once.