Skip to main content

Modern Python CLI for automating GitHub Classroom assignment management

Project description

ClassDock

A comprehensive Python CLI tool for automating GitHub Classroom assignment management with modular workflow orchestration, repository operations, and secret management.

PyPI version Python Support Tests

๐ŸŽฏ Overview

ClassDock provides instructors with a powerful, modern CLI to automate GitHub Classroom workflows:

  • ๐Ÿ Modern Python CLI - Type-safe, intuitive commands with rich help and output
  • ๐Ÿ“ฆ PyPI Package - Simple installation: pip install classdock
  • ๐Ÿ”ง Modular Architecture - Organized command structure for different workflow areas
  • ๐Ÿ” Smart Repository Discovery - Automated filtering and batch operations
  • ๐Ÿ” Secret Management - Secure distribution of tokens and credentials
  • โš™๏ธ Configuration-Driven - Flexible, reusable assignment setups
  • ๐Ÿ›ก๏ธ Enterprise Support - Custom GitHub hosts and internal Git systems
  • ๐ŸŽฏ Instructor-Focused - Excludes instructor repos from batch operations automatically
  • ๐Ÿ›ก๏ธ Robust Error Handling - Centralized GitHub API error management with retry logic
  • ๐Ÿ”„ Fault Tolerance - Automatic retry mechanisms with exponential backoff
  • ๐Ÿ“Š Comprehensive Testing - 70+ tests with 100% pass rate and extensive coverage
  • ๐Ÿ“š Production Ready - Professional documentation and type-safe implementations

๐Ÿ“ฆ Installation

Quick Install (Recommended)

# Install from PyPI
pip install classdock

# Verify installation
classdock --help

Development Installation

# Clone repository
git clone https://github.com/hugo-valle/classdock.git
cd classdock

# Install with Poetry
poetry install
poetry shell

# Or install in development mode
pip install -e .

Requirements

  • Python 3.10+ (3.11+ recommended)
  • Git for repository operations
  • GitHub CLI (optional, for enhanced authentication)

๏ฟฝ๏ธ Enterprise Features

Centralized Error Handling

ClassDock includes a comprehensive error handling system for reliable GitHub operations:

  • ๐Ÿ”„ Automatic Retry Logic - Intelligent retry with exponential backoff for transient failures
  • โฑ๏ธ Rate Limit Management - Automatic handling of GitHub API rate limits
  • ๐Ÿ› ๏ธ Fallback Mechanisms - CLI fallback when GitHub API is unavailable
  • ๐Ÿ“Š Detailed Error Context - Comprehensive error reporting with context and suggestions
  • ๐Ÿ—๏ธ Resilient Operations - Fault-tolerant batch operations with individual error isolation
# Example: Automatic retry with error context
from classdock.utils.github_exceptions import github_api_retry

@github_api_retry(max_attempts=3, base_delay=1.0)
def discover_repositories():
    # Automatic retry for GitHub API failures
    # Handles rate limits, network issues, and transient errors
    pass

Enhanced CLI Architecture

  • ๐Ÿ“‹ Modular Commands - Organized subcommand structure (assignments, repos, secrets, automation)
  • ๐Ÿ”— Legacy Compatibility - Backward compatibility with deprecation warnings
  • ๐ŸŽฏ Rich Output - Beautiful terminal output with progress indicators
  • โš™๏ธ Flexible Configuration - Multiple configuration sources with precedence handling
  • ๐Ÿ” Comprehensive Help - Context-aware help system with examples

Production Quality

  • ๐Ÿงช Comprehensive Testing - 70+ tests covering all functionality with 100% pass rate
  • ๐Ÿ“š Professional Documentation - Complete docstrings following Python standards
  • ๐Ÿ—๏ธ Type Safety - Full type hints and mypy compatibility
  • ๐Ÿ”’ Security First - Secure credential handling and validation
  • ๐Ÿ“ฆ CI/CD Integration - Automated testing and publishing pipeline

๏ฟฝ๐Ÿš€ Quick Start

1. Basic Configuration

Create an assignment configuration file:

# Create assignment.conf
cat > assignment.conf << 'EOF'
# GitHub Classroom Configuration
CLASSROOM_URL="https://classroom.github.com/classrooms/123/assignments/456"
TEMPLATE_REPO_URL="https://github.com/instructor/assignment-template"
ASSIGNMENT_FILE="homework.py"

# Authentication
GITHUB_TOKEN_FILE="github_token.txt"

# Optional: Secrets to distribute
SECRETS_LIST="API_KEY,DATABASE_URL"
EOF

2. Command Structure

ClassDock uses a modular command structure:

# Main command groups
classdock assignments    # Assignment setup and orchestration
classdock repos         # Repository operations and collaboration
classdock secrets       # Secret and token management
classdock automation    # Scheduling and batch processing

# Legacy commands (for backward compatibility)
classdock setup         # Interactive assignment setup
classdock run           # Complete workflow execution

3. Common Workflows

# Setup a new assignment (interactive)
classdock assignments setup

# Discover student repositories
classdock repos fetch --config assignment.conf

# Add secrets to all student repos
classdock secrets add --config assignment.conf

# Run orchestrated workflow
classdock assignments orchestrate --config assignment.conf

# Check what would happen (dry-run)
classdock --dry-run assignments orchestrate

๐Ÿ”ง Command Reference

Assignment Management

# Setup new assignment configuration
classdock assignments setup

# Orchestrate complete assignment workflow
classdock assignments orchestrate [--config FILE] [--dry-run]

# Manage assignment templates
classdock assignments manage [--config FILE]

Repository Operations

# Fetch student repositories
classdock repos fetch [--config FILE]

# Manage collaborators
classdock repos collaborator add|remove [--config FILE]

Secret Management

# Add secrets to repositories
classdock secrets add [--config FILE] [--secrets LIST]

# Remove secrets from repositories  
classdock secrets remove [--config FILE] [--secrets LIST]

# List existing secrets
classdock secrets list [--config FILE]

Automation & Scheduling

# Setup cron jobs for automation
classdock automation scheduler setup [--config FILE]

# Run batch operations
classdock automation batch [--config FILE]

Global Options

Option Description Example
--dry-run Preview actions without executing classdock --dry-run assignments orchestrate
--verbose Enable detailed logging classdock --verbose repos fetch
--config FILE Use custom configuration file classdock --config my.conf assignments setup
--help Show help for any command classdock assignments --help

โš™๏ธ Configuration

Assignment Configuration File

The assignment.conf file contains all settings for your assignment:

# Required: GitHub Classroom assignment URL
CLASSROOM_URL="https://classroom.github.com/classrooms/123/assignments/456"

# Required: Template repository URL
TEMPLATE_REPO_URL="https://github.com/instructor/assignment-template"

# Required: Assignment file to validate
ASSIGNMENT_FILE="homework.py"

# Optional: GitHub Enterprise support
GITHUB_HOSTS="github.enterprise.com,git.company.internal"

# Optional: Authentication
# Prefer centralized token manager (~/.config/classdock/token_config.json) or set GITHUB_TOKEN
# Example (CI): export GITHUB_TOKEN="ghp_your_token_here"

# Optional: Secrets management
SECRETS_LIST="API_KEY,DATABASE_URL,SECRET_TOKEN"

# Optional: Repository filtering
EXCLUDE_REPOS="template,example,demo"
INSTRUCTOR_REPOS="instructor-solution"

Environment Variables

Override configuration with environment variables:

# Custom GitHub hosts
export GITHUB_HOSTS="git.company.internal,github.enterprise.com"

# GitHub token
export GITHUB_TOKEN="ghp_your_token_here"

# Custom assignment file
export ASSIGNMENT_FILE="main.cpp"

# Run with overrides
classdock assignments orchestrate

๐Ÿ’ก Best Practices

Workflow Recommendations

  • Always test with --dry-run before making changes
  • Use --verbose for debugging configuration issues
  • Keep configuration files in version control with your assignment
  • Use environment variables for sensitive information
  • Test with single student first using filtered configuration

Security Guidelines

  • Store GitHub tokens securely using the centralized token manager or OS keychain; avoid placing token files in the repository root.
  • Use environment variables for sensitive configuration
  • Review --dry-run output before executing changes
  • Limit repository access with proper filtering
  • Audit secret distribution using verbose logging

Configuration Management

  • Separate configs per assignment for better organization
  • Use descriptive filenames like midterm-exam.conf
  • Document custom GitHub hosts in your assignment README
  • Validate URLs before running batch operations

๐Ÿ› ๏ธ Development

Project Architecture

classdock/
โ”œโ”€โ”€ __init__.py              # Package initialization
โ”œโ”€โ”€ __main__.py             # CLI entry point
โ”œโ”€โ”€ cli.py                  # Main Typer CLI interface
โ”œโ”€โ”€ config.py               # Configuration management
โ”œโ”€โ”€ bash_wrapper.py         # Legacy script wrapper
โ”œโ”€โ”€ utils.py                # Utility functions
โ”œโ”€โ”€ utils/                  # Enhanced utilities
โ”‚   โ””โ”€โ”€ github_exceptions.py # Centralized error handling system
โ”œโ”€โ”€ assignments/            # Assignment management
โ”‚   โ”œโ”€โ”€ setup.py           # Interactive setup
โ”‚   โ”œโ”€โ”€ orchestrator.py    # Workflow orchestration
โ”‚   โ””โ”€โ”€ manage.py          # Template management
โ”œโ”€โ”€ repos/                  # Repository operations
โ”‚   โ”œโ”€โ”€ fetch.py           # Repository discovery (enhanced with error handling)
โ”‚   โ””โ”€โ”€ collaborator.py    # Collaborator management (with retry logic)
โ”œโ”€โ”€ secrets/                # Secret management
โ”‚   โ”œโ”€โ”€ manager.py         # Secret distribution (fault-tolerant)
โ”‚   โ”œโ”€โ”€ add.py             # Secret distribution
โ”‚   โ”œโ”€โ”€ remove.py          # Secret removal
โ”‚   โ””โ”€โ”€ list.py            # Secret listing
โ”œโ”€โ”€ automation/             # Automation & scheduling
โ”‚   โ”œโ”€โ”€ scheduler.py       # Cron job management
โ”‚   โ””โ”€โ”€ batch.py           # Batch processing
โ””โ”€โ”€ config/                 # Configuration system
    โ”œโ”€โ”€ loader.py          # Configuration loading
    โ”œโ”€โ”€ validator.py       # Validation logic
    โ””โ”€โ”€ generator.py       # Config generation

Contributing

# Clone and setup development environment
git clone https://github.com/hugo-valle/classdock.git
cd classdock

# Install with Poetry
poetry install
poetry shell

# Run tests
poetry run pytest tests/ -v

# Test CLI functionality
poetry run classdock --help

# Format code
poetry run black classdock/
poetry run isort classdock/

# Type checking
poetry run mypy classdock/

# Create feature branch
git checkout -b feature/new-feature

Testing

The project includes comprehensive testing with professional-grade coverage:

  • 70+ tests across all modules with 100% pass rate
  • Unit tests for individual components with proper mocking
  • Integration tests for workflow validation and API interactions
  • CLI tests for command-line interface with legacy compatibility
  • Error handling tests for GitHub API resilience and retry logic
  • Comprehensive mocking for reliable test execution without external dependencies
# Run all tests
poetry run pytest tests/ -v

# Run specific test categories
poetry run pytest tests/test_assignments.py -v
poetry run pytest tests/test_cli.py -v
poetry run pytest tests/test_github_exceptions.py -v  # New error handling tests

# Test with coverage
poetry run pytest tests/ --cov=classdock

# Test error handling specifically
poetry run pytest tests/test_github_exceptions.py -v --tb=short

Test Categories

  • Module Tests (44 tests) - Core functionality across all components
  • Error Handling Tests (26 tests) - GitHub API resilience and retry mechanisms
  • CLI Tests (16 tests) - Command-line interface and backward compatibility
  • Integration Tests - End-to-end workflow validation

๐Ÿ“š Documentation

Key Resources

Technical Documentation

  • Error Handling System - Comprehensive GitHub API error management with retry logic
  • CLI Design Patterns - Modular architecture with backward compatibility
  • Testing Framework - Professional test suite with mocking and coverage
  • Configuration Management - Flexible, hierarchical configuration system
  • Security Practices - Secure credential handling and validation patterns

Version Information

  • Current Version: 3.1.1b0 (Beta release with GitHub API integration and comprehensive testing)
  • Python Support: 3.10, 3.11, 3.12
  • Package Distribution: PyPI with automated CI/CD
  • Release Cycle: Semantic versioning with PEP 440 compliant identifiers
  • Versioning Strategy: Development Documentation

Recent Improvements (v3.1.1b0)

  • ๐ŸŽฏ Universal CLI Options - All commands support --help, --verbose, --dry-run
  • ๐Ÿ—๏ธ CLI Modernization - Complete Typer-based architecture with consistent UX
  • ๐Ÿ“ Legacy Preservation - Scripts moved to scripts_legacy/ for backward compatibility
  • ๐Ÿ”„ Workflow Consolidation - Eliminated duplicate testing, enhanced CI/CD pipeline
  • ๐Ÿงช Enhanced Testing - 496+ comprehensive tests with consolidated coverage reporting
  • ๐Ÿ“š Documentation Updates - Complete modernization documentation across all resources
  • ๏ฟฝ Beta Release - Ready for broader community testing and feedback

๐Ÿ†˜ Support

๐Ÿ“œ License

MIT License - see LICENSE file for details.


ClassDock - Modern Python automation for GitHub Classroom assignment management.

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

classdock-0.1.0.tar.gz (174.3 kB view details)

Uploaded Source

Built Distribution

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

classdock-0.1.0-py3-none-any.whl (205.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: classdock-0.1.0.tar.gz
  • Upload date:
  • Size: 174.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.4 CPython/3.12.4 Darwin/25.2.0

File hashes

Hashes for classdock-0.1.0.tar.gz
Algorithm Hash digest
SHA256 71c9cf83255705564bcc8d21a060fde8e6766215922082570c53f5eeccf3732b
MD5 120fe33a97531fcc043d5587bed9ed04
BLAKE2b-256 0d9c71471ed7df88476bafc2d024a72d5317f599f1c642e911f1d528595004e2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: classdock-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 205.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.4 CPython/3.12.4 Darwin/25.2.0

File hashes

Hashes for classdock-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d2e26bcf8976619ed2747d0b0317ed3128c418e75e55db295ac34c6a5e1f1fd8
MD5 1a148d503eead331b993167c39334a90
BLAKE2b-256 0ff16f4942af8c2cbf275995070658553d704987b3f06d4d05ea6ac8593983a3

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