From a3d778f7a0313fca4ad86f64f9f32158011c8a0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabr=C3=ADzio=20de=20Royes=20Mello?= Date: Tue, 4 Apr 2023 15:39:38 -0300 Subject: [PATCH] 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. --- .github/workflows/code_style.yaml | 5 ++++- ...eck_missing_gitignore_for_template_tests.sh | 18 ++++++++++++++++++ test/sql/.gitignore | 1 + 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100755 scripts/check_missing_gitignore_for_template_tests.sh diff --git a/.github/workflows/code_style.yaml b/.github/workflows/code_style.yaml index 8dcb92d51..9127f58fe 100644 --- a/.github/workflows/code_style.yaml +++ b/.github/workflows/code_style.yaml @@ -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 diff --git a/scripts/check_missing_gitignore_for_template_tests.sh b/scripts/check_missing_gitignore_for_template_tests.sh new file mode 100755 index 000000000..acd0258c6 --- /dev/null +++ b/scripts/check_missing_gitignore_for_template_tests.sh @@ -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} diff --git a/test/sql/.gitignore b/test/sql/.gitignore index d4e6f5cdd..de49af45f 100644 --- a/test/sql/.gitignore +++ b/test/sql/.gitignore @@ -21,3 +21,4 @@ /query-*.sql /rowsecurity-*.sql /update-*.sql +/loader-*.sql