Skip to main content

Automated routine workflow runner for repository hygiene, backups, and dumps orchestration and much more.

Project description

routine-workflow logo

PyPI version Python Wheel Release

Build status Codecov Test Coverage Code style: black Ruff Security

Downloads OS Python Versions

License: MIT

Docs

Routine Workflow

Production-grade automation for repository hygiene: code reformatting, cache cleaning, backups and dumps orchestration.


Table of Contents

  • Overview
  • Key Features
  • Installation
  • Quick Start
  • CLI Reference
  • Configuration
  • Workflow Steps
  • Logging & Locking
  • Testing & CI
  • Development
  • Troubleshooting
  • Contributing
  • License

Overview

routine_workflow is a small, robust Python package designed to automate routine repository maintenance tasks in production — including cleaning caches, running code formatting tools, creating backups, and producing code dumps via an external tool (formerly code-dump, now create-dump).
It is written for reliability in CI and on developer machines and intended to be easy to integrate into cronjobs, CI pipelines, or run interactively.

This repository follows a src/ layout and provides a CLI entrypoint, a dataclass-based configuration object, and a well-tested runner orchestration.


Key Features

  • Deterministic, configurable workflow orchestration
  • Safe locking to prevent concurrent runs
  • Dry-run mode for previewing operations
  • Pluggable external dump tool integration (create-dump)
  • Parallelizable tasks (autoimport / formatting) with configurable worker count
  • Thorough test coverage and CI-friendly behavior

Installation

Recommended: install inside a virtual environment.

# From PyPI (if published)
pip install routine-workflow

# From local source (editable)
git clone git@github.com:dhruv13x/routine-workflow.git
cd routine-workflow
python -m venv .venv
source .venv/bin/activate
pip install -e .


---

Quick Start

Run the workflow with defaults (uses sensible local defaults for logging, lock dir, and the create-dump helper script):

routine-workflow
# OR if running the package directly
python -m src.routine_workflow

Dry-run to preview actions without executing commands:

routine-workflow --dry-run

Run with increased verbosity (logs written to configured log_dir):

routine-workflow --project-root /path/to/project --log-dir /var/log/routine-workflow

routine-workflow --steps step2 step3  # Run only formatting + cleaning, in that order
routine-workflow --steps step5 step1 step3.5  # Custom order: dumps first, then prune + scan
routine-workflow --steps step3 step3 step4  # Repeat cache clean before backup


---

CLI Reference

Run routine-workflow --help or refer to src/routine_workflow/cli.py for the most up-to-date options. Highlights:

--project-root PATH            Project root (default: $PROJECT_ROOT or current dir)
--log-dir PATH                 Directory for rotating logs (default: /sdcard/tools/logs)
--log-file PATH                Explicit log file path
--lock-dir PATH                Directory used for locking (default: /tmp/routine_workflow.lock)
--clean-script PATH            Path to clean helper script (default: /sdcard/tools/clean.py)
--backup-script PATH           Path to backup helper script (default: /sdcard/tools/create_backup.py)
--create-dump-script PATH      Path to external create-dump script (default: /sdcard/tools/run_create_dump.sh)
--create-dump-run-cmd ...      Override base run command for the create-dump tool
--fail-on-backup               Exit with error if backup fails
--yes                          Auto-confirm prompts
--dry-run                      Show actions without executing
--workers INT                  Parallel workers (default: min(8, CPU))
--workflow-timeout INT         Overall timeout in seconds (0 = disabled)
--exclude-patterns PATTERN ... File discovery exclude patterns
--steps STEP ...   Run specific steps only (space-separated; supports order/repeats, e.g., "step1 step3 step1"). Defaults to all.


---

Configuration

Runtime configuration is encapsulated in WorkflowConfig (src/routine_workflow/config.py).
You can supply configuration via CLI flags or environment variables.

Defaults:

LOG_DIR: /sdcard/tools/logs

LOCK_DIR: /tmp/routine_workflow.lock

CREATE_DUMP_SCRIPT: /sdcard/tools/run_create_dump.sh

WORKFLOW_TIMEOUT: 0 (disabled)


Config exposes:

create_dump_script: Path
create_dump_clean_cmd: List[str]
create_dump_run_cmd: List[str]
fail_on_backup: bool
auto_yes: bool
dry_run: bool
max_workers: int
workflow_timeout: int
exclude_patterns: List[str]


---

Workflow Steps

The workflow orchestrates these steps (under src/routine_workflow/steps):

1. delete_old_dumps  prune old dumps


2. reformat_code  run autoformatter / autoimport helpers


3. clean_caches  remove temporary caches and artifacts


4. backup_project  create a backup of the project


5. generate_dumps  call create-dump tool to produce project dumps



Each step is idempotent and resilient to failures; fail_on_backup controls whether workflow aborts on backup failure.


---

Logging & Locking

Logging uses a RotatingFileHandler (5MB, 5 backups) plus console output.

Runner enforces directory-based lock (config.lock_dir) to prevent concurrent runs, validated by PID file contents.



---

Testing & CI

Run the tests locally:

pip install -r requirements-dev.txt
pytest -q

Example coverage:

81 passed
coverage: 96.73%

CI suggestions:

Run tests on every PR

Run linting (black, flake8)

Publish coverage reports



---

Development

Recommended workflow for contributors:

# create feature branch
git checkout -b feat/your-change

# run tests & fix
pytest -q

# commit and push; open PR
git commit -am "Describe change"
git push origin feat/your-change

Maintain a clean src/ layout and keep WorkflowConfig stable for backward compatibility.


---

Troubleshooting

Q: Why does it ask for credentials when pushing?
A: Use SSH remotes (git@github.com:...) or store a PAT for HTTPS remotes.

Q: .pyc or .coverage files appear after tests.
A: Add .gitignore with __pycache__/, *.pyc, .coverage, .bak.

Q: External create-dump tool not found.
A: Ensure create-dump is installed or specify --create-dump-script.


---

Contributing

Contributions welcome.

1. Open an issue for major changes


2. Fork the repo and submit PRs against main


3. Keep changes small, tested, and documented



Add a CONTRIBUTING.md for release/versioning and commit conventions.


---

Release & Versioning

Uses semantic versioning.
Tag releases with:

git tag -a v2.0.0 -m "Rename code-dump → create-dump (stable release)"
git push origin v2.0.0


---

License

MIT License  see LICENSE file.


---

Maintainers / Contact

dhruv13x  primary maintainer



---

Thank you for using routine_workflow.
Optional: I can generate CONTRIBUTING.md, CHANGELOG.md, and .github/workflows/ci.yml for CI automation.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

routine_workflow-7.0.0.tar.gz (40.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

routine_workflow-7.0.0-py3-none-any.whl (26.6 kB view details)

Uploaded Python 3

File details

Details for the file routine_workflow-7.0.0.tar.gz.

File metadata

  • Download URL: routine_workflow-7.0.0.tar.gz
  • Upload date:
  • Size: 40.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for routine_workflow-7.0.0.tar.gz
Algorithm Hash digest
SHA256 cd70fe879f8f1d93877385b4ecbf1f692ea5350b4279b4d0b863815b9b8f81b6
MD5 19fec64a58f42a535f4685c3196b5eee
BLAKE2b-256 ffbc664a3e9de67665d417404a324aa5aec8dd2764c4bd2167772ba3b32fdb35

See more details on using hashes here.

Provenance

The following attestation bundles were made for routine_workflow-7.0.0.tar.gz:

Publisher: publish.yml on dhruv13x/routine-workflow

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file routine_workflow-7.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for routine_workflow-7.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0ae3487402bb4883e7ca3c68918534fbe2edc6aa7bbb7310884b0916adf8abc5
MD5 47f4048efbddef26c6df58b9c91028c6
BLAKE2b-256 84d8f6fde22fdf19cb9f7326a81c4691f0e6918e66d6d033e60684f1cbfe69ca

See more details on using hashes here.

Provenance

The following attestation bundles were made for routine_workflow-7.0.0-py3-none-any.whl:

Publisher: publish.yml on dhruv13x/routine-workflow

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page