-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
33ce813
commit 0fc78ef
Showing
11 changed files
with
228 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
root = true | ||
|
||
[*] | ||
end_of_line = lf | ||
insert_final_newline = true | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
indent_style = space | ||
indent_size = 2 | ||
|
||
[**.sh] | ||
max_line_length = 120 | ||
|
||
[**.md] | ||
indent_size = 4 | ||
|
||
[{Makefile,**.mk,.git*}] | ||
indent_style = tab | ||
|
||
[{lib/*,README.md}] | ||
indent_size = unset |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
# Contributing to bashunit | ||
|
||
## We have a Code of Conduct | ||
|
||
Please note that this project is released with a [Contributor Code of Conduct](CODE_OF_CONDUCT.md). By participating in this project you agree to abide by its terms. | ||
|
||
## Any contributions you make will be under the MIT License | ||
|
||
When you submit code changes, your submissions are understood to be under the same [MIT](https://github.com/TypedDevs/bashunit/blob/main/LICENSE) that covers the project. By contributing to this project, you agree that your contributions will be licensed under its MIT. | ||
|
||
## Write bug reports with detail, background, and sample code | ||
|
||
In your bug report, please provide the following: | ||
|
||
* A quick summary and/or background | ||
* Steps to reproduce | ||
* Be specific! | ||
* Give sample code if you can. | ||
* What you expected would happen | ||
* What actually happens | ||
* Notes (possibly including why you think this might be happening, or stuff you tried that didn't work) | ||
|
||
Please post code and output as text ([using proper markup](https://guides.github.com/features/mastering-markdown/)). Additional screenshots to help contextualize behavior are ok. | ||
|
||
## Workflow for Pull Requests | ||
|
||
1. Fork/clone the repository. | ||
2. Create your branch from `main` if you plan to implement new functionality or change existing code significantly. | ||
3. Implement your change and add tests for it. | ||
4. Ensure the test suite passes. | ||
5. Ensure the code complies with our coding guidelines (see below). | ||
6. Send that pull request! | ||
|
||
Please make sure you have [set up your username and email address](https://git-scm.com/book/en/v2/Getting-Started-First-Time-Git-Setup) for use with Git. Strings such as `silly nick name <root@localhost>` looks bad in the commit history of a project. | ||
|
||
## Testing | ||
|
||
Run tests from the library: | ||
```bash | ||
# using make | ||
make test | ||
|
||
# using bashunit | ||
lib/bashunit tests | ||
``` | ||
|
||
Run the test with a watcher for development: | ||
this will require to have installed [fswatcher](https://github.com/emcrisostomo/fswatch) | ||
```bash | ||
# you have to install `watch` for your OS | ||
make test/watch | ||
``` | ||
|
||
## Coding Guidelines | ||
|
||
### ShellCheck | ||
|
||
To contribute to this repository you must have [ShellCheck](https://github.com/koalaman/shellcheck) installed on your local machine or IDE, since it is the static code analyzer that is being used in continuous integration pipelines. | ||
|
||
Installation: https://github.com/koalaman/shellcheck#installing | ||
|
||
#### Example of usage | ||
|
||
```bash | ||
# using make | ||
make sa | ||
|
||
# using ShellCheck itself | ||
shellcheck ./**/**/*.sh -C | ||
``` | ||
|
||
### editorconfig-checker | ||
|
||
To contribute to this repository, consider installing [editorconfig-checker](https://github.com/editorconfig-checker/editorconfig-checker) to check all project files regarding the `.editorconfig` to ensure we all fulfill the standard. | ||
|
||
Installation: https://github.com/editorconfig-checker/editorconfig-checker#installation | ||
|
||
To run it, use the following command: | ||
```bash | ||
# using make | ||
make lint | ||
|
||
# using editorconfig-checker itself | ||
ec -config .editorconfig | ||
``` | ||
|
||
This command will be executed on the CI to ensure the project's quality standards. | ||
|
||
#### We recommend | ||
|
||
To install the pre-commit of the project with the following command: | ||
|
||
**Please note that you will need to have ShellCheck and editorconfig-checker installed on your computer.** | ||
See above how to install in your local. | ||
|
||
```bash | ||
make pre_commit/install | ||
``` | ||
|
||
[Shell Guide](https://google.github.io/styleguide/shellguide.html#s7.2-variable-names) by Google Conventions. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
SHELL=/bin/bash | ||
|
||
-include .env | ||
|
||
STATIC_ANALYSIS_CHECKER := $(shell which shellcheck 2> /dev/null) | ||
LINTER_CHECKER := $(shell which ec 2> /dev/null) | ||
GIT_DIR = $(shell git rev-parse --git-dir 2> /dev/null) | ||
|
||
OS:= | ||
ifeq ($(OS),Windows_NT) | ||
OS +=WIN32 | ||
ifeq ($(PROCESSOR_ARCHITECTURE),AMD64) | ||
OS +=_AMD64 | ||
endif | ||
ifeq ($(PROCESSOR_ARCHITECTURE),x86) | ||
OS +=_IA32 | ||
endif | ||
else | ||
UNAME_S := $(shell uname -s) | ||
ifeq ($(UNAME_S),Linux) | ||
OS+=LINUX | ||
endif | ||
ifeq ($(UNAME_S),Darwin) | ||
OS+=OSX | ||
endif | ||
UNAME_P := $(shell uname -p) | ||
ifeq ($(UNAME_P),x86_64) | ||
OS +=_AMD64 | ||
endif | ||
ifneq ($(filter %86,$(UNAME_P)),) | ||
OS+=_IA32 | ||
endif | ||
ifneq ($(filter arm%,$(UNAME_P)),) | ||
OS+=_ARM | ||
endif | ||
endif | ||
|
||
help: | ||
@echo "" | ||
@echo "Usage: make [command]" | ||
@echo "" | ||
@echo "Commands:" | ||
@echo " test Run the tests" | ||
@echo " test/list List all tests under the tests directory" | ||
@echo " test/watch Automatically run tests every second" | ||
@echo " env/example Copy variables without the values from .env into .env.example" | ||
@echo " pre_commit/install Install the pre-commit hook" | ||
@echo " pre_commit/run Function that will be called when the pre-commit hook runs" | ||
@echo " sa Run shellcheck static analysis tool" | ||
@echo " lint Run editorconfig linter tool" | ||
|
||
SRC_SCRIPTS_DIR=src | ||
TEST_SCRIPTS_DIR=tests | ||
EXAMPLE_TEST_SCRIPTS=./example/logic_test.sh | ||
PRE_COMMIT_SCRIPTS_FILE=./bin/pre-commit | ||
|
||
TEST_SCRIPTS = $(wildcard $(TEST_SCRIPTS_DIR)/*/*[tT]est.sh) | ||
|
||
test/list: | ||
@echo "Test scripts found:" | ||
@echo $(TEST_SCRIPTS) | tr ' ' '\n' | ||
|
||
test: $(TEST_SCRIPTS) | ||
@lib/bashunit $(TEST_SCRIPTS) | ||
|
||
test/watch: $(TEST_SCRIPTS) | ||
@lib/bashunit $(TEST_SCRIPTS) | ||
@fswatch -m poll_monitor -or $(SRC_SCRIPTS_DIR) $(TEST_SCRIPTS_DIR) .env Makefile | xargs -n1 lib/bashunit $(TEST_SCRIPTS) | ||
|
||
env/example: | ||
@echo "Copying variables without the values from .env into .env.example" | ||
@sed 's/=.*/=/' .env > .env.example | ||
|
||
pre_commit/install: | ||
@echo "Installing pre-commit hook" | ||
cp $(PRE_COMMIT_SCRIPTS_FILE) $(GIT_DIR)/hooks/ | ||
|
||
pre_commit/run: test sa lint env/example | ||
|
||
sa: | ||
ifndef STATIC_ANALYSIS_CHECKER | ||
@printf "\e[1m\e[31m%s\e[0m\n" "Shellcheck not installed: Static analysis not performed!" && exit 1 | ||
else | ||
@shellcheck ./**/*.sh -C && printf "\e[1m\e[32m%s\e[0m\n" "ShellCheck: OK!" | ||
endif | ||
|
||
lint: | ||
ifndef LINTER_CHECKER | ||
@printf "\e[1m\e[31m%s\e[0m\n" "Editorconfig not installed: Lint not performed!" && exit 1 | ||
else | ||
@ec -config .editorconfig && printf "\e[1m\e[32m%s\e[0m\n" "editorconfig-check: OK!" | ||
endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,4 +9,4 @@ elif [[ "$(uname)" == "Darwin" ]]; then | |
_OS="OSX" | ||
elif [[ $(uname) == *"MINGW"* ]]; then | ||
_OS="Windows" | ||
fi | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters