Skip to main content

A modern Python task automation and multi-repository orchestration tool

Project description

Job Runner

PyPI version Python versions License: MIT Downloads

Multi-repository task automation with intelligent dependency management.

Features

  • Dependency Resolution: Automatically handles job dependencies with circular dependency protection
  • Template System: Reusable job templates with inheritance
  • Git Integration: Clone and manage multiple repositories
  • Task-Level Execution: Run specific tasks within jobs
  • Dependency Graphs: Visualize job dependencies with Mermaid
  • Conditional Configuration: Use when clauses for dynamic configs
  • Environment Management: Isolated environment variables per job

Installation

pip install job-runner

For development:

pip install job-runner[dev]

Quick Start

1. Create a jobs.yml file:

variables:
  build_dir: /tmp/builds
  user: ${USER}

jobs:
  build-frontend:
    type: build
    description: Build the frontend application
    repo:
      server: https://github.com/
      group: myorg/
      name: frontend
    directory: ${build_dir}
    script:
      - npm install
      - npm run build

  build-backend:
    type: build
    description: Build the backend service
    repo:
      server: https://github.com/
      group: myorg/
      name: backend
    directory: ${build_dir}
    script:
      - go mod download
      - go build -o server

  deploy:
    type: run
    description: Deploy all services
    dependencies:
      - build-frontend
      - build-backend
    script:
      - echo "Deploying services..."
      - ./deploy.sh

2. Run a job:

# Run a job with all its dependencies
job-runner run deploy

# Run a specific task within a job
job-runner run build-frontend test

# Run multiple tasks in sequence
job-runner run build-frontend clean,default,test

# Use "default" to refer to the main script
job-runner run build-frontend default    # Same as: job-runner run build-frontend

# Limit dependency depth
job-runner run deploy --depth 1

# Fetch (clone) a repository without running scripts
job-runner fetch build-frontend

3. List available jobs:

job-runner list

4. Visualize dependencies:

job-runner graph deploy

Configuration

Job Types

  • build: Clone a repository and run build scripts
  • run: Execute scripts in a specified directory

Templates

Create reusable job configurations:

templates:
  python-build:
    type: build
    script:
      - python -m pip install -r requirements.txt
      - python -m pytest
      - python -m build

jobs:
  my-python-app:
    template: python-build
    repo:
      server: https://github.com/
      group: myorg/
      name: my-app

Conditional Configuration

Use when clauses for dynamic configurations:

jobs:
  deploy:
    type: run
    script:
      - echo "Base script"
    when:
      - condition: "variables.get('ENVIRONMENT') == 'production'"
        data:
          script:
            - echo "Production deployment"
            - ./deploy-prod.sh

Tasks

Define multiple tasks within a job:

jobs:
  myapp:
    type: build
    repo:
      server: https://github.com/
      group: myorg/
      name: app
    script:
      - make build
    tasks:
      test:
        script:
          - make test
      clean:
        script:
          - make clean
      deploy:
        dependencies:
          - myapp:test
        script:
          - make deploy

Run specific tasks:

# Run a single task
job-runner run myapp test

# Run multiple tasks in sequence
job-runner run myapp clean,default,test

# The "default" task refers to the job's main script
job-runner run myapp default              # Runs: make build
job-runner run myapp clean,default        # Runs: make clean, then make build

# Run tasks with dependencies
job-runner run myapp deploy               # Runs test first, then deploy

CLI Commands

Command Description
job-runner list List all available jobs
job-runner run JOB [TASKS] Run a job or specific tasks (comma-separated)
job-runner fetch JOB Clone repository for build job without running scripts
job-runner info JOB [FIELD] Show job information
job-runner validate Validate configuration
job-runner dump JOB Export job definition
job-runner graph JOB Generate dependency graph

Advanced Features

Environment Variables

jobs:
  myapp:
    type: run
    env:
      NODE_ENV: production
      DEBUG: "false"
    script:
      - npm start

Variable Substitution

variables:
  version: "1.0.0"
  output: /tmp/builds

jobs:
  build:
    script:
      - echo "Building version {version}"
      - cp output {output}/app-{version}

Multiple Configuration Files

Organize jobs across multiple files:

# jobs.yml
jobs-dir: ./jobs

# jobs/frontend.yml
jobs:
  frontend:
    type: build
    # ...

# jobs/backend.yml
jobs:
  backend:
    type: build
    # ...

Development

# Clone the repository
git clone https://gitlab.com/proj_amx_01/tools/job-runner.git
cd job-runner

# Install in development mode
pip install -e ".[dev]"

# Run tests
pytest

# Format code
black deprun tests

# Lint
ruff check deprun tests

# Type check
mypy deprun

# Build wheel package
python -m build

# Or use the Makefile
make build

# Clean build artifacts
make clean

Contributing

Contributions are welcome! Please:

  1. Fork the repository
  2. Create a feature branch
  3. Add tests for new functionality
  4. Ensure all tests pass
  5. Submit a pull request

License

MIT License - see LICENSE file for details.

Credits

Created by Peter De Herdt

Support

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

deprun-0.1.0.tar.gz (21.9 kB view details)

Uploaded Source

Built Distribution

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

deprun-0.1.0-py3-none-any.whl (22.9 kB view details)

Uploaded Python 3

File details

Details for the file deprun-0.1.0.tar.gz.

File metadata

  • Download URL: deprun-0.1.0.tar.gz
  • Upload date:
  • Size: 21.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.2

File hashes

Hashes for deprun-0.1.0.tar.gz
Algorithm Hash digest
SHA256 70c561ec85aaad798227cd0cbf58adaef6f9b851047f7855575f1c40808c7922
MD5 a4fd995419b277e54cdf46853f64878e
BLAKE2b-256 3e5281d3501c49a90779592dd9c27a451813455225f3d24b4b31c89683e9c235

See more details on using hashes here.

File details

Details for the file deprun-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: deprun-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 22.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.2

File hashes

Hashes for deprun-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 99746b19b1131410adae7b4bb4d9f05951c973d08d57cbad218038df29290383
MD5 4d1d5ed356fcd3fed3fe591994ab527e
BLAKE2b-256 a32399b503e43651fc609d2ac5a3be1b5f5a219d6f59c38bd1c716524316e6e2

See more details on using hashes here.

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