Skip to content

Latest commit

 

History

History
51 lines (41 loc) · 2.09 KB

CONTRIBUTING.md

File metadata and controls

51 lines (41 loc) · 2.09 KB

Contributing

Thanks for your interest in bash-lib!

For general contribution and community guidelines, please see the community repo. In particular, before contributing please review our contributor licensing guide to ensure your contribution is compliant with our contributor license agreements.

Contributed bash functions are most welcome! The more we share the less we duplicate each other. In order to keep this repo tidy, every function must be documented in the readme and tested, the lint scripts enforce these rules.

  1. Add the libraries or functions that you need
  2. Add BATS tests for all new top level functions
  3. Add descriptions for each function to the contents table in this readme
  4. Run ./run-tests to ensure all tests pass before submitting
  5. Create a PR
  6. Wait for review

Style Guide

Follow the google shell style guide. TL;DR:

  1. Use snake_case function and variable names
  2. Use function when declaring functions.
  3. Don't use .sh extensions

Testing

Tests are written using BATS. Each lib has a lib-name.bats file in tests-for-this-repo. Asserts are provided by bats-assert-1. Asserts provide useful debugging output when the assertion fails, eg expected x got y.

Example:

# source support and assert libraries
. "${BASH_LIB_DIR}/test-utils/bats-support/load.bash"
. "${BASH_LIB_DIR}/test-utils/bats-assert-1/load.bash"

# source the library under test
. "${BASH_LIB_DIR}/git/lib"

# define a test that calls a library function
@test "it does the thing" {
  some_prep_work
  # run is a wrapper that catches failures so that assertsions can be run,
  # otherwise the test would immediately fail.
  run does_the_thing
  assert_success
  assert_output "thing done"
}

Test fixtures should go in /tests-for-this-repo/fixtures/lib-name.