Skip to content

Commit

Permalink
add shellcheck
Browse files Browse the repository at this point in the history
  • Loading branch information
shyim committed Jan 24, 2024
1 parent 71424d6 commit e4e305a
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 16 deletions.
1 change: 0 additions & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ jobs:
fail-fast: false
matrix:
php-version:
- '8.0'
- '8.1'
- '8.2'
steps:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:

jobs:
check:
name: Test Image
runs-on: ubuntu-latest
steps:
- name: Set up Docker Buildx
Expand Down
19 changes: 19 additions & 0 deletions .github/workflows/shell-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Shellcheck
on:
pull_request:
paths:
- "rootfs/setup*"

permissions:
contents: read

jobs:
lint:
name: Shell Lint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Run ShellCheck
uses: ludeeus/action-shellcheck@master
9 changes: 6 additions & 3 deletions rootfs/setup
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
set -e
set -x

shopware_version=$(jq '.packages[] | select(.name == "shopware/core") | .version' -r < composer.lock)
shopware_version=$(jq '.packages[] | select (.name == "shopware/core") | .version' -r < composer.lock)
# if shopware version starts with 6.6 echo 6.6
# shellcheck disable=SC2081,SC3010
if [[ $shopware_version == v6.6.* ]]; then
source /setup_6.6.x
# shellcheck source=./setup_6.6.x
. /setup_6.6.x
else
source /setup_6.5.x
# shellcheck source=./setup_6.5.x
. /setup_6.5.x
fi
16 changes: 9 additions & 7 deletions rootfs/setup_6.5.x
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,22 @@
set -e
set -x

database_host=$(trurl $DATABASE_URL --get '{host}')
database_port=$(trurl $DATABASE_URL --get '{port}')
database_host=$(trurl "$DATABASE_URL" --get '{host}')
database_port=$(trurl "$DATABASE_URL" --get '{port}')

MYSQL_WAIT_SECONDS=${MYSQL_WAIT_SECONDS:-20}

try=0
if [[ $MYSQL_WAIT_SECONDS != 0 ]]; then
until nc -z -v -w30 $database_host ${database_port:-3306}
if [ "$MYSQL_WAIT_SECONDS" != 0 ]; then
until nc -z -v -w30 "$database_host" "${database_port:-3306}"
do
echo "Waiting for database connection..."
# wait for 5 seconds before check again
sleep 1

try=$((try+1))

if [[ $try -gt $MYSQL_WAIT_SECONDS ]]; then
if [ $try = "$MYSQL_WAIT_SECONDS" ]; then
echo "Error: We have been waiting for database connection too long already; failing."
exit 1
fi
Expand All @@ -31,15 +33,15 @@ update_all_plugins() {
list_with_updates=$(php bin/console plugin:list --json | jq 'map(select(.upgradeVersion != null)) | .[].name' -r)

for plugin in $list_with_updates; do
php -derror_reporting=E_ALL bin/console plugin:update $plugin
php -derror_reporting=E_ALL bin/console plugin:update "$plugin"
done
}

install_all_plugins() {
list_with_updates=$(php bin/console plugin:list --json | jq 'map(select(.installedAt == null)) | .[].name' -r)

for plugin in $list_with_updates; do
php -derror_reporting=E_ALL bin/console plugin:install --activate $plugin
php -derror_reporting=E_ALL bin/console plugin:install --activate "$plugin"
done
}

Expand Down
12 changes: 7 additions & 5 deletions rootfs/setup_6.6.x
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,22 @@
set -e
set -x

database_host=$(trurl $DATABASE_URL --get '{host}')
database_port=$(trurl $DATABASE_URL --get '{port}')
database_host=$(trurl "$DATABASE_URL" --get '{host}')
database_port=$(trurl "$DATABASE_URL" --get '{port}')

MYSQL_WAIT_SECONDS=${MYSQL_WAIT_SECONDS:-20}

try=0
if [[ $MYSQL_WAIT_SECONDS != 0 ]]; then
until nc -z -v -w30 $database_host ${database_port:-3306}
if [ "$MYSQL_WAIT_SECONDS" != 0 ]; then
until nc -z -v -w30 "$database_host" "${database_port:-3306}"
do
echo "Waiting for database connection..."
# wait for 5 seconds before check again
sleep 1

try=$((try+1))

if [[ $try -gt $MYSQL_WAIT_SECONDS ]]; then
if [ $try = "$MYSQL_WAIT_SECONDS" ]; then
echo "Error: We have been waiting for database connection too long already; failing."
exit 1
fi
Expand Down

0 comments on commit e4e305a

Please sign in to comment.