Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Repository template with Shell/Bash unit testing and pre-commit.

License

Notifications You must be signed in to change notification settings

HiveMinds/Bash-Project-Template

Repository files navigation

Unit tested Bash project template with Pre-commit

Travis Build Status License: AGPL v3

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.

Usage

The main code can be ran with:

src/main.sh

Testing

Put your unit test files (with extension .bats) in folder: /test/

Prerequisites

(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

Pre-commit

Run pre-commit with:

pre-commit run --all

Tests

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

Code coverage

bashcov bats test

How to help

  • 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.

About

Repository template with Shell/Bash unit testing and pre-commit.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

AltStyle によって変換されたページ (->オリジナル) /