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

Routine Workflow

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

routine_workflow is a robust, "batteries-included" Python tool designed to automate the mundane but critical maintenance tasks of your repository. Whether running in a CI pipeline or on a local developer machine, it ensures your project stays clean, secure, and well-formatted with a single command.


๐Ÿš€ Quick Start

Prerequisites

  • Python 3.9+
  • pip

Installation

Install from PyPI with a single command:

pip install routine-workflow

Tip For an enhanced CLI experience with rich formatting and colors, install with the rich extra: pip install "routine-workflow[rich]"

Usage Example

Run the default workflow in safe mode (Dry-Run):

routine-workflow

Execute the full workflow (Real Run):

routine-workflow -nd -y

Run specific steps using Aliases:

routine-workflow -s reformat clean backup -nd

โœจ Key Features

  • ๐Ÿ›ก๏ธ Safe by Default: Ships with dry-run enabled to prevent accidental changes.
  • ๐Ÿง  Interactive Mode: Guided wizard to configure steps and options on the fly.
  • โš™๏ธ Extensible Step Runner: Run steps in any order, repeat them, or run a custom selection.
  • ๐Ÿงฉ Alias-Driven: Use intuitive aliases like reformat, clean, pytest, or audit.
  • โšก Parallel Execution: Utilizes multi-core processing for supported tasks to save time.
  • โœ… Integrated Testing: Run your pytest suite as part of the hygiene workflow.
  • ๐Ÿ”’ Concurrency Safe: Robust file-based locking prevents multiple instances from stepping on each other.
  • ๐Ÿ” Security & Auditing: God Level integration of security scans (bandit, safety) and dependency auditing.
  • ๐Ÿ“Š Performance Profiling: Built-in --profile mode to analyze step execution times.
  • ๐Ÿช Pre-commit Ready: Easily install as a pre-commit hook with --install-pre-commit.
  • ๐Ÿ“ Advanced Logging: JSON output, log rotation, and configurable verbosity levels.
  • โœ๏ธ Git Integration: Automatically commit and push a hygiene snapshot after a successful run.

โš™๏ธ Configuration & Advanced Usage

Environment Variables

You can configure defaults via environment variables or a .env file (if supported by your environment loader).

Variable Description Default
PROJECT_ROOT Root directory of the project. CWD
LOG_DIR Directory for log files. /sdcard/tools/logs
LOCK_DIR Directory for the lock file. /tmp/routine_workflow.lock
LOCK_TTL Lock time-to-live in seconds. 3600
WORKFLOW_TIMEOUT Overall workflow timeout in seconds. 0 (Disabled)
FAIL_ON_BACKUP Set to 1 to fail if backup fails. 0
GIT_PUSH Set to 1 to enable git push. 0
ENABLE_SECURITY Set to 1 to enable security scans. 0
ENABLE_DEP_AUDIT Set to 1 to enable dependency audit. 0
LOG_LEVEL Logging verbosity (DEBUG, INFO, etc.). INFO
LOG_FORMAT Log format (text or json). text

CLI Arguments

Below is the complete list of arguments available in routine-workflow:

Flag Description Default
-p, --project-root Path to the project root. CWD
-l, --log-dir Directory to write logs. /sdcard/tools/logs
--log-file Optional single log file path. None
--lock-dir Directory for lock file. /tmp/routine_workflow.lock
--lock-ttl Lock eviction TTL in seconds (0=disable). 3600
--log-level Logging verbosity (DEBUG, INFO, etc.). INFO
--log-format Log format (text or json). text
--log-rotation-max-bytes Max bytes per log file before rotation. 5MB
--log-rotation-backup-count Number of backup log files to keep. 5
--fail-on-backup Exit if backup step fails. False
-y, --yes Auto-confirm prompts. False
-d, --dry-run Dry-run mode (default). True
-nd, --no-dry-run Disable dry-run (perform real execution). False
-w, --workers Parallel workers. min(8, CPU)
-t, --workflow-timeout Overall timeout in seconds. 0
-s, --steps Specific steps/aliases to run. All
--test-cov-threshold Pytest coverage threshold. 85
--git-push Enable git commit/push in step 6. False
-es, --enable-security Enable security scan (step 3.5). False
-eda, --enable-dep-audit Enable dependency audit (step 6.5). False
--profile Profile execution time of steps. False
--install-pre-commit Install routine-workflow hook. False
-i, --interactive Enter interactive configuration mode. False
--create-dump-run-cmd Override create-dump run command. None
--exclude-patterns Override default exclude patterns. None
--version Show program's version. N/A

๐Ÿ—๏ธ Architecture

The routine-workflow follows a clean src/ layout with modular components.

src/routine_workflow/
โ”œโ”€โ”€ __init__.py
โ”œโ”€โ”€ banner.py           # CLI Banner & Art
โ”œโ”€โ”€ cli.py              # Entry point & Argument Parsing
โ”œโ”€โ”€ config.py           # Configuration Dataclass
โ”œโ”€โ”€ defaults.py         # Default Settings
โ”œโ”€โ”€ lock.py             # Concurrency Control
โ”œโ”€โ”€ runner.py           # Workflow Orchestrator
โ”œโ”€โ”€ steps/              # Modular Step Definitions
โ”‚   โ”œโ”€โ”€ step1.py        # Delete Dumps
โ”‚   โ”œโ”€โ”€ step2.py        # Reformat Code
โ”‚   โ”œโ”€โ”€ step2_5.py      # Pytest Runner
โ”‚   โ”œโ”€โ”€ step3.py        # Clean Caches
โ”‚   โ”œโ”€โ”€ step3_5.py      # Security Scan
โ”‚   โ”œโ”€โ”€ step4.py        # Backup
โ”‚   โ”œโ”€โ”€ step5.py        # Create Dumps
โ”‚   โ”œโ”€โ”€ step6.py        # Git Operations
โ”‚   โ””โ”€โ”€ step6_5.py      # Dependency Audit
โ””โ”€โ”€ utils.py            # Helpers

Core Flow:

  1. Config Loading: Loads defaults, env vars, and CLI args into a WorkflowConfig object.
  2. Lock Acquisition: Ensures only one instance runs via lock.py.
  3. Step Resolution: Maps requested aliases (e.g., audit) to step modules (e.g., step6_5.py).
  4. Execution: The WorkflowRunner executes steps sequentially, handling logging and errors.
  5. Report: Generates a summary of the run.

๐Ÿ—บ๏ธ Roadmap

Upcoming vs. Completed Features:

โœ… Completed

  • Core Essentials: CLI entrypoint, step runner, reformatting (ruff, isort), cache cleaning, and concurrency locking.
  • Integration: pytest integration, backup orchestration, and git snapshotting.
  • Security: Security scanning (bandit, safety) and dependency auditing.
  • Advanced Usage: Interactive mode, performance profiling, and pre-commit hook generation.
  • Observability: Advanced JSON logging and rotation.

๐Ÿ”ฎ Upcoming

  • Ecosystem: 3rd party plugins architecture and official Docker image.
  • Integrations: Webhook notifications (Slack/Discord) and CI/CD blueprints.
  • Visionary: AI-powered code analysis and automated refactoring.
  • Sandbox: Gamification and experimental "chaos mode" features.

๐Ÿค Contributing & License

We welcome contributions! Please see CONTRIBUTING.md (if available) or open a PR.

License: This project is licensed under the MIT License.

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-10.0.0.tar.gz (54.2 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-10.0.0-py3-none-any.whl (38.5 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for routine_workflow-10.0.0.tar.gz
Algorithm Hash digest
SHA256 02bc5bb71d1dc2ddea9409d705c1979998b8d997d22f345a2e6bd5477e4a4574
MD5 4a1861cfe38bb24daed2f76799f1dfbb
BLAKE2b-256 bd5067dd0298386765fb69892102af0ea7a5e43ddd870891cb903d32aca036d3

See more details on using hashes here.

Provenance

The following attestation bundles were made for routine_workflow-10.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-10.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for routine_workflow-10.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ee8f9b265ca83b0304c34a66f946547cf0f7ac9d91a9f714c167142a8a5c7ac1
MD5 bde243408ca50687512d1085815871fc
BLAKE2b-256 eee5cdcf202c8306dc4b5867538ba3e3ddbe0e465db7ca87adc63e253edaf436

See more details on using hashes here.

Provenance

The following attestation bundles were made for routine_workflow-10.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