Welcome! This guide will help you contribute to the bashunit testing framework.
- Fork and clone the repository
- Set up your development environment
- Find an issue to work on (good first issues)
- Make your changes following our guidelines
- Submit a Pull Request
This project follows a Contributor Code of Conduct. By participating, you agree to abide by its terms.
Contributions are licensed under the MIT License.
- Bash 3.0+
- Git
- Make
- ShellCheck
- editorconfig-checker
# Clone and setup
git clone https://github.com/YOUR_USERNAME/bashunit.git
cd bashunit
git remote add upstream https://github.com/TypedDevs/bashunit.git
# Install pre-commit hooks
make pre_commit/install
# Verify setup
make test && make sa && make lintFor documentation changes:
nvm use # Uses .nvmrc version
npm ci
npm run docs:dev- Good first issues for new contributors
- Bug reports
- Enhancement requests
- Documentation issues
Create descriptive branch names:
# For new features
git checkout -b feat/add-new-assertion
# For bug fixes
git checkout -b fix/resolve-test-timeout
# For documentation
git checkout -b doc/improve-installation-guide
# For refactoring
git checkout -b ref/simplify-runner-logicUse Conventional Commits:
<type>(<scope>): <description>
Types: feat, fix, docs, style, refactor, test, chore
Examples:
feat(assert): add assert_file_contains function
fix(runner): resolve test timeout in parallel execution
docs(readme): update installation instructions- Keep commits atomic (one logical change)
- Reference issues with "Closes #123"
- Set up git identity:
git config user.name "Your Name" git config user.email "your.email@example.com"
When reporting bugs, please include:
**Description**
A clear description of what the bug is.
**To Reproduce**
Steps to reproduce the behavior:
1. Run command '...'
2. With these test files '...'
3. See error
**Expected Behavior**
What you expected to happen.
**Actual Behavior**
What actually happened.
**Environment**
- OS: [e.g., macOS 12.0, Ubuntu 20.04]
- Bash version: [e.g., 5.1.8]
- bashunit version: [e.g., 0.24.0]
**Additional Context**
- Test files (if applicable)
- Error messages
- Screenshots (if helpful)Please post code and output as text using proper markdown formatting. Screenshots are welcome for additional context.
- Search existing issues to avoid duplicates
- For significant changes, create an issue first to discuss your approach
- Keep PRs focused (one feature/fix per PR)
# Update your fork
git checkout main
git pull upstream main
git push origin main
# Create feature branch
git checkout -b feature/your-feature-name
# Make changes, then test
make test && make sa && make lint
# Push and create PR
git push origin feature/your-feature-nameThen create the PR on GitHub, fill out the template, and link related issues.
- Automated checks - GitHub Actions will run tests and code quality checks
- Review process - Maintainers will review your code and provide feedback
- Address feedback - Make requested changes and push updates
- Approval and merge - Once approved, maintainers will merge your PR
- Be patient - Reviews take time, especially for complex changes
- Be responsive - Address feedback promptly
- Be collaborative - Work with reviewers to improve the code
- Learn from feedback - Use reviews as learning opportunities
Documentation is built with VitePress.
nvm use
npm ci
npm run docs:dev # Start dev server
npm run docs:build # Build and testGuidelines: Keep it simple, include examples, test all code examples.
cp .env.example .envEdit .env with your settings.
make test # Full test suite
./bashunit tests/**/*_test.sh # Direct
make test/watch # With file watchingGuidelines: Write tests first (TDD), test edge cases, use descriptive names, test on multiple environments.
Supported: Linux (Ubuntu, Alpine), macOS, Windows (WSL/Git Bash)
# Docker testing
make docker/alpine
make docker/ubuntu
# NixOS
nix-shell --pure --run "./bashunit --simple --parallel"bashunit supports Bash 3.0+. A dedicated Dockerfile is provided at local/Dockerfile.bash3 to compile Bash 3.0 from source for compatibility testing. This is the same setup used in CI.
# Build the Bash 3.0 image
docker build -t bashunit-bash3 -f local/Dockerfile.bash3 .
# Run all tests under Bash 3.0
docker run --rm -v "$(pwd)":/bashunit -w /bashunit bashunit-bash3 \
/opt/bash-3.0/bin/bash ./bashunit tests/
# Run tests in parallel
docker run --rm -v "$(pwd)":/bashunit -w /bashunit bashunit-bash3 \
/opt/bash-3.0/bin/bash ./bashunit --parallel tests/
# Open an interactive Bash 3.0 shell for debugging
docker run --rm -it -v "$(pwd)":/bashunit -w /bashunit bashunit-bash3 \
/opt/bash-3.0/bin/bash- Create files ending with
_test.sh - Use descriptive function names:
test_should_return_expected_value() - Follow Arrange/Act/Assert pattern
- Use appropriate assertions:
assert_equals,assert_contains,assert_matches,assert_exit_code - Test success and failure cases
- Place in correct directory:
tests/unit/,tests/functional/,tests/acceptance/
- Follow Google Shell Style Guide
- Use 2 spaces (no tabs)
- Add proper error handling with
set -euo pipefail - Use clear variable and function names
- Comment complex logic sparingly
ShellCheck (install):
make sa # Recommended
find . -name "*.sh" -not -path "./local/*" -exec shellcheck -xC {} \; # DirectEditorConfig Checker (install):
make lint # Recommended
editorconfig-checker # DirectPre-commit hooks (recommended):
make pre_commit/install-
make sapasses -
make lintpasses -
make testpasses - Functions documented
- Error handling robust
##
# Brief description
# Arguments: $1 - first arg, $2 - second arg (optional)
# Returns: 0 on success, 1 on failure
# Example: my_function "input" "optional"
##
function my_function() {
local input="$1"
local optional="${2:-default}"
# Implementation
}- New contributors: Good first issues
- Questions: GitHub Discussions
- Documentation: bashunit.typeddevs.com
- Bug reports: Create an issue
- Feature requests: Create an issue
For significant changes (API changes, major features, breaking changes), create an ADR using these templates.
Maintainers handle releases following Semantic Versioning.
Ready to contribute?
Thank you for contributing to bashunit!