Skip to content

Commit 0b9eaa7

Browse files
authored
Merge pull request #6 from conjurinc/oss_requirements_3
Create CONTRIBUTING.md
2 parents 70ed3c0 + 5cf9dca commit 0b9eaa7

File tree

2 files changed

+57
-54
lines changed

2 files changed

+57
-54
lines changed

CONTRIBUTING.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Contributing
2+
Thanks for your interest in bash-lib. Before contributing, please take a
3+
moment to read and sign our [Contributor
4+
Agreement](CyberArk_Open_Source_Contributor_Agreement.pdf). This provides
5+
patent protection for all bash-lib users and allows CyberArk to
6+
enforce its license terms. Please email a signed copy to <a
7+
8+
9+
Contributed bash functions are most welcome! The more we share the less we
10+
duplicate each other. In order to keep this repo tidy, every function must be
11+
documented in the readme and tested, the lint scripts enforce these rules.
12+
13+
1. Add the libraries or functions that you need
14+
2. Add BATS tests for all new top level functions
15+
3. Add descriptions for each function to the contents table in this readme
16+
4. Run ./run-tests to ensure all tests pass before submitting
17+
5. Create a PR
18+
6. Wait for review
19+
20+
## Style Guide
21+
Follow the [google shell style guide](https://google.github.io/styleguide/shell.xml#Naming_Conventions).
22+
TL;DR:
23+
1. Use snake_case function and variable names
24+
1. Use `function` when declaring functions.
25+
1. Don't use .sh extensions
26+
27+
## Testing
28+
Tests are written using [BATS](https://github.com/bats-core/bats). Each lib has a `lib-name.bats` file in [tests-for-this-repo](/tests-for-this-repo).
29+
Asserts are provided by [bats-assert-1](https://github.com/jasonkarns/bats-assert-1). Asserts provide useful debugging output when the assertion fails, eg expected x got y.
30+
31+
Example:
32+
```bash
33+
# source support and assert libraries
34+
. "${BASH_LIB_DIR}/test-utils/bats-support/load.bash"
35+
. "${BASH_LIB_DIR}/test-utils/bats-assert-1/load.bash"
36+
37+
# source the library under test
38+
. "${BASH_LIB_DIR}/git/lib"
39+
40+
# define a test that calls a library function
41+
@test "it does the thing" {
42+
some_prep_work
43+
# run is a wrapper that catches failures so that assertsions can be run,
44+
# otherwise the test would immediately fail.
45+
run does_the_thing
46+
assert_success
47+
assert_output "thing done"
48+
}
49+
```
50+
51+
Test fixtures should go in /tests-for-this-repo/[fixtures](tests-for-this-repo/fixtures)/lib-name.

README.md

Lines changed: 6 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@ files within it's directory.
7676
├── run-tests # top level test script, executes all tests
7777
├── secrets.yml # secrets required for executing tests
7878
├── test-utils
79-
│ ├── bats # subtree
80-
│ ├── bats-assert-1 # subtree
81-
│ ├── bats-support # subtree
79+
│ ├── bats # git subtree
80+
│ ├── bats-assert-1 # git subtree
81+
│ ├── bats-support # git subtree
8282
│ ├── lib
8383
│ └── tap2junit
8484
└── tests-for-this-repo
@@ -90,14 +90,8 @@ files within it's directory.
9090
├── python-lint # supporting files for python lint
9191
├── run-bats-tests # script to run bats tests
9292
├── run-gitleaks # script to check for leaked secrets
93-
└── run-python-lint # script to run python lint
93+
└── run-python-lint # script to run python lint
9494
```
95-
## Style Guide
96-
Follow the [google shell style guide](https://google.github.io/styleguide/shell.xml#Naming_Conventions).
97-
TL;DR:
98-
1. Use snake_case function and variable names
99-
1. Use `function` when declaring functions.
100-
10195

10296
## Contents
10397

@@ -179,50 +173,8 @@ TL;DR:
179173
</tbody>
180174
</table>
181175

182-
# Contibuting
183-
Thanks for your interest in bash-lib. Before contributing, please take a
184-
moment to read and sign our [Contributor
185-
Agreement](CyberArk_Open_Source_Contributor_Agreement.pdf). This provides
186-
patent protection for all Secretless Broker users and allows CyberArk to
187-
enforce its license terms. Please email a signed copy to <a
188-
189-
190-
Contributed bash functions are most welcome! The more we share the less we
191-
duplicate each other. In order to keep this repo tidy, every function must be
192-
documented in the readme and tested, the lint scripts enforce these rules.
193-
194-
1. Add the libraries or functions that you need
195-
1. Add BATS tests for all new top level functions
196-
1. Add descriptions for each function to the contents table in this readme
197-
1. Run ./run-tests to ensure all tests pass before submitting
198-
1. Create a PR
199-
1. Wait for review
200-
201-
## Testing
202-
Tests are written using [BATS](https://github.com/bats-core/bats). Each lib has a `lib-name.bats` file in [tests-for-this-repo](/tests-for-this-repo).
203-
Asserts are provided by [bats-assert-1](https://github.com/jasonkarns/bats-assert-1). Asserts provide useful debugging output when the assertion fails, eg expected x got y.
204-
205-
Example:
206-
```bash
207-
# source support and assert libraries
208-
. "${BASH_LIB_DIR}/test-utils/bats-support/load.bash"
209-
. "${BASH_LIB_DIR}/test-utils/bats-assert-1/load.bash"
210-
211-
# source the library under test
212-
. "${BASH_LIB_DIR}/git/lib"
213-
214-
# define a test that calls a library function
215-
@test "it does the thing" {
216-
some_prep_work
217-
# run is a wrapper that catches failures so that assertsions can be run,
218-
# otherwise the test would immediately fail.
219-
run does_the_thing
220-
assert_success
221-
assert_output "thing done"
222-
}
223-
```
224-
225-
Test fixtures should go in /tests-for-this-repo/[fixtures](tests-for-this-repo/fixtures)/lib-name.
176+
# Contributing
177+
For further informaiton on contributing, style & testing, please see [CONTRIBUTING.md](CONTRIBUTING.md)
226178

227179
# Maintainers
228180
* [Hugh Saunders](github.com/hughsaunders)

0 commit comments

Comments
 (0)