You can use this as a starting point for your Bash/shell project with:
- Unit testing
- Code Coverage (100 %)
- Pre-commit:
- shfmt (Auto-formatter)
- Shellcheck
- Continuous Integration (GitLab CI)
That way, you start your project in a clean, tested environment.
The main code can be ran with:
src/main.sh
Put your unit test files (with extension .bats) in folder: /test/
(Re)-install the required submodules with:
chmod +x install-bats-libs.sh
./install-bats-libs.sh
Install:
sudo gem install bats
sudo gem install bashcov
sudo apt install shfmt -y
pre-commit install
pre-commit autoupdate
Run pre-commit with:
pre-commit run --all
Run the tests with:
bats test
If you want to run particular tests, you could use the test.sh
file:
chmod +x test.sh
./test.sh
bashcov bats test
- Include bash code coverage in GitLab CI.
- Add additional (relevant) pre-commit hooks.
- Develop Bash documentation checks here, and add them to this pre-commit.