Add CI check for missing gitignore entries

Whenever we create a template sql file (*.sql.in) we should add the
respective .gitignore entry for the generated test files.

So added a CI check to check for missing gitignore entries for generated
test files.
This commit is contained in:
Fabrízio de Royes Mello 2023-04-04 15:39:38 -03:00
parent a383c8dd4f
commit a3d778f7a0
3 changed files with 23 additions and 1 deletions

View File

@ -100,7 +100,7 @@ jobs:
git diff --exit-code
misc_checks:
name: Check license, update scripts, and git hooks
name: Check license, update scripts, git hooks and missing gitignore entries
runs-on: ubuntu-22.04
strategy:
fail-fast: false
@ -121,3 +121,6 @@ jobs:
- name: Check update scripts
if: always()
run: ./scripts/check_update_scripts.sh
- name: Check for missing gitignore entries for template test files
if: always()
run: ./scripts/check_missing_gitignore_for_template_tests.sh

View File

@ -0,0 +1,18 @@
#!/bin/bash
ERROR=0
for FILE in $(git ls-files | grep '\.sql\.in')
do
DIRNAME=$(dirname "${FILE}")
FILENAME=$(basename "${FILE}" .sql.in)
GITIGNORE=${DIRNAME}/.gitignore
if [ -f "${GITIGNORE}" ]; then
if ! grep -F --silent -e "${FILENAME}-*.sql" "${GITIGNORE}"; then
echo "Missing entry in ${GITIGNORE} for template file ${FILE}"
ERROR=1
fi
fi
done
exit ${ERROR}

1
test/sql/.gitignore vendored
View File

@ -21,3 +21,4 @@
/query-*.sql
/rowsecurity-*.sql
/update-*.sql
/loader-*.sql