Skip to content

feat: enhance DevContainer for development-focused workflow#17

Open
agramms wants to merge 2 commits intomainfrom
feat/improve-devcontainer-development-focus
Open

feat: enhance DevContainer for development-focused workflow#17
agramms wants to merge 2 commits intomainfrom
feat/improve-devcontainer-development-focus

Conversation

@agramms
Copy link
Copy Markdown
Owner

@agramms agramms commented Sep 24, 2025

Summary

This PR restructures the development environment to provide a clear separation between rich development experience and clean CI testing, implementing the philosophy that DevContainer = Development, CI = Clean Tests.

Key Improvements

🏗️ Development Environment

  • Enhanced DevContainer Configuration: Pure development focus with full service stack
  • Rich VS Code Extensions: Added test explorer, prettier, hex editor, and development tools
  • Development Gems: Added pry, pry-byebug, yard for enhanced debugging and documentation
  • Service Integration: Redis, PostgreSQL, DynamoDB Local, and JDPI Mock Server available
  • Environment Detection: Clear DEV_CONTAINER and DEVELOPMENT_MODE variables

🧪 CI Test Safety & Isolation

  • Automatic CI Detection: New CIEnvironment module detects CI vs development automatically
  • Service URL Cleaning: Removes external service URLs in CI environments automatically
  • Forced Memory Adapters: Always uses in-memory storage in CI regardless of configuration
  • Safety Logging: Comprehensive logging of CI safety measures applied
  • Zero Dependencies: Impossible for CI tests to accidentally use external services

🚀 Enhanced Development Experience

  • Development Setup Script: Rich environment setup with service health checks
  • Flexible Testing: Choose between fast mocks or real service integration
  • Service Health Checks: Built-in tools to verify all services are running
  • Integration Testing: Optional real Redis/PostgreSQL/DynamoDB testing in development

Architecture Philosophy

Development Container = Rich services + debugging tools + integration testing
CI Environment       = Pure memory + mocks + fast execution + no dependencies

Testing Modes

CI Testing (Automatic)

  • ✅ Uses memory adapters and mocks exclusively
  • ✅ No external services required
  • ✅ Fast execution (~30 seconds)
  • ✅ Automatically activated in CI environments
  • ✅ Service URL cleaning and safety measures

Development Testing (DevContainer)

  • ✅ Optional real service integration
  • ✅ Rich debugging capabilities with pry and byebug
  • ✅ Full service stack available
  • ✅ Service health monitoring
  • ✅ Integration testing with TEST_ADAPTER=all

Usage Examples

# Default: Fast tests with mocks (works everywhere)
bundle exec rake test

# Development: Test with real Redis
TEST_ADAPTER=redis bundle exec rake test

# Development: Test with all services
TEST_ADAPTER=all bundle exec rake test

# CI: Always uses memory regardless of TEST_ADAPTER setting
CI=true bundle exec rake test  # Forces memory adapters

Safety Features

Automatic Environment Detection

  • Detects CI=true, GITHUB_ACTIONS=true, DEV_CONTAINER=true, DEVELOPMENT_MODE=true
  • Automatically applies appropriate configuration for each environment
  • Logs all safety measures taken in CI environments

Service URL Protection

  • Removes external service URLs in CI automatically
  • Forces TEST_ADAPTER=memory in CI regardless of configuration
  • Prevents accidental external service usage in CI

Development Flexibility

  • Rich service integration available when explicitly requested
  • Health checks for all development services
  • Optional integration testing with real services

Files Changed

Configuration

  • .devcontainer/devcontainer.json - Enhanced with development tools and extensions
  • .devcontainer/Dockerfile.dev - Added development gems and environment setup

Test Safety

  • test/test_helper.rb - Added CIEnvironment module for automatic CI detection and safety
  • Enhanced ServiceConfiguration with CI-aware adapter selection

Development Tools

  • scripts/setup-dev.sh - Enhanced development setup with service health checks
  • CLAUDE.md - Comprehensive documentation of development vs CI philosophy

Docker Infrastructure

  • All Docker configurations and services already implemented in previous commits

Benefits

Clear Mental Model: Developers know DevContainer = development, CI = clean tests
Fast CI: Zero infrastructure dependencies, pure memory/mocks
Rich Development: Full service integration available when needed
Automatic Safety: Impossible for CI tests to accidentally use external services
Developer Flexibility: Choose appropriate testing level for the task
No Breaking Changes: Existing test suite continues to work perfectly

Test Plan

  • Verify CI safety features activate automatically in CI environment
  • Confirm memory adapters are forced in CI regardless of TEST_ADAPTER
  • Test service URL cleaning in CI environments
  • Validate development container provides rich service integration
  • Ensure existing test suite passes in both environments
  • Verify service health checks work in development container

🤖 Generated with Claude Code

This commit restructures the development environment to provide a clear
separation between rich development experience and clean CI testing.

## Key Changes

### DevContainer Enhancements
- Enhanced DevContainer configuration for pure development focus
- Added development-specific VS Code extensions and tools
- Improved Dockerfile with additional development gems (pry, yard, etc.)
- Clear environment variables to distinguish development vs CI modes

### CI Test Safety & Isolation
- Added CIEnvironment module for automatic CI detection
- Implemented automatic service URL cleaning in CI environments
- Force memory adapters in CI regardless of TEST_ADAPTER setting
- Added comprehensive logging of CI safety measures
- Ensured tests can never accidentally use external services in CI

### Development Experience Improvements
- Enhanced setup script with development-specific features
- Clear distinction between development and CI commands
- Rich service integration available in development (Redis, PostgreSQL, DynamoDB, Mock Server)
- Service health checks and integration testing capabilities

### Documentation Updates
- Comprehensive CLAUDE.md updates explaining development vs CI philosophy
- Clear usage patterns for different testing scenarios
- Environment-aware debugging tips and best practices
- Development container feature documentation

## Benefits Achieved

✅ **Simple Mental Model**: DevContainer = development, CI = clean tests
✅ **Rich Development Experience**: Full services and tooling for developers
✅ **Fast CI Tests**: No infrastructure dependencies, pure memory/mocks
✅ **Automatic Safety**: Impossible for CI tests to use external services
✅ **Flexibility**: Choose appropriate testing level for the task

## Testing Philosophy

```
Development Container = Rich services + debugging tools + integration testing
CI Environment       = Pure memory + mocks + fast execution + no dependencies
```

This approach ensures developers have powerful tools while maintaining fast,
reliable CI execution with zero infrastructure dependencies.
- Replace ENV[var] with ENV.fetch(var, nil) for better style
- Ensures consistent environment variable access patterns
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant