diff --git a/.github/workflows/check_pending_sql.yml b/.github/workflows/check_pending_sql.yml index ddfe5b8e5..df0dca4f0 100644 --- a/.github/workflows/check_pending_sql.yml +++ b/.github/workflows/check_pending_sql.yml @@ -4,25 +4,8 @@ on: jobs: check-pending-sql: - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - name: Check for Procedure/Function - run: | - for i in `find data/sql/updates/pending* -name "*.sql" -type f`; do - if $(cat "$i"|sed "s/'.*'\(.*\)/\1/g"|grep -q -i -E "(PROCEDURE|FUNCTION)"); then - exit 1 - else - exit 0 - fi - done - - name: Semicolon check - run: | - for i in `find data/sql/updates/pending* -name "*.sql" -type f`; do - if [[ $(cat "$i"|sed 's/ --[^--]*$//'|tr -d '\n'|tr -d " "|tail -c 1) != ";" ]]; then - echo "Missing Semicolon (;) or multiple newlines at the end of the file." - exit 1 - else - exit 0 - fi - done + - name: Check pending SQL + run: source ./apps/ci/ci-pending.sh diff --git a/apps/ci/ci-pending.sh b/apps/ci/ci-pending.sh new file mode 100644 index 000000000..2b07719cb --- /dev/null +++ b/apps/ci/ci-pending.sh @@ -0,0 +1,35 @@ +#!/bin/bash +set -e + +echo "Pending SQL check script:" +echo + +for i in `find data/sql/updates/pending* -name "*.sql" -type f`; do + if $(cat "$i"|sed "s/'.*'\(.*\)/\1/g"|grep -q -i -E "(PROCEDURE|FUNCTION)"); then + echo "> PROCEDURE check - Failed" + exit 1 + else + echo "> PROCEDURE check - OK" + fi +done + +for i in `find data/sql/updates/pending* -name "*.sql" -type f`; do + if [[ $(cat "$i"|sed 's/ --[^--]*$//'|tr -d '\n'|tr -d " "|tail -c 1) != ";" ]]; then + echo "Missing Semicolon (;) or multiple newlines at the end of the file." + exit 1 + else + echo "> Semicolon check - OK" + fi +done + +for i in `find data/sql/updates/pending* -name "*.sql" -type f`; do + if $(cat "$i"|sed "s/'.*'\(.*\)/\1/g"|grep -q -i -E "version_db_"); then + echo "> version_db check - OK" + else + echo "> version_db check - Failed" + exit 1 + fi +done + +echo +echo "Everything looks good"