This document outlines the comprehensive multi-layered testing approach implemented for the github2gerrit repository.
- Purpose: Validate bash script functionality and URL parsing logic
- Runtime: 3 minutes
- Components:
- Shellcheck validation for all
.shfiles - Unit tests for
gerrit_query_parse.shfunctions:extract_hostname()- Parse Gerrit hostnames from URLsextract_change_number()- Extract change numbers from URLsextract_project()- Extract project names from URLs
- Input validation testing (malformed URLs, missing arguments)
- Edge case handling (empty strings, invalid formats)
- Shellcheck validation for all
- Purpose: Cross-platform compatibility testing
- Runtime: 5 minutes per matrix combination
- Matrix Dimensions:
- OS:
ubuntu-latest,ubuntu-22.04 - Action Type:
composite,reusable
- OS:
- Test Cases:
- Dependency installation (git-review, jq, python3)
- Conflicting input validation (
SUBMIT_SINGLE_COMMITS+USE_PR_AS_COMMIT) - Missing
.gitreviewfile handling - Boolean input validation for workflow calls
- Purpose: End-to-end workflow testing with mock data
- Runtime: 8 minutes
- Test Scenarios:
- Valid composite action execution with mock SSH environment
- Malformed input handling (invalid booleans, empty required fields)
- SSH connection timeout testing
.gitreviewparsing edge cases- Change-ID format validation
- JSON response parsing with jq
- Purpose: Real Gerrit connectivity testing (when secrets available)
- Runtime: 10 minutes
- Conditions: Only runs in
lfit/github2gerritrepository - Features:
- Uses actual repository secrets and variables
- Tests real SSH connections (with failure tolerance)
- Validates complete workflow execution
- Generates test results summary
tests/
├── test-functions.sh # Unit test runner
├── fixtures/
│ ├── sample-gerrit-response.json # Mock Gerrit API response
│ └── sample-gitreview # Sample .gitreview configuration
└── ...
- Continue-on-Error: All potentially failing tests use
continue-on-error: true - Timeout Protection: Every job has explicit timeout limits
- Mock Data: Uses realistic test data without external dependencies
- Input Validation: Comprehensive testing of all input combinations
- Cross-Platform: Matrix testing across Ubuntu LTS versions
# Run shell script unit tests
./tests/test-functions.sh
# Run shellcheck
shellcheck gerrit_query_parse.sh
# Validate YAML syntax
python3 -c "import yaml; yaml.safe_load(open('.github/workflows/testing.yaml'))"Tests run automatically on:
- Push to
mainbranch - Pull requests to
mainbranch - Manual trigger via
workflow_dispatch
- ✅ Input validation (conflicting options)
- ✅ Dependency installation
- ✅
.gitreviewfile handling - ✅ SSH environment setup
- ✅ Git operations (clone, commit, review)
- ✅ Error conditions
- ✅ Workflow input validation
- ✅ Boolean parameter handling
- ✅ Secret management
- ✅ Environment variable setup
- ✅ Concurrency control
- ✅ URL parsing functions
- ✅ JSON response handling
- ✅ SSH command construction
- ✅ Error handling and exit codes
- ✅ Input sanitization
All tests must pass before:
- Merging pull requests
- Creating releases
- Deploying to production environments
The testing workflow integrates with:
- Pre-commit hooks: Syntax and quality validation
- GitHub Actions: Automated testing on every change
- Security scanning: Credential and injection detection
- Code quality tools: shellcheck, yamllint, actionlint
Planned testing improvements:
- Performance benchmarking for large repositories
- Integration with real Gerrit test instances
- Automated dependency vulnerability scanning
- Extended cross-platform support (macOS, Windows)