From 0621ff4aec4b23f2578ebda89de989e81c4bdcad Mon Sep 17 00:00:00 2001 From: Danny Ben Shitrit Date: Fri, 31 Jan 2020 08:24:10 +0000 Subject: [PATCH 1/2] migrate to github actions and strip ansi colors due to github actions not being a tty ref: https://github.com/actions/runner/issues/241 --- .github/workflows/test.yml | 36 +++++++++++++++++++ .travis.yml => .travis.disabled.yml | 0 README.md | 2 +- lib/bashly/polyfills/hash.rb | 4 ++- spec/approvals/cli/add/colors | 3 +- spec/approvals/cli/add/config | 3 +- spec/approvals/cli/add/lib | 3 +- spec/approvals/cli/add/strings | 3 +- spec/approvals/cli/add/strings-exist | 2 +- spec/approvals/cli/add/yaml | 3 +- spec/approvals/cli/commands | 8 ++--- spec/approvals/cli/error | 5 ++- spec/approvals/cli/generate/minimal | 10 +++--- spec/approvals/cli/generate/no-args | 12 +++---- spec/approvals/cli/generate/no-args-skip | 12 +++---- spec/approvals/cli/init/minimal | 4 +-- spec/approvals/cli/init/no-args | 4 +-- spec/approvals/examples/colors | 18 +++++----- spec/approvals/examples/command-default | 12 +++---- spec/approvals/examples/command-groups | 16 ++++----- spec/approvals/examples/commands | 12 +++---- spec/approvals/examples/commands-nested | 16 ++++----- spec/approvals/examples/config-ini | 14 ++++---- spec/approvals/examples/custom-includes | 10 +++--- spec/approvals/examples/custom-strings | 10 +++--- spec/approvals/examples/dependencies | 12 +++---- spec/approvals/examples/docker-like | 14 ++++---- spec/approvals/examples/environment-variables | 10 +++--- spec/approvals/examples/git-like | 12 +++---- spec/approvals/examples/minimal | 10 +++--- spec/approvals/examples/minus-v | 10 +++--- spec/approvals/examples/multiline | 12 +++---- spec/approvals/examples/short-command-code | 12 +++---- spec/approvals/examples/yaml | 10 +++--- spec/spec_helper.rb | 3 +- 35 files changed, 180 insertions(+), 147 deletions(-) create mode 100644 .github/workflows/test.yml rename .travis.yml => .travis.disabled.yml (100%) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000..227db55d --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,36 @@ +name: Test +on: + pull_request: + push: { branches: master } + +jobs: + test: + name: Ruby ${{ matrix.ruby }} + + runs-on: ubuntu-latest + + strategy: + matrix: { ruby: ['2.4', '2.5', '2.6', '2.7'] } + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Cache gem dependencies + uses: actions/cache@v1 + with: + path: vendor/bundle + key: ${{ runner.os }}-${{ matrix.ruby }}-bundle + + - name: Setup Ruby + uses: actions/setup-ruby@v1 + with: { ruby-version: '${{ matrix.ruby }}' } + + - name: Bundle install + run: | + gem install bundler + bundle config path vendor/bundle + bundle install --jobs 4 --retry 3 + + - name: Run tests + run: bundle exec rspec diff --git a/.travis.yml b/.travis.disabled.yml similarity index 100% rename from .travis.yml rename to .travis.disabled.yml diff --git a/README.md b/README.md index f6cba90a..e9f7cd0f 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Bashly - Bash CLI Framework and Generator Create beautiful bash scripts from simple YAML configuration [![Gem Version](https://badge.fury.io/rb/bashly.svg)](https://badge.fury.io/rb/bashly) -[![Build Status](https://travis-ci.com/DannyBen/bashly.svg?branch=master)](https://travis-ci.com/DannyBen/bashly) +[![Build Status](https://github.com/DannyBen/bashly/workflows/Test/badge.svg)](https://github.com/DannyBen/bashly/actions?query=workflow%3ATest) [![Maintainability](https://api.codeclimate.com/v1/badges/8cf89047e50ca601e431/maintainability)](https://codeclimate.com/github/DannyBen/bashly/maintainability) --- diff --git a/lib/bashly/polyfills/hash.rb b/lib/bashly/polyfills/hash.rb index 64974738..02ad8f98 100644 --- a/lib/bashly/polyfills/hash.rb +++ b/lib/bashly/polyfills/hash.rb @@ -7,4 +7,6 @@ def self.empty?(path_name) exist?(path_name) && (entries(path_name) - ['.', '..']).empty? end end -end \ No newline at end of file +end + +# :nocov: \ No newline at end of file diff --git a/spec/approvals/cli/add/colors b/spec/approvals/cli/add/colors index f83c7bd3..affaa155 100644 --- a/spec/approvals/cli/add/colors +++ b/spec/approvals/cli/add/colors @@ -1,2 +1 @@ -created spec/tmp/src/lib/colors.sh - \ No newline at end of file +created spec/tmp/src/lib/colors.sh diff --git a/spec/approvals/cli/add/config b/spec/approvals/cli/add/config index 3d90442a..1e272ed5 100644 --- a/spec/approvals/cli/add/config +++ b/spec/approvals/cli/add/config @@ -1,2 +1 @@ -created spec/tmp/src/lib/config.sh - \ No newline at end of file +created spec/tmp/src/lib/config.sh diff --git a/spec/approvals/cli/add/lib b/spec/approvals/cli/add/lib index 4d3ace1c..bd5c0ef1 100644 --- a/spec/approvals/cli/add/lib +++ b/spec/approvals/cli/add/lib @@ -1,2 +1 @@ -created spec/tmp/src/lib/sample_function.sh - \ No newline at end of file +created spec/tmp/src/lib/sample_function.sh diff --git a/spec/approvals/cli/add/strings b/spec/approvals/cli/add/strings index 36e89d4c..feb73740 100644 --- a/spec/approvals/cli/add/strings +++ b/spec/approvals/cli/add/strings @@ -1,2 +1 @@ -created spec/tmp/src/bashly-strings.yml - \ No newline at end of file +created spec/tmp/src/bashly-strings.yml diff --git a/spec/approvals/cli/add/strings-exist b/spec/approvals/cli/add/strings-exist index db8a3620..95b1038f 100644 --- a/spec/approvals/cli/add/strings-exist +++ b/spec/approvals/cli/add/strings-exist @@ -1 +1 @@ -skipped spec/tmp/src/bashly-strings.yml (exists) +skipped spec/tmp/src/bashly-strings.yml (exists) diff --git a/spec/approvals/cli/add/yaml b/spec/approvals/cli/add/yaml index 1ba8b21b..a62a043f 100644 --- a/spec/approvals/cli/add/yaml +++ b/spec/approvals/cli/add/yaml @@ -1,2 +1 @@ -created spec/tmp/src/lib/yaml.sh - \ No newline at end of file +created spec/tmp/src/lib/yaml.sh diff --git a/spec/approvals/cli/commands b/spec/approvals/cli/commands index cc9ab636..b342fb9e 100644 --- a/spec/approvals/cli/commands +++ b/spec/approvals/cli/commands @@ -1,7 +1,7 @@ Bashly - Bash CLI Generator Commands: - init Initialize a new workspace - preview Generate the bash script to STDOUT - generate Generate the bash script and required files - add Add extra features and customization to your script + init Initialize a new workspace + preview Generate the bash script to STDOUT + generate Generate the bash script and required files + add Add extra features and customization to your script diff --git a/spec/approvals/cli/error b/spec/approvals/cli/error index 8f11e52f..bdcf3d0a 100644 --- a/spec/approvals/cli/error +++ b/spec/approvals/cli/error @@ -1,4 +1,3 @@ -Errno::ENOENT +Errno::ENOENT No such file or directory @ rb_sysopen - src/bashly.yml -creating user files in src - \ No newline at end of file +creating user files in src diff --git a/spec/approvals/cli/generate/minimal b/spec/approvals/cli/generate/minimal index 778c8497..79ed90dd 100644 --- a/spec/approvals/cli/generate/minimal +++ b/spec/approvals/cli/generate/minimal @@ -1,5 +1,5 @@ -creating user files in spec/tmp/src -created spec/tmp/src/initialize.sh -created spec/tmp/src/root_command.sh -created spec/tmp/download -run spec/tmp/download --help to test your bash script +creating user files in spec/tmp/src +created spec/tmp/src/initialize.sh +created spec/tmp/src/root_command.sh +created spec/tmp/download +run spec/tmp/download --help to test your bash script diff --git a/spec/approvals/cli/generate/no-args b/spec/approvals/cli/generate/no-args index f7571c37..fb706a92 100644 --- a/spec/approvals/cli/generate/no-args +++ b/spec/approvals/cli/generate/no-args @@ -1,6 +1,6 @@ -creating user files in spec/tmp/src -created spec/tmp/src/initialize.sh -created spec/tmp/src/download_command.sh -created spec/tmp/src/upload_command.sh -created spec/tmp/cli -run spec/tmp/cli --help to test your bash script +creating user files in spec/tmp/src +created spec/tmp/src/initialize.sh +created spec/tmp/src/download_command.sh +created spec/tmp/src/upload_command.sh +created spec/tmp/cli +run spec/tmp/cli --help to test your bash script diff --git a/spec/approvals/cli/generate/no-args-skip b/spec/approvals/cli/generate/no-args-skip index 134c7994..38ae2f36 100644 --- a/spec/approvals/cli/generate/no-args-skip +++ b/spec/approvals/cli/generate/no-args-skip @@ -1,6 +1,6 @@ -creating user files in spec/tmp/src -skipped spec/tmp/src/initialize.sh (exists) -skipped spec/tmp/src/download_command.sh (exists) -skipped spec/tmp/src/upload_command.sh (exists) -created spec/tmp/cli -run spec/tmp/cli --help to test your bash script +creating user files in spec/tmp/src +skipped spec/tmp/src/initialize.sh (exists) +skipped spec/tmp/src/download_command.sh (exists) +skipped spec/tmp/src/upload_command.sh (exists) +created spec/tmp/cli +run spec/tmp/cli --help to test your bash script diff --git a/spec/approvals/cli/init/minimal b/spec/approvals/cli/init/minimal index bfffe52b..82a02c6a 100644 --- a/spec/approvals/cli/init/minimal +++ b/spec/approvals/cli/init/minimal @@ -1,2 +1,2 @@ -created spec/tmp/src/bashly.yml -run bashly generate to create the bash script +created spec/tmp/src/bashly.yml +run bashly generate to create the bash script diff --git a/spec/approvals/cli/init/no-args b/spec/approvals/cli/init/no-args index bfffe52b..82a02c6a 100644 --- a/spec/approvals/cli/init/no-args +++ b/spec/approvals/cli/init/no-args @@ -1,2 +1,2 @@ -created spec/tmp/src/bashly.yml -run bashly generate to create the bash script +created spec/tmp/src/bashly.yml +run bashly generate to create the bash script diff --git a/spec/approvals/examples/colors b/spec/approvals/examples/colors index 156bb2b5..59dc42d2 100644 --- a/spec/approvals/examples/colors +++ b/spec/approvals/examples/colors @@ -1,13 +1,13 @@ + bashly generate -creating user files in src -skipped src/initialize.sh (exists) -skipped src/root_command.sh (exists) -created ./colorly -run ./colorly --help to test your bash script +creating user files in src +skipped src/initialize.sh (exists) +skipped src/root_command.sh (exists) +created ./colorly +run ./colorly --help to test your bash script + ./colorly -Message Recevied: +Message Recevied: - => hello colors - ==> hello colors - ===> hello colors + => hello colors + ==> hello colors + ===> hello colors diff --git a/spec/approvals/examples/command-default b/spec/approvals/examples/command-default index 495b46ef..fa935c19 100644 --- a/spec/approvals/examples/command-default +++ b/spec/approvals/examples/command-default @@ -1,10 +1,10 @@ + bashly generate -creating user files in src -created src/initialize.sh -created src/upload_command.sh -created src/download_command.sh -created ./ftp -run ./ftp --help to test your bash script +creating user files in src +created src/initialize.sh +created src/upload_command.sh +created src/download_command.sh +created ./ftp +run ./ftp --help to test your bash script + ./ftp ftp - Sample application that uses the default command option diff --git a/spec/approvals/examples/command-groups b/spec/approvals/examples/command-groups index 6957d7c3..c536b5eb 100644 --- a/spec/approvals/examples/command-groups +++ b/spec/approvals/examples/command-groups @@ -1,12 +1,12 @@ + bashly generate -creating user files in src -created src/initialize.sh -created src/download_command.sh -created src/upload_command.sh -created src/login_command.sh -created src/logout_command.sh -created ./ftp -run ./ftp --help to test your bash script +creating user files in src +created src/initialize.sh +created src/download_command.sh +created src/upload_command.sh +created src/login_command.sh +created src/logout_command.sh +created ./ftp +run ./ftp --help to test your bash script + ./ftp ftp - Sample application with command grouping diff --git a/spec/approvals/examples/commands b/spec/approvals/examples/commands index 89eb0819..fc818d78 100644 --- a/spec/approvals/examples/commands +++ b/spec/approvals/examples/commands @@ -1,10 +1,10 @@ + bashly generate -creating user files in src -created src/initialize.sh -created src/download_command.sh -created src/upload_command.sh -created ./cli -run ./cli --help to test your bash script +creating user files in src +created src/initialize.sh +created src/download_command.sh +created src/upload_command.sh +created ./cli +run ./cli --help to test your bash script + ./cli cli - Sample application diff --git a/spec/approvals/examples/commands-nested b/spec/approvals/examples/commands-nested index 8c674ad6..fe97f1a1 100644 --- a/spec/approvals/examples/commands-nested +++ b/spec/approvals/examples/commands-nested @@ -1,12 +1,12 @@ + bashly generate -creating user files in src -created src/initialize.sh -created src/dir_list_command.sh -created src/dir_remove_command.sh -created src/file_show_command.sh -created src/file_edit_command.sh -created ./cli -run ./cli --help to test your bash script +creating user files in src +created src/initialize.sh +created src/dir_list_command.sh +created src/dir_remove_command.sh +created src/file_show_command.sh +created src/file_edit_command.sh +created ./cli +run ./cli --help to test your bash script + ./cli cli - Sample application with nested commands diff --git a/spec/approvals/examples/config-ini b/spec/approvals/examples/config-ini index dbee6905..8c291b89 100644 --- a/spec/approvals/examples/config-ini +++ b/spec/approvals/examples/config-ini @@ -1,11 +1,11 @@ + bashly generate -creating user files in src -skipped src/initialize.sh (exists) -skipped src/set_command.sh (exists) -skipped src/get_command.sh (exists) -skipped src/list_command.sh (exists) -created ./configly -run ./configly --help to test your bash script +creating user files in src +skipped src/initialize.sh (exists) +skipped src/set_command.sh (exists) +skipped src/get_command.sh (exists) +skipped src/list_command.sh (exists) +created ./configly +run ./configly --help to test your bash script + ./configly -h configly - Sample application that uses the config functions diff --git a/spec/approvals/examples/custom-includes b/spec/approvals/examples/custom-includes index 229edecb..5c58d3a3 100644 --- a/spec/approvals/examples/custom-includes +++ b/spec/approvals/examples/custom-includes @@ -1,9 +1,9 @@ + bashly generate -creating user files in src -skipped src/initialize.sh (exists) -skipped src/root_command.sh (exists) -created ./download -run ./download --help to test your bash script +creating user files in src +skipped src/initialize.sh (exists) +skipped src/root_command.sh (exists) +created ./download +run ./download --help to test your bash script + ./download Before custom code --- diff --git a/spec/approvals/examples/custom-strings b/spec/approvals/examples/custom-strings index 6a894d98..46f7382f 100644 --- a/spec/approvals/examples/custom-strings +++ b/spec/approvals/examples/custom-strings @@ -1,9 +1,9 @@ + bashly generate -creating user files in src -created src/initialize.sh -created src/root_command.sh -created ./download -run ./download --help to test your bash script +creating user files in src +created src/initialize.sh +created src/root_command.sh +created ./download +run ./download --help to test your bash script + ./download Boom! a required argument is missing: SOURCE usage: download SOURCE [options] diff --git a/spec/approvals/examples/dependencies b/spec/approvals/examples/dependencies index 876d07f3..1335221f 100644 --- a/spec/approvals/examples/dependencies +++ b/spec/approvals/examples/dependencies @@ -1,10 +1,10 @@ + bashly generate -creating user files in src -skipped src/initialize.sh (exists) -skipped src/download_command.sh (exists) -skipped src/upload_command.sh (exists) -created ./cli -run ./cli --help to test your bash script +creating user files in src +skipped src/initialize.sh (exists) +skipped src/download_command.sh (exists) +skipped src/upload_command.sh (exists) +created ./cli +run ./cli --help to test your bash script + ./cli download missing dependency: shmurl + ./cli upload diff --git a/spec/approvals/examples/docker-like b/spec/approvals/examples/docker-like index b854c552..2a8fca91 100644 --- a/spec/approvals/examples/docker-like +++ b/spec/approvals/examples/docker-like @@ -1,11 +1,11 @@ + bashly generate -creating user files in src -created src/initialize.sh -created src/container_run_command.sh -created src/container_stop_command.sh -created src/image_ls_command.sh -created ./docker -run ./docker --help to test your bash script +creating user files in src +created src/initialize.sh +created src/container_run_command.sh +created src/container_stop_command.sh +created src/image_ls_command.sh +created ./docker +run ./docker --help to test your bash script + ./docker docker - Docker example diff --git a/spec/approvals/examples/environment-variables b/spec/approvals/examples/environment-variables index dc6c665a..552158d0 100644 --- a/spec/approvals/examples/environment-variables +++ b/spec/approvals/examples/environment-variables @@ -1,9 +1,9 @@ + bashly generate -creating user files in src -skipped src/initialize.sh (exists) -skipped src/verify_command.sh (exists) -created ./cli -run ./cli --help to test your bash script +creating user files in src +skipped src/initialize.sh (exists) +skipped src/verify_command.sh (exists) +created ./cli +run ./cli --help to test your bash script + ./cli cli - Sample application that requires environment variables diff --git a/spec/approvals/examples/git-like b/spec/approvals/examples/git-like index 543a35f1..9092b577 100644 --- a/spec/approvals/examples/git-like +++ b/spec/approvals/examples/git-like @@ -1,10 +1,10 @@ + bashly generate -creating user files in src -created src/initialize.sh -created src/status_command.sh -created src/commit_command.sh -created ./git -run ./git --help to test your bash script +creating user files in src +created src/initialize.sh +created src/status_command.sh +created src/commit_command.sh +created ./git +run ./git --help to test your bash script + ./git git - Git example diff --git a/spec/approvals/examples/minimal b/spec/approvals/examples/minimal index 9957f3b8..95d4ce9c 100644 --- a/spec/approvals/examples/minimal +++ b/spec/approvals/examples/minimal @@ -1,9 +1,9 @@ + bashly generate -creating user files in src -created src/initialize.sh -created src/root_command.sh -created ./download -run ./download --help to test your bash script +creating user files in src +created src/initialize.sh +created src/root_command.sh +created ./download +run ./download --help to test your bash script + ./download missing required argument: SOURCE usage: download SOURCE [TARGET] [options] diff --git a/spec/approvals/examples/minus-v b/spec/approvals/examples/minus-v index 47bb155e..be09bd0f 100644 --- a/spec/approvals/examples/minus-v +++ b/spec/approvals/examples/minus-v @@ -1,9 +1,9 @@ + bashly generate -creating user files in src -created src/initialize.sh -created src/root_command.sh -created ./cli -run ./cli --help to test your bash script +creating user files in src +created src/initialize.sh +created src/root_command.sh +created ./cli +run ./cli --help to test your bash script + ./cli # this file is located in 'src/root_command.sh' # you can edit it freely and regenerate (it will not be overwritten) diff --git a/spec/approvals/examples/multiline b/spec/approvals/examples/multiline index 00ff0176..c1ea2181 100644 --- a/spec/approvals/examples/multiline +++ b/spec/approvals/examples/multiline @@ -1,10 +1,10 @@ + bashly generate -creating user files in src -created src/initialize.sh -created src/multiline_command.sh -created src/regular_command.sh -created ./multi -run ./multi --help to test your bash script +creating user files in src +created src/initialize.sh +created src/multiline_command.sh +created src/regular_command.sh +created ./multi +run ./multi --help to test your bash script + ./multi multi - Multiline test diff --git a/spec/approvals/examples/short-command-code b/spec/approvals/examples/short-command-code index 24e3f551..920fe941 100644 --- a/spec/approvals/examples/short-command-code +++ b/spec/approvals/examples/short-command-code @@ -1,10 +1,10 @@ + bashly generate -creating user files in src -created src/initialize.sh -created src/config_command.sh -created src/get_command.sh -created ./rush -run ./rush --help to test your bash script +creating user files in src +created src/initialize.sh +created src/config_command.sh +created src/get_command.sh +created ./rush +run ./rush --help to test your bash script + ./rush c # this file is located in 'src/config_command.sh' # code for 'rush config' goes here diff --git a/spec/approvals/examples/yaml b/spec/approvals/examples/yaml index dd075290..84ba7061 100644 --- a/spec/approvals/examples/yaml +++ b/spec/approvals/examples/yaml @@ -1,9 +1,9 @@ + bashly generate -creating user files in src -skipped src/initialize.sh (exists) -skipped src/root_command.sh (exists) -created ./yaml -run ./yaml --help to test your bash script +creating user files in src +skipped src/initialize.sh (exists) +skipped src/root_command.sh (exists) +created ./yaml +run ./yaml --help to test your bash script + ./yaml -h yaml - Sample application that uses the YAML functions diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 3e48df64..530f78d0 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -17,9 +17,10 @@ reset_tmp_dir # Consistent Colsole output (for rspec_fixtures) -ENV['TTY'] = 'on' +ENV['TTY'] = 'off' RSpec.configure do |c| c.include SpecMixin c.fixtures_path = "spec/approvals" + c.strip_ansi_escape = true end From 222039bfde97e9cf8255183ab056614ebf3ad672 Mon Sep 17 00:00:00 2001 From: Danny Ben Shitrit Date: Fri, 31 Jan 2020 08:26:52 +0000 Subject: [PATCH 2/2] add shellcheck tests --- .github/workflows/test.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 227db55d..93b23b62 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -34,3 +34,6 @@ jobs: - name: Run tests run: bundle exec rspec + + - name: Run shellcheck tests + run: bundle exec run shellcheck