Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ruby hello world #269

Merged
merged 23 commits into from
Oct 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
27f038b
ruby: start track for october challenge
vpayno Oct 2, 2023
be77562
ruby(tools): add for_each script
vpayno Oct 2, 2023
954d1c8
ruby(tools): add submit_files script
vpayno Oct 2, 2023
587ebdd
ruby(tools): add update_readmes script
vpayno Oct 2, 2023
01327f3
ruby(ci): add wrapper scripts
vpayno Oct 3, 2023
8c0dcef
ruby(ci): add initial workflow
vpayno Oct 2, 2023
de3cc01
ruby(tools): add run-tests script
vpayno Oct 2, 2023
038573c
ruby(tools): add code coverage test edit to update_readmes script
vpayno Oct 3, 2023
31c996c
ruby/hello-world: download exercise
vpayno Oct 2, 2023
b4d9e79
ruby/hello-world: 1st iteration
vpayno Oct 2, 2023
24126db
ruby(tools): add gitignore file
vpayno Oct 3, 2023
f2242a8
ruby(tools): fix setup script
vpayno Oct 3, 2023
66d7287
ruby(tools): add track_errors() and use it in setup script to debug e…
vpayno Oct 3, 2023
3d1a518
ruby(tools): move rbenv-doctor call to after ruby is setup
vpayno Oct 3, 2023
93a4767
ruby(tools): move ruby-setup-verify fixes
vpayno Oct 4, 2023
e19d108
ruby(tools): add profile changes to /etc/skel
vpayno Oct 4, 2023
7468f7e
ruby(tools): profile/shell fixes for ci runs
vpayno Oct 4, 2023
8e35b46
ruby(tools): add rbenv version to show_tool_versions*() functions
vpayno Oct 4, 2023
86929a2
ruby(tools): use show_tool_versions_ruby_short() in test and lint scr…
vpayno Oct 4, 2023
3aea457
ruby(ci): coverage report to test wrapper script
vpayno Oct 5, 2023
87e1979
ruby(tools): add bc and xq to install script
vpayno Oct 5, 2023
fe209d1
ruby(ci): update var info step and add user info step
vpayno Oct 5, 2023
2562f2a
ruby(ci): xq is now included in the ci container
vpayno Oct 6, 2023
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
36 changes: 36 additions & 0 deletions .github/citools/includes/wrapper-library
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ run_command() {
# md_code_tag
} # run_command()

track_errors() {
((retval++))
printf "\nERROR: Failure detected in last command.\n"
} # track_errors()

print_ruler() {
printf "\n "
printf "=%.0s" {1..78}
Expand Down Expand Up @@ -115,3 +120,34 @@ show_tool_versions_go() {
# md_code_tag
printf "\n"
} # show_tool_versions_go()

show_tool_versions_ruby_short() {
# md_code_tag text
printf "Ruby version:\n"
printf "\n"
ruby --version | paste /dev/null -
rbenv --version | paste /dev/null -
# md_code_tag
printf "\n"
} # show_tool_versions_ruby_short()

show_tool_versions_ruby() {
# md_code_tag text
printf "Ruby version:\n"
printf "\n"
ruby --version | paste /dev/null -
rbenv --version | paste /dev/null -
# md_code_tag
printf "\n"

if [[ -z ${GITHUB_ACTIONS} ]]; then
return
fi

# md_code_tag text
printf "Installed Gem packages:\n"
printf "\n"
gem list | paste /dev/null -
# md_code_tag
printf "\n"
} # show_tool_versions_ruby()
28 changes: 28 additions & 0 deletions .github/citools/ruby/ruby-lint-rubycritic
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash
#
# .github/citools/ruby/ruby-lint-rubycritic
#

# shellcheck disable=SC1091
source ../../.github/citools/includes/wrapper-library || exit

declare -i retval=0

main() {
printf "\nRunning RubyCritic\n\n"

show_tool_versions_ruby_short

print_ruler

# https://github.com/whitesmith/rubycritic

run_command rubycritic --path .rubycritic --format console --no-browser . || ((retval++))

print_ruler

echo Exit code: "${retval}"
return "${retval}"
}

time main "${@}"
24 changes: 24 additions & 0 deletions .github/citools/ruby/ruby-setup-config
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash
#
# .github/citools/ruby/ruby-setup-config
#

# shellcheck disable=SC1091
source ../../.github/citools/includes/wrapper-library || exit

declare -i retval=0

main() {
printf "Setup Ruby Environment\n\n"

print_ruler

printf "%s\n" "${HOME}/.rbenv/bin" "${HOME}/.rbenv/shims" | tee -a "${GITHUB_PATH}"

print_ruler

echo Exit code: "${retval}"
return "${retval}"
}

time main "${@}"
126 changes: 126 additions & 0 deletions .github/citools/ruby/ruby-setup-install
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
#!/bin/bash
#
# .github/citools/ruby/ruby-setup-install
#

# shellcheck disable=SC1091
source ../../.github/citools/includes/wrapper-library || exit

declare -i retval=0

main() {
printf "Ruby Installation\n\n"

print_ruler

echo Running: sudo apt update
time sudo apt update || track_errors

print_ruler

local -a debs
debs=(
autoconf
automake
bison
bc
build-essential
curl
g++
gcc
git
gnupg
libc6-dev
libffi-dev
libgdbm-dev
libgmp-dev
libncurses5-dev
libreadline-dev
libsqlite3-dev
libssl-dev
libtool
libyaml-dev
make
pkg-config
sqlite3
zlib1g-dev
)

echo Running: sudo apt install -y "${debs[@]}"
time sudo apt install -y "${debs[@]}" || track_errors

print_ruler

echo Running: curl -fsSL https://github.com/rbenv/rbenv-installer/raw/HEAD/bin/rbenv-installer \| bash
time curl -fsSL https://github.com/rbenv/rbenv-installer/raw/HEAD/bin/rbenv-installer | bash || track_errors

print_ruler

echo Running: rbenv -v
time rbenv -v || track_errors

print_ruler

printf "Configuring Shell: "
# shellcheck disable=SC2016
{
echo 'export PATH="${HOME}/.rbenv/bin::${HOME}/.rbenv/bin/shims:${PATH}"' >>"${HOME}"/.bashrc
echo 'eval "$(rbenv init -)"' >>"${HOME}"/.bashrc
}
# shellcheck disable=SC1090
source "${HOME}"/.bashrc || track_errors
printf "done\n"

print_ruler

echo Running: rbenv install --list
time rbenv install --list || track_errors

print_ruler

local ruby_version
ruby_version="$(rbenv install --list 2>/dev/null | grep '^3[.][0-9][.]' | tail -n 1)" || track_errors

echo Running: rbenv install "${ruby_version}"
time rbenv install "${ruby_version}" || track_errors

print_ruler

echo Running: rbenv global "${ruby_version}"
time rbenv global "${ruby_version}" || track_errors

print_ruler

echo Running: ruby -v
time ruby -v || track_errors

print_ruler

local -a gems
gems=(
rspec
rspec-core
rspec-expectations
rspec-mocks
rspec-parameterized
rspec-support
rubycritic
simplecov
simplecov-cobertura
)

echo Running: gem install "${gems[@]}"
time gem install "${gems[@]}" || track_errors

print_ruler

echo Running: curl -fsSL https://github.com/rbenv/rbenv-installer/raw/HEAD/bin/rbenv-doctor \| bash
time curl -fsSL https://github.com/rbenv/rbenv-installer/raw/HEAD/bin/rbenv-doctor | bash || track_errors

print_ruler

echo Exit code: "${retval}"
return "${retval}"
}

time main "${@}"
58 changes: 58 additions & 0 deletions .github/citools/ruby/ruby-setup-verify
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/bin/bash
#
# .github/citools/ruby/ruby-setup-verify
#

# shellcheck disable=SC1091
source ../../.github/citools/includes/wrapper-library || exit

declare -i retval=0

declare -A ruby_cmds

ruby_cmds=(
[ruby]=$(
command -v ruby >&/dev/null
echo "$?"
)
[rubycritic]=$(
command -v rubycritic >&/dev/null
echo "$?"
)
)

main() {
printf "Verifying Ruby Installation\n\n"

print_ruler

printf "RBENV_SHELL=%s\n" "${RBENV_SHELL}"
printf "PATH=%s\n" "${PATH}"

print_ruler

echo Running: rbenv init -
time rbenv init -

for key in "${!ruby_cmds[@]}"; do
if [[ ${ruby_cmds[${key}]} -ne 0 ]]; then
printf "ERROR: command [%s] not found.\n" "${key}"
((retval++))
fi
done

if [[ ${retval} -ne 0 ]]; then
return "${retval}"
fi

print_ruler

show_tool_versions_ruby

print_ruler

echo Exit code: "${retval}"
return "${retval}"
}

time main "${@}"
40 changes: 40 additions & 0 deletions .github/citools/ruby/ruby-test-with-coverage
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/bash
#
# .github/citools/ruby/ruby-test-with-coverage
#

# shellcheck disable=SC1091
source ../../.github/citools/includes/wrapper-library || exit

declare -i retval=0

main() {
printf "\nRunning Ruby Tests With Coverage\n\n"

show_tool_versions_ruby_short

print_ruler

run_command rm -rf ./coverage

print_ruler

# https://github.com/simplecov-ruby/simplecov
# https://github.com/dashingrocket/simplecov-cobertura
# https://about.codecov.io/blog/getting-started-with-code-coverage-for-ruby/

run_command ruby ./*_test.rb -v || ((retval++))

print_ruler

local coverage_raw
coverage_raw="$(xq -q coverage -a line-rate ./coverage/coverage.xml)"
printf "Coverage: %.1f%%\n" "$(bc <<<"scale=1; ${coverage_raw}* 100")"

print_ruler

echo Exit code: "${retval}"
return "${retval}"
}

time main "${@}"
Loading
Loading