-
-
Notifications
You must be signed in to change notification settings - Fork 38
Description
Summary
Implement comprehensive validation tests for setup-chromedriver shell scripts (setup-chromedriver.sh and setup-chromedriver.ps1) with an abstraction layer that prepares for future TypeScript integration. This will enable unified validation of Chrome paths, versions, architectures, download URLs, actual binary hash verification, and enhanced CI/CD workflows.
Problem
Current situation:
- Insufficient Testing: Complex logic in shell scripts lacks comprehensive test coverage
- Missing Validation: No verification that downloaded binaries are correct
- Future Extensibility: Design doesn't prepare for TypeScript migration
- Platform-Specific Fragmentation: Platform-specific logic is scattered across different scripts
- Limited CI/CD Coverage: Current workflows don't validate binary integrity or cross-platform equivalence
Both scripts perform critical operations without validation mechanisms:
- Chrome installation path detection
- Chrome version detection and API selection (Chrome 115 boundary)
- Platform/architecture mapping
- Download URL generation
- ChromeDriver binary integrity
Proposed Solution
1. Abstraction Layer Implementation
Define a common ChromeDriverInstaller interface supporting both current shell scripts and future TypeScript implementation:
interface ChromeDriverInstaller {
detectChromePath(): Promise<string>;
getChromeVersion(chromePath: string): Promise<string>;
detectPlatform(): Promise<Platform>;
resolveDownloadUrl(version: string, platform: Platform): Promise<string>;
downloadChromeDriver(url: string, destination: string): Promise<void>;
calculateHash(filePath: string): Promise<string>;
install(options?: InstallOptions): Promise<InstallResult>;
}2. Adapter Pattern Implementation
BashScriptAdapter: Wrapper for setup-chromedriver.shPowerShellAdapter: Wrapper for setup-chromedriver.ps1TypeScriptAdapter: Wrapper for future setup-chromedriver.ts
3. Actual Binary Verification
Rigorous validation through hash comparison:
- Get expected URL from Chrome for Testing API
- Direct download from that URL (expected value)
- Execute script to download (actual value)
- Compare SHA256 hashes of both binaries
4. Comprehensive Validation Tests
- Chrome Path Validation: Standard paths for each platform
- Version Validation: Exact match, fallback, API selection logic
- Architecture Validation: Platform-specific mappings
- URL Validation: Legacy API vs Chrome for Testing API
- Hash Validation: Actual binary integrity verification
- Cross-Platform Equivalence: Unified behavior verification across all platforms
5. Enhanced GitHub Actions Workflows
New Workflow: comprehensive-validation.yml
- Multi-platform testing: Ubuntu, macOS, Windows across multiple versions
- Hash verification jobs: Binary integrity validation for each platform
- Performance testing: Download speed and installation time benchmarks
- Cross-adapter equivalence: Bash vs PowerShell result comparison
Existing Workflow Enhancements
test.ymlexpansion: Integration of new test suites, coverage reportingwindows.ymlenhancement: PowerShell-specific testing, Windows hash verification- CI/CD integration: Automated test result reporting, failure diagnostics
Benefits
- Gradual TypeScript Migration: Smooth transition path from shell scripts to TypeScript
- Actual Binary Verification: Guarantee that downloaded files are correct
- Unified Testing: All implementations share the same interface and tests
- Type Safety: Future safety through TypeScript's type system
- Cross-Platform Consistency: Uniform behavior across all platforms
- Enhanced CI/CD Integration: Comprehensive automated testing with binary verification
- Performance Monitoring: Automated detection of performance regressions
- Quality Assurance: 95%+ test coverage with real-world validation
Acceptance Criteria
Core Implementation
- Implement
ChromeDriverInstallerinterface - Chrome path validation tests (Linux/macOS/Windows)
- Chrome version detection and API selection logic tests
- Architecture mapping validation (linux64, mac-x64, mac-arm64, win32)
- Download URL validation tests (legacy/new API)
- Actual binary hash comparison tests
- Error handling tests (network failures, invalid versions, etc.)
- Cross-platform equivalence tests
GitHub Actions Integration
- Create
comprehensive-validation.ymlworkflow - Enhance
test.ymlwith new test suites and coverage reporting - Enhance
windows.ymlwith PowerShell-specific testing - Implement hash verification jobs for all platforms
- Add performance benchmarking and regression detection
- Integrate test result artifacts and failure diagnostics
Quality & Documentation
- Design compatible with future TypeScript implementation
- Achieve 95%+ test coverage
- Automated testing across all platforms in CI/CD
- Documentation updates for test implementation
- Performance monitoring and alerting
Technical Notes
Implementation Architecture
- Abstraction Layer: Unified implementation through common interface
- Adapter Pattern: Wrappers for each implementation (Bash/PowerShell/TypeScript)
- Hash Verification: SHA256-based actual binary integrity verification
- Mock Support: External dependency mocking for test environments
- CI/CD Integration: Multi-platform validation with performance monitoring
Gradual Migration Strategy
- Phase 1: Shell scripts + adapter tests + GitHub Actions enhancement
- Phase 2: Partial TypeScript implementation
- Phase 3: Complete TypeScript migration (maintaining backward compatibility)
Test Coverage Areas
- Platform-specific behavior (Linux/macOS vs Windows)
- Chrome for Testing API network requests
- Chrome version detection accuracy
- Fallback mechanism behavior
- Proper error handling under various conditions
- Binary integrity verification
- Cross-platform equivalence validation
- Performance benchmarking
GitHub Actions Strategy
- Comprehensive Validation: New dedicated workflow for thorough testing
- Enhanced Existing Workflows: Gradual integration of new capabilities
- Multi-Platform Matrix: Testing across Ubuntu, macOS, Windows variants
- Performance Monitoring: Automated benchmarking and regression detection
- Quality Gates: Coverage thresholds and test success requirements
This issue addresses both current shell script quality assurance and establishes the foundation for future TypeScript integration with robust CI/CD validation.
File Structure
__tests__/
├── lib/
│ ├── ChromeDriverInstallerInterface.ts # Common interface
│ ├── adapters/
│ │ ├── BashScriptAdapter.ts # .sh wrapper
│ │ ├── PowerShellAdapter.ts # .ps1 wrapper
│ │ └── TypeScriptAdapter.ts # .ts wrapper (future)
│ ├── core/
│ │ ├── HashValidator.ts # Hash verification
│ │ ├── DownloadManager.ts # Download processing
│ │ ├── PlatformDetector.ts # Platform detection
│ │ └── VersionResolver.ts # Version resolution
│ └── utils/
│ ├── TestEnvironment.ts # Test environment
│ ├── MockServer.ts # Mock server
│ └── TestData.ts # Test data management
├── unit/
│ ├── chrome-detection.test.ts # Chrome path detection
│ ├── version-resolution.test.ts # Version resolution logic
│ ├── hash-validation.test.ts # Hash verification
│ └── platform-mapping.test.ts # Platform mapping
├── integration/
│ ├── installer.test.ts # End-to-end testing
│ ├── cross-platform.test.ts # Cross-platform validation
│ └── performance.test.ts # Performance benchmarks
├── equivalence/
│ └── cross-adapter.test.ts # Adapter equivalence
└── fixtures/
├── test-binaries/ # Test binary files
└── api-responses/ # Mock API responses
.github/workflows/
├── comprehensive-validation.yml # New: Comprehensive testing
├── test.yml # Enhanced: Existing Unix testing
├── windows.yml # Enhanced: Existing Windows testing
├── claude.yml # Maintained: Claude integration
└── claude-code-review.yml # Maintained: Code review
Implementation Priority
High Priority - Essential for meeting Issue #408 acceptance criteria
Complexity: Medium-High
- Cross-platform testing coordination is technically complex
- Hash verification requires careful binary comparison
- Adapter pattern implementation needs thorough design
- GitHub Actions workflow enhancement requires CI/CD expertise
- Clear implementation guidance available from existing patterns
Estimated Effort: 7.5-11.5 days
- Abstraction layer design and implementation: 2-3 days
- Adapter implementations: 2-3 days
- Comprehensive test suite: 2-3 days
- GitHub Actions workflow enhancement: 1-2 days
- Error handling and quality assurance: 1 day
- Documentation and future preparation: 0.5 day
Implementation Phases
Phase 1: Abstraction Layer (2-3 days)
- Common interface definition
- Adapter pattern implementation
- Basic test infrastructure
Phase 2: Hash Verification (1-2 days)
- SHA256 validation system
- Chrome for Testing API integration
- Binary comparison functionality
Phase 3: Comprehensive Testing (2-3 days)
- Unit tests for all components
- Integration and cross-platform tests
- Performance benchmarking
Phase 4: GitHub Actions Enhancement (1-2 days)
- New comprehensive validation workflow
- Existing workflow enhancements
- CI/CD integration features
Phase 5: Quality Assurance (1 day)
- Error handling robustness
- Security enhancements
- Performance optimization
Phase 6: Documentation (0.5 day)
- Updated documentation
- Migration preparation
- Implementation guides
Next Steps
- Create abstraction layer:
ChromeDriverInstallerInterface.ts - Implement adapters: Bash and PowerShell script wrappers
- Build test suite: Comprehensive validation tests
- Enhance GitHub Actions: Multi-platform automated testing with hash verification
- Documentation: Update README with test execution procedures and CI/CD integration