Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 102 additions & 0 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
name: Static Analysis
on:
pull_request:
push: { branches: master }

jobs:
static_analysis:
name: Run shellcheck and shfmt

runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

# Rush needed for easy installation of latest shfmt
- name: Install rush
run: curl -Ls http://get.dannyb.co/rush/setup | bash

- name: Connect rush repo
run: rush clone dannyben --shallow --default

- name: Install shfmt
run: rush get shfmt

# libyaml needed for Ruby's YAML library
- name: Install OS dependencies
run: sudo apt-get -y install libyaml-dev

- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.1'
bundler-cache: true

- name: Generate all examples
run: bundle exec run examples regen

- name: Generate all fixtures
run: bundle exec run fixtures regen

- name: Run shellcheck tests (examples)
run: bundle exec run shellcheck examples

- name: Run shellcheck tests (fixtures)
run: bundle exec run shellcheck fixtures

- name: Run shfmt tests (examples)
run: bundle exec run shfmt examples

- name: Run shfmt tests (fixtures)
run: bundle exec run shfmt fixtures

json_schema:
name: Validate JSON schemas

runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

# Rush needed for easy installation of check-jsonschema
- name: Install rush
run: curl -Ls http://get.dannyb.co/rush/setup | bash

- name: Connect rush repo
run: rush clone dannyben --shallow --default

- name: Install check-jsonschema
run: rush get check-jsonschema

# libyaml needed for Ruby's YAML library
- name: Install OS dependencies
run: sudo apt-get -y install libyaml-dev

- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.1'
bundler-cache: true

- name: Generate all subjects
run: bundle exec run examples regen

- name: Run schema tests
run: bundle exec run schema all

codespell:
name: Spell check

runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install OS dependencies
run: sudo apt-get -y install codespell

- name: Run codespell
run: codespell
88 changes: 0 additions & 88 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,94 +46,6 @@ jobs:
- name: Run tests
run: bundle exec rspec

static_analysis:
name: Example files static analysis

runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

# Rush needed for easy installation of latest shfmt
- name: Install rush
run: curl -Ls http://get.dannyb.co/rush/setup | bash

- name: Connect rush repo
run: rush clone dannyben --shallow --default

- name: Install shfmt
run: rush get shfmt

# libyaml needed for Ruby's YAML library
- name: Install OS dependencies
run: sudo apt-get -y install libyaml-dev

- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.1'
bundler-cache: true

- name: Generate all subjects
run: bundle exec run examples regen

- name: Run shellcheck tests
run: bundle exec run shellcheck

- name: Run shfmt tests
run: bundle exec run shfmt

json_schema:
name: JSON schemas validation

runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

# Rush needed for easy installation of check-jsonschema
- name: Install rush
run: curl -Ls http://get.dannyb.co/rush/setup | bash

- name: Connect rush repo
run: rush clone dannyben --shallow --default

- name: Install check-jsonschema
run: rush get check-jsonschema

# libyaml needed for Ruby's YAML library
- name: Install OS dependencies
run: sudo apt-get -y install libyaml-dev

- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.1'
bundler-cache: true

- name: Generate all subjects
run: bundle exec run examples regen

- name: Run schema tests
run: bundle exec run schema all

codespell:
name: Spell check

runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install OS dependencies
run: sudo apt-get -y install codespell

- name: Run codespell
run: codespell

docker:
name: Docker smoke test

Expand Down
1 change: 1 addition & 0 deletions lib/bashly/views/argument/validations.gtx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ if validate

if repeatable
> if [[ -v args['{{ name }}'] ]]; then
> values=''
> eval "values=(${args['{{ name }}']})"
> for value in "${values[@]}"; do
> if [[ -n $(validate_{{ validate }} "$value") ]]; then
Expand Down
6 changes: 5 additions & 1 deletion lib/bashly/views/command/normalize_input_function.gtx
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
= view_marker

> normalize_input() {
> local arg flags passthru
if Settings.compact_short_flags
> local arg passthru flags
else
> local arg passthru
end
> passthru=false
>
> while [[ $# -gt 0 ]]; do
Expand Down
2 changes: 2 additions & 0 deletions lib/bashly/views/command/whitelist_filter.gtx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ if whitelisted_args.any? or whitelisted_flags.any?

whitelisted_args.each do |arg|
if arg.repeatable
> input_array=''
> eval "input_array=(${args[{{ arg.name }}]})"
> for i in "${input_array[@]}"; do
> if [[ ! $i =~ ^({{ arg.allowed.join '|' }})$ ]]; then
Expand All @@ -22,6 +23,7 @@ if whitelisted_args.any? or whitelisted_flags.any?

whitelisted_flags.each do |flag|
if flag.repeatable
> input_array=''
> eval "input_array=(${args[{{ flag.name }}]})"
> for i in "${input_array[@]}"; do
> if [[ ! $i =~ ^({{ flag.allowed.join '|' }})$ ]]; then
Expand Down
1 change: 1 addition & 0 deletions lib/bashly/views/flag/validations.gtx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ if validate

if repeatable
> if [[ -v args['{{ long }}'] ]]; then
> values=''
> eval "values=(${args['{{ long }}']})"
> for value in "${values[@]}"; do
> if [[ -n $(validate_{{ validate }} "$value") ]]; then
Expand Down
1 change: 1 addition & 0 deletions runfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
require 'debug'
require 'bashly/version'
require_relative 'support/runfile/example'
require_relative 'support/runfile/workspace_fixture'

title 'Bashly Developer Toolbelt'
summary 'Runfile tasks for building the Bashly gem'
Expand Down
2 changes: 1 addition & 1 deletion spec/fixtures/workspaces/heredoc/src/root_command.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ SECOND_BLOCK
echo also unindented

echo "writing to file:"
cat << EOF > output.txt
cat <<EOF >output.txt
0 indentation
1 indentation
1 indentation
Expand Down
2 changes: 0 additions & 2 deletions spec/fixtures/workspaces/lib-custom-source/.gitignore

This file was deleted.

Loading