Skip to content

Commit

Permalink
Updated CI
Browse files Browse the repository at this point in the history
  • Loading branch information
ulises-jeremias committed Nov 25, 2022
1 parent 45af9ee commit a1f9924
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 27 deletions.
1 change: 1 addition & 0 deletions .github/workflows/docker-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jobs:
docker:
uses: ./.github/workflows/docker-publish.yml
with:
dockerfile: './.devcontainer/Dockerfile'
tags: ulisesjeremias/vsl:dev
build-args: |
DEV_IMG=true
4 changes: 2 additions & 2 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ on:
dockerfile:
description: 'The dockerfile to use'
type: string
required: true
required: false
default: './Dockerfile'
context:
description: 'The context to use'
type: string
required: true
required: false
default: '.'
build-args:
description: 'The build args to use'
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/docker-stable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ jobs:
docker-latest:
uses: ./.github/workflows/docker-publish.yml
with:
dockerfile: './Dockerfile'
tags: ulisesjeremias/vsl:latest
build-args: |
DEV_IMG=false
Expand All @@ -26,6 +27,7 @@ jobs:
- name: Docker Publish
uses: ./.github/workflows/docker-publish.yml
with:
dockerfile: './Dockerfile'
tags: ulisesjeremias/vsl:${{ env.GIT_TAG }}
build-args: |
DEV_IMG=false
2 changes: 1 addition & 1 deletion bin/docker
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

ROOT=$(dirname "$0")

source "${ROOT}/util/opts/opts.sh" || exit
source "${ROOT}/util/easyoptions/easyoptions.sh" || exit
source "${ROOT}/util/logs.sh" || exit

#==========================================
Expand Down
2 changes: 1 addition & 1 deletion bin/test
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

ROOT=$(dirname "$0")

source "${ROOT}/util/opts/opts.sh" || exit
source "${ROOT}/util/easyoptions/easyoptions.sh" || exit
source "${ROOT}/util/logs.sh" || exit

set -eo pipefail
Expand Down
50 changes: 28 additions & 22 deletions bin/util/opts/opts.sh → bin/util/easyoptions/easyoptions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,16 @@ parse_options() {
parse_documentation
while read -r line; do
case "$line" in
"-h, --help"*) continue ;;
"--help, -h"*) continue ;;
-*," "--*) option=$(echo "$line" | awk -F'(^-|, --| )' '{ print $2"="$3 }') ;;
--*," "-*) option=$(echo "$line" | awk -F'(--|, -| )' '{ print $3"="$2 }') ;;
--*=*) option=$(echo "$line" | awk -F'(--|=| )' '{ print $2"=?" }') ;;
--*" "*) option=$(echo "$line" | awk -F'(--| )' '{ print $2 }') ;;
*) continue ;;
"-h, --help"*) continue ;;
"--help, -h"*) continue ;;
-*," "--*) option=$(echo "$line" | awk -F'(^-|, --| )' '{ print $2"="$3 }') ;;
--*," "-*) option=$(echo "$line" | awk -F'(--|, -| )' '{ print $3"="$2 }') ;;
--*=*) option=$(echo "$line" | awk -F'(--|=| )' '{ print $2"=?" }') ;;
--*" "*) option=$(echo "$line" | awk -F'(--| )' '{ print $2 }') ;;
*) continue ;;
esac
options+=("$option")
done <<< "$documentation"
done <<<"$documentation"
fi

options+=(h=help)
Expand All @@ -106,10 +106,10 @@ parse_options() {
# Prepare known options
for option in "${options[@]}"; do
option_var=${option#*=}
option_name=${option%=$option_var}
option_name=${option%="$option_var"}
if [[ "${#option_name}" = "1" ]]; then
short_options="${short_options}${option_name}"
if [[ "${#option_var}" > "1" ]]; then
if [[ "${#option_var}" -gt "1" ]]; then
short_option_vars+=("$option_var")
fi
fi
Expand All @@ -123,7 +123,7 @@ parse_options() {
parameters+=("$argument")
for known_option in "${options[@]}"; do
known_option_var=${known_option#*=}
known_option_name=${known_option%=$known_option_var}
known_option_name=${known_option%="$known_option_var"}
if [[ "$known_option_var" = "?" && "$argument" = --$known_option_name ]]; then
next_is_value="yes"
break
Expand All @@ -149,7 +149,7 @@ parse_options() {
# Set the corresponding variable for known options
for known_option in "${options[@]}" "${short_option_vars[@]}"; do
known_option_var=${known_option#*=}
known_option_name=${known_option%=$known_option_var}
known_option_name=${known_option%="$known_option_var"}

# Short option
if [[ "$option" = "$known_option_name" ]]; then
Expand Down Expand Up @@ -186,25 +186,31 @@ parse_options() {

# Long option with unnecessary value
elif [[ "$option" = -$known_option_name=* && "$known_option_var" != "?" ]]; then
option_value=${option#*=}
show_error "--$known_option_name does not accept a value, you specified \"$option_value\""
exit 1
if [[ -z "${NO_CHECK}" ]]; then
option_value=${option#*=}
show_error "--$known_option_name does not accept a value, you specified \"$option_value\""
exit 1
fi
fi
done

# Unknown option
if [[ -z "$option_value" ]]; then
option=${option%%=*}
[[ "$option" = \?* ]] && option=${option#*\?}
show_error "unrecognized option -$option"
exit 1
if [[ -z "${NO_CHECK}" ]]; then
option=${option%%=*}
[[ "$option" = \?* ]] && option=${option#*\?}
show_error "unrecognized option -$option"
exit 1
fi
fi

# Help option
if [[ -n "$help" ]]; then
[[ -z "$documentation" ]] && parse_documentation
echo "$documentation"
exit
if [[ -z "${NO_HELP}" ]]; then
[[ -z "$documentation" ]] && parse_documentation
echo "$documentation"
exit
fi
fi
done
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
## format.

ROOT=$(dirname $0)
source "${ROOT}/opts.sh" || exit # Bash implementation, slower
source "${ROOT}/easy-options.sh" || exit # Bash implementation, slower

# Boolean and parameter options
[[ -n "$some_option" ]] && echo "Option specified: --some-option"
Expand Down

0 comments on commit a1f9924

Please sign in to comment.